typedef struct URLContext {
const AVClass *av_class; /**< information for av_log(). Set by url_open(). */
const struct URLProtocol *prot;
+ /**
+ * A NULL-terminated list of protocols usable by the child contexts.
+ */
+ const struct URLProtocol **protocols;
void *priv_data;
char *filename; /**< specified URL */
int flags;
int is_streamed; /**< true if streamed (no seek possible), default = false */
int is_connected;
AVIOInterruptCB interrupt_callback;
+ int64_t rw_timeout; /**< maximum time to wait for (network) read/write operation completion, in microseconds */
} URLContext;
typedef struct URLProtocol {
* is to be opened
* @param int_cb interrupt callback to use for the URLContext, may be
* NULL
+ * @param protocols a NULL-terminate list of protocols available for use by
+ * this context and its children. The caller must ensure this
+ * list remains valid until the context is closed.
* @return 0 in case of success, a negative value corresponding to an
* AVERROR code in case of failure
*/
int ffurl_alloc(URLContext **puc, const char *filename, int flags,
- const AVIOInterruptCB *int_cb);
+ const AVIOInterruptCB *int_cb,
+ const URLProtocol **protocols);
/**
* Connect an URLContext that has been allocated by ffurl_alloc
* @param options A dictionary filled with protocol-private options. On return
* this parameter will be destroyed and replaced with a dict containing options
* that were not found. May be NULL.
+ * @param protocols a NULL-terminate list of protocols available for use by
+ * this context and its children. The caller must ensure this
+ * list remains valid until the context is closed.
+ * @param parent An enclosing URLContext, whose generic options should
+ * be applied to this URLContext as well.
* @return 0 in case of success, a negative value corresponding to an
* AVERROR code in case of failure
*/
int ffurl_open(URLContext **puc, const char *filename, int flags,
- const AVIOInterruptCB *int_cb, AVDictionary **options);
+ const AVIOInterruptCB *int_cb, AVDictionary **options,
+ const URLProtocol **protocols, URLContext *parent);
/**
* Read up to size bytes from the resource accessed by h, and store
int ffurl_shutdown(URLContext *h, int flags);
/**
- * Check if the user has requested to interrup a blocking function
+ * Check if the user has requested to interrupt a blocking function
* associated with cb.
*/
int ff_check_interrupt(AVIOInterruptCB *cb);
void ff_make_absolute_url(char *buf, int size, const char *base,
const char *rel);
-extern const URLProtocol *ff_url_protocols[];
+const AVClass *ff_urlcontext_child_class_next(const AVClass *prev);
+
+/**
+ * Construct a list of protocols matching a given whitelist and/or blacklist.
+ *
+ * @param whitelist a comma-separated list of allowed protocol names or NULL. If
+ * this is a non-empty string, only protocols in this list will
+ * be included.
+ * @param blacklist a comma-separated list of forbidden protocol names or NULL.
+ * If this is a non-empty string, all protocols in this list
+ * will be excluded.
+ *
+ * @return a NULL-terminated array of matching protocols. The array must be
+ * freed by the caller.
+ */
+const URLProtocol **ffurl_get_protocols(const char *whitelist,
+ const char *blacklist);
#endif /* AVFORMAT_URL_H */