]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/avio.c
avutil: remove deprecated AVClass.child_class_next
[ffmpeg] / libavformat / avio.c
index 663789ec024264f877d6a695f17549c722731905..2974f4b2b4e4f954caf1dbb3ad1fb0063073c7e5 100644 (file)
@@ -26,6 +26,7 @@
 #include "libavutil/avassert.h"
 #include "os_support.h"
 #include "avformat.h"
+#include "internal.h"
 #if CONFIG_NETWORK
 #include "network.h"
 #endif
@@ -54,8 +55,8 @@ static void *urlcontext_child_next(void *obj, void *prev)
 #define E AV_OPT_FLAG_ENCODING_PARAM
 #define D AV_OPT_FLAG_DECODING_PARAM
 static const AVOption options[] = {
-    {"protocol_whitelist", "List of protocols that are allowed to be used", OFFSET(protocol_whitelist), AV_OPT_TYPE_STRING, { .str = NULL },  CHAR_MIN, CHAR_MAX, D },
-    {"protocol_blacklist", "List of protocols that are not allowed to be used", OFFSET(protocol_blacklist), AV_OPT_TYPE_STRING, { .str = NULL },  CHAR_MIN, CHAR_MAX, D },
+    {"protocol_whitelist", "List of protocols that are allowed to be used", OFFSET(protocol_whitelist), AV_OPT_TYPE_STRING, { .str = NULL },  0, 0, D },
+    {"protocol_blacklist", "List of protocols that are not allowed to be used", OFFSET(protocol_blacklist), AV_OPT_TYPE_STRING, { .str = NULL },  0, 0, D },
     {"rw_timeout", "Timeout for IO operations (in microseconds)", offsetof(URLContext, rw_timeout), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT64_MAX, AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_DECODING_PARAM },
     { NULL }
 };
@@ -66,7 +67,7 @@ const AVClass ffurl_context_class = {
     .option           = options,
     .version          = LIBAVUTIL_VERSION_INT,
     .child_next       = urlcontext_child_next,
-    .child_class_next = ff_urlcontext_child_class_next,
+    .child_class_iterate = ff_urlcontext_child_class_iterate,
 };
 /*@}*/
 
@@ -110,11 +111,10 @@ static int url_alloc_for_protocol(URLContext **puc, const URLProtocol *up,
             goto fail;
         }
         if (up->priv_data_class) {
-            int proto_len= strlen(up->name);
-            char *start = strchr(uc->filename, ',');
+            char *start;
             *(const AVClass **)uc->priv_data = up->priv_data_class;
             av_opt_set_defaults(uc->priv_data);
-            if(!strncmp(up->name, uc->filename, proto_len) && uc->filename + proto_len == start){
+            if (av_strstart(uc->filename, up->name, (const char**)&start) && *start == ',') {
                 int ret= 0;
                 char *p= start;
                 char sep= *++p;
@@ -283,6 +283,9 @@ static const struct URLProtocol *url_find_protocol(const char *filename)
         }
     }
     av_freep(&protocols);
+    if (av_strstart(filename, "https:", NULL) || av_strstart(filename, "tls:", NULL))
+        av_log(NULL, AV_LOG_WARNING, "https protocol not found, recompile FFmpeg with "
+                                     "openssl, gnutls or securetransport enabled.\n");
 
     return NULL;
 }
@@ -297,10 +300,6 @@ int ffurl_alloc(URLContext **puc, const char *filename, int flags,
        return url_alloc_for_protocol(puc, p, filename, flags, int_cb);
 
     *puc = NULL;
-    if (av_strstart(filename, "https:", NULL) || av_strstart(filename, "tls:", NULL))
-        av_log(NULL, AV_LOG_WARNING, "https protocol not found, recompile FFmpeg with "
-                                     "openssl, gnutls "
-                                     "or securetransport enabled.\n");
     return AVERROR_PROTOCOL_NOT_FOUND;
 }
 
@@ -347,18 +346,10 @@ int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags,
     if (!ret)
         return 0;
 fail:
-    ffurl_close(*puc);
-    *puc = NULL;
+    ffurl_closep(puc);
     return ret;
 }
 
-int ffurl_open(URLContext **puc, const char *filename, int flags,
-               const AVIOInterruptCB *int_cb, AVDictionary **options)
-{
-    return ffurl_open_whitelist(puc, filename, flags,
-                                int_cb, options, NULL, NULL, NULL);
-}
-
 static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf,
                                          int size, int size_min,
                                          int (*transfer_func)(URLContext *h,
@@ -667,3 +658,11 @@ int ff_check_interrupt(AVIOInterruptCB *cb)
         return cb->callback(cb->opaque);
     return 0;
 }
+
+int ff_rename(const char *url_src, const char *url_dst, void *logctx)
+{
+    int ret = avpriv_io_move(url_src, url_dst);
+    if (ret < 0)
+        av_log(logctx, AV_LOG_ERROR, "failed to rename file %s to %s: %s\n", url_src, url_dst, av_err2str(ret));
+    return ret;
+}