Commit 0b44cb99 authored by Clément Stenac's avatar Clément Stenac

Stop using strings to index stats, use integers. The list is not sorted yet, though

parent b41bfdb8
...@@ -228,10 +228,11 @@ struct counter_sample_t ...@@ -228,10 +228,11 @@ struct counter_sample_t
struct counter_t struct counter_t
{ {
/* The list is *NOT* sorted at the moment, it could be ... */
uint64_t i_index;
char * psz_name; char * psz_name;
int i_source_object;
int i_compute_type;
int i_type; int i_type;
int i_compute_type;
int i_samples; int i_samples;
counter_sample_t ** pp_samples; counter_sample_t ** pp_samples;
...@@ -239,66 +240,93 @@ struct counter_t ...@@ -239,66 +240,93 @@ struct counter_t
mtime_t last_update; 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 struct stats_handler_t
{ {
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
int i_counters; int i_counters;
hashtable_entry_t * p_counters; counter_t **pp_counters;
}; };
VLC_EXPORT( void, stats_HandlerDestroy, (stats_handler_t*) ); VLC_EXPORT( void, stats_HandlerDestroy, (stats_handler_t*) );
#define stats_Update( a,b,c, d) __stats_Update( VLC_OBJECT( a ), b, c, d ) #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 *) ); VLC_EXPORT( int, __stats_Update, (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *) );
#define stats_Create( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d ) #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 *, int, int) ); 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 ) #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 ) #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 ) #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, 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; 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; *value = val.i_int;
return i_ret; return i_ret;
} }
#define stats_GetFloat(a,b,c,d ) __stats_GetFloat( VLC_OBJECT(a), b, c, d ) #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, 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; 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; *value = val.f_float;
return i_ret; return i_ret;
} }
#define stats_UpdateInteger( a,b,c,d ) __stats_UpdateInteger( VLC_OBJECT(a),b,c,d ) #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, 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; int i_ret;
vlc_value_t val; vlc_value_t val;
vlc_value_t new_val; vlc_value_t new_val;
val.i_int = i; 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 ) if( pi_new )
*pi_new = new_val.i_int; *pi_new = new_val.i_int;
return i_ret; return i_ret;
} }
#define stats_UpdateFloat( a,b,c,d ) __stats_UpdateFloat( VLC_OBJECT(a),b,c,d ) #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, 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; vlc_value_t val;
int i_ret; int i_ret;
vlc_value_t new_val; vlc_value_t new_val;
val.f_float = f; 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 ) if( pf_new )
*pf_new = new_val.f_float; *pf_new = new_val.f_float;
return i_ret; return i_ret;
...@@ -368,7 +396,7 @@ VLC_EXPORT( void, __stats_ComputeGlobalStats, (vlc_object_t*,global_stats_t*)); ...@@ -368,7 +396,7 @@ VLC_EXPORT( void, __stats_ComputeGlobalStats, (vlc_object_t*,global_stats_t*));
* Timing * Timing
********/ ********/
#ifdef DEBUG #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_TimerStop(a,b) __stats_TimerStop( VLC_OBJECT(a), b )
#define stats_TimerDump(a,b) __stats_TimerDump( 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_TimersDumpAll(a) __stats_TimersDumpAll( VLC_OBJECT(a) )
...@@ -378,7 +406,7 @@ VLC_EXPORT( void, __stats_ComputeGlobalStats, (vlc_object_t*,global_stats_t*)); ...@@ -378,7 +406,7 @@ VLC_EXPORT( void, __stats_ComputeGlobalStats, (vlc_object_t*,global_stats_t*));
#define stats_TimerDump(a,b) {} #define stats_TimerDump(a,b) {}
#define stats_TimersDumpAll(a) {} #define stats_TimersDumpAll(a) {}
#endif #endif
VLC_EXPORT( void,__stats_TimerStart, (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*, const char *) ); VLC_EXPORT( void,__stats_TimerStop, (vlc_object_t*, unsigned int) );
VLC_EXPORT( void,__stats_TimerDump, (vlc_object_t*, const char *) ); VLC_EXPORT( void,__stats_TimerDump, (vlc_object_t*, unsigned int) );
VLC_EXPORT( void,__stats_TimersDumpAll, (vlc_object_t*) ); VLC_EXPORT( void,__stats_TimersDumpAll, (vlc_object_t*) );
...@@ -65,7 +65,7 @@ int playlist_ItemSetName (playlist_item_t *, char *); ...@@ -65,7 +65,7 @@ int playlist_ItemSetName (playlist_item_t *, char *);
void __osd_MenuShow (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); 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); 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 httpd_RedirectDelete (httpd_redirect_t *);
void __sout_CfgParse (vlc_object_t *, char *psz_prefix, const char **ppsz_options, sout_cfg_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); vlm_media_t * vlm_MediaNew (vlm_t *, const char *, int);
...@@ -124,8 +124,8 @@ void vlm_MessageDelete (vlm_message_t *); ...@@ -124,8 +124,8 @@ void vlm_MessageDelete (vlm_message_t *);
void vout_SynchroDecode (vout_synchro_t *); void vout_SynchroDecode (vout_synchro_t *);
int playlist_Delete (playlist_t *, int); 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); 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_Update (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *);
int __stats_Get (vlc_object_t*, int, const char *, vlc_value_t*); int __stats_Get (vlc_object_t*, int, int, vlc_value_t*);
char* httpd_ClientIP (httpd_client_t *cl, char *psz_ip); char* httpd_ClientIP (httpd_client_t *cl, char *psz_ip);
int __intf_UserProgress (vlc_object_t*, const char*, const char*, float); int __intf_UserProgress (vlc_object_t*, const char*, const char*, float);
void httpd_FileDelete (httpd_file_t *); void httpd_FileDelete (httpd_file_t *);
...@@ -139,7 +139,7 @@ sout_mux_t * sout_MuxNew (sout_instance_t*, char *, sout_access_out_t *); ...@@ -139,7 +139,7 @@ sout_mux_t * sout_MuxNew (sout_instance_t*, char *, sout_access_out_t *);
stream_t * __stream_DemuxNew (vlc_object_t *p_obj, char *psz_demux, es_out_t *out); 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); 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); 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 block_FifoPut (block_fifo_t *, block_t *);
int playlist_ItemAddParent (playlist_item_t *, int,playlist_item_t *); int playlist_ItemAddParent (playlist_item_t *, int,playlist_item_t *);
int __var_Create (vlc_object_t *, const char *, int); int __var_Create (vlc_object_t *, const char *, int);
...@@ -151,7 +151,7 @@ int vlc_getnameinfo (const struct sockaddr *, int, char *, int, int *, int); ...@@ -151,7 +151,7 @@ int vlc_getnameinfo (const struct sockaddr *, int, char *, int, int *, int);
int vlm_ExecuteCommand (vlm_t *, const char *, vlm_message_t **); int vlm_ExecuteCommand (vlm_t *, const char *, vlm_message_t **);
char * config_GetUserDir (void); 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); 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 *); int __config_GetType (vlc_object_t *, const char *);
void __vlc_thread_ready (vlc_object_t *); void __vlc_thread_ready (vlc_object_t *);
int playlist_Export (playlist_t *, const char *, const char *); int playlist_Export (playlist_t *, const char *, const char *);
...@@ -206,7 +206,7 @@ int vlm_Save (vlm_t *, const char *); ...@@ -206,7 +206,7 @@ int vlm_Save (vlm_t *, const char *);
int ACL_AddNet (vlc_acl_t *p_acl, const char *psz_ip, int i_len, vlc_bool_t b_allow); 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 AddMD5 (struct md5_s *, const uint8_t *, uint32_t);
void config_Duplicate (module_t *, module_config_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); block_t * __block_New (vlc_object_t *, int);
void xml_Delete (xml_t *); void xml_Delete (xml_t *);
void __msg_Warn (vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3); void __msg_Warn (vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3);
...@@ -425,7 +425,7 @@ void aout_FormatsPrint (aout_instance_t * p_aout, const char * psz_text, const a ...@@ -425,7 +425,7 @@ void aout_FormatsPrint (aout_instance_t * p_aout, const char * psz_text, const a
char * FromUTF32 (const wchar_t *); char * FromUTF32 (const wchar_t *);
void __vout_OSDMessage (vlc_object_t *, int, char *, ...); void __vout_OSDMessage (vlc_object_t *, int, char *, ...);
void intf_StopThread (intf_thread_t *); 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); 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 mwait (mtime_t date);
void __config_ResetAll (vlc_object_t *); void __config_ResetAll (vlc_object_t *);
...@@ -896,23 +896,23 @@ struct module_symbols_t ...@@ -896,23 +896,23 @@ struct module_symbols_t
int (*__intf_UserProgress_inner) (vlc_object_t*, const char*, const char*, float); 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_UserProgressUpdate_inner) (vlc_object_t*, int, const char*, float);
void (*__intf_UserHide_inner) (vlc_object_t *, int); void (*__intf_UserHide_inner) (vlc_object_t *, int);
int (*__stats_Create_inner) (vlc_object_t*, const char *, int, int); int (*__stats_Create_inner) (vlc_object_t*, const char *, unsigned int, int, int);
int (*__stats_Update_inner) (vlc_object_t*, const char *, vlc_value_t, vlc_value_t *); int (*__stats_Update_inner) (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *);
int (*__stats_Get_inner) (vlc_object_t*, int, const char *, 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_ComputeInputStats_inner) (input_thread_t*, input_stats_t*);
void (*stats_DumpInputStats_inner) (input_stats_t *); void (*stats_DumpInputStats_inner) (input_stats_t *);
void (*stats_ReinitInputStats_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; void *__stats_CounterGet_deprecated;
input_thread_t * (*__input_CreateThread2_inner) (vlc_object_t *, input_item_t *, char *); input_thread_t * (*__input_CreateThread2_inner) (vlc_object_t *, input_item_t *, char *);
void (*stats_HandlerDestroy_inner) (stats_handler_t*); void (*stats_HandlerDestroy_inner) (stats_handler_t*);
vlc_t * (*vlc_current_object_inner) (int); vlc_t * (*vlc_current_object_inner) (int);
void (*__var_OptionParse_inner) (vlc_object_t *, const char *); void (*__var_OptionParse_inner) (vlc_object_t *, const char *);
void *__stats_TimerDumpAll_deprecated; void *__stats_TimerDumpAll_deprecated;
void (*__stats_TimerDump_inner) (vlc_object_t*, const char *); void (*__stats_TimerDump_inner) (vlc_object_t*, unsigned int);
void (*__stats_TimerStart_inner) (vlc_object_t*, const char *); void (*__stats_TimerStart_inner) (vlc_object_t*, const char *, int);
void (*__stats_ComputeGlobalStats_inner) (vlc_object_t*,global_stats_t*); 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*); void (*__stats_TimersDumpAll_inner) (vlc_object_t*);
update_iterator_t * (*update_iterator_New_inner) (update_t *); update_iterator_t * (*update_iterator_New_inner) (update_t *);
void (*update_Check_inner) (update_t *, vlc_bool_t); void (*update_Check_inner) (update_t *, vlc_bool_t);
......
...@@ -1328,7 +1328,8 @@ static int transcode_audio_process( sout_stream_t *p_stream, ...@@ -1328,7 +1328,8 @@ static int transcode_audio_process( sout_stream_t *p_stream,
while( (p_audio_buf = id->p_decoder->pf_decode_audio( id->p_decoder, while( (p_audio_buf = id->p_decoder->pf_decode_audio( id->p_decoder,
&in )) ) &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 ) if( p_sys->b_master_sync )
{ {
mtime_t i_dts = date_Get( &id->interpolated_pts ) + 1; mtime_t i_dts = date_Get( &id->interpolated_pts ) + 1;
...@@ -1731,7 +1732,8 @@ static int transcode_video_process( sout_stream_t *p_stream, ...@@ -1731,7 +1732,8 @@ static int transcode_video_process( sout_stream_t *p_stream,
while( (p_pic = id->p_decoder->pf_decode_video( id->p_decoder, &in )) ) while( (p_pic = id->p_decoder->pf_decode_video( id->p_decoder, &in )) )
{ {
subpicture_t *p_subpic = 0; 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 ) if( p_stream->p_sout->i_out_pace_nocontrol && p_sys->b_hurry_up )
{ {
......
...@@ -312,7 +312,7 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -312,7 +312,7 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
p_buffer->start_date - mdate()); p_buffer->start_date - mdate());
if( p_input->p_input_thread ) 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 ); NULL );
} }
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
...@@ -368,7 +368,7 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -368,7 +368,7 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
if( p_input->p_input_thread ) if( p_input->p_input_thread )
{ {
stats_UpdateInteger( 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 ); vlc_mutex_unlock( &p_aout->mixer_lock );
......
...@@ -447,7 +447,7 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -447,7 +447,7 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
start_date = 0; start_date = 0;
if( p_input->p_input_thread ) 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 ); NULL );
} }
} }
...@@ -460,7 +460,7 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -460,7 +460,7 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
mdate() - p_buffer->start_date ); mdate() - p_buffer->start_date );
if( p_input->p_input_thread ) 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 ); NULL );
} }
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
...@@ -502,7 +502,7 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -502,7 +502,7 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
if( p_input->p_input_thread ) 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 ); NULL );
} }
return 0; return 0;
......
...@@ -429,11 +429,11 @@ static decoder_t * CreateDecoder( input_thread_t *p_input, ...@@ -429,11 +429,11 @@ static decoder_t * CreateDecoder( input_thread_t *p_input,
vlc_object_attach( p_dec, p_input ); 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 ); 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 ); 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 ); VLC_VAR_INTEGER, STATS_COUNTER );
/* Find a suitable decoder/packetizer module */ /* Find a suitable decoder/packetizer module */
if( i_object_type == VLC_OBJECT_DECODER ) if( i_object_type == VLC_OBJECT_DECODER )
...@@ -627,7 +627,8 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) ...@@ -627,7 +627,8 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, while( (p_aout_buf = p_dec->pf_decode_audio( p_dec,
&p_packetized_block )) ) &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 /* FIXME the best would be to handle the case start_date < preroll < end_date
* but that's not easy with non raw audio stream */ * but that's not easy with non raw audio stream */
if( p_dec->p_owner->i_preroll_end > 0 && if( p_dec->p_owner->i_preroll_end > 0 &&
...@@ -651,7 +652,7 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) ...@@ -651,7 +652,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 )) ) 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 && if( p_dec->p_owner->i_preroll_end > 0 &&
p_aout_buf->start_date < p_dec->p_owner->i_preroll_end ) p_aout_buf->start_date < p_dec->p_owner->i_preroll_end )
{ {
...@@ -697,7 +698,7 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) ...@@ -697,7 +698,7 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
while( (p_pic = p_dec->pf_decode_video( p_dec, while( (p_pic = p_dec->pf_decode_video( p_dec,
&p_packetized_block )) ) &p_packetized_block )) )
{ {
stats_UpdateInteger( p_dec->p_parent, "decoded_video", stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_VIDEO,
1, NULL ); 1, NULL );
if( p_dec->p_owner->i_preroll_end > 0 && if( p_dec->p_owner->i_preroll_end > 0 &&
p_pic->date < p_dec->p_owner->i_preroll_end ) p_pic->date < p_dec->p_owner->i_preroll_end )
...@@ -719,7 +720,7 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) ...@@ -719,7 +720,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 )) ) 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 && if( p_dec->p_owner->i_preroll_end > 0 &&
p_pic->date < p_dec->p_owner->i_preroll_end ) p_pic->date < p_dec->p_owner->i_preroll_end )
{ {
...@@ -739,7 +740,7 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) ...@@ -739,7 +740,7 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
subpicture_t *p_spu; subpicture_t *p_spu;
while( (p_spu = p_dec->pf_decode_sub( p_dec, &p_block ) ) ) 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 && if( p_dec->p_owner->i_preroll_end > 0 &&
p_spu->i_start < p_dec->p_owner->i_preroll_end && 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 ) ) ( p_spu->i_stop <= 0 || p_spu->i_stop <= p_dec->p_owner->i_preroll_end ) )
......
...@@ -1033,9 +1033,9 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block ) ...@@ -1033,9 +1033,9 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
if( p_input->p_libvlc->b_stats ) 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 ); &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 */ /* Mark preroll blocks */
......
...@@ -685,22 +685,28 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick ) ...@@ -685,22 +685,28 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
{ {
/* Prepare statistics */ /* Prepare statistics */
counter_t *p_counter; counter_t *p_counter;
stats_Create( p_input, "read_bytes", VLC_VAR_INTEGER, STATS_COUNTER ); stats_Create( p_input, "read_bytes", STATS_READ_BYTES,
stats_Create( p_input, "read_packets", VLC_VAR_INTEGER, STATS_COUNTER ); VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( p_input, "demux_read", VLC_VAR_INTEGER, STATS_COUNTER ); stats_Create( p_input, "read_packets", STATS_READ_PACKETS,
stats_Create( p_input, "input_bitrate", VLC_VAR_FLOAT, VLC_VAR_INTEGER, STATS_COUNTER );
STATS_DERIVATIVE ); stats_Create( p_input, "demux_read", STATS_DEMUX_READ,
stats_Create( p_input, "demux_bitrate", VLC_VAR_FLOAT, VLC_VAR_INTEGER, STATS_COUNTER );
STATS_DERIVATIVE ); 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, p_counter = stats_CounterGet( p_input, p_input->i_object_id,
"input_bitrate" ); STATS_INPUT_BITRATE );
if( p_counter ) p_counter->update_interval = 1000000; if( p_counter ) p_counter->update_interval = 1000000;
p_counter = stats_CounterGet( p_input, p_input->i_object_id, p_counter = stats_CounterGet( p_input, p_input->i_object_id,
"demux_bitrate" ); STATS_DEMUX_BITRATE );
if( p_counter ) p_counter->update_interval = 1000000; if( p_counter ) p_counter->update_interval = 1000000;
stats_Create( p_input, "played_abuffers", VLC_VAR_INTEGER, STATS_COUNTER ); stats_Create( p_input, "played_abuffers", STATS_PLAYED_ABUFFERS,
stats_Create( p_input, "lost_abuffers", VLC_VAR_INTEGER, STATS_COUNTER ); VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( p_input, "lost_abuffers", STATS_LOST_ABUFFERS,
VLC_VAR_INTEGER, STATS_COUNTER );
/* handle sout */ /* handle sout */
psz = var_GetString( p_input, "sout" ); psz = var_GetString( p_input, "sout" );
......
...@@ -1580,11 +1580,12 @@ static int AReadStream( stream_t *s, void *p_read, int i_read ) ...@@ -1580,11 +1580,12 @@ static int AReadStream( stream_t *s, void *p_read, int i_read )
if( !p_sys->i_list ) if( !p_sys->i_list )
{ {
i_read = p_access->pf_read( p_access, p_read, i_read ); 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 ); &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 ); (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; return i_read;
} }
...@@ -1613,11 +1614,11 @@ static int AReadStream( stream_t *s, void *p_read, int i_read ) ...@@ -1613,11 +1614,11 @@ static int AReadStream( stream_t *s, void *p_read, int i_read )
} }
/* Update read bytes in input */ /* 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 ); &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 ); (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; return i_read;
} }
...@@ -1635,11 +1636,11 @@ static block_t *AReadBlock( stream_t *s, vlc_bool_t *pb_eof ) ...@@ -1635,11 +1636,11 @@ static block_t *AReadBlock( stream_t *s, vlc_bool_t *pb_eof )
if( pb_eof ) *pb_eof = p_access->info.b_eof; if( pb_eof ) *pb_eof = p_access->info.b_eof;
if( p_block && p_access->p_libvlc->b_stats ) 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 ); 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 ); (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; return p_block;
} }
...@@ -1670,11 +1671,12 @@ static block_t *AReadBlock( stream_t *s, vlc_bool_t *pb_eof ) ...@@ -1670,11 +1671,12 @@ static block_t *AReadBlock( stream_t *s, vlc_bool_t *pb_eof )
} }
if( 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 ); 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 ); (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; return p_block;
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
static counter_t *GetCounter( stats_handler_t *p_handler, int i_object_id, 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, static int stats_CounterUpdate( stats_handler_t *p_handler,
counter_t *p_counter, counter_t *p_counter,
vlc_value_t val, vlc_value_t * ); vlc_value_t val, vlc_value_t * );
...@@ -57,8 +57,7 @@ void stats_HandlerDestroy( stats_handler_t *p_stats ) ...@@ -57,8 +57,7 @@ void stats_HandlerDestroy( stats_handler_t *p_stats )
for ( i = p_stats->i_counters - 1 ; i >= 0 ; i-- ) for ( i = p_stats->i_counters - 1 ; i >= 0 ; i-- )
{ {
int j; int j;
hashtable_entry_t p_entry = p_stats->p_counters[i]; counter_t *p_counter = p_stats->pp_counters[i];
counter_t * p_counter = p_entry.p_data;
for( j = p_counter->i_samples -1; j >= 0 ; j-- ) for( j = p_counter->i_samples -1; j >= 0 ; j-- )
{ {
...@@ -67,8 +66,7 @@ void stats_HandlerDestroy( stats_handler_t *p_stats ) ...@@ -67,8 +66,7 @@ void stats_HandlerDestroy( stats_handler_t *p_stats )
free( p_sample ); free( p_sample );
} }
free( p_counter->psz_name ); free( p_counter->psz_name );
free( p_entry.psz_name ); REMOVE_ELEM( p_stats->pp_counters, p_stats->i_counters, i );
REMOVE_ELEM( p_stats->p_counters, p_stats->i_counters, i );
free( p_counter ); free( p_counter );
} }
} }
...@@ -84,8 +82,8 @@ void stats_HandlerDestroy( stats_handler_t *p_stats ) ...@@ -84,8 +82,8 @@ void stats_HandlerDestroy( stats_handler_t *p_stats )
* STATS_MAX (keep the maximum passed value), STATS_MIN, or STATS_DERIVATIVE * STATS_MAX (keep the maximum passed value), STATS_MIN, or STATS_DERIVATIVE
* (keep a time derivative of the value) * (keep a time derivative of the value)
*/ */
int __stats_Create( vlc_object_t *p_this, const char *psz_name, int i_type, int __stats_Create( vlc_object_t *p_this, const char *psz_name, unsigned int i_id,
int i_compute_type ) int i_type, int i_compute_type )
{ {
counter_t *p_counter; counter_t *p_counter;
stats_handler_t *p_handler; stats_handler_t *p_handler;
...@@ -102,7 +100,7 @@ int __stats_Create( vlc_object_t *p_this, const char *psz_name, int i_type, ...@@ -102,7 +100,7 @@ int __stats_Create( vlc_object_t *p_this, const char *psz_name, int i_type,
p_counter = (counter_t*) malloc( sizeof( counter_t ) ) ; p_counter = (counter_t*) malloc( sizeof( counter_t ) ) ;
p_counter->psz_name = strdup( psz_name ); 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_compute_type = i_compute_type;
p_counter->i_type = i_type; p_counter->i_type = i_type;
p_counter->i_samples = 0; p_counter->i_samples = 0;
...@@ -111,8 +109,8 @@ int __stats_Create( vlc_object_t *p_this, const char *psz_name, int i_type, ...@@ -111,8 +109,8 @@ int __stats_Create( vlc_object_t *p_this, const char *psz_name, int i_type,
p_counter->update_interval = 0; p_counter->update_interval = 0;
p_counter->last_update = 0; p_counter->last_update = 0;
vlc_HashInsert( &p_handler->p_counters, &p_handler->i_counters, p_this->i_object_id, INSERT_ELEM( p_handler->pp_counters, p_handler->i_counters,
psz_name, p_counter ); p_handler->i_counters, p_counter );
vlc_mutex_unlock( &p_handler->object_lock ); vlc_mutex_unlock( &p_handler->object_lock );
...@@ -125,7 +123,7 @@ int __stats_Create( vlc_object_t *p_this, const char *psz_name, int i_type, ...@@ -125,7 +123,7 @@ int __stats_Create( vlc_object_t *p_this, const char *psz_name, int i_type,
* \param val the vlc_value union containing the new value to aggregate. For * \param val the vlc_value union containing the new value to aggregate. For
* more information on how data is aggregated, \see __stats_Create * 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 ) vlc_value_t val, vlc_value_t *val_new )
{ {
int i_ret; int i_ret;
...@@ -142,8 +140,7 @@ int __stats_Update( vlc_object_t *p_this, const char *psz_name, ...@@ -142,8 +140,7 @@ int __stats_Update( vlc_object_t *p_this, const char *psz_name,
vlc_mutex_lock( &p_handler->object_lock ); vlc_mutex_lock( &p_handler->object_lock );
/* Look for existing element */ /* Look for existing element */
p_counter = GetCounter( p_handler, p_this->i_object_id, p_counter = GetCounter( p_handler, p_this->i_object_id, i_counter );
psz_name );
if( !p_counter ) if( !p_counter )
{ {
vlc_mutex_unlock( &p_handler->object_lock ); vlc_mutex_unlock( &p_handler->object_lock );
...@@ -166,7 +163,7 @@ int __stats_Update( vlc_object_t *p_this, const char *psz_name, ...@@ -166,7 +163,7 @@ int __stats_Update( vlc_object_t *p_this, const char *psz_name,
* \return an error code * \return an error code
*/ */
int __stats_Get( vlc_object_t *p_this, int i_object_id, 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; counter_t *p_counter;
...@@ -181,8 +178,7 @@ int __stats_Get( vlc_object_t *p_this, int i_object_id, ...@@ -181,8 +178,7 @@ int __stats_Get( vlc_object_t *p_this, int i_object_id,
vlc_mutex_lock( &p_handler->object_lock ); vlc_mutex_lock( &p_handler->object_lock );
/* Look for existing element */ /* Look for existing element */
p_counter = GetCounter( p_handler, i_object_id, p_counter = GetCounter( p_handler, i_object_id, i_counter );
psz_name );
if( !p_counter ) if( !p_counter )
{ {
vlc_mutex_unlock( &p_handler->object_lock ); vlc_mutex_unlock( &p_handler->object_lock );
...@@ -245,7 +241,7 @@ int __stats_Get( vlc_object_t *p_this, int i_object_id, ...@@ -245,7 +241,7 @@ int __stats_Get( vlc_object_t *p_this, int i_object_id,
* \return the counter, or NULL if not found (or handler not created yet) * \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, 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; counter_t *p_counter;
...@@ -260,8 +256,7 @@ counter_t *__stats_CounterGet( vlc_object_t *p_this, int i_object_id, ...@@ -260,8 +256,7 @@ counter_t *__stats_CounterGet( vlc_object_t *p_this, int i_object_id,
vlc_mutex_lock( &p_handler->object_lock ); vlc_mutex_lock( &p_handler->object_lock );
/* Look for existing element */ /* Look for existing element */
p_counter = GetCounter( p_handler, i_object_id, p_counter = GetCounter( p_handler, i_object_id, i_counter );
psz_name );
vlc_mutex_unlock( &p_handler->object_lock ); vlc_mutex_unlock( &p_handler->object_lock );
vlc_object_release( p_handler ); vlc_object_release( p_handler );
...@@ -278,35 +273,35 @@ void stats_ComputeInputStats( input_thread_t *p_input, ...@@ -278,35 +273,35 @@ void stats_ComputeInputStats( input_thread_t *p_input,
vlc_mutex_lock( &p_stats->lock ); vlc_mutex_lock( &p_stats->lock );
/* Input */ /* 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 ); &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 ); &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 ); &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 ); &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 ); &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 ); &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 ); &p_stats->i_decoded_audio );
/* Sout */ /* 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 ); &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 ); &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 ); &p_stats->f_send_bitrate );
/* Aout - We store in p_input because aout is shared */ /* 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 ); &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 ); &p_stats->i_lost_abuffers );
/* Vouts - FIXME: Store all in input */ /* Vouts - FIXME: Store all in input */
...@@ -319,9 +314,10 @@ void stats_ComputeInputStats( input_thread_t *p_input, ...@@ -319,9 +314,10 @@ void stats_ComputeInputStats( input_thread_t *p_input,
{ {
int i_displayed = 0, i_lost = 0; int i_displayed = 0, i_lost = 0;
p_obj = (vlc_object_t *)p_list->p_values[i_index].p_object; 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 ); &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 ); &i_lost );
p_stats->i_displayed_pictures += i_displayed; p_stats->i_displayed_pictures += i_displayed;
p_stats->i_lost_pictures += i_lost; p_stats->i_lost_pictures += i_lost;
...@@ -351,8 +347,9 @@ void stats_DumpInputStats( input_stats_t *p_stats ) ...@@ -351,8 +347,9 @@ void stats_DumpInputStats( input_stats_t *p_stats )
vlc_mutex_lock( &p_stats->lock ); vlc_mutex_lock( &p_stats->lock );
/* f_bitrate is in bytes / microsecond /* f_bitrate is in bytes / microsecond
* *1000 => bytes / millisecond => kbytes / seconds */ * *1000 => bytes / millisecond => kbytes / seconds */
fprintf( stderr, "Input : %i (%i bytes) - %f kB/s - Demux : %i (%i bytes) - %f kB/s\n" fprintf( stderr, "Input : %i (%i bytes) - %f kB/s - "
" - Vout : %i/%i - Aout : %i/%i - Vout : %f\n", "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->i_read_packets, p_stats->i_read_bytes,
p_stats->f_input_bitrate * 1000, p_stats->f_input_bitrate * 1000,
p_stats->i_demux_read_packets, p_stats->i_demux_read_bytes, p_stats->i_demux_read_packets, p_stats->i_demux_read_bytes,
...@@ -378,11 +375,11 @@ void __stats_ComputeGlobalStats( vlc_object_t *p_obj, ...@@ -378,11 +375,11 @@ void __stats_ComputeGlobalStats( vlc_object_t *p_obj,
{ {
float f_in = 0, f_out = 0, f_demux = 0; float f_in = 0, f_out = 0, f_demux = 0;
p_obj = (vlc_object_t *)p_list->p_values[i_index].p_object; 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 ); &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 ); &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_demux );
f_total_in += f_in; f_total_out += f_out;f_total_demux += f_demux; f_total_in += f_in; f_total_out += f_out;f_total_demux += f_demux;
} }
...@@ -401,17 +398,17 @@ void stats_ReinitGlobalStats( global_stats_t *p_stats ) ...@@ -401,17 +398,17 @@ void stats_ReinitGlobalStats( global_stats_t *p_stats )
} }
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, counter_t *p_counter = stats_CounterGet( p_obj,
p_obj->p_vlc->i_object_id, p_obj->p_vlc->i_object_id, i_id );
psz_name );
if( !p_counter ) if( !p_counter )
{ {
counter_sample_t *p_sample; 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, p_counter = stats_CounterGet( p_obj, p_obj->p_vlc->i_object_id,
psz_name ); i_id );
if( !p_counter ) return; if( !p_counter ) return;
/* 1st sample : if started: start_date, else last_time, b_started */ /* 1st sample : if started: start_date, else last_time, b_started */
p_sample = (counter_sample_t *)malloc( sizeof( counter_sample_t ) ); p_sample = (counter_sample_t *)malloc( sizeof( counter_sample_t ) );
...@@ -433,14 +430,14 @@ void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name ) ...@@ -433,14 +430,14 @@ void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name )
p_counter->pp_samples[0]->date = mdate(); 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, counter_t *p_counter = stats_CounterGet( p_obj,
p_obj->p_vlc->i_object_id, p_obj->p_vlc->i_object_id,
psz_name ); i_id );
if( !p_counter || p_counter->i_samples != 2 ) 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; return;
} }
p_counter->pp_samples[0]->value.b_bool = VLC_FALSE; p_counter->pp_samples[0]->value.b_bool = VLC_FALSE;
...@@ -449,11 +446,11 @@ void __stats_TimerStop( vlc_object_t *p_obj, const char *psz_name ) ...@@ -449,11 +446,11 @@ void __stats_TimerStop( vlc_object_t *p_obj, const char *psz_name )
p_counter->pp_samples[1]->date += p_counter->pp_samples[0]->date; 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, counter_t *p_counter = stats_CounterGet( p_obj,
p_obj->p_vlc->i_object_id, p_obj->p_vlc->i_object_id,
psz_name ); i_id );
TimerDump( p_obj, p_counter, VLC_TRUE ); TimerDump( p_obj, p_counter, VLC_TRUE );
} }
...@@ -467,7 +464,7 @@ void __stats_TimersDumpAll( vlc_object_t *p_obj ) ...@@ -467,7 +464,7 @@ void __stats_TimersDumpAll( vlc_object_t *p_obj )
vlc_mutex_lock( &p_handler->object_lock ); vlc_mutex_lock( &p_handler->object_lock );
for ( i = 0 ; i< p_handler->i_counters; i++ ) 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 ) if( p_counter->i_compute_type == STATS_TIMER )
{ {
TimerDump( p_obj, p_counter, VLC_FALSE ); TimerDump( p_obj, p_counter, VLC_FALSE );
...@@ -617,11 +614,16 @@ static int stats_CounterUpdate( stats_handler_t *p_handler, ...@@ -617,11 +614,16 @@ static int stats_CounterUpdate( stats_handler_t *p_handler,
} }
static counter_t *GetCounter( stats_handler_t *p_handler, int i_object_id, static counter_t *GetCounter( stats_handler_t *p_handler, int i_object_id,
const char *psz_name ) unsigned int i_counter )
{ {
int i; int i;
return (counter_t *)vlc_HashRetrieve( p_handler->p_counters, p_handler->i_counters, uint64_t i_index = ((uint64_t) i_object_id << 32 ) + i_counter;
i_object_id, psz_name ); 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;
} }
...@@ -661,7 +663,7 @@ static stats_handler_t* stats_HandlerCreate( vlc_object_t *p_this ) ...@@ -661,7 +663,7 @@ static stats_handler_t* stats_HandlerCreate( vlc_object_t *p_this )
return NULL; return NULL;
} }
p_handler->i_counters = 0; 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 ? /// \bug is it p_vlc or p_libvlc ?
vlc_object_attach( p_handler, p_this->p_vlc ); vlc_object_attach( p_handler, p_this->p_vlc );
......
...@@ -2055,8 +2055,10 @@ static void httpd_HostThread( httpd_host_t *host ) ...@@ -2055,8 +2055,10 @@ static void httpd_HostThread( httpd_host_t *host )
{ {
tls_session_t *p_tls = NULL; tls_session_t *p_tls = NULL;
stats_Create( host, "client_connections", VLC_VAR_INTEGER, STATS_COUNTER ); stats_Create( host, "client_connections", STATS_CLIENT_CONNECTIONS,
stats_Create( host, "active_connections", VLC_VAR_INTEGER, STATS_COUNTER ); VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( host, "active_connections", STATS_ACTIVE_CONNECTIONS,
VLC_VAR_INTEGER, STATS_COUNTER );
while( !host->b_die ) while( !host->b_die )
{ {
...@@ -2106,7 +2108,7 @@ static void httpd_HostThread( httpd_host_t *host ) ...@@ -2106,7 +2108,7 @@ static void httpd_HostThread( httpd_host_t *host )
cl->i_activity_date+cl->i_activity_timeout < mdate()) ) ) ) cl->i_activity_date+cl->i_activity_timeout < mdate()) ) ) )
{ {
httpd_ClientClean( cl ); 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 ); TAB_REMOVE( host->i_client, host->client, cl );
free( cl ); free( cl );
i_client--; i_client--;
...@@ -2560,9 +2562,9 @@ static void httpd_HostThread( httpd_host_t *host ) ...@@ -2560,9 +2562,9 @@ static void httpd_HostThread( httpd_host_t *host )
if( fd >= 0 ) if( fd >= 0 )
{ {
httpd_client_t *cl; httpd_client_t *cl;
stats_UpdateInteger( host, "client_connections", 1, stats_UpdateInteger( host, STATS_CLIENT_CONNECTIONS,
NULL ); 1, NULL );
stats_UpdateInteger( host, "active_connections", 1, stats_UpdateInteger( host, STATS_ACTIVE_CONNECTIONS, 1,
NULL ); NULL );
cl = httpd_ClientNew( fd, &sock, i_sock_size, p_tls ); cl = httpd_ClientNew( fd, &sock, i_sock_size, p_tls );
p_tls = NULL; p_tls = NULL;
......
...@@ -598,9 +598,10 @@ static void RunThread ( playlist_t *p_playlist ) ...@@ -598,9 +598,10 @@ static void RunThread ( playlist_t *p_playlist )
i_loops++; i_loops++;
if( p_playlist->p_interaction ) if( p_playlist->p_interaction )
{ {
stats_TimerStart( p_playlist, "Interaction thread" ); stats_TimerStart( p_playlist, "Interaction thread",
STATS_TIMER_INTERACTION );
intf_InteractionManage( p_playlist ); 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 ) if( i_loops %5 == 0 && p_playlist->p_stats )
...@@ -712,9 +713,10 @@ static void RunThread ( playlist_t *p_playlist ) ...@@ -712,9 +713,10 @@ static void RunThread ( playlist_t *p_playlist )
{ {
/* Start another input. /* Start another input.
* Get the next item to play */ * 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 ); p_item = NextItem( p_playlist );
stats_TimerStop( p_playlist, "Playlist walk" ); stats_TimerStop( p_playlist, STATS_TIMER_PLAYLIST_WALK );
/* We must stop */ /* We must stop */
if( p_item == NULL ) if( p_item == NULL )
...@@ -876,9 +878,10 @@ static void RunPreparse ( playlist_preparse_t *p_obj ) ...@@ -876,9 +878,10 @@ static void RunPreparse ( playlist_preparse_t *p_obj )
strncmp( p_current->input.psz_uri, "dshow:", 6 ) ) strncmp( p_current->input.psz_uri, "dshow:", 6 ) )
{ {
b_preparsed = VLC_TRUE; 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 ); 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 ); vlc_mutex_unlock( &p_playlist->object_lock );
if( b_preparsed ) if( b_preparsed )
......
...@@ -143,13 +143,14 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest ) ...@@ -143,13 +143,14 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest )
vlc_object_attach( p_sout, p_parent ); vlc_object_attach( p_sout, p_parent );
/* Create statistics */ /* 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 ); VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( p_parent, "sout_sent_bytes", VLC_VAR_INTEGER, STATS_COUNTER ); stats_Create( p_parent, "sout_sent_bytes", STATS_SOUT_SENT_BYTES,
stats_Create( p_parent, "sout_send_bitrate", VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( p_parent, "sout_send_bitrate", STATS_SOUT_SEND_BITRATE,
VLC_VAR_FLOAT, STATS_DERIVATIVE ); VLC_VAR_FLOAT, STATS_DERIVATIVE );
p_counter = stats_CounterGet( p_parent, p_parent->i_object_id, 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; if( p_counter) p_counter->update_interval = 1000000;
p_sout->p_stream = sout_StreamNew( p_sout, p_sout->psz_chain ); p_sout->p_stream = sout_StreamNew( p_sout, p_sout->psz_chain );
...@@ -373,7 +374,7 @@ int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer ) ...@@ -373,7 +374,7 @@ int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer )
int i_total; int i_total;
p_access->i_writes++; p_access->i_writes++;
p_access->i_sent_bytes += p_buffer->i_buffer; 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 */ /* Access_out -> sout_instance -> input_thread_t */
input_thread_t *p_input = input_thread_t *p_input =
...@@ -381,10 +382,10 @@ int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer ) ...@@ -381,10 +382,10 @@ int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer )
FIND_PARENT ); FIND_PARENT );
if( p_input ) if( p_input )
{ {
stats_UpdateInteger( p_input, "sout_sent_packets", 10, NULL ); stats_UpdateInteger( p_input, STATS_SOUT_SENT_PACKETS, 30, NULL );
stats_UpdateInteger( p_input, "sout_sent_bytes", stats_UpdateInteger( p_input, STATS_SOUT_SENT_BYTES,
p_access->i_sent_bytes, &i_total ); 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 ); NULL );
p_access->i_sent_bytes = 0; p_access->i_sent_bytes = 0;
vlc_object_release( p_input ); vlc_object_release( p_input );
......
...@@ -229,9 +229,10 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt ) ...@@ -229,9 +229,10 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
return NULL; return NULL;
} }
stats_Create( p_vout, "displayed_pictures", VLC_VAR_INTEGER, stats_Create( p_vout, "displayed_pictures",STATS_DISPLAYED_PICTURES,
STATS_COUNTER ); VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( p_vout, "lost_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 /* Initialize pictures - translation tables and functions
* will be initialized later in InitThread */ * will be initialized later in InitThread */
...@@ -814,7 +815,7 @@ static void RunThread( vout_thread_t *p_vout) ...@@ -814,7 +815,7 @@ static void RunThread( vout_thread_t *p_vout)
} }
msg_Warn( p_vout, "late picture skipped ("I64Fd")", msg_Warn( p_vout, "late picture skipped ("I64Fd")",
current_date - display_date ); 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 ); vlc_mutex_unlock( &p_vout->picture_lock );
continue; continue;
...@@ -837,7 +838,7 @@ static void RunThread( vout_thread_t *p_vout) ...@@ -837,7 +838,7 @@ static void RunThread( vout_thread_t *p_vout)
p_picture->i_status = DESTROYED_PICTURE; p_picture->i_status = DESTROYED_PICTURE;
p_vout->i_heap_size--; 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 " msg_Warn( p_vout, "vout warning: early picture skipped "
"("I64Fd")", display_date - current_date "("I64Fd")", display_date - current_date
- p_vout->i_pts_delay ); - p_vout->i_pts_delay );
...@@ -895,7 +896,7 @@ static void RunThread( vout_thread_t *p_vout) ...@@ -895,7 +896,7 @@ static void RunThread( vout_thread_t *p_vout)
/* /*
* Perform rendering * 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 ); 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