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

Steve Lhomme robux4 at ycbcr.xyz
Mon May 13 13:54:51 CEST 2019


---
 include/vlc/libvlc_media_player.h       |  8 ++++++++
 include/vlc_vout_display.h              |  4 ++++
 modules/video_output/win32/direct3d11.c | 10 +++++++++-
 modules/video_output/win32/direct3d9.c  | 10 +++++++++-
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index f10fcf7a96..91bc949d01 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -608,6 +608,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
+     *
+     * This callback must not be called once the \ref libvlc_video_direct3d_device_cleanup_cb
+     * callback has been called.
+     */
+    void (*repot_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_display.h b/include/vlc_vout_display.h
index 687a655cfc..e46696e1d4 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -388,6 +388,10 @@ static inline void vout_display_SendEventTitle(vout_display_t *vd, const char *t
 {
     vout_window_SetTitle(vd->cfg->window, title);
 }
+static inline void vout_display_SendEventHostSize(vout_display_t *vd, unsigned width, unsigned height)
+{
+    vout_window_SetSize( vd->cfg->window, width, height );
+}
 static inline void vout_display_SendEventViewpointMoved(vout_display_t *vd,
                                                         const vlc_viewpoint_t *vp)
 {
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index b2d5b000f1..bac4f34b94 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1364,13 +1364,21 @@ static const d3d_format_t *GetBlendableFormat(vout_display_t *vd, vlc_fourcc_t i
     return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, false, 0, 0, 0, false, supportFlags );
 }
 
+static void ReportSizeCallback(void *report_opaque, unsigned width, unsigned height)
+{
+    vout_display_t *vd = report_opaque;
+    vout_display_SendEventHostSize( vd, width, height );
+}
+
 static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp)
 {
     vout_display_sys_t *sys = vd->sys;
     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 ),
+        .repot_size_change = ReportSizeCallback,
+        .report_opaque = vd,
     };
     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 8d5f6b059d..375e6ebcd7 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -1662,6 +1662,12 @@ static bool LocalSwapchainStartEndRendering( void *opaque, bool enter, const lib
     return true;
 }
 
+static void ReportSizeCallback(void *report_opaque, unsigned width, unsigned height)
+{
+    vout_display_t *vd = report_opaque;
+    vout_display_SendEventHostSize( vd, width, height );
+}
+
 /**
  * It creates a Direct3D vout display.
  */
@@ -1711,7 +1717,9 @@ 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 ),
+        .repot_size_change = ReportSizeCallback,
+        .report_opaque = vd,
     };
     libvlc_video_direct3d_device_setup_t device_setup;
     IDirect3DDevice9 *d3d9_device = NULL;
-- 
2.17.1



More information about the vlc-devel mailing list