Changeset e56193e811c52c1f0945524e47f0f9aa4069d5e0
- Timestamp:
- 11/01/06 21:00:58 (3 years ago)
- git-parent:
- Files:
-
- include/vlc_input.h (modified) (2 diffs)
- include/vlc_messages.h (modified) (4 diffs)
- include/vlc_symbols.h (modified) (7 diffs)
- src/input/input.c (modified) (2 diffs)
- src/input/stream.c (modified) (2 diffs)
- src/misc/stats.c (modified) (7 diffs)
- src/playlist/item.c (modified) (1 diff)
- src/playlist/playlist.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/vlc_input.h
rdc09f86 re56193e 65 65 vlc_bool_t b_fixed_name; /**< Can the interface change the name ?*/ 66 66 67 input_stats_t *p_stats; /**< Statistics */ 68 67 69 vlc_mutex_t lock; /**< Item cannot be changed without this lock */ 68 70 }; … … 92 94 p_i->i_type = ITEM_TYPE_UNKNOWN; 93 95 p_i->b_fixed_name = VLC_TRUE; 96 97 p_i->p_stats = (input_stats_t*) malloc( sizeof( input_stats_t ) ); 98 vlc_mutex_init( p_o, &p_i->p_stats->lock ); 99 94 100 vlc_mutex_init( p_o, &p_i->lock ); 95 101 } include/vlc_messages.h
r91c8dba re56193e 26 26 27 27 #include <stdarg.h> 28 29 int vlc_mutex_lock( vlc_mutex_t * ) ; 30 int vlc_mutex_unlock( vlc_mutex_t * ) ; 31 28 32 /** 29 33 * \defgroup messages Messages … … 240 244 #define stats_Create( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d ) 241 245 VLC_EXPORT( int, __stats_Create, (vlc_object_t*, char *, int, int) ); 242 246 #define stats_Get( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d ) 247 VLC_EXPORT( int, __stats_Get, (vlc_object_t*, int, char *, vlc_value_t*) ); 248 249 #define stats_GetInteger( a,b,c,d ) __stats_GetInteger( VLC_OBJECT(a), b, c, d ) 250 static inline int __stats_GetInteger( vlc_object_t *p_obj, int i_id, 251 char *psz_name, int *value ) 252 { 253 vlc_value_t val; 254 int i_ret = __stats_Get( p_obj, i_id, psz_name, &val ); 255 *value = val.i_int; 256 return i_ret; 257 } 258 259 #define stats_UpdateInteger( a,b,c ) __stats_UpdateInteger( VLC_OBJECT(a),b,c ) 243 260 static inline int __stats_UpdateInteger( vlc_object_t *p_obj, char *psz_name, 244 261 int i ) … … 248 265 return __stats_Update( p_obj, psz_name, val ); 249 266 } 250 #define stats_UpdateInteger( a,b,c ) __stats_UpdateInteger( VLC_OBJECT(a),b,c )251 267 252 268 253 269 struct input_stats_t 254 270 { 271 272 vlc_mutex_t lock; 273 255 274 /* Input */ 256 275 int i_read_packets; … … 266 285 int i_lost_pictures; 267 286 }; 287 288 VLC_EXPORT( void, stats_ComputeInputStats, (input_thread_t*, input_stats_t*) ); 289 VLC_EXPORT( void, stats_ReinitInputStats, (input_stats_t *) ); 290 VLC_EXPORT( void, stats_DumpInputStats, (input_stats_t *) ); include/vlc_symbols.h
ra078354 re56193e 30 30 int playlist_ItemSetDuration (playlist_item_t *, mtime_t); 31 31 void aout_Delete (aout_instance_t *); 32 void stats_ComputeInputStats (input_thread_t*, input_stats_t*); 32 33 int playlist_Control (playlist_t *, int, ...); 33 34 vlc_acl_t * __ACL_Create (vlc_object_t *p_this, vlc_bool_t b_allow); … … 121 122 void aout_FiltersPlay (aout_instance_t * p_aout, aout_filter_t ** pp_filters, int i_nb_filters, aout_buffer_t ** pp_input_buffer); 122 123 int __stats_Update (vlc_object_t*, char *, vlc_value_t); 124 int __stats_Get (vlc_object_t*, int, char *, vlc_value_t*); 123 125 char* httpd_ClientIP (httpd_client_t *cl, char *psz_ip); 124 126 int __intf_UserProgress (vlc_object_t*, const char*, const char*, float); … … 242 244 void * __vlc_object_create (vlc_object_t *, int); 243 245 int __aout_VolumeInfos (vlc_object_t *, audio_volume_t *); 246 void stats_DumpInputStats (input_stats_t *); 244 247 const iso639_lang_t * GetLang_2T (const char *); 245 248 int __intf_Interact (vlc_object_t *,interaction_dialog_t *); … … 252 255 char * __net_Gets (vlc_object_t *p_this, int fd, v_socket_t *); 253 256 void aout_DateMove (audio_date_t *, mtime_t); 257 void stats_ReinitInputStats (input_stats_t *); 254 258 void sout_MuxDelete (sout_mux_t *); 255 259 void vout_InitFormat (video_frame_format_t *, uint32_t, int, int, int); … … 874 878 int (*__stats_Create_inner) (vlc_object_t*, char *, int, int); 875 879 int (*__stats_Update_inner) (vlc_object_t*, char *, vlc_value_t); 880 int (*__stats_Get_inner) (vlc_object_t*, int, char *, vlc_value_t*); 881 void (*stats_ComputeInputStats_inner) (input_thread_t*, input_stats_t*); 882 void (*stats_DumpInputStats_inner) (input_stats_t *); 883 void (*stats_ReinitInputStats_inner) (input_stats_t *); 876 884 }; 877 885 # if defined (__PLUGIN__) … … 1296 1304 # define __stats_Create (p_symbols)->__stats_Create_inner 1297 1305 # define __stats_Update (p_symbols)->__stats_Update_inner 1306 # define __stats_Get (p_symbols)->__stats_Get_inner 1307 # define stats_ComputeInputStats (p_symbols)->stats_ComputeInputStats_inner 1308 # define stats_DumpInputStats (p_symbols)->stats_DumpInputStats_inner 1309 # define stats_ReinitInputStats (p_symbols)->stats_ReinitInputStats_inner 1298 1310 # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) 1299 1311 /****************************************************************** … … 1721 1733 ((p_symbols)->__stats_Create_inner) = __stats_Create; \ 1722 1734 ((p_symbols)->__stats_Update_inner) = __stats_Update; \ 1735 ((p_symbols)->__stats_Get_inner) = __stats_Get; \ 1736 ((p_symbols)->stats_ComputeInputStats_inner) = stats_ComputeInputStats; \ 1737 ((p_symbols)->stats_DumpInputStats_inner) = stats_DumpInputStats; \ 1738 ((p_symbols)->stats_ReinitInputStats_inner) = stats_ReinitInputStats; \ 1723 1739 (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ 1724 1740 src/input/input.c
r03b059c re56193e 151 151 p_input->input.i_cr_average = 0; 152 152 153 stats_ReinitInputStats( p_item->p_stats ); 154 153 155 /* No slave */ 154 156 p_input->i_slave = 0; … … 674 676 { 675 677 stats_Create( p_input, "read_bytes", VLC_VAR_INTEGER, STATS_COUNTER ); 678 stats_Create( p_input, "read_packets", VLC_VAR_INTEGER, STATS_COUNTER ); 676 679 stats_Create( p_input, "input_bitrate", VLC_VAR_FLOAT, 677 STATS_DERIVATIVE );680 STATS_DERIVATIVE ); 678 681 psz = var_GetString( p_input, "sout" ); 679 682 if( *psz && strncasecmp( p_input->input.p_item->psz_uri, "vlc:", 4 ) ) src/input/stream.c
r03b059c re56193e 1570 1570 { 1571 1571 i_read = p_access->pf_read( p_access, p_read, i_read ); 1572 stats_UpdateInteger( s->p_parent->p_parent , "read_bytes", i_read ); 1573 stats_UpdateInteger( s->p_parent->p_parent , "input_bitrate", i_read ); 1574 stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1 ); 1572 1575 return i_read; 1573 1576 } … … 1598 1601 1599 1602 /* Update read bytes in input */ 1600 stats_UpdateInteger( s->p_parent, "read_bytes", i_read ); 1601 1603 stats_UpdateInteger( s->p_parent->p_parent , "read_bytes", i_read ); 1604 stats_UpdateInteger( s->p_parent->p_parent , "input_bitrate", i_read ); 1605 stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1 ); 1602 1606 return i_read; 1603 1607 } src/misc/stats.c
r68aa3ca re56193e 28 28 29 29 #include <vlc/vlc.h> 30 #include <vlc_input.h> 30 31 31 32 /***************************************************************************** … … 49 50 counter_t *p_counter; 50 51 stats_handler_t *p_handler = stats_HandlerGet( p_this ); 52 if( !p_handler ) return VLC_ENOMEM; 53 54 vlc_mutex_lock( &p_handler->object_lock ); 51 55 52 56 p_counter = (counter_t*) malloc( sizeof( counter_t ) ) ; … … 64 68 p_counter ); 65 69 70 vlc_mutex_unlock( &p_handler->object_lock ); 71 66 72 return VLC_SUCCESS; 67 73 } … … 71 77 int __stats_Update( vlc_object_t *p_this, char *psz_name, vlc_value_t val ) 72 78 { 79 int i_ret; 73 80 counter_t *p_counter; 74 81 … … 76 83 stats_handler_t *p_handler = stats_HandlerGet( p_this ); 77 84 if( !p_handler ) return VLC_ENOMEM; 85 86 vlc_mutex_lock( &p_handler->object_lock ); 78 87 79 88 /* Look for existing element */ … … 82 91 if( !p_counter ) 83 92 { 93 vlc_mutex_unlock( &p_handler->object_lock ); 84 94 vlc_object_release( p_handler ); 85 95 return VLC_ENOOBJ; 86 96 } 87 97 88 return stats_CounterUpdate( p_handler, p_counter, val ); 89 } 90 98 i_ret = stats_CounterUpdate( p_handler, p_counter, val ); 99 vlc_mutex_unlock( &p_handler->object_lock ); 100 101 return i_ret; 102 } 103 104 int __stats_Get( vlc_object_t *p_this, int i_object_id, char *psz_name, vlc_value_t *val ) 105 { 106 counter_t *p_counter; 107 108 /* Get stats handler singleton */ 109 stats_handler_t *p_handler = stats_HandlerGet( p_this ); 110 if( !p_handler ) return VLC_ENOMEM; 111 vlc_mutex_lock( &p_handler->object_lock ); 112 113 114 /* Look for existing element */ 115 p_counter = stats_GetCounter( p_handler, i_object_id, 116 psz_name ); 117 if( !p_counter ) 118 { 119 vlc_mutex_unlock( &p_handler->object_lock ); 120 vlc_object_release( p_handler ); 121 return VLC_ENOOBJ; 122 } 123 124 if( p_counter->i_samples == 0 ) 125 { 126 vlc_mutex_unlock( &p_handler->object_lock ); 127 return VLC_EGENERIC; 128 } 129 130 /* FIXME: Does not work for all types, maybe */ 131 *val = p_counter->pp_samples[0]->value; 132 vlc_object_release( p_handler ); 133 134 vlc_mutex_unlock( &p_handler->object_lock ); 135 return VLC_SUCCESS;; 136 } 137 138 void stats_ComputeInputStats( input_thread_t *p_input, 139 input_stats_t *p_stats ) 140 { 141 vlc_mutex_lock( &p_stats->lock ); 142 /* read_packets and read_bytes are common to all streams */ 143 stats_GetInteger( p_input, p_input->i_object_id, "read_packets", 144 &p_stats->i_read_packets ); 145 stats_GetInteger( p_input, p_input->i_object_id, "read_bytes", 146 &p_stats->i_read_bytes ); 147 vlc_mutex_unlock( &p_stats->lock ); 148 } 149 150 void stats_ReinitInputStats( input_stats_t *p_stats ) 151 { 152 p_stats->i_read_packets = p_stats->i_read_bytes = 153 p_stats->f_last_bitrate = p_stats->f_average_bitrate = 154 p_stats->i_displayed_pictures = p_stats->i_lost_pictures = 0; 155 } 156 157 void stats_DumpInputStats( input_stats_t *p_stats ) 158 { 159 vlc_mutex_lock( &p_stats->lock ); 160 fprintf( stderr, "Read packets : %i (%i bytes)\n", 161 p_stats->i_read_packets, p_stats->i_read_bytes ); 162 vlc_mutex_unlock( &p_stats->lock ); 163 } 164 165 166 /******************************************************************** 167 * Following functions are local 168 ********************************************************************/ 169 170 /** 171 * Update a statistics counter, according to its type 172 * If needed, perform a bit of computation (derivative, mostly) 173 * This function must be entered with stats handler lock 174 * \param p_handler stats handler singleton 175 * \param p_counter the counter to update 176 * \param val the "new" value 177 * \return an error code 178 */ 91 179 static int stats_CounterUpdate( stats_handler_t *p_handler, 92 180 counter_t *p_counter, … … 245 333 246 334 247 void stats_ComputeInputStats( input_thread_t *p_input,248 input_stats_t *p_stats )249 {250 int i;251 /* read_packets and read_bytes are common to all streams */252 //p_stats->i_read_packets = stats_GetInteger( p_input, "read_packets" );253 // p_stats->i_read_bytes = stats_GetInteger( p_input, "read_bytes" );254 255 }src/playlist/item.c
r7389268 re56193e 63 63 64 64 memset( p_item, 0, sizeof( playlist_item_t ) ); 65 66 vlc_input_item_Init( p_obj, &p_item->input ); 65 67 66 68 p_item->input.psz_uri = strdup( psz_uri ); src/playlist/playlist.c
r8b953e6 re56193e 619 619 if( p_playlist->p_input ) 620 620 { 621 stats_ComputeInputStats( p_playlist->p_input, 622 p_playlist->p_input->input.p_item->p_stats ); 623 621 624 /* This input is dead. Remove it ! */ 622 625 if( p_playlist->p_input->b_dead )
