struct counter_t
{
+ /* The list is *NOT* sorted at the moment, it could be ... */
+ uint64_t i_index;
char * psz_name;
- int i_source_object;
- int i_compute_type;
int i_type;
+ int i_compute_type;
int i_samples;
counter_sample_t ** pp_samples;
mtime_t last_update;
};
+enum
+{
+ STATS_INPUT_BITRATE,
+ STATS_READ_BYTES,
+ STATS_READ_PACKETS,
+ STATS_DEMUX_READ,
+ STATS_DEMUX_BITRATE,
+ STATS_PLAYED_ABUFFERS,
+ STATS_LOST_ABUFFERS,
+ STATS_DECODED_AUDIO,
+ STATS_DECODED_VIDEO,
+ STATS_DECODED_SUB,
+ STATS_CLIENT_CONNECTIONS,
+ STATS_ACTIVE_CONNECTIONS,
+ STATS_SOUT_SENT_PACKETS,
+ STATS_SOUT_SENT_BYTES,
+ STATS_SOUT_SEND_BITRATE,
+ STATS_DISPLAYED_PICTURES,
+ STATS_LOST_PICTURES,
+
+ STATS_TIMER_PLAYLIST_WALK,
+ STATS_TIMER_INTERACTION,
+ STATS_TIMER_PREPARSE
+};
+
struct stats_handler_t
{
VLC_COMMON_MEMBERS
int i_counters;
- hashtable_entry_t * p_counters;
+ counter_t **pp_counters;
};
VLC_EXPORT( void, stats_HandlerDestroy, (stats_handler_t*) );
#define stats_Update( a,b,c, d) __stats_Update( VLC_OBJECT( a ), b, c, d )
-VLC_EXPORT( int, __stats_Update, (vlc_object_t*, const char *, vlc_value_t, vlc_value_t *) );
-#define stats_Create( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d )
-VLC_EXPORT( int, __stats_Create, (vlc_object_t*, const char *, int, int) );
+VLC_EXPORT( int, __stats_Update, (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *) );
+#define stats_Create( a,b,c,d,e ) __stats_Create( VLC_OBJECT(a), b, c, d,e )
+VLC_EXPORT( int, __stats_Create, (vlc_object_t*, const char *, unsigned int, int, int) );
#define stats_Get( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d )
-VLC_EXPORT( int, __stats_Get, (vlc_object_t*, int, const char *, vlc_value_t*) );
+VLC_EXPORT( int, __stats_Get, (vlc_object_t*, int, unsigned int, vlc_value_t*) );
#define stats_CounterGet( a,b,c) __stats_CounterGet( VLC_OBJECT(a), b, c )
-VLC_EXPORT( counter_t*, __stats_CounterGet, (vlc_object_t*, int, const char * ) );
+VLC_EXPORT( counter_t*, __stats_CounterGet, (vlc_object_t*, int, unsigned int ) );
#define stats_GetInteger( a,b,c,d ) __stats_GetInteger( VLC_OBJECT(a), b, c, d )
static inline int __stats_GetInteger( vlc_object_t *p_obj, int i_id,
- const char *psz_name, int *value )
+ unsigned int i_counter, int *value )
{
vlc_value_t val;
- int i_ret = __stats_Get( p_obj, i_id, psz_name, &val );
+ int i_ret = __stats_Get( p_obj, i_id, i_counter, &val );
*value = val.i_int;
return i_ret;
}
#define stats_GetFloat(a,b,c,d ) __stats_GetFloat( VLC_OBJECT(a), b, c, d )
static inline int __stats_GetFloat( vlc_object_t *p_obj, int i_id,
- const char *psz_name, float *value )
+ unsigned int i_counter, float *value )
{
vlc_value_t val;
- int i_ret = __stats_Get( p_obj, i_id, psz_name, &val );
+ int i_ret = __stats_Get( p_obj, i_id, i_counter, &val );
*value = val.f_float;
return i_ret;
}
#define stats_UpdateInteger( a,b,c,d ) __stats_UpdateInteger( VLC_OBJECT(a),b,c,d )
static inline int __stats_UpdateInteger( vlc_object_t *p_obj,
- const char *psz_name, int i, int *pi_new )
+ unsigned int i_counter, int i,
+ int *pi_new )
{
int i_ret;
vlc_value_t val;
vlc_value_t new_val;
val.i_int = i;
- i_ret = __stats_Update( p_obj, psz_name, val , &new_val );
+ i_ret = __stats_Update( p_obj, i_counter, val , &new_val );
if( pi_new )
*pi_new = new_val.i_int;
return i_ret;
}
#define stats_UpdateFloat( a,b,c,d ) __stats_UpdateFloat( VLC_OBJECT(a),b,c,d )
static inline int __stats_UpdateFloat( vlc_object_t *p_obj,
- const char *psz_name, float f, float *pf_new )
+ unsigned int i_counter, float f,
+ float *pf_new )
{
vlc_value_t val;
int i_ret;
vlc_value_t new_val;
val.f_float = f;
- i_ret = __stats_Update( p_obj, psz_name, val, &new_val );
+ i_ret = __stats_Update( p_obj, i_counter, val, &new_val );
if( pf_new )
*pf_new = new_val.f_float;
return i_ret;
* Timing
********/
#ifdef DEBUG
-#define stats_TimerStart(a,b) __stats_TimerStart( VLC_OBJECT(a), b )
+#define stats_TimerStart(a,b,c) __stats_TimerStart( VLC_OBJECT(a), b,c )
#define stats_TimerStop(a,b) __stats_TimerStop( VLC_OBJECT(a), b )
#define stats_TimerDump(a,b) __stats_TimerDump( VLC_OBJECT(a), b )
#define stats_TimersDumpAll(a) __stats_TimersDumpAll( VLC_OBJECT(a) )
#define stats_TimerDump(a,b) {}
#define stats_TimersDumpAll(a) {}
#endif
-VLC_EXPORT( void,__stats_TimerStart, (vlc_object_t*, const char *) );
-VLC_EXPORT( void,__stats_TimerStop, (vlc_object_t*, const char *) );
-VLC_EXPORT( void,__stats_TimerDump, (vlc_object_t*, const char *) );
+VLC_EXPORT( void,__stats_TimerStart, (vlc_object_t*, const char *, unsigned int ) );
+VLC_EXPORT( void,__stats_TimerStop, (vlc_object_t*, unsigned int) );
+VLC_EXPORT( void,__stats_TimerDump, (vlc_object_t*, unsigned int) );
VLC_EXPORT( void,__stats_TimersDumpAll, (vlc_object_t*) );
void __osd_MenuShow (vlc_object_t *);
httpd_url_t * httpd_UrlNewUnique (httpd_host_t *, const char *psz_url, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl);
void httpd_ClientModeStream (httpd_client_t *cl);
-int __stats_Create (vlc_object_t*, const char *, int, int);
+int __stats_Create (vlc_object_t*, const char *, unsigned int, int, int);
void httpd_RedirectDelete (httpd_redirect_t *);
void __sout_CfgParse (vlc_object_t *, char *psz_prefix, const char **ppsz_options, sout_cfg_t *);
vlm_media_t * vlm_MediaNew (vlm_t *, const char *, int);
void vout_SynchroDecode (vout_synchro_t *);
int playlist_Delete (playlist_t *, int);
void aout_FiltersPlay (aout_instance_t * p_aout, aout_filter_t ** pp_filters, int i_nb_filters, aout_buffer_t ** pp_input_buffer);
-int __stats_Update (vlc_object_t*, const char *, vlc_value_t, vlc_value_t *);
-int __stats_Get (vlc_object_t*, int, const char *, vlc_value_t*);
+int __stats_Update (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *);
+int __stats_Get (vlc_object_t*, int, int, vlc_value_t*);
char* httpd_ClientIP (httpd_client_t *cl, char *psz_ip);
int __intf_UserProgress (vlc_object_t*, const char*, const char*, float);
void httpd_FileDelete (httpd_file_t *);
stream_t * __stream_DemuxNew (vlc_object_t *p_obj, char *psz_demux, es_out_t *out);
int vout_ShowTextRelative (vout_thread_t *, int, char *, text_style_t *, int, int, int, mtime_t);
unsigned int update_iterator_Action (update_iterator_t *, int);
-void __stats_TimerDump (vlc_object_t*, const char *);
+void __stats_TimerDump (vlc_object_t*, unsigned int);
int block_FifoPut (block_fifo_t *, block_t *);
int playlist_ItemAddParent (playlist_item_t *, int,playlist_item_t *);
int __var_Create (vlc_object_t *, const char *, int);
int vlm_ExecuteCommand (vlm_t *, const char *, vlm_message_t **);
char * config_GetUserDir (void);
httpd_stream_t * httpd_StreamNew (httpd_host_t *, const char *psz_url, const char *psz_mime, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl);
-counter_t* __stats_CounterGet (vlc_object_t*, int, const char *);
+counter_t* __stats_CounterGet (vlc_object_t*, int, unsigned int);
int __config_GetType (vlc_object_t *, const char *);
void __vlc_thread_ready (vlc_object_t *);
int playlist_Export (playlist_t *, const char *, const char *);
int ACL_AddNet (vlc_acl_t *p_acl, const char *psz_ip, int i_len, vlc_bool_t b_allow);
void AddMD5 (struct md5_s *, const uint8_t *, uint32_t);
void config_Duplicate (module_t *, module_config_t *);
-void __stats_TimerStart (vlc_object_t*, const char *);
+void __stats_TimerStart (vlc_object_t*, const char *, int);
block_t * __block_New (vlc_object_t *, int);
void xml_Delete (xml_t *);
void __msg_Warn (vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3);
char * FromUTF32 (const wchar_t *);
void __vout_OSDMessage (vlc_object_t *, int, char *, ...);
void intf_StopThread (intf_thread_t *);
-void __stats_TimerStop (vlc_object_t*, const char *);
+void __stats_TimerStop (vlc_object_t*, unsigned int);
stream_t * __stream_MemoryNew (vlc_object_t *p_obj, uint8_t *p_buffer, int64_t i_size, vlc_bool_t i_preserve_memory);
void mwait (mtime_t date);
void __config_ResetAll (vlc_object_t *);
int (*__intf_UserProgress_inner) (vlc_object_t*, const char*, const char*, float);
void (*__intf_UserProgressUpdate_inner) (vlc_object_t*, int, const char*, float);
void (*__intf_UserHide_inner) (vlc_object_t *, int);
- int (*__stats_Create_inner) (vlc_object_t*, const char *, int, int);
- int (*__stats_Update_inner) (vlc_object_t*, const char *, vlc_value_t, vlc_value_t *);
- int (*__stats_Get_inner) (vlc_object_t*, int, const char *, vlc_value_t*);
+ int (*__stats_Create_inner) (vlc_object_t*, const char *, unsigned int, int, int);
+ int (*__stats_Update_inner) (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *);
+ int (*__stats_Get_inner) (vlc_object_t*, int, int, vlc_value_t*);
void (*stats_ComputeInputStats_inner) (input_thread_t*, input_stats_t*);
void (*stats_DumpInputStats_inner) (input_stats_t *);
void (*stats_ReinitInputStats_inner) (input_stats_t *);
- counter_t* (*__stats_CounterGet_inner) (vlc_object_t*, int, const char *);
+ counter_t* (*__stats_CounterGet_inner) (vlc_object_t*, int, unsigned int);
void *__stats_CounterGet_deprecated;
input_thread_t * (*__input_CreateThread2_inner) (vlc_object_t *, input_item_t *, char *);
void (*stats_HandlerDestroy_inner) (stats_handler_t*);
vlc_t * (*vlc_current_object_inner) (int);
void (*__var_OptionParse_inner) (vlc_object_t *, const char *);
void *__stats_TimerDumpAll_deprecated;
- void (*__stats_TimerDump_inner) (vlc_object_t*, const char *);
- void (*__stats_TimerStart_inner) (vlc_object_t*, const char *);
+ void (*__stats_TimerDump_inner) (vlc_object_t*, unsigned int);
+ void (*__stats_TimerStart_inner) (vlc_object_t*, const char *, int);
void (*__stats_ComputeGlobalStats_inner) (vlc_object_t*,global_stats_t*);
- void (*__stats_TimerStop_inner) (vlc_object_t*, const char *);
+ void (*__stats_TimerStop_inner) (vlc_object_t*, unsigned int);
void (*__stats_TimersDumpAll_inner) (vlc_object_t*);
update_iterator_t * (*update_iterator_New_inner) (update_t *);
void (*update_Check_inner) (update_t *, vlc_bool_t);
while( (p_audio_buf = id->p_decoder->pf_decode_audio( id->p_decoder,
&in )) )
{
- stats_UpdateInteger( p_stream->p_parent->p_parent, "decoded_audio", 1, NULL );
+ stats_UpdateInteger( p_stream->p_parent->p_parent, STATS_DECODED_AUDIO,
+ 1, NULL );
if( p_sys->b_master_sync )
{
mtime_t i_dts = date_Get( &id->interpolated_pts ) + 1;
while( (p_pic = id->p_decoder->pf_decode_video( id->p_decoder, &in )) )
{
subpicture_t *p_subpic = 0;
- stats_UpdateInteger( p_stream->p_parent->p_parent, "decoded_video", 1, NULL );
+ stats_UpdateInteger( p_stream->p_parent->p_parent, STATS_DECODED_VIDEO,
+ 1, NULL );
if( p_stream->p_sout->i_out_pace_nocontrol && p_sys->b_hurry_up )
{
p_buffer->start_date - mdate());
if( p_input->p_input_thread )
{
- stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1,
+ stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1,
NULL );
}
aout_BufferFree( p_buffer );
if( p_input->p_input_thread )
{
stats_UpdateInteger( p_input->p_input_thread,
- "played_abuffers", 1, NULL );
+ STATS_PLAYED_ABUFFERS, 1, NULL );
}
vlc_mutex_unlock( &p_aout->mixer_lock );
start_date = 0;
if( p_input->p_input_thread )
{
- stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1,
+ stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1,
NULL );
}
}
mdate() - p_buffer->start_date );
if( p_input->p_input_thread )
{
- stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1,
+ stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1,
NULL );
}
aout_BufferFree( p_buffer );
aout_BufferFree( p_buffer );
if( p_input->p_input_thread )
{
- stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1,
+ stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1,
NULL );
}
return 0;
vlc_object_attach( p_dec, p_input );
- stats_Create( p_dec->p_parent, "decoded_audio",
+ stats_Create( p_dec->p_parent, "decoded_audio", STATS_DECODED_AUDIO,
VLC_VAR_INTEGER, STATS_COUNTER );
- stats_Create( p_dec->p_parent, "decoded_video",
+ stats_Create( p_dec->p_parent, "decoded_video", STATS_DECODED_VIDEO,
VLC_VAR_INTEGER, STATS_COUNTER );
- stats_Create( p_dec->p_parent, "decoded_sub",
+ stats_Create( p_dec->p_parent, "decoded_sub", STATS_DECODED_SUB,
VLC_VAR_INTEGER, STATS_COUNTER );
/* Find a suitable decoder/packetizer module */
if( i_object_type == VLC_OBJECT_DECODER )
while( (p_aout_buf = p_dec->pf_decode_audio( p_dec,
&p_packetized_block )) )
{
- stats_UpdateInteger( p_dec->p_parent, "decoded_audio", 1, NULL );
+ stats_UpdateInteger( p_dec->p_parent,
+ STATS_DECODED_AUDIO, 1, NULL );
/* 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 &&
}
else while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, &p_block )) )
{
- stats_UpdateInteger( p_dec->p_parent, "decoded_audio", 1, NULL );
+ stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_AUDIO, 1, NULL );
if( p_dec->p_owner->i_preroll_end > 0 &&
p_aout_buf->start_date < p_dec->p_owner->i_preroll_end )
{
while( (p_pic = p_dec->pf_decode_video( p_dec,
&p_packetized_block )) )
{
- stats_UpdateInteger( p_dec->p_parent, "decoded_video",
+ stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_VIDEO,
1, NULL );
if( p_dec->p_owner->i_preroll_end > 0 &&
p_pic->date < p_dec->p_owner->i_preroll_end )
}
else while( (p_pic = p_dec->pf_decode_video( p_dec, &p_block )) )
{
- stats_UpdateInteger( p_dec->p_parent, "decoded_video", 1 , NULL);
+ stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_VIDEO, 1 , NULL);
if( p_dec->p_owner->i_preroll_end > 0 &&
p_pic->date < p_dec->p_owner->i_preroll_end )
{
subpicture_t *p_spu;
while( (p_spu = p_dec->pf_decode_sub( p_dec, &p_block ) ) )
{
- stats_UpdateInteger( p_dec->p_parent, "decoded_sub", 1 , NULL);
+ stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_SUB, 1 , NULL);
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 ) )
if( p_input->p_libvlc->b_stats )
{
- stats_UpdateInteger( p_input, "demux_read", p_block->i_buffer,
+ stats_UpdateInteger( p_input, STATS_DEMUX_READ, p_block->i_buffer,
&i_total );
- stats_UpdateFloat( p_input , "demux_bitrate", (float)i_total, NULL );
+ stats_UpdateFloat( p_input , STATS_DEMUX_BITRATE, (float)i_total, NULL );
}
/* Mark preroll blocks */
{
/* Prepare statistics */
counter_t *p_counter;
- stats_Create( p_input, "read_bytes", VLC_VAR_INTEGER, STATS_COUNTER );
- stats_Create( p_input, "read_packets", VLC_VAR_INTEGER, STATS_COUNTER );
- stats_Create( p_input, "demux_read", VLC_VAR_INTEGER, STATS_COUNTER );
- stats_Create( p_input, "input_bitrate", VLC_VAR_FLOAT,
- STATS_DERIVATIVE );
- stats_Create( p_input, "demux_bitrate", VLC_VAR_FLOAT,
- STATS_DERIVATIVE );
+ 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,
- "input_bitrate" );
+ STATS_INPUT_BITRATE );
if( p_counter ) p_counter->update_interval = 1000000;
p_counter = stats_CounterGet( p_input, p_input->i_object_id,
- "demux_bitrate" );
+ STATS_DEMUX_BITRATE );
if( p_counter ) p_counter->update_interval = 1000000;
- stats_Create( p_input, "played_abuffers", VLC_VAR_INTEGER, STATS_COUNTER );
- stats_Create( p_input, "lost_abuffers", VLC_VAR_INTEGER, STATS_COUNTER );
+ 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 );
/* handle sout */
psz = var_GetString( p_input, "sout" );
if( !p_sys->i_list )
{
i_read = p_access->pf_read( p_access, p_read, i_read );
- stats_UpdateInteger( s->p_parent->p_parent , "read_bytes", i_read,
+ stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_BYTES, i_read,
&i_total );
- stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate",
+ stats_UpdateFloat( s->p_parent->p_parent , STATS_INPUT_BITRATE,
(float)i_total, NULL );
- stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1, NULL );
+ stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_PACKETS, 1,
+ NULL );
return i_read;
}
}
/* Update read bytes in input */
- stats_UpdateInteger( s->p_parent->p_parent , "read_bytes", i_read,
+ stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_BYTES, i_read,
&i_total );
- stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate",
+ stats_UpdateFloat( s->p_parent->p_parent , STATS_INPUT_BITRATE,
(float)i_total, NULL );
- stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1, NULL );
+ stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_PACKETS, 1, NULL );
return i_read;
}
if( pb_eof ) *pb_eof = p_access->info.b_eof;
if( p_block && p_access->p_libvlc->b_stats )
{
- stats_UpdateInteger( s->p_parent->p_parent, "read_bytes",
+ stats_UpdateInteger( s->p_parent->p_parent, STATS_READ_BYTES,
p_block->i_buffer, &i_total );
- stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate",
+ stats_UpdateFloat( s->p_parent->p_parent , STATS_INPUT_BITRATE,
(float)i_total, NULL );
- stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1, NULL );
+ stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_PACKETS, 1, NULL );
}
return p_block;
}
}
if( p_block )
{
- stats_UpdateInteger( s->p_parent->p_parent, "read_bytes",
+ stats_UpdateInteger( s->p_parent->p_parent, STATS_READ_BYTES,
p_block->i_buffer, &i_total );
- stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate",
+ stats_UpdateFloat( s->p_parent->p_parent , STATS_INPUT_BITRATE,
(float)i_total, NULL );
- stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1 , NULL);
+ stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_PACKETS,
+ 1 , NULL);
}
return p_block;
* Local prototypes
*****************************************************************************/
static counter_t *GetCounter( stats_handler_t *p_handler, int i_object_id,
- const char *psz_name );
+ unsigned int i_counter );
static int stats_CounterUpdate( stats_handler_t *p_handler,
counter_t *p_counter,
vlc_value_t val, vlc_value_t * );
for ( i = p_stats->i_counters - 1 ; i >= 0 ; i-- )
{
int j;
- hashtable_entry_t p_entry = p_stats->p_counters[i];
- counter_t * p_counter = p_entry.p_data;
+ counter_t *p_counter = p_stats->pp_counters[i];
for( j = p_counter->i_samples -1; j >= 0 ; j-- )
{
free( p_sample );
}
free( p_counter->psz_name );
- free( p_entry.psz_name );
- REMOVE_ELEM( p_stats->p_counters, p_stats->i_counters, i );
+ REMOVE_ELEM( p_stats->pp_counters, p_stats->i_counters, i );
free( p_counter );
}
}
* STATS_MAX (keep the maximum passed value), STATS_MIN, or STATS_DERIVATIVE
* (keep a time derivative of the value)
*/
-int __stats_Create( vlc_object_t *p_this, const char *psz_name, int i_type,
- int i_compute_type )
+int __stats_Create( vlc_object_t *p_this, const char *psz_name, unsigned int i_id,
+ int i_type, int i_compute_type )
{
counter_t *p_counter;
stats_handler_t *p_handler;
p_counter = (counter_t*) malloc( sizeof( counter_t ) ) ;
p_counter->psz_name = strdup( psz_name );
- p_counter->i_source_object = p_this->i_object_id;
+ p_counter->i_index = ((uint64_t)p_this->i_object_id << 32 ) + i_id;
p_counter->i_compute_type = i_compute_type;
p_counter->i_type = i_type;
p_counter->i_samples = 0;
p_counter->update_interval = 0;
p_counter->last_update = 0;
- vlc_HashInsert( &p_handler->p_counters, &p_handler->i_counters, p_this->i_object_id,
- psz_name, p_counter );
+ INSERT_ELEM( p_handler->pp_counters, p_handler->i_counters,
+ p_handler->i_counters, p_counter );
vlc_mutex_unlock( &p_handler->object_lock );
* \param val the vlc_value union containing the new value to aggregate. For
* more information on how data is aggregated, \see __stats_Create
*/
-int __stats_Update( vlc_object_t *p_this, const char *psz_name,
+int __stats_Update( vlc_object_t *p_this, unsigned int i_counter,
vlc_value_t val, vlc_value_t *val_new )
{
int i_ret;
vlc_mutex_lock( &p_handler->object_lock );
/* Look for existing element */
- p_counter = GetCounter( p_handler, p_this->i_object_id,
- psz_name );
+ p_counter = GetCounter( p_handler, p_this->i_object_id, i_counter );
if( !p_counter )
{
vlc_mutex_unlock( &p_handler->object_lock );
* \return an error code
*/
int __stats_Get( vlc_object_t *p_this, int i_object_id,
- const char *psz_name, vlc_value_t *val )
+ unsigned int i_counter, vlc_value_t *val )
{
counter_t *p_counter;
vlc_mutex_lock( &p_handler->object_lock );
/* Look for existing element */
- p_counter = GetCounter( p_handler, i_object_id,
- psz_name );
+ p_counter = GetCounter( p_handler, i_object_id, i_counter );
if( !p_counter )
{
vlc_mutex_unlock( &p_handler->object_lock );
* \return the counter, or NULL if not found (or handler not created yet)
*/
counter_t *__stats_CounterGet( vlc_object_t *p_this, int i_object_id,
- const char *psz_name )
+ unsigned int i_counter )
{
counter_t *p_counter;
vlc_mutex_lock( &p_handler->object_lock );
/* Look for existing element */
- p_counter = GetCounter( p_handler, i_object_id,
- psz_name );
+ p_counter = GetCounter( p_handler, i_object_id, i_counter );
vlc_mutex_unlock( &p_handler->object_lock );
vlc_object_release( p_handler );
vlc_mutex_lock( &p_stats->lock );
/* Input */
- stats_GetInteger( p_input, p_input->i_object_id, "read_packets",
+ stats_GetInteger( p_input, p_input->i_object_id, STATS_READ_PACKETS,
&p_stats->i_read_packets );
- stats_GetInteger( p_input, p_input->i_object_id, "read_bytes",
+ stats_GetInteger( p_input, p_input->i_object_id, STATS_READ_BYTES,
&p_stats->i_read_bytes );
- stats_GetFloat( p_input, p_input->i_object_id, "input_bitrate",
+ stats_GetFloat( p_input, p_input->i_object_id, STATS_INPUT_BITRATE,
&p_stats->f_input_bitrate );
- stats_GetInteger( p_input, p_input->i_object_id, "demux_read",
+ stats_GetInteger( p_input, p_input->i_object_id, STATS_DEMUX_READ,
&p_stats->i_demux_read_bytes );
- stats_GetFloat( p_input, p_input->i_object_id, "demux_bitrate",
+ stats_GetFloat( p_input, p_input->i_object_id, STATS_DEMUX_BITRATE,
&p_stats->f_demux_bitrate );
- stats_GetInteger( p_input, p_input->i_object_id, "decoded_video",
+ stats_GetInteger( p_input, p_input->i_object_id, STATS_DECODED_VIDEO,
&p_stats->i_decoded_video );
- stats_GetInteger( p_input, p_input->i_object_id, "decoded_audio",
+ stats_GetInteger( p_input, p_input->i_object_id, STATS_DECODED_AUDIO,
&p_stats->i_decoded_audio );
/* Sout */
- stats_GetInteger( p_input, p_input->i_object_id, "sout_sent_packets",
+ stats_GetInteger( p_input, p_input->i_object_id, STATS_SOUT_SENT_PACKETS,
&p_stats->i_sent_packets );
- stats_GetInteger( p_input, p_input->i_object_id, "sout_sent_bytes",
+ stats_GetInteger( p_input, p_input->i_object_id, STATS_SOUT_SENT_BYTES,
&p_stats->i_sent_bytes );
- stats_GetFloat ( p_input, p_input->i_object_id, "sout_send_bitrate",
+ stats_GetFloat ( p_input, p_input->i_object_id, STATS_SOUT_SEND_BITRATE,
&p_stats->f_send_bitrate );
/* Aout - We store in p_input because aout is shared */
- stats_GetInteger( p_input, p_input->i_object_id, "played_abuffers",
+ stats_GetInteger( p_input, p_input->i_object_id, STATS_PLAYED_ABUFFERS,
&p_stats->i_played_abuffers );
- stats_GetInteger( p_input, p_input->i_object_id, "lost_abuffers",
+ stats_GetInteger( p_input, p_input->i_object_id, STATS_LOST_ABUFFERS,
&p_stats->i_lost_abuffers );
/* Vouts - FIXME: Store all in input */
{
int i_displayed = 0, i_lost = 0;
p_obj = (vlc_object_t *)p_list->p_values[i_index].p_object;
- stats_GetInteger( p_obj, p_obj->i_object_id, "displayed_pictures",
+ stats_GetInteger( p_obj, p_obj->i_object_id,
+ STATS_DISPLAYED_PICTURES,
&i_displayed );
- stats_GetInteger( p_obj, p_obj->i_object_id, "lost_pictures",
+ stats_GetInteger( p_obj, p_obj->i_object_id, STATS_LOST_PICTURES,
&i_lost );
p_stats->i_displayed_pictures += i_displayed;
p_stats->i_lost_pictures += i_lost;
vlc_mutex_lock( &p_stats->lock );
/* f_bitrate is in bytes / microsecond
* *1000 => bytes / millisecond => kbytes / seconds */
- fprintf( stderr, "Input : %i (%i bytes) - %f kB/s - Demux : %i (%i bytes) - %f kB/s\n"
- " - Vout : %i/%i - Aout : %i/%i - Vout : %f\n",
+ fprintf( stderr, "Input : %i (%i bytes) - %f kB/s - "
+ "Demux : %i (%i bytes) - %f kB/s\n"
+ " - Vout : %i/%i - Aout : %i/%i - Sout : %f\n",
p_stats->i_read_packets, p_stats->i_read_bytes,
p_stats->f_input_bitrate * 1000,
p_stats->i_demux_read_packets, p_stats->i_demux_read_bytes,
{
float f_in = 0, f_out = 0, f_demux = 0;
p_obj = (vlc_object_t *)p_list->p_values[i_index].p_object;
- stats_GetFloat( p_obj, p_obj->i_object_id, "input_bitrate",
+ stats_GetFloat( p_obj, p_obj->i_object_id, STATS_INPUT_BITRATE,
&f_in );
- stats_GetFloat( p_obj, p_obj->i_object_id, "sout_send_bitrate",
+ stats_GetFloat( p_obj, p_obj->i_object_id, STATS_SOUT_SEND_BITRATE,
&f_out );
- stats_GetFloat( p_obj, p_obj->i_object_id, "demux_bitrate",
+ stats_GetFloat( p_obj, p_obj->i_object_id, STATS_DEMUX_BITRATE,
&f_demux );
f_total_in += f_in; f_total_out += f_out;f_total_demux += f_demux;
}
}
-void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name )
+void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name,
+ unsigned int i_id )
{
counter_t *p_counter = stats_CounterGet( p_obj,
- p_obj->p_vlc->i_object_id,
- psz_name );
+ p_obj->p_vlc->i_object_id, i_id );
if( !p_counter )
{
counter_sample_t *p_sample;
- stats_Create( p_obj->p_vlc, psz_name, VLC_VAR_TIME, STATS_TIMER );
+ stats_Create( p_obj->p_vlc, psz_name, i_id, VLC_VAR_TIME, STATS_TIMER );
p_counter = stats_CounterGet( p_obj, p_obj->p_vlc->i_object_id,
- psz_name );
+ i_id );
if( !p_counter ) return;
/* 1st sample : if started: start_date, else last_time, b_started */
p_sample = (counter_sample_t *)malloc( sizeof( counter_sample_t ) );
p_counter->pp_samples[0]->date = mdate();
}
-void __stats_TimerStop( vlc_object_t *p_obj, const char *psz_name )
+void __stats_TimerStop( vlc_object_t *p_obj, unsigned int i_id )
{
counter_t *p_counter = stats_CounterGet( p_obj,
- p_obj->p_vlc->i_object_id,
- psz_name );
+ p_obj->p_vlc->i_object_id,
+ i_id );
if( !p_counter || p_counter->i_samples != 2 )
{
- msg_Err( p_obj, "timer %s does not exist", psz_name );
+ msg_Err( p_obj, "timer does not exist" );
return;
}
p_counter->pp_samples[0]->value.b_bool = VLC_FALSE;
p_counter->pp_samples[1]->date += p_counter->pp_samples[0]->date;
}
-void __stats_TimerDump( vlc_object_t *p_obj, const char *psz_name )
+void __stats_TimerDump( vlc_object_t *p_obj, unsigned int i_id )
{
counter_t *p_counter = stats_CounterGet( p_obj,
p_obj->p_vlc->i_object_id,
- psz_name );
+ i_id );
TimerDump( p_obj, p_counter, VLC_TRUE );
}
vlc_mutex_lock( &p_handler->object_lock );
for ( i = 0 ; i< p_handler->i_counters; i++ )
{
- counter_t * p_counter = (counter_t *)(p_handler->p_counters[i].p_data);
+ counter_t * p_counter = p_handler->pp_counters[i];
if( p_counter->i_compute_type == STATS_TIMER )
{
TimerDump( p_obj, p_counter, VLC_FALSE );
}
static counter_t *GetCounter( stats_handler_t *p_handler, int i_object_id,
- const char *psz_name )
+ unsigned int i_counter )
{
int i;
- return (counter_t *)vlc_HashRetrieve( p_handler->p_counters, p_handler->i_counters,
- i_object_id, psz_name );
+ uint64_t i_index = ((uint64_t) i_object_id << 32 ) + i_counter;
+ for (i = 0 ; i < p_handler->i_counters ; i++ )
+ {
+ if( i_index == p_handler->pp_counters[i]->i_index )
+ return p_handler->pp_counters[i];
+ }
+ return NULL;
}
return NULL;
}
p_handler->i_counters = 0;
- p_handler->p_counters = (hashtable_entry_t *) malloc( 4 * sizeof( variable_t ) );
+ p_handler->pp_counters = NULL;
/// \bug is it p_vlc or p_libvlc ?
vlc_object_attach( p_handler, p_this->p_vlc );
{
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 );
+ stats_Create( host, "client_connections", STATS_CLIENT_CONNECTIONS,
+ VLC_VAR_INTEGER, STATS_COUNTER );
+ stats_Create( host, "active_connections", STATS_ACTIVE_CONNECTIONS,
+ VLC_VAR_INTEGER, STATS_COUNTER );
while( !host->b_die )
{
cl->i_activity_date+cl->i_activity_timeout < mdate()) ) ) )
{
httpd_ClientClean( cl );
- stats_UpdateInteger( host, "active_connections", -1, NULL );
+ stats_UpdateInteger( host, STATS_ACTIVE_CONNECTIONS, -1, NULL );
TAB_REMOVE( host->i_client, host->client, cl );
free( cl );
i_client--;
if( fd >= 0 )
{
httpd_client_t *cl;
- stats_UpdateInteger( host, "client_connections", 1,
- NULL );
- stats_UpdateInteger( host, "active_connections", 1,
+ stats_UpdateInteger( host, STATS_CLIENT_CONNECTIONS,
+ 1, NULL );
+ stats_UpdateInteger( host, STATS_ACTIVE_CONNECTIONS, 1,
NULL );
cl = httpd_ClientNew( fd, &sock, i_sock_size, p_tls );
p_tls = NULL;
i_loops++;
if( p_playlist->p_interaction )
{
- stats_TimerStart( p_playlist, "Interaction thread" );
+ stats_TimerStart( p_playlist, "Interaction thread",
+ STATS_TIMER_INTERACTION );
intf_InteractionManage( p_playlist );
- stats_TimerStop( p_playlist, "Interaction thread" );
+ stats_TimerStop( p_playlist, STATS_TIMER_INTERACTION );
}
if( i_loops %5 == 0 && p_playlist->p_stats )
{
/* Start another input.
* Get the next item to play */
- stats_TimerStart( p_playlist, "Playlist walk" );
+ stats_TimerStart( p_playlist, "Playlist walk",
+ STATS_TIMER_PLAYLIST_WALK );
p_item = NextItem( p_playlist );
- stats_TimerStop( p_playlist, "Playlist walk" );
+ stats_TimerStop( p_playlist, STATS_TIMER_PLAYLIST_WALK );
/* We must stop */
if( p_item == NULL )
strncmp( p_current->input.psz_uri, "dshow:", 6 ) )
{
b_preparsed = VLC_TRUE;
- stats_TimerStart( p_playlist, "Preparse run" );
+ stats_TimerStart( p_playlist, "Preparse run",
+ STATS_TIMER_PREPARSE );
input_Preparse( p_playlist, &p_current->input );
- stats_TimerStop( p_playlist, "Preparse run" );
+ stats_TimerStop( p_playlist, STATS_TIMER_PREPARSE );
}
vlc_mutex_unlock( &p_playlist->object_lock );
if( b_preparsed )
vlc_object_attach( p_sout, p_parent );
/* Create statistics */
- stats_Create( p_parent, "sout_sent_packets",
+ stats_Create( p_parent, "sout_sent_packets", STATS_SOUT_SENT_PACKETS,
VLC_VAR_INTEGER, STATS_COUNTER );
- stats_Create( p_parent, "sout_sent_bytes", VLC_VAR_INTEGER, STATS_COUNTER );
- stats_Create( p_parent, "sout_send_bitrate",
+ stats_Create( p_parent, "sout_sent_bytes", STATS_SOUT_SENT_BYTES,
+ VLC_VAR_INTEGER, STATS_COUNTER );
+ stats_Create( p_parent, "sout_send_bitrate", STATS_SOUT_SEND_BITRATE,
VLC_VAR_FLOAT, STATS_DERIVATIVE );
p_counter = stats_CounterGet( p_parent, p_parent->i_object_id,
- "sout_send_bitrate" );
+ STATS_SOUT_SEND_BITRATE );
if( p_counter) p_counter->update_interval = 1000000;
p_sout->p_stream = sout_StreamNew( p_sout, p_sout->psz_chain );
int i_total;
p_access->i_writes++;
p_access->i_sent_bytes += p_buffer->i_buffer;
- if( p_access->p_libvlc->b_stats && p_access->i_writes % 10 == 0 )
+ if( p_access->p_libvlc->b_stats && p_access->i_writes % 30 == 0 )
{
/* Access_out -> sout_instance -> input_thread_t */
input_thread_t *p_input =
FIND_PARENT );
if( p_input )
{
- stats_UpdateInteger( p_input, "sout_sent_packets", 10, NULL );
- stats_UpdateInteger( p_input, "sout_sent_bytes",
+ stats_UpdateInteger( p_input, STATS_SOUT_SENT_PACKETS, 30, NULL );
+ stats_UpdateInteger( p_input, STATS_SOUT_SENT_BYTES,
p_access->i_sent_bytes, &i_total );
- stats_UpdateFloat( p_input, "sout_send_bitrate", (float)i_total,
+ stats_UpdateFloat( p_input, STATS_SOUT_SEND_BITRATE, (float)i_total,
NULL );
p_access->i_sent_bytes = 0;
vlc_object_release( p_input );
return NULL;
}
- stats_Create( p_vout, "displayed_pictures", VLC_VAR_INTEGER,
- STATS_COUNTER );
- stats_Create( p_vout, "lost_pictures", VLC_VAR_INTEGER, STATS_COUNTER );
+ stats_Create( p_vout, "displayed_pictures",STATS_DISPLAYED_PICTURES,
+ VLC_VAR_INTEGER, STATS_COUNTER );
+ stats_Create( p_vout, "lost_pictures", STATS_LOST_PICTURES,
+ VLC_VAR_INTEGER, STATS_COUNTER );
/* Initialize pictures - translation tables and functions
* will be initialized later in InitThread */
}
msg_Warn( p_vout, "late picture skipped ("I64Fd")",
current_date - display_date );
- stats_UpdateInteger( p_vout, "lost_pictures", 1 , NULL);
+ stats_UpdateInteger( p_vout, STATS_LOST_PICTURES, 1 , NULL);
vlc_mutex_unlock( &p_vout->picture_lock );
continue;
p_picture->i_status = DESTROYED_PICTURE;
p_vout->i_heap_size--;
}
- stats_UpdateInteger( p_vout, "lost_pictures", 1, NULL );
+ stats_UpdateInteger( p_vout, STATS_LOST_PICTURES, 1, NULL );
msg_Warn( p_vout, "vout warning: early picture skipped "
"("I64Fd")", display_date - current_date
- p_vout->i_pts_delay );
/*
* Perform rendering
*/
- stats_UpdateInteger( p_vout, "displayed_pictures", 1, NULL );
+ stats_UpdateInteger( p_vout, STATS_DISPLAYED_PICTURES, 1, NULL );
p_directbuffer = vout_RenderPicture( p_vout, p_picture, p_subpic );
/*