Go to the documentation of this file.
55 char ipfs_full_data_folder[
PATH_MAX];
60 FILE *gateway_file =
NULL;
61 char *env_ipfs_gateway, *env_ipfs_path;
65 if (env_ipfs_gateway !=
NULL) {
66 int printed =
snprintf(
c->gateway_buffer,
sizeof(
c->gateway_buffer),
67 "%s", env_ipfs_gateway);
69 if (printed >=
sizeof(
c->gateway_buffer)) {
71 "The IPFS_GATEWAY environment variable "
72 "exceeds the maximum length. "
73 "We allow a max of %zu characters\n",
74 sizeof(
c->gateway_buffer));
87 if (env_ipfs_path ==
NULL) {
94 if (env_home ==
NULL) {
102 ipfs_full_data_folder,
sizeof(ipfs_full_data_folder),
103 "%s/.ipfs/", env_home);
105 if (printed >=
sizeof(ipfs_full_data_folder)) {
107 "The IPFS data path exceeds the "
108 "max path length (%zu)\n",
109 sizeof(ipfs_full_data_folder));
116 stat_ret = stat(ipfs_full_data_folder, &st);
120 "Unable to find IPFS folder. We tried:\n"
121 "- $IPFS_PATH, which was empty.\n"
122 "- $HOME/.ipfs (full uri: %s) which doesn't exist.\n",
123 ipfs_full_data_folder);
129 ipfs_full_data_folder,
sizeof(ipfs_full_data_folder),
130 "%s", env_ipfs_path);
132 if (printed >=
sizeof(ipfs_full_data_folder)) {
134 "The IPFS_PATH environment variable "
135 "exceeds the maximum length. "
136 "We allow a max of %zu characters\n",
137 sizeof(
c->gateway_buffer));
144 if (
snprintf(ipfs_gateway_file,
sizeof(ipfs_gateway_file),
"%sgateway",
145 ipfs_full_data_folder)
146 >=
sizeof(ipfs_gateway_file)) {
148 "The IPFS gateway file path exceeds "
149 "the max path length (%zu)\n",
150 sizeof(ipfs_gateway_file));
159 "The IPFS gateway file (full uri: %s) doesn't exist. "
160 "Is the gateway enabled?\n",
167 if (!fgets(
c->gateway_buffer,
sizeof(
c->gateway_buffer) - 1, gateway_file)) {
175 c->gateway_buffer[strcspn(
c->gateway_buffer,
"\r\n")] = 0;
179 if (*
c->gateway_buffer ==
'\0') {
181 "The IPFS gateway file (full uri: %s) appears to be empty. "
182 "Is the gateway started?\n",
194 fclose(gateway_file);
201 const char *ipfs_cid;
202 char *fulluri =
NULL;
212 if (!is_ipfs && !is_ipns) {
221 if (strlen(ipfs_cid) < 1) {
228 if (
c->gateway !=
NULL) {
229 if (
snprintf(
c->gateway_buffer,
sizeof(
c->gateway_buffer),
"%s",
231 >=
sizeof(
c->gateway_buffer)) {
233 "The -gateway parameter is too long. "
234 "We allow a max of %zu characters\n",
235 sizeof(
c->gateway_buffer));
246 "IPFS does not appear to be running.\n\n"
247 "Installing IPFS locally is recommended to "
248 "improve performance and reliability, "
249 "and not share all your activity with a single IPFS gateway.\n"
250 "There are multiple options to define this gateway.\n"
251 "1. Call ffmpeg with a gateway param, "
252 "without a trailing slash: -gateway <url>.\n"
253 "2. Define an $IPFS_GATEWAY environment variable with the "
254 "full HTTP URL to the gateway "
255 "without trailing forward slash.\n"
256 "3. Define an $IPFS_PATH environment variable "
257 "and point it to the IPFS data path "
258 "- this is typically ~/.ipfs\n");
268 "The gateway URL didn't start with http:// or "
269 "https:// and is therefore invalid.\n");
283 (
c->gateway_buffer[strlen(
c->gateway_buffer) - 1] ==
'/') ?
"" :
"/",
284 (is_ipns) ?
"ipns/" :
"ipfs/",
296 h->protocol_whitelist,
297 h->protocol_blacklist,
h);
326 #define OFFSET(x) offsetof(IPFSGatewayContext, x)
static 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.
#define AV_LOG_WARNING
Something somehow does not look correct.
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
char * av_asprintf(const char *fmt,...)
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.
const URLProtocol ff_ipns_gateway_protocol
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)
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
static const AVClass ipfs_gateway_context_class
#define AV_LOG_INFO
Standard information.
const URLProtocol ff_ipfs_gateway_protocol
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...
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
#define flags(name, subs,...)
static int ipfs_read(URLContext *h, unsigned char *buf, int size)
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
static int ipfs_close(URLContext *h)
static int populate_ipfs_gateway(URLContext *h)
static int ffurl_read(URLContext *h, uint8_t *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf.