[vlc-devel] [PATCH] statistics for libvlc

Frank Enderle frank.enderle at anamica.de
Wed Jul 14 18:04:41 CEST 2010


i see. i didn't know that there's such a function. do you think it would
be a better idea to return the stats structure directly without copying?
- i wanted to hide the mutex from the user, but maybe this is not
necessary at all?

it might be a better ide to provide get_statistics which does a
stats_NewInputStats() followed by stats_ComputeInputStats() and return
the stats structure. a second free_statistics function could be used to
clean up. comments?

frank..

Am 14.07.2010 17:45, schrieb Ilkka Ollakka:
> On Wed, Jul 14, 2010 at 04:36:11PM +0200, Frank Enderle wrote:
> 
>>  /**************************************************************************
>> + * Returns the statistics
>> + **************************************************************************/
>> +int libvlc_media_player_get_statistics( libvlc_media_player_t *p_mi, libvlc_statistics_t *p_stats )
>> +{
>> +    assert( p_mi != NULL && p_stats != NULL );
>> +
>> +    input_thread_t * p_input_thread = libvlc_get_input_thread( p_mi );
>> +    if( !p_input_thread )
>> +        return 0;
>> +
>> +    input_item_t *p_item = input_GetItem( p_input_thread );
>> +    if( !p_item )
>> +    {
>> +        vlc_object_release( p_input_thread );
>> +        return 0;
>> +    }
> 
> That mutex lock and stat-copying could be replaced with just
> stats_ComputeInputStats( p_input_thread, p_stats ); 
> 
>> +    vlc_mutex_lock( &p_item->p_stats->lock );
>> +
>> +    /* Input */
>> +    p_stats->i_read_packets = p_item->p_stats->i_read_packets;
>> +    p_stats->i_read_bytes = p_item->p_stats->i_read_bytes;
>> +    p_stats->f_input_bitrate = p_item->p_stats->f_input_bitrate;
>> +    p_stats->f_average_input_bitrate = p_item->p_stats->f_average_input_bitrate;
>> +
>> +    /* Demux */
>> +    p_stats->i_demux_read_packets = p_item->p_stats->i_demux_read_packets;
>> +    p_stats->i_demux_read_bytes = p_item->p_stats->i_demux_read_bytes;
>> +    p_stats->f_demux_bitrate = p_item->p_stats->f_demux_bitrate;
>> +    p_stats->f_average_demux_bitrate = p_item->p_stats->f_average_demux_bitrate;
>> +    p_stats->i_demux_corrupted = p_item->p_stats->i_demux_corrupted;
>> +    p_stats->i_demux_discontinuity = p_item->p_stats->i_demux_discontinuity;
>> +
>> +    /* Decoders */
>> +    p_stats->i_decoded_audio = p_item->p_stats->i_decoded_audio;
>> +    p_stats->i_decoded_video = p_item->p_stats->i_decoded_video;
>> +
>> +    /* Vout */
>> +    p_stats->i_displayed_pictures = p_item->p_stats->i_displayed_pictures;
>> +    p_stats->i_lost_pictures = p_item->p_stats->i_lost_pictures;
>> +
>> +    /* Sout */
>> +    p_stats->i_sent_packets = p_item->p_stats->i_sent_packets;
>> +    p_stats->i_sent_bytes = p_item->p_stats->i_sent_bytes;
>> +    p_stats->f_send_bitrate = p_item->p_stats->f_send_bitrate;
>> +
>> +    /* Aout */
>> +    p_stats->i_played_abuffers = p_item->p_stats->i_played_abuffers;
>> +    p_stats->i_lost_abuffers = p_item->p_stats->i_lost_abuffers;
>> +
>> +    vlc_mutex_unlock( &p_item->p_stats->lock );
> 
> 
> 
> 
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel


-- 
Dipl.-Ing. (FH) Frank Enderle

anamica UG (haftungsbeschränkt)
Beinsteinerstr. 6
71334 Waiblingen

Telefon:  +49 151 14981091
Telefax:  +49 7151 1335770
E-Mail:   frank.enderle at anamica.de
Internet: www.anamica.de

Handelsregister: AG Stuttgart HRB 732357
Geschäftsführer: Yvonne Holzwarth, Frank Enderle



More information about the vlc-devel mailing list