From patchwork Fri Dec 29 22:06:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 7025 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.79.195 with SMTP id r64csp10985146jad; Fri, 29 Dec 2017 14:06:35 -0800 (PST) X-Google-Smtp-Source: ACJfBot6VoG1gau4ZgEn3WtvdKqQiojli6zPkE0+ovMaieJ/gWNJDO1GU85YeeBFWMcpLZiOreEt X-Received: by 10.28.216.212 with SMTP id p203mr30518137wmg.50.1514585195196; Fri, 29 Dec 2017 14:06:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514585195; cv=none; d=google.com; s=arc-20160816; b=DxZNoLPRyy1DNrM5GdmceJ8JPgSNdfIFoWb/k10rtNwjCycXZBP3D7+N/1yht0lRYm ufrcgiLDQx8maY63TmLPV9h/F0jCqjCAsd5v9fZGMppYBIj4znyKWZOtRYtgvifbdVXo ZZ3A+zXRpt5etmauWCzE6YHfw/6SdkFdX02rnTk3Vss3j9y4vau69NezrvQU6o0o0Bvs 83b/LiDOzUqriR/PSm5Sq9yYwqXC3N8o2FZ6psmZuGiYvOP/oNAJq2C5X839SPTC8kot ykG0MGy9te/YsW7HZqI5HyR/Y5wqOcTrwCW9mPpZlFb/1J66ctXkCiyG1l3+BM4Qt7il qhEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=ukOCaxE5k5HvXCLcSwUtM4YdeBdmvOQjHIhVvSPn7dw=; b=jfYndUESiOycVsnd8anKAUG5T/6W4DtPLRwffErZrMwqQv5rsEnx+aOOhIiW0aOhhe xDmQJ0smiFEda/yEbrdsrO6OLzNttaSX2pObaPaoQWmB92vIopUKcRrjag88zfPbH4KJ bm5wRmBh6lzG57P+IeMyEwCKeGPs7eHgAAf4C6bA3LlW2873HC/SJXQLT6MSnvH3ztAY Z0aScx72jVmYruW8cSnv43JMqx9sHUXvsRncJT8MxyNm2o08gUTl/HTbUfwO/Ol9Ratn zYaKeH8uyEOFPd+BhaUr63L9WNmLkyX34kZzeL+NWLieacq4eaT3YK31o+MH6k10lWBs H4jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=GThp/a3o; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r132si17007213wmb.66.2017.12.29.14.06.34; Fri, 29 Dec 2017 14:06:35 -0800 (PST) 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=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=GThp/a3o; 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 CE09A6899D3; Sat, 30 Dec 2017 00:06:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DA6A2689944 for ; Sat, 30 Dec 2017 00:06:03 +0200 (EET) Received: by mail-pl0-f67.google.com with SMTP id bi12so23619780plb.6 for ; Fri, 29 Dec 2017 14:06:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm1-net.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=E2qI91MZoxZxKC4a/e84mVx/xKT8fyUOEDoLgxr7n0E=; b=GThp/a3oRrLZhuADlYiJWm7sOGrBHlwXYHTYsGeHD1+D4FGIYtnI50ojQs7ZBoY17u gWwMayHyOcWfvPkvyeoN1KgLiA4Qy4OmSmpsVbmzBMl1qszMi2nOSgx5rTFdetor2CUN +slBK8thLlfN5qvY+0O161ugSWItkfroONBFWnA/yh1LARfrMkV04Rmn88JdECqmYp1j 7R3gSbYJtDC4hibYn3/X9OivqgUERPdgVo3xHXH7I2REsSyCCK8sd3V+r8L977XjZm9U tYLlxPK8y6ciy2K0NXQQGnnQ2IwCO5bttXTf/EobmBR0ZrSXzlyYFwjhGL6Dtl4fBD1U vT+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=E2qI91MZoxZxKC4a/e84mVx/xKT8fyUOEDoLgxr7n0E=; b=n2b1GCCxxMhxVOK+rWYvzf85VZ84B/AEY76iQVIM5DEjyFVDPPlN/s5KibcemQlC4J 4JxnscCyaNbNLp3NyQIU/+rMejcrzWZYGXv8OMJbvsjFu3ONdNNk8D84M6AXv708LoTc eB+S50jqdHJh3Qv+uGGsYdPlxHnTGPdi/irxVGfO/Wdy/VaXj67ChQIVw1GLl+qXXpmo kDKmiEsLLNwabHzQzPG8AjUwEmqmQjK2Hm1NmPOhcj0I0C2d+3XrExXwTmamk32/CZSN ttwF2H57F4btQhDn4ggwDWjBJCsX2vySUfD7J1SCBZAzn0wphdmDCSBXaHQFIJ1gYGY/ X/Rg== X-Gm-Message-State: AKGB3mJaJDsLT5c2AE37VGuiyEiIzrGyWmq9tXBLHsmLM0UT1AoduzZh xMuhsm+xeR/xdEU6xQPcZuaqi46T X-Received: by 10.159.229.10 with SMTP id s10mr36886691plq.386.1514585177022; Fri, 29 Dec 2017 14:06:17 -0800 (PST) Received: from localhost.localdomain (c-69-181-54-242.hsd1.ca.comcast.net. [69.181.54.242]) by smtp.gmail.com with ESMTPSA id s14sm83011713pfe.36.2017.12.29.14.06.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Dec 2017 14:06:16 -0800 (PST) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Dec 2017 14:06:06 -0800 Message-Id: <20171229220606.29155-2-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171229220606.29155-1-ffmpeg@tmm1.net> References: <20171229220606.29155-1-ffmpeg@tmm1.net> Subject: [FFmpeg-devel] [PATCH 2/2] avformat/hls: use AVIOContext new_http_request callback 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: anssi.hannula@iki.fi, Aman Gupta , kjeyapal@akamai.com, wm4 , lq@chinaffmpeg.org MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta This fixes a segfault when streaming from an HLS playlist which uses crypto, by ensuring ff_http_do_new_request will never be invoked on a non-http URLContext. Additionally it simplifies the demuxer by removing http.h and all the http specific code in open_url_keepalive. Signed-off-by: Aman Gupta Signed-off-by: wm4 --- libavformat/hls.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index dccc7c7dd2..6c638537ff 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -26,7 +26,6 @@ * http://tools.ietf.org/html/draft-pantos-http-live-streaming */ -#include "libavformat/http.h" #include "libavutil/avstring.h" #include "libavutil/avassert.h" #include "libavutil/intreadwrite.h" @@ -611,19 +610,13 @@ static void update_options(char **dest, const char *name, void *src) static int open_url_keepalive(AVFormatContext *s, AVIOContext **pb, const char *url) { -#if !CONFIG_HTTP_PROTOCOL - return AVERROR_PROTOCOL_NOT_FOUND; -#else int ret; - URLContext *uc = ffio_geturlcontext(*pb); - av_assert0(uc); (*pb)->eof_reached = 0; - ret = ff_http_do_new_request(uc, url); + ret = (*pb)->new_http_request(*pb, url); if (ret < 0) { ff_format_io_close(s, pb); } return ret; -#endif } static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url, @@ -670,7 +663,7 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url, else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5)) return AVERROR_INVALIDDATA; - if (is_http && c->http_persistent && *pb) { + if (c->http_persistent && *pb && (*pb)->new_http_request) { ret = open_url_keepalive(c->ctx, pb, url); if (ret == AVERROR_EXIT) { return ret; @@ -725,9 +718,9 @@ static int parse_playlist(HLSContext *c, const char *url, struct variant_info variant_info; char tmp_str[MAX_URL_SIZE]; struct segment *cur_init_section = NULL; - int is_http = av_strstart(url, "http", NULL); - if (is_http && !in && c->http_persistent && c->playlist_pb) { + if (!in && c->http_persistent && + c->playlist_pb && c->playlist_pb->new_http_request) { in = c->playlist_pb; ret = open_url_keepalive(c->ctx, &c->playlist_pb, url); if (ret == AVERROR_EXIT) { @@ -761,7 +754,7 @@ static int parse_playlist(HLSContext *c, const char *url, if (ret < 0) return ret; - if (is_http && c->http_persistent) + if (c->http_persistent && in && in->new_http_request) c->playlist_pb = in; else close_in = 1; @@ -1511,7 +1504,7 @@ reload: return ret; } - if (c->http_persistent && av_strstart(seg->url, "http", NULL)) { + if (c->http_persistent && v->input && v->input->new_http_request) { v->input_read_done = 1; } else { ff_format_io_close(v->parent, &v->input);