From patchwork Thu Feb 3 17:29:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Gaiser X-Patchwork-Id: 34096 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp2683115iov; Thu, 3 Feb 2022 09:31:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwc64dSUUYaZU0KK4yyu8j9ysALj3KIZbGka/btEhmOQBs49pniVy7dSXbgwARvT2RLwpgA X-Received: by 2002:aa7:d296:: with SMTP id w22mr35916263edq.245.1643909472477; Thu, 03 Feb 2022 09:31:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643909472; cv=none; d=google.com; s=arc-20160816; b=yyeX5857q0YcrABu48mmnlwMMVpTvYCkttzt07i8KB1ZOwuTJmfxLLUqa/+TMMTVcE b23yhKxJUOuw4QhetjNGqCV76m3ZGC9xj78iN0VYQ/Krvl2Oy5xLgqQET+i8vFdOTZen lEldpDEQwfSGXRF6lu/Q/1/n42sPiBlia/rZyuAqaeir5+sPag+gyNShSMvUpj/34bdx 3iB0log50BJCZM4XU3re9CPAvg0Ea7oQV5pk0KR+HZ2Eui7a4XBMijS1NN+buFL9cj+7 dsYuujPbBsr/bbgv3w88hVZQys6lQU7+CoiRsSbf3H4lTfZBzO8keVOH0CkIFdmE/KyY 6Z7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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=JGWIV6WZ6JTcHoNnFXds5tw4uvsTDgdOQY6b+lRVLVU=; b=LqymImxnhPBjcICRc4grvbSDoc+x7PnyB5vtshqUHcfAIAzh+dst/+f9A6eVeh7hI7 TGrHOHEO8dWskHEm9lgS2eGHlCEmZMphM+cctUg+4GG31uLuHHWW8gCWdjfJ4NUQRcfX OwLbE7LImJMzWRmLMGtuHjkMm5q5NStAHEG1yh0+nB/8y3cxGVccYr5W3JsvFaIxGhrS dwnBr2dZyZdkj0UBU2jAHfTh0RCoaozc2E3EtIhqAK8FWHiKOMOaBM13HXUukoeFdlXy NZoYhxwTDVhRip45DViqz0JMr5g2M1SL2d5+47DcYJkHoBTfQyz4Seju7MGvgkkfNa5j OIRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Y7WMaUbz; 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 d30si13378148ejo.183.2022.02.03.09.31.12; Thu, 03 Feb 2022 09:31:12 -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=Y7WMaUbz; 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 5207068B13E; Thu, 3 Feb 2022 19:31:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 64B7568AF96 for ; Thu, 3 Feb 2022 19:31:02 +0200 (EET) Received: by mail-ej1-f51.google.com with SMTP id s13so11029096ejy.3 for ; Thu, 03 Feb 2022 09:31:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QwudAh1Fo0plratguLuDSdAElknE7bbeyjqQVXaOm9k=; b=Y7WMaUbzgDNSHRBVlNo2j+BqpnQjilZqQ+agXjCiiQyxjI81ZQs0y4+pQfEMiLWFo1 TkEXwcT+v9NcfqQ9TTuKapBUMReiuKAjkVFyhr3UcMKxU2hfAWuKO9+Qwse2rYIccBLZ uGN6t5quBoHOfxXbpR+7cWrJohpPN2NVHv2tjTujtReT+A28EdDxWQLB8qN4N8CdRegE p1yWnJu29pyF7JCr5KMszd/Ybt8qVynjDjVxlYlfjOHSzGNH/sPPtZ5BZxROmdyiqYjC qHwinkqQyT3Fc5T+0X8UQHak+n2lFtRZWKaz9winfIOGku7X/1VeDABnvmWmiZvkZmHz xMkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QwudAh1Fo0plratguLuDSdAElknE7bbeyjqQVXaOm9k=; b=DjE8j6paCXrkYyrOpFXjd4PuTNiyRHmKMluVP44R6BvbLHYVWy2pwZIoWVW4+eqnfN WJIK/Qt/y7upZuAWH5BDGFNkpaRn+FmKAXrPzejM/S2Uiw/3QK4crG7cTL/MFgn+z/uc 2BVAp8JU2Of3ToRcpk1lfWJ+OQGJfQHF1OmcNbSs5E8lh4xJMMtslLHprnlQX8kF8RH5 t2h0JZpQ+E/OruuSeMW/Y6qN4vX6qSpmuIV2ZSwZXxzRaEuKcukUYr7ui4JVBC6jCdZp T9NuREui0SP1ov6DztYv+E1Ygxq1/3iZMYrYDom0UDRMb4+fTORy9Ly2oxKxeIkbBVB5 vb0g== X-Gm-Message-State: AOAM531sEdoknS1d+7TTyPQGt6CZafAUtHDDlLPFrW2+Ptt8LLAPOZHm zKr+kkfOBMlGV5rVHx02WvlGRYJmOs11fA== X-Received: by 2002:a17:907:6ea7:: with SMTP id sh39mr29807962ejc.380.1643909461477; Thu, 03 Feb 2022 09:31:01 -0800 (PST) Received: from localhost.localdomain (ip60-253-211-87.adsl2.static.versatel.nl. [87.211.253.60]) by smtp.gmail.com with ESMTPSA id gz12sm17060489ejc.124.2022.02.03.09.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 09:31:01 -0800 (PST) From: Mark Gaiser To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Feb 2022 18:29:49 +0100 Message-Id: <20220203172950.21458-1-markg85@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 0/1] Add IPFS protocol support. 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 Cc: Mark Gaiser Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: n38pccPGZh6C Hi, This patch series adds support for IPFS. V3 (V4): - V4: title issue from V3.. - A lot of style changes - Made url checks a lot more strict - av_asprintf leak fixes - So many changes that a diff to v2 is again not sensible. V2: - Squashed and changed so much that a diff to v1 was not sensible. The following is a short summary. In the IPFS ecosystem you access it's content by a "Content IDentifier" (CID). This CID is, in simplified terms, a hash of the content. IPFS itself is a distributed network where any user can run a node to be part of the network and access files by their CID. If any reachable node within that network has the CID, you can get it. IPFS (as a technology) has two protocols, ipfs and ipns. The ipfs protocol is the immutable way to access content. The ipns protocol is a mutable layer on top of it. It's essentially a new CID that points to a ipfs CID. This "pointer" if you will can be changed to point to something else. Much more information on how this technology works can be found here [1]. This patch series allows to interact natively with IPFS. That means being able to access files like: - ffplay ipfs:// - ffplay ipns:// There are multiple ways to access files on the IPFS network. This patch series uses the gateway driven way. An IPFS node - by default - exposes a local gateway (say http://localhost:8080) which is then used to get content from IPFS. The gateway functionality on the IPFS side contains optimizations to be as ideal to streaming data as it can be. Optimizations that the http protocol in ffmpeg also has and are thus reused for free in this approach. A note on other "more appropiate" ways, as I received some feedback on that. For ffmpeg purposes the gateway approach is ideal! There is a "libipfs" but that would spin up an ipfs node with the overhead of: - bootstrapping - connecting to nodes - finding other nodes to connect too - finally finding your file This alternative approach could take minutes before a file is played. The gateway approach immediately connects to an already running node thus gives the file the fastest. Much of the logic in this patch series is to find that gateway and essentially rewrite: "ipfs://" to: "http://localhost:8080/ipfs/" Once that's found it's forwared to the protocol handler where eventually the http protocol is going to handle it. Note that it could also be https. There's enough flexibility in the implementation to allow the user to provide a gateway. There are also public https gateways which can be used just as well. After this patch is accepted, I'll work on getting IPFS supported in: - mpv (requires this ffmpeg patch) - vlc (prefers this patch but can be made to work without this patch) - kodi (requires this ffmpeg patch) Best regards, Mark Gaiser [1] https://docs.ipfs.io/concepts/ Mark Gaiser (1): avformat: Add IPFS protocol support. configure | 2 + doc/protocols.texi | 30 ++++ libavformat/Makefile | 2 + libavformat/ipfsgateway.c | 329 ++++++++++++++++++++++++++++++++++++++ libavformat/protocols.c | 2 + 5 files changed, 365 insertions(+) create mode 100644 libavformat/ipfsgateway.c