X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fstream_out%2Fduplicate.c;h=51cc9ea8c6a79ff8a96b493c3c27d521e3f823ba;hb=17ea145c1be2c35073c31d151b2b34ae23530a8b;hp=4585638739c968d6862a6b67980d980c1d91eceb;hpb=df7711771f63427a2535835551f419f7760d3f7f;p=vlc diff --git a/modules/stream_out/duplicate.c b/modules/stream_out/duplicate.c index 4585638739..51cc9ea8c6 100644 --- a/modules/stream_out/duplicate.c +++ b/modules/stream_out/duplicate.c @@ -40,15 +40,14 @@ static int Open ( vlc_object_t * ); static void Close ( vlc_object_t * ); -vlc_module_begin(); - set_description( N_("Duplicate stream output") ); - set_capability( "sout stream", 50 ); - add_shortcut( "duplicate" ); - add_shortcut( "dup" ); - set_category( CAT_SOUT ); - set_subcategory( SUBCAT_SOUT_STREAM ); - set_callbacks( Open, Close ); -vlc_module_end(); +vlc_module_begin () + set_description( N_("Duplicate stream output") ) + set_capability( "sout stream", 50 ) + add_shortcut( "duplicate", "dup" ) + set_category( CAT_SOUT ) + set_subcategory( SUBCAT_SOUT_STREAM ) + set_callbacks( Open, Close ) +vlc_module_end () /***************************************************************************** @@ -64,6 +63,9 @@ struct sout_stream_sys_t int i_nb_streams; sout_stream_t **pp_streams; + int i_nb_last_streams; + sout_stream_t **pp_last_streams; + int i_nb_select; char **ppsz_select; }; @@ -92,20 +94,24 @@ static int Open( vlc_object_t *p_this ) return VLC_ENOMEM; TAB_INIT( p_sys->i_nb_streams, p_sys->pp_streams ); + TAB_INIT( p_sys->i_nb_last_streams, p_sys->pp_last_streams ); TAB_INIT( p_sys->i_nb_select, p_sys->ppsz_select ); for( p_cfg = p_stream->p_cfg; p_cfg != NULL; p_cfg = p_cfg->p_next ) { if( !strncmp( p_cfg->psz_name, "dst", strlen( "dst" ) ) ) { - sout_stream_t *s; + sout_stream_t *s, *p_last; msg_Dbg( p_stream, " * adding `%s'", p_cfg->psz_value ); - s = sout_StreamNew( p_stream->p_sout, p_cfg->psz_value ); + s = sout_StreamChainNew( p_stream->p_sout, p_cfg->psz_value, + p_stream->p_next, &p_last ); if( s ) { TAB_APPEND( p_sys->i_nb_streams, p_sys->pp_streams, s ); + TAB_APPEND( p_sys->i_nb_last_streams, p_sys->pp_last_streams, + p_last ); TAB_APPEND( p_sys->i_nb_select, p_sys->ppsz_select, NULL ); } } @@ -164,10 +170,11 @@ static void Close( vlc_object_t * p_this ) msg_Dbg( p_stream, "closing a duplication" ); for( i = 0; i < p_sys->i_nb_streams; i++ ) { - sout_StreamDelete( p_sys->pp_streams[i] ); + sout_StreamChainDelete(p_sys->pp_streams[i], p_sys->pp_last_streams[i]); free( p_sys->ppsz_select[i] ); } free( p_sys->pp_streams ); + free( p_sys->pp_last_streams ); free( p_sys->ppsz_select ); free( p_sys ); @@ -299,26 +306,27 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, /***************************************************************************** * Divers *****************************************************************************/ -static bool NumInRange( char *psz_range, int i_num ) +static bool NumInRange( const char *psz_range, int i_num ) { - char *psz = strchr( psz_range, '-' ); + const char *psz = strchr( psz_range, '-' ); char *end; int i_start, i_stop; + i_start = strtol( psz_range, &end, 0 ); + if( end == psz_range ) + i_start = i_num; + if( psz ) { - i_start = strtol( psz_range, &end, 0 ); - if( end == psz_range ) i_start = i_num; - - i_stop = strtol( psz, &end, 0 ); - if( end == psz_range ) i_stop = i_num; + psz++; + i_stop = strtol( psz, &end, 0 ); + if( end == psz ) + i_stop = i_num; } else - { - i_start = i_stop = strtol( psz_range, NULL, 0 ); - } + i_stop = i_start; - return i_start <= i_num && i_num <= i_stop ? true : false; + return i_start <= i_num && i_num <= i_stop; } static bool ESSelected( es_format_t *fmt, char *psz_select )