[vlc-commits] lib: Expose a new libvlc_MediaAttachedThumbnailsFound event

Hugo Beauzée-Luyssen git at videolan.org
Thu Nov 19 11:00:29 CET 2020


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed Nov 18 14:54:41 2020 +0100| [235b7212bd0d98a46ae46711479aeb426fd5ce35] | committer: Hugo Beauzée-Luyssen

lib: Expose a new libvlc_MediaAttachedThumbnailsFound event

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

 include/vlc/libvlc_events.h | 10 ++++++++++
 lib/media.c                 | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index 85483555ac..826a0f4562 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -89,6 +89,12 @@ enum libvlc_event_e {
      * \see libvlc_media_get_thumbnail()
      */
     libvlc_MediaThumbnailGenerated,
+    /**
+     * One or more embedded thumbnails were found during the media preparsing
+     * The user can hold these picture(s) using libvlc_picture_retain if they
+     * wish to use them
+     */
+    libvlc_MediaAttachedThumbnailsFound,
 
     libvlc_MediaPlayerMediaChanged=0x100,
     libvlc_MediaPlayerNothingSpecial,
@@ -272,6 +278,10 @@ typedef struct libvlc_event_t
         {
             libvlc_media_t * item;
         } media_subitemtree_added;
+        struct
+        {
+            libvlc_picture_list_t* thumbnails;
+        } media_attached_thumbnails_found;
 
         /* media instance */
         struct
diff --git a/lib/media.c b/lib/media.c
index 346809f93b..dd4faf0066 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -332,6 +332,33 @@ static void input_item_duration_changed( const vlc_event_t *p_event,
     libvlc_event_send( &p_md->event_manager, &event );
 }
 
+static void input_item_attachments_found( const vlc_event_t *p_event,
+                                                 void * user_data )
+{
+    libvlc_media_t * p_md = user_data;
+    libvlc_event_t event;
+
+    libvlc_picture_list_t* list = libvlc_picture_list_from_attachments(
+                p_event->u.input_item_attachments_found.attachments,
+                p_event->u.input_item_attachments_found.count );
+    if( !list )
+        return;
+    if( !libvlc_picture_list_count(list) )
+    {
+        libvlc_picture_list_destroy( list );
+        return;
+    }
+
+    /* Construct the event */
+    event.type = libvlc_MediaAttachedThumbnailsFound;
+    event.u.media_attached_thumbnails_found.thumbnails = list;
+
+    /* Send the event */
+    libvlc_event_send( &p_md->event_manager, &event );
+
+    libvlc_picture_list_destroy( list );
+}
+
 static void send_parsed_changed( libvlc_media_t *p_md,
                                  libvlc_media_parsed_status_t new_status )
 {
@@ -421,6 +448,10 @@ static void install_input_item_observer( libvlc_media_t *p_md )
                       vlc_InputItemDurationChanged,
                       input_item_duration_changed,
                       p_md );
+    vlc_event_attach( &p_md->p_input_item->event_manager,
+                      vlc_InputItemAttachmentsFound,
+                      input_item_attachments_found,
+                      p_md );
 }
 
 /**
@@ -437,6 +468,10 @@ static void uninstall_input_item_observer( libvlc_media_t *p_md )
                       vlc_InputItemDurationChanged,
                       input_item_duration_changed,
                       p_md );
+    vlc_event_detach( &p_md->p_input_item->event_manager,
+                      vlc_InputItemAttachmentsFound,
+                      input_item_attachments_found,
+                      p_md );
 }
 
 /**



More information about the vlc-commits mailing list