[vlc-commits] player: get vout and vout_order from VIDEO/SPU es_ids

Thomas Guillem git at videolan.org
Tue Jun 25 20:55:30 CEST 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Jun 14 15:46:16 2019 +0200| [c896210b006825278adde0c3119f42e741330a8e] | committer: Thomas Guillem

player: get vout and vout_order from VIDEO/SPU es_ids

vlc_player_GetVoutFromEsId() can now return the vout used by an SPU es_id.
It also returns the vout order.

The on_vout_changed callback is also used for SPU es_ids. Users could check the
category of the es_id to know if the vout is attached to a VIDEO es or an SPU
one.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c896210b006825278adde0c3119f42e741330a8e
---

 include/vlc_player.h                              |  9 ++++---
 lib/media_player.c                                |  9 ++++---
 modules/control/gestures.c                        |  8 +++++-
 modules/control/hotkeys.c                         |  8 ++++--
 modules/gui/macosx/playlist/VLCPlayerController.m |  7 ++++-
 modules/gui/qt/components/player_controller.cpp   | 12 ++++++++-
 src/input/player.c                                | 31 ++++++++++++++++++-----
 test/src/input/player.c                           |  5 +++-
 8 files changed, 70 insertions(+), 19 deletions(-)

diff --git a/include/vlc_player.h b/include/vlc_player.h
index e5c165234f..df5b75b045 100644
--- a/include/vlc_player.h
+++ b/include/vlc_player.h
@@ -850,12 +850,13 @@ struct vlc_player_cbs
      * @param player locked player instance
      * @param action started or stopped
      * @param vout vout (can't be NULL)
+     * @param order vout order
      * @param es_id the ES id 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,
-        vlc_es_id_t *es_id, void *data);
+        enum vlc_vout_order order, vlc_es_id_t *es_id, void *data);
 
     /**
      * Called when the player is corked
@@ -1703,11 +1704,13 @@ vlc_player_GetTrack(vlc_player_t *player, vlc_es_id_t *es_id);
  * @param player locked player instance
  * @param id an ES ID (retrieved from vlc_player_cbs.on_track_list_changed or
  * vlc_player_GetTrackAt())
+ * @param order if not null, the order of the vout
  * @return a valid vout or NULL (if the track is disabled, it it's not a video
- * track, or if the vout failed to start)
+ * or spu track, or if the vout failed to start)
  */
 VLC_API vout_thread_t *
-vlc_player_GetEsIdVout(vlc_player_t *player, vlc_es_id_t *es_id);
+vlc_player_GetEsIdVout(vlc_player_t *player, vlc_es_id_t *es_id,
+                       enum vlc_vout_order *order);
 
 /**
  * Get the ES identifier of a video output
diff --git a/lib/media_player.c b/lib/media_player.c
index 667ec517d0..cb29d76ebf 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -400,12 +400,15 @@ 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, vlc_es_id_t *es_id,
-                void *data)
+                vout_thread_t *vout, enum vlc_vout_order order,
+                vlc_es_id_t *es_id, void *data)
 {
     (void) action;
     (void) vout;
-    (void) es_id;
+    (void) order;
+
+    if (vlc_es_id_GetCat(es_id) != VIDEO_ES)
+        return;
 
     libvlc_media_player_t *mp = data;
 
diff --git a/modules/control/gestures.c b/modules/control/gestures.c
index 804e6df2eb..668be6936a 100644
--- a/modules/control/gestures.c
+++ b/modules/control/gestures.c
@@ -105,6 +105,7 @@ vlc_module_end ()
 static void player_on_vout_changed(vlc_player_t *player,
                                    enum vlc_player_vout_action action,
                                    vout_thread_t *vout,
+                                   enum vlc_vout_order order,
                                    vlc_es_id_t *es_id,
                                    void *data);
 static int MovedEvent( vlc_object_t *, char const *,
@@ -392,11 +393,16 @@ static void
 player_on_vout_changed(vlc_player_t *player,
                        enum vlc_player_vout_action action,
                        vout_thread_t *vout,
+                       enum vlc_vout_order order,
                        vlc_es_id_t *es_id, void *data)
 {
-    VLC_UNUSED(player); VLC_UNUSED(es_id);
+    VLC_UNUSED(player); VLC_UNUSED(order);
     intf_thread_t *intf = data;
     intf_sys_t *sys = intf->p_sys;
+
+    if (vlc_es_id_GetCat(es_id) != VIDEO_ES)
+        return;
+
     switch (action)
     {
         case VLC_PLAYER_VOUT_STARTED:
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 35d8557038..6d38b310ed 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -1053,11 +1053,15 @@ 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,
-                       vlc_es_id_t *es_id,
+                       enum vlc_vout_order order, vlc_es_id_t *es_id,
                        void *data)
 {
-    VLC_UNUSED(es_id);
+    VLC_UNUSED(order);
     intf_thread_t *intf = data;
+
+    if (vlc_es_id_GetCat(es_id) != VIDEO_ES)
+        return;
+
     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 a1fae94533..5c966aacd5 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.m
+++ b/modules/gui/macosx/playlist/VLCPlayerController.m
@@ -434,12 +434,17 @@ 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,
+                                   enum vlc_vout_order order,
                                    vlc_es_id_t *es_id,
                                    void *p_data)
 {
     VLC_UNUSED(p_player);
     VLC_UNUSED(p_vout);
-    VLC_UNUSED(es_id);
+    VLC_UNUSED(order);
+
+    if (vlc_es_id_GetCat(es_id) != VIDEO_ES)
+        return;
+
     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 553d461d41..c19b927d45 100644
--- a/modules/gui/qt/components/player_controller.cpp
+++ b/modules/gui/qt/components/player_controller.cpp
@@ -710,11 +710,16 @@ 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 *, vlc_es_id_t *, void *data)
+static void on_player_vout_changed(vlc_player_t *player, enum vlc_player_vout_action,
+    vout_thread_t *, enum vlc_vout_order, vlc_es_id_t *es_id, void *data)
 {
     PlayerControllerPrivate* that = static_cast<PlayerControllerPrivate*>(data);
     msg_Dbg( that->p_intf, "on_player_vout_list_changed");
 
+    switch (vlc_es_id_GetCat(es_id))
+    {
+        case VIDEO_ES:
+        {
     //player is locked within callbacks*
     size_t i_vout = 0;
     vout_thread_t **vouts = vlc_player_vout_HoldAll(player, &i_vout);
@@ -729,6 +734,11 @@ static void on_player_vout_changed(vlc_player_t *player, enum vlc_player_vout_ac
     that->callAsync([that,voutsPtr,i_vout] () {
         that->UpdateVouts(voutsPtr.get(), i_vout);
     });
+            break;
+        }
+        default:
+            break;
+    }
 }
 
 //player vout callbacks
diff --git a/src/input/player.c b/src/input/player.c
index b7819d5ef1..4f0d3e727a 100644
--- a/src/input/player.c
+++ b/src/input/player.c
@@ -59,6 +59,8 @@ struct vlc_player_track_priv
     struct vlc_player_track t;
     vout_thread_t *vout; /* weak reference */
     vlc_tick_t delay;
+    /* only valid if selected and if category is VIDEO_ES or SPU_ES */
+    enum vlc_vout_order vout_order;
 };
 
 typedef struct VLC_VECTOR(struct vlc_player_program *)
@@ -423,6 +425,8 @@ vlc_player_track_New(vlc_es_id_t *id, const char *name, const es_format_t *fmt)
     struct vlc_player_track *track = &trackpriv->t;
 
     trackpriv->delay = INT64_MAX;
+    trackpriv->vout = NULL;
+    trackpriv->vout_order = VLC_VOUT_ORDER_NONE;
 
     track->name = strdup(name);
     if (!track->name)
@@ -1327,11 +1331,18 @@ vlc_player_GetTrack(vlc_player_t *player, vlc_es_id_t *id)
 }
 
 vout_thread_t *
-vlc_player_GetEsIdVout(vlc_player_t *player, vlc_es_id_t *es_id)
+vlc_player_GetEsIdVout(vlc_player_t *player, vlc_es_id_t *es_id,
+                       enum vlc_vout_order *order)
 {
     struct vlc_player_track_priv *trackpriv =
         vlc_player_GetPrivTrack(player, es_id);
-    return trackpriv ? trackpriv->vout : NULL;
+    if (trackpriv)
+    {
+        if (order)
+            *order = trackpriv->vout_order;
+        return trackpriv->vout;
+    }
+    return NULL;
 }
 
 vlc_es_id_t *
@@ -1343,7 +1354,7 @@ vlc_player_GetEsIdFromVout(vlc_player_t *player, vout_thread_t *vout)
         return NULL;
 
     static const enum es_format_category_e cats[] = {
-        VIDEO_ES, AUDIO_ES /* for visualisation filters */
+        VIDEO_ES, SPU_ES, AUDIO_ES /* for visualisation filters */
     };
     for (size_t i = 0; i < ARRAY_SIZE(cats); ++i)
     {
@@ -2060,16 +2071,17 @@ vlc_player_input_HandleVoutEvent(struct vlc_player_input *input,
         return;
 
     const bool is_video_es = trackpriv->t.fmt.i_cat == VIDEO_ES;
-    if (!is_video_es) /* XXX: will be removed on next commits */
-        return;
 
     switch (ev->action)
     {
         case VLC_INPUT_EVENT_VOUT_ADDED:
             trackpriv->vout = ev->vout;
             vlc_player_SendEvent(player, on_vout_changed,
-                                 VLC_PLAYER_VOUT_STARTED, ev->vout, ev->id);
+                                 VLC_PLAYER_VOUT_STARTED, ev->vout,
+                                 ev->order, ev->id);
 
+            if (is_video_es)
+            {
             /* Register vout callbacks after the vout list event */
             var_AddCallback(ev->vout, "fullscreen",
                             vlc_player_VoutCallback, player);
@@ -2078,8 +2090,11 @@ vlc_player_input_HandleVoutEvent(struct vlc_player_input *input,
             for (size_t i = 0; i < ARRAY_SIZE(osd_vars); ++i)
                 var_AddCallback(ev->vout, osd_vars[i],
                                 vlc_player_VoutOSDCallback, player);
+            }
             break;
         case VLC_INPUT_EVENT_VOUT_DELETED:
+            if (is_video_es)
+            {
             /* Un-register vout callbacks before the vout list event */
             var_DelCallback(ev->vout, "fullscreen",
                             vlc_player_VoutCallback, player);
@@ -2088,10 +2103,12 @@ vlc_player_input_HandleVoutEvent(struct vlc_player_input *input,
             for (size_t i = 0; i < ARRAY_SIZE(osd_vars); ++i)
                 var_DelCallback(ev->vout, osd_vars[i],
                                 vlc_player_VoutOSDCallback, player);
+            }
 
             trackpriv->vout = NULL;
             vlc_player_SendEvent(player, on_vout_changed,
-                                 VLC_PLAYER_VOUT_STOPPED, ev->vout, ev->id);
+                                 VLC_PLAYER_VOUT_STOPPED, ev->vout,
+                                 VLC_VOUT_ORDER_NONE, ev->id);
             break;
         default:
             vlc_assert_unreachable();
diff --git a/test/src/input/player.c b/test/src/input/player.c
index 012f1990aa..de916e7a8a 100644
--- a/test/src/input/player.c
+++ b/test/src/input/player.c
@@ -85,6 +85,7 @@ struct report_vout
 {
     enum vlc_player_vout_action action;
     vout_thread_t *vout;
+    enum vlc_vout_order order;
     vlc_es_id_t *es_id;
 };
 
@@ -437,12 +438,14 @@ 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, vlc_es_id_t *es_id, void *data)
+                       vout_thread_t *vout, enum vlc_vout_order order,
+                       vlc_es_id_t *es_id, void *data)
 {
     struct ctx *ctx = get_ctx(player, data);
     struct report_vout report = {
         .action = action,
         .vout = vout_Hold(vout),
+        .order = order,
         .es_id = vlc_es_id_Hold(es_id),
     };
     assert(report.es_id);



More information about the vlc-commits mailing list