Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
c7cd6ad8
Unverified
Commit
c7cd6ad8
authored
Apr 08, 2016
by
Rodger Combs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf/segment: add deinit function
parent
a246fef1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
27 deletions
+20
-27
segment.c
libavformat/segment.c
+20
-27
No files found.
libavformat/segment.c
View file @
c7cd6ad8
...
@@ -627,8 +627,9 @@ static int select_reference_stream(AVFormatContext *s)
...
@@ -627,8 +627,9 @@ static int select_reference_stream(AVFormatContext *s)
return
0
;
return
0
;
}
}
static
void
seg_free
_context
(
SegmentContext
*
seg
)
static
void
seg_free
(
AVFormatContext
*
s
)
{
{
SegmentContext
*
seg
=
s
->
priv_data
;
ff_format_io_close
(
seg
->
avf
,
&
seg
->
list_pb
);
ff_format_io_close
(
seg
->
avf
,
&
seg
->
list_pb
);
avformat_free_context
(
seg
->
avf
);
avformat_free_context
(
seg
->
avf
);
seg
->
avf
=
NULL
;
seg
->
avf
=
NULL
;
...
@@ -693,7 +694,7 @@ static int seg_init(AVFormatContext *s)
...
@@ -693,7 +694,7 @@ static int seg_init(AVFormatContext *s)
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Could not parse format options list '%s'
\n
"
,
av_log
(
s
,
AV_LOG_ERROR
,
"Could not parse format options list '%s'
\n
"
,
seg
->
format_options_str
);
seg
->
format_options_str
);
goto
fail
;
return
ret
;
}
}
}
}
...
@@ -707,7 +708,7 @@ static int seg_init(AVFormatContext *s)
...
@@ -707,7 +708,7 @@ static int seg_init(AVFormatContext *s)
}
}
if
(
!
seg
->
list_size
&&
seg
->
list_type
!=
LIST_TYPE_M3U8
)
{
if
(
!
seg
->
list_size
&&
seg
->
list_type
!=
LIST_TYPE_M3U8
)
{
if
((
ret
=
segment_list_open
(
s
))
<
0
)
if
((
ret
=
segment_list_open
(
s
))
<
0
)
goto
fail
;
return
ret
;
}
else
{
}
else
{
const
char
*
proto
=
avio_find_protocol_name
(
seg
->
list
);
const
char
*
proto
=
avio_find_protocol_name
(
seg
->
list
);
seg
->
use_rename
=
proto
&&
!
strcmp
(
proto
,
"file"
);
seg
->
use_rename
=
proto
&&
!
strcmp
(
proto
,
"file"
);
...
@@ -718,29 +719,26 @@ static int seg_init(AVFormatContext *s)
...
@@ -718,29 +719,26 @@ static int seg_init(AVFormatContext *s)
av_log
(
s
,
AV_LOG_WARNING
,
"'ext' list type option is deprecated in favor of 'csv'
\n
"
);
av_log
(
s
,
AV_LOG_WARNING
,
"'ext' list type option is deprecated in favor of 'csv'
\n
"
);
if
((
ret
=
select_reference_stream
(
s
))
<
0
)
if
((
ret
=
select_reference_stream
(
s
))
<
0
)
goto
fail
;
return
ret
;
av_log
(
s
,
AV_LOG_VERBOSE
,
"Selected stream id:%d type:%s
\n
"
,
av_log
(
s
,
AV_LOG_VERBOSE
,
"Selected stream id:%d type:%s
\n
"
,
seg
->
reference_stream_index
,
seg
->
reference_stream_index
,
av_get_media_type_string
(
s
->
streams
[
seg
->
reference_stream_index
]
->
codecpar
->
codec_type
));
av_get_media_type_string
(
s
->
streams
[
seg
->
reference_stream_index
]
->
codecpar
->
codec_type
));
seg
->
oformat
=
av_guess_format
(
seg
->
format
,
s
->
filename
,
NULL
);
seg
->
oformat
=
av_guess_format
(
seg
->
format
,
s
->
filename
,
NULL
);
if
(
!
seg
->
oformat
)
{
if
(
!
seg
->
oformat
)
ret
=
AVERROR_MUXER_NOT_FOUND
;
return
AVERROR_MUXER_NOT_FOUND
;
goto
fail
;
}
if
(
seg
->
oformat
->
flags
&
AVFMT_NOFILE
)
{
if
(
seg
->
oformat
->
flags
&
AVFMT_NOFILE
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"format %s not supported.
\n
"
,
av_log
(
s
,
AV_LOG_ERROR
,
"format %s not supported.
\n
"
,
seg
->
oformat
->
name
);
seg
->
oformat
->
name
);
ret
=
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
goto
fail
;
}
}
if
((
ret
=
segment_mux_init
(
s
))
<
0
)
if
((
ret
=
segment_mux_init
(
s
))
<
0
)
goto
fail
;
return
ret
;
if
((
ret
=
set_segment_filename
(
s
))
<
0
)
if
((
ret
=
set_segment_filename
(
s
))
<
0
)
goto
fail
;
return
ret
;
oc
=
seg
->
avf
;
oc
=
seg
->
avf
;
if
(
seg
->
write_header_trailer
)
{
if
(
seg
->
write_header_trailer
)
{
...
@@ -748,13 +746,13 @@ static int seg_init(AVFormatContext *s)
...
@@ -748,13 +746,13 @@ static int seg_init(AVFormatContext *s)
seg
->
header_filename
?
seg
->
header_filename
:
oc
->
filename
,
seg
->
header_filename
?
seg
->
header_filename
:
oc
->
filename
,
AVIO_FLAG_WRITE
,
NULL
))
<
0
)
{
AVIO_FLAG_WRITE
,
NULL
))
<
0
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Failed to open segment '%s'
\n
"
,
oc
->
filename
);
av_log
(
s
,
AV_LOG_ERROR
,
"Failed to open segment '%s'
\n
"
,
oc
->
filename
);
goto
fail
;
return
ret
;
}
}
if
(
!
seg
->
individual_header_trailer
)
if
(
!
seg
->
individual_header_trailer
)
oc
->
pb
->
seekable
=
0
;
oc
->
pb
->
seekable
=
0
;
}
else
{
}
else
{
if
((
ret
=
open_null_ctx
(
&
oc
->
pb
))
<
0
)
if
((
ret
=
open_null_ctx
(
&
oc
->
pb
))
<
0
)
goto
fail
;
return
ret
;
}
}
av_dict_copy
(
&
options
,
seg
->
format_options
,
0
);
av_dict_copy
(
&
options
,
seg
->
format_options
,
0
);
...
@@ -762,13 +760,14 @@ static int seg_init(AVFormatContext *s)
...
@@ -762,13 +760,14 @@ static int seg_init(AVFormatContext *s)
if
(
av_dict_count
(
options
))
{
if
(
av_dict_count
(
options
))
{
av_log
(
s
,
AV_LOG_ERROR
,
av_log
(
s
,
AV_LOG_ERROR
,
"Some of the provided format options in '%s' are not recognized
\n
"
,
seg
->
format_options_str
);
"Some of the provided format options in '%s' are not recognized
\n
"
,
seg
->
format_options_str
);
ret
=
AVERROR
(
EINVAL
);
av_dict_free
(
&
options
);
goto
fail
;
return
AVERROR
(
EINVAL
)
;
}
}
av_dict_free
(
&
options
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
ff_format_io_close
(
oc
,
&
oc
->
pb
);
ff_format_io_close
(
oc
,
&
oc
->
pb
);
goto
fail
;
return
ret
;
}
}
seg
->
segment_frame_count
=
0
;
seg
->
segment_frame_count
=
0
;
...
@@ -790,17 +789,12 @@ static int seg_init(AVFormatContext *s)
...
@@ -790,17 +789,12 @@ static int seg_init(AVFormatContext *s)
close_null_ctxp
(
&
oc
->
pb
);
close_null_ctxp
(
&
oc
->
pb
);
}
}
if
((
ret
=
oc
->
io_open
(
oc
,
&
oc
->
pb
,
oc
->
filename
,
AVIO_FLAG_WRITE
,
NULL
))
<
0
)
if
((
ret
=
oc
->
io_open
(
oc
,
&
oc
->
pb
,
oc
->
filename
,
AVIO_FLAG_WRITE
,
NULL
))
<
0
)
goto
fail
;
return
ret
;
if
(
!
seg
->
individual_header_trailer
)
if
(
!
seg
->
individual_header_trailer
)
oc
->
pb
->
seekable
=
0
;
oc
->
pb
->
seekable
=
0
;
}
}
fail:
return
0
;
av_dict_free
(
&
options
);
if
(
ret
<
0
)
seg_free_context
(
seg
);
return
ret
;
}
}
static
int
seg_write_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
static
int
seg_write_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
...
@@ -913,9 +907,6 @@ fail:
...
@@ -913,9 +907,6 @@ fail:
seg
->
segment_frame_count
++
;
seg
->
segment_frame_count
++
;
}
}
if
(
ret
<
0
)
seg_free_context
(
seg
);
return
ret
;
return
ret
;
}
}
...
@@ -1023,6 +1014,7 @@ AVOutputFormat ff_segment_muxer = {
...
@@ -1023,6 +1014,7 @@ AVOutputFormat ff_segment_muxer = {
.
init
=
seg_init
,
.
init
=
seg_init
,
.
write_packet
=
seg_write_packet
,
.
write_packet
=
seg_write_packet
,
.
write_trailer
=
seg_write_trailer
,
.
write_trailer
=
seg_write_trailer
,
.
deinit
=
seg_free
,
.
priv_class
=
&
seg_class
,
.
priv_class
=
&
seg_class
,
};
};
...
@@ -1041,5 +1033,6 @@ AVOutputFormat ff_stream_segment_muxer = {
...
@@ -1041,5 +1033,6 @@ AVOutputFormat ff_stream_segment_muxer = {
.
init
=
seg_init
,
.
init
=
seg_init
,
.
write_packet
=
seg_write_packet
,
.
write_packet
=
seg_write_packet
,
.
write_trailer
=
seg_write_trailer
,
.
write_trailer
=
seg_write_trailer
,
.
deinit
=
seg_free
,
.
priv_class
=
&
sseg_class
,
.
priv_class
=
&
sseg_class
,
};
};
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