From 9ed5803323b5c1e90c247cac7cd51ce9007c9b88 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Sun, 1 Sep 2013 12:19:32 -0400 Subject: [PATCH] videosource: Make sure to update z-order when layer priority changes Conflicts: ges/ges-video-source.c --- ges/ges-video-source.c | 59 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/ges/ges-video-source.c b/ges/ges-video-source.c index 981eaf2..de07a87 100644 --- a/ges/ges-video-source.c +++ b/ges/ges-video-source.c @@ -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); + g_object_set (self->priv->positionner, "zorder", + 10000 - ges_layer_get_priority (layer), NULL); +} + +static void +layer_changed_cb (GESClip * clip, GParamSpec * arg G_GNUC_UNUSED, + GESVideoSource * self) +{ + GESVideoSourcePrivate *priv = self->priv; - if (layer == NULL) + 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 (layer), NULL); - - gst_object_unref (layer); + 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; -- 2.7.4