Commit 572a8292 authored by MrBoogs's avatar MrBoogs Committed by Michael Niedermayer

avformat/hlsenc: Add hls flag for starting a playlist with a discontinuity on startup

Reviewed-by: 's avatarThomas Volkert <silvo@gmx.net>
parent 8fd01b4a
......@@ -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 },
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment