diff options
author | Willy Aubry <waubry@viotech.net> | 2014-02-05 17:59:00 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-03-03 19:46:22 +0400 |
commit | 65c95de213d9fcf3f06513bcb9ce6ed5396fa75d (patch) | |
tree | 8b1052c25b50b09cb7ef5cfa0f0d66cb286f4bee /libavformat/segment.c | |
parent | 40feed524854eeaff67860e8932f792a0e373c8a (diff) |
avformat/HLS: modified EXT-X-MEDIA-SEQUENCE header in order to follow the HLS standard
When using the wrap option the EXT-X-MEDIA-SEQUENCE header of the playlist file was reset instead of being incremented.
It is now incremented by one for every media URI removed from the playlist file as the standard states.
Signed-off-by: Willy Aubry <waubry@viotech.net>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/segment.c')
-rw-r--r-- | libavformat/segment.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libavformat/segment.c b/libavformat/segment.c index ad313a316f..3568d2a0de 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -65,6 +65,7 @@ typedef struct { const AVClass *class; /**< Class for private options. */ int segment_idx; ///< index of the segment file to write, starting from 0 int segment_idx_wrap; ///< number after which the index wraps + int segment_idx_wrap_nb; ///< number of time the index has wraped int segment_count; ///< number of segment files already written AVOutputFormat *oformat; AVFormatContext *avf; @@ -199,6 +200,9 @@ static int segment_start(AVFormatContext *s, int write_header) } seg->segment_idx++; + if ((seg->segment_idx_wrap) && (seg->segment_idx%seg->segment_idx_wrap == 0)) + seg->segment_idx_wrap_nb++; + if ((err = set_segment_filename(s)) < 0) return err; @@ -689,7 +693,7 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt) if ((ret = segment_start(s, seg->individual_header_trailer)) < 0) goto fail; - seg->cur_entry.index = seg->segment_idx; + seg->cur_entry.index = seg->segment_idx + seg->segment_idx_wrap*seg->segment_idx_wrap_nb; seg->cur_entry.start_time = (double)pkt->pts * av_q2d(st->time_base); seg->cur_entry.start_pts = av_rescale_q(pkt->pts, st->time_base, AV_TIME_BASE_Q); } else if (pkt->pts != AV_NOPTS_VALUE) { @@ -795,6 +799,7 @@ static const AVOption options[] = { { "segment_frames", "set segment split frame numbers", OFFSET(frames_str),AV_OPT_TYPE_STRING,{.str = NULL}, 0, 0, E }, { "segment_wrap", "set number after which the index wraps", OFFSET(segment_idx_wrap), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E }, { "segment_start_number", "set the sequence number of the first segment", OFFSET(segment_idx), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E }, + { "segment_wrap_number", "set the number of wrap before the first segment", OFFSET(segment_idx_wrap_nb), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E }, { "individual_header_trailer", "write header/trailer to each segment", OFFSET(individual_header_trailer), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E }, { "write_header_trailer", "write a header to the first segment and a trailer to the last one", OFFSET(write_header_trailer), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E }, |