From 65365caa213dea1674670e7e5e27e69ad04be242 Mon Sep 17 00:00:00 2001 From: Adrien De Coninck Date: Tue, 24 Oct 2023 16:32:36 +0200 Subject: [PATCH] d3d11videosink: post "have-window-handle" element message on the bus * when window_id is not user-provided and window_type==GST_D3D11_WINDOW_NATIVE_TYPE_HWND * allows user to retrieve internally created window handle * for custom positionning * for custom icons * ... Part-of: --- .../gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp | 8 ++++++++ .../gst-plugins-bad/sys/d3d11/gstd3d11window_win32.cpp | 7 +++++++ .../gst-plugins-bad/sys/d3d11/gstd3d11window_win32.h | 3 +++ 3 files changed, 18 insertions(+) diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp index 57cc2ffd01..490d12adfb 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp @@ -1019,6 +1019,14 @@ gst_d3d11_video_sink_prepare_window (GstD3D11VideoSink * self) #if (!GST_D3D11_WINAPI_ONLY_APP) case GST_D3D11_WINDOW_NATIVE_TYPE_HWND: self->window = gst_d3d11_window_win32_new (self->device, self->window_id); + if (!self->window_id) { + HWND internal_hwnd = + gst_d3d11_window_win32_get_internal_hwnd (self->window); + GST_DEBUG_OBJECT (self, "Have window handle %" G_GUINTPTR_FORMAT, + (guintptr) internal_hwnd); + gst_video_overlay_got_window_handle (GST_VIDEO_OVERLAY (self), + (guintptr) internal_hwnd); + } break; #endif #if GST_D3D11_WINAPI_APP diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_win32.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_win32.cpp index 70f3a9ac00..9b3b18ce79 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_win32.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_win32.cpp @@ -1285,6 +1285,13 @@ gst_d3d11_window_win32_change_fullscreen_mode (GstD3D11Window * window) } } +HWND +gst_d3d11_window_win32_get_internal_hwnd (GstD3D11Window * window) +{ + GstD3D11WindowWin32 *self = GST_D3D11_WINDOW_WIN32 (window); + return self->internal_hwnd; +} + GstD3D11Window * gst_d3d11_window_win32_new (GstD3D11Device * device, guintptr handle) { diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_win32.h b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_win32.h index 7bdc050695..21bb640bb8 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_win32.h +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_win32.h @@ -34,6 +34,9 @@ G_DECLARE_FINAL_TYPE (GstD3D11WindowWin32, GstD3D11Window * gst_d3d11_window_win32_new (GstD3D11Device * device, guintptr handle); +HWND gst_d3d11_window_win32_get_internal_hwnd (GstD3D11Window * window); + + G_END_DECLS #endif /* __GST_D3D11_WINDOW_WIN32_H__ */