Commit 1ab90751 authored by Clément Stenac's avatar Clément Stenac

Compute global input/output stats (Refs:#473)

parent 8eaff121
...@@ -344,6 +344,7 @@ struct global_stats_t ...@@ -344,6 +344,7 @@ struct global_stats_t
vlc_mutex_t lock; vlc_mutex_t lock;
float f_input_bitrate; float f_input_bitrate;
float f_demux_bitrate;
float f_output_bitrate; float f_output_bitrate;
int i_http_clients; int i_http_clients;
......
...@@ -218,6 +218,8 @@ struct playlist_t ...@@ -218,6 +218,8 @@ struct playlist_t
// thread // thread
interaction_t *p_interaction; interaction_t *p_interaction;
global_stats_t *p_stats;
/*@}*/ /*@}*/
}; };
......
...@@ -370,20 +370,25 @@ void __stats_ComputeGlobalStats( vlc_object_t *p_obj, ...@@ -370,20 +370,25 @@ void __stats_ComputeGlobalStats( vlc_object_t *p_obj,
int i_index; int i_index;
vlc_mutex_lock( &p_stats->lock ); vlc_mutex_lock( &p_stats->lock );
p_list = vlc_list_find( p_obj, VLC_OBJECT_INPUT, FIND_CHILD ); p_list = vlc_list_find( p_obj, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_list ) if( p_list )
{ {
float f_total_in = 0, f_total_out = 0,f_total_demux = 0;
for( i_index = 0; i_index < p_list->i_count ; i_index ++ ) for( i_index = 0; i_index < p_list->i_count ; i_index ++ )
{ {
float f_in = 0, f_out = 0; float f_in = 0, f_out = 0, f_demux = 0;
p_obj = (vlc_object_t *)p_list->p_values[i_index].p_object; p_obj = (vlc_object_t *)p_list->p_values[i_index].p_object;
stats_GetFloat( p_obj, p_obj->i_object_id, "input_bitrate", stats_GetFloat( p_obj, p_obj->i_object_id, "input_bitrate",
&f_in ); &f_in );
stats_GetFloat( p_obj, p_obj->i_object_id, "sout_send_bitrate", stats_GetFloat( p_obj, p_obj->i_object_id, "sout_send_bitrate",
&f_out ); &f_out );
p_stats->f_input_bitrate += f_in; stats_GetFloat( p_obj, p_obj->i_object_id, "demux_bitrate",
p_stats->f_output_bitrate += f_out; &f_demux );
f_total_in += f_in; f_total_out += f_out;f_total_demux += f_demux;
} }
p_stats->f_input_bitrate = f_total_in;
p_stats->f_output_bitrate = f_total_out;
p_stats->f_demux_bitrate = f_total_demux;
vlc_list_release( p_list ); vlc_list_release( p_list );
} }
......
...@@ -173,10 +173,12 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent ) ...@@ -173,10 +173,12 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
p_playlist->request.b_request = VLC_FALSE; p_playlist->request.b_request = VLC_FALSE;
p_playlist->status.i_status = PLAYLIST_STOPPED; p_playlist->status.i_status = PLAYLIST_STOPPED;
p_playlist->i_sort = SORT_ID; p_playlist->i_sort = SORT_ID;
p_playlist->i_order = ORDER_NORMAL; p_playlist->i_order = ORDER_NORMAL;
p_playlist->p_stats = (global_stats_t *)malloc( sizeof( global_stats_t ) );
vlc_mutex_init( p_playlist, &p_playlist->p_stats->lock );
/* Finally, launch the thread ! */ /* Finally, launch the thread ! */
if( vlc_thread_create( p_playlist, "playlist", RunThread, if( vlc_thread_create( p_playlist, "playlist", RunThread,
VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) ) VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) )
...@@ -598,6 +600,11 @@ static void RunThread ( playlist_t *p_playlist ) ...@@ -598,6 +600,11 @@ static void RunThread ( playlist_t *p_playlist )
stats_TimerStop( p_playlist, "Interaction thread" ); stats_TimerStop( p_playlist, "Interaction thread" );
} }
if( i_loops %5 == 0 && p_playlist->p_stats )
{
stats_ComputeGlobalStats( p_playlist, p_playlist->p_stats );
}
vlc_mutex_lock( &p_playlist->object_lock ); vlc_mutex_lock( &p_playlist->object_lock );
/* First, check if we have something to do */ /* First, check if we have something to do */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment