From patchwork Fri Apr 21 10:34:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amine KABAB X-Patchwork-Id: 3457 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp226476vsd; Fri, 21 Apr 2017 03:35:10 -0700 (PDT) X-Received: by 10.223.134.118 with SMTP id 51mr12616756wrw.75.1492770910514; Fri, 21 Apr 2017 03:35:10 -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 f186si1866013wmd.167.2017.04.21.03.34.53; Fri, 21 Apr 2017 03:35:10 -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 249336898A9; Fri, 21 Apr 2017 13:34:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f182.google.com (mail-wr0-f182.google.com [209.85.128.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A52F068987D for ; Fri, 21 Apr 2017 13:34:34 +0300 (EEST) Received: by mail-wr0-f182.google.com with SMTP id z109so52115835wrb.1 for ; Fri, 21 Apr 2017 03:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to; bh=VmDwL/dE4naFRLqoEHJIVpZQgUWOovDQEJixZmYFjg0=; b=nDt3nOv0F96q9Xyic+fcv3laCHG9MdPl7LEA6pf5OONwoyK61zruMN9AaMzoPvOpQ8 dx5mX1HosfzxX96cSjDeyuGOKXaXLdSGNcy1CukHl4y69RtQEqxmLirp3oB77ozgHsy/ j3NwsbYnHPjo9tngvr5rYnAVInxvGakYz0o8bNxDohfmrpSNwkmnIhiwfwHlFf3oX3V9 Nfu0XFHttU3IgasdsFMk3fTDLZKkYo6fZBsa1p2M+BwNwaTrtmJjj4DpcQoo4UvWNTBl o1hVWxjQcdb1DeMSJ5nVPkhhahukURW1cuNYsD0ZFj4fH1+9z7EPHdjdKPdMCiZ+VzFZ T0SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to; bh=VmDwL/dE4naFRLqoEHJIVpZQgUWOovDQEJixZmYFjg0=; b=ai2g/BlrDFFUETpqi8K58msFUPDa7R/NySl0spwP738xHAM/MLREzjxO7ayrC4y3X0 WJ46wSyQ4gUpw56HM4Ofn3I1rjCTv/FoCgbiynD6Q0NnERwRf/xePs6A1yOXqtAV+txM gACl4EPoswla1h1xD81bb2DF9Rot/u4aLwVu5hfFh+5I6xxdTq6cwUpugSADLNiAHafU YYIWbSZsXROG85a+WdNJ5DqFJzsvBr73uX5XxrI7vFOhrBIEy7OW6rtO40Qzre5hXdwo lciJh3scX68od38b6QfMap/XIdP67XYyMdlI6lHYqrKXz05q5Jt5YmwYanK/4Miy9XBc 2SMA== X-Gm-Message-State: AN3rC/5hTB84kzBc4E2Mb506kpFpZ6MzqsTZ8Gy0fmgmpenUlQuQ5MC4 E8Aagt2xRbj5CPoXBMI= X-Received: by 10.223.163.18 with SMTP id c18mr12893170wrb.70.1492770883130; Fri, 21 Apr 2017 03:34:43 -0700 (PDT) Received: from MacBook-Pro-de-Amine.local (adsl-244-111-192-81.adsl.iam.net.ma. [81.192.111.244]) by smtp.gmail.com with ESMTPSA id x64sm4049225wrb.10.2017.04.21.03.34.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2017 03:34:42 -0700 (PDT) To: FFmpeg development discussions and patches References: From: Amine kabab Message-ID: Date: Fri, 21 Apr 2017 11:34:39 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH] [UPDATE] HLS, add option to skip down streams, 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" Hi Ben, thanks for reviewing the patch, On 21/04/2017 08:13, Benoit Fouet wrote: > Hi, > > > On 20/04/2017 18:18, Amine kabab wrote: >> From 5079f9b7114589626a4c9fff0fbb8f6e0d2f4fd9 Mon Sep 17 00:00:00 2001 >> From: amine kabab >> Date: Thu, 20 Apr 2017 15:59:42 +0000 >> Subject: [PATCH] HLS skip down streams >> >> --- >> libavformat/hls.c | 14 +++++++++++++- >> 1 file changed, 13 insertions(+), 1 deletion(-) >> >> diff --git a/libavformat/hls.c b/libavformat/hls.c >> index bac53a4..26d7679 100644 >> --- a/libavformat/hls.c >> +++ b/libavformat/hls.c >> @@ -194,6 +194,7 @@ typedef struct HLSContext { >> >> int cur_seq_no; >> int live_start_index; >> + int skip_down_streams; >> int first_packet; >> int64_t first_timestamp; >> int64_t cur_timestamp; >> @@ -1652,11 +1653,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) { >> + int all_failed = 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) >> + av_log(NULL, AV_LOG_WARNING, "Trying %s\n", pls->url); > Do you really want to keep this trace? I think the log is very helpful in this part, otherwise if the playlist is too long the user will get no feedback. > >> + ret = parse_playlist(c, pls->url, pls, NULL); >> + if (c->skip_down_streams && ret >= 0) { >> + all_failed = 0; >> + } else if (!c->skip_down_streams && ret < 0){ >> goto fail; >> + } > If I understand correctly, that means that if you do not set > skip_down_streams and the playlist parsing is OK, you will not unset > all_failed, and bail out below. Is this really what you want? I wanted to keep the normal behavior, I've updated the patch to fix the issue > >> } >> + >> + if (all_failed) >> + goto fail; >> } >> >> if (c->variants[0]->playlists[0]->n_segments == 0) { >> @@ -2126,6 +2136,8 @@ static int hls_probe(AVProbeData *p) >> static const AVOption hls_options[] = { >> {"live_start_index", "segment index to start live streams at (negative values are from the end)", >> OFFSET(live_start_index), AV_OPT_TYPE_INT, {.i64 = -3}, INT_MIN, INT_MAX, FLAGS}, >> + {"skip_down_streams", "continue playback of HLS when one of the variant streams are down", >> + OFFSET(skip_down_streams), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS}, >> {NULL} >> }; From 277650244439cd28ba7aa068364ed5358ead0546 Mon Sep 17 00:00:00 2001 From: amine kabab Date: Fri, 21 Apr 2017 10:27:18 +0000 Subject: [PATCH] HLS, add option to skip down streams --- libavformat/hls.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index bac53a4..8cea34e 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -194,6 +194,7 @@ typedef struct HLSContext { int cur_seq_no; int live_start_index; + int skip_down_streams; int first_packet; int64_t first_timestamp; int64_t cur_timestamp; @@ -1652,11 +1653,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) { + int all_failed = 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) + av_log(NULL, AV_LOG_WARNING, "Trying %s\n", pls->url); + ret = parse_playlist(c, pls->url, pls, NULL); + if (c->skip_down_streams && ret >= 0) { + all_failed = 0; + } else if (!c->skip_down_streams && ret < 0){ goto fail; + } } + + if (c->skip_down_streams && all_failed) + goto fail; } if (c->variants[0]->playlists[0]->n_segments == 0) { @@ -2126,6 +2136,8 @@ static int hls_probe(AVProbeData *p) static const AVOption hls_options[] = { {"live_start_index", "segment index to start live streams at (negative values are from the end)", OFFSET(live_start_index), AV_OPT_TYPE_INT, {.i64 = -3}, INT_MIN, INT_MAX, FLAGS}, + {"skip_down_streams", "continue playback of HLS when one of the variant streams are down", + OFFSET(skip_down_streams), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS}, {NULL} };