[vlc-commits] libvlc: add libvlc_MediaParsedStatus event

Thomas Guillem git at videolan.org
Sun Apr 17 07:22:31 CEST 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Apr 14 17:04:04 2016 +0200| [af0e55a02a7a97202390f32244046f119ae0090e] | committer: Thomas Guillem

libvlc: add libvlc_MediaParsedStatus event

This event is always sent after libvlc_media_parse_with_options is successfuly
called.

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

 include/vlc/libvlc_events.h |    5 +++++
 include/vlc/libvlc_media.h  |   21 +++++++++++++++++----
 lib/media.c                 |   22 ++++++++++++++++++++++
 lib/media_internal.h        |    1 +
 4 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index 4da43f6..45ce86e 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -53,6 +53,7 @@ enum libvlc_event_e {
     libvlc_MediaFreed,
     libvlc_MediaStateChanged,
     libvlc_MediaSubItemTreeAdded,
+    libvlc_MediaParsedStatus,
 
     libvlc_MediaPlayerMediaChanged=0x100,
     libvlc_MediaPlayerNothingSpecial,
@@ -154,6 +155,10 @@ typedef struct libvlc_event_t
         {
             libvlc_media_t * item;
         } media_subitemtree_added;
+        struct
+        {
+            int new_status;
+        } media_parsed_status;
 
         /* media instance */
         struct
diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h
index 20b28c6..7f74228 100644
--- a/include/vlc/libvlc_media.h
+++ b/include/vlc/libvlc_media.h
@@ -276,6 +276,19 @@ typedef enum libvlc_media_parse_flag_t
 } libvlc_media_parse_flag_t;
 
 /**
+ * Parse status used sent by libvlc_media_parse_with_options()
+ *
+ * \see libvlc_media_parse_with_options
+ */
+typedef enum libvlc_media_parsed_status_t
+{
+    libvlc_media_parse_init,
+    libvlc_media_parse_skipped,
+    libvlc_media_parse_failed,
+    libvlc_media_parse_done,
+} libvlc_media_parsed_status_t;
+
+/**
  * Callback prototype to open a custom bitstream input media.
  *
  * The same media item can be opened multiple times. Each time, this callback
@@ -665,15 +678,15 @@ libvlc_media_parse_async( libvlc_media_t *p_md );
  * This fetches (local or network) art, meta data and/or tracks information.
  * This method is the extended version of libvlc_media_parse_async().
  *
- * To track when this is over you can listen to libvlc_MediaParsedChanged
- * event. However if this functions returns an error, you will not receive this
- * event.
+ * To track when this is over you can listen to libvlc_MediaParsedStatus
+ * event. However if this functions returns an error, you will not receive any
+ * events.
  *
  * It uses a flag to specify parse options (see libvlc_media_parse_flag_t). All
  * these flags can be combined. By default, media is parsed if it's a local
  * file.
  *
- * \see libvlc_MediaParsedChanged
+ * \see libvlc_MediaParsedStatus
  * \see libvlc_media_get_meta
  * \see libvlc_media_tracks_get
  * \see libvlc_media_parse_flag_t
diff --git a/lib/media.c b/lib/media.c
index f3259ea..c4e799f 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -257,6 +257,26 @@ static void input_item_preparse_ended( const vlc_event_t * p_event,
     VLC_UNUSED( p_event );
     libvlc_media_t * p_md = user_data;
     libvlc_media_list_t *p_subitems = media_get_subitems( p_md, false );
+    libvlc_event_t event;
+
+    event.type = libvlc_MediaParsedStatus;
+
+    vlc_mutex_lock(&p_md->parsed_lock);
+    switch (p_event->u.input_item_preparse_ended.new_status)
+    {
+        case ITEM_PREPARSE_SKIPPED:
+            p_md->parsed_status = libvlc_media_parse_skipped;
+            p_md->has_asked_preparse = false;
+            break;
+        case ITEM_PREPARSE_FAILED:
+            p_md->parsed_status = libvlc_media_parse_failed;
+            break;
+        case ITEM_PREPARSE_DONE:
+            p_md->parsed_status = libvlc_media_parse_done;
+            break;
+    }
+    event.u.media_parsed_status.new_status = p_md->parsed_status;
+    vlc_mutex_unlock(&p_md->parsed_lock);
 
     if( p_subitems != NULL )
     {
@@ -270,6 +290,8 @@ static void input_item_preparse_ended( const vlc_event_t * p_event,
      * libvlc_MediaParsedChanged was sent with a true status. Therefore, send
      * this event if it was not previously sent */
     send_preparsed_event(p_md);
+
+    libvlc_event_send(p_md->p_event_manager, &event);
 }
 
 /**************************************************************************
diff --git a/lib/media_internal.h b/lib/media_internal.h
index 35f06a4..dd12176 100644
--- a/lib/media_internal.h
+++ b/lib/media_internal.h
@@ -45,6 +45,7 @@ struct libvlc_media_t
     vlc_mutex_t parsed_lock;
     vlc_mutex_t subitems_lock;
 
+    int  parsed_status;
     bool is_parsed;
     bool has_asked_preparse;
 };



More information about the vlc-commits mailing list