mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 20:05:38 +00:00
videosource: Make sure to update z-order when layer priority changes
Conflicts: ges/ges-video-source.c
This commit is contained in:
parent
9fa99df5a7
commit
9ed5803323
1 changed files with 54 additions and 11 deletions
|
@ -36,23 +36,42 @@ struct _GESVideoSourcePrivate
|
|||
{
|
||||
GstFramePositionner *positionner;
|
||||
GstElement *capsfilter;
|
||||
GESLayer *layer;
|
||||
};
|
||||
|
||||
/* TrackElement VMethods */
|
||||
static void
|
||||
update_z_order_cb (GESClip * clip, GParamSpec * arg G_GNUC_UNUSED,
|
||||
layer_priority_changed_cb (GESLayer * layer, GParamSpec * arg G_GNUC_UNUSED,
|
||||
GESVideoSource * self)
|
||||
{
|
||||
GESLayer *layer = ges_clip_get_layer (clip);
|
||||
|
||||
if (layer == NULL)
|
||||
return;
|
||||
|
||||
/* 10000 is the max value of zorder on videomixerpad, hardcoded */
|
||||
|
||||
g_object_set (self->priv->positionner, "zorder",
|
||||
10000 - ges_layer_get_priority (layer), NULL);
|
||||
}
|
||||
|
||||
gst_object_unref (layer);
|
||||
static void
|
||||
layer_changed_cb (GESClip * clip, GParamSpec * arg G_GNUC_UNUSED,
|
||||
GESVideoSource * self)
|
||||
{
|
||||
GESVideoSourcePrivate *priv = self->priv;
|
||||
|
||||
if (priv->layer) {
|
||||
g_signal_handlers_disconnect_by_func (priv->layer,
|
||||
layer_priority_changed_cb, self);
|
||||
}
|
||||
|
||||
priv->layer = ges_clip_get_layer (clip);
|
||||
if (priv->layer == NULL)
|
||||
return;
|
||||
|
||||
/* We do not need any ref ourself as our parent owns one and we are connected
|
||||
* to it */
|
||||
g_object_unref (priv->layer);
|
||||
/* 10000 is the max value of zorder on videomixerpad, hardcoded */
|
||||
g_signal_connect (self->priv->layer, "notify::priority",
|
||||
G_CALLBACK (layer_priority_changed_cb), self);
|
||||
|
||||
g_object_set (self->priv->positionner, "zorder",
|
||||
10000 - ges_layer_get_priority (self->priv->layer), NULL);
|
||||
}
|
||||
|
||||
static GstElement *
|
||||
|
@ -93,8 +112,8 @@ ges_video_source_create_element (GESTrackElement * trksrc)
|
|||
if (parent) {
|
||||
self->priv->positionner = GST_FRAME_POSITIONNER (positionner);
|
||||
g_signal_connect (parent, "notify::layer",
|
||||
(GCallback) update_z_order_cb, trksrc);
|
||||
update_z_order_cb (GES_CLIP (parent), NULL, self);
|
||||
(GCallback) layer_changed_cb, trksrc);
|
||||
layer_changed_cb (GES_CLIP (parent), NULL, self);
|
||||
gst_object_unref (parent);
|
||||
} else {
|
||||
GST_ERROR ("No parent timeline element, SHOULD NOT HAPPEN");
|
||||
|
@ -105,14 +124,38 @@ ges_video_source_create_element (GESTrackElement * trksrc)
|
|||
return topbin;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_set_parent (GESTimelineElement * self, GESTimelineElement * parent)
|
||||
{
|
||||
GESVideoSourcePrivate *priv = GES_VIDEO_SOURCE (self)->priv;
|
||||
|
||||
if (self->parent) {
|
||||
if (priv->layer) {
|
||||
g_signal_handlers_disconnect_by_func (priv->layer,
|
||||
layer_priority_changed_cb, self);
|
||||
priv->layer = NULL;
|
||||
}
|
||||
|
||||
g_signal_handlers_disconnect_by_func (self->parent, layer_changed_cb, self);
|
||||
}
|
||||
|
||||
if (parent && priv->positionner)
|
||||
layer_changed_cb (GES_CLIP (parent), NULL, GES_VIDEO_SOURCE (self));
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
ges_video_source_class_init (GESVideoSourceClass * klass)
|
||||
{
|
||||
GESTrackElementClass *track_class = GES_TRACK_ELEMENT_CLASS (klass);
|
||||
GESTimelineElementClass *element_class = GES_TIMELINE_ELEMENT_CLASS (klass);
|
||||
GESVideoSourceClass *video_source_class = GES_VIDEO_SOURCE_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (GESVideoSourcePrivate));
|
||||
|
||||
element_class->set_parent = _set_parent;
|
||||
track_class->gnlobject_factorytype = "gnlsource";
|
||||
track_class->create_element = ges_video_source_create_element;
|
||||
video_source_class->create_source = NULL;
|
||||
|
|
Loading…
Reference in a new issue