URLContext: switch to child_class_iterate()

This commit is contained in:
Anton Khirnov 2020-05-27 15:34:07 +02:00
parent c7d8d8d8d9
commit 43ed2b86d6
3 changed files with 23 additions and 0 deletions

View File

@ -67,7 +67,10 @@ const AVClass ffurl_context_class = {
.option = options, .option = options,
.version = LIBAVUTIL_VERSION_INT, .version = LIBAVUTIL_VERSION_INT,
.child_next = urlcontext_child_next, .child_next = urlcontext_child_next,
#if FF_API_CHILD_CLASS_NEXT
.child_class_next = ff_urlcontext_child_class_next, .child_class_next = ff_urlcontext_child_class_next,
#endif
.child_class_iterate = ff_urlcontext_child_class_iterate,
}; };
/*@}*/ /*@}*/

View File

@ -73,6 +73,7 @@ extern const URLProtocol ff_libzmq_protocol;
#include "libavformat/protocol_list.c" #include "libavformat/protocol_list.c"
#if FF_API_CHILD_CLASS_NEXT
const AVClass *ff_urlcontext_child_class_next(const AVClass *prev) const AVClass *ff_urlcontext_child_class_next(const AVClass *prev)
{ {
int i; int i;
@ -91,7 +92,22 @@ const AVClass *ff_urlcontext_child_class_next(const AVClass *prev)
return url_protocols[i]->priv_data_class; return url_protocols[i]->priv_data_class;
return NULL; return NULL;
} }
#endif
const AVClass *ff_urlcontext_child_class_iterate(void **iter)
{
const AVClass *ret = NULL;
uintptr_t i;
for (i = (uintptr_t)*iter; url_protocols[i]; i++) {
ret = url_protocols[i]->priv_data_class;
if (ret)
break;
}
*iter = (void*)(uintptr_t)(url_protocols[i] ? i + 1 : i);
return ret;
}
const char *avio_enum_protocols(void **opaque, int output) const char *avio_enum_protocols(void **opaque, int output)
{ {

View File

@ -322,7 +322,11 @@ void ff_make_absolute_url(char *buf, int size, const char *base,
*/ */
AVIODirEntry *ff_alloc_dir_entry(void); AVIODirEntry *ff_alloc_dir_entry(void);
#if FF_API_CHILD_CLASS_NEXT
const AVClass *ff_urlcontext_child_class_next(const AVClass *prev); const AVClass *ff_urlcontext_child_class_next(const AVClass *prev);
#endif
const AVClass *ff_urlcontext_child_class_iterate(void **iter);
/** /**
* Construct a list of protocols matching a given whitelist and/or blacklist. * Construct a list of protocols matching a given whitelist and/or blacklist.