X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fstream_out%2Fduplicate.c;h=2510be0f39294e7000e43b7cc5c9ec8c52c96bc6;hb=175d1beb96ca494f8bfdee0ad488b303ef55e9ec;hp=f7aa83f97c9e90d1fb9da1d754ddfd5129570edb;hpb=8547ffaaeb80e961f0d5a415e863f9f2226629a4;p=vlc diff --git a/modules/stream_out/duplicate.c b/modules/stream_out/duplicate.c index f7aa83f97c..2510be0f39 100644 --- a/modules/stream_out/duplicate.c +++ b/modules/stream_out/duplicate.c @@ -1,7 +1,7 @@ /***************************************************************************** * duplicate.c: duplicate stream output module ***************************************************************************** - * Copyright (C) 2003-2004 VideoLAN + * Copyright (C) 2003-2004 the VideoLAN team * $Id$ * * Author: Laurent Aimar @@ -18,17 +18,21 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include /***************************************************************************** * Module descriptor @@ -37,10 +41,12 @@ static int Open ( vlc_object_t * ); static void Close ( vlc_object_t * ); vlc_module_begin(); - set_description( _("Duplicate stream output") ); + 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(); @@ -68,7 +74,7 @@ struct sout_stream_id_t void **pp_ids; }; -static vlc_bool_t ESSelected( es_format_t *fmt, char *psz_select ); +static bool ESSelected( es_format_t *fmt, char *psz_select ); /***************************************************************************** * Open: @@ -77,7 +83,7 @@ static int Open( vlc_object_t *p_this ) { sout_stream_t *p_stream = (sout_stream_t*)p_this; sout_stream_sys_t *p_sys; - sout_cfg_t *p_cfg; + config_chain_t *p_cfg; msg_Dbg( p_stream, "creating 'duplicate'" ); @@ -95,7 +101,7 @@ static int Open( vlc_object_t *p_this ) sout_stream_t *s; msg_Dbg( p_stream, " * adding `%s'", p_cfg->psz_value ); - s = sout_stream_new( p_stream->p_sout, p_cfg->psz_value ); + s = sout_StreamNew( p_stream->p_sout, p_cfg->psz_value ); if( s ) { @@ -141,23 +147,14 @@ static void Close( vlc_object_t * p_this ) int i; - msg_Dbg( p_stream, "closing a duplication"); + msg_Dbg( p_stream, "closing a duplication" ); for( i = 0; i < p_sys->i_nb_streams; i++ ) { - sout_stream_delete( p_sys->pp_streams[i] ); - if( p_sys->ppsz_select[i] ) - { - free( p_sys->ppsz_select[i] ); - } - } - if( p_sys->pp_streams ) - { - free( p_sys->pp_streams ); - } - if( p_sys->ppsz_select ) - { - free( p_sys->ppsz_select ); + sout_StreamDelete( p_sys->pp_streams[i] ); + free( p_sys->ppsz_select[i] ); } + free( p_sys->pp_streams ); + free( p_sys->ppsz_select ); free( p_sys ); } @@ -176,9 +173,8 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt ) id->pp_ids = NULL; msg_Dbg( p_stream, "duplicated a new stream codec=%4.4s (es=%d group=%d)", - (char*)&p_fmt->i_codec, - p_fmt->i_id, - p_fmt->i_group ); + (char*)&p_fmt->i_codec, p_fmt->i_id, p_fmt->i_group ); + for( i_stream = 0; i_stream < p_sys->i_nb_streams; i_stream++ ) { void *id_new = NULL; @@ -289,7 +285,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, /***************************************************************************** * Divers *****************************************************************************/ -static vlc_bool_t NumInRange( char *psz_range, int i_num ) +static bool NumInRange( char *psz_range, int i_num ) { char *psz = strchr( psz_range, '-' ); char *end; @@ -308,15 +304,15 @@ static vlc_bool_t NumInRange( char *psz_range, int i_num ) i_start = i_stop = strtol( psz_range, NULL, 0 ); } - return i_start <= i_num && i_num <= i_stop ? VLC_TRUE : VLC_FALSE; + return i_start <= i_num && i_num <= i_stop ? true : false; } -static vlc_bool_t ESSelected( es_format_t *fmt, char *psz_select ) +static bool ESSelected( es_format_t *fmt, char *psz_select ) { char *psz_dup; char *psz; - /* We have tree state variable : no tested (-1), failed(0), succeed(1) */ + /* We have tri-state variable : no tested (-1), failed(0), succeed(1) */ int i_cat = -1; int i_es = -1; int i_prgm= -1; @@ -324,7 +320,7 @@ static vlc_bool_t ESSelected( es_format_t *fmt, char *psz_select ) /* If empty all es are selected */ if( psz_select == NULL || *psz_select == '\0' ) { - return VLC_TRUE; + return true; } psz_dup = strdup( psz_select ); psz = psz_dup; @@ -361,7 +357,7 @@ static vlc_bool_t ESSelected( es_format_t *fmt, char *psz_select ) if( !strncmp( psz, "no-audio", strlen( "no-audio" ) ) || !strncmp( psz, "noaudio", strlen( "noaudio" ) ) ) { - if( i_cat != 1 ) + if( i_cat == -1 ) { i_cat = fmt->i_cat != AUDIO_ES ? 1 : 0; } @@ -369,7 +365,7 @@ static vlc_bool_t ESSelected( es_format_t *fmt, char *psz_select ) else if( !strncmp( psz, "no-video", strlen( "no-video" ) ) || !strncmp( psz, "novideo", strlen( "novideo" ) ) ) { - if( i_cat != 1 ) + if( i_cat == -1 ) { i_cat = fmt->i_cat != VIDEO_ES ? 1 : 0; } @@ -377,28 +373,28 @@ static vlc_bool_t ESSelected( es_format_t *fmt, char *psz_select ) else if( !strncmp( psz, "no-spu", strlen( "no-spu" ) ) || !strncmp( psz, "nospu", strlen( "nospu" ) ) ) { - if( i_cat != 1 ) + if( i_cat == -1 ) { i_cat = fmt->i_cat != SPU_ES ? 1 : 0; } } else if( !strncmp( psz, "audio", strlen( "audio" ) ) ) { - if( i_cat != 1 ) + if( i_cat == -1 ) { i_cat = fmt->i_cat == AUDIO_ES ? 1 : 0; } } else if( !strncmp( psz, "video", strlen( "video" ) ) ) { - if( i_cat != 1 ) + if( i_cat == -1 ) { i_cat = fmt->i_cat == VIDEO_ES ? 1 : 0; } } else if( !strncmp( psz, "spu", strlen( "spu" ) ) ) { - if( i_cat != 1 ) + if( i_cat == -1 ) { i_cat = fmt->i_cat == SPU_ES ? 1 : 0; } @@ -408,33 +404,33 @@ static vlc_bool_t ESSelected( es_format_t *fmt, char *psz_select ) char *psz_arg = strchr( psz, '=' ); *psz_arg++ = '\0'; - if( !strcmp( psz, "no-es" ) || !strcmp( psz, "es" ) ) + if( !strcmp( psz, "no-es" ) || !strcmp( psz, "noes" ) ) { - if( i_es != 1 ) + if( i_es == -1 ) { - i_es = !NumInRange( psz_arg, fmt->i_id ) ? 1 : 0; + i_es = NumInRange( psz_arg, fmt->i_id ) ? 0 : -1; } } else if( !strcmp( psz, "es" ) ) { - if( i_es != 1 ) + if( i_es == -1 ) { - i_es = NumInRange( psz_arg, fmt->i_id) ? 1 : 0; + i_es = NumInRange( psz_arg, fmt->i_id) ? 1 : -1; } } else if( !strcmp( psz, "no-prgm" ) || !strcmp( psz, "noprgm" ) || !strcmp( psz, "no-program" ) || !strcmp( psz, "noprogram" ) ) { - if( fmt->i_group >= 0 && i_prgm != 1 ) + if( fmt->i_group >= 0 && i_prgm == -1 ) { - i_prgm = !NumInRange( psz_arg, fmt->i_group ) ? 1 : 0; + i_prgm = NumInRange( psz_arg, fmt->i_group ) ? 0 : -1; } } else if( !strcmp( psz, "prgm" ) || !strcmp( psz, "program" ) ) { - if( fmt->i_group >= 0 && i_prgm != 1 ) + if( fmt->i_group >= 0 && i_prgm == -1 ) { - i_prgm = NumInRange( psz_arg, fmt->i_group ) ? 1 : 0; + i_prgm = NumInRange( psz_arg, fmt->i_group ) ? 1 : -1; } } } @@ -448,10 +444,9 @@ static vlc_bool_t ESSelected( es_format_t *fmt, char *psz_select ) free( psz_dup ); - if( i_cat == 0 || i_es == 0 || i_prgm == 0 ) + if( i_cat == 1 || i_es == 1 || i_prgm == 1 ) { - /* One test failed */ - return VLC_FALSE; + return true; } - return VLC_TRUE; + return false; }