[vlc-devel] [PATCH 4/4] player: associate tracks with vouts

Thomas Guillem thomas at gllm.fr
Fri May 31 08:48:46 CEST 2019


On Wed, May 29, 2019, at 16:24, Thomas Guillem wrote:
> 
> On Wed, May 29, 2019, at 16:19, Rémi Denis-Courmont wrote:
> > Le keskiviikkona 29. toukokuuta 2019, 16.32.58 EEST Thomas Guillem a écrit :
> > > This will allow API users to clearly identify vouts.
> > > ---
> > >  include/vlc_player.h                              |  4 +++-
> > >  lib/media_player.c                                |  4 +++-
> > >  modules/control/gestures.c                        |  9 ++++++---
> > >  modules/control/hotkeys.c                         |  2 ++
> > >  modules/gui/macosx/playlist/VLCPlayerController.m |  2 ++
> > >  modules/gui/qt/components/player_controller.cpp   |  2 +-
> > >  src/input/player.c                                | 13 +++++++++++--
> > >  test/src/input/player.c                           | 13 ++++++++++---
> > >  8 files changed, 38 insertions(+), 11 deletions(-)
> > > 
> > > diff --git a/include/vlc_player.h b/include/vlc_player.h
> > > index 054c4abae3..17d13fee1e 100644
> > > --- a/include/vlc_player.h
> > > +++ b/include/vlc_player.h
> > > @@ -836,10 +836,12 @@ struct vlc_player_cbs
> > >       * @param player locked player instance
> > >       * @param action started or stopped
> > >       * @param vout vout (can't be NULL)
> > > +     * @param track the track associated with this vout
> > >       * @param data opaque pointer set by vlc_player_AddListener()
> > >       */
> > >      void (*on_vout_changed)(vlc_player_t *player,
> > > -        enum vlc_player_vout_action action, vout_thread_t *vout, void
> > > *data); +        enum vlc_player_vout_action action, vout_thread_t *vout,
> > > +        const struct vlc_player_track *track, void *data);
> > > 
> > >      /**
> > >       * Called when the player is corked
> > > diff --git a/lib/media_player.c b/lib/media_player.c
> > > index fd085c3793..45b506b43d 100644
> > > --- a/lib/media_player.c
> > > +++ b/lib/media_player.c
> > > @@ -401,10 +401,12 @@ on_cork_changed(vlc_player_t *player, unsigned
> > > cork_count, void *data)
> > > 
> > >  static void
> > >  on_vout_changed(vlc_player_t *player, enum vlc_player_vout_action action,
> > > -                vout_thread_t *vout, void *data)
> > > +                vout_thread_t *vout, const struct vlc_player_track *track,
> > > +                void *data)
> > >  {
> > >      (void) action;
> > >      (void) vout;
> > > +    (void) track;
> > > 
> > >      libvlc_media_player_t *mp = data;
> > > 
> > > diff --git a/modules/control/gestures.c b/modules/control/gestures.c
> > > index 608747f43b..2b8b430d8a 100644
> > > --- a/modules/control/gestures.c
> > > +++ b/modules/control/gestures.c
> > > @@ -104,7 +104,9 @@ vlc_module_end ()
> > > 
> > >  static void player_on_vout_changed(vlc_player_t *player,
> > >                                     enum vlc_player_vout_action action,
> > > -                                   vout_thread_t *vout, void *data);
> > > +                                   vout_thread_t *vout,
> > > +                                   const struct vlc_player_track *track,
> > > +                                   void *data);
> > >  static int MovedEvent( vlc_object_t *, char const *,
> > >                         vlc_value_t, vlc_value_t, void * );
> > >  static int ButtonEvent( vlc_object_t *, char const *,
> > > @@ -389,9 +391,10 @@ static int ButtonEvent( vlc_object_t *p_this, char
> > > const *psz_var, static void
> > >  player_on_vout_changed(vlc_player_t *player,
> > >                         enum vlc_player_vout_action action,
> > > -                       vout_thread_t *vout, void *data)
> > > +                       vout_thread_t *vout,
> > > +                       const struct vlc_player_track *track, void *data)
> > >  {
> > > -    VLC_UNUSED(player);
> > > +    VLC_UNUSED(player); VLC_UNUSED(track);
> > >      intf_thread_t *intf = data;
> > >      intf_sys_t *sys = intf->p_sys;
> > >      switch (action)
> > > diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
> > > index b81debb4ea..81f0c92795 100644
> > > --- a/modules/control/hotkeys.c
> > > +++ b/modules/control/hotkeys.c
> > > @@ -1016,8 +1016,10 @@ ViewpointMovedCallback(vlc_object_t *obj, char const
> > > *var, static void
> > >  player_on_vout_changed(vlc_player_t *player,
> > >                         enum vlc_player_vout_action action, vout_thread_t
> > > *vout, +                       const struct vlc_player_track *track,
> > >                         void *data)
> > >  {
> > > +    VLC_UNUSED(track);
> > >      intf_thread_t *intf = data;
> > >      bool vrnav = var_GetBool(vout, "viewpoint-changeable");
> > >      switch (action)
> > > diff --git a/modules/gui/macosx/playlist/VLCPlayerController.m
> > > b/modules/gui/macosx/playlist/VLCPlayerController.m index
> > > 50dd9f5339..6996ad7c1d 100644
> > > --- a/modules/gui/macosx/playlist/VLCPlayerController.m
> > > +++ b/modules/gui/macosx/playlist/VLCPlayerController.m
> > > @@ -429,10 +429,12 @@ static void cb_player_item_meta_changed(vlc_player_t
> > > *p_player, static void cb_player_vout_changed(vlc_player_t *p_player,
> > >                                     enum vlc_player_vout_action action,
> > >                                     vout_thread_t *p_vout,
> > > +                                   const struct vlc_player_track *track,
> > >                                     void *p_data)
> > >  {
> > >      VLC_UNUSED(p_player);
> > >      VLC_UNUSED(p_vout);
> > > +    VLC_UNUSED(track);
> > >      dispatch_async(dispatch_get_main_queue(), ^{
> > >          VLCPlayerController *playerController = (__bridge
> > > VLCPlayerController *)p_data; [playerController voutListUpdated];
> > > diff --git a/modules/gui/qt/components/player_controller.cpp
> > > b/modules/gui/qt/components/player_controller.cpp index
> > > 37580926f3..77467cfb9e 100644
> > > --- a/modules/gui/qt/components/player_controller.cpp
> > > +++ b/modules/gui/qt/components/player_controller.cpp
> > > @@ -713,7 +713,7 @@ static void on_player_subitems_changed(vlc_player_t *,
> > > input_item_t *, input_ite }
> > > 
> > > 
> > > -static void on_player_vout_changed(vlc_player_t *player, enum
> > > vlc_player_vout_action, vout_thread_t *, void *data) +static void
> > > on_player_vout_changed(vlc_player_t *player, enum vlc_player_vout_action,
> > > vout_thread_t *,  const struct vlc_player_track *, void *data) {
> > >      PlayerControllerPrivate* that =
> > > static_cast<PlayerControllerPrivate*>(data); msg_Dbg( that->p_intf,
> > > "on_player_vout_list_changed");
> > > diff --git a/src/input/player.c b/src/input/player.c
> > > index a1c44c5dc0..046b74470d 100644
> > > --- a/src/input/player.c
> > > +++ b/src/input/player.c
> > > @@ -1792,6 +1792,7 @@ vlc_player_input_HandleVoutEvent(struct
> > > vlc_player_input *input, const struct vlc_input_event_vout *ev) {
> > >      assert(ev->vout);
> > > +    assert(ev->id);
> > > 
> > >      static const char osd_vars[][sizeof("deinterlace-mode")] = {
> > >          "aspect-ratio", "autoscale", "crop", "crop-bottom",
> > > @@ -1800,11 +1801,19 @@ vlc_player_input_HandleVoutEvent(struct
> > > vlc_player_input *input, };
> > > 
> > >      vlc_player_t *player = input->player;
> > > +
> > > +    vlc_player_track_vector *vec =
> > > +        vlc_player_input_GetTrackVector(input, vlc_es_id_GetCat(ev->id));
> > > +    struct vlc_player_track *track =
> > > +        vec ? vlc_player_track_vector_FindById(vec, ev->id, NULL) : NULL;
> > > +    if (!track)
> > > +        return;
> > > +
> > >      switch (ev->action)
> > >      {
> > >          case VLC_INPUT_EVENT_VOUT_ADDED:
> > >              vlc_player_SendEvent(player, on_vout_changed,
> > > -                                 VLC_PLAYER_VOUT_STARTED, ev->vout);
> > > +                                 VLC_PLAYER_VOUT_STARTED, ev->vout, track);
> > > 
> > >              /* Register vout callbacks after the vout list event */
> > >              var_AddCallback(ev->vout, "fullscreen",
> > > @@ -1826,7 +1835,7 @@ vlc_player_input_HandleVoutEvent(struct
> > > vlc_player_input *input, vlc_player_VoutOSDCallback, player);
> > > 
> > >              vlc_player_SendEvent(player, on_vout_changed,
> > > -                                 VLC_PLAYER_VOUT_STOPPED, ev->vout);
> > > +                                 VLC_PLAYER_VOUT_STOPPED, ev->vout, track);
> > 
> > I would not expect a track in the stopped event, TBH.
> 
> Why not ? The track (or es_out_t) is always valid in that case. This 
> allow more controls for users, to identify which vout is stopping.
> 
> > How do you foresee the event to change ES<->vout mapping?
> I'm not sure if I understand correctly.
> 
> When playing 2 videos in a raw with the same vout.
> 
> on_vout_changed(VLC_PLAYER_VOUT_STARTED, main_vout, video_es_id_one);
> on_vout_changed(VLC_PLAYER_VOUT_STOPPED, main_vout, video_es_id_one);
> on_vout_changed(VLC_PLAYER_VOUT_STARTED, main_vout, video_es_id_two);
> on_vout_changed(VLC_PLAYER_VOUT_STOPPED, main_vout, video_es_id_two);


Furthermore, the vout will never be strongly attached to a track or vlc_es_id_t.
This means that the information of a vlc_es_id_t linked to a vout will be only valid while the player is locked or until you receive a new vout event.

> 
> 
> > 
> > > break;
> > >          default:
> > >              vlc_assert_unreachable();
> > > diff --git a/test/src/input/player.c b/test/src/input/player.c
> > > index 8406e4352f..20df9d00bc 100644
> > > --- a/test/src/input/player.c
> > > +++ b/test/src/input/player.c
> > > @@ -79,6 +79,7 @@ struct report_vout
> > >  {
> > >      enum vlc_player_vout_action action;
> > >      vout_thread_t *vout;
> > > +    struct vlc_player_track *track;
> > >  };
> > > 
> > >  struct report_media_subitems
> > > @@ -434,14 +435,17 @@ player_on_statistics_changed(vlc_player_t *player,
> > >  static void
> > >  player_on_vout_changed(vlc_player_t *player,
> > >                              enum vlc_player_vout_action action,
> > > -                            vout_thread_t *vout, void *data)
> > > +                            vout_thread_t *vout,
> > > +                            const struct vlc_player_track *track,
> > > +                            void *data)
> > >  {
> > >      struct ctx *ctx = get_ctx(player, data);
> > >      struct report_vout report = {
> > >          .action = action,
> > > -        .vout = vout,
> > > +        .vout = vout_Hold(vout),
> > > +        .track = vlc_player_track_Dup(track),
> > >      };
> > > -    vout_Hold(vout);
> > > +    assert(report.track);
> > >      VEC_PUSH(on_vout_changed, report);
> > >  }
> > > 
> > > @@ -570,7 +574,10 @@ ctx_reset(struct ctx *ctx)
> > >      {
> > >          struct report_vout report;
> > >          FOREACH_VEC(report, on_vout_changed)
> > > +        {
> > >              vout_Release(report.vout);
> > > +            vlc_player_track_Delete(report.track);
> > > +        }
> > >      }
> > > 
> > >      {
> > 
> > 
> > -- 
> > Rémi Denis-Courmont
> > http://www.remlab.net/
> > 
> > 
> > 
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> 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