From: Michael Niedermayer <michael@niedermayer.cc> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH 1/5] Early version of IPFS protocol support. Date: Mon, 31 Jan 2022 16:59:27 +0100 Message-ID: <20220131155927.GJ2829255@pb2> (raw) In-Reply-To: <20220131135116.14035-2-markg85@gmail.com> [-- Attachment #1.1: Type: text/plain, Size: 5705 bytes --] On Mon, Jan 31, 2022 at 02:51:12PM +0100, Mark Gaiser wrote: > Signed-off-by: Mark Gaiser <markg85@gmail.com> > --- > configure | 1 + > doc/protocols.texi | 30 ++++++ > libavformat/Makefile | 1 + > libavformat/ipfs.c | 202 ++++++++++++++++++++++++++++++++++++++++ > libavformat/protocols.c | 2 + > 5 files changed, 236 insertions(+) > create mode 100644 libavformat/ipfs.c > > diff --git a/configure b/configure > index 5b19a35f59..e466f924a3 100755 > --- a/configure > +++ b/configure > @@ -3585,6 +3585,7 @@ udp_protocol_select="network" > udplite_protocol_select="network" > unix_protocol_deps="sys_un_h" > unix_protocol_select="network" > +ipfs_protocol_select="https_protocol" > > # external library protocols > libamqp_protocol_deps="librabbitmq" > diff --git a/doc/protocols.texi b/doc/protocols.texi > index d207df0b52..7c9c0a4808 100644 > --- a/doc/protocols.texi > +++ b/doc/protocols.texi > @@ -2025,5 +2025,35 @@ decoding errors. > > @end table > > +@section ipfs > + > +InterPlanetary File System (IPFS) protocol support. One can access files stored > +on the IPFS network through so called gateways. Those are http(s) endpoints. > +This protocol wraps the IPFS native protocols (ipfs:// and ipns://) to be send > +to such a gateway. Users can (and should) host their own node which means this > +protocol will use your local machine gateway to access files on the IPFS network. > + > +If a user doesn't have a node of their own then the public gateway dweb.link is > +used by default. > + > +You can use this protocol in 2 ways. Using IPFS: > +@example > +ffplay ipfs://QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T > +@end example > + > +Or the IPNS protocol (IPNS is mutable IPFS): > +@example > +ffplay ipns://QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T > +@end example > + > +You can also change the gateway to be used: > + > +@table @option > + > +@item gateway > +Defines the gateway to use. When nothing is provided the protocol will first try > +your local gateway. If that fails dweb.link will be used. > + > +@end table > > @c man end PROTOCOLS > diff --git a/libavformat/Makefile b/libavformat/Makefile > index 3dc6a479cc..983a77f4f2 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -656,6 +656,7 @@ OBJS-$(CONFIG_SRTP_PROTOCOL) += srtpproto.o srtp.o > OBJS-$(CONFIG_SUBFILE_PROTOCOL) += subfile.o > OBJS-$(CONFIG_TEE_PROTOCOL) += teeproto.o tee_common.o > OBJS-$(CONFIG_TCP_PROTOCOL) += tcp.o > +OBJS-$(CONFIG_IPFS_PROTOCOL) += ipfs.o > TLS-OBJS-$(CONFIG_GNUTLS) += tls_gnutls.o > TLS-OBJS-$(CONFIG_LIBTLS) += tls_libtls.o > TLS-OBJS-$(CONFIG_MBEDTLS) += tls_mbedtls.o > diff --git a/libavformat/ipfs.c b/libavformat/ipfs.c > new file mode 100644 > index 0000000000..4cc65750ed > --- /dev/null > +++ b/libavformat/ipfs.c > @@ -0,0 +1,202 @@ > +/* > + * IPFS protocol. > + * Copyright (c) 2021 Mark Gaiser > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#include "libavutil/avassert.h" > +#include "libavutil/avstring.h" > +#include "libavutil/internal.h" > +#include "libavutil/opt.h" > +#include "libavutil/tree.h" > +#include "avformat.h" > +#include <fcntl.h> > +#if HAVE_IO_H > +#include <io.h> > +#endif > +#if HAVE_UNISTD_H > +#include <unistd.h> > +#endif > +#include <sys/stat.h> > +#include <stdlib.h> > +#include "os_support.h" > +#include "url.h" > + > +typedef struct Context { > + AVClass *class; > + URLContext *inner; > + char *fulluri; > + char *gateway; > +} Context; > + > +static int ipfs_open(URLContext *h, const char *uri, int flags, AVDictionary **options) > +{ > + const char *gatewaysuffix; > + int ret = 0; the initializuation seems redundant > + Context *c = h->priv_data; > + > + if (!av_strstart(uri, "ipfs://", &gatewaysuffix) && > + !av_strstart(uri, "ipfs:", &gatewaysuffix)) { > + av_log(h, AV_LOG_ERROR, "Unsupported url %s\n", uri); > + ret = AVERROR(EINVAL); > + goto err; > + } > + > + char* ipfs_gateway = "https://ipfs.io/ipfs/"; > + > + c->fulluri = malloc(strlen(ipfs_gateway)+strlen(gatewaysuffix) + 1); > + > + strcpy(c->fulluri, ipfs_gateway); > + strcat(c->fulluri, gatewaysuffix); malloc() should be av_malloc() unless there is some API interaction requiring otherwise also all the cpy/cat stuff should use "secure" size checking variants but maybe something like av_asprintf() could simplify this all [...] thx -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Elect your leaders based on what they did after the last election, not based on what they say before an election. [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] [-- Attachment #2: Type: text/plain, Size: 251 bytes --] _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-01-31 15:59 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-01-31 13:51 [FFmpeg-devel] [PATCH 0/5] Add IPFS and IPNS " Mark Gaiser 2022-01-31 13:51 ` [FFmpeg-devel] [PATCH 1/5] Early version of IPFS " Mark Gaiser 2022-01-31 15:59 ` Michael Niedermayer [this message] 2022-01-31 16:06 ` James Almer 2022-01-31 16:34 ` Mark Gaiser 2022-01-31 20:26 ` Lynne 2022-01-31 22:04 ` Mark Gaiser 2022-01-31 13:51 ` [FFmpeg-devel] [PATCH 2/5] Fix up IPNS support Mark Gaiser 2022-01-31 16:00 ` Michael Niedermayer 2022-01-31 13:51 ` [FFmpeg-devel] [PATCH 3/5] Merge IPNS and IPFS handling Mark Gaiser 2022-01-31 13:51 ` [FFmpeg-devel] [PATCH 4/5] Implement logic to determine the IPFS gateway Mark Gaiser 2022-01-31 13:51 ` [FFmpeg-devel] [PATCH 5/5] Fix review feedback Mark Gaiser 2022-01-31 15:46 ` Michael Niedermayer 2022-01-31 16:33 ` Mark Gaiser 2022-01-31 15:52 ` [FFmpeg-devel] [PATCH 0/5] Add IPFS and IPNS protocol support Tomas Härdin 2022-01-31 16:31 ` Mark Gaiser 2022-01-31 20:22 ` Tomas Härdin 2022-01-31 22:00 ` Mark Gaiser 2022-02-01 16:39 ` Tomas Härdin 2022-02-01 21:18 ` Mark Gaiser 2022-02-02 12:51 ` Tomas Härdin 2022-02-02 13:32 ` Mark Gaiser 2022-02-01 10:06 ` Michael Niedermayer 2022-02-01 16:43 ` Tomas Härdin 2022-02-02 13:48 ` Michael Niedermayer 2022-02-04 10:28 ` Tomas Härdin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220131155927.GJ2829255@pb2 \ --to=michael@niedermayer.cc \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git