[FFmpeg-devel,2/2] libavformat/tee: Add possibility to pass fifo options by using fifo_ prefix

Submitted by sebechlebskyjan@gmail.com on Dec. 22, 2016, 9:06 a.m.

Details

Message ID 1482397596-7571-3-git-send-email-sebechlebskyjan@gmail.com
State New
Headers show

Commit Message

sebechlebskyjan@gmail.com Dec. 22, 2016, 9:06 a.m.
From: Jan Sebechlebsky <sebechlebskyjan@gmail.com>

---
 doc/muxers.texi   |  9 +++++++++
 libavformat/tee.c | 20 ++++++++++++++++++++
 2 files changed, 29 insertions(+)

Patch hide | download patch | download mbox

diff --git a/doc/muxers.texi b/doc/muxers.texi
index ced223e..139ced0 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1603,6 +1603,11 @@  outputs and setup transparent recovery. By default this feature is turned off.
 @item fifo_options
 Options to pass to fifo pseudo-muxer instances. See @ref{fifo}.
 
+@item fifo_[opt]
+Option will be passed as [opt] to fifo pseudo-muxer instances. For example
+fifo_queue_size will set queue_size option of fifo pseudo muxer.
+This allows to specify fifo_options without need of extensive escaping.
+
 @end table
 
 The slave outputs are specified in the file name given to the muxer,
@@ -1633,6 +1638,10 @@  This allows to override tee muxer use_fifo option for individual slave muxer.
 This allows to override tee muxer fifo_options for individual slave muxer.
 See @ref{fifo}.
 
+@item fifo_[opt]
+This allows to override tee muxer fifo_options by setting [opt] for fifo of
+individual slave muxer, without need of another level of escaping.
+
 It is possible to specify to which streams a given bitstream filter
 applies, by appending a stream specifier to the option separated by
 @code{/}. @var{spec} must be a stream specifier (see @ref{Format
diff --git a/libavformat/tee.c b/libavformat/tee.c
index 99259a7..7001e38 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -156,6 +156,23 @@  static void close_slaves(AVFormatContext *avf)
     av_freep(&tee->slaves);
 }
 
+static int steal_fifo_options(AVDictionary **src_options, AVDictionary **dst_options)
+{
+    int ret;
+    AVDictionaryEntry *entry;
+
+    while((entry = av_dict_get(*src_options, "fifo_", NULL, AV_DICT_IGNORE_SUFFIX))) {
+        ret = av_dict_set(dst_options, entry->key + 5, /* 5 = strlen("fifo_") */
+                          entry->value, AV_DICT_DONT_STRDUP_VAL);
+        if (ret < 0)
+            return ret;
+
+        entry->value = NULL;
+        ret = av_dict_set(src_options, entry->key, NULL, 0);
+    }
+    return 0;
+}
+
 static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
 {
     int i, ret;
@@ -186,6 +203,9 @@  static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
     STEAL_OPTION("onfail", on_fail);
     STEAL_OPTION("use_fifo", use_fifo);
     STEAL_OPTION("fifo_options", fifo_options_str);
+    ret = steal_fifo_options(&options, &tee_slave->fifo_options);
+    if (ret < 0)
+        goto end;
 
     ret = parse_slave_failure_policy_option(on_fail, tee_slave);
     if (ret < 0) {