[FFmpeg-devel] [PATCH] avformat/hlsenc: fix ticket id 5988 for DISCONTINUITY
Steven Liu
lingjiujianke at gmail.com
Mon Dec 5 11:57:04 EET 2016
2016-12-04 21:36 GMT+08:00 Steven Liu <lq at chinaffmpeg.org>:
> add EXT-X-DISCONTINUITY tag at the position of the append point.
>
> Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
> ---
> libavformat/hlsenc.c | 14 ++++++++++++++
> 1 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index e16fb0c..0e55a31 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");
> --
> 1.7.1
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
applied!
Thanks
More information about the ffmpeg-devel
mailing list