[vlc-devel] commit: libvlc: add a function get the statistics about the current media ( also add a structure to expose this values). ( Rémi Duraffort )

git version control git at videolan.org
Fri Nov 20 12:17:53 CET 2009


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Fri Nov 20 12:17:13 2009 +0100| [41b54a0abc868480e67e09f9ce5db348771a4742] | committer: Rémi Duraffort 

libvlc: add a function get the statistics about the current media (also add a structure to expose this values).
All statistics are not exported, only the most used are exported.

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

 include/vlc/libvlc_media.h |   48 ++++++++++++++++++++++++++++++++++++++++++++
 src/control/media.c        |   35 ++++++++++++++++++++++++++++++++
 src/libvlc.sym             |    1 +
 3 files changed, 84 insertions(+), 0 deletions(-)

diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h
index c3cd38d..88857c4 100644
--- a/include/vlc/libvlc_media.h
+++ b/include/vlc/libvlc_media.h
@@ -99,6 +99,44 @@ typedef enum libvlc_media_option_t
     libvlc_media_option_unique = 0x100
 } libvlc_media_option_t;
 
+
+/** defgroup libvlc_media_stats_t libvlc_media_stats_t
+ * \ingroup libvlc_media
+ * LibVLC Media statistics
+ * @{
+ */
+typedef struct libvlc_media_stats_t
+{
+    /* Input */
+    int         i_read_bytes;
+    float       f_input_bitrate;
+
+    /* Demux */
+    int         i_demux_read_bytes;
+    float       f_demux_bitrate;
+    int         i_demux_corrupted;
+    int         i_demux_discontinuity;
+
+    /* Decoders */
+    int         i_decoded_video;
+    int         i_decoded_audio;
+
+    /* Video Output */
+    int         i_displayed_pictures;
+    int         i_lost_pictures;
+
+    /* Audio output */
+    int         i_played_abuffers;
+    int         i_lost_abuffers;
+
+    /* Stream output */
+    int         i_sent_packets;
+    int         i_sent_bytes;
+    float       f_send_bitrate;
+} libvlc_media_stats_t;
+/** @}*/
+
+
 /**
  * Create a media with the given MRL.
  *
@@ -225,6 +263,16 @@ VLC_PUBLIC_API libvlc_state_t libvlc_media_get_state(
 
 
 /**
+ * get the current statistics about the media
+ * @param p_md: media descriptor object
+ * @param p_stats: structure that contain the statistics about the media
+ *                 (this structure must be allocated by the caller)
+ * @return true if the statistics are available, false otherwise
+ */
+VLC_PUBLIC_API int libvlc_media_get_stats( libvlc_media_t *p_md,
+                                           libvlc_media_stats_t *p_stats );
+
+/**
  * Get subitems of media descriptor object. This will increment
  * the reference count of supplied media descriptor object. Use
  * libvlc_media_list_release() to decrement the reference counting.
diff --git a/src/control/media.c b/src/control/media.c
index 9a893b0..9dd3b97 100644
--- a/src/control/media.c
+++ b/src/control/media.c
@@ -514,6 +514,41 @@ libvlc_media_subitems( libvlc_media_t * p_md )
 }
 
 /**************************************************************************
+ * Setter for state information (LibVLC Internal)
+ **************************************************************************/
+int libvlc_media_get_stats( libvlc_media_t *p_md,
+                            libvlc_media_stats_t *p_stats )
+{
+    if( !p_md->p_input_item )
+        return false;
+
+    input_stats_t *p_itm_stats = p_md->p_input_item->p_stats;
+    vlc_mutex_lock( &p_itm_stats->lock );
+    p_stats->i_read_bytes = p_itm_stats->i_read_bytes;
+    p_stats->f_input_bitrate = p_itm_stats->f_input_bitrate;
+
+    p_stats->i_demux_read_bytes = p_itm_stats->i_demux_read_bytes;
+    p_stats->f_demux_bitrate = p_itm_stats->f_demux_bitrate;
+    p_stats->i_demux_corrupted = p_itm_stats->i_demux_corrupted;
+    p_stats->i_demux_discontinuity = p_itm_stats->i_demux_discontinuity;
+
+    p_stats->i_decoded_video = p_itm_stats->i_decoded_video;
+    p_stats->i_decoded_audio = p_itm_stats->i_decoded_audio;
+
+    p_stats->i_displayed_pictures = p_itm_stats->i_displayed_pictures;
+    p_stats->i_lost_pictures = p_itm_stats->i_lost_pictures;
+
+    p_stats->i_played_abuffers = p_itm_stats->i_played_abuffers;
+    p_stats->i_lost_abuffers = p_itm_stats->i_lost_abuffers;
+
+    p_stats->i_sent_packets = p_itm_stats->i_sent_packets;
+    p_stats->i_sent_bytes = p_itm_stats->i_sent_bytes;
+    p_stats->f_send_bitrate = p_itm_stats->f_send_bitrate;
+    vlc_mutex_unlock( &p_itm_stats->lock );
+    return true;
+}
+
+/**************************************************************************
  * event_manager
  **************************************************************************/
 libvlc_event_manager_t *
diff --git a/src/libvlc.sym b/src/libvlc.sym
index fa316d0..7cdfded 100644
--- a/src/libvlc.sym
+++ b/src/libvlc.sym
@@ -64,6 +64,7 @@ libvlc_media_get_duration
 libvlc_media_get_meta
 libvlc_media_get_mrl
 libvlc_media_get_state
+libvlc_media_get_stats
 libvlc_media_get_user_data
 libvlc_media_is_preparsed
 libvlc_media_library_load




More information about the vlc-devel mailing list