Go to the documentation of this file.
53 char ipfs_full_data_folder[
PATH_MAX];
58 FILE *gateway_file =
NULL;
59 char *env_ipfs_gateway, *env_ipfs_path;
63 if (env_ipfs_gateway !=
NULL) {
64 int printed =
snprintf(
c->gateway_buffer,
sizeof(
c->gateway_buffer),
65 "%s", env_ipfs_gateway);
67 if (printed >=
sizeof(
c->gateway_buffer)) {
69 "The IPFS_GATEWAY environment variable "
70 "exceeds the maximum length. "
71 "We allow a max of %zu characters\n",
72 sizeof(
c->gateway_buffer));
85 if (env_ipfs_path ==
NULL) {
92 if (env_home ==
NULL) {
100 ipfs_full_data_folder,
sizeof(ipfs_full_data_folder),
101 "%s/.ipfs/", env_home);
103 if (printed >=
sizeof(ipfs_full_data_folder)) {
105 "The IPFS data path exceeds the "
106 "max path length (%zu)\n",
107 sizeof(ipfs_full_data_folder));
114 stat_ret = stat(ipfs_full_data_folder, &st);
118 "Unable to find IPFS folder. We tried:\n"
119 "- $IPFS_PATH, which was empty.\n"
120 "- $HOME/.ipfs (full uri: %s) which doesn't exist.\n",
121 ipfs_full_data_folder);
127 ipfs_full_data_folder,
sizeof(ipfs_full_data_folder),
128 "%s", env_ipfs_path);
130 if (printed >=
sizeof(ipfs_full_data_folder)) {
132 "The IPFS_PATH environment variable "
133 "exceeds the maximum length. "
134 "We allow a max of %zu characters\n",
135 sizeof(
c->gateway_buffer));
142 if (
snprintf(ipfs_gateway_file,
sizeof(ipfs_gateway_file),
"%sgateway",
143 ipfs_full_data_folder)
144 >=
sizeof(ipfs_gateway_file)) {
146 "The IPFS gateway file path exceeds "
147 "the max path length (%zu)\n",
148 sizeof(ipfs_gateway_file));
157 "The IPFS gateway file (full uri: %s) doesn't exist. "
158 "Is the gateway enabled?\n",
165 if (!fgets(
c->gateway_buffer,
sizeof(
c->gateway_buffer) - 1, gateway_file)) {
173 c->gateway_buffer[strcspn(
c->gateway_buffer,
"\r\n")] = 0;
177 if (*
c->gateway_buffer ==
'\0') {
179 "The IPFS gateway file (full uri: %s) appears to be empty. "
180 "Is the gateway started?\n",
192 fclose(gateway_file);
199 const char *ipfs_cid;
200 char *fulluri =
NULL;
210 if (!is_ipfs && !is_ipns) {
219 if (strlen(ipfs_cid) < 1) {
226 if (
c->gateway !=
NULL) {
227 if (
snprintf(
c->gateway_buffer,
sizeof(
c->gateway_buffer),
"%s",
229 >=
sizeof(
c->gateway_buffer)) {
231 "The -gateway parameter is too long. "
232 "We allow a max of %zu characters\n",
233 sizeof(
c->gateway_buffer));
244 "IPFS does not appear to be running.\n\n"
245 "Installing IPFS locally is recommended to "
246 "improve performance and reliability, "
247 "and not share all your activity with a single IPFS gateway.\n"
248 "There are multiple options to define this gateway.\n"
249 "1. Call ffmpeg with a gateway param, "
250 "without a trailing slash: -gateway <url>.\n"
251 "2. Define an $IPFS_GATEWAY environment variable with the "
252 "full HTTP URL to the gateway "
253 "without trailing forward slash.\n"
254 "3. Define an $IPFS_PATH environment variable "
255 "and point it to the IPFS data path "
256 "- this is typically ~/.ipfs\n");
266 "The gateway URL didn't start with http:// or "
267 "https:// and is therefore invalid.\n");
281 (
c->gateway_buffer[strlen(
c->gateway_buffer) - 1] ==
'/') ?
"" :
"/",
282 (is_ipns) ?
"ipns/" :
"ipfs/",
294 h->protocol_whitelist,
295 h->protocol_blacklist,
h);
324 #define OFFSET(x) offsetof(IPFSGatewayContext, x)
#define AV_LOG_WARNING
Something somehow does not look correct.
const URLProtocol ff_ipfs_protocol
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int64_t ffurl_seek(URLContext *h, int64_t pos, int whence)
Change the position that will be used by the next read/write operation on the resource accessed by h.
char * av_asprintf(const char *fmt,...)
const URLProtocol ff_ipns_protocol
static void freeenv_utf8(char *var)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist, URLContext *parent)
Create an URLContext for accessing to the resource indicated by url, and open it.
char gateway_buffer[PATH_MAX]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int av_stristart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str independent of case.
static int64_t ipfs_seek(URLContext *h, int64_t pos, int whence)
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
const char * av_default_item_name(void *ptr)
Return the context name.
static char * getenv_utf8(const char *varname)
static const AVClass ipfs_context_class
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#define AV_LOG_INFO
Standard information.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
FILE * avpriv_fopen_utf8(const char *path, const char *mode)
Open a file using a UTF-8 filename.
static int translate_ipfs_to_http(URLContext *h, const char *uri, int flags, AVDictionary **options)
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
static const AVOption options[]
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int ffurl_read(URLContext *h, unsigned char *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf.
#define flags(name, subs,...)
static int ipfs_read(URLContext *h, unsigned char *buf, int size)
static int ipfs_close(URLContext *h)
static int populate_ipfs_gateway(URLContext *h)