Go to the documentation of this file.
54 char ipfs_full_data_folder[
PATH_MAX];
59 FILE *gateway_file =
NULL;
60 char *env_ipfs_gateway, *env_ipfs_path;
64 if (env_ipfs_gateway !=
NULL) {
65 int printed =
snprintf(
c->gateway_buffer,
sizeof(
c->gateway_buffer),
66 "%s", env_ipfs_gateway);
68 if (printed >=
sizeof(
c->gateway_buffer)) {
70 "The IPFS_GATEWAY environment variable "
71 "exceeds the maximum length. "
72 "We allow a max of %zu characters\n",
73 sizeof(
c->gateway_buffer));
86 if (env_ipfs_path ==
NULL) {
93 if (env_home ==
NULL) {
101 ipfs_full_data_folder,
sizeof(ipfs_full_data_folder),
102 "%s/.ipfs/", env_home);
104 if (printed >=
sizeof(ipfs_full_data_folder)) {
106 "The IPFS data path exceeds the "
107 "max path length (%zu)\n",
108 sizeof(ipfs_full_data_folder));
115 stat_ret = stat(ipfs_full_data_folder, &st);
119 "Unable to find IPFS folder. We tried:\n"
120 "- $IPFS_PATH, which was empty.\n"
121 "- $HOME/.ipfs (full uri: %s) which doesn't exist.\n",
122 ipfs_full_data_folder);
128 ipfs_full_data_folder,
sizeof(ipfs_full_data_folder),
129 "%s", env_ipfs_path);
131 if (printed >=
sizeof(ipfs_full_data_folder)) {
133 "The IPFS_PATH environment variable "
134 "exceeds the maximum length. "
135 "We allow a max of %zu characters\n",
136 sizeof(
c->gateway_buffer));
143 if (
snprintf(ipfs_gateway_file,
sizeof(ipfs_gateway_file),
"%sgateway",
144 ipfs_full_data_folder)
145 >=
sizeof(ipfs_gateway_file)) {
147 "The IPFS gateway file path exceeds "
148 "the max path length (%zu)\n",
149 sizeof(ipfs_gateway_file));
158 "The IPFS gateway file (full uri: %s) doesn't exist. "
159 "Is the gateway enabled?\n",
166 if (!fgets(
c->gateway_buffer,
sizeof(
c->gateway_buffer) - 1, gateway_file)) {
174 c->gateway_buffer[strcspn(
c->gateway_buffer,
"\r\n")] = 0;
178 if (*
c->gateway_buffer ==
'\0') {
180 "The IPFS gateway file (full uri: %s) appears to be empty. "
181 "Is the gateway started?\n",
193 fclose(gateway_file);
200 const char *ipfs_cid;
201 char *fulluri =
NULL;
211 if (!is_ipfs && !is_ipns) {
220 if (strlen(ipfs_cid) < 1) {
227 if (
c->gateway !=
NULL) {
228 if (
snprintf(
c->gateway_buffer,
sizeof(
c->gateway_buffer),
"%s",
230 >=
sizeof(
c->gateway_buffer)) {
232 "The -gateway parameter is too long. "
233 "We allow a max of %zu characters\n",
234 sizeof(
c->gateway_buffer));
245 "IPFS does not appear to be running.\n\n"
246 "Installing IPFS locally is recommended to "
247 "improve performance and reliability, "
248 "and not share all your activity with a single IPFS gateway.\n"
249 "There are multiple options to define this gateway.\n"
250 "1. Call ffmpeg with a gateway param, "
251 "without a trailing slash: -gateway <url>.\n"
252 "2. Define an $IPFS_GATEWAY environment variable with the "
253 "full HTTP URL to the gateway "
254 "without trailing forward slash.\n"
255 "3. Define an $IPFS_PATH environment variable "
256 "and point it to the IPFS data path "
257 "- this is typically ~/.ipfs\n");
267 "The gateway URL didn't start with http:// or "
268 "https:// and is therefore invalid.\n");
282 (
c->gateway_buffer[strlen(
c->gateway_buffer) - 1] ==
'/') ?
"" :
"/",
283 (is_ipns) ?
"ipns/" :
"ipfs/",
295 h->protocol_whitelist,
296 h->protocol_blacklist,
h);
325 #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
#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...
#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)
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.