Merge branch 'v4-custom-meta' into 'master'

libvlc: add libvlc_media_get_custom_meta

See merge request videolan/vlc!3024
This commit is contained in:
Duncan McNamara 2024-04-28 07:10:55 +00:00
commit 66bdb04944
2 changed files with 32 additions and 0 deletions

View File

@ -463,6 +463,17 @@ LIBVLC_API libvlc_media_t *libvlc_media_duplicate( libvlc_media_t *p_md );
LIBVLC_API char *libvlc_media_get_meta( libvlc_media_t *p_md,
libvlc_meta_t e_meta );
/**
* Read the custom meta of the media
*
* \param p_md the media descriptor
* \param psz_key custom meta key
* \return the media's custom meta
*/
LIBVLC_API char *libvlc_media_get_custom_meta( libvlc_media_t *p_md,
const char *psz_key );
/**
* Set the meta of the media (this function will not save the meta, call
* libvlc_media_save_meta in order to save the meta)

View File

@ -558,6 +558,27 @@ char *libvlc_media_get_meta( libvlc_media_t *p_md, libvlc_meta_t e_meta )
return psz_meta;
}
// Getter for custom meta information
char *libvlc_media_get_custom_meta( libvlc_media_t *p_md, const char *psz_key )
{
assert( p_md );
input_item_t *item = p_md->p_input_item;
vlc_mutex_lock( &item->lock );
if ( psz_key != NULL && item != NULL && item->p_meta != NULL)
{
const char *psz_meta = vlc_meta_GetExtra(item->p_meta, psz_key );
if ( psz_meta != NULL )
{
vlc_mutex_unlock( &item->lock );
return strdup( psz_meta );
}
}
vlc_mutex_unlock( &item->lock );
return NULL;
}
// Set the meta of the media
void libvlc_media_set_meta( libvlc_media_t *p_md, libvlc_meta_t e_meta, const char *psz_value )
{