diff options
author | Steven Liu <lq@chinaffmpeg.org> | 2016-12-05 17:55:33 +0800 |
---|---|---|
committer | Steven Liu <lq@chinaffmpeg.org> | 2016-12-05 17:55:33 +0800 |
commit | 55affd95bd9b3212dc505aec67f9be58d519b4fe (patch) | |
tree | 158390a30c72041d992809694fd38bf195bb2ae2 /libavformat/hlsenc.c | |
parent | 1f5630af51f24d79053b6bef5b8b3ba93d637306 (diff) | |
download | ffmpeg-55affd95bd9b3212dc505aec67f9be58d519b4fe.tar.gz |
avformat/hlsenc: fix ticket id 5988 for DISCONTINUITY
add EXT-X-DISCONTINUITY tag at the position of the append point.
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Diffstat (limited to 'libavformat/hlsenc.c')
-rw-r--r-- | libavformat/hlsenc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index e16fb0caa9..0e55a312b9 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -46,6 +46,7 @@ typedef struct HLSSegment { char filename[1024]; char sub_filename[1024]; double duration; /* in seconds */ + int discont; int64_t pos; int64_t size; @@ -107,6 +108,7 @@ typedef struct HLSContext { int64_t max_seg_size; // every segment file max size int nb_entries; int discontinuity_set; + int discontinuity; HLSSegment *segments; HLSSegment *last_segment; @@ -387,6 +389,12 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, double en->pos = pos; en->size = size; en->next = NULL; + en->discont = 0; + + if (hls->discontinuity) { + en->discont = 1; + hls->discontinuity = 0; + } if (hls->key_info_file) { av_strlcpy(en->key_uri, hls->key_uri, sizeof(en->key_uri)); @@ -446,6 +454,7 @@ static int parse_playlist(AVFormatContext *s, const char *url) goto fail; } + hls->discontinuity = 0; while (!avio_feof(in)) { read_chomp_line(in, line, sizeof(line)); if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) { @@ -560,6 +569,10 @@ static int hls_window(AVFormatContext *s, int last) iv_string = en->iv_string; } + if (en->discont) { + avio_printf(out, "#EXT-X-DISCONTINUITY\n"); + } + if (hls->flags & HLS_ROUND_DURATIONS) avio_printf(out, "#EXTINF:%ld,\n", lrint(en->duration)); else @@ -883,6 +896,7 @@ static int hls_write_header(AVFormatContext *s) if (hls->flags & HLS_APPEND_LIST) { parse_playlist(s, s->filename); + hls->discontinuity = 1; if (hls->init_time > 0) { av_log(s, AV_LOG_WARNING, "append_list mode does not support hls_init_time," " hls_init_time value will have no effect\n"); |