From patchwork Sun Dec 4 13:36:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 1674 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.65.86 with SMTP id o83csp1176793vsa; Sun, 4 Dec 2016 05:37:18 -0800 (PST) X-Received: by 10.28.147.81 with SMTP id v78mr5701098wmd.60.1480858638432; Sun, 04 Dec 2016 05:37:18 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id rk19si11744364wjb.69.2016.12.04.05.37.17; Sun, 04 Dec 2016 05:37:18 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D5115689F68; Sun, 4 Dec 2016 15:37:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 46A6F689E72 for ; Sun, 4 Dec 2016 15:36:57 +0200 (EET) X-QQ-mid: bizesmtp13t1480858597t32cp575 Received: from localhost (unknown [58.96.181.81]) by esmtp4.qq.com (ESMTP) with id ; Sun, 04 Dec 2016 21:36:34 +0800 (CST) X-QQ-SSF: 01100000003000F0F610B00A0000000 X-QQ-FEAT: oIoGrveFQB/c5xlZfXgu8QwD90235v6HPoxX8AM9M+lMeFKExOkgZaGamtQ/5 EC4GKbfVGjHBGIEntGW2oGGZdRQUQQ9nCt37P7U77SBdCJmfS/JmszY27s1VLKxtT8ieoMi ouG+QxOcjCSb6fcv4irAricDZtteETixLpEBrGpl3sK5NEsx72k6roXZqkpB8oFRXJDZw6K TYeq/9csw477htcmSMg56cP5rv2aCkjH5xM5Jqhmx4W4lm2fjOhip0ieqdB575HED3cRi3W rnPA== X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Sun, 4 Dec 2016 21:36:29 +0800 Message-Id: <20161204133629.535-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.10.1.382.ga23ca1b.dirty X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix ticket id 5988 for DISCONTINUITY X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steven Liu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" add EXT-X-DISCONTINUITY tag at the position of the append point. Signed-off-by: Steven Liu --- 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");