From patchwork Thu Apr 13 15:14:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Hunt X-Patchwork-Id: 3395 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp743483vsd; Thu, 13 Apr 2017 08:21:18 -0700 (PDT) X-Received: by 10.28.0.78 with SMTP id 75mr3635129wma.138.1492096877906; Thu, 13 Apr 2017 08:21:17 -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 m56si17424530wrm.247.2017.04.13.08.21.16; Thu, 13 Apr 2017 08:21:17 -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 69798689923; Thu, 13 Apr 2017 18:21:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yb0-f181.google.com (mail-yb0-f181.google.com [209.85.213.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8C557688373 for ; Thu, 13 Apr 2017 18:21:00 +0300 (EEST) Received: by mail-yb0-f181.google.com with SMTP id l201so14335835ybf.0 for ; Thu, 13 Apr 2017 08:21:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=ZWqyQm4DnZCET8thCTI7/eRWoRy9ivvIfqSorSmMosg=; b=c5UAy+zh3ZI7CwRLMqQ6jO2Jzmn8yvcxUYpUjx/aFOwzC7XUDSeF8kA5QDs3N6uGmW Cg8K/zwbLxBYgRC+5Ln40I3IwnYlg4gy/ers84mJJop6vQsit30xaJsep+alS7FXk942 nxMFj9Dg+ysMLPzTRoPubl6wGryBTc9XGhTQmkbIIAtH2Dr0ab0qp3JF+TQsBX8Q74fB r//5rp6sQ3EhJ2K1qGfjiYL/URItp9P9yH/lP8juOMpLLVk2E8QFENnuPbm3AzS8r6n5 Wighbz1kBmimoroAjBTuPdNJvFnsc0sJEJwctfflHe98oa2wNauj4PzSXdElnIjLNmlR 6GUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=ZWqyQm4DnZCET8thCTI7/eRWoRy9ivvIfqSorSmMosg=; b=GLj0mqXT55hVW/1qFpuMWfTd/tUBCKVE6FWFKlFnc0wll/wlP0dg6B67lxYJ8bXkIs ewfzWLsy5+vIO3Ge6Q5rO3aQhbSRQz66NNubV4aJpcLLEaH3hJTDEvPgNQpjRhoO+pJa I9j1XCaHNyrTDPpjyCg8vgnsLN1py9dJ2dkOsop1HfV576KLZlNzRmaqXAFuWELAvsRb 6bZafDCpxsWE6qGAHvg7nnETgXMF1eSUsPiClCUtcKJCBUbNXLyCJuBRA7XiXAjIypI/ 7ysCNJBdfyOIfcKIP0NcAPn3WcWvWfJNAf4B1oaYMZsdK0KwanBn1ralFtP7q0usdbki f3Aw== X-Gm-Message-State: AN3rC/5IJd3JeK0KTNJB4dkG5FjunSZA/RJDHBiHV7HllfrcWOkps7Vb EoFXZDGe8pVPlB54n8etUKaqsmkOIGdi X-Received: by 10.37.12.195 with SMTP id 186mr2556483ybm.17.1492096506736; Thu, 13 Apr 2017 08:15:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.215.130 with HTTP; Thu, 13 Apr 2017 08:14:46 -0700 (PDT) In-Reply-To: References: From: Tim Hunt Date: Thu, 13 Apr 2017 16:14:46 +0100 Message-ID: To: ffmpeg-devel@ffmpeg.org X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [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" My last patch was slightly convoluted and really dumb. I suspect it impacts on a couple of checks for variants[0]->playlists[0]->finished and the problem will be when a non live stream has two variants using EXT-X-ENDLIST and the first stream in the playlist is down? Not sure how to approach this, will look into it more later. --- libavformat/hls.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) goto fail; @@ -1805,7 +1811,6 @@ static int hls_read_header(AVFormatContext *s) } update_noheader_flag(s); - return 0; fail: hls_close(s); diff --git a/libavformat/hls.c b/libavformat/hls.c index bac53a4..26b8751 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -1611,7 +1611,7 @@ 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 highest_cur_seq_no = 0, found_segments; c->ctx = s; c->interrupt_callback = &s->interrupt_callback; @@ -1652,14 +1652,20 @@ static int hls_read_header(AVFormatContext *s) /* If the playlist only contained playlists (Master Playlist), * parse each individual playlist. */ if (c->n_playlists > 1 || c->playlists[0]->n_segments == 0) { + found_segments = -1; + 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; + if (parse_playlist(c, pls->url, pls, NULL) == 0 && pls->n_segments > 0) + found_segments = 1; } - } - if (c->variants[0]->playlists[0]->n_segments == 0) { + 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;