diff options
author | MrBoogs <blendz@shaw.ca> | 2015-04-21 15:52:03 -0600 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-05-17 17:14:00 +0200 |
commit | 572a8292cbded93c64110b872d2a8abadc92b741 (patch) | |
tree | 132b5aeb37fe37f86c168418fe6d8e6a73e7bc27 /libavformat/hlsenc.c | |
parent | 8fd01b4a794c1e5fd3888256b816b30023a2d856 (diff) | |
download | ffmpeg-572a8292cbded93c64110b872d2a8abadc92b741.tar.gz |
avformat/hlsenc: Add hls flag for starting a playlist with a discontinuity on startup
Reviewed-by: Thomas Volkert <silvo@gmx.net>
Diffstat (limited to 'libavformat/hlsenc.c')
-rw-r--r-- | libavformat/hlsenc.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index dcb718a976..f23a89174b 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -51,6 +51,7 @@ typedef enum HLSFlags { HLS_SINGLE_FILE = (1 << 0), HLS_DELETE_SEGMENTS = (1 << 1), HLS_ROUND_DURATIONS = (1 << 2), + HLS_DISCONT_START = (1 << 3), } HLSFlags; typedef struct HLSContext { @@ -77,6 +78,7 @@ typedef struct HLSContext { int64_t start_pos; // last segment starting position int64_t size; // last segment size int nb_entries; + int discontinuity_set; HLSSegment *segments; HLSSegment *last_segment; @@ -263,6 +265,7 @@ static int hls_window(AVFormatContext *s, int last) target_duration = ceil(en->duration); } + hls->discontinuity_set = 0; avio_printf(out, "#EXTM3U\n"); avio_printf(out, "#EXT-X-VERSION:%d\n", version); if (hls->allowcache == 0 || hls->allowcache == 1) { @@ -273,7 +276,10 @@ static int hls_window(AVFormatContext *s, int last) av_log(s, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence); - + if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && hls->discontinuity_set==0 ){ + avio_printf(out, "#EXT-X-DISCONTINUITY\n"); + hls->discontinuity_set = 1; + } for (en = hls->segments; en; en = en->next) { if (hls->flags & HLS_ROUND_DURATIONS) avio_printf(out, "#EXTINF:%d,\n", (int)round(en->duration)); @@ -517,7 +523,7 @@ static const AVOption options[] = { {"single_file", "generate a single media file indexed with byte ranges", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SINGLE_FILE }, 0, UINT_MAX, E, "flags"}, {"delete_segments", "delete segment files that are no longer part of the playlist", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_DELETE_SEGMENTS }, 0, UINT_MAX, E, "flags"}, {"round_durations", "round durations in m3u8 to whole numbers", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_ROUND_DURATIONS }, 0, UINT_MAX, E, "flags"}, - + {"discont_start", "start the playlist with a discontinuity tag", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_DISCONT_START }, 0, UINT_MAX, E, "flags"}, { NULL }, }; |