From patchwork Wed Mar 10 21:43:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ed Martin X-Patchwork-Id: 26318 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 14EA744A635 for ; Wed, 10 Mar 2021 23:43:19 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F17B268AAE8; Wed, 10 Mar 2021 23:43:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a8-176.smtp-out.amazonses.com (a8-176.smtp-out.amazonses.com [54.240.8.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 28D3D68AB03 for ; Wed, 10 Mar 2021 23:43:12 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=fxwna5ofi5lcv5tb5ulysijj32u6rh3v; d=edman007.com; t=1615412590; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=T8v7Ss8H+JZ/2Tc/QSDfBchkiWfoGXDSisbDuU2ht4g=; b=K35hmzkycSLaV5VKL6/Ziz6DLvOmglsnX40DU5LUs9F4iFyyflfk60On8wN79cKE p/+4RkBJ0fBmi2Tc1nOp03PD3YTgaduKTRJHGgllJDgue5lqlvwfEgxeBAs/nAVC40T 5AIChL8XF1f6z1Wew2SOLRfN712hXSscknb2B1Zw= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=224i4yxa5dv7c2xz3womw6peuasteono; d=amazonses.com; t=1615412590; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Feedback-ID; bh=T8v7Ss8H+JZ/2Tc/QSDfBchkiWfoGXDSisbDuU2ht4g=; b=EpK5kY/wTAhkMWahT8sMUFpzTTzyo/zu7/lqiAWauwXsvp/P1ocg1Fbgz9N7Dh/Z O1ZXrXUzd/qt70p1VbstxPJ0jhG4zGBXUbNqFjcUzOsfC7f8ESyfpH3/cZqi/IOlDem e9dQccGLBdcGKv71cyC2uCxNt/9s2eb9jl2hv29I= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-172-31-22-232.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=no autolearn_force=no version=3.4.0 From: lists@edman007.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Mar 2021 21:43:10 +0000 Message-ID: <010001781e17f6e0-4bae9a44-0672-440e-95f8-3543a4a344aa-000000@email.amazonses.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310214245.16156-1-lists@edman007.com> References: <20210310214245.16156-1-lists@edman007.com> MIME-Version: 1.0 X-SES-Outgoing: 2021.03.10-54.240.8.176 Feedback-ID: 1.us-east-1.wWwZDPI8362DZ8jLb9zYEI2vbIp+e8DcpQLgTWAwzSs=:AmazonSES Subject: [FFmpeg-devel] [PATCH 1/1] libavformat/hls: Reset options after open_url_keepalive() fails 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: Ed Martin Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Ed Martin open_url_keepalive() unsets the options when it uses them, this includes the offsets for the Range: header. When using the HLS tag #EXT-X-BYTERANGE along with multiple files, the range options must be preserved after open_url_keepalive() returns EOF so that the new file can be opened. Failure to do this results in ignoring the #EXT-X-BYTERANGE tag and reading the wrong bytes of the file. To fix it, reset the options before calling io_open() following open_url_keepalive() reaching EOF --- libavformat/hls.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/hls.c b/libavformat/hls.c index af2468ad9b..d08d00cf24 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -677,6 +677,8 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url, av_log(s, AV_LOG_WARNING, "keepalive request failed for '%s' with error: '%s' when opening url, retrying with new connection\n", url, av_err2str(ret)); + av_dict_copy(&tmp, *opts, 0); + av_dict_copy(&tmp, opts2, 0); ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp); } } else {