Changeset baacaea316cff470f3fe11e52a833ef4a51afe74
- Timestamp:
- 15/06/06 23:22:35 (2 years ago)
- git-parent:
- Files:
-
- include/main.h (modified) (1 diff)
- include/vlc_httpd.h (modified) (1 diff)
- include/vlc_input.h (modified) (1 diff)
- include/vlc_messages.h (modified) (6 diffs)
- include/vlc_symbols.h (modified) (9 diffs)
- src/audio_output/dec.c (modified) (2 diffs)
- src/audio_output/input.c (modified) (3 diffs)
- src/input/decoder.c (modified) (6 diffs)
- src/input/es_out.c (modified) (1 diff)
- src/input/input.c (modified) (5 diffs)
- src/input/stream.c (modified) (6 diffs)
- src/libvlc.c (modified) (3 diffs)
- src/misc/objects.c (modified) (1 diff)
- src/misc/stats.c (modified) (14 diffs)
- src/network/httpd.c (modified) (3 diffs)
- src/playlist/control.c (modified) (1 diff)
- src/playlist/thread.c (modified) (1 diff)
- src/stream_output/stream_output.c (modified) (3 diffs)
- src/video_output/video_output.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/main.h
r86b94ec rbaacaea 57 57 /* Do stats ? - We keep this boolean to avoid unneeded lookups */ 58 58 vlc_bool_t b_stats; 59 stats_handler_t *p_stats; 59 vlc_mutex_t timer_lock; 60 int i_timers; 61 counter_t **pp_timers; 60 62 61 63 /* Arch-specific variables */ include/vlc_httpd.h
re611fda rbaacaea 77 77 int i_port; 78 78 int *fd; 79 80 /* Statistics */ 81 counter_t *p_active_counter; 82 counter_t *p_total_counter; 79 83 80 84 vlc_mutex_t lock; include/vlc_input.h
rc9c85be rbaacaea 422 422 input_source_t **slave; 423 423 424 /* Stats counters */ 425 struct { 426 counter_t *p_read_packets; 427 counter_t *p_read_bytes; 428 counter_t *p_input_bitrate; 429 counter_t *p_demux_read; 430 counter_t *p_demux_bitrate; 431 counter_t *p_decoded_audio; 432 counter_t *p_decoded_video; 433 counter_t *p_decoded_sub; 434 counter_t *p_sout_sent_packets; 435 counter_t *p_sout_sent_bytes; 436 counter_t *p_sout_send_bitrate; 437 counter_t *p_played_abuffers; 438 counter_t *p_lost_abuffers; 439 counter_t *p_displayed_pictures; 440 counter_t *p_lost_pictures; 441 vlc_mutex_t counters_lock; 442 } counters; 443 424 444 /* Buffer of pending actions */ 425 445 vlc_mutex_t lock_control; include/vlc_messages.h
r8e7484b rbaacaea 229 229 struct counter_t 230 230 { 231 /* The list is *NOT* sorted at the moment, it could be ... */ 232 uint64_t i_index; 231 unsigned int i_id; 233 232 char * psz_name; 234 233 int i_type; … … 268 267 }; 269 268 270 struct stats_handler_t 271 { 272 VLC_COMMON_MEMBERS 273 274 int i_counters; 275 counter_t **pp_counters; 276 }; 277 278 VLC_EXPORT( void, stats_HandlerDestroy, (stats_handler_t*) ); 279 280 #define stats_Update(a,b,c,d) __stats_Update( VLC_OBJECT( a ), b, c, d ) 281 VLC_EXPORT( int, __stats_Update, (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *) ); 282 #define stats_Create(a,b,c,d,e) __stats_Create( VLC_OBJECT(a), b, c, d,e ) 283 VLC_EXPORT( int, __stats_Create, (vlc_object_t*, const char *, unsigned int, int, int) ); 284 #define stats_Get(a,b,c,d) __stats_Get( VLC_OBJECT(a), b, c, d ) 285 VLC_EXPORT( int, __stats_Get, (vlc_object_t*, int, unsigned int, vlc_value_t*) ); 286 #define stats_CounterGet(a,b,c) __stats_CounterGet( VLC_OBJECT(a), b, c ) 287 VLC_EXPORT( counter_t*, __stats_CounterGet, (vlc_object_t*, int, unsigned int ) ); 288 289 #define stats_GetInteger(a,b,c,d) __stats_GetInteger( VLC_OBJECT(a), b, c, d ) 290 static inline int __stats_GetInteger( vlc_object_t *p_obj, int i_id, 291 unsigned int i_counter, int *value ) 269 #define stats_Update(a,b,c) __stats_Update( VLC_OBJECT(a), b, c ) 270 VLC_EXPORT( int, __stats_Update, (vlc_object_t*, counter_t *, vlc_value_t, vlc_value_t *) ); 271 #define stats_CounterCreate(a,b,c) __stats_CounterCreate( VLC_OBJECT(a), b, c ) 272 VLC_EXPORT( counter_t *, __stats_CounterCreate, (vlc_object_t*, int, int) ); 273 #define stats_Get(a,b,c) __stats_Get( VLC_OBJECT(a), b, c) 274 VLC_EXPORT( int, __stats_Get, (vlc_object_t*, counter_t *, vlc_value_t*) ); 275 276 VLC_EXPORT (void, stats_CounterClean, (counter_t * ) ); 277 278 #define stats_GetInteger(a,b,c) __stats_GetInteger( VLC_OBJECT(a), b, c ) 279 static inline int __stats_GetInteger( vlc_object_t *p_obj, counter_t *p_counter, 280 int *value ) 292 281 { 293 282 int i_ret; 294 283 vlc_value_t val; val.i_int = 0; 295 i_ret = __stats_Get( p_obj, i_id, i_counter, &val );284 i_ret = __stats_Get( p_obj, p_counter, &val ); 296 285 *value = val.i_int; 297 286 return i_ret; 298 287 } 299 288 300 #define stats_GetFloat(a,b,c ,d) __stats_GetFloat( VLC_OBJECT(a), b, c, d)301 static inline int __stats_GetFloat( vlc_object_t *p_obj, int i_id,302 unsigned int i_counter,float *value )303 { 304 int i_ret;289 #define stats_GetFloat(a,b,c) __stats_GetFloat( VLC_OBJECT(a), b, c ) 290 static inline int __stats_GetFloat( vlc_object_t *p_obj, counter_t *p_counter, 291 float *value ) 292 { 293 int i_ret; 305 294 vlc_value_t val; val.f_float = 0.0; 306 i_ret = __stats_Get( p_obj, i_id, i_counter, &val );295 i_ret = __stats_Get( p_obj, p_counter, &val ); 307 296 *value = val.f_float; 308 297 return i_ret; 309 298 } 310 299 #define stats_UpdateInteger(a,b,c,d) __stats_UpdateInteger( VLC_OBJECT(a),b,c,d ) 311 static inline int __stats_UpdateInteger( vlc_object_t *p_obj, 312 unsigned int i_counter, int i, 313 int *pi_new ) 300 static inline int __stats_UpdateInteger( vlc_object_t *p_obj,counter_t *p_co, 301 int i, int *pi_new ) 314 302 { 315 303 int i_ret; … … 317 305 vlc_value_t new_val; new_val.i_int = 0; 318 306 val.i_int = i; 319 i_ret = __stats_Update( p_obj, i_counter, val, &new_val );307 i_ret = __stats_Update( p_obj, p_co, val, &new_val ); 320 308 if( pi_new ) 321 309 *pi_new = new_val.i_int; … … 323 311 } 324 312 #define stats_UpdateFloat(a,b,c,d) __stats_UpdateFloat( VLC_OBJECT(a),b,c,d ) 325 static inline int __stats_UpdateFloat( vlc_object_t *p_obj, 326 unsigned int i_counter, float f, 327 float *pf_new ) 313 static inline int __stats_UpdateFloat( vlc_object_t *p_obj, counter_t *p_co, 314 float f, float *pf_new ) 328 315 { 329 316 vlc_value_t val; … … 331 318 vlc_value_t new_val;new_val.f_float = 0.0; 332 319 val.f_float = f; 333 i_ret = __stats_Update( p_obj, i_counter, val, &new_val );320 i_ret = __stats_Update( p_obj, p_co, val, &new_val ); 334 321 if( pf_new ) 335 322 *pf_new = new_val.f_float; … … 414 401 VLC_EXPORT( void,__stats_TimerDump, (vlc_object_t*, unsigned int) ); 415 402 VLC_EXPORT( void,__stats_TimersDumpAll, (vlc_object_t*) ); 403 #define stats_TimersClean(a) __stats_TimersClean( VLC_OBJECT(a) ) 404 VLC_EXPORT( void, __stats_TimersClean, (vlc_object_t * ) ); include/vlc_symbols.h
rc9c85be rbaacaea 439 439 void (*__intf_UserProgressUpdate_inner) (vlc_object_t*, int, const char*, float); 440 440 void (*__intf_UserHide_inner) (vlc_object_t *, int); 441 int (*__stats_Create_inner) (vlc_object_t*, const char *, unsigned int, int, int);442 int (*__stats_Update_inner) (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *);443 int (*__stats_Get_inner) (vlc_object_t*, int, unsigned int, vlc_value_t*);441 void *__stats_Create_deprecated; 442 int (*__stats_Update_inner) (vlc_object_t*, counter_t *, vlc_value_t, vlc_value_t *); 443 int (*__stats_Get_inner) (vlc_object_t*, counter_t *, vlc_value_t*); 444 444 void (*stats_ComputeInputStats_inner) (input_thread_t*, input_stats_t*); 445 445 void (*stats_DumpInputStats_inner) (input_stats_t *); 446 446 void (*stats_ReinitInputStats_inner) (input_stats_t *); 447 counter_t* (*__stats_CounterGet_inner) (vlc_object_t*, int, unsigned int);448 447 void *__stats_CounterGet_deprecated; 449 448 input_thread_t * (*__input_CreateThread2_inner) (vlc_object_t *, input_item_t *, char *); 450 void (*stats_HandlerDestroy_inner) (stats_handler_t*);449 void *stats_HandlerDestroy_deprecated; 451 450 vlc_t * (*vlc_current_object_inner) (int); 452 451 void (*__var_OptionParse_inner) (vlc_object_t *, const char *); … … 515 514 void (*playlist_NodesCreateForSD_inner) (playlist_t *, char *, playlist_item_t **, playlist_item_t **); 516 515 vlc_bool_t (*input_AddSubtitles_inner) (input_thread_t *, char *, vlc_bool_t); 516 counter_t * (*__stats_CounterCreate_inner) (vlc_object_t*, int, int); 517 void *stats_TimerClean_deprecated; 518 void *stats_TimersClean_deprecated; 519 void (*__stats_TimersClean_inner) (vlc_object_t *); 517 520 }; 518 521 # if defined (__PLUGIN__) … … 910 913 # define __intf_UserProgressUpdate (p_symbols)->__intf_UserProgressUpdate_inner 911 914 # define __intf_UserHide (p_symbols)->__intf_UserHide_inner 912 # define __stats_Create (p_symbols)->__stats_Create_inner913 915 # define __stats_Update (p_symbols)->__stats_Update_inner 914 916 # define __stats_Get (p_symbols)->__stats_Get_inner … … 916 918 # define stats_DumpInputStats (p_symbols)->stats_DumpInputStats_inner 917 919 # define stats_ReinitInputStats (p_symbols)->stats_ReinitInputStats_inner 918 # define __stats_CounterGet (p_symbols)->__stats_CounterGet_inner919 920 # define __input_CreateThread2 (p_symbols)->__input_CreateThread2_inner 920 # define stats_HandlerDestroy (p_symbols)->stats_HandlerDestroy_inner921 921 # define vlc_current_object (p_symbols)->vlc_current_object_inner 922 922 # define __var_OptionParse (p_symbols)->__var_OptionParse_inner … … 983 983 # define playlist_NodesCreateForSD (p_symbols)->playlist_NodesCreateForSD_inner 984 984 # define input_AddSubtitles (p_symbols)->input_AddSubtitles_inner 985 # define __stats_CounterCreate (p_symbols)->__stats_CounterCreate_inner 986 # define __stats_TimersClean (p_symbols)->__stats_TimersClean_inner 985 987 # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) 986 988 /****************************************************************** … … 1381 1383 ((p_symbols)->__intf_UserProgressUpdate_inner) = __intf_UserProgressUpdate; \ 1382 1384 ((p_symbols)->__intf_UserHide_inner) = __intf_UserHide; \ 1383 ((p_symbols)->__stats_Create_inner) = __stats_Create; \1384 1385 ((p_symbols)->__stats_Update_inner) = __stats_Update; \ 1385 1386 ((p_symbols)->__stats_Get_inner) = __stats_Get; \ … … 1387 1388 ((p_symbols)->stats_DumpInputStats_inner) = stats_DumpInputStats; \ 1388 1389 ((p_symbols)->stats_ReinitInputStats_inner) = stats_ReinitInputStats; \ 1389 ((p_symbols)->__stats_CounterGet_inner) = __stats_CounterGet; \1390 1390 ((p_symbols)->__input_CreateThread2_inner) = __input_CreateThread2; \ 1391 ((p_symbols)->stats_HandlerDestroy_inner) = stats_HandlerDestroy; \1392 1391 ((p_symbols)->vlc_current_object_inner) = vlc_current_object; \ 1393 1392 ((p_symbols)->__var_OptionParse_inner) = __var_OptionParse; \ … … 1454 1453 ((p_symbols)->playlist_NodesCreateForSD_inner) = playlist_NodesCreateForSD; \ 1455 1454 ((p_symbols)->input_AddSubtitles_inner) = input_AddSubtitles; \ 1455 ((p_symbols)->__stats_CounterCreate_inner) = __stats_CounterCreate; \ 1456 ((p_symbols)->__stats_TimersClean_inner) = __stats_TimersClean; \ 1456 1457 (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ 1457 1458 (p_symbols)->__playlist_ItemCopy_deprecated = NULL; \ … … 1480 1481 (p_symbols)->playlist_Move_deprecated = NULL; \ 1481 1482 (p_symbols)->playlist_NodeRemoveParent_deprecated = NULL; \ 1483 (p_symbols)->__stats_Create_deprecated = NULL; \ 1482 1484 (p_symbols)->__stats_CounterGet_deprecated = NULL; \ 1485 (p_symbols)->stats_HandlerDestroy_deprecated = NULL; \ 1483 1486 (p_symbols)->__stats_TimerDumpAll_deprecated = NULL; \ 1484 1487 (p_symbols)->playlist_ItemNewFromInput_deprecated = NULL; \ 1488 (p_symbols)->stats_TimerClean_deprecated = NULL; \ 1489 (p_symbols)->stats_TimersClean_deprecated = NULL; \ 1485 1490 1486 1491 # endif /* __PLUGIN__ */ src/audio_output/dec.c
r0b44cb9 rbaacaea 313 313 if( p_input->p_input_thread ) 314 314 { 315 stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1, 316 NULL ); 315 vlc_mutex_lock( &p_input->p_input_thread->counters.counters_lock); 316 stats_UpdateInteger( p_aout, 317 p_input->p_input_thread->counters.p_lost_abuffers, 318 1, NULL ); 319 vlc_mutex_unlock( &p_input->p_input_thread->counters.counters_lock); 317 320 } 318 321 aout_BufferFree( p_buffer ); … … 368 371 if( p_input->p_input_thread ) 369 372 { 370 stats_UpdateInteger( p_input->p_input_thread, 371 STATS_PLAYED_ABUFFERS, 1, NULL ); 373 vlc_mutex_lock( &p_input->p_input_thread->counters.counters_lock); 374 stats_UpdateInteger( p_aout, 375 p_input->p_input_thread->counters.p_lost_abuffers, 376 1, NULL ); 377 vlc_mutex_unlock( &p_input->p_input_thread->counters.counters_lock); 372 378 } 373 379 vlc_mutex_unlock( &p_aout->mixer_lock ); src/audio_output/input.c
r470b47f rbaacaea 450 450 if( p_input->p_input_thread ) 451 451 { 452 stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1, 453 NULL ); 452 vlc_mutex_lock( &p_input->p_input_thread->counters.counters_lock); 453 stats_UpdateInteger( p_aout, p_input->p_input_thread->counters.p_lost_abuffers, 1, NULL ); 454 vlc_mutex_unlock( &p_input->p_input_thread->counters.counters_lock); 454 455 } 455 456 } … … 463 464 if( p_input->p_input_thread ) 464 465 { 465 stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 466 1, NULL ); 466 vlc_mutex_lock( &p_input->p_input_thread->counters.counters_lock); 467 stats_UpdateInteger( p_aout, p_input->p_input_thread->counters.p_lost_abuffers, 1, NULL ); 468 vlc_mutex_unlock( &p_input->p_input_thread->counters.counters_lock); 467 469 } 468 470 aout_BufferFree( p_buffer ); … … 505 507 if( p_input->p_input_thread ) 506 508 { 507 stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 508 1, NULL ); 509 vlc_mutex_lock( &p_input->p_input_thread->counters.counters_lock); 510 stats_UpdateInteger( p_aout, p_input->p_input_thread->counters.p_lost_abuffers, 1, NULL ); 511 vlc_mutex_unlock( &p_input->p_input_thread->counters.counters_lock); 509 512 } 510 513 return 0; src/input/decoder.c
r2ef372c rbaacaea 430 430 vlc_object_attach( p_dec, p_input ); 431 431 432 stats_Create( p_dec->p_parent, "decoded_audio", STATS_DECODED_AUDIO,433 VLC_VAR_INTEGER, STATS_COUNTER );434 stats_Create( p_dec->p_parent, "decoded_video", STATS_DECODED_VIDEO,435 VLC_VAR_INTEGER, STATS_COUNTER );436 stats_Create( p_dec->p_parent, "decoded_sub", STATS_DECODED_SUB,437 VLC_VAR_INTEGER, STATS_COUNTER );438 432 /* Find a suitable decoder/packetizer module */ 439 433 if( i_object_type == VLC_OBJECT_DECODER ) … … 628 622 &p_packetized_block )) ) 629 623 { 630 stats_UpdateInteger( p_dec->p_parent, 631 STATS_DECODED_AUDIO, 1, NULL ); 632 /* FIXME the best would be to handle the case start_date < preroll < end_date 624 input_thread_t *p_i =(input_thread_t*)(p_dec->p_parent); 625 vlc_mutex_lock( &p_i->counters.counters_lock ); 626 stats_UpdateInteger( p_dec, 627 p_i->counters.p_decoded_audio, 1, NULL ); 628 vlc_mutex_unlock( &p_i->counters.counters_lock ); 629 630 /* FIXME the best would be to handle the case 631 * start_date < preroll < end_date 633 632 * but that's not easy with non raw audio stream */ 634 633 if( p_dec->p_owner->i_preroll_end > 0 && … … 653 652 else while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, &p_block )) ) 654 653 { 655 stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_AUDIO, 1, NULL ); 654 input_thread_t *p_i = (input_thread_t*)(p_dec->p_parent); 655 vlc_mutex_lock( &p_i->counters.counters_lock ); 656 stats_UpdateInteger( p_dec, 657 p_i->counters.p_decoded_audio, 1, NULL ); 658 vlc_mutex_unlock( &p_i->counters.counters_lock ); 659 656 660 if( p_dec->p_owner->i_preroll_end > 0 && 657 661 p_aout_buf->start_date < p_dec->p_owner->i_preroll_end ) … … 699 703 &p_packetized_block )) ) 700 704 { 701 stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_VIDEO, 702 1, NULL ); 705 input_thread_t *p_i =(input_thread_t*)(p_dec->p_parent); 706 vlc_mutex_lock( &p_i->counters.counters_lock ); 707 stats_UpdateInteger( p_dec, 708 p_i->counters.p_decoded_video, 1, NULL ); 709 vlc_mutex_unlock( &p_i->counters.counters_lock ); 710 703 711 if( p_dec->p_owner->i_preroll_end > 0 && 704 712 p_pic->date < p_dec->p_owner->i_preroll_end ) … … 721 729 else while( (p_pic = p_dec->pf_decode_video( p_dec, &p_block )) ) 722 730 { 723 stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_VIDEO, 1 , NULL); 731 input_thread_t *p_i = (input_thread_t*)(p_dec->p_parent); 732 vlc_mutex_lock( &p_i->counters.counters_lock ); 733 stats_UpdateInteger( p_dec, 734 p_i->counters.p_decoded_video, 1, NULL ); 735 vlc_mutex_unlock( &p_i->counters.counters_lock ); 736 724 737 if( p_dec->p_owner->i_preroll_end > 0 && 725 738 p_pic->date < p_dec->p_owner->i_preroll_end ) … … 741 754 while( (p_spu = p_dec->pf_decode_sub( p_dec, &p_block ) ) ) 742 755 { 743 stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_SUB, 1 , NULL); 756 input_thread_t *p_i = (input_thread_t*)(p_dec->p_parent); 757 vlc_mutex_lock( &p_i->counters.counters_lock ); 758 stats_UpdateInteger( p_dec, 759 p_i->counters.p_decoded_sub, 1, NULL ); 760 vlc_mutex_unlock( &p_i->counters.counters_lock ); 761 744 762 if( p_dec->p_owner->i_preroll_end > 0 && 745 763 p_spu->i_start < p_dec->p_owner->i_preroll_end && src/input/es_out.c
red0b72e rbaacaea 1026 1026 if( p_input->p_libvlc->b_stats ) 1027 1027 { 1028 stats_UpdateInteger( p_input, STATS_DEMUX_READ, p_block->i_buffer, 1029 &i_total ); 1030 stats_UpdateFloat( p_input , STATS_DEMUX_BITRATE, (float)i_total, NULL ); 1028 vlc_mutex_lock( &p_input->counters.counters_lock ); 1029 stats_UpdateInteger( p_input, p_input->counters.p_demux_read, 1030 p_block->i_buffer, &i_total ); 1031 stats_UpdateFloat( p_input , p_input->counters.p_demux_bitrate, 1032 (float)i_total, NULL ); 1033 vlc_mutex_unlock( &p_input->counters.counters_lock ); 1031 1034 } 1032 1035 src/input/input.c
r188a9ba rbaacaea 680 680 { 681 681 /* Prepare statistics */ 682 counter_t *p_counter; 683 stats_Create( p_input, "read_bytes", STATS_READ_BYTES, 684 VLC_VAR_INTEGER, STATS_COUNTER ); 685 stats_Create( p_input, "read_packets", STATS_READ_PACKETS, 686 VLC_VAR_INTEGER, STATS_COUNTER ); 687 stats_Create( p_input, "demux_read", STATS_DEMUX_READ, 688 VLC_VAR_INTEGER, STATS_COUNTER ); 689 stats_Create( p_input, "input_bitrate", STATS_INPUT_BITRATE, 690 VLC_VAR_FLOAT, STATS_DERIVATIVE ); 691 stats_Create( p_input, "demux_bitrate", STATS_DEMUX_BITRATE, 692 VLC_VAR_FLOAT, STATS_DERIVATIVE ); 693 694 p_counter = stats_CounterGet( p_input, p_input->i_object_id, 695 STATS_INPUT_BITRATE ); 696 if( p_counter ) p_counter->update_interval = 1000000; 697 p_counter = stats_CounterGet( p_input, p_input->i_object_id, 698 STATS_DEMUX_BITRATE ); 699 if( p_counter ) p_counter->update_interval = 1000000; 700 701 stats_Create( p_input, "played_abuffers", STATS_PLAYED_ABUFFERS, 702 VLC_VAR_INTEGER, STATS_COUNTER ); 703 stats_Create( p_input, "lost_abuffers", STATS_LOST_ABUFFERS, 704 VLC_VAR_INTEGER, STATS_COUNTER ); 682 #define INIT_COUNTER( p, type, compute ) p_input->counters.p_##p = \ 683 stats_CounterCreate( p_input, VLC_VAR_##type, STATS_##compute); 684 685 INIT_COUNTER( read_bytes, INTEGER, COUNTER ); 686 INIT_COUNTER( read_packets, INTEGER, COUNTER ); 687 INIT_COUNTER( demux_read, INTEGER, COUNTER ); 688 INIT_COUNTER( input_bitrate, FLOAT, DERIVATIVE ); 689 INIT_COUNTER( demux_bitrate, FLOAT, DERIVATIVE ); 690 INIT_COUNTER( played_abuffers, INTEGER, COUNTER ); 691 INIT_COUNTER( lost_abuffers, INTEGER, COUNTER ); 692 INIT_COUNTER( displayed_pictures, INTEGER, COUNTER ); 693 INIT_COUNTER( lost_pictures, INTEGER, COUNTER ); 694 INIT_COUNTER( decoded_audio, INTEGER, COUNTER ); 695 INIT_COUNTER( decoded_video, INTEGER, COUNTER ); 696 INIT_COUNTER( decoded_sub, INTEGER, COUNTER ); 697 p_input->counters.p_sout_send_bitrate = NULL; 698 p_input->counters.p_sout_sent_packets = NULL; 699 p_input->counters.p_sout_sent_bytes = NULL; 700 p_input->counters.p_demux_bitrate->update_interval = 1000000; 701 p_input->counters.p_input_bitrate->update_interval = 1000000; 702 vlc_mutex_init( p_input, &p_input->counters.counters_lock ); 705 703 706 704 /* handle sout */ … … 716 714 return VLC_EGENERIC; 717 715 } 716 INIT_COUNTER( sout_sent_packets, INTEGER, COUNTER ); 717 INIT_COUNTER (sout_sent_bytes, INTEGER, COUNTER ); 718 INIT_COUNTER( sout_send_bitrate, FLOAT, DERIVATIVE ); 719 p_input->counters.p_sout_send_bitrate->update_interval = 1000000; 718 720 } 719 721 free( psz ); … … 1106 1108 input_EsOutDelete( p_input->p_es_out ); 1107 1109 1110 #define CL_CO( c ) stats_CounterClean( p_input->counters.p_##c ) 1111 1112 CL_CO( read_bytes ); 1113 CL_CO( read_packets ); 1114 CL_CO( demux_read ); 1115 CL_CO( input_bitrate ); 1116 CL_CO( demux_bitrate ); 1117 CL_CO( played_abuffers ); 1118 CL_CO( lost_abuffers ); 1119 CL_CO( displayed_pictures ); 1120 CL_CO( lost_pictures ); 1121 CL_CO( decoded_audio) ; 1122 CL_CO( decoded_video ); 1123 CL_CO( decoded_sub) ; 1124 CL_CO( read_bytes ); 1125 1108 1126 /* Close optional stream output instance */ 1109 1127 if( p_input->p_sout ) … … 1112 1130 vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); 1113 1131 vlc_value_t keep; 1132 1133 CL_CO( sout_sent_packets ); 1134 CL_CO( sout_sent_bytes ); 1135 CL_CO( sout_send_bitrate ); 1114 1136 1115 1137 if( var_Get( p_input, "sout-keep", &keep ) >= 0 && keep.b_bool && p_pl ) … … 1129 1151 } 1130 1152 1153 #undef CL_CO 1131 1154 /* Tell we're dead */ 1132 1155 p_input->b_dead = VLC_TRUE; src/input/stream.c
r8cbf9ec rbaacaea 25 25 #include <vlc/vlc.h> 26 26 #include <vlc/input.h> 27 #include <assert.h> 27 28 28 29 #include "input_internal.h" … … 1578 1579 int i_total; 1579 1580 1581 input_thread_t *p_input = (input_thread_t *)s->p_parent->p_parent ; 1582 assert( p_input ); 1583 1580 1584 if( !p_sys->i_list ) 1581 1585 { 1582 1586 i_read = p_access->pf_read( p_access, p_read, i_read ); 1583 stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_BYTES, i_read, 1587 vlc_mutex_lock( &p_input->counters.counters_lock ); 1588 stats_UpdateInteger( s, p_input->counters.p_read_bytes, i_read, 1584 1589 &i_total ); 1585 stats_UpdateFloat( s ->p_parent->p_parent , STATS_INPUT_BITRATE,1590 stats_UpdateFloat( s, p_input->counters.p_input_bitrate, 1586 1591 (float)i_total, NULL ); 1587 stats_UpdateInteger( s ->p_parent->p_parent , STATS_READ_PACKETS, 1,1588 NULL);1592 stats_UpdateInteger( s, p_input->counters.p_read_packets, 1, NULL ); 1593 vlc_mutex_unlock( &p_input->counters.counters_lock ); 1589 1594 return i_read; 1590 1595 } … … 1615 1620 1616 1621 /* Update read bytes in input */ 1617 stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_BYTES, i_read, 1618 &i_total ); 1619 stats_UpdateFloat( s->p_parent->p_parent , STATS_INPUT_BITRATE, 1620 (float)i_total, NULL ); 1621 stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_PACKETS, 1, NULL ); 1622 vlc_mutex_lock( &p_input->counters.counters_lock ); 1623 stats_UpdateInteger( s, p_input->counters.p_read_bytes, i_read, &i_total ); 1624 stats_UpdateFloat( s, p_input->counters.p_input_bitrate, 1625 (float)i_total, NULL ); 1626 stats_UpdateInteger( s, p_input->counters.p_read_packets, 1, NULL ); 1627 vlc_mutex_unlock( &p_input->counters.counters_lock ); 1622 1628 return i_read; 1623 1629 } … … 1631 1637 int i_total; 1632 1638 1639 input_thread_t *p_input = (input_thread_t *)s->p_parent->p_parent ; 1640 assert( p_input ); 1641 1633 1642 if( !p_sys->i_list ) 1634 1643 { … … 1637 1646 if( p_block && p_access->p_libvlc->b_stats ) 1638 1647 { 1639 stats_UpdateInteger( s->p_parent->p_parent, STATS_READ_BYTES, 1648 vlc_mutex_lock( &p_input->counters.counters_lock ); 1649 stats_UpdateInteger( s, p_input->counters.p_read_bytes, 1640 1650 p_block->i_buffer, &i_total ); 1641 stats_UpdateFloat( s ->p_parent->p_parent , STATS_INPUT_BITRATE,1651 stats_UpdateFloat( s, p_input->counters.p_input_bitrate, 1642 1652 (float)i_total, NULL ); 1643 stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_PACKETS, 1, NULL ); 1653 stats_UpdateInteger( s, p_input->counters.p_read_packets, 1, NULL ); 1654 vlc_mutex_unlock( &p_input->counters.counters_lock ); 1644 1655 } 1645 1656 return p_block; … … 1672 1683 if( p_block ) 1673 1684 { 1674 stats_UpdateInteger( s->p_parent->p_parent, STATS_READ_BYTES, 1685 vlc_mutex_lock( &p_input->counters.counters_lock ); 1686 stats_UpdateInteger( s, p_input->counters.p_read_bytes, 1675 1687 p_block->i_buffer, &i_total ); 1676 stats_UpdateFloat( s ->p_parent->p_parent , STATS_INPUT_BITRATE,1688 stats_UpdateFloat( s, p_input->counters.p_input_bitrate, 1677 1689 (float)i_total, NULL ); 1678 stats_UpdateInteger( s ->p_parent->p_parent , STATS_READ_PACKETS,1690 stats_UpdateInteger( s, p_input->counters.p_read_packets, 1679 1691 1 , NULL); 1680 }1681 1692 vlc_mutex_unlock( &p_input->counters.counters_lock ); 1693 } 1682 1694 return p_block; 1683 1695 } src/libvlc.c
r4896c11 rbaacaea 687 687 688 688 libvlc.b_stats = config_GetInt( p_vlc, "stats" ); 689 libvlc.p_stats = NULL; 689 libvlc.i_timers = 0; 690 libvlc.pp_timers = NULL; 691 vlc_mutex_init( p_vlc, &libvlc.timer_lock ); 690 692 691 693 /* … … 888 890 aout_instance_t * p_aout; 889 891 announce_handler_t * p_announce; 890 stats_handler_t * p_stats;891 892 vlc_t *p_vlc = vlc_current_object( i_object ); 892 893 … … 943 944 } 944 945 945 while( ( p_stats = vlc_object_find( p_vlc, VLC_OBJECT_STATS, FIND_CHILD) )) 946 { 947 stats_TimersDumpAll( p_vlc ); 948 stats_HandlerDestroy( p_stats ); 949 vlc_object_detach( (vlc_object_t*) p_stats ); 950 vlc_object_release( (vlc_object_t *)p_stats ); 951 // TODO: Delete it 952 } 946 stats_TimersDumpAll( p_vlc ); 947 stats_TimersClean( p_vlc ); 953 948 954 949 /* src/misc/objects.c
r8ab353b rbaacaea 217 217 psz_type = "osd menu"; 218 218 break; 219 case VLC_OBJECT_STATS:220 i_size = sizeof( stats_handler_t );221 psz_type = "statistics";222 break;223 219 default: 224 220 i_size = i_type > (int)sizeof(vlc_object_t) src/misc/stats.c
re444bfd rbaacaea 33 33 * Local prototypes 34 34 *****************************************************************************/ 35 static counter_t *GetCounter( stats_handler_t *p_handler, int i_object_id, 36 unsigned int i_counter ); 37 static int stats_CounterUpdate( stats_handler_t *p_handler, 38 counter_t *p_counter, 39 vlc_value_t val, vlc_value_t * ); 40 static stats_handler_t* stats_HandlerCreate( vlc_object_t *p_this ); 41 static stats_handler_t *stats_HandlerGet( vlc_object_t *p_this ); 42 35 static int CounterUpdate( vlc_object_t *p_this, 36 counter_t *p_counter, 37 vlc_value_t val, vlc_value_t * ); 43 38 static void TimerDump( vlc_object_t *p_this, counter_t *p_counter, vlc_bool_t); 44 39 … … 48 43 49 44 /** 50 * Cleanup statistics handler stuff51 * \param p_stats the handler to clean52 * \return nothing53 */54 void stats_HandlerDestroy( stats_handler_t *p_stats )55 {56 int i;57 for ( i = p_stats->i_counters - 1 ; i >= 0 ; i-- )58 {59 int j;60 counter_t *p_counter = p_stats->pp_counters[i];61 62 for( j = p_counter->i_samples -1; j >= 0 ; j-- )63 {64 counter_sample_t *p_sample = p_counter->pp_samples[j];65 REMOVE_ELEM( p_counter->pp_samples, p_counter->i_samples, j );66 free( p_sample );67 }68 free( p_counter->psz_name );69 REMOVE_ELEM( p_stats->pp_counters, p_stats->i_counters, i );70 free( p_counter );71 }72 }73 74 /**75 45 * Create a statistics counter 76 * \param p_this the object for which to create the counter 77 * \param psz_name the name 46 * \param p_this a VLC object 78 47 * \param i_type the type of stored data. One of VLC_VAR_STRING, 79 48 * VLC_VAR_INTEGER, VLC_VAR_FLOAT … … 83 52 * (keep a time derivative of the value) 84 53 */ 85 int __stats_Create( vlc_object_t *p_this, const char *psz_name, unsigned int i_id,86 int i_type, int i_compute_type )54 counter_t * __stats_CounterCreate( vlc_object_t *p_this, 55 int i_type, int i_compute_type ) 87 56 { 88 57 counter_t *p_counter; 89 stats_handler_t *p_handler; 90 91 if( !p_this->p_libvlc->b_stats ) return VLC_EGENERIC; 92 93 p_handler = stats_HandlerGet( p_this ); 94 if( !p_handler ) return VLC_ENOMEM; 95 96 vlc_mutex_lock( &p_handler->object_lock ); 58 if( !p_this->p_libvlc->b_stats ) return NULL; 97 59 98 60 p_counter = (counter_t*) malloc( sizeof( counter_t ) ) ; 99 61 100 p_counter->psz_name = strdup( psz_name );101 p_counter->i_index = ((uint64_t)p_this->i_object_id << 32 ) + i_id;102 62 p_counter->i_compute_type = i_compute_type; 103 63 p_counter->i_type = i_type; 104 64 p_counter->i_samples = 0; 105 65 p_counter->pp_samples = NULL; 66 p_counter->psz_name = NULL; 106 67 107 68 p_counter->update_interval = 0; 108 69 p_counter->last_update = 0; 109 70 110 INSERT_ELEM( p_handler->pp_counters, p_handler->i_counters, 111 p_handler->i_counters, p_counter ); 112 113 vlc_mutex_unlock( &p_handler->object_lock ); 114 vlc_object_release( p_handler ); 115 116 return VLC_SUCCESS; 71 return p_counter; 117 72 } 118 73 119 74 /** Update a counter element with new values 120 * \param p_this the object in which to update121 * \param p sz_name the name75 * \param p_this a VLC object 76 * \param p_counter the counter to update 122 77 * \param val the vlc_value union containing the new value to aggregate. For 123 78 * more information on how data is aggregated, \see __stats_Create 79 * \param val_new a pointer that will be filled with new data 124 80 */ 125 int __stats_Update( vlc_object_t *p_this, unsigned int i_counter,81 int __stats_Update( vlc_object_t *p_this, counter_t *p_counter, 126 82 vlc_value_t val, vlc_value_t *val_new ) 127 83 { 128 int i_ret;129 counter_t *p_counter;130 stats_handler_t *p_handler;131 132 84 if( !p_this->p_libvlc->b_stats ) return VLC_EGENERIC; 133 134 /* Get stats handler singleton */ 135 p_handler = stats_HandlerGet( p_this ); 136 if( !p_handler ) return VLC_ENOMEM; 137 138 vlc_mutex_lock( &p_handler->object_lock ); 139 /* Look for existing element */ 140 p_counter = GetCounter( p_handler, p_this->i_object_id, i_counter ); 141 if( !p_counter ) 142 { 143 vlc_mutex_unlock( &p_handler->object_lock ); 144 vlc_object_release( p_handler ); 145 return VLC_ENOOBJ; 146 } 147 148 i_ret = stats_CounterUpdate( p_handler, p_counter, val, val_new ); 149 vlc_mutex_unlock( &p_handler->object_lock ); 150 vlc_object_release( p_handler ); 151 152 return i_ret; 85 return CounterUpdate( p_this, p_counter, val, val_new ); 153 86 } 154 87 155 88 /** Get the aggregated value for a counter 156 89 * \param p_this an object 157 * \param i_object_id the object id from which we want the data 158 * \param psz_name the name of the couner 90 * \param p_counter the counter 159 91 * \param val a pointer to an initialized vlc_value union. It will contain the 160 92 * retrieved value 161 93 * \return an error code 162 94 */ 163 int __stats_Get( vlc_object_t *p_this, int i_object_id, 164 unsigned int i_counter, vlc_value_t *val ) 165 { 166 counter_t *p_counter; 167 stats_handler_t *p_handler; 168 95 int __stats_Get( vlc_object_t *p_this, counter_t *p_counter, vlc_value_t *val ) 96 { 169 97 if( !p_this->p_libvlc->b_stats ) return VLC_EGENERIC; 170 98 171 /* Get stats handler singleton */172 p_handler = stats_HandlerGet( p_this );173 if( !p_handler ) return VLC_ENOMEM;174 vlc_mutex_lock( &p_handler->object_lock );175 176 /* Look for existing element */177 p_counter = GetCounter( p_handler, i_object_id, i_counter );178 if( !p_counter )179 {180 vlc_mutex_unlock( &p_handler->object_lock );181 vlc_object_release( p_handler );182 val->i_int = val->f_float = 0.0;183 return VLC_ENOOBJ;184 }185 186 99 if( p_counter->i_samples == 0 ) 187 100 { 188 vlc_mutex_unlock( &p_handler->object_lock );
