[vlc-commits] commit: Add method for getting stats from VLCMedia (Rune Botten )

git at videolan.org git at videolan.org
Mon Dec 27 15:37:06 CET 2010


vlc | branch: master | Rune Botten <rbotten at gmail.com> | Mon Dec 20 16:11:47 2010 +0100| [7f92a65ed716a69ebf7dc49ddca43bc9e4ad0af0] | committer: Pierre d'Herbemont 

Add method for getting stats from VLCMedia

Signed-off-by: Pierre d'Herbemont <pdherbemont at free.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7f92a65ed716a69ebf7dc49ddca43bc9e4ad0af0
---

 .../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..6908f71 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*) stats;
+
 @end
diff --git a/projects/macosx/framework/Sources/VLCMedia.m b/projects/macosx/framework/Sources/VLCMedia.m
index 958591e..019cf90 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*) stats
+{
+    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:@"demuxBitrate"];
+    [d setObject:[NSNumber numberWithFloat: p_stats.f_input_bitrate]       forKey:@"inputBitrate"];
+    [d setObject:[NSNumber numberWithFloat: p_stats.f_send_bitrate]        forKey:@"sendBitrate"];
+    [d setObject:[NSNumber numberWithInt:   p_stats.i_decoded_audio]       forKey:@"decodedAudio"];
+    [d setObject:[NSNumber numberWithInt:   p_stats.i_decoded_video]       forKey:@"decodedVideo"];
+    [d setObject:[NSNumber numberWithInt:   p_stats.i_demux_corrupted]     forKey:@"demuxCorrupted"];
+    [d setObject:[NSNumber numberWithInt:   p_stats.i_demux_discontinuity] forKey:@"demuxDiscontinuity"];
+    [d setObject:[NSNumber numberWithInt:   p_stats.i_demux_read_bytes]    forKey:@"demuxReadBytes"];
+    [d setObject:[NSNumber numberWithInt:   p_stats.i_displayed_pictures]  forKey:@"displayedPictures"];
+    [d setObject:[NSNumber numberWithInt:   p_stats.i_lost_abuffers]       forKey:@"lostAbuffers"];
+    [d setObject:[NSNumber numberWithInt:   p_stats.i_lost_pictures]       forKey:@"lostPictures"];
+    [d setObject:[NSNumber numberWithInt:   p_stats.i_played_abuffers]     forKey:@"playedAbuffers"];
+    [d setObject:[NSNumber numberWithInt:   p_stats.i_read_bytes]          forKey:@"readBytes"];
+    [d setObject:[NSNumber numberWithInt:   p_stats.i_sent_bytes]          forKey:@"sentBytes"];
+    [d setObject:[NSNumber numberWithInt:   p_stats.i_sent_packets]        forKey:@"sentPackets"];
+
+    return d;
+}
+
 NSString *VLCMediaTracksInformationCodec = @"codec"; // NSNumber
 NSString *VLCMediaTracksInformationId    = @"id";    // NSNumber
 NSString *VLCMediaTracksInformationType  = @"type";  // NSString



More information about the vlc-commits mailing list