vlc | branch: master | Francois Cartegnie <[email protected]> | Thu Dec 7 16:52:19 2017 +0100| [9eba78d641f70ce405f6be4f192f16f0343128c3] | committer: Francois Cartegnie
demux: avformat: refactor stream info/options > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9eba78d641f70ce405f6be4f192f16f0343128c3 --- modules/demux/avformat/demux.c | 64 +++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c index f7e2531254..ce59cc7ccc 100644 --- a/modules/demux/avformat/demux.c +++ b/modules/demux/avformat/demux.c @@ -167,6 +167,42 @@ static void get_rotation(es_format_t *fmt, AVStream *s) } } +static void FindStreamInfo( demux_t *p_demux ) +{ + demux_sys_t *p_sys = p_demux->p_sys; + unsigned nb_streams = p_sys->ic->nb_streams; + + char *psz_opts = var_InheritString( p_demux, "avformat-options" ); + AVDictionary *options[nb_streams ? nb_streams : 1]; + options[0] = NULL; + for (unsigned i = 1; i < nb_streams; i++) + options[i] = NULL; + if (psz_opts) { + vlc_av_get_options(psz_opts, &options[0]); + for (unsigned i = 1; i < nb_streams; i++) { + av_dict_copy(&options[i], options[0], 0); + } + free(psz_opts); + } + vlc_avcodec_lock(); /* avformat calls avcodec behind our back!!! */ + int error = avformat_find_stream_info( p_sys->ic, options ); + vlc_avcodec_unlock(); + AVDictionaryEntry *t = NULL; + while ((t = av_dict_get(options[0], "", t, AV_DICT_IGNORE_SUFFIX))) { + msg_Err( p_demux, "Unknown option \"%s\"", t->key ); + } + av_dict_free(&options[0]); + for (unsigned i = 1; i < nb_streams; i++) { + av_dict_free(&options[i]); + } + + if( error < 0 ) + { + msg_Warn( p_demux, "Could not find stream info: %s", + vlc_strerror_c(AVUNERROR(error)) ); + } +} + static int avformat_ProbeDemux( vlc_object_t *p_this, AVInputFormat **pp_fmt, const char *psz_url ) { @@ -337,33 +373,9 @@ int avformat_OpenDemux( vlc_object_t *p_this ) return VLC_EGENERIC; } - char *psz_opts = var_InheritString( p_demux, "avformat-options" ); - unsigned nb_streams = p_sys->ic->nb_streams; - - AVDictionary *options[nb_streams ? nb_streams : 1]; - options[0] = NULL; - for (unsigned i = 1; i < nb_streams; i++) - options[i] = NULL; - if (psz_opts) { - vlc_av_get_options(psz_opts, &options[0]); - for (unsigned i = 1; i < nb_streams; i++) { - 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[0], "", t, AV_DICT_IGNORE_SUFFIX))) { - msg_Err( p_demux, "Unknown option \"%s\"", t->key ); - } - av_dict_free(&options[0]); - for (unsigned i = 1; i < nb_streams; i++) { - av_dict_free(&options[i]); - } + FindStreamInfo( p_demux ); - nb_streams = p_sys->ic->nb_streams; /* it may have changed */ + unsigned nb_streams = p_sys->ic->nb_streams; /* it may have changed */ if( !nb_streams ) { msg_Err( p_demux, "No streams found"); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
