Browse Source

VLCMedia: add individual getters for all stats

Felix Paul Kühne 12 years ago
parent
commit
2d1b7b4200
3 changed files with 253 additions and 0 deletions
  1. 85 0
      Headers/Public/VLCMedia.h
  2. 3 0
      NEWS
  3. 165 0
      Sources/VLCMedia.m

+ 85 - 0
Headers/Public/VLCMedia.h

@@ -398,4 +398,89 @@ extern NSString *VLCMediaTracksInformationTypeUnknown;
  */
  */
 - (NSDictionary*) stats;
 - (NSDictionary*) stats;
 
 
+#pragma mark - individual stats
+
+/**
+ * returns the number of bytes read by the current input module
+ * \return a NSInteger with the raw number of bytes
+ */
+- (NSInteger)numberOfReadBytesOnInput;
+/**
+ * returns the current input bitrate. may be 0 if the buffer is full
+ * \return a float of the current input bitrate
+ */
+- (float)inputBitrate;
+
+/**
+ * returns the number of bytes read by the current demux module
+ * \return a NSInteger with the raw number of bytes
+ */
+- (NSInteger)numberOfReadBytesOnDemux;
+/**
+ * returns the current demux bitrate. may be 0 if the buffer is empty
+ * \return a float of the current demux bitrate
+ */
+- (float)demuxBitrate;
+
+/**
+ * returns the total number of decoded video blocks in the current media session
+ * \return a NSInteger with the total number of decoded blocks
+ */
+- (NSInteger)numberOfDecodedVideoBlocks;
+/**
+ * returns the total number of decoded audio blocks in the current media session
+ * \return a NSInteger with the total number of decoded blocks
+ */
+- (NSInteger)numberOfDecodedAudioBlocks;
+
+/**
+ * returns the total number of displayed pictures during the current media session
+ * \return a NSInteger with the total number of displayed pictures
+ */
+- (NSInteger)numberOfDisplayedPictures;
+/**
+ * returns the total number of pictures lost during the current media session
+ * \return a NSInteger with the total number of lost pictures
+ */
+- (NSInteger)numberOfLostPictures;
+
+/**
+ * returns the total number of played audio buffers during the current media session
+ * \return a NSInteger with the total number of played audio buffers
+ */
+- (NSInteger)numberOfPlayedAudioBuffers;
+/**
+ * returns the total number of audio buffers lost during the current media session
+ * \return a NSInteger with the total number of displayed pictures
+ */
+- (NSInteger)numberOfLostAudioBuffers;
+
+/**
+ * returns the total number of packets sent during the current media session
+ * \return a NSInteger with the total number of sent packets
+ */
+- (NSInteger)numberOfSentPackets;
+/**
+ * returns the total number of raw bytes sent during the current media session
+ * \return a NSInteger with the total number of sent bytes
+ */
+- (NSInteger)numberOfSentBytes;
+/**
+ * returns the current bitrate of sent bytes
+ * \return a float of the current bitrate of sent bits
+ */
+- (float)streamOutputBitrate;
+/**
+ * returns the total number of corrupted data packets during current sout session
+ * \note value is 0 on non-stream-output operations
+ * \return a NSInteger with the total number of corrupted data packets
+ */
+- (NSInteger)numberOfCorruptedDataPackets;
+/**
+ * returns the total number of discontinuties during current sout session
+ * \note value is 0 on non-stream-output operations
+ * \return a NSInteger with the total number of discontinuties
+ */
+- (NSInteger)numberOfDiscontinuties;
+
 @end
 @end

+ 3 - 0
NEWS

@@ -15,6 +15,9 @@ New APIs:
   - added (BOOL)isMediaSizeSuitableForDevice to let VLCKit determine whether the
   - added (BOOL)isMediaSizeSuitableForDevice to let VLCKit determine whether the
     current media is considered to be suitable for the current device or
     current media is considered to be suitable for the current device or
     playback is discouraged. Will always return true on OS X devices.
     playback is discouraged. Will always return true on OS X devices.
+  - added individual getters for all statistic values, so client application can
+    fetch single values instead of having to process a NSDictionary with all the
+    available values. The old API is still available and will stay.
 - VLCMediaPlayer:
 - VLCMediaPlayer:
   - added support to enable, switch and disable video tracks
   - added support to enable, switch and disable video tracks
   - added setter/getter for SPU and audio delays
   - added setter/getter for SPU and audio delays

+ 165 - 0
Sources/VLCMedia.m

@@ -352,6 +352,171 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
     return d;
     return d;
 }
 }
 
 
+- (NSInteger)numberOfReadBytesOnInput
+{
+    if (!p_md)
+        return 0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.i_read_bytes;
+}
+
+- (float)inputBitrate
+{
+    if (!p_md)
+        return .0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.f_input_bitrate;
+}
+
+- (NSInteger)numberOfReadBytesOnDemux
+{
+    if (!p_md)
+        return 0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.i_demux_read_bytes;
+}
+
+- (float)demuxBitrate
+{
+    if (!p_md)
+        return .0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.f_demux_bitrate;
+}
+
+- (NSInteger)numberOfDecodedVideoBlocks
+{
+    if (!p_md)
+        return 0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.i_decoded_video;
+}
+
+- (NSInteger)numberOfDecodedAudioBlocks
+{
+    if (!p_md)
+        return 0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.i_decoded_audio;
+}
+
+- (NSInteger)numberOfDisplayedPictures
+{
+    if (!p_md)
+        return 0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.i_displayed_pictures;
+}
+
+- (NSInteger)numberOfLostPictures
+{
+    if (!p_md)
+        return 0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.i_lost_pictures;
+}
+
+- (NSInteger)numberOfPlayedAudioBuffers
+{
+    if (!p_md)
+        return 0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.i_played_abuffers;
+}
+
+- (NSInteger)numberOfLostAudioBuffers
+{
+    if (!p_md)
+        return 0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.i_lost_abuffers;
+}
+
+- (NSInteger)numberOfSentPackets
+{
+    if (!p_md)
+        return 0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.i_sent_packets;
+}
+
+- (NSInteger)numberOfSentBytes
+{
+    if (!p_md)
+        return 0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.i_sent_bytes;
+}
+
+- (float)streamOutputBitrate
+{
+    if (!p_md)
+        return .0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.f_send_bitrate;
+}
+
+- (NSInteger)numberOfCorruptedDataPackets
+{
+    if (!p_md)
+        return 0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.i_demux_corrupted;
+}
+
+- (NSInteger)numberOfDiscontinuties
+{
+    if (!p_md)
+        return 0;
+
+    libvlc_media_stats_t p_stats;
+    libvlc_media_get_stats(p_md, &p_stats);
+
+    return p_stats.i_demux_discontinuity;
+}
+
 NSString *VLCMediaTracksInformationCodec = @"codec"; // NSNumber
 NSString *VLCMediaTracksInformationCodec = @"codec"; // NSNumber
 NSString *VLCMediaTracksInformationId    = @"id";    // NSNumber
 NSString *VLCMediaTracksInformationId    = @"id";    // NSNumber
 NSString *VLCMediaTracksInformationType  = @"type";  // NSString
 NSString *VLCMediaTracksInformationType  = @"type";  // NSString