Commit 08fb37c0 authored by Rafaël Carré's avatar Rafaël Carré

avformat (mux/demux): implement private options

parent 637db918
......@@ -67,7 +67,7 @@ static inline void vlc_init_avcodec(void)
static inline AVDictionary *vlc_av_get_options(const char *psz_opts)
{
AVDictionary *options = NULL;
config_chain_t *cfg;
config_chain_t *cfg = NULL;
config_ChainParseOptions(&cfg, psz_opts);
while (cfg) {
config_chain_t *next = cfg->p_next;
......
......@@ -31,6 +31,7 @@
#include <vlc_plugin.h>
#include "avformat.h"
#include "../../codec/avcodec/avcommon.h"
vlc_module_begin ()
#endif /* MERGE_FFMPEG */
......@@ -43,6 +44,7 @@ vlc_module_begin ()
set_callbacks( OpenDemux, CloseDemux )
add_string( "avformat-format", NULL, FORMAT_TEXT, FORMAT_LONGTEXT, true )
add_obsolete_string("ffmpeg-format") /* removed since 2.1.0 */
add_string( "avformat-options", NULL, AV_OPTIONS_TEXT, AV_OPTIONS_LONGTEXT, true )
#ifdef ENABLE_SOUT
/* mux submodule */
......@@ -52,6 +54,7 @@ vlc_module_begin ()
set_capability( "sout mux", 2 )
add_string( "sout-avformat-mux", NULL, MUX_TEXT, MUX_LONGTEXT, true )
add_obsolete_string("ffmpeg-mux") /* removed since 2.1.0 */
add_string( "sout-avformat-options", NULL, AV_OPTIONS_TEXT, AV_OPTIONS_LONGTEXT, true )
set_callbacks( OpenMux, CloseMux )
#endif
#ifndef MERGE_FFMPEG
......
......@@ -250,13 +250,31 @@ int OpenDemux( vlc_object_t *p_this )
return VLC_EGENERIC;
}
vlc_avcodec_lock(); /* avformat calls avcodec behind our back!!! */
#if LIBAVFORMAT_VERSION_INT >= ((53<<16)+(26<<8)+0)
error = avformat_find_stream_info( p_sys->ic, NULL /* options */ );
char *psz_opts = var_InheritString( p_demux, "avformat-options" );
AVDictionary *options[p_sys->ic->nb_streams];
if (psz_opts && *psz_opts) {
options[0] = vlc_av_get_options(psz_opts);
for (unsigned i = 1; i < p_sys->ic->nb_streams; i++) {
options[i] = NULL;
av_dict_copy(&options[i], options[0], 0);
}
}
free(psz_opts);
vlc_avcodec_lock(); /* avformat calls avcodec behind our back!!! */
error = avformat_find_stream_info( p_sys->ic, options );
vlc_avcodec_unlock();
AVDictionaryEntry *t = NULL;
while ((t = av_dict_get(options, "", t, AV_DICT_IGNORE_SUFFIX))) {
msg_Err( p_demux, "Unknown option \"%s\"", t->key );
}
av_dict_free(&options);
#else
vlc_avcodec_lock(); /* avformat calls avcodec behind our back!!! */
error = av_find_stream_info( p_sys->ic );
#endif
vlc_avcodec_unlock();
#endif
if( error < 0 )
{
errno = AVUNERROR(error);
......
......@@ -47,7 +47,7 @@
//#define AVFORMAT_DEBUG 1
static const char *const ppsz_mux_options[] = {
"mux", NULL
"mux", "options", NULL
};
/*****************************************************************************
......@@ -381,7 +381,17 @@ static int Mux( sout_mux_t *p_mux )
msg_Dbg( p_mux, "writing header" );
#if (LIBAVFORMAT_VERSION_INT >= ((53<<16)+(2<<8)+0))
error = avformat_write_header( p_sys->oc, NULL /* options */ );
char *psz_opts = var_GetNonEmptyString( p_mux, "sout-avformat-options" );
AVDictionary *options = NULL;
if (psz_opts && *psz_opts)
options = vlc_av_get_options(psz_opts);
free(psz_opts);
error = avformat_write_header( p_sys->oc, options ? &options : NULL);
AVDictionaryEntry *t = NULL;
while ((t = av_dict_get(options, "", t, AV_DICT_IGNORE_SUFFIX))) {
msg_Err( p_mux, "Unknown option \"%s\"", t->key );
}
av_dict_free(&options);
#else
error = av_write_header( p_sys->oc );
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment