Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.WithCustomProto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.WithCustomProto
Commits
f781f9c4
Commit
f781f9c4
authored
May 06, 2022
by
NzSN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
0baae007
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
6 deletions
+32
-6
CMakeLists.txt
CMakeLists.txt
+2
-0
movMemProto.cc
src/proto/movMemProto.cc
+1
-1
utils.cc
src/utils.cc
+28
-4
ioctxTestCases.cc
tests/ioctxTestCases.cc
+1
-1
No files found.
CMakeLists.txt
View file @
f781f9c4
...
...
@@ -19,6 +19,8 @@ option(DEBUG "Only enable during development" OFF)
include_directories
(
${
INCLUDE
}
)
if
(
DEBUG
)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
message
(
"Fetching googletest..."
)
# Google Test
include
(
FetchContent
)
...
...
src/proto/movMemProto.cc
View file @
f781f9c4
...
...
@@ -48,7 +48,6 @@ int MovMemProto::read_packet_internal(void *priv, uint8_t *buf, int bufSize) {
trans
.
remain
=
0
;
}
printf
(
"Size %ld
\n
"
,
sizeToRead
);
return
sizeToRead
==
0
?
AVERROR
(
EAGAIN
)
:
sizeToRead
;
}
...
...
@@ -66,6 +65,7 @@ void MovMemProto::close_internal() {
while
(
!
s
.
empty
())
{
auto
mem
=
s
.
front
();
mem
.
data
=
nullptr
;
s
.
pop
();
}
}
...
...
src/utils.cc
View file @
f781f9c4
...
...
@@ -3,21 +3,37 @@
namespace
Utils
{
static
void
close_input_file
(
AVFormatContext
**
ctx_ptr
)
{
int
i
;
AVFormatContext
*
fmt_ctx
=
*
ctx_ptr
;
/* close decoder for each stream */
for
(
i
=
0
;
i
<
fmt_ctx
->
nb_streams
;
i
++
)
{
AVStream
*
stream
=
fmt_ctx
->
streams
[
i
];
avcodec_close
(
stream
->
codec
);
}
avformat_close_input
(
ctx_ptr
);
}
static
AVFormatContext
*
AVFormatInputContextConstructor
(
std
::
string
path
,
AVIOContext
*
customIO
)
{
const
char
*
filename
=
path
.
c_str
();
AVFormatContext
*
ctx
=
nullptr
;
if
(
customIO
!=
nullptr
)
{
ctx
=
avformat_alloc_context
();
ctx
->
pb
=
customIO
;
filename
=
nullptr
;
}
if
(
avformat_open_input
(
&
ctx
,
path
.
c_str
()
,
nullptr
,
nullptr
)
<
0
)
{
if
(
avformat_open_input
(
&
ctx
,
filename
,
nullptr
,
nullptr
)
<
0
)
{
return
nullptr
;
}
if
(
avformat_find_stream_info
(
ctx
,
nullptr
)
<
0
)
{
avformat_close_input
(
&
ctx
);
close_input_file
(
&
ctx
);
return
nullptr
;
}
...
...
@@ -25,7 +41,10 @@ static AVFormatContext* AVFormatInputContextConstructor(
}
static
void
AVFormatInputContextDestructor
(
AVFormatContext
*
ctx
)
{
avformat_close_input
(
&
ctx
);
if
(
ctx
!=
nullptr
)
{
std
::
cerr
<<
"Input DESTRUCTOR: "
<<
ctx
->
filename
<<
std
::
endl
;
avformat_close_input
(
&
ctx
);
}
}
AVFormatContextShared
makeInAVFormat
(
std
::
string
path
,
AVIOContext
*
customIO
)
{
...
...
@@ -56,7 +75,12 @@ static AVFormatContext* AVFormatOutputContextConstructor(
}
static
void
AVFormatOutputContextDestructor
(
AVFormatContext
*
ctx
)
{
avformat_close_input
(
&
ctx
);
std
::
cerr
<<
"Output DESTRUCTOR: "
<<
ctx
->
filename
<<
std
::
endl
;
if
(
ctx
!=
nullptr
)
{
if
(
ctx
->
pb
&&
strnlen
(
ctx
->
filename
,
1024
)
>
0
)
avio_close
(
ctx
->
pb
);
avformat_free_context
(
ctx
);
}
}
AVFormatContextShared
makeOutAVFormat
(
...
...
tests/ioctxTestCases.cc
View file @
f781f9c4
...
...
@@ -235,7 +235,7 @@ TEST_F(IOCTX_With_MovMem_Proto_Fixture, Initialize) {
t1
.
detach
();
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
1
00
));
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
5
00
));
inCtxMM
=
new
IOCtx
::
InCtx
(
""
,
mmProto
);
AVStream
*
s
=
inCtxMM
->
getStream
([](
AVStream
*
s
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment