[vlc-devel] [RFC PATCH 6/6] lib: add a new libvlc_media_player track selection API

Thomas Guillem thomas at gllm.fr
Thu Jun 4 14:52:44 CEST 2020



On Wed, Jun 3, 2020, at 18:12, Rémi Denis-Courmont wrote:
> Le tiistaina 2. kesäkuuta 2020, 23.02.10 EEST Thomas Guillem a écrit :
> > ---
> >  include/vlc/libvlc_media_player.h |  89 ++++++++++++++++++++++++++
> >  include/vlc/libvlc_media_track.h  |   4 ++
> >  lib/media_internal.h              |  19 ++++++
> >  lib/media_player.c                | 103 ++++++++++++++++++++++++++++++
> >  lib/media_player_internal.h       |   3 +
> >  lib/media_track.c                 |  48 ++++++++++++++
> >  6 files changed, 266 insertions(+)
> > 
> > diff --git a/include/vlc/libvlc_media_player.h
> > b/include/vlc/libvlc_media_player.h index a6f5fbf8e5..ad4ae7e88e 100644
> > --- a/include/vlc/libvlc_media_player.h
> > +++ b/include/vlc/libvlc_media_player.h
> > @@ -1284,6 +1284,95 @@ LIBVLC_API void libvlc_media_player_navigate(
> > libvlc_media_player_t* p_mi, */
> >  LIBVLC_API void libvlc_media_player_set_video_title_display(
> > libvlc_media_player_t *p_mi, libvlc_position_t position, unsigned int
> > timeout );
> > 
> > +/**
> > + * Get the track list for one type
> > + *
> > + * \version LibVLC 4.0.0 and later.
> > + *
> > + * \note You need to call libvlc_media_parse_with_options() or play the
> > media + * at least once before calling this function.  Not doing this will
> > result in + * an empty list.
> > + *
> > + * \note This track list is a snapshot of the current tracks when this
> > function + * is called. If a track is updated after this call, the user
> > will need to call + * this function again to get the updated track.
> > + *
> > + *
> > + * The track list can be used to get track informations and to select
> > specific + * tracks.
> > + *
> > + * \param p_mi the media player
> > + * \param type type of the track list to request
> > + *
> > + * \return a valid libvlc_media_tracklist_t or NULL in case of error, if
> > there + * is no track for a category, the returned list will have a size of
> > 0, delete + * with libvlc_media_tracklist_release()
> > + */
> > +LIBVLC_API libvlc_media_tracklist_t *
> > +libvlc_media_player_get_tracklist( libvlc_media_player_t *p_mi,
> > +                                   libvlc_track_type_t type );
> > +
> > +
> > +/**
> > + * Get the selected track for one type
> > + *
> > + * \version LibVLC 4.0.0 and later.
> > + *
> > + * \warning More than one tracks can be selected for one type. In that
> > case, + * libvlc_media_player_get_tracklist() should be used.
> > + *
> > + * \param p_mi the media player
> > + * \param type type of the selected track
> > + *
> > + * \return a valid track or NULL if there is no selected tracks for this
> > type, + * the returned track can only be used to get track informations
> > (selection is + * not possible) and is valid until the next call to
> > + * libvlc_media_player_get_selected_track()
> 
> What happens to the last track when the media player is deleted?

The track is invalid in that case.

After second though, I am not sure about this particular function. I decided to return a const track because I didn't want to add a libvlc_media_track_release() function to avoid the confusion with libvlc_media_tracklist_release() (indeed, tracks returned by libvlc_media_get_tracklist() should not be released individually (only the list should be released once)).

This API is missing a function to get a track from the id string representation (I will add a "const char *psz_id" in libvlc_media_track_t that will be filled from vlc_es_id_GetStrId()).

It will be possible to get the proper track manually by getting the tracklist, iterating and comparing all tracks id with the one we want. But I would prefer adding the following function:

libvlc_media_track_t *libvlc_media_player_get_track_from_id( liblvc_media_player *mp, const char *id );

In that case, I do need a specific libvlc_media_track_release() function.

> 
> Also weird/long sentence construction.
> 
> Doc aside, the set looks good.

Thanks for your review.

> 
> 
> -- 
> レミ・デニ-クールモン
> http://www.remlab.net/
> 
> 
> 
> _______________________________________________
> 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