[vlc-devel] [V3 13/13] lib: Expose a new libvlc_MediaAttachedThumbnailsFound event
Thomas Guillem
thomas at gllm.fr
Wed Nov 18 15:49:29 CET 2020
On Wed, Nov 18, 2020, at 15:23, Hugo Beauzée-Luyssen wrote:
> ---
> include/vlc/libvlc_events.h | 5 +++++
> lib/media.c | 29 +++++++++++++++++++++++++++++
> 2 files changed, 34 insertions(+)
>
> diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
> index 85483555ac..91a6d8fbfa 100644
> --- a/include/vlc/libvlc_events.h
> +++ b/include/vlc/libvlc_events.h
> @@ -89,6 +89,7 @@ enum libvlc_event_e {
> * \see libvlc_media_get_thumbnail()
> */
> libvlc_MediaThumbnailGenerated,
> + libvlc_MediaAttachedThumbnailsFound,
>
> libvlc_MediaPlayerMediaChanged=0x100,
> libvlc_MediaPlayerNothingSpecial,
> @@ -272,6 +273,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..227bba3d0b 100644
> --- a/lib/media.c
> +++ b/lib/media.c
> @@ -332,6 +332,27 @@ 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 );
List can be NULL because of an error alloc. It could also be empty because attachments are not pictures. In that case, you should not send any event.
> +
> + /* 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 +442,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 +462,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 );
> }
>
> /**
> --
> 2.29.2
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list