[vlc-devel] [PATCH 2/2] Add method for getting stats from VLCMedia

Pierre d'Herbemont pdherbemont at gmail.com
Tue Dec 21 22:12:58 CET 2010


Hello Rune,

El 20/12/2010, a las 16:14, Rune Botten <rbotten at gmail.com> escribió:

> ---
> .../macosx/framework/Headers/Public/VLCMedia.h     |   12 ++++++--
> projects/macosx/framework/Sources/VLCMedia.m       |   30 +++++++++++++++++++-
> 2 files changed, 38 insertions(+), 4 deletions(-)
> 
> diff --git a/projects/macosx/framework/Headers/Public/VLCMedia.h b/projects/macosx/framework/Headers/Public/VLCMedia.h
> index 1322332..29e9578 100644
> --- a/projects/macosx/framework/Headers/Public/VLCMedia.h
> +++ b/projects/macosx/framework/Headers/Public/VLCMedia.h
> @@ -332,15 +332,21 @@ extern NSString *VLCMediaTracksInformationTypeUnknown;
>  */
> - (void)parse;
> 
> -/**************************************************************************
> +/**
>  * Add options to the media, that will be used to determine how
>  * VLCMediaPlayer will read the media. This allow to use VLC advanced
>  * reading/streaming options in a per-media basis
>  *
>  * The options are detailed in vlc --long-help, for instance "--sout-all"
>  * And on the web: http://wiki.videolan.org/VLC_command-line_help
> -
> -**************************************************************************/
> +*/
> - (void) addOptions:(NSDictionary*) options;
> 
> +/**
> + * Getter for statistics information
> + * Returns a NSDictionary with NSNumbers for values.
> + *
> + */
> +- (NSDictionary*) getStats;

The "get" prefix is superfluous, and doesn't match our coding style.

> @end
> diff --git a/projects/macosx/framework/Sources/VLCMedia.m b/projects/macosx/framework/Sources/VLCMedia.m
> index 958591e..eaf0dd3 100644
> --- a/projects/macosx/framework/Sources/VLCMedia.m
> +++ b/projects/macosx/framework/Sources/VLCMedia.m
> @@ -240,7 +240,7 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
>     libvlc_event_detach(p_em, libvlc_MediaDurationChanged, HandleMediaDurationChanged, self);
>     libvlc_event_detach(p_em, libvlc_MediaStateChanged,    HandleMediaStateChanged,    self);
>     libvlc_event_detach(p_em, libvlc_MediaSubItemAdded,    HandleMediaSubItemAdded,    self);
> -    libvlc_event_detach(p_em, libvlc_MediaParsedChanged,   HandleMediaParsedChanged,    self);
> +    libvlc_event_detach(p_em, libvlc_MediaParsedChanged,   HandleMediaParsedChanged,   self);
>     [[VLCEventManager sharedManager] cancelCallToObject:self];
> 
>     // Testing to see if the pointer exists is not required, if the pointer is null
> @@ -338,6 +338,34 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
>     }
> }
> 
> +- (NSDictionary*) getStats
> +{
> +    if(!p_md)
> +        return NULL;
> +
> +    NSMutableDictionary *d = [NSMutableDictionary dictionary];
> +    libvlc_media_stats_t p_stats;
> +    libvlc_media_get_stats(p_md, &p_stats);
> +
> +    [d setObject:[NSNumber numberWithFloat: p_stats.f_demux_bitrate]       forKey:@"demux_bitrate"];

While we are at it, could we use upper case for key name (demuxBitrate)?

Thanks for the patches!

Pierre.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20101221/b4de3b97/attachment.html>


More information about the vlc-devel mailing list