ges/gstframepositioner: don't create one compositor per frame meta

Instead, cache the looked up operator property

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2623>
This commit is contained in:
Mathieu Duponchelle 2022-06-16 22:40:21 +02:00 committed by GStreamer Marge Bot
parent e1fd0f620f
commit 4b50e674c3

View file

@ -84,30 +84,37 @@ G_DEFINE_TYPE (GstFramePositioner, gst_frame_positioner,
static GType static GType
gst_compositor_operator_get_type_and_default_value (int *default_operator_value) gst_compositor_operator_get_type_and_default_value (int *default_operator_value)
{ {
GstElement *compositor = static gsize _init = 0;
gst_element_factory_create (ges_get_compositor_factory (), NULL); static int operator_value = 0;
static GType operator_gtype = G_TYPE_NONE;
GstPad *compositorPad = if (g_once_init_enter (&_init)) {
gst_element_request_pad_simple (compositor, "sink_%u"); GstElement *compositor =
gst_element_factory_create (ges_get_compositor_factory (), NULL);
GParamSpec *pspec = GstPad *compositorPad =
g_object_class_find_property (G_OBJECT_GET_CLASS (compositorPad), gst_element_request_pad_simple (compositor, "sink_%u");
"operator");
GType ret = 0;
if (pspec) { GParamSpec *pspec =
*default_operator_value = g_object_class_find_property (G_OBJECT_GET_CLASS (compositorPad),
g_value_get_enum (g_param_spec_get_default_value (pspec)); "operator");
g_return_val_if_fail (pspec, G_TYPE_NONE);
ret = pspec->value_type; if (pspec) {
operator_value =
g_value_get_enum (g_param_spec_get_default_value (pspec));
operator_gtype = pspec->value_type;
}
gst_element_release_request_pad (compositor, compositorPad);
gst_object_unref (compositorPad);
gst_object_unref (compositor);
g_once_init_leave (&_init, 1);
} }
gst_element_release_request_pad (compositor, compositorPad); *default_operator_value = operator_value;
gst_object_unref (compositorPad);
gst_object_unref (compositor);
return ret; return operator_gtype;
} }
static void static void