[vlc-devel] [PATCH 2/5] libvlc: provide a callback to the host that it can call when its size changes

Steve Lhomme robux4 at ycbcr.xyz
Mon May 27 13:06:47 CEST 2019


---
 include/vlc/libvlc_media_player.h       | 8 ++++++++
 include/vlc_vout_window.h               | 5 +++--
 lib/media_player.c                      | 2 +-
 modules/video_output/win32/direct3d11.c | 5 ++++-
 modules/video_output/win32/direct3d9.c  | 5 ++++-
 5 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 7706765beb..7678d73b89 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -609,6 +609,14 @@ typedef enum libvlc_video_direct3d_engine_t {
 typedef struct
 {
     bool hardware_decoding; /** set if D3D11_CREATE_DEVICE_VIDEO_SUPPORT is needed for D3D11 */
+
+    /** Callback to call when the size of the host changes
+     *
+     * \note This may be called from any thread as long as it's not after
+     *    \ref libvlc_video_direct3d_device_cleanup_cb has been called.
+     */
+    void (*report_size_change)(void *report_opaque, unsigned width, unsigned height);
+    void *report_opaque;
 } libvlc_video_direct3d_device_cfg_t;
 
 typedef struct
diff --git a/include/vlc_vout_window.h b/include/vlc_vout_window.h
index 73154d2cd8..afa1a98fd7 100644
--- a/include/vlc_vout_window.h
+++ b/include/vlc_vout_window.h
@@ -375,7 +375,8 @@ typedef struct vout_window_t {
         struct wl_display *wl; /**< Wayland display (client pointer) */
     } display;
 
-    const struct vout_window_operations *ops;
+    const struct vout_window_operations *ops; /**< operations handled by the
+                             window. Once this is set it MUST NOT be changed */
 
     struct {
         bool has_double_click; /**< Whether double click events are sent,
@@ -427,7 +428,7 @@ void vout_window_SetInhibition(vout_window_t *window, bool enabled);
 /**
  * Requests a new window state.
  *
- * This requests a change of the state of a window from the windowing system. 
+ * This requests a change of the state of a window from the windowing system.
  * See \ref vout_window_state for possible states.
  *
  * @param window window whose state to change
diff --git a/lib/media_player.c b/lib/media_player.c
index fd085c3793..ab5b5d43c7 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1073,7 +1073,7 @@ bool libvlc_video_direct3d_set_callbacks(libvlc_media_player_t *mp,
                                          libvlc_video_direct3d_select_plane_cb select_plane_cb,
                                          void *opaque)
 {
-    var_SetString( mp, "window", "wdummy");
+    var_SetString( mp, "window", "wextern");
 
     if ( engine == libvlc_video_direct3d_engine_d3d11 )
     {
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index e057f20fbd..49d487ef1c 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1372,7 +1372,10 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp)
     HRESULT hr = E_FAIL;
 
     libvlc_video_direct3d_device_cfg_t cfg = {
-        .hardware_decoding = is_d3d11_opaque( vd->source.i_chroma ) 
+        .hardware_decoding = is_d3d11_opaque( vd->source.i_chroma ),
+        /* bypass the size handling as the window doesn't handle the size */
+        .report_size_change = vd->cfg->window->ops->resize ? NULL: vout_window_ReportSize,
+        .report_opaque     = vd->cfg->window->ops->resize ? NULL: vd->cfg->window,
     };
     libvlc_video_direct3d_device_setup_t out;
     ID3D11DeviceContext *d3d11_ctx = NULL;
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 3f1381c3fe..69a4665e3e 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -1711,7 +1711,10 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     }
 
     libvlc_video_direct3d_device_cfg_t surface_cfg = {
-        .hardware_decoding = is_d3d9_opaque( vd->source.i_chroma )
+        .hardware_decoding = is_d3d9_opaque( vd->source.i_chroma ),
+        /* bypass the size handling as the window doesn't handle the size */
+        .report_size_change = vd->cfg->window->ops->resize ? NULL: vout_window_ReportSize,
+        .report_opaque     = vd->cfg->window->ops->resize ? NULL: vd->cfg->window,
     };
     libvlc_video_direct3d_device_setup_t device_setup;
     IDirect3DDevice9 *d3d9_device = NULL;
-- 
2.17.1



More information about the vlc-devel mailing list