From patchwork Mon Nov 15 15:52:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 31436 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp6026658iob; Mon, 15 Nov 2021 07:53:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLsbb5zGPYeSEdjE4NWdcMGOUr4Md8kIY1K1+mB62T1lonZZlXZ30enrBYiG+YDQ52Hp2f X-Received: by 2002:a17:906:4fc4:: with SMTP id i4mr53839279ejw.81.1636991585754; Mon, 15 Nov 2021 07:53:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636991585; cv=none; d=google.com; s=arc-20160816; b=CUMp7bkygWdKyGhwut1O5+PgVO1Q/JjNGFrw+PreO5fg75Y++9ZsTQHgPXiEuWv4Ug BI+UJ8RQOuUnP7b0/6hQBM8hzvpMLPdc6Q4h+EREAA5fAMVU8cET6PgxFbKXpN9K1rhA dqZvXuCHDLNuA/oNOuK7EX8jQ4+lX/LuWY2FIUDcTq21W3wgU2QwfJGKa9yuFEBavw05 UoYvML3Ynz5Bv5rEUsbIeYNLk8XMWLNTdNgQ8b3HHaMWXWjAfPH+AxOEFJFaEcXv/rGG 9aow5XBRGalItTPZ/45sOTm0RqGGK5aDS0ck0odymjNNazP1QQcZtuLoLRR8IBGdlke/ ykiQ== 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=pmMOD8lvwrtCDPpjbcD94AYQ+YZ2yy54RAWcz3FJRY8=; b=hLUGvTGxyMI/6qly+ea1Z3NKA/icLM39gx498zKgfpLPHndd26NkxYYVe7ugrafs06 kmsAIwiq/1rouDYMcXXjxsgUSPj2IcqOM1sxOFy/NbFjQ2EPrjW+VPIITP+3TV25sI9j iJoIZApRwKRXCooKZ8xwPoYg/H4ljMoGnyT76SV6JGFe4LKB9WfuK6hbAQZhgBYwAcBB 7QD+fW47d0h2o4UMLGyUYWgFVviWNhSGjI+TEhVPSqSacodJHlPnh3D/o5QCuPrSMyd6 CpwmbVNkU2YcFPoeokpuiGZ10vWswRyhLVf16nnt3v+cCYzNS4R6h2v4iV5jsmmObYqK HPAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="XF/y/mmp"; 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 sg41si41461244ejc.677.2021.11.15.07.53.05; Mon, 15 Nov 2021 07:53:05 -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="XF/y/mmp"; 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 E2CEC68AA75; Mon, 15 Nov 2021 17:53:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 09A54689EC9 for ; Mon, 15 Nov 2021 17:52:56 +0200 (EET) Received: by mail-wr1-f45.google.com with SMTP id n29so31582125wra.11 for ; Mon, 15 Nov 2021 07:52:56 -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=Xzn6JlVGKVQRUF7PstWtAAYSh9Fo4hay3OG233ZfFts=; b=XF/y/mmpMkiOeX6wh+PYbIN31zWEGjCabG/Nd307reYjz++MY4OHQLdkbGERijI322 o1LvNcOIUPaP1vpoeV+/NXc7oFuA2p6GdAnnqhMsV3Ldwe6lJAHB5oZhxbOBSNEWOsZT IWFFrWG4uNqECW7lId8QvMmnrl3eFVjgMe+b+G/SGiKQwTDVlgdpIfIgxHVDOQoe2W6n fQqnnZR9Md39r7OiOZ4KqmxE9gkMxkn223pyQXwNHzwROYQWxSF0CigzxHSqu1Ti42qQ uVGbe7iTJAeu3FwacBLe5xSYYGCp3br9z3U6ZXGNXlOsMV9omnjkeZ9OK/jqrbSE2EEH /BRA== 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=Xzn6JlVGKVQRUF7PstWtAAYSh9Fo4hay3OG233ZfFts=; b=qC2rBQqpvvKYlDno5+x9xVV3aiA0DapIocOJND92wxPpOvCz9rWuS1bfkezFz1Hkch pEelNb1NdjkkoWXkc7PEg2zqj5ngGghMR3XYNvUEtbKYgJNGE0aubbpE1QRFTx0hWGSz nLsGXCVQRV/drJ1fGlUr8rIMH2yIj3g8aHrHkyWGADVSjsvkduwB8wLT2zR2SL8ajckc mNtm2A7kCyL2wTAbRQ+WebHyzUDSguRE8MLbo69U01fPEKd3VsEsv++NE32t5BSBqyJp hC286NJoT3BQEL2c5ITU0cyPLCgyqrxpod/y9jNPRCqdMWFSaidYHZl5mIfPAD9DJYGx KhmA== X-Gm-Message-State: AOAM5321WitTcwj3CdoM/JqzlbjCvF6mPc9v+cgtDAtk1+a3hnUvXiMJ GKI/AmnGazbALpoql06uqmMgZxZ9a2k= X-Received: by 2002:a5d:548f:: with SMTP id h15mr47103798wrv.99.1636991575170; Mon, 15 Nov 2021 07:52:55 -0800 (PST) Received: from localhost.localdomain ([82.129.92.120]) by smtp.gmail.com with ESMTPSA id x4sm19282142wmi.3.2021.11.15.07.52.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 07:52:54 -0800 (PST) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Nov 2021 15:52:42 +0000 Message-Id: <20211115155242.1722587-1-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] 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: DHqpZIPkly43 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 --- Same as last version but I'm marking it as non-RFC. I think I prefer the AVOption approach. Comments welcome. --- libavformat/http.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/http.c b/libavformat/http.c index 476b9a8456..0dc1ce0f43 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 = -1 }, 1, INT64_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); }