From patchwork Wed Apr 12 23:43:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Hunt X-Patchwork-Id: 3381 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp471188vsd; Wed, 12 Apr 2017 16:51:13 -0700 (PDT) X-Received: by 10.223.134.219 with SMTP id 27mr171584wry.33.1492041073358; Wed, 12 Apr 2017 16:51:13 -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 s25si20113572wrb.187.2017.04.12.16.51.12; Wed, 12 Apr 2017 16:51:13 -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; dkim=neutral (body hash did not verify) header.i=@gmail.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 163B5688289; Thu, 13 Apr 2017 02:51:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yw0-f170.google.com (mail-yw0-f170.google.com [209.85.161.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 05ABA6891E0 for ; Thu, 13 Apr 2017 02:50:56 +0300 (EEST) Received: by mail-yw0-f170.google.com with SMTP id l189so18784899ywb.0 for ; Wed, 12 Apr 2017 16:51:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=pDFON5AJiymd5XWRPZVINMkuc3bEOXWk7EChPUEG7Uc=; b=I60Lq2AT8a5T1BgYHUWfykmnxLKqM4rHsrZoKRNGab2oQdGwHjd9DGRKpCN+xMX3nP 9vO+I45gaSvnZBBJTGn6KEElAhzhCEJEnfDmiKBrzXtNXPU9R6YYkLH1ksATyjbQeVqS 1f9GYe4Z+dHLuQ6BuYwkTFJ74RXJ6vSriM11EapLVCWeB8Iye7jICE8eq38VV3JenatM Zawldn9FBGxcA0t5SjRZPUlLF50zqtkBMyxLZwB7G8aWR5t3ZwPIuuKZfSKIz19d1Twm 0JdQEzjwlnl5zcE5s0oNzIj+4QOMoPckW4nDZ5Ne5LEXkjNVeIgeboUqVMGxuD6Fq9vK 9sIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=pDFON5AJiymd5XWRPZVINMkuc3bEOXWk7EChPUEG7Uc=; b=XTaS7IfhEMeIIVAlAJSUj302yNjreR1FAMwBtF+CXSEeU1k2h1kK74ETjnGNiU5hF3 HilmczeD1h247yF4yzrTU/XjR89xbUoO4AQOzq7bjAI5CKpx3QiUR+wATZTKzaO0iqPf 3noDZjpih4YMGPkkswGcC4bWs4ja+Et+Cw7pF/w/k1XgrkGTCVgIPblA9xB7/8cfphMi m6T0KjGZQwAQl2zT1/csXe9Ayz/8yUWpPjHuYu4qigF+bc6ZRnrHmuJo9xUKOqNArCy6 /w+tuUo+HmRJUD3YQrcBb119eiyCIVesMs5filxHTEiev6Fp2HCGhnGyamdozB8iZb5F IGWA== X-Gm-Message-State: AN3rC/4UKawekErfUwPB51fX+I80NM/vDL3PjpsOH6VEDPKBzEiYrao6 V2zwuxk4q7WF6tVoYNK7gosP2p6K3sEp X-Received: by 10.129.76.21 with SMTP id z21mr195604ywa.43.1492040608939; Wed, 12 Apr 2017 16:43:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.208.205 with HTTP; Wed, 12 Apr 2017 16:43:08 -0700 (PDT) From: Tim Hunt Date: Thu, 13 Apr 2017 00:43:08 +0100 Message-ID: To: ffmpeg-devel@ffmpeg.org X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] avformat/hls allow playback when some variant streams are unavailable 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" addresses ticket #2617 The test url given in the bug report is now working and has been playing for a couple of hours. http://amd.cdn.turner.com/adultswim/big/streams/playlists/toonami.m3u8 --- libavformat/hls.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index bac53a4..87e0c71 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -1610,8 +1610,8 @@ static int hls_read_header(AVFormatContext *s) { void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb; HLSContext *c = s->priv_data; - int ret = 0, i; - int highest_cur_seq_no = 0; + int ret = 0, i, j; + int highest_cur_seq_no = 0, found_segments; c->ctx = s; c->interrupt_callback = &s->interrupt_callback; @@ -1655,11 +1655,26 @@ static int hls_read_header(AVFormatContext *s) for (i = 0; i < c->n_playlists; i++) { struct playlist *pls = c->playlists[i]; if ((ret = parse_playlist(c, pls->url, pls, NULL)) < 0) - goto fail; + continue; } - } - if (c->variants[0]->playlists[0]->n_segments == 0) { + found_segments = -1; + for(i = 0; i < c->n_variants && found_segments == -1; i++) { + struct variant *var = c->variants[i]; + for(j = 0; j < var->n_playlists; j++) { + if(var->playlists[j]->n_segments > 0) { + found_segments = 1; + break; + } + } + } + + if(found_segments == -1) { + av_log(NULL, AV_LOG_WARNING, "Empty playlist\n"); + ret = AVERROR_EOF; + goto fail; + } + } else if (c->variants[0]->playlists[0]->n_segments == 0) { av_log(NULL, AV_LOG_WARNING, "Empty playlist\n"); ret = AVERROR_EOF; goto fail; @@ -1805,7 +1820,6 @@ static int hls_read_header(AVFormatContext *s) } update_noheader_flag(s); - return 0; fail: hls_close(s);