[vlc-commits] avio: specify libav private options

Rafaël Carré git at videolan.org
Sun Nov 4 18:01:09 CET 2012


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Sun Nov  4 18:00:15 2012 +0100| [f8d33b35b84b35ac422e9544f0550ea77be665af] | committer: Rafaël Carré

avio: specify libav private options

Usage: --avio-options={foo=bar,few=baz}

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f8d33b35b84b35ac422e9544f0550ea77be665af
---

 modules/access/avio.c |   24 ++++++++++++++++++++++--
 modules/access/avio.h |    4 +++-
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/modules/access/avio.c b/modules/access/avio.c
index 5221469..e78b1b3 100644
--- a/modules/access/avio.c
+++ b/modules/access/avio.c
@@ -148,7 +148,17 @@ int OpenAvio(vlc_object_t *object)
         .callback = UrlInterruptCallback,
         .opaque = access,
     };
-    ret = avio_open2(&sys->context, url, AVIO_FLAG_READ, &cb, NULL /* options */);
+    AVDictionary *options = NULL;
+    char *psz_opts = var_InheritString(access, "avio-options");
+    if (psz_opts && *psz_opts) {
+        options = vlc_av_get_options(psz_opts);
+        free(psz_opts);
+    }
+    ret = avio_open2(&sys->context, url, AVIO_FLAG_READ, &cb, &options);
+    AVDictionaryEntry *t = NULL;
+    while ((t = av_dict_get(options, "", t, AV_DICT_IGNORE_SUFFIX)))
+        msg_Err( access, "unknown option \"%s\"", t->key );
+    av_dict_free(&options);
 #endif
     if (ret < 0) {
         errno = AVUNERROR(ret);
@@ -216,8 +226,18 @@ int OutOpenAvio(vlc_object_t *object)
         .callback = UrlInterruptCallback,
         .opaque = access,
     };
+    AVDictionary *options = NULL;
+    char *psz_opts = var_InheritString(access, "avio-options");
+    if (psz_opts && *psz_opts) {
+        options = vlc_av_get_options(psz_opts);
+        free(psz_opts);
+    }
     ret = avio_open2(&sys->context, access->psz_path, AVIO_FLAG_WRITE,
-                     &cb, NULL /* options */);
+                     &cb, &options);
+    AVDictionaryEntry *t = NULL;
+    while ((t = av_dict_get(options, "", t, AV_DICT_IGNORE_SUFFIX)))
+        msg_Err( access, "unknown option \"%s\"", t->key );
+    av_dict_free(&options);
 #endif
     if (ret < 0) {
         errno = AVUNERROR(ret);
diff --git a/modules/access/avio.h b/modules/access/avio.h
index c8e599f..2979ae7 100644
--- a/modules/access/avio.h
+++ b/modules/access/avio.h
@@ -43,6 +43,7 @@ void OutCloseAvio(vlc_object_t *);
     set_capability("access", -1)            \
     add_shortcut("avio", "rtmp", "rtmpe", "rtmps", "rtmpt", "rtmpte", "rtmpts") \
     set_callbacks(OpenAvio, CloseAvio) \
+    add_string("avio-options", NULL, AV_OPTIONS_TEXT, AV_OPTIONS_LONGTEXT, true) \
     add_submodule () \
         set_shortname( "libavformat" ) \
         set_description( N_("libavformat access output") ) \
@@ -50,4 +51,5 @@ void OutCloseAvio(vlc_object_t *);
         set_category( CAT_SOUT ) \
         set_subcategory( SUBCAT_SOUT_ACO ) \
         add_shortcut( "avio", "rtmp" ) \
-        set_callbacks( OutOpenAvio, OutCloseAvio)
+        set_callbacks( OutOpenAvio, OutCloseAvio) \
+        add_string("avio-options", NULL, AV_OPTIONS_TEXT, AV_OPTIONS_LONGTEXT, true)



More information about the vlc-commits mailing list