[vlc-devel] [PATCH 2/2] Add method for getting stats from VLCMedia
Pierre d'Herbemont
pdherbemont at gmail.com
Fri Dec 24 00:40:49 CET 2010
Pierre.
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;
> +
> @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"];
> + [d setObject:[NSNumber numberWithFloat: p_stats.f_input_bitrate] forKey:@"input_bitrate"];
> + [d setObject:[NSNumber numberWithFloat: p_stats.f_send_bitrate] forKey:@"send_bitrate"];
> + [d setObject:[NSNumber numberWithInt: p_stats.i_decoded_audio] forKey:@"decoded_audio"];
> + [d setObject:[NSNumber numberWithInt: p_stats.i_decoded_video] forKey:@"decoded_video"];
> + [d setObject:[NSNumber numberWithInt: p_stats.i_demux_corrupted] forKey:@"demux_corrupted"];
> + [d setObject:[NSNumber numberWithInt: p_stats.i_demux_discontinuity] forKey:@"demux_discontinuity"];
> + [d setObject:[NSNumber numberWithInt: p_stats.i_demux_read_bytes] forKey:@"demux_read_bytes"];
> + [d setObject:[NSNumber numberWithInt: p_stats.i_displayed_pictures] forKey:@"displayed_pictures"];
> + [d setObject:[NSNumber numberWithInt: p_stats.i_lost_abuffers] forKey:@"lost_abuffers"];
> + [d setObject:[NSNumber numberWithInt: p_stats.i_lost_pictures] forKey:@"lost_pictures"];
> + [d setObject:[NSNumber numberWithInt: p_stats.i_played_abuffers] forKey:@"played_abuffers"];
> + [d setObject:[NSNumber numberWithInt: p_stats.i_read_bytes] forKey:@"read_bytes"];
> + [d setObject:[NSNumber numberWithInt: p_stats.i_sent_bytes] forKey:@"sent_bytes"];
> + [d setObject:[NSNumber numberWithInt: p_stats.i_sent_packets] forKey:@"sent_packets"];
> +
> + return d;
> +}
> +
> NSString *VLCMediaTracksInformationCodec = @"codec"; // NSNumber
> NSString *VLCMediaTracksInformationId = @"id"; // NSNumber
> NSString *VLCMediaTracksInformationType = @"type"; // NSString
> --
> 1.7.3.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list