[vlc-devel] [V2 16/16] lib: media: Expose attached pictures

Hugo Beauzée-Luyssen hugo at beauzee.fr
Fri Nov 13 11:27:32 CET 2020


---
 include/vlc/libvlc_media.h | 11 +++++++++++
 lib/libvlc.sym             |  1 +
 lib/media.c                | 18 ++++++++++++++++++
 3 files changed, 30 insertions(+)

diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h
index 904e265561..48dd704b59 100644
--- a/include/vlc/libvlc_media.h
+++ b/include/vlc/libvlc_media.h
@@ -807,6 +807,17 @@ libvlc_media_thumbnail_request_cancel( libvlc_media_thumbnail_request_t *p_req )
 LIBVLC_API void
 libvlc_media_thumbnail_request_destroy( libvlc_media_thumbnail_request_t *p_req );
 
+/**
+ * Get this media's attached pictures
+ * @param md media descriptor object
+ * @return A picture list, or NULL on error or if the media has no picture attachments
+ *
+ * If this function returns a non NULL list, it must be released by calling
+ * libvlc_picture_list_destroy
+ */
+LIBVLC_API libvlc_picture_list_t*
+libvlc_media_get_attached_pictures( libvlc_media_t *md );
+
 /**
  * Add a slave to the current media.
  *
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index a6034392b2..65de2ff4fc 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -71,6 +71,7 @@ libvlc_media_discoverer_start
 libvlc_media_discoverer_stop
 libvlc_media_duplicate
 libvlc_media_event_manager
+libvlc_media_get_attached_pictures
 libvlc_media_get_codec_description
 libvlc_media_get_duration
 libvlc_media_get_meta
diff --git a/lib/media.c b/lib/media.c
index 7ab98de7c1..2c5a810197 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -1301,3 +1301,21 @@ void libvlc_media_slaves_release( libvlc_media_slave_t **pp_slaves,
     }
     free( pp_slaves );
 }
+
+libvlc_picture_list_t*
+libvlc_media_get_attached_pictures( libvlc_media_t *md )
+{
+    assert( md );
+    input_item_attachment_t **attachments;
+    int res = input_item_GetAttachments( md->p_input_item, &attachments );
+    if( res <= 0 )
+        return NULL;
+    libvlc_picture_list_t *list =
+            libvlc_picture_list_from_attachments( attachments, res );
+
+    for ( int i = 0; i < res; ++i )
+        vlc_input_attachment_Release( attachments[i] );
+    free( attachments );
+
+    return list;
+}
-- 
2.29.2



More information about the vlc-devel mailing list