From patchwork Fri May 5 16:50:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 3578 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp104179vsd; Fri, 5 May 2017 01:53:08 -0700 (PDT) X-Received: by 10.223.166.66 with SMTP id k60mr29701917wrc.139.1493974387966; Fri, 05 May 2017 01:53:07 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n138si2033334wmd.71.2017.05.05.01.53.07; Fri, 05 May 2017 01:53:07 -0700 (PDT) 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 27F7A689A86; Fri, 5 May 2017 11:53:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbg291.qq.com (smtpbg291.qq.com [113.108.11.223]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A4B626899DC for ; Fri, 5 May 2017 11:52:52 +0300 (EEST) X-QQ-mid: bizesmtp3t1493974250tn7ohyl0z Received: from localhost (unknown [114.255.44.132]) by esmtp4.qq.com (ESMTP) with id ; Fri, 05 May 2017 16:50:50 +0800 (CST) X-QQ-SSF: 01100000002000F0FF30B00A0000000 X-QQ-FEAT: pBpCf8MqS+tkD9cxVEdcCaJFO5xPeu+0VW4Oebz0Z+fu2V3olzGQDT0faaDmm ahEqoMkbAJUw8U/WWFxpCz8TJXcdral5c6NKaMxt9V9DcVdHhQ3OU+l5QHTjISGnKKiOmEr teCamtkuKOnpBNsmXiBEf6QwiE9Mf4OOCm6PY0p4SSzsvedb5aoBZECCn8JLCzqmmWAay8p Ym8kU8vJCxa8IJVnWFpeS0uWkc1NqVzLBrdFoLDe3EKei7v7+9kZ3zNWdifYgDxerbNO1Yx OQ04Vw50YtnZWxmRp8+tlqIfs= X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Sat, 6 May 2017 00:50:45 +0800 Message-Id: <20170505165045.4154-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.13.0.rc2 X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: support TAG span multiple lines when parse playlist 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" refer to: https://developer.apple.com/library/content/technotes/tn2288/_index.html support to parse the EXT-X-KEY span multiple lines: #EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:10 #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-KEY:METHOD=AES-128,URI="/file.key", \ IV=0x498c8325965f907960e3d94d20c4d138 #EXTINF:10.000000, out0.ts #EXTINF:8.640000, out1.ts #EXTINF:9.160000, out2.ts Reported-by: Aaron Levinson Signed-off-by: Steven Liu --- libavformat/hlsenc.c | 21 +++++++++++++++++++-- 1 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 221089c..c167624 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -500,10 +500,27 @@ static int hls_encryption_start(AVFormatContext *s) static int read_chomp_line(AVIOContext *s, char *buf, int maxlen) { - int len = ff_get_line(s, buf, maxlen); + int len = 0; + int total_len = 0; + +re_get_line: + if (maxlen > total_len) { + len = ff_get_line(s, buf, maxlen - total_len); + } else { + av_log(s, AV_LOG_WARNING, "The tag is too long, context only can get %s\n", buf); + return maxlen; + } while (len > 0 && av_isspace(buf[len - 1])) buf[--len] = '\0'; - return len; + + if (buf[len - 1] == '\\') { + buf += len - 1; + total_len += len - 1; + goto re_get_line; + } + + total_len += len; + return total_len; } static int hls_mux_init(AVFormatContext *s)