#include "vlc_interface.h"
#include "vlc_interaction.h"
+#include "charset.h"
+
/*****************************************************************************
* Local prototypes
*****************************************************************************/
/* Allocate descriptor */
p_input = Create( p_parent, p_item, NULL, VLC_TRUE );
- p_input->i_flags |= OBJECT_FLAGS_NODBG;
+ p_input->i_flags |= OBJECT_FLAGS_QUIET;
p_input->i_flags |= OBJECT_FLAGS_NOINTERACT;
/* Now we can attach our new input */
p_input->b_eof = VLC_TRUE;
}
- /* Wait we are asked to die */
+ /* Wait until we are asked to die */
if( !p_input->b_die )
{
Error( p_input );
if( !p_input->b_eof && !p_input->b_error && p_input->input.b_eof )
{
- /* We have finish to demux data but not to play them */
+ /* We have finished demuxing data but not playing it */
while( !p_input->b_die )
{
if( input_EsOutDecodersEmpty( p_input->p_es_out ) )
msleep( INPUT_IDLE_SLEEP );
}
+
/* We have finished */
p_input->b_eof = VLC_TRUE;
}
* (this will break playing of file starting by 'vlc:' but I don't
* want to add more logic, just force file by file:// or code it ;)
*/
+ memset( &p_input->counters, 0, sizeof( p_input->counters ) );
if( !b_quick )
{
/* Prepare statistics */
- counter_t *p_counter;
- stats_Create( p_input, "read_bytes", STATS_READ_BYTES,
- VLC_VAR_INTEGER, STATS_COUNTER );
- stats_Create( p_input, "read_packets", STATS_READ_PACKETS,
- VLC_VAR_INTEGER, STATS_COUNTER );
- stats_Create( p_input, "demux_read", STATS_DEMUX_READ,
- VLC_VAR_INTEGER, STATS_COUNTER );
- stats_Create( p_input, "input_bitrate", STATS_INPUT_BITRATE,
- VLC_VAR_FLOAT, STATS_DERIVATIVE );
- stats_Create( p_input, "demux_bitrate", STATS_DEMUX_BITRATE,
- VLC_VAR_FLOAT, STATS_DERIVATIVE );
-
- p_counter = stats_CounterGet( p_input, p_input->i_object_id,
- STATS_INPUT_BITRATE );
- if( p_counter ) p_counter->update_interval = 1000000;
- p_counter = stats_CounterGet( p_input, p_input->i_object_id,
- STATS_DEMUX_BITRATE );
- if( p_counter ) p_counter->update_interval = 1000000;
-
- stats_Create( p_input, "played_abuffers", STATS_PLAYED_ABUFFERS,
- VLC_VAR_INTEGER, STATS_COUNTER );
- stats_Create( p_input, "lost_abuffers", STATS_LOST_ABUFFERS,
- VLC_VAR_INTEGER, STATS_COUNTER );
+#define INIT_COUNTER( p, type, compute ) p_input->counters.p_##p = \
+ stats_CounterCreate( p_input, VLC_VAR_##type, STATS_##compute);
+ if( p_input->p_libvlc_global->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->counters.p_sout_send_bitrate = NULL;
+ p_input->counters.p_sout_sent_packets = NULL;
+ p_input->counters.p_sout_sent_bytes = NULL;
+ if( p_input->counters.p_demux_bitrate )
+ p_input->counters.p_demux_bitrate->update_interval = 1000000;
+ if( p_input->counters.p_input_bitrate )
+ p_input->counters.p_input_bitrate->update_interval = 1000000;
+ }
+ vlc_mutex_init( p_input, &p_input->counters.counters_lock );
/* handle sout */
psz = var_GetString( p_input, "sout" );
free( psz );
return VLC_EGENERIC;
}
+ if( p_input->p_libvlc_global->b_stats )
+ {
+ INIT_COUNTER( sout_sent_packets, INTEGER, COUNTER );
+ INIT_COUNTER (sout_sent_bytes, INTEGER, COUNTER );
+ INIT_COUNTER( sout_send_bitrate, FLOAT, DERIVATIVE );
+ if( p_input->counters.p_sout_send_bitrate )
+ p_input->counters.p_sout_send_bitrate->update_interval =
+ 1000000;
+ }
}
free( psz );
}
}
/* initialization is complete */
- p_input->i_state = PLAYING_S;
-
- val.i_int = PLAYING_S;
- var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
+ input_ChangeState(p_input, PLAYING_S);
return VLC_SUCCESS;
*****************************************************************************/
static void End( input_thread_t * p_input )
{
- vlc_value_t val;
int i;
msg_Dbg( p_input, "closing input" );
/* We are at the end */
- p_input->i_state = END_S;
-
- val.i_int = END_S;
- var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
+ input_ChangeState(p_input, END_S);
/* Clean control variables */
input_ControlVarClean( p_input );
if( p_input->p_es_out )
input_EsOutDelete( p_input->p_es_out );
+#define CL_CO( c ) stats_CounterClean( p_input->counters.p_##c ); p_input->counters.p_##c = NULL;
+ if( p_input->p_libvlc_global->b_stats )
+ {
+ vlc_mutex_lock( &p_input->counters.counters_lock );
+ CL_CO( read_bytes );
+ CL_CO( read_packets );
+ CL_CO( demux_read );
+ CL_CO( input_bitrate );
+ CL_CO( demux_bitrate );
+ CL_CO( played_abuffers );
+ CL_CO( lost_abuffers );
+ CL_CO( displayed_pictures );
+ CL_CO( lost_pictures );
+ CL_CO( decoded_audio) ;
+ CL_CO( decoded_video );
+ CL_CO( decoded_sub) ;
+ vlc_mutex_unlock( &p_input->counters.counters_lock );
+ }
+
/* Close optional stream output instance */
if( p_input->p_sout )
{
vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
vlc_value_t keep;
+ vlc_mutex_lock( &p_input->counters.counters_lock );
+ CL_CO( sout_sent_packets );
+ CL_CO( sout_sent_bytes );
+ CL_CO( sout_send_bitrate );
+ vlc_mutex_unlock( &p_input->counters.counters_lock );
+
if( var_Get( p_input, "sout-keep", &keep ) >= 0 && keep.b_bool && p_pl )
{
/* attach sout to the playlist */
vlc_object_release( p_pl );
}
+#undef CL_CO
/* Tell we're dead */
p_input->b_dead = VLC_TRUE;
}
{
int64_t i_pts_delay;
+ input_ChangeState( p_input, OPENING_S);
+
/* Now try a real access */
in->p_access = access2_New( p_input, psz_access, psz_demux, psz_path,
b_quick );
if( in->p_access == NULL )
{
msg_Err( p_input, "no suitable access module for `%s'", psz_mrl );
- intf_UserFatal( VLC_OBJECT( p_input),
- _("Errors"),"Unable to open '%s'", psz_mrl );
+ intf_UserFatal( VLC_OBJECT( p_input), VLC_FALSE,
+ _("Your input can't be opened"),
+ _("VLC is unable to open the MRL '%s'."
+ " Check the log for details."), psz_mrl );
goto error;
}
var_Set( p_input, "seekable", val );
}
+ input_ChangeState( p_input, BUFFERING_S);
+
/* Create the stream_t */
in->p_stream = stream_AccessNew( in->p_access, b_quick );
if( in->p_stream == NULL )
{
msg_Err( p_input, "no suitable demux module for `%s/%s://%s'",
psz_access, psz_demux, psz_path );
- intf_UserFatal( VLC_OBJECT( p_input), _("Errors"),
- "Unrecognized format for '%s'", psz_mrl );
+ intf_UserFatal( VLC_OBJECT( p_input), VLC_FALSE,
+ _("Can't recognize the input's format"),
+ _("The format of '%s' can't be detected. "
+ "Have a look the log for details."), psz_mrl );
goto error;
}
input_source_t *sub;
vlc_value_t count;
vlc_value_t list;
+ char *psz_path, *psz_extension;
if( b_check_extension && !subtitles_Filter( psz_subtitle ) )
{
return VLC_FALSE;
}
+ /* if we are provided a subtitle.sub file,
+ * see if we don't have a subtitle.idx and use it instead */
+ psz_path = strdup( psz_subtitle );
+ if( psz_path )
+ {
+ psz_extension = strrchr( psz_path, '.');
+ if( psz_extension && strcmp( psz_extension, ".sub" ) == 0 )
+ {
+ FILE *f;
+
+ strcpy( psz_extension, ".idx" );
+ /* FIXME: a portable wrapper for stat() or access() would be more suited */
+ if( ( f = utf8_fopen( psz_path, "rt" ) ) )
+ {
+ fclose( f );
+ msg_Dbg( p_input, "using %s subtitles file instead of %s",
+ psz_path, psz_subtitle );
+ strcpy( psz_subtitle, psz_path );
+ }
+ }
+ free( psz_path );
+ }
+
var_Change( p_input, "spu-es", VLC_VAR_CHOICESCOUNT, &count, NULL );
sub = InputSourceNew( p_input );