[vlc-commits] player: associate ES ids in vout_changed event

Thomas Guillem git at videolan.org
Mon Jun 3 16:16:14 CEST 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed May 29 15:31:44 2019 +0200| [42e8a35e763f2d72780cc6541e44b64f22f30d6e] | committer: Thomas Guillem

player: associate ES ids in vout_changed event

This will allow API users to clearly identify vouts.

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

 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 |  6 ++++--
 modules/gui/qt/components/player_controller.cpp   |  2 +-
 src/input/player.c                                |  5 +++--
 test/src/input/player.c                           | 13 +++++++++----
 8 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/include/vlc_player.h b/include/vlc_player.h
index 054c4abae3..3d924e927d 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 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, void *data);
+        enum vlc_player_vout_action action, vout_thread_t *vout,
+        vlc_es_id_t *es_id, void *data);
 
     /**
      * Called when the player is corked
diff --git a/lib/media_player.c b/lib/media_player.c
index fd085c3793..ad61bdb779 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, vlc_es_id_t *es_id,
+                void *data)
 {
     (void) action;
     (void) vout;
+    (void) es_id;
 
     libvlc_media_player_t *mp = data;
 
diff --git a/modules/control/gestures.c b/modules/control/gestures.c
index 608747f43b..804e6df2eb 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,
+                                   vlc_es_id_t *es_id,
+                                   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,
+                       vlc_es_id_t *es_id, void *data)
 {
-    VLC_UNUSED(player);
+    VLC_UNUSED(player); VLC_UNUSED(es_id);
     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..a3d74cfd57 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,
+                       vlc_es_id_t *es_id,
                        void *data)
 {
+    VLC_UNUSED(es_id);
     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 268eecf250..816ac2ade1 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.m
+++ b/modules/gui/macosx/playlist/VLCPlayerController.m
@@ -348,10 +348,10 @@ static void cb_player_stats_changed(vlc_player_t *p_player,
 
 static void cb_player_track_list_changed(vlc_player_t *p_player,
                                          enum vlc_player_list_action action,
-                                         const struct vlc_player_track *track,
+                                         vlc_es_id_t *es_id,
                                          void *p_data)
 {
-    VLC_UNUSED(p_player); VLC_UNUSED(action); VLC_UNUSED(track);
+    VLC_UNUSED(p_player); VLC_UNUSED(action); VLC_UNUSED(es_id);
     dispatch_async(dispatch_get_main_queue(), ^{
         VLCPlayerController *playerController = (__bridge VLCPlayerController *)p_data;
         [playerController trackListChanged];
@@ -432,10 +432,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 111a2407e0..41e719ecd9 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 *, vlc_es_id_t *, 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 bac2203556..874490e115 100644
--- a/src/input/player.c
+++ b/src/input/player.c
@@ -1819,6 +1819,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",
@@ -1831,7 +1832,7 @@ vlc_player_input_HandleVoutEvent(struct vlc_player_input *input,
     {
         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, ev->id);
 
             /* Register vout callbacks after the vout list event */
             var_AddCallback(ev->vout, "fullscreen",
@@ -1853,7 +1854,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, ev->id);
             break;
         default:
             vlc_assert_unreachable();
diff --git a/test/src/input/player.c b/test/src/input/player.c
index 8406e4352f..2c031f83a4 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;
+    vlc_es_id_t *es_id;
 };
 
 struct report_media_subitems
@@ -433,15 +434,16 @@ 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)
+                       enum vlc_player_vout_action action,
+                       vout_thread_t *vout, vlc_es_id_t *es_id, void *data)
 {
     struct ctx *ctx = get_ctx(player, data);
     struct report_vout report = {
         .action = action,
-        .vout = vout,
+        .vout = vout_Hold(vout),
+        .es_id = vlc_es_id_Hold(es_id),
     };
-    vout_Hold(vout);
+    assert(report.es_id);
     VEC_PUSH(on_vout_changed, report);
 }
 
@@ -570,7 +572,10 @@ ctx_reset(struct ctx *ctx)
     {
         struct report_vout report;
         FOREACH_VEC(report, on_vout_changed)
+        {
             vout_Release(report.vout);
+            vlc_es_id_Release(report.es_id);
+        }
     }
 
     {



More information about the vlc-commits mailing list