diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp index 142d0d5150..17776e7a7d 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp @@ -64,6 +64,7 @@ enum PROP_GAMMA_MODE, PROP_PRIMARIES_MODE, PROP_DISPLAY_FORMAT, + PROP_EMIT_PRESENT, }; #define DEFAULT_ADAPTER -1 @@ -75,6 +76,7 @@ enum #define DEFAULT_GAMMA_MODE GST_VIDEO_GAMMA_MODE_NONE #define DEFAULT_PRIMARIES_MODE GST_VIDEO_PRIMARIES_MODE_NONE #define DEFAULT_DISPLAY_FORMAT DXGI_FORMAT_UNKNOWN +#define DEFAULT_EMIT_PRESENT FALSE #define GST_TYPE_D3D11_VIDEO_SINK_DISPLAY_FORMAT (gst_d3d11_video_sink_display_format_type()) static GType @@ -155,6 +157,7 @@ struct _GstD3D11VideoSink GstVideoGammaMode gamma_mode; GstVideoPrimariesMode primaries_mode; DXGI_FORMAT display_format; + gboolean emit_present; /* saved render rectangle until we have a window */ GstVideoRectangle render_rect; @@ -352,6 +355,19 @@ gst_d3d11_video_sink_class_init (GstD3D11VideoSinkClass * klass) DEFAULT_DISPLAY_FORMAT, (GParamFlags) (G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY | G_PARAM_STATIC_STRINGS))); + /** + * GstD3D11VideoSink:emit-present: + * + * Emits "present" signal + * + * Since: 1.22 + */ + g_object_class_install_property (gobject_class, PROP_EMIT_PRESENT, + g_param_spec_boolean ("emit-present", "Emit present", + "Emits present signal", DEFAULT_EMIT_PRESENT, + (GParamFlags) (G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY | + G_PARAM_STATIC_STRINGS))); + /** * GstD3D11VideoSink::begin-draw: * @videosink: the #d3d11videosink @@ -407,10 +423,6 @@ gst_d3d11_video_sink_class_init (GstD3D11VideoSinkClass * klass) * client should perform GPU operation from the thread where this signal * emitted. * - * If a client wants to listen this signal, the client must connect this - * signal before the first present. Otherwise this signal will not be - * emitted. - * * Since: 1.22 */ gst_d3d11_video_sink_signals[SIGNAL_PRESENT] = @@ -466,6 +478,7 @@ gst_d3d11_video_sink_init (GstD3D11VideoSink * self) self->gamma_mode = DEFAULT_GAMMA_MODE; self->primaries_mode = DEFAULT_PRIMARIES_MODE; self->display_format = DEFAULT_DISPLAY_FORMAT; + self->emit_present = DEFAULT_EMIT_PRESENT; InitializeCriticalSection (&self->lock); } @@ -524,6 +537,9 @@ gst_d3d11_videosink_set_property (GObject * object, guint prop_id, case PROP_DISPLAY_FORMAT: self->display_format = (DXGI_FORMAT) g_value_get_enum (value); break; + case PROP_EMIT_PRESENT: + self->emit_present = g_value_get_boolean (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -572,6 +588,9 @@ gst_d3d11_videosink_get_property (GObject * object, guint prop_id, case PROP_DISPLAY_FORMAT: g_value_set_enum (value, self->display_format); break; + case PROP_EMIT_PRESENT: + g_value_set_boolean (value, self->emit_present); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -869,7 +888,6 @@ static gboolean gst_d3d11_video_sink_prepare_window (GstD3D11VideoSink * self) { GstD3D11WindowNativeType window_type = GST_D3D11_WINDOW_NATIVE_TYPE_HWND; - gboolean emit_present = FALSE; if (self->window) return TRUE; @@ -933,18 +951,12 @@ done: return FALSE; } - /* Emits present signal only if signal is connected for performance reason */ - if (g_signal_has_handler_pending (self, - gst_d3d11_video_sink_signals[SIGNAL_PRESENT], 0, FALSE)) { - emit_present = TRUE; - } - g_object_set (self->window, "force-aspect-ratio", self->force_aspect_ratio, "fullscreen-toggle-mode", self->fullscreen_toggle_mode, "fullscreen", self->fullscreen, "enable-navigation-events", self->enable_navigation_events, - "emit-present", emit_present, nullptr); + "emit-present", self->emit_present, nullptr); gst_d3d11_window_set_orientation (self->window, self->selected_method); diff --git a/subprojects/gst-plugins-bad/tests/examples/d3d11/d3d11videosink-present.cpp b/subprojects/gst-plugins-bad/tests/examples/d3d11/d3d11videosink-present.cpp index d690102342..714ff4aa3a 100644 --- a/subprojects/gst-plugins-bad/tests/examples/d3d11/d3d11videosink-present.cpp +++ b/subprojects/gst-plugins-bad/tests/examples/d3d11/d3d11videosink-present.cpp @@ -616,6 +616,9 @@ main (gint argc, gchar ** argv) context.sink = gst_element_factory_make ("d3d11videosink", nullptr); g_assert (context.sink); + /* Enables present signal */ + g_object_set (context.sink, "emit-present", TRUE, nullptr); + /* D2D <-> DXGI interop requires BGRA format */ g_object_set (context.sink, "display-format", DXGI_FORMAT_B8G8R8A8_UNORM, nullptr);