+ for( i = 0; i < p_input->p->input.p_item->i_options; i++ )
+ {
+ if( !strncmp( p_input->p->input.p_item->ppsz_options[i], "meta-file", 9 ) )
+ {
+ msg_Dbg( p_input, "Input is a meta file: disabling unneeded options" );
+ var_SetString( p_input, "sout", "" );
+ var_SetBool( p_input, "sout-all", VLC_FALSE );
+ var_SetString( p_input, "input-slave", "" );
+ var_SetInteger( p_input, "input-repeat", 0 );
+ var_SetString( p_input, "sub-file", "" );
+ var_SetBool( p_input, "sub-autodetect-file", VLC_FALSE );
+ }
+ }
+
+ if( !p_input->b_preparsing )
+ {
+ /* Prepare statistics */
+#define INIT_COUNTER( c, type, compute ) p_input->p->counters.p_##c = \
+ stats_CounterCreate( p_input, VLC_VAR_##type, STATS_##compute);
+ if( p_input->p_libvlc->b_stats )
+ {
+ INIT_COUNTER( read_bytes, INTEGER, COUNTER );
+ INIT_COUNTER( read_packets, INTEGER, COUNTER );
+ INIT_COUNTER( demux_read, INTEGER, COUNTER );
+ INIT_COUNTER( input_bitrate, FLOAT, DERIVATIVE );
+ INIT_COUNTER( demux_bitrate, FLOAT, DERIVATIVE );
+ INIT_COUNTER( played_abuffers, INTEGER, COUNTER );
+ INIT_COUNTER( lost_abuffers, INTEGER, COUNTER );
+ INIT_COUNTER( displayed_pictures, INTEGER, COUNTER );
+ INIT_COUNTER( lost_pictures, INTEGER, COUNTER );
+ INIT_COUNTER( decoded_audio, INTEGER, COUNTER );
+ INIT_COUNTER( decoded_video, INTEGER, COUNTER );
+ INIT_COUNTER( decoded_sub, INTEGER, COUNTER );
+ p_input->p->counters.p_sout_send_bitrate = NULL;
+ p_input->p->counters.p_sout_sent_packets = NULL;
+ p_input->p->counters.p_sout_sent_bytes = NULL;
+ if( p_input->p->counters.p_demux_bitrate )
+ p_input->p->counters.p_demux_bitrate->update_interval = 1000000;
+ if( p_input->p->counters.p_input_bitrate )
+ p_input->p->counters.p_input_bitrate->update_interval = 1000000;
+ }
+
+ /* Find a usable sout and attach it to p_input */
+ psz = var_GetNonEmptyString( p_input, "sout" );
+ if( psz && strncasecmp( p_input->p->input.p_item->psz_uri, "vlc:", 4 ) )
+ {
+ /* Check the validity of the provided sout */
+ if( p_input->p->p_sout )
+ {
+ if( strcmp( p_input->p->p_sout->psz_sout, psz ) )
+ {
+ msg_Dbg( p_input, "destroying unusable sout" );
+
+ sout_DeleteInstance( p_input->p->p_sout );
+ p_input->p->p_sout = NULL;
+ }
+ }
+
+ if( p_input->p->p_sout )
+ {
+ /* Reuse it */
+ msg_Dbg( p_input, "sout keep: reusing sout" );
+ msg_Dbg( p_input, "sout keep: you probably want to use "
+ "gather stream_out" );
+ vlc_object_attach( p_input->p->p_sout, p_input );
+ }
+ else
+ {
+ /* Create a new one */
+ p_input->p->p_sout = sout_NewInstance( p_input, psz );
+ if( !p_input->p->p_sout )
+ {
+ input_ChangeState( p_input, ERROR_S );
+ msg_Err( p_input, "cannot start stream output instance, " \
+ "aborting" );
+ free( psz );
+ return VLC_EGENERIC;
+ }
+ }
+
+ if( p_input->p_libvlc->b_stats )