ges-smart-video-mixer: use the proper pad to get the positioner meta

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2094>
This commit is contained in:
Xabier Rodriguez Calvar 2022-03-31 12:49:48 +02:00
parent 199b62570f
commit d522b17d9c
2 changed files with 25 additions and 7 deletions

View file

@ -129,6 +129,7 @@ typedef struct _PadInfos
GESSmartMixer *self;
GstPad *mixer_pad;
GstPad *ghostpad;
GstPad *real_mixer_pad;
} PadInfos;
static void
@ -140,6 +141,7 @@ pad_infos_unref (PadInfos * infos)
gst_element_release_request_pad (infos->self->mixer, infos->mixer_pad);
gst_object_unref (infos->mixer_pad);
}
gst_clear_object (&infos->real_mixer_pad);
g_free (infos);
}
@ -252,6 +254,7 @@ _request_new_pad (GstElement * element, GstPadTemplate * templ,
PadInfos *infos = pad_infos_new ();
GESSmartMixer *self = GES_SMART_MIXER (element);
GstPad *ghost;
gchar *mixer_pad_name;
infos->mixer_pad = gst_element_request_pad (self->mixer,
gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (self->mixer),
@ -264,6 +267,19 @@ _request_new_pad (GstElement * element, GstPadTemplate * templ,
return NULL;
}
/* We can rely on this because the mixer bin uses the same name pad
as the internal mixer when creating the ghost pad. */
mixer_pad_name = gst_pad_get_name (infos->mixer_pad);
infos->real_mixer_pad = gst_element_get_static_pad (self->real_mixer,
mixer_pad_name);
g_free (mixer_pad_name);
if (infos->real_mixer_pad == NULL) {
GST_WARNING_OBJECT (element, "Could not get the real mixer pad");
pad_infos_unref (infos);
return NULL;
}
infos->self = self;
ghost = g_object_new (ges_smart_mixer_pad_get_type (), "name", name,
@ -281,6 +297,8 @@ _request_new_pad (GstElement * element, GstPadTemplate * templ,
g_hash_table_insert (self->pads_infos, ghost, infos);
g_hash_table_insert (self->pads_infos, infos->mixer_pad,
pad_infos_ref (infos));
g_hash_table_insert (self->pads_infos, infos->real_mixer_pad,
pad_infos_ref (infos));
UNLOCK (self);
GST_DEBUG_OBJECT (self, "Returning new pad %" GST_PTR_FORMAT, ghost);
@ -383,6 +401,7 @@ ges_smart_mixer_dispose (GObject * object)
g_hash_table_unref (self->pads_infos);
self->pads_infos = NULL;
}
gst_clear_object (&self->real_mixer);
G_OBJECT_CLASS (ges_smart_mixer_parent_class)->dispose (object);
}
@ -404,23 +423,21 @@ ges_smart_mixer_constructed (GObject * obj)
GstElement *identity, *videoconvert;
GESSmartMixer *self = GES_SMART_MIXER (obj);
gchar *cname = g_strdup_printf ("%s-compositor", GST_OBJECT_NAME (self));
GstElement *mixer;
self->mixer =
gst_element_factory_create (ges_get_compositor_factory (), cname);
g_free (cname);
if (GST_IS_BIN (self->mixer)) {
g_object_get (self->mixer, "mixer", &mixer, NULL);
g_assert (mixer);
g_object_get (self->mixer, "mixer", &self->real_mixer, NULL);
g_assert (self->real_mixer);
} else {
mixer = gst_object_ref (self->mixer);
self->real_mixer = gst_object_ref (self->mixer);
}
g_object_set (mixer, "background", 1, "emit-signals", TRUE, NULL);
g_signal_connect (mixer, "samples-selected",
g_object_set (self->real_mixer, "background", 1, "emit-signals", TRUE, NULL);
g_signal_connect (self->real_mixer, "samples-selected",
G_CALLBACK (ges_smart_mixer_samples_selected_cb), self);
gst_object_unref (mixer);
/* See https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/310 */
GST_FIXME ("Stop dropping allocation query when it is not required anymore.");

View file

@ -50,6 +50,7 @@ struct _GESSmartMixer
GHashTable *pads_infos;
GstPad *srcpad;
GstElement *mixer;
GstElement *real_mixer;
GMutex lock;
GstCaps *caps;