[vlc-devel] [PATCH 1/2] libvlc: add media_player metadata listener API

Thomas Guillem thomas at gllm.fr
Tue Jan 19 09:28:58 UTC 2021



On Tue, Jan 19, 2021, at 10:16, Romain Vimont wrote:
> On Mon, Jan 18, 2021 at 05:32:14PM +0100, Thomas Guillem wrote:
> > For now, it is only used for propagating loudness measurements.
> > ---
> >  include/vlc/libvlc_media_player.h | 133 ++++++++++++++++++++++++++++++
> >  lib/libvlc.sym                    |   2 +
> >  lib/media_player.c                | 103 +++++++++++++++++++++++
> >  3 files changed, 238 insertions(+)
> > 
> > diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
> > index 8dd85d16049..a0398883c88 100644
> > --- a/include/vlc/libvlc_media_player.h
> > +++ b/include/vlc/libvlc_media_player.h
> > @@ -2608,6 +2608,139 @@ LIBVLC_API int libvlc_media_player_set_role(libvlc_media_player_t *p_mi,
> >  
> >  /** @} audio */
> >  
> > +/** \defgroup libvlc_media_player_metadata_cbs LibVLC media player metadata callbacks
> > + * @{
> > + */
> > +
> > +/**
> > + * Media player metadata listener opaque structure.
> > + *
> > + * This opaque structure is returned by
> > + * libvlc_media_player_add_metadata_listener() and can be used to remove the
> > + * listener via libvlc_media_player_remove_metadata_listener().
> > + */
> > +typedef struct libvlc_media_player_metadata_listener_id
> > +    libvlc_media_player_metadata_listener_id;
> > +
> > +/**
> > + * Audio loudness measurement
> > + */
> > +struct libvlc_audio_loudness
> > +{
> > +    /** Momentary loudness (last 400 ms), in LUFS */
> > +    double loudness_momentary;
> > +    /** Short term loudness (last 3seconds), in LUFS */
> > +    double loudness_shortterm;
> > +    /** Integrated loudness (global), in LUFS */
> > +    double loudness_integrated;
> > +    /** Loudness range, in LU */
> > +    double loudness_range;
> > +    /** True Peak, in dBTP */
> > +    double truepeak;
> > +};
> > +
> > +/**
> > + * Player metadata option
> > + */
> > +enum libvlc_media_player_metadata_option
> > +{
> > +    /**
> > +     * Ask for momentary loudness measurement
> > +     *
> > +     * Very low CPU usage.
> > +     * @see libvlc_media_player_metadata_cbs.on_momentary_loudness_changed
> > +     */
> > +    LIBVLC_MEDIA_PLAYER_METADATA_LOUDNESS_MOMENTARY,
> > +
> > +    /**
> > +     * Ask for all loudness measurements
> > +     *
> > +     * High CPU usage.
> > +     * @see libvlc_media_player_metadata_cbs.on_loudness_changed
> > +     */
> > +    LIBVLC_MEDIA_PLAYER_METADATA_LOUDNESS_FULL,
> > +};
> > +
> > +/**
> > + * Player metadata callbacks
> > + *
> > + * Can be registered with libvlc_media_player_add_metadata_listener().
> > + *
> > + * @warning To avoid deadlocks, users should never call libvlc_media_player_t
> > + * functions from these callbacks.
> > + */
> > +union libvlc_media_player_metadata_cbs
> 
> I would prefer two different listener types than an union (it
> complexifies the API IMO).


It was done like that mainly to avoid adding a new function every time we want to add a metadata option.

> 
> Regards
> _______________________________________________
> 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