Stop using strings to index stats, use integers. The list is not sorted yet, though
authorClément Stenac <zorglub@videolan.org>
Sat, 4 Feb 2006 16:26:23 +0000 (16:26 +0000)
committerClément Stenac <zorglub@videolan.org>
Sat, 4 Feb 2006 16:26:23 +0000 (16:26 +0000)
14 files changed:
include/vlc_messages.h
include/vlc_symbols.h
modules/stream_out/transcode.c
src/audio_output/dec.c
src/audio_output/input.c
src/input/decoder.c
src/input/es_out.c
src/input/input.c
src/input/stream.c
src/misc/stats.c
src/network/httpd.c
src/playlist/playlist.c
src/stream_output/stream_output.c
src/video_output/video_output.c

index feef6de..6b4b3da 100644 (file)
@@ -228,10 +228,11 @@ struct counter_sample_t
 
 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;
 
@@ -239,66 +240,93 @@ struct counter_t
     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;
@@ -368,7 +396,7 @@ VLC_EXPORT( void, __stats_ComputeGlobalStats, (vlc_object_t*,global_stats_t*));
  * 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) )
@@ -378,7 +406,7 @@ VLC_EXPORT( void, __stats_ComputeGlobalStats, (vlc_object_t*,global_stats_t*));
 #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*) );
index 746d2e5..079c2f9 100644 (file)
@@ -65,7 +65,7 @@ int playlist_ItemSetName (playlist_item_t *,  char *);
 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);
@@ -124,8 +124,8 @@ void vlm_MessageDelete (vlm_message_t *);
 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 *);
@@ -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);
 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);
@@ -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 **);
 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 *);
@@ -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);
 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);
@@ -425,7 +425,7 @@ void aout_FormatsPrint (aout_instance_t * p_aout, const char * psz_text, const a
 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 *);
@@ -896,23 +896,23 @@ struct module_symbols_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);
index 043ed5e..8c79c24 100644 (file)
@@ -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,
                                                           &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;
@@ -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 )) )
     {
         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 )
         {
index 5e721bb..cecd583 100644 (file)
@@ -312,7 +312,7 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
                   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 );
@@ -368,7 +368,7 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
     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 );
 
index a7a5226..555913f 100644 (file)
@@ -447,7 +447,7 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
         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 );
         }
     }
@@ -460,7 +460,7 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
                   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 );
@@ -502,7 +502,7 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
         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;
index c078dbb..40e8edf 100644 (file)
@@ -429,11 +429,11 @@ static decoder_t * CreateDecoder( input_thread_t *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 );
-    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 )
@@ -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,
                                                        &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 &&
@@ -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 )) )
         {
-            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 )
             {
@@ -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,
                                                        &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 )
@@ -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 )) )
         {
-            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 )
             {
@@ -739,7 +740,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->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 ) )
index a919a30..3769826 100644 (file)
@@ -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 )
     {
-        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 */
index ff78ae2..7c7a1b2 100644 (file)
@@ -685,22 +685,28 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
     {
         /* 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" );
index 3ce55b2..4332376 100644 (file)
@@ -1580,11 +1580,12 @@ static int AReadStream( stream_t *s, void *p_read, int i_read )
     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;
     }
 
@@ -1613,11 +1614,11 @@ static int AReadStream( stream_t *s, void *p_read, int 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;
 }
 
@@ -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( 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;
     }
@@ -1670,11 +1671,12 @@ static block_t *AReadBlock( stream_t *s, vlc_bool_t *pb_eof )
     }
     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;
index a34e090..4d24ddd 100644 (file)
@@ -33,7 +33,7 @@
  * 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 * );
@@ -57,8 +57,7 @@ void stats_HandlerDestroy( stats_handler_t *p_stats )
     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-- )
         {
@@ -67,8 +66,7 @@ void stats_HandlerDestroy( stats_handler_t *p_stats )
             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 );
     }
 }
@@ -84,8 +82,8 @@ void stats_HandlerDestroy( stats_handler_t *p_stats )
  * 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;
@@ -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->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;
@@ -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->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 );
 
@@ -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
  * 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;
@@ -142,8 +140,7 @@ int __stats_Update( vlc_object_t *p_this, const char *psz_name,
 
     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 );
@@ -166,7 +163,7 @@ int __stats_Update( vlc_object_t *p_this, const char *psz_name,
  * \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;
 
@@ -181,8 +178,7 @@ int __stats_Get( vlc_object_t *p_this, int i_object_id,
     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 );
@@ -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)
  */
 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;
 
@@ -260,8 +256,7 @@ counter_t *__stats_CounterGet( vlc_object_t *p_this, int i_object_id,
     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 );
 
@@ -278,35 +273,35 @@ void stats_ComputeInputStats( input_thread_t *p_input,
     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 */
@@ -319,9 +314,10 @@ void stats_ComputeInputStats( input_thread_t *p_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;
@@ -351,8 +347,9 @@ void stats_DumpInputStats( input_stats_t *p_stats  )
     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,
@@ -378,11 +375,11 @@ void __stats_ComputeGlobalStats( vlc_object_t *p_obj,
         {
             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;
         }
@@ -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,
-                                             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 ) );
@@ -433,14 +430,14 @@ void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name )
     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;
@@ -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;
 }
 
-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 );
 }
 
@@ -467,7 +464,7 @@ void __stats_TimersDumpAll( vlc_object_t *p_obj )
     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 );
@@ -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,
-                              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;
 }
 
 
@@ -661,7 +663,7 @@ static stats_handler_t* stats_HandlerCreate( vlc_object_t *p_this )
         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 );
index c1ddfc9..85c9308 100644 (file)
@@ -2055,8 +2055,10 @@ 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 );
+    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 )
     {
@@ -2106,7 +2108,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, NULL );
+                stats_UpdateInteger( host, STATS_ACTIVE_CONNECTIONS, -1, NULL );
                 TAB_REMOVE( host->i_client, host->client, cl );
                 free( cl );
                 i_client--;
@@ -2560,9 +2562,9 @@ static void httpd_HostThread( httpd_host_t *host )
                     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;
index b52d202..18e0264 100644 (file)
@@ -598,9 +598,10 @@ static void RunThread ( playlist_t *p_playlist )
         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 )
@@ -712,9 +713,10 @@ static void RunThread ( playlist_t *p_playlist )
         {
             /* 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 )
@@ -876,9 +878,10 @@ static void RunPreparse ( playlist_preparse_t *p_obj )
                     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 )
index 4bfd91d..cba1a98 100644 (file)
@@ -143,13 +143,14 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest )
     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 );
@@ -373,7 +374,7 @@ int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer )
     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 =
@@ -381,10 +382,10 @@ int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer )
                                                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 );
index 1156749..129e361 100644 (file)
@@ -229,9 +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 );
+    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 */
@@ -814,7 +815,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 , NULL);
+                stats_UpdateInteger( p_vout, STATS_LOST_PICTURES, 1 , NULL);
                 vlc_mutex_unlock( &p_vout->picture_lock );
 
                 continue;
@@ -837,7 +838,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, 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 );
@@ -895,7 +896,7 @@ static void RunThread( vout_thread_t *p_vout)
         /*
          * 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 );
 
         /*