Commit 03b059c1 authored by Clément Stenac's avatar Clément Stenac

Some more stats preliminary work

parent efacf7b5
......@@ -208,6 +208,7 @@ enum
STATS_COUNTER,
STATS_MAX,
STATS_MIN,
STATS_DERIVATIVE
};
struct counter_sample_t
......@@ -247,3 +248,20 @@ static inline int __stats_UpdateInteger( vlc_object_t *p_obj, char *psz_name,
return __stats_Update( p_obj, psz_name, val );
}
#define stats_UpdateInteger( a,b,c ) __stats_UpdateInteger( VLC_OBJECT(a),b,c )
struct input_stats_t
{
/* Input */
int i_read_packets;
int i_read_bytes;
float f_last_bitrate;
float f_average_bitrate;
/* Decoders */
/* Vout */
int i_displayed_pictures;
int i_lost_pictures;
}
......@@ -384,6 +384,10 @@ static decoder_t * CreateDecoder( input_thread_t *p_input,
p_dec->pf_decode_sub = 0;
p_dec->pf_packetize = 0;
stats_Create( p_dec, "decoded_audio", VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( p_dec, "decoded_video", VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( p_dec, "decoded_sub", VLC_VAR_INTEGER, STATS_COUNTER );
/* Initialize the decoder fifo */
p_dec->p_module = NULL;
......@@ -621,6 +625,7 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
while( (p_aout_buf = p_dec->pf_decode_audio( p_dec,
&p_packetized_block )) )
{
stats_UpdateInteger( p_dec, "decoded_audio", 1 );
/* FIXME the best would be to handle the case start_date < preroll < end_date
* but that's not easy with non raw audio stream */
if( p_dec->p_owner->i_preroll_end > 0 &&
......@@ -644,6 +649,7 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
}
else while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, &p_block )) )
{
stats_UpdateInteger( p_dec, "decoded_audio", 1 );
if( p_dec->p_owner->i_preroll_end > 0 &&
p_aout_buf->start_date < p_dec->p_owner->i_preroll_end )
{
......@@ -689,6 +695,7 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
while( (p_pic = p_dec->pf_decode_video( p_dec,
&p_packetized_block )) )
{
stats_UpdateInteger( p_dec, "decoded_video", 1 );
if( p_dec->p_owner->i_preroll_end > 0 &&
p_pic->date < p_dec->p_owner->i_preroll_end )
{
......@@ -709,6 +716,7 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
}
else while( (p_pic = p_dec->pf_decode_video( p_dec, &p_block )) )
{
stats_UpdateInteger( p_dec, "decoded_video", 1 );
if( p_dec->p_owner->i_preroll_end > 0 &&
p_pic->date < p_dec->p_owner->i_preroll_end )
{
......@@ -728,6 +736,7 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
subpicture_t *p_spu;
while( (p_spu = p_dec->pf_decode_sub( p_dec, &p_block ) ) )
{
stats_UpdateInteger( p_dec, "decoded_sub", 1 );
if( p_dec->p_owner->i_preroll_end > 0 &&
p_spu->i_start < p_dec->p_owner->i_preroll_end &&
( p_spu->i_stop <= 0 || p_spu->i_stop <= p_dec->p_owner->i_preroll_end ) )
......
......@@ -672,6 +672,9 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
*/
if( !b_quick )
{
stats_Create( p_input, "read_bytes", VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( p_input, "input_bitrate", VLC_VAR_FLOAT,
STATS_DERIVATIVE );
psz = var_GetString( p_input, "sout" );
if( *psz && strncasecmp( p_input->input.p_item->psz_uri, "vlc:", 4 ) )
{
......
......@@ -1596,6 +1596,9 @@ static int AReadStream( stream_t *s, void *p_read, int i_read )
return AReadStream( s, p_read, i_read_orig );
}
/* Update read bytes in input */
stats_UpdateInteger( s->p_parent, "read_bytes", i_read );
return i_read;
}
......
......@@ -902,6 +902,7 @@ int VLC_CleanUp( int i_object )
vout_thread_t * p_vout;
aout_instance_t * p_aout;
announce_handler_t * p_announce;
stats_handler_t * p_stats;
vlc_t *p_vlc = vlc_current_object( i_object );
/* Check that the handle is valid */
......@@ -956,6 +957,13 @@ int VLC_CleanUp( int i_object )
aout_Delete( p_aout );
}
while( ( p_stats = vlc_object_find( p_vlc, VLC_OBJECT_STATS, FIND_CHILD) ))
{
vlc_object_detach( (vlc_object_t*) p_stats );
vlc_object_release( (vlc_object_t *)p_stats );
// TODO: Delete it
}
/*
* Free announce handler(s?)
*/
......
......@@ -94,12 +94,22 @@ static int stats_CounterUpdate( stats_handler_t *p_handler,
{
switch( p_counter->i_compute_type )
{
case STATS_LAST:
case STATS_MIN:
case STATS_LAST:
if( p_counter->i_samples > 1)
{
msg_Err( p_handler, "LAST counter has several samples !" );
return VLC_EGENERIC;
}
if( p_counter->i_type != VLC_VAR_FLOAT &&
p_counter->i_type != VLC_VAR_INTEGER &&
p_counter->i_compute_type != STATS_LAST )
{
msg_Err( p_handler, "Unable to compute MIN or MAX for this type");
return VLC_EGENERIC;
}
if( p_counter->i_samples == 0 )
{
counter_sample_t *p_new = (counter_sample_t*)malloc(
......@@ -111,14 +121,31 @@ static int stats_CounterUpdate( stats_handler_t *p_handler,
}
if( p_counter->i_samples == 1 )
{
if( p_counter->i_type == VLC_VAR_STRING &&
p_counter->pp_samples[0]->value.psz_string )
/* Update if : LAST or (MAX and bigger) or (MIN and bigger) */
if( p_counter->i_compute_type == STATS_LAST ||
( p_counter->i_compute_type == STATS_MAX &&
( ( p_counter->i_type == VLC_VAR_INTEGER &&
p_counter->pp_samples[0]->value.i_int > val.i_int ) ||
( p_counter->i_type == VLC_VAR_FLOAT &&
p_counter->pp_samples[0]->value.f_float > val.f_float )
) ) ||
( p_counter->i_compute_type == STATS_MIN &&
( ( p_counter->i_type == VLC_VAR_INTEGER &&
p_counter->pp_samples[0]->value.i_int < val.i_int ) ||
( p_counter->i_type == VLC_VAR_FLOAT &&
p_counter->pp_samples[0]->value.f_float < val.f_float )
) ) )
{
free( p_counter->pp_samples[0]->value.psz_string );
if( p_counter->i_type == VLC_VAR_STRING &&
p_counter->pp_samples[0]->value.psz_string )
{
free( p_counter->pp_samples[0]->value.psz_string );
}
p_counter->pp_samples[0]->value = val;
}
p_counter->pp_samples[0]->value = val;
}
break;
case STATS_COUNTER:
if( p_counter->i_samples > 1)
{
......@@ -216,3 +243,13 @@ static stats_handler_t* stats_HandlerCreate( vlc_object_t *p_this )
return p_handler;
}
void stats_ComputeInputStats( input_thread_t *p_input,
input_stats_t *p_stats )
{
int i;
/* read_packets and read_bytes are common to all streams */
p_stats->i_read_packets = stats_GetInteger( p_input, "read_packets" );
p_stats->i_read_bytes = stats_GetInteger( p_input, "read_bytes" );
}
......@@ -2059,6 +2059,7 @@ static void httpd_HostThread( httpd_host_t *host )
tls_session_t *p_tls = NULL;
stats_Create( host, "client_connections", VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( host, "active_connections", VLC_VAR_INTEGER, STATS_COUNTER );
while( !host->b_die )
{
......@@ -2108,6 +2109,7 @@ static void httpd_HostThread( httpd_host_t *host )
cl->i_activity_date+cl->i_activity_timeout < mdate()) ) ) )
{
httpd_ClientClean( cl );
stats_UpdateInteger( host, "active_connections", -1 );
TAB_REMOVE( host->i_client, host->client, cl );
free( cl );
i_client--;
......@@ -2563,6 +2565,7 @@ static void httpd_HostThread( httpd_host_t *host )
httpd_client_t *cl;
stats_UpdateInteger( host, "client_connections",
1 );
stats_UpdateInteger( host, "active_connections", 1 );
cl = httpd_ClientNew( fd, &sock, i_sock_size, p_tls );
p_tls = NULL;
vlc_mutex_lock( &host->lock );
......
......@@ -229,6 +229,10 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
return NULL;
}
stats_Create( p_vout, "displayed_pictures", VLC_VAR_INTEGER,
STATS_COUNTER );
stats_Create( p_vout, "lost_pictures", VLC_VAR_INTEGER, STATS_COUNTER );
/* Initialize pictures - translation tables and functions
* will be initialized later in InitThread */
for( i_index = 0; i_index < 2 * VOUT_MAX_PICTURES + 1; i_index++)
......@@ -810,6 +814,7 @@ static void RunThread( vout_thread_t *p_vout)
}
msg_Warn( p_vout, "late picture skipped ("I64Fd")",
current_date - display_date );
stats_UpdateInteger( p_vout, "lost_pictures", 1 );
vlc_mutex_unlock( &p_vout->picture_lock );
continue;
......@@ -832,6 +837,7 @@ static void RunThread( vout_thread_t *p_vout)
p_picture->i_status = DESTROYED_PICTURE;
p_vout->i_heap_size--;
}
stats_UpdateInteger( p_vout, "lost_pictures", 1 );
msg_Warn( p_vout, "vout warning: early picture skipped "
"("I64Fd")", display_date - current_date
- p_vout->i_pts_delay );
......@@ -889,6 +895,7 @@ static void RunThread( vout_thread_t *p_vout)
/*
* Perform rendering
*/
stats_UpdateInteger( p_vout, "displayed_pictures", 1 );
p_directbuffer = vout_RenderPicture( p_vout, p_picture, p_subpic );
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment