Changeset 0b44cb999e661507876710e271a58b800e7db068

Show
Ignore:
Timestamp:
02/04/06 17:26:23 (3 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1139070383 +0000
git-parent:

[b41bfdb8bbb2c14e3313ce1f89c3f880ca93fd6f]

git-author:
Clément Stenac <zorglub@videolan.org> 1139070383 +0000
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_messages.h

    r26d5b73 r0b44cb9  
    229229struct counter_t 
    230230{ 
     231    /* The list is *NOT* sorted at the moment, it could be ... */ 
     232    uint64_t            i_index; 
    231233    char              * psz_name; 
    232     int                 i_source_object
     234    int                 i_type
    233235    int                 i_compute_type; 
    234     int                 i_type; 
    235236    int                 i_samples; 
    236237    counter_sample_t ** pp_samples; 
     
    240241}; 
    241242 
     243enum 
     244{ 
     245    STATS_INPUT_BITRATE, 
     246    STATS_READ_BYTES, 
     247    STATS_READ_PACKETS, 
     248    STATS_DEMUX_READ, 
     249    STATS_DEMUX_BITRATE, 
     250    STATS_PLAYED_ABUFFERS, 
     251    STATS_LOST_ABUFFERS, 
     252    STATS_DECODED_AUDIO, 
     253    STATS_DECODED_VIDEO, 
     254    STATS_DECODED_SUB, 
     255    STATS_CLIENT_CONNECTIONS, 
     256    STATS_ACTIVE_CONNECTIONS, 
     257    STATS_SOUT_SENT_PACKETS, 
     258    STATS_SOUT_SENT_BYTES, 
     259    STATS_SOUT_SEND_BITRATE, 
     260    STATS_DISPLAYED_PICTURES, 
     261    STATS_LOST_PICTURES, 
     262 
     263    STATS_TIMER_PLAYLIST_WALK, 
     264    STATS_TIMER_INTERACTION, 
     265    STATS_TIMER_PREPARSE 
     266}; 
     267 
    242268struct stats_handler_t 
    243269{ 
     
    245271 
    246272    int                 i_counters; 
    247     hashtable_entry_t * p_counters; 
     273    counter_t         **pp_counters; 
    248274}; 
    249275 
     
    251277 
    252278#define stats_Update( a,b,c, d) __stats_Update( VLC_OBJECT( a ), b, c, d ) 
    253 VLC_EXPORT( int, __stats_Update, (vlc_object_t*, const char *, vlc_value_t, vlc_value_t *) ); 
    254 #define stats_Create( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d
    255 VLC_EXPORT( int, __stats_Create, (vlc_object_t*, const char *, int, int) ); 
     279VLC_EXPORT( int, __stats_Update, (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *) ); 
     280#define stats_Create( a,b,c,d,e ) __stats_Create( VLC_OBJECT(a), b, c, d,e
     281VLC_EXPORT( int, __stats_Create, (vlc_object_t*, const char *, unsigned int, int, int) ); 
    256282#define stats_Get( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d ) 
    257 VLC_EXPORT( int, __stats_Get, (vlc_object_t*, int, const char *, vlc_value_t*) ); 
     283VLC_EXPORT( int, __stats_Get, (vlc_object_t*, int, unsigned int, vlc_value_t*) ); 
    258284#define stats_CounterGet( a,b,c) __stats_CounterGet( VLC_OBJECT(a), b, c ) 
    259 VLC_EXPORT( counter_t*, __stats_CounterGet, (vlc_object_t*, int, const char * ) ); 
     285VLC_EXPORT( counter_t*, __stats_CounterGet, (vlc_object_t*, int, unsigned int ) ); 
    260286 
    261287#define stats_GetInteger( a,b,c,d ) __stats_GetInteger( VLC_OBJECT(a), b, c, d ) 
    262288static inline int __stats_GetInteger( vlc_object_t *p_obj, int i_id, 
    263                                       const char *psz_name, int *value ) 
     289                                      unsigned int i_counter, int *value ) 
    264290{ 
    265291    vlc_value_t val; 
    266     int i_ret = __stats_Get( p_obj, i_id, psz_name, &val ); 
     292    int i_ret = __stats_Get( p_obj, i_id, i_counter, &val ); 
    267293    *value = val.i_int; 
    268294    return i_ret; 
     
    271297#define stats_GetFloat(a,b,c,d ) __stats_GetFloat( VLC_OBJECT(a), b, c, d ) 
    272298static inline int __stats_GetFloat( vlc_object_t *p_obj, int i_id, 
    273                                     const char *psz_name, float *value ) 
     299                                    unsigned int i_counter, float *value ) 
    274300{ 
    275301    vlc_value_t val; 
    276     int i_ret = __stats_Get( p_obj, i_id, psz_name, &val ); 
     302    int i_ret = __stats_Get( p_obj, i_id, i_counter, &val ); 
    277303    *value = val.f_float; 
    278304    return i_ret; 
     
    280306#define stats_UpdateInteger( a,b,c,d ) __stats_UpdateInteger( VLC_OBJECT(a),b,c,d ) 
    281307static inline int __stats_UpdateInteger( vlc_object_t *p_obj, 
    282                                          const char *psz_name, int i, int *pi_new ) 
     308                                         unsigned int i_counter, int i, 
     309                                         int *pi_new ) 
    283310{ 
    284311    int i_ret; 
     
    286313    vlc_value_t new_val; 
    287314    val.i_int = i; 
    288     i_ret = __stats_Update( p_obj, psz_name, val , &new_val ); 
     315    i_ret = __stats_Update( p_obj, i_counter, val , &new_val ); 
    289316    if( pi_new ) 
    290317        *pi_new = new_val.i_int; 
     
    293320#define stats_UpdateFloat( a,b,c,d ) __stats_UpdateFloat( VLC_OBJECT(a),b,c,d ) 
    294321static inline int __stats_UpdateFloat( vlc_object_t *p_obj, 
    295                                        const char *psz_name, float f, float *pf_new ) 
     322                                       unsigned int i_counter, float f, 
     323                                       float *pf_new ) 
    296324{ 
    297325    vlc_value_t val; 
     
    299327    vlc_value_t new_val; 
    300328    val.f_float = f; 
    301     i_ret =  __stats_Update( p_obj, psz_name, val, &new_val ); 
     329    i_ret =  __stats_Update( p_obj, i_counter, val, &new_val ); 
    302330    if( pf_new ) 
    303331        *pf_new = new_val.f_float; 
     
    369397 ********/ 
    370398#ifdef DEBUG 
    371 #define stats_TimerStart(a,b) __stats_TimerStart( VLC_OBJECT(a), b
     399#define stats_TimerStart(a,b,c) __stats_TimerStart( VLC_OBJECT(a), b,c
    372400#define stats_TimerStop(a,b) __stats_TimerStop( VLC_OBJECT(a), b ) 
    373401#define stats_TimerDump(a,b) __stats_TimerDump( VLC_OBJECT(a), b ) 
     
    379407#define stats_TimersDumpAll(a) {} 
    380408#endif 
    381 VLC_EXPORT( void,__stats_TimerStart, (vlc_object_t*, const char *) ); 
    382 VLC_EXPORT( void,__stats_TimerStop, (vlc_object_t*, const char *) ); 
    383 VLC_EXPORT( void,__stats_TimerDump, (vlc_object_t*, const char *) ); 
     409VLC_EXPORT( void,__stats_TimerStart, (vlc_object_t*, const char *, unsigned int ) ); 
     410VLC_EXPORT( void,__stats_TimerStop, (vlc_object_t*, unsigned int) ); 
     411VLC_EXPORT( void,__stats_TimerDump, (vlc_object_t*, unsigned int) ); 
    384412VLC_EXPORT( void,__stats_TimersDumpAll, (vlc_object_t*) ); 
  • include/vlc_symbols.h

    r26d5b73 r0b44cb9  
    6666httpd_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); 
    6767void httpd_ClientModeStream (httpd_client_t *cl); 
    68 int __stats_Create (vlc_object_t*, const char *, int, int); 
     68int __stats_Create (vlc_object_t*, const char *, unsigned int, int, int); 
    6969void httpd_RedirectDelete (httpd_redirect_t *); 
    7070void __sout_CfgParse (vlc_object_t *, char *psz_prefix, const char **ppsz_options, sout_cfg_t *); 
     
    125125int playlist_Delete (playlist_t *, int); 
    126126void aout_FiltersPlay (aout_instance_t * p_aout, aout_filter_t ** pp_filters, int i_nb_filters, aout_buffer_t ** pp_input_buffer); 
    127 int __stats_Update (vlc_object_t*, const char *, vlc_value_t, vlc_value_t *); 
    128 int __stats_Get (vlc_object_t*, int, const char *, vlc_value_t*); 
     127int __stats_Update (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *); 
     128int __stats_Get (vlc_object_t*, int, int, vlc_value_t*); 
    129129char* httpd_ClientIP (httpd_client_t *cl, char *psz_ip); 
    130130int __intf_UserProgress (vlc_object_t*, const char*, const char*, float); 
     
    140140int vout_ShowTextRelative (vout_thread_t *, int, char *, text_style_t *, int, int, int, mtime_t); 
    141141unsigned int update_iterator_Action (update_iterator_t *, int); 
    142 void __stats_TimerDump (vlc_object_t*, const char *); 
     142void __stats_TimerDump (vlc_object_t*, unsigned int); 
    143143int block_FifoPut (block_fifo_t *, block_t *); 
    144144int playlist_ItemAddParent (playlist_item_t *, int,playlist_item_t *); 
     
    152152char * config_GetUserDir (void); 
    153153httpd_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); 
    154 counter_t* __stats_CounterGet (vlc_object_t*, int, const char *); 
     154counter_t* __stats_CounterGet (vlc_object_t*, int, unsigned int); 
    155155int __config_GetType (vlc_object_t *, const char *); 
    156156void __vlc_thread_ready (vlc_object_t *); 
     
    207207void AddMD5 (struct md5_s *, const uint8_t *, uint32_t); 
    208208void config_Duplicate (module_t *, module_config_t *); 
    209 void __stats_TimerStart (vlc_object_t*, const char *); 
     209void __stats_TimerStart (vlc_object_t*, const char *, int); 
    210210block_t * __block_New (vlc_object_t *, int); 
    211211void xml_Delete (xml_t *); 
     
    426426void __vout_OSDMessage (vlc_object_t *, int, char *, ...); 
    427427void intf_StopThread (intf_thread_t *); 
    428 void __stats_TimerStop (vlc_object_t*, const char *); 
     428void __stats_TimerStop (vlc_object_t*, unsigned int); 
    429429stream_t * __stream_MemoryNew (vlc_object_t *p_obj, uint8_t *p_buffer, int64_t i_size, vlc_bool_t i_preserve_memory); 
    430430void mwait (mtime_t date); 
     
    897897    void (*__intf_UserProgressUpdate_inner) (vlc_object_t*, int, const char*, float); 
    898898    void (*__intf_UserHide_inner) (vlc_object_t *, int); 
    899     int (*__stats_Create_inner) (vlc_object_t*, const char *, int, int); 
    900     int (*__stats_Update_inner) (vlc_object_t*, const char *, vlc_value_t, vlc_value_t *); 
    901     int (*__stats_Get_inner) (vlc_object_t*, int, const char *, vlc_value_t*); 
     899    int (*__stats_Create_inner) (vlc_object_t*, const char *, unsigned int, int, int); 
     900    int (*__stats_Update_inner) (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *); 
     901    int (*__stats_Get_inner) (vlc_object_t*, int, int, vlc_value_t*); 
    902902    void (*stats_ComputeInputStats_inner) (input_thread_t*, input_stats_t*); 
    903903    void (*stats_DumpInputStats_inner) (input_stats_t *); 
    904904    void (*stats_ReinitInputStats_inner) (input_stats_t *); 
    905     counter_t* (*__stats_CounterGet_inner) (vlc_object_t*, int, const char *); 
     905    counter_t* (*__stats_CounterGet_inner) (vlc_object_t*, int, unsigned int); 
    906906    void *__stats_CounterGet_deprecated; 
    907907    input_thread_t * (*__input_CreateThread2_inner) (vlc_object_t *, input_item_t *, char *); 
     
    910910    void (*__var_OptionParse_inner) (vlc_object_t *, const char *); 
    911911    void *__stats_TimerDumpAll_deprecated; 
    912     void (*__stats_TimerDump_inner) (vlc_object_t*, const char *); 
    913     void (*__stats_TimerStart_inner) (vlc_object_t*, const char *); 
     912    void (*__stats_TimerDump_inner) (vlc_object_t*, unsigned int); 
     913    void (*__stats_TimerStart_inner) (vlc_object_t*, const char *, int); 
    914914    void (*__stats_ComputeGlobalStats_inner) (vlc_object_t*,global_stats_t*); 
    915     void (*__stats_TimerStop_inner) (vlc_object_t*, const char *); 
     915    void (*__stats_TimerStop_inner) (vlc_object_t*, unsigned int); 
    916916    void (*__stats_TimersDumpAll_inner) (vlc_object_t*); 
    917917    update_iterator_t * (*update_iterator_New_inner) (update_t *); 
  • modules/stream_out/transcode.c

    r26d5b73 r0b44cb9  
    13291329                                                          &in )) ) 
    13301330    { 
    1331         stats_UpdateInteger( p_stream->p_parent->p_parent, "decoded_audio", 1, NULL ); 
     1331        stats_UpdateInteger( p_stream->p_parent->p_parent, STATS_DECODED_AUDIO, 
     1332                             1, NULL ); 
    13321333        if( p_sys->b_master_sync ) 
    13331334        { 
     
    17321733    { 
    17331734        subpicture_t *p_subpic = 0; 
    1734         stats_UpdateInteger( p_stream->p_parent->p_parent, "decoded_video", 1, NULL ); 
     1735        stats_UpdateInteger( p_stream->p_parent->p_parent, STATS_DECODED_VIDEO, 
     1736                              1, NULL ); 
    17351737 
    17361738        if( p_stream->p_sout->i_out_pace_nocontrol && p_sys->b_hurry_up ) 
  • src/audio_output/dec.c

    r26d5b73 r0b44cb9  
    313313        if( p_input->p_input_thread ) 
    314314        { 
    315             stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1, 
     315            stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1, 
    316316                                 NULL ); 
    317317        } 
     
    369369    { 
    370370        stats_UpdateInteger( p_input->p_input_thread, 
    371                             "played_abuffers", 1, NULL ); 
     371                            STATS_PLAYED_ABUFFERS, 1, NULL ); 
    372372    } 
    373373    vlc_mutex_unlock( &p_aout->mixer_lock ); 
  • src/audio_output/input.c

    r26d5b73 r0b44cb9  
    448448        if( p_input->p_input_thread ) 
    449449        { 
    450             stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1, 
     450            stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1, 
    451451                                 NULL ); 
    452452        } 
     
    461461        if( p_input->p_input_thread ) 
    462462        { 
    463             stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1, 
     463            stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1, 
    464464                                 NULL ); 
    465465        } 
     
    503503        if( p_input->p_input_thread ) 
    504504        { 
    505             stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1, 
     505            stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1, 
    506506                                 NULL ); 
    507507        } 
  • src/input/decoder.c

    r26d5b73 r0b44cb9  
    430430    vlc_object_attach( p_dec, p_input ); 
    431431 
    432     stats_Create( p_dec->p_parent, "decoded_audio", 
     432    stats_Create( p_dec->p_parent, "decoded_audio", STATS_DECODED_AUDIO, 
    433433                  VLC_VAR_INTEGER, STATS_COUNTER ); 
    434     stats_Create( p_dec->p_parent, "decoded_video", 
     434    stats_Create( p_dec->p_parent, "decoded_video", STATS_DECODED_VIDEO, 
    435435                  VLC_VAR_INTEGER, STATS_COUNTER ); 
    436     stats_Create( p_dec->p_parent, "decoded_sub", 
     436    stats_Create( p_dec->p_parent, "decoded_sub", STATS_DECODED_SUB, 
    437437                  VLC_VAR_INTEGER, STATS_COUNTER ); 
    438438    /* Find a suitable decoder/packetizer module */ 
     
    628628                                                       &p_packetized_block )) ) 
    629629                    { 
    630                         stats_UpdateInteger( p_dec->p_parent, "decoded_audio", 1, NULL ); 
     630                        stats_UpdateInteger( p_dec->p_parent, 
     631                                             STATS_DECODED_AUDIO, 1, NULL ); 
    631632                        /* FIXME the best would be to handle the case start_date < preroll < end_date 
    632633                         * but that's not easy with non raw audio stream */ 
     
    652653        else while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, &p_block )) ) 
    653654        { 
    654             stats_UpdateInteger( p_dec->p_parent, "decoded_audio", 1, NULL ); 
     655            stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_AUDIO, 1, NULL ); 
    655656            if( p_dec->p_owner->i_preroll_end > 0 && 
    656657                p_aout_buf->start_date < p_dec->p_owner->i_preroll_end ) 
     
    698699                                                       &p_packetized_block )) ) 
    699700                    { 
    700                         stats_UpdateInteger( p_dec->p_parent, "decoded_video"
     701                        stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_VIDEO
    701702                                                             1, NULL ); 
    702703                        if( p_dec->p_owner->i_preroll_end > 0 && 
     
    720721        else while( (p_pic = p_dec->pf_decode_video( p_dec, &p_block )) ) 
    721722        { 
    722             stats_UpdateInteger( p_dec->p_parent, "decoded_video", 1 , NULL); 
     723            stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_VIDEO, 1 , NULL); 
    723724            if( p_dec->p_owner->i_preroll_end > 0 && 
    724725                p_pic->date < p_dec->p_owner->i_preroll_end ) 
     
    740741        while( (p_spu = p_dec->pf_decode_sub( p_dec, &p_block ) ) ) 
    741742        { 
    742             stats_UpdateInteger( p_dec->p_parent, "decoded_sub", 1 , NULL); 
     743            stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_SUB, 1 , NULL); 
    743744            if( p_dec->p_owner->i_preroll_end > 0 && 
    744745                p_spu->i_start < p_dec->p_owner->i_preroll_end && 
  • src/input/es_out.c

    r26d5b73 r0b44cb9  
    10341034    if( p_input->p_libvlc->b_stats ) 
    10351035    { 
    1036         stats_UpdateInteger( p_input, "demux_read", p_block->i_buffer, 
     1036        stats_UpdateInteger( p_input, STATS_DEMUX_READ, p_block->i_buffer, 
    10371037                             &i_total ); 
    1038         stats_UpdateFloat( p_input , "demux_bitrate", (float)i_total, NULL ); 
     1038        stats_UpdateFloat( p_input , STATS_DEMUX_BITRATE, (float)i_total, NULL ); 
    10391039    } 
    10401040 
  • src/input/input.c

    r8eaff12 r0b44cb9  
    686686        /* Prepare statistics */ 
    687687        counter_t *p_counter; 
    688         stats_Create( p_input, "read_bytes", VLC_VAR_INTEGER, STATS_COUNTER ); 
    689         stats_Create( p_input, "read_packets", VLC_VAR_INTEGER, STATS_COUNTER ); 
    690         stats_Create( p_input, "demux_read", VLC_VAR_INTEGER, STATS_COUNTER ); 
    691         stats_Create( p_input, "input_bitrate", VLC_VAR_FLOAT, 
    692                                STATS_DERIVATIVE ); 
    693         stats_Create( p_input, "demux_bitrate", VLC_VAR_FLOAT, 
    694                                STATS_DERIVATIVE ); 
     688        stats_Create( p_input, "read_bytes", STATS_READ_BYTES, 
     689                      VLC_VAR_INTEGER, STATS_COUNTER ); 
     690        stats_Create( p_input, "read_packets", STATS_READ_PACKETS, 
     691                      VLC_VAR_INTEGER, STATS_COUNTER ); 
     692        stats_Create( p_input, "demux_read", STATS_DEMUX_READ, 
     693                      VLC_VAR_INTEGER, STATS_COUNTER ); 
     694        stats_Create( p_input, "input_bitrate", STATS_INPUT_BITRATE, 
     695                      VLC_VAR_FLOAT, STATS_DERIVATIVE ); 
     696        stats_Create( p_input, "demux_bitrate", STATS_DEMUX_BITRATE, 
     697                      VLC_VAR_FLOAT,  STATS_DERIVATIVE ); 
     698 
    695699        p_counter = stats_CounterGet( p_input, p_input->i_object_id, 
    696                                       "input_bitrate" ); 
     700                                      STATS_INPUT_BITRATE ); 
    697701        if( p_counter ) p_counter->update_interval = 1000000; 
    698702        p_counter = stats_CounterGet( p_input, p_input->i_object_id, 
    699                                       "demux_bitrate" ); 
     703                                      STATS_DEMUX_BITRATE ); 
    700704        if( p_counter ) p_counter->update_interval = 1000000; 
    701705 
    702         stats_Create( p_input, "played_abuffers", VLC_VAR_INTEGER, STATS_COUNTER ); 
    703         stats_Create( p_input, "lost_abuffers", VLC_VAR_INTEGER, STATS_COUNTER ); 
     706        stats_Create( p_input, "played_abuffers", STATS_PLAYED_ABUFFERS, 
     707                      VLC_VAR_INTEGER, STATS_COUNTER ); 
     708        stats_Create( p_input, "lost_abuffers", STATS_LOST_ABUFFERS, 
     709                      VLC_VAR_INTEGER, STATS_COUNTER ); 
    704710 
    705711        /* handle sout */ 
  • src/input/stream.c

    r26d5b73 r0b44cb9  
    15811581    { 
    15821582        i_read = p_access->pf_read( p_access, p_read, i_read ); 
    1583         stats_UpdateInteger( s->p_parent->p_parent , "read_bytes", i_read, 
     1583        stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_BYTES, i_read, 
    15841584                             &i_total ); 
    1585         stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate"
     1585        stats_UpdateFloat( s->p_parent->p_parent , STATS_INPUT_BITRATE
    15861586                           (float)i_total, NULL ); 
    1587         stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1, NULL ); 
     1587        stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_PACKETS, 1, 
     1588                             NULL ); 
    15881589        return i_read; 
    15891590    } 
     
    16141615 
    16151616    /* Update read bytes in input */ 
    1616     stats_UpdateInteger( s->p_parent->p_parent , "read_bytes", i_read, 
     1617    stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_BYTES, i_read, 
    16171618                         &i_total ); 
    1618     stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate"
     1619    stats_UpdateFloat( s->p_parent->p_parent , STATS_INPUT_BITRATE
    16191620                      (float)i_total, NULL ); 
    1620     stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1, NULL ); 
     1621    stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_PACKETS, 1, NULL ); 
    16211622    return i_read; 
    16221623} 
     
    16361637        if( p_block && p_access->p_libvlc->b_stats ) 
    16371638        { 
    1638             stats_UpdateInteger( s->p_parent->p_parent, "read_bytes"
     1639            stats_UpdateInteger( s->p_parent->p_parent, STATS_READ_BYTES
    16391640                                 p_block->i_buffer, &i_total ); 
    1640             stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate"
     1641            stats_UpdateFloat( s->p_parent->p_parent , STATS_INPUT_BITRATE
    16411642                              (float)i_total, NULL ); 
    1642             stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1, NULL ); 
     1643            stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_PACKETS, 1, NULL ); 
    16431644        } 
    16441645        return p_block; 
     
    16711672    if( p_block ) 
    16721673    { 
    1673         stats_UpdateInteger( s->p_parent->p_parent, "read_bytes"
     1674        stats_UpdateInteger( s->p_parent->p_parent, STATS_READ_BYTES
    16741675                             p_block->i_buffer, &i_total ); 
    1675         stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate"
     1676        stats_UpdateFloat( s->p_parent->p_parent , STATS_INPUT_BITRATE
    16761677                          (float)i_total, NULL ); 
    1677         stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1 , NULL); 
     1678        stats_UpdateInteger( s->p_parent->p_parent ,  STATS_READ_PACKETS, 
     1679                             1 , NULL); 
    16781680    } 
    16791681 
  • src/misc/stats.c

    r26d5b73 r0b44cb9  
    3434 *****************************************************************************/ 
    3535static counter_t *GetCounter( stats_handler_t *p_handler, int i_object_id, 
    36                               const char *psz_name ); 
     36                              unsigned int i_counter ); 
    3737static int stats_CounterUpdate( stats_handler_t *p_handler, 
    3838                                counter_t *p_counter, 
     
    5858    { 
    5959        int j; 
    60         hashtable_entry_t p_entry = p_stats->p_counters[i]; 
    61         counter_t * p_counter = p_entry.p_data; 
     60        counter_t *p_counter = p_stats->pp_counters[i]; 
    6261 
    6362        for( j = p_counter->i_samples -1; j >= 0 ; j-- ) 
     
    6867        } 
    6968        free( p_counter->psz_name ); 
    70         free( p_entry.psz_name ); 
    71         REMOVE_ELEM( p_stats->p_counters, p_stats->i_counters, i ); 
     69        REMOVE_ELEM( p_stats->pp_counters, p_stats->i_counters, i ); 
    7270        free( p_counter ); 
    7371    } 
     
    8583 * (keep a time derivative of the value) 
    8684 */ 
    87 int __stats_Create( vlc_object_t *p_this, const char *psz_name, int i_type
    88                     int i_compute_type ) 
     85int __stats_Create( vlc_object_t *p_this, const char *psz_name, unsigned int i_id
     86                    int i_type, int i_compute_type ) 
    8987{ 
    9088    counter_t *p_counter; 
     
    103101 
    104102    p_counter->psz_name = strdup( psz_name ); 
    105     p_counter->i_source_object = p_this->i_object_id; 
     103    p_counter->i_index = ((uint64_t)p_this->i_object_id << 32 ) + i_id; 
    106104    p_counter->i_compute_type = i_compute_type; 
    107105    p_counter->i_type = i_type; 
     
    112110    p_counter->last_update = 0; 
    113111 
    114     vlc_HashInsert( &p_handler->p_counters, &p_handler->i_counters, p_this->i_object_id
    115                     psz_name, p_counter ); 
     112    INSERT_ELEM( p_handler->pp_counters, p_handler->i_counters
     113                 p_handler->i_counters, p_counter ); 
    116114 
    117115    vlc_mutex_unlock( &p_handler->object_lock ); 
     
    126124 * more information on how data is aggregated, \see __stats_Create 
    127125 */ 
    128 int __stats_Update( vlc_object_t *p_this, const char *psz_name
     126int __stats_Update( vlc_object_t *p_this, unsigned int i_counter
    129127                    vlc_value_t val, vlc_value_t *val_new ) 
    130128{ 
     
    143141    vlc_mutex_lock( &p_handler->object_lock ); 
    144142    /* Look for existing element */ 
    145     p_counter = GetCounter( p_handler, p_this->i_object_id, 
    146                             psz_name ); 
     143    p_counter = GetCounter( p_handler, p_this->i_object_id, i_counter ); 
    147144    if( !p_counter ) 
    148145    { 
     
    167164 */ 
    168165int __stats_Get( vlc_object_t *p_this, int i_object_id, 
    169                  const char *psz_name, vlc_value_t *val ) 
     166                 unsigned int i_counter, vlc_value_t *val ) 
    170167{ 
    171168    counter_t *p_counter; 
     
    182179 
    183180    /* Look for existing element */ 
    184     p_counter = GetCounter( p_handler, i_object_id, 
    185                             psz_name ); 
     181    p_counter = GetCounter( p_handler, i_object_id, i_counter ); 
    186182    if( !p_counter ) 
    187183    { 
     
    246242 */ 
    247243counter_t *__stats_CounterGet( vlc_object_t *p_this, int i_object_id, 
    248                                const char *psz_name
     244                               unsigned int i_counter
    249245{ 
    250246    counter_t *p_counter; 
     
    261257 
    262258    /* Look for existing element */ 
    263     p_counter = GetCounter( p_handler, i_object_id, 
    264                             psz_name ); 
     259    p_counter = GetCounter( p_handler, i_object_id, i_counter ); 
    265260    vlc_mutex_unlock( &p_handler->object_lock ); 
    266261    vlc_object_release( p_handler ); 
     
    279274 
    280275    /* Input */ 
    281     stats_GetInteger( p_input, p_input->i_object_id, "read_packets"
     276    stats_GetInteger( p_input, p_input->i_object_id, STATS_READ_PACKETS
    282277                       &p_stats->i_read_packets ); 
    283     stats_GetInteger( p_input, p_input->i_object_id, "read_bytes"
     278    stats_GetInteger( p_input, p_input->i_object_id, STATS_READ_BYTES
    284279                       &p_stats->i_read_bytes ); 
    285     stats_GetFloat( p_input, p_input->i_object_id, "input_bitrate"
     280    stats_GetFloat( p_input, p_input->i_object_id, STATS_INPUT_BITRATE
    286281                       &p_stats->f_input_bitrate ); 
    287282 
    288     stats_GetInteger( p_input, p_input->i_object_id, "demux_read"
     283    stats_GetInteger( p_input, p_input->i_object_id, STATS_DEMUX_READ
    289284                      &p_stats->i_demux_read_bytes ); 
    290     stats_GetFloat( p_input, p_input->i_object_id, "demux_bitrate"
     285    stats_GetFloat( p_input, p_input->i_object_id, STATS_DEMUX_BITRATE
    291286                      &p_stats->f_demux_bitrate ); 
    292287 
    293     stats_GetInteger( p_input, p_input->i_object_id, "decoded_video"
     288    stats_GetInteger( p_input, p_input->i_object_id, STATS_DECODED_VIDEO
    294289                      &p_stats->i_decoded_video ); 
    295     stats_GetInteger( p_input, p_input->i_object_id, "decoded_audio"
     290    stats_GetInteger( p_input, p_input->i_object_id, STATS_DECODED_AUDIO
    296291                      &p_stats->i_decoded_audio ); 
    297292 
    298293    /* Sout */ 
    299     stats_GetInteger( p_input, p_input->i_object_id, "sout_sent_packets"
     294    stats_GetInteger( p_input, p_input->i_object_id, STATS_SOUT_SENT_PACKETS
    300295                      &p_stats->i_sent_packets ); 
    301     stats_GetInteger( p_input, p_input->i_object_id, "sout_sent_bytes"
     296    stats_GetInteger( p_input, p_input->i_object_id, STATS_SOUT_SENT_BYTES
    302297                      &p_stats->i_sent_bytes ); 
    303     stats_GetFloat  ( p_input, p_input->i_object_id, "sout_send_bitrate"
     298    stats_GetFloat  ( p_input, p_input->i_object_id, STATS_SOUT_SEND_BITRATE
    304299                      &p_stats->f_send_bitrate ); 
    305300 
    306301    /* Aout - We store in p_input because aout is shared */ 
    307     stats_GetInteger( p_input, p_input->i_object_id, "played_abuffers"
     302    stats_GetInteger( p_input, p_input->i_object_id, STATS_PLAYED_ABUFFERS
    308303                      &p_stats->i_played_abuffers ); 
    309     stats_GetInteger( p_input, p_input->i_object_id, "lost_abuffers"
     304    stats_GetInteger( p_input, p_input->i_object_id, STATS_LOST_ABUFFERS
    310305                      &p_stats->i_lost_abuffers ); 
    311306 
     
    320315            int i_displayed = 0, i_lost = 0; 
    321316            p_obj = (vlc_object_t *)p_list->p_values[i_index].p_object; 
    322             stats_GetInteger( p_obj, p_obj->i_object_id, "displayed_pictures", 
     317            stats_GetInteger( p_obj, p_obj->i_object_id, 
     318                              STATS_DISPLAYED_PICTURES, 
    323319                              &i_displayed ); 
    324             stats_GetInteger( p_obj, p_obj->i_object_id, "lost_pictures"
     320            stats_GetInteger( p_obj, p_obj->i_object_id, STATS_LOST_PICTURES
    325321                              &i_lost ); 
    326322            p_stats->i_displayed_pictures += i_displayed; 
     
    352348    /* f_bitrate is in bytes / microsecond 
    353349     * *1000 => bytes / millisecond => kbytes / seconds */ 
    354     fprintf( stderr, "Input : %i (%i bytes) - %f kB/s - Demux : %i (%i bytes) - %f kB/s\n" 
    355                      " - Vout : %i/%i - Aout : %i/%i - Vout : %f\n", 
     350    fprintf( stderr, "Input : %i (%i bytes) - %f kB/s - " 
     351                     "Demux : %i (%i bytes) - %f kB/s\n" 
     352                     " - Vout : %i/%i - Aout : %i/%i - Sout : %f\n", 
    356353                    p_stats->i_read_packets, p_stats->i_read_bytes, 
    357354                    p_stats->f_input_bitrate * 1000, 
     
    379376            float f_in = 0, f_out = 0, f_demux = 0; 
    380377            p_obj = (vlc_object_t *)p_list->p_values[i_index].p_object; 
    381             stats_GetFloat( p_obj, p_obj->i_object_id, "input_bitrate"
     378            stats_GetFloat( p_obj, p_obj->i_object_id, STATS_INPUT_BITRATE
    382379                            &f_in ); 
    383             stats_GetFloat( p_obj, p_obj->i_object_id, "sout_send_bitrate"
     380            stats_GetFloat( p_obj, p_obj->i_object_id, STATS_SOUT_SEND_BITRATE
    384381                            &f_out ); 
    385             stats_GetFloat( p_obj, p_obj->i_object_id, "demux_bitrate"
     382            stats_GetFloat( p_obj, p_obj->i_object_id, STATS_DEMUX_BITRATE
    386383                            &f_demux ); 
    387384            f_total_in += f_in; f_total_out += f_out;f_total_demux += f_demux; 
     
    402399 
    403400 
    404 void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name ) 
     401void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name, 
     402                         unsigned int i_id ) 
    405403{ 
    406404    counter_t *p_counter = stats_CounterGet( p_obj, 
    407                                              p_obj->p_vlc->i_object_id, 
    408                                              psz_name ); 
     405                                             p_obj->p_vlc->i_object_id, i_id ); 
    409406    if( !p_counter ) 
    410407    { 
    411408        counter_sample_t *p_sample; 
    412         stats_Create( p_obj->p_vlc, psz_name, VLC_VAR_TIME, STATS_TIMER ); 
     409        stats_Create( p_obj->p_vlc, psz_name, i_id, VLC_VAR_TIME, STATS_TIMER ); 
    413410        p_counter = stats_CounterGet( p_obj,  p_obj->p_vlc->i_object_id, 
    414                                       psz_name ); 
     411                                      i_id ); 
    415412        if( !p_counter ) return; 
    416413        /* 1st sample : if started: start_date, else last_time, b_started */ 
     
    434431} 
    435432 
    436 void __stats_TimerStop( vlc_object_t *p_obj, const char *psz_name
     433void __stats_TimerStop( vlc_object_t *p_obj, unsigned int i_id
    437434{ 
    438435    counter_t *p_counter = stats_CounterGet( p_obj, 
    439                                               p_obj->p_vlc->i_object_id, 
    440                                              psz_name ); 
     436                                             p_obj->p_vlc->i_object_id, 
     437                                             i_id ); 
    441438    if( !p_counter || p_counter->i_samples != 2 ) 
    442439    { 
    443         msg_Err( p_obj, "timer %s does not exist", psz_name ); 
     440        msg_Err( p_obj, "timer does not exist" ); 
    444441        return; 
    445442    } 
     
    450447} 
    451448 
    452 void __stats_TimerDump( vlc_object_t *p_obj, const char *psz_name
     449void __stats_TimerDump( vlc_object_t *p_obj, unsigned int i_id
    453450{ 
    454451    counter_t *p_counter = stats_CounterGet( p_obj, 
    455452                                             p_obj->p_vlc->i_object_id, 
    456                                              psz_name ); 
     453                                             i_id ); 
    457454    TimerDump( p_obj, p_counter, VLC_TRUE ); 
    458455} 
     
    468465    for ( i = 0 ; i< p_handler->i_counters; i++ ) 
    469466    { 
    470         counter_t * p_counter = (counter_t *)(p_handler->p_counters[i].p_data)
     467        counter_t * p_counter = p_handler->pp_counters[i]
    471468        if( p_counter->i_compute_type == STATS_TIMER ) 
    472469        { 
     
    618615 
    619616static counter_t *GetCounter( stats_handler_t *p_handler, int i_object_id, 
    620                               const char *psz_name
     617                              unsigned int i_counter
    621618{ 
    622619    int i; 
    623     return (counter_t *)vlc_HashRetrieve( p_handler->p_counters, p_handler->i_counters, 
    624                                           i_object_id, psz_name ); 
     620    uint64_t i_index = ((uint64_t) i_object_id << 32 ) + i_counter; 
     621    for (i = 0 ; i < p_handler->i_counters ; i++ ) 
     622    { 
     623         if( i_index == p_handler->pp_counters[i]->i_index ) 
     624             return p_handler->pp_counters[i]; 
     625    } 
     626    return NULL; 
    625627} 
    626628 
     
    662664    } 
    663665    p_handler->i_counters = 0; 
    664     p_handler->p_counters = (hashtable_entry_t *) malloc( 4 * sizeof( variable_t ) )
     666    p_handler->pp_counters = NULL
    665667 
    666668    /// \bug is it p_vlc or p_libvlc ? 
  • src/network/httpd.c

    r26d5b73 r0b44cb9  
    20562056    tls_session_t *p_tls = NULL; 
    20572057 
    2058     stats_Create( host, "client_connections", VLC_VAR_INTEGER, STATS_COUNTER ); 
    2059     stats_Create( host, "active_connections", VLC_VAR_INTEGER, STATS_COUNTER ); 
     2058    stats_Create( host, "client_connections", STATS_CLIENT_CONNECTIONS, 
     2059                  VLC_VAR_INTEGER, STATS_COUNTER ); 
     2060    stats_Create( host, "active_connections", STATS_ACTIVE_CONNECTIONS, 
     2061                  VLC_VAR_INTEGER, STATS_COUNTER ); 
    20602062 
    20612063    while( !host->b_die ) 
     
    21072109            { 
    21082110                httpd_ClientClean( cl ); 
    2109                 stats_UpdateInteger( host, "active_connections", -1, NULL ); 
     2111                stats_UpdateInteger( host, STATS_ACTIVE_CONNECTIONS, -1, NULL ); 
    21102112                TAB_REMOVE( host->i_client, host->client, cl ); 
    21112113                free( cl ); 
     
    25612563                    { 
    25622564                        httpd_client_t *cl; 
    2563                         stats_UpdateInteger( host, "client_connections", 1
    2564                                              NULL ); 
    2565                         stats_UpdateInteger( host, "active_connections", 1, 
     2565                        stats_UpdateInteger( host, STATS_CLIENT_CONNECTIONS
     2566                                             1, NULL ); 
     2567                        stats_UpdateInteger( host, STATS_ACTIVE_CONNECTIONS, 1, 
    25662568                                             NULL ); 
    25672569                        cl = httpd_ClientNew( fd, &sock, i_sock_size, p_tls ); 
  • src/playlist/playlist.c

    rb41bfdb r0b44cb9  
    599599        if( p_playlist->p_interaction ) 
    600600        { 
    601             stats_TimerStart( p_playlist, "Interaction thread" ); 
     601            stats_TimerStart( p_playlist, "Interaction thread", 
     602                              STATS_TIMER_INTERACTION ); 
    602603            intf_InteractionManage( p_playlist ); 
    603             stats_TimerStop( p_playlist, "Interaction thread" ); 
     604            stats_TimerStop( p_playlist, STATS_TIMER_INTERACTION ); 
    604605        } 
    605606 
     
    713714            /* Start another input. 
    714715             * Get the next item to play */ 
    715             stats_TimerStart( p_playlist, "Playlist walk" ); 
     716