From patchwork Tue Nov 16 14:52:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 31448 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7501815iob; Tue, 16 Nov 2021 06:52:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJypiP6qvN7WZI7gRJKxbe0MjhFnbGtb+XlkQ/fFKF5Ufb/5z1NdQsiHUn92C5jQ8jEsuBgR X-Received: by 2002:a05:6402:34c1:: with SMTP id w1mr11146492edc.179.1637074353738; Tue, 16 Nov 2021 06:52:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637074353; cv=none; d=google.com; s=arc-20160816; b=BPiXgUxxpcLZQElC3P62K052lTfHFsUERYC5Z8zHCl+2yQNAcGN2LzQ26CZCgTnumg +I1j0a+8FPKyy4zITTz09NqEw5sWRKOa9CnTkbJuaFz8fQpSYeA8+/O3eI7VKVYg5K+b GgPSWuzrp1aQ4BFa2ThMzS/3mrDAaen+Z5r2WxST/pZb43qAxboZK82u09cNdV4lHwwz OKmPVjn3h1auZWIIWKEHPJrnEwQDeRayfYTCuFROieldnJSHHhD34KCrzKSS48Efrw2p 7ukBHmbNKUuQIgLZf0TE4w9T4oM+oc50EuRG4AFUOTLFyQq9dhoktUmjgIAdhY0WRe1L 7+qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=qSKwm6XIi31PNZdwQo2WHfkxKT2Zfl3mwvGAru+iLu8=; b=Kd8P5rY1C+NXzzIDlze+lx2Y6MuPHs8Mcc2LlkpPKnAqxge8837SR7lHNIK9GmIMs/ 9SoLWW3H+SGvVuhsQQr1Nbud+lMdJfl9baC3ol9qxYeGTxUzAYUEVKn67FGidWT/Ie9O b0gc53JUV4caXCRuFN/xdNnNw6s1IWTZHRwuVryglThZmG0XNZECBItbAb//s54PWcRX 808Zsv5gBwge/StwPpXiK21cO0cn/5DoJY1fNDhuhfz0/JfI2XVpUmWRu3rWp67YuKZS 2ad/ESFYbf+hLAWA2B4V1WnshjSUaFGqrq4bzr2uDA2SBEWqQ9fBDnYGtYEJezB8wRsA PdxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Pb+Oazd9; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id oz17si45553955ejc.12.2021.11.16.06.52.32; Tue, 16 Nov 2021 06:52:33 -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=@gmail.com header.s=20210112 header.b=Pb+Oazd9; 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=QUARANTINE 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 0F63168A637; Tue, 16 Nov 2021 16:52:29 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 56ED568921B for ; Tue, 16 Nov 2021 16:52:22 +0200 (EET) Received: by mail-wm1-f54.google.com with SMTP id n33-20020a05600c502100b0032fb900951eso2196350wmr.4 for ; Tue, 16 Nov 2021 06:52:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=N6sZYGNBk+g+tVzU471lWzRmsH0U00ByXbFdoBd+PI4=; b=Pb+Oazd9HPvf5UtMbcke/5xLuUnoFz7apwaKPZcTwtS/rI+cFTl975hQKjqZrCfA1F SfR8kBLo1FRZMquBqJl7TC0JicJUQwNfXjh093rMdy14PptxHIOvknaKzkeBcKQP2EMd GzDt7ZH5qj38AbyVlRRKaWnIYVO8m+3/8jjgsSgt11jdSzQxq2UAlVzVj/xdcevY5V6Q CRM4ws5uMIuKmGAJ1jTJwp0wUmBU16ADsUQobWkjiFQUj8CduR86j906A4ZYKfzoroj3 sihPuasN1XB6x/bYq2Qhljw7E3g69GV3Q35QEQv0GJr5GmqEmqrkJkH13D5cu+eZD+0P JFMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=N6sZYGNBk+g+tVzU471lWzRmsH0U00ByXbFdoBd+PI4=; b=rtyRA15WyjVFPj6lzmX3W4jCBkt6HZeT1jN4XOzj44me2OFendBS9xl4MTe0Tb7fS+ SDbeBnhokjOd73hOVg41OCH+W0AosC0VaLmWBI6LSRKzwaBla5M4YahNkeJTfucbdTho C+CUVtptqH3NoQe9fFO1yj04o6+ScoQJbFXE09ONL8VIzvDEdeYBwtCS/47GVRF8HR/h eufoPQY6OBzcCTwR2tFZN/0XUq4ADmkil0tX7QFPsqAPGaDUKF1Wl+cZytlOhZtLWRxl y4bbKSnMazO808VSVhOSrhXxVCTvf3YiKoiNqrAeyW61N/cGoKLp5yXthugKh2GSPliN 6FWA== X-Gm-Message-State: AOAM531vscsqW0bLCUIo50IK/23WOSURPzDQP8sOlmN9LLxjgE0JJGUO sPfX0DOl76FZ7cQG0F3iF4VOT8wbxE4= X-Received: by 2002:a1c:a592:: with SMTP id o140mr8588735wme.10.1637074341015; Tue, 16 Nov 2021 06:52:21 -0800 (PST) Received: from localhost.localdomain ([82.129.92.120]) by smtp.gmail.com with ESMTPSA id u6sm2591469wmc.29.2021.11.16.06.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 06:52:20 -0800 (PST) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Nov 2021 14:52:07 +0000 Message-Id: <20211116145207.1723312-1-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] avformat/http: Add short_seek_size option X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: tSaVajqea/L9 In 45bfe8b838275235412777dd430206d9a24eb3ee, short_seek_threshold was removed from the public AVIO struct. Although this option was private and not intended to be used by public API users, it was nonetheless, because it provided functionality that could otherwise not be gained via public API. This was especially important for networked I/O like HTTP, where the internal size for lavf could be way to small depending on the specifics of a user's usecase, such as reading interlavd media files from cloud storage. Add an AVOption to make this functionality accessible to the HTTP client. Signed-off-by: Derek Buitenhuis --- libavformat/http.c | 4 ++++ libavformat/version.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libavformat/http.c b/libavformat/http.c index 476b9a8456..fdfbc69da1 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -126,6 +126,7 @@ typedef struct HTTPContext { int is_multi_client; HandshakeState handshake_step; int is_connected_server; + int short_seek_size; } HTTPContext; #define OFFSET(x) offsetof(HTTPContext, x) @@ -167,6 +168,7 @@ static const AVOption options[] = { { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, D | E }, { "resource", "The resource requested by a client", OFFSET(resource), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E }, { "reply_code", "The http status code to return to a client", OFFSET(reply_code), AV_OPT_TYPE_INT, { .i64 = 200}, INT_MIN, 599, E}, + { "short_seek_size", "Threshold to favor readahead over seek.", OFFSET(short_seek_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, D }, { NULL } }; @@ -1842,6 +1844,8 @@ static int http_get_file_handle(URLContext *h) static int http_get_short_seek(URLContext *h) { HTTPContext *s = h->priv_data; + if (s->short_seek_size >= 1) + return s->short_seek_size; return ffurl_get_short_seek(s->hd); } diff --git a/libavformat/version.h b/libavformat/version.h index 2e860b8d76..d8a9351b3a 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 59 -#define LIBAVFORMAT_VERSION_MINOR 8 +#define LIBAVFORMAT_VERSION_MINOR 9 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \