libvlc: libvlc_MediaSubItemTreeAdded event type added
authorSergey Radionov <rsatom@gmail.com>
Sun, 1 Sep 2013 14:00:18 +0000 (21:00 +0700)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 2 Sep 2013 15:42:02 +0000 (18:42 +0300)
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
include/vlc/libvlc_events.h
lib/event.c
lib/media.c

index 2cfedbf..ae1a94b 100644 (file)
@@ -52,6 +52,7 @@ enum libvlc_event_e {
     libvlc_MediaParsedChanged,
     libvlc_MediaFreed,
     libvlc_MediaStateChanged,
+    libvlc_MediaSubItemTreeAdded,
 
     libvlc_MediaPlayerMediaChanged=0x100,
     libvlc_MediaPlayerNothingSpecial,
@@ -137,6 +138,10 @@ typedef struct libvlc_event_t
         {
             libvlc_state_t new_state;
         } media_state_changed;
+        struct
+        {
+            libvlc_media_t * item;
+        } media_subitemtree_added;
 
         /* media instance */
         struct
index c71a48a..87f7d12 100644 (file)
@@ -259,6 +259,7 @@ static const event_name_t event_list[] = {
     DEF(MediaParsedChanged)
     DEF(MediaFreed)
     DEF(MediaStateChanged)
+    DEF(MediaSubItemTreeAdded)
 
     DEF(MediaPlayerMediaChanged)
     DEF(MediaPlayerNothingSpecial)
index 593f5c6..7acfb69 100644 (file)
@@ -119,6 +119,23 @@ static void input_item_subitem_added( const vlc_event_t *p_event,
     libvlc_media_release( p_md_child );
 }
 
+/**************************************************************************
+ * input_item_subitemtree_added (Private) (vlc event Callback)
+ **************************************************************************/
+static void input_item_subitemtree_added( const vlc_event_t * p_event,
+                                          void * user_data )
+{
+    libvlc_media_t * p_md = user_data;
+    libvlc_event_t event;
+
+    /* Construct the event */
+    event.type = libvlc_MediaSubItemTreeAdded;
+    event.u.media_subitemtree_added.item = p_md;
+
+    /* Send the event */
+    libvlc_event_send( p_md->p_event_manager, &event );
+}
+
 /**************************************************************************
  * input_item_meta_changed (Private) (vlc event Callback)
  **************************************************************************/
@@ -201,6 +218,10 @@ static void install_input_item_observer( libvlc_media_t *p_md )
                       vlc_InputItemPreparsedChanged,
                       input_item_preparsed_changed,
                       p_md );
+    vlc_event_attach( &p_md->p_input_item->event_manager,
+                      vlc_InputItemSubItemTreeAdded,
+                      input_item_subitemtree_added,
+                      p_md );
 }
 
 /**************************************************************************
@@ -224,6 +245,10 @@ static void uninstall_input_item_observer( libvlc_media_t *p_md )
                       vlc_InputItemPreparsedChanged,
                       input_item_preparsed_changed,
                       p_md );
+    vlc_event_detach( &p_md->p_input_item->event_manager,
+                      vlc_InputItemSubItemTreeAdded,
+                      input_item_subitemtree_added,
+                      p_md );
 }
 
 /**************************************************************************
@@ -277,6 +302,7 @@ libvlc_media_t * libvlc_media_new_from_input_item(
     libvlc_event_manager_register_event_type(em, libvlc_MediaDurationChanged);
     libvlc_event_manager_register_event_type(em, libvlc_MediaStateChanged);
     libvlc_event_manager_register_event_type(em, libvlc_MediaParsedChanged);
+    libvlc_event_manager_register_event_type(em, libvlc_MediaSubItemTreeAdded);
 
     vlc_gc_incref( p_md->p_input_item );