2009-08-04 15:13:11 +00:00
|
|
|
/* GStreamer Editing Services
|
2009-11-30 14:14:25 +00:00
|
|
|
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
|
|
|
|
* 2009 Nokia Corporation
|
2011-12-22 20:21:37 +00:00
|
|
|
* 2011 Mathieu Duponchelle <mathieu.duponchelle@epitech.eu>
|
2009-08-04 15:13:11 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2009-09-10 16:40:51 +00:00
|
|
|
* SECTION:ges-timeline-layer
|
2011-12-22 20:21:37 +00:00
|
|
|
* @short_description: Non-overlapping sequence of #GESTimelineObject
|
2009-08-04 15:13:11 +00:00
|
|
|
*
|
2010-05-31 16:59:12 +00:00
|
|
|
* Responsible for the ordering of the various contained TimelineObject(s). A
|
|
|
|
* timeline layer has a "priority" property, which is used to manage the
|
|
|
|
* priorities of individual TimelineObjects. Two layers should not have the
|
|
|
|
* same priority within a given timeline.
|
2009-08-04 15:13:11 +00:00
|
|
|
*/
|
|
|
|
|
2009-09-10 16:40:51 +00:00
|
|
|
#include "ges-internal.h"
|
|
|
|
#include "gesmarshal.h"
|
|
|
|
#include "ges-timeline-layer.h"
|
|
|
|
#include "ges.h"
|
2011-07-24 00:49:36 +00:00
|
|
|
#include "ges-timeline-source.h"
|
2009-09-10 16:40:51 +00:00
|
|
|
|
2011-06-17 18:29:52 +00:00
|
|
|
#define LAYER_HEIGHT 1000
|
2011-06-03 01:35:59 +00:00
|
|
|
|
2011-12-06 17:11:21 +00:00
|
|
|
static void
|
|
|
|
track_object_removed_cb (GESTimelineObject * object,
|
2011-12-21 18:48:22 +00:00
|
|
|
GESTrackObject * track_object);
|
2011-11-02 16:51:36 +00:00
|
|
|
static void track_object_added_cb (GESTimelineObject * object,
|
2011-08-24 10:04:32 +00:00
|
|
|
GESTrackObject * track_object, GHashTable * signal_table);
|
2011-11-02 16:51:36 +00:00
|
|
|
static void track_object_changed_cb (GESTrackObject * track_object,
|
2011-12-21 18:48:22 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED);
|
|
|
|
static void calculate_transitions (GESTrackObject * track_object);
|
2011-11-02 16:51:36 +00:00
|
|
|
static void calculate_next_transition (GESTrackObject * track_object,
|
|
|
|
GESTimelineLayer * layer);
|
2011-07-24 00:49:36 +00:00
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
static void
|
2011-07-24 00:49:36 +00:00
|
|
|
timeline_object_height_changed_cb (GESTimelineObject * obj,
|
|
|
|
GESTrackEffect * tr_eff, GESTimelineObject * second_obj);
|
|
|
|
|
2010-12-20 11:00:06 +00:00
|
|
|
G_DEFINE_TYPE (GESTimelineLayer, ges_timeline_layer, G_TYPE_INITIALLY_UNOWNED);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2010-12-04 18:54:13 +00:00
|
|
|
struct _GESTimelineLayerPrivate
|
|
|
|
{
|
2010-12-16 11:41:26 +00:00
|
|
|
/*< private > */
|
2011-07-24 00:49:36 +00:00
|
|
|
GList *objects_start; /* The TimelineObjects sorted by start and
|
2010-12-16 11:41:26 +00:00
|
|
|
* priority */
|
|
|
|
|
|
|
|
guint32 priority; /* The priority of the layer within the
|
|
|
|
* containing timeline */
|
2011-07-24 00:49:36 +00:00
|
|
|
|
|
|
|
gboolean auto_transition;
|
2011-08-24 10:04:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
GHashTable *signal_table;
|
2010-12-04 18:54:13 +00:00
|
|
|
};
|
|
|
|
|
2010-03-12 18:06:42 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_PRIORITY,
|
2011-07-24 00:49:36 +00:00
|
|
|
PROP_AUTO_TRANSITION,
|
|
|
|
PROP_LAST
|
2010-03-12 18:06:42 +00:00
|
|
|
};
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
OBJECT_ADDED,
|
|
|
|
OBJECT_REMOVED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint ges_timeline_layer_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2010-06-09 14:27:43 +00:00
|
|
|
static gboolean ges_timeline_layer_resync_priorities (GESTimelineLayer * layer);
|
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
static GList *track_get_by_layer (GESTimelineLayer * layer, GESTrack * track);
|
2011-07-24 00:49:36 +00:00
|
|
|
|
|
|
|
static void compare (GList * compared, GESTrackObject * track_object,
|
|
|
|
gboolean ahead);
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
static void
|
|
|
|
ges_timeline_layer_get_property (GObject * object, guint property_id,
|
2009-08-04 15:16:31 +00:00
|
|
|
GValue * value, GParamSpec * pspec)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2010-03-12 18:06:42 +00:00
|
|
|
GESTimelineLayer *layer = GES_TIMELINE_LAYER (object);
|
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
switch (property_id) {
|
2010-03-12 18:06:42 +00:00
|
|
|
case PROP_PRIORITY:
|
2010-12-16 11:41:26 +00:00
|
|
|
g_value_set_uint (value, layer->priv->priority);
|
2010-03-12 18:06:42 +00:00
|
|
|
break;
|
2011-07-24 00:49:36 +00:00
|
|
|
case PROP_AUTO_TRANSITION:
|
|
|
|
g_value_set_boolean (value, layer->priv->auto_transition);
|
|
|
|
break;
|
2009-08-04 15:16:31 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_layer_set_property (GObject * object, guint property_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2010-03-12 18:06:42 +00:00
|
|
|
GESTimelineLayer *layer = GES_TIMELINE_LAYER (object);
|
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
switch (property_id) {
|
2010-03-12 18:06:42 +00:00
|
|
|
case PROP_PRIORITY:
|
|
|
|
ges_timeline_layer_set_priority (layer, g_value_get_uint (value));
|
|
|
|
break;
|
2011-07-24 00:49:36 +00:00
|
|
|
case PROP_AUTO_TRANSITION:
|
|
|
|
ges_timeline_layer_set_auto_transition (layer,
|
|
|
|
g_value_get_boolean (value));
|
|
|
|
break;
|
2009-08-04 15:16:31 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_layer_dispose (GObject * object)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2009-09-14 17:23:52 +00:00
|
|
|
GESTimelineLayer *layer = GES_TIMELINE_LAYER (object);
|
2010-12-16 11:41:26 +00:00
|
|
|
GESTimelineLayerPrivate *priv = layer->priv;
|
2009-09-14 17:23:52 +00:00
|
|
|
|
2010-06-09 11:52:08 +00:00
|
|
|
GST_DEBUG ("Disposing layer");
|
|
|
|
|
2010-12-16 11:41:26 +00:00
|
|
|
while (priv->objects_start)
|
|
|
|
ges_timeline_layer_remove_object (layer,
|
|
|
|
(GESTimelineObject *) priv->objects_start->data);
|
2010-06-09 11:52:08 +00:00
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
G_OBJECT_CLASS (ges_timeline_layer_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_layer_class_init (GESTimelineLayerClass * klass)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2010-12-04 18:54:13 +00:00
|
|
|
g_type_class_add_private (klass, sizeof (GESTimelineLayerPrivate));
|
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
object_class->get_property = ges_timeline_layer_get_property;
|
|
|
|
object_class->set_property = ges_timeline_layer_set_property;
|
|
|
|
object_class->dispose = ges_timeline_layer_dispose;
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2010-03-12 18:06:42 +00:00
|
|
|
/**
|
|
|
|
* GESTimelineLayer:priority
|
|
|
|
*
|
|
|
|
* The priority of the layer in the #GESTimeline. 0 is the highest
|
2010-05-31 16:59:12 +00:00
|
|
|
* priority. Conceptually, a #GESTimeline is a stack of GESTimelineLayers,
|
|
|
|
* and the priority of the layer represents its position in the stack. Two
|
|
|
|
* layers should not have the same priority within a given GESTimeline.
|
2010-03-12 18:06:42 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class, PROP_PRIORITY,
|
|
|
|
g_param_spec_uint ("priority", "Priority",
|
|
|
|
"The priority of the layer", 0, G_MAXUINT, 0, G_PARAM_READWRITE));
|
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
/**
|
|
|
|
* GESTimelineLayer:auto_transitioning
|
|
|
|
*
|
2011-12-22 20:21:37 +00:00
|
|
|
* Sets whether transitions are added automagically when timeline objects overlap.
|
2011-07-24 00:49:36 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class, PROP_AUTO_TRANSITION,
|
|
|
|
g_param_spec_boolean ("auto-transition", "Auto-Transition",
|
|
|
|
"whether the transitions are added", FALSE, G_PARAM_READWRITE));
|
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
|
|
|
* GESTimelineLayer::object-added
|
|
|
|
* @layer: the #GESTimelineLayer
|
|
|
|
* @object: the #GESTimelineObject that was added.
|
|
|
|
*
|
|
|
|
* Will be emitted after the object was added to the layer.
|
|
|
|
*/
|
2009-08-06 15:38:43 +00:00
|
|
|
ges_timeline_layer_signals[OBJECT_ADDED] =
|
|
|
|
g_signal_new ("object-added", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineLayerClass, object_added),
|
|
|
|
NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
|
|
|
|
GES_TYPE_TIMELINE_OBJECT);
|
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
|
|
|
* GESTimelineLayer::object-removed
|
|
|
|
* @layer: the #GESTimelineLayer
|
|
|
|
* @object: the #GESTimelineObject that was removed
|
|
|
|
*
|
|
|
|
* Will be emitted after the object was removed from the layer.
|
|
|
|
*/
|
2009-08-06 15:38:43 +00:00
|
|
|
ges_timeline_layer_signals[OBJECT_REMOVED] =
|
|
|
|
g_signal_new ("object-removed", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineLayerClass,
|
|
|
|
object_removed), NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
|
|
|
|
GES_TYPE_TIMELINE_OBJECT);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_layer_init (GESTimelineLayer * self)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2010-12-04 18:54:13 +00:00
|
|
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
|
|
|
GES_TYPE_TIMELINE_LAYER, GESTimelineLayerPrivate);
|
|
|
|
|
2010-12-16 11:41:26 +00:00
|
|
|
self->priv->priority = 0;
|
2011-07-24 00:49:36 +00:00
|
|
|
self->priv->auto_transition = FALSE;
|
2010-03-12 18:06:42 +00:00
|
|
|
self->min_gnl_priority = 0;
|
2011-12-01 00:46:21 +00:00
|
|
|
self->max_gnl_priority = LAYER_HEIGHT;
|
2011-08-24 10:04:32 +00:00
|
|
|
self->priv->signal_table =
|
|
|
|
g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref,
|
2011-12-23 16:16:20 +00:00
|
|
|
NULL);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_layer_new:
|
|
|
|
*
|
|
|
|
* Creates a new #GESTimelineLayer.
|
|
|
|
*
|
|
|
|
* Returns: A new #GESTimelineLayer
|
|
|
|
*/
|
2009-08-04 15:16:31 +00:00
|
|
|
GESTimelineLayer *
|
2009-08-04 15:13:11 +00:00
|
|
|
ges_timeline_layer_new (void)
|
|
|
|
{
|
|
|
|
return g_object_new (GES_TYPE_TIMELINE_LAYER, NULL);
|
|
|
|
}
|
2009-08-06 15:38:43 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
ges_timeline_layer_set_timeline (GESTimelineLayer * layer,
|
|
|
|
GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
GST_DEBUG ("layer:%p, timeline:%p", layer, timeline);
|
|
|
|
|
|
|
|
layer->timeline = timeline;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
objects_start_compare (GESTimelineObject * a, GESTimelineObject * b)
|
|
|
|
{
|
|
|
|
if (a->start == b->start) {
|
|
|
|
if (a->priority < b->priority)
|
|
|
|
return -1;
|
|
|
|
if (a->priority > b->priority)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (a->start < b->start)
|
|
|
|
return -1;
|
|
|
|
if (a->start > b->start)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
static GList *
|
2011-11-02 16:51:36 +00:00
|
|
|
track_get_by_layer (GESTimelineLayer * layer, GESTrack * track)
|
2011-07-24 00:49:36 +00:00
|
|
|
{
|
|
|
|
GList *tck_objects_list = NULL, *tmp = NULL, *return_list = NULL;
|
|
|
|
GESTimelineObject *tl_obj;
|
|
|
|
|
|
|
|
tck_objects_list = ges_track_get_objects (track);
|
|
|
|
for (tmp = tck_objects_list; tmp; tmp = tmp->next) {
|
|
|
|
tl_obj = ges_track_object_get_timeline_object (tmp->data);
|
2011-11-02 16:51:36 +00:00
|
|
|
|
|
|
|
if (ges_timeline_object_get_layer (tl_obj) == layer) {
|
2011-12-21 18:48:22 +00:00
|
|
|
/* We steal the reference from tck_objects_list */
|
2011-07-24 00:49:36 +00:00
|
|
|
return_list = g_list_append (return_list, tmp->data);
|
2011-11-02 16:51:36 +00:00
|
|
|
|
|
|
|
} else
|
|
|
|
g_object_unref (tmp->data);
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return return_list;
|
|
|
|
}
|
|
|
|
|
2011-12-01 00:46:21 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_layer_add_object:
|
|
|
|
* @layer: a #GESTimelineLayer
|
|
|
|
* @object: (transfer full): the #GESTimelineObject to add.
|
|
|
|
*
|
|
|
|
* Adds the given object to the layer. Sets the object's parent, and thus
|
|
|
|
* takes ownership of the object.
|
|
|
|
*
|
|
|
|
* An object can only be added to one layer.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the object was properly added to the layer, or FALSE
|
|
|
|
* if the @layer refuses to add the object.
|
|
|
|
*/
|
2009-08-06 15:38:43 +00:00
|
|
|
gboolean
|
|
|
|
ges_timeline_layer_add_object (GESTimelineLayer * layer,
|
|
|
|
GESTimelineObject * object)
|
|
|
|
{
|
2010-11-28 12:24:07 +00:00
|
|
|
GESTimelineLayer *tl_obj_layer;
|
2011-04-15 23:34:28 +00:00
|
|
|
guint32 maxprio, minprio, prio;
|
2010-11-28 12:24:07 +00:00
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
GST_DEBUG ("layer:%p, object:%p", layer, object);
|
|
|
|
|
2010-11-28 12:24:07 +00:00
|
|
|
tl_obj_layer = ges_timeline_object_get_layer (object);
|
2010-12-20 11:01:04 +00:00
|
|
|
|
2010-11-28 12:24:07 +00:00
|
|
|
if (G_UNLIKELY (tl_obj_layer)) {
|
2011-01-31 19:00:49 +00:00
|
|
|
GST_WARNING ("TimelineObject %p already belongs to another layer", object);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_unref (tl_obj_layer);
|
2009-08-06 15:38:43 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-12-20 11:01:04 +00:00
|
|
|
g_object_ref_sink (object);
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
/* Take a reference to the object and store it stored by start/priority */
|
2010-12-16 11:41:26 +00:00
|
|
|
layer->priv->objects_start =
|
2011-07-24 00:49:36 +00:00
|
|
|
g_list_insert_sorted (layer->priv->objects_start, object,
|
2009-08-06 15:38:43 +00:00
|
|
|
(GCompareFunc) objects_start_compare);
|
|
|
|
|
2011-12-22 20:21:37 +00:00
|
|
|
/* We have to wait for the track objects to be created to calculate transitions */
|
2011-07-24 00:49:36 +00:00
|
|
|
if (layer->priv->auto_transition) {
|
2011-11-02 16:51:36 +00:00
|
|
|
if (GES_IS_TIMELINE_SOURCE (object)) {
|
2011-07-24 00:49:36 +00:00
|
|
|
g_signal_connect (G_OBJECT (object), "track-object-added",
|
2011-08-24 10:04:32 +00:00
|
|
|
G_CALLBACK (track_object_added_cb), layer->priv->signal_table);
|
2011-12-06 17:11:21 +00:00
|
|
|
g_signal_connect (G_OBJECT (object), "track-object-removed",
|
2011-12-21 18:48:22 +00:00
|
|
|
G_CALLBACK (track_object_removed_cb), NULL);
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
/* Inform the object it's now in this layer */
|
|
|
|
ges_timeline_object_set_layer (object, layer);
|
|
|
|
|
2010-11-26 12:02:48 +00:00
|
|
|
GST_DEBUG ("current object priority : %d, layer min/max : %d/%d",
|
|
|
|
GES_TIMELINE_OBJECT_PRIORITY (object),
|
|
|
|
layer->min_gnl_priority, layer->max_gnl_priority);
|
|
|
|
|
2010-03-12 18:06:42 +00:00
|
|
|
/* Set the priority. */
|
2011-04-15 23:34:28 +00:00
|
|
|
maxprio = layer->max_gnl_priority;
|
|
|
|
minprio = layer->min_gnl_priority;
|
|
|
|
prio = GES_TIMELINE_OBJECT_PRIORITY (object);
|
|
|
|
if (minprio + prio > (maxprio)) {
|
|
|
|
GST_WARNING ("%p is out of the layer %p space, setting its priority to "
|
2011-07-24 00:49:36 +00:00
|
|
|
"setting its priority %d to failthe maximum priority of the layer %d",
|
2011-04-15 23:34:28 +00:00
|
|
|
object, layer, prio, maxprio - minprio);
|
|
|
|
ges_timeline_object_set_priority (object, LAYER_HEIGHT - 1);
|
2010-05-25 11:44:57 +00:00
|
|
|
}
|
2011-04-15 23:34:28 +00:00
|
|
|
/* If the object has an acceptable priority, we just let it with its current
|
|
|
|
* priority */
|
2010-05-25 11:44:57 +00:00
|
|
|
|
2011-04-15 23:34:28 +00:00
|
|
|
ges_timeline_layer_resync_priorities (layer);
|
2010-03-12 18:06:42 +00:00
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
/* emit 'object-added' */
|
|
|
|
g_signal_emit (layer, ges_timeline_layer_signals[OBJECT_ADDED], 0, object);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2009-08-07 14:39:09 +00:00
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
static void
|
|
|
|
track_object_duration_cb (GESTrackObject * track_object,
|
2011-12-21 18:48:22 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED)
|
2011-11-02 16:51:36 +00:00
|
|
|
{
|
2011-12-21 18:48:22 +00:00
|
|
|
GESTimelineLayer *layer;
|
|
|
|
GESTimelineObject *tlobj;
|
|
|
|
|
|
|
|
tlobj = ges_track_object_get_timeline_object (track_object);
|
|
|
|
layer = ges_timeline_object_get_layer (tlobj);
|
2011-11-02 16:51:36 +00:00
|
|
|
if (G_LIKELY (GES_IS_TRACK_SOURCE (track_object)))
|
|
|
|
GST_DEBUG ("Here we should recalculate");
|
|
|
|
calculate_next_transition (track_object, layer);
|
|
|
|
}
|
|
|
|
|
2011-08-24 10:04:32 +00:00
|
|
|
static void
|
|
|
|
track_object_deleted_cb (GESTrack * track, GESTrackObject * track_object)
|
|
|
|
{
|
|
|
|
GList *track_objects, *tmp, *cur;
|
|
|
|
GESTimelineLayer *layer;
|
|
|
|
|
|
|
|
track_objects = ges_track_get_objects (track);
|
|
|
|
cur = g_list_find (track_objects, track_object);
|
|
|
|
for (tmp = cur->next; tmp; tmp = tmp->next) {
|
|
|
|
if (GES_IS_TRACK_SOURCE (tmp->data)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (GES_IS_TRACK_AUDIO_TRANSITION (tmp->data)
|
|
|
|
|| GES_IS_TRACK_VIDEO_TRANSITION (tmp->data)) {
|
|
|
|
layer =
|
|
|
|
ges_timeline_object_get_layer (ges_track_object_get_timeline_object
|
|
|
|
(tmp->data));
|
|
|
|
if (ges_timeline_layer_get_auto_transition (layer)) {
|
|
|
|
ges_track_enable_update (track, FALSE);
|
|
|
|
ges_timeline_layer_remove_object (layer,
|
|
|
|
ges_track_object_get_timeline_object (tmp->data));
|
|
|
|
ges_track_enable_update (track, TRUE);
|
|
|
|
}
|
|
|
|
g_object_unref (layer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (tmp = cur->prev; tmp; tmp = tmp->prev) {
|
|
|
|
if (GES_IS_TRACK_SOURCE (tmp->data)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (GES_IS_TRACK_AUDIO_TRANSITION (tmp->data)
|
|
|
|
|| GES_IS_TRACK_VIDEO_TRANSITION (tmp->data)) {
|
|
|
|
layer =
|
|
|
|
ges_timeline_object_get_layer (ges_track_object_get_timeline_object
|
|
|
|
(tmp->data));
|
|
|
|
if (ges_timeline_layer_get_auto_transition (layer)) {
|
|
|
|
ges_track_enable_update (track, FALSE);
|
|
|
|
ges_timeline_layer_remove_object (layer,
|
|
|
|
ges_track_object_get_timeline_object (tmp->data));
|
|
|
|
ges_track_enable_update (track, TRUE);
|
|
|
|
}
|
|
|
|
g_object_unref (layer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_object_unref (track_object);
|
|
|
|
}
|
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
static void
|
2011-07-24 00:49:36 +00:00
|
|
|
track_object_added_cb (GESTimelineObject * object,
|
2011-08-24 10:04:32 +00:00
|
|
|
GESTrackObject * track_object, GHashTable * signal_table)
|
2011-07-24 00:49:36 +00:00
|
|
|
{
|
2011-08-24 10:04:32 +00:00
|
|
|
GESTrack *track;
|
|
|
|
gint ptr;
|
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
if (GES_IS_TRACK_SOURCE (track_object)) {
|
|
|
|
g_signal_connect (G_OBJECT (track_object), "notify::start",
|
2011-12-21 18:48:22 +00:00
|
|
|
G_CALLBACK (track_object_changed_cb), NULL);
|
2011-11-02 16:51:36 +00:00
|
|
|
g_signal_connect (G_OBJECT (track_object), "notify::duration",
|
2011-12-21 18:48:22 +00:00
|
|
|
G_CALLBACK (track_object_duration_cb), NULL);
|
|
|
|
calculate_transitions (track_object);
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
2011-08-24 10:04:32 +00:00
|
|
|
track = ges_track_object_get_track (track_object);
|
|
|
|
if (!g_hash_table_lookup (signal_table, track)) {
|
|
|
|
ptr = g_signal_connect (track, "track-object-removed",
|
|
|
|
(GCallback) track_object_deleted_cb, NULL);
|
2011-12-23 16:16:20 +00:00
|
|
|
g_hash_table_insert (signal_table, track, GINT_TO_POINTER (ptr));
|
2011-08-24 10:04:32 +00:00
|
|
|
}
|
2011-07-24 00:49:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
static void
|
|
|
|
track_object_removed_cb (GESTimelineObject * object,
|
2011-12-21 18:48:22 +00:00
|
|
|
GESTrackObject * track_object)
|
2011-11-02 16:51:36 +00:00
|
|
|
{
|
2011-08-24 10:04:32 +00:00
|
|
|
return;
|
2011-11-02 16:51:36 +00:00
|
|
|
if (GES_IS_TRACK_SOURCE (track_object)) {
|
|
|
|
g_signal_handlers_disconnect_by_func (track_object, track_object_changed_cb,
|
|
|
|
object);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-07-24 00:49:36 +00:00
|
|
|
timeline_object_height_changed_cb (GESTimelineObject * obj,
|
|
|
|
GESTrackEffect * tr_eff, GESTimelineObject * second_obj)
|
|
|
|
{
|
|
|
|
gint priority, height;
|
|
|
|
g_object_get (obj, "height", &height, "priority", &priority, NULL);
|
|
|
|
g_object_set (second_obj, "priority", priority + height, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-02 16:51:36 +00:00
|
|
|
track_object_changed_cb (GESTrackObject * track_object,
|
2011-12-21 18:48:22 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED)
|
2011-07-24 00:49:36 +00:00
|
|
|
{
|
2011-11-02 16:51:36 +00:00
|
|
|
if (G_LIKELY (GES_IS_TRACK_SOURCE (track_object)))
|
2011-12-21 18:48:22 +00:00
|
|
|
calculate_transitions (track_object);
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
static void
|
|
|
|
calculate_next_transition_with_list (GESTrackObject * track_object,
|
|
|
|
GList * tckobjs_in_layer, GESTimelineLayer * layer)
|
2011-07-24 00:49:36 +00:00
|
|
|
{
|
2011-11-02 16:51:36 +00:00
|
|
|
GList *compared;
|
2011-07-24 00:49:36 +00:00
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
if (!(compared = g_list_find (tckobjs_in_layer, track_object)))
|
|
|
|
return;
|
2011-07-24 00:49:36 +00:00
|
|
|
|
|
|
|
if (compared == NULL)
|
2011-11-02 16:51:36 +00:00
|
|
|
/* This is the last TrackObject of the Track */
|
|
|
|
return;
|
2011-07-24 00:49:36 +00:00
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
do {
|
|
|
|
compared = compared->next;
|
2011-07-24 00:49:36 +00:00
|
|
|
if (compared == NULL)
|
2011-11-02 16:51:36 +00:00
|
|
|
return;
|
|
|
|
} while (!GES_IS_TRACK_SOURCE (compared->data));
|
|
|
|
|
|
|
|
compare (compared, track_object, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
calculate_next_transition (GESTrackObject * track_object,
|
|
|
|
GESTimelineLayer * layer)
|
|
|
|
{
|
|
|
|
GESTrack *track = ges_track_object_get_track (track_object);
|
|
|
|
GList *tckobjs_in_layer = track_get_by_layer (layer, track);
|
|
|
|
|
|
|
|
if (ges_track_object_get_track (track_object)) {
|
|
|
|
calculate_next_transition_with_list (track_object, tckobjs_in_layer, layer);
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
g_list_free_full (tckobjs_in_layer, g_object_unref);
|
|
|
|
}
|
2011-07-24 00:49:36 +00:00
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
static void
|
2011-12-21 18:48:22 +00:00
|
|
|
calculate_transitions (GESTrackObject * track_object)
|
2011-11-02 16:51:36 +00:00
|
|
|
{
|
|
|
|
GList *tckobjs_in_layer, *compared;
|
|
|
|
GESTrack *track = ges_track_object_get_track (track_object);
|
2011-12-21 18:48:22 +00:00
|
|
|
GESTimelineLayer *layer;
|
|
|
|
GESTimelineObject *tlobj;
|
2011-07-24 00:49:36 +00:00
|
|
|
|
2011-12-21 18:48:22 +00:00
|
|
|
tlobj = ges_track_object_get_timeline_object (track_object);
|
|
|
|
layer = ges_timeline_object_get_layer (tlobj);
|
2011-11-02 16:51:36 +00:00
|
|
|
tckobjs_in_layer = track_get_by_layer (layer, track);
|
|
|
|
if (!(compared = g_list_find (tckobjs_in_layer, track_object)))
|
2011-07-24 00:49:36 +00:00
|
|
|
return;
|
2011-11-02 16:51:36 +00:00
|
|
|
do {
|
|
|
|
compared = compared->prev;
|
|
|
|
|
|
|
|
if (compared == NULL) {
|
|
|
|
/* Nothing before, let's check after */
|
|
|
|
calculate_next_transition_with_list (track_object, tckobjs_in_layer,
|
|
|
|
layer);
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
}
|
|
|
|
} while (!GES_IS_TRACK_SOURCE (compared->data));
|
|
|
|
|
|
|
|
compare (compared, track_object, TRUE);
|
2011-07-24 00:49:36 +00:00
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
calculate_next_transition_with_list (track_object, tckobjs_in_layer, layer);
|
2011-07-24 00:49:36 +00:00
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
done:
|
|
|
|
g_list_free_full (tckobjs_in_layer, g_object_unref);
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
/* Compare:
|
|
|
|
* @compared: The #GList of #GESTrackObjects that we compare with @track_object
|
|
|
|
* @track_object: The #GESTrackObject that serves as a reference
|
|
|
|
* @ahead: %TRUE if we are comparing frontward %FALSE if we are comparing
|
|
|
|
* backward*/
|
2011-07-24 00:49:36 +00:00
|
|
|
static void
|
|
|
|
compare (GList * compared, GESTrackObject * track_object, gboolean ahead)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
2011-09-14 12:58:01 +00:00
|
|
|
gint64 start, duration, compared_start, compared_duration, end, compared_end,
|
|
|
|
tr_start, tr_duration;
|
2011-11-02 16:51:36 +00:00
|
|
|
GESTimelineStandardTransition *trans = NULL;
|
2011-07-24 00:49:36 +00:00
|
|
|
GESTrack *track;
|
|
|
|
GESTimelineLayer *layer;
|
2011-09-14 12:58:01 +00:00
|
|
|
GESTimelineObject *object, *compared_object, *first_object, *second_object;
|
2011-07-24 00:49:36 +00:00
|
|
|
gint priority;
|
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
g_return_if_fail (compared);
|
|
|
|
|
|
|
|
GST_DEBUG ("Recalculating transitions");
|
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
object = ges_track_object_get_timeline_object (track_object);
|
2011-11-02 16:51:36 +00:00
|
|
|
|
|
|
|
if (!object) {
|
|
|
|
GST_WARNING ("Trackobject not in a timeline object: "
|
|
|
|
"Can not calulate transitions");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-09-14 12:58:01 +00:00
|
|
|
compared_object = ges_track_object_get_timeline_object (compared->data);
|
2011-07-24 00:49:36 +00:00
|
|
|
layer = ges_timeline_object_get_layer (object);
|
|
|
|
|
|
|
|
start = ges_track_object_get_start (track_object);
|
|
|
|
duration = ges_track_object_get_duration (track_object);
|
|
|
|
compared_start = ges_track_object_get_start (compared->data);
|
|
|
|
compared_duration = ges_track_object_get_duration (compared->data);
|
2011-09-14 12:58:01 +00:00
|
|
|
end = start + duration;
|
|
|
|
compared_end = compared_start + compared_duration;
|
2011-07-24 00:49:36 +00:00
|
|
|
|
|
|
|
if (ahead) {
|
2011-11-02 16:51:36 +00:00
|
|
|
/* Make sure we remove the last transition we created it is not needed
|
|
|
|
* FIXME make it a smarter way */
|
|
|
|
if (compared->prev && GES_IS_TRACK_TRANSITION (compared->prev->data)) {
|
|
|
|
trans = GES_TIMELINE_STANDARD_TRANSITION
|
|
|
|
(ges_track_object_get_timeline_object (compared->prev->data));
|
|
|
|
g_object_get (compared->prev->data, "start", &tr_start, "duration",
|
|
|
|
&tr_duration, NULL);
|
|
|
|
if (tr_start >= compared_start && tr_start + tr_duration <= compared_end)
|
|
|
|
ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (trans));
|
|
|
|
trans = NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
for (tmp = compared->next; tmp; tmp = tmp->next) {
|
2011-12-21 18:48:22 +00:00
|
|
|
/* If we have a transitionmnmnm we recaluculuculate its values */
|
2011-11-02 16:51:36 +00:00
|
|
|
if (GES_IS_TRACK_TRANSITION (tmp->data)) {
|
2011-07-24 00:49:36 +00:00
|
|
|
g_object_get (tmp->data, "start", &tr_start, "duration", &tr_duration,
|
|
|
|
NULL);
|
2011-11-02 16:51:36 +00:00
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
if (tr_start + tr_duration == compared_start + compared_duration) {
|
2011-11-02 16:51:36 +00:00
|
|
|
GESTimelineObject *tlobj;
|
|
|
|
tlobj = ges_track_object_get_timeline_object (tmp->data);
|
|
|
|
|
|
|
|
trans = GES_TIMELINE_STANDARD_TRANSITION (tlobj);
|
2011-07-24 00:49:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-11-02 16:51:36 +00:00
|
|
|
}
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
2011-09-14 12:58:01 +00:00
|
|
|
|
|
|
|
if (compared_end <= start) {
|
2011-11-02 16:51:36 +00:00
|
|
|
if (trans) {
|
|
|
|
ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (trans));
|
2011-09-14 12:58:01 +00:00
|
|
|
g_object_get (compared_object, "priority", &priority, NULL);
|
|
|
|
g_object_set (object, "priority", priority, NULL);
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
2011-11-02 16:51:36 +00:00
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
goto clean;
|
2011-09-14 12:58:01 +00:00
|
|
|
} else if (start > compared_start && end < compared_end) {
|
2011-11-02 16:51:36 +00:00
|
|
|
if (trans) {
|
|
|
|
/* Transition not needed anymore */
|
|
|
|
ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (trans));
|
2011-09-14 12:58:01 +00:00
|
|
|
}
|
|
|
|
goto clean;
|
|
|
|
} else if (start <= compared_start) {
|
2011-11-02 16:51:36 +00:00
|
|
|
if (trans) {
|
|
|
|
ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (trans));
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
2011-11-02 16:51:36 +00:00
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
goto clean;
|
|
|
|
}
|
2011-09-14 12:58:01 +00:00
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
} else {
|
2011-11-02 16:51:36 +00:00
|
|
|
if (compared->next && GES_IS_TRACK_TRANSITION (compared->next->data)) {
|
|
|
|
trans = GES_TIMELINE_STANDARD_TRANSITION
|
|
|
|
(ges_track_object_get_timeline_object (compared->next->data));
|
|
|
|
g_object_get (compared->prev->data, "start", &tr_start, "duration",
|
|
|
|
&tr_duration, NULL);
|
|
|
|
if (tr_start >= compared_start && tr_start + tr_duration <= compared_end)
|
|
|
|
ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (trans));
|
|
|
|
trans = NULL;
|
|
|
|
}
|
2011-07-24 00:49:36 +00:00
|
|
|
for (tmp = compared->prev; tmp; tmp = tmp->prev) {
|
|
|
|
if GES_IS_TRACK_TRANSITION
|
|
|
|
(tmp->data) {
|
|
|
|
g_object_get (tmp->data, "start", &tr_start, "duration", &tr_duration,
|
|
|
|
NULL);
|
|
|
|
if (tr_start == compared_start) {
|
2011-11-02 16:51:36 +00:00
|
|
|
trans = GES_TIMELINE_STANDARD_TRANSITION
|
2011-07-24 00:49:36 +00:00
|
|
|
(ges_track_object_get_timeline_object (tmp->data));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-09-14 12:58:01 +00:00
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
if (start + duration <= compared_start) {
|
2011-11-02 16:51:36 +00:00
|
|
|
if (trans) {
|
|
|
|
ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (trans));
|
2011-09-14 12:58:01 +00:00
|
|
|
g_object_get (object, "priority", &priority, NULL);
|
|
|
|
g_object_set (compared_object, "priority", priority, NULL);
|
|
|
|
}
|
|
|
|
goto clean;
|
2011-11-02 16:51:36 +00:00
|
|
|
|
2011-09-14 12:58:01 +00:00
|
|
|
} else if (start > compared_start) {
|
2011-11-02 16:51:36 +00:00
|
|
|
if (trans)
|
|
|
|
ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (trans));
|
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
goto clean;
|
2011-09-14 12:58:01 +00:00
|
|
|
} else if (start < compared_start && end > compared_end) {
|
2011-11-02 16:51:36 +00:00
|
|
|
if (trans) {
|
|
|
|
ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (trans));
|
2011-09-14 12:58:01 +00:00
|
|
|
}
|
2011-11-02 16:51:36 +00:00
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
goto clean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
if (!trans) {
|
2011-07-24 00:49:36 +00:00
|
|
|
gint height;
|
2011-11-02 16:51:36 +00:00
|
|
|
|
|
|
|
trans =
|
|
|
|
ges_timeline_standard_transition_new_for_nick ((gchar *) "crossfade");
|
2011-07-24 00:49:36 +00:00
|
|
|
track = ges_track_object_get_track (track_object);
|
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
ges_timeline_object_set_supported_formats (GES_TIMELINE_OBJECT (trans),
|
2011-07-24 00:49:36 +00:00
|
|
|
track->type);
|
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
ges_timeline_layer_add_object (layer, GES_TIMELINE_OBJECT (trans));
|
2011-07-24 00:49:36 +00:00
|
|
|
|
|
|
|
if (ahead) {
|
|
|
|
first_object = ges_track_object_get_timeline_object (compared->data);
|
|
|
|
second_object = object;
|
|
|
|
} else {
|
|
|
|
second_object = ges_track_object_get_timeline_object (compared->data);
|
|
|
|
first_object = object;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (first_object, "priority", &priority, "height", &height, NULL);
|
|
|
|
g_object_set (second_object, "priority", priority + height, NULL);
|
|
|
|
g_signal_connect (first_object, "notify::height",
|
|
|
|
(GCallback) timeline_object_height_changed_cb, second_object);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ahead) {
|
2011-11-02 16:51:36 +00:00
|
|
|
g_object_set (trans, "start", start, "duration",
|
2011-07-24 00:49:36 +00:00
|
|
|
compared_duration + compared_start - start, NULL);
|
|
|
|
} else {
|
2011-11-02 16:51:36 +00:00
|
|
|
g_object_set (trans, "start", compared_start, "duration",
|
2011-07-24 00:49:36 +00:00
|
|
|
start + duration - compared_start, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
clean:
|
|
|
|
g_object_unref (layer);
|
|
|
|
}
|
|
|
|
|
2011-08-24 10:04:32 +00:00
|
|
|
static void
|
|
|
|
look_for_transition (GESTrackObject * track_object, GESTimelineLayer * layer)
|
|
|
|
{
|
|
|
|
GESTrack *track;
|
|
|
|
GList *track_objects, *tmp, *cur;
|
|
|
|
|
|
|
|
track = ges_track_object_get_track (track_object);
|
|
|
|
|
|
|
|
track_objects = ges_track_get_objects (track);
|
|
|
|
|
|
|
|
cur = g_list_find (track_objects, track_object);
|
|
|
|
|
|
|
|
for (tmp = cur->next; tmp; tmp = tmp->next) {
|
|
|
|
if (GES_IS_TRACK_SOURCE (tmp->data)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (GES_IS_TRACK_AUDIO_TRANSITION (tmp->data)
|
|
|
|
|| GES_IS_TRACK_VIDEO_TRANSITION (tmp->data)) {
|
|
|
|
ges_timeline_layer_remove_object (layer,
|
|
|
|
ges_track_object_get_timeline_object (tmp->data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (tmp = cur->prev; tmp; tmp = tmp->prev) {
|
|
|
|
if (GES_IS_TRACK_SOURCE (tmp->data)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (GES_IS_TRACK_AUDIO_TRANSITION (tmp->data)
|
|
|
|
|| GES_IS_TRACK_VIDEO_TRANSITION (tmp->data)) {
|
|
|
|
ges_timeline_layer_remove_object (layer,
|
|
|
|
ges_track_object_get_timeline_object (tmp->data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_list_free_full (track_objects, g_object_unref);
|
|
|
|
}
|
2011-07-24 00:49:36 +00:00
|
|
|
|
2011-12-23 16:16:20 +00:00
|
|
|
static gboolean
|
|
|
|
disconnect_handlers (GESTrack * track, gpointer * ptr)
|
|
|
|
{
|
|
|
|
g_signal_handler_disconnect (track, GPOINTER_TO_INT (ptr));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-09-14 17:23:52 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_layer_remove_object:
|
|
|
|
* @layer: a #GESTimelineLayer
|
|
|
|
* @object: the #GESTimelineObject to remove
|
|
|
|
*
|
2010-12-20 11:01:04 +00:00
|
|
|
* Removes the given @object from the @layer and unparents it.
|
|
|
|
* Unparenting it means the reference owned by @layer on the @object will be
|
|
|
|
* removed. If you wish to use the @object after this function, make sure you
|
|
|
|
* call g_object_ref() before removing it from the @layer.
|
2009-09-14 17:23:52 +00:00
|
|
|
*
|
2010-12-20 11:01:04 +00:00
|
|
|
* Returns: TRUE if the object could be removed, FALSE if the layer does
|
|
|
|
* not want to remove the object.
|
2009-09-14 17:23:52 +00:00
|
|
|
*/
|
2009-08-07 14:39:09 +00:00
|
|
|
gboolean
|
|
|
|
ges_timeline_layer_remove_object (GESTimelineLayer * layer,
|
|
|
|
GESTimelineObject * object)
|
|
|
|
{
|
2010-11-28 12:24:07 +00:00
|
|
|
GESTimelineLayer *tl_obj_layer;
|
2011-08-24 10:04:32 +00:00
|
|
|
GList *trackobjects, *tmp;
|
2010-12-20 11:01:04 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), FALSE);
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
|
|
|
|
|
2009-08-07 14:39:09 +00:00
|
|
|
GST_DEBUG ("layer:%p, object:%p", layer, object);
|
|
|
|
|
2010-11-28 12:24:07 +00:00
|
|
|
tl_obj_layer = ges_timeline_object_get_layer (object);
|
|
|
|
if (G_UNLIKELY (tl_obj_layer != layer)) {
|
2009-08-07 14:39:09 +00:00
|
|
|
GST_WARNING ("TimelineObject doesn't belong to this layer");
|
2010-11-28 12:24:07 +00:00
|
|
|
if (tl_obj_layer != NULL)
|
|
|
|
g_object_unref (tl_obj_layer);
|
2009-08-07 14:39:09 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_unref (tl_obj_layer);
|
2009-08-07 14:39:09 +00:00
|
|
|
|
2011-08-24 10:04:32 +00:00
|
|
|
if (layer->priv->auto_transition) {
|
|
|
|
trackobjects = ges_timeline_object_get_track_objects (object);
|
|
|
|
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
|
|
|
look_for_transition (tmp->data, layer);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free_full (trackobjects, g_object_unref);
|
|
|
|
}
|
|
|
|
|
2011-12-23 16:16:20 +00:00
|
|
|
g_hash_table_foreach_remove (layer->priv->signal_table,
|
|
|
|
(GHRFunc) disconnect_handlers, NULL);
|
|
|
|
|
2009-08-07 14:39:09 +00:00
|
|
|
/* emit 'object-removed' */
|
|
|
|
g_signal_emit (layer, ges_timeline_layer_signals[OBJECT_REMOVED], 0, object);
|
|
|
|
|
|
|
|
/* inform the object it's no longer in a layer */
|
|
|
|
ges_timeline_object_set_layer (object, NULL);
|
|
|
|
|
|
|
|
/* Remove it from our list of controlled objects */
|
2010-12-16 11:41:26 +00:00
|
|
|
layer->priv->objects_start =
|
2011-07-24 00:49:36 +00:00
|
|
|
g_list_remove (layer->priv->objects_start, object);
|
2009-08-07 14:39:09 +00:00
|
|
|
|
|
|
|
/* Remove our reference to the object */
|
|
|
|
g_object_unref (object);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2010-03-12 18:06:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_layer_resync_priorities:
|
|
|
|
* @layer: a #GESTimelineLayer
|
|
|
|
*
|
|
|
|
* Resyncs the priorities of the objects controlled by @layer.
|
2010-12-16 11:41:26 +00:00
|
|
|
* This method
|
|
|
|
*/
|
2010-03-12 18:06:42 +00:00
|
|
|
gboolean
|
|
|
|
ges_timeline_layer_resync_priorities (GESTimelineLayer * layer)
|
|
|
|
{
|
2011-07-24 00:49:36 +00:00
|
|
|
GList *tmp;
|
2011-04-15 23:34:28 +00:00
|
|
|
GESTimelineObject *obj;
|
2010-03-12 18:06:42 +00:00
|
|
|
|
2011-06-03 02:01:43 +00:00
|
|
|
GST_DEBUG ("Resync priorities of %p", layer);
|
|
|
|
|
2010-03-12 18:06:42 +00:00
|
|
|
/* TODO : Inhibit composition updates while doing this.
|
|
|
|
* Ideally we want to do it from an even higher level, but here will
|
|
|
|
* do in the meantime. */
|
|
|
|
|
2010-12-16 11:41:26 +00:00
|
|
|
for (tmp = layer->priv->objects_start; tmp; tmp = tmp->next) {
|
2011-04-15 23:34:28 +00:00
|
|
|
obj = GES_TIMELINE_OBJECT (tmp->data);
|
|
|
|
ges_timeline_object_set_priority (obj, GES_TIMELINE_OBJECT_PRIORITY (obj));
|
2010-03-12 18:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-07-06 14:27:08 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_layer_set_priority:
|
|
|
|
* @layer: a #GESTimelineLayer
|
|
|
|
* @priority: the priority to set
|
|
|
|
*
|
2010-12-16 11:41:26 +00:00
|
|
|
* Sets the layer to the given @priority. See the documentation of the
|
|
|
|
* priority property for more information.
|
2010-07-06 14:27:08 +00:00
|
|
|
*/
|
2010-03-12 18:06:42 +00:00
|
|
|
void
|
|
|
|
ges_timeline_layer_set_priority (GESTimelineLayer * layer, guint priority)
|
|
|
|
{
|
2010-12-16 11:41:26 +00:00
|
|
|
g_return_if_fail (GES_IS_TIMELINE_LAYER (layer));
|
|
|
|
|
2010-03-12 18:06:42 +00:00
|
|
|
GST_DEBUG ("layer:%p, priority:%d", layer, priority);
|
|
|
|
|
2010-12-16 11:41:26 +00:00
|
|
|
if (priority != layer->priv->priority) {
|
|
|
|
layer->priv->priority = priority;
|
2011-06-03 01:35:59 +00:00
|
|
|
layer->min_gnl_priority = (priority * LAYER_HEIGHT);
|
|
|
|
layer->max_gnl_priority = ((priority + 1) * LAYER_HEIGHT) - 1;
|
2010-03-12 18:06:42 +00:00
|
|
|
|
|
|
|
ges_timeline_layer_resync_priorities (layer);
|
|
|
|
}
|
|
|
|
}
|
2010-09-22 11:29:26 +00:00
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_layer_get_auto_transition:
|
|
|
|
* @layer: a #GESTimelineLayer
|
|
|
|
*
|
|
|
|
* Get the priority of @layer within the timeline.
|
|
|
|
*
|
|
|
|
* Returns: The priority of the @layer within the timeline.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_timeline_layer_get_auto_transition (GESTimelineLayer * layer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), 0);
|
|
|
|
|
|
|
|
return layer->priv->auto_transition;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_layer_set_auto_transition:
|
|
|
|
* @layer: a #GESTimelineLayer
|
2011-12-07 02:11:25 +00:00
|
|
|
* @auto_transition: whether the auto_transition is active
|
2011-07-24 00:49:36 +00:00
|
|
|
*
|
|
|
|
* Sets the layer to the given @auto_transition. See the documentation of the
|
2011-12-07 02:11:25 +00:00
|
|
|
* property auto_transition for more information.
|
2011-07-24 00:49:36 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ges_timeline_layer_set_auto_transition (GESTimelineLayer * layer,
|
|
|
|
gboolean auto_transition)
|
|
|
|
{
|
2011-11-02 16:51:36 +00:00
|
|
|
|
|
|
|
GList *tmp;
|
2011-07-24 00:49:36 +00:00
|
|
|
g_return_if_fail (GES_IS_TIMELINE_LAYER (layer));
|
|
|
|
|
2011-11-02 16:51:36 +00:00
|
|
|
if (auto_transition) {
|
|
|
|
for (tmp = layer->priv->objects_start; tmp; tmp = tmp->next) {
|
|
|
|
if (GES_IS_TIMELINE_SOURCE (tmp->data)) {
|
|
|
|
g_signal_connect (G_OBJECT (tmp->data), "track-object-added",
|
|
|
|
G_CALLBACK (track_object_added_cb), layer);
|
|
|
|
g_signal_connect (G_OBJECT (tmp->data), "track-object-removed",
|
|
|
|
G_CALLBACK (track_object_removed_cb), layer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* FIXME calculate all the transitions at that time */
|
|
|
|
}
|
2011-07-24 00:49:36 +00:00
|
|
|
layer->priv->auto_transition = auto_transition;
|
|
|
|
}
|
|
|
|
|
2010-12-16 11:41:26 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_layer_get_priority:
|
|
|
|
* @layer: a #GESTimelineLayer
|
|
|
|
*
|
2011-01-10 13:28:35 +00:00
|
|
|
* Get the priority of @layer within the timeline.
|
|
|
|
*
|
|
|
|
* Returns: The priority of the @layer within the timeline.
|
2010-12-16 11:41:26 +00:00
|
|
|
*/
|
|
|
|
guint
|
|
|
|
ges_timeline_layer_get_priority (GESTimelineLayer * layer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), 0);
|
|
|
|
|
|
|
|
return layer->priv->priority;
|
|
|
|
}
|
|
|
|
|
2010-09-22 11:29:26 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_layer_get_objects:
|
|
|
|
* @layer: a #GESTimelineLayer
|
|
|
|
*
|
|
|
|
* Get the timeline objects this layer contains.
|
|
|
|
*
|
2010-12-15 18:40:11 +00:00
|
|
|
* Returns: (transfer full) (element-type GESTimelineObject): a #GList of
|
|
|
|
* timeline objects. The user is responsible for
|
2010-09-22 11:29:26 +00:00
|
|
|
* unreffing the contained objects and freeing the list.
|
|
|
|
*/
|
|
|
|
|
|
|
|
GList *
|
|
|
|
ges_timeline_layer_get_objects (GESTimelineLayer * layer)
|
|
|
|
{
|
|
|
|
GList *ret = NULL;
|
2011-07-24 00:49:36 +00:00
|
|
|
GList *tmp;
|
2010-09-22 11:29:26 +00:00
|
|
|
GESTimelineLayerClass *klass;
|
|
|
|
|
2010-12-16 11:41:26 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), NULL);
|
|
|
|
|
2010-09-22 11:29:26 +00:00
|
|
|
klass = GES_TIMELINE_LAYER_GET_CLASS (layer);
|
|
|
|
|
|
|
|
if (klass->get_objects) {
|
|
|
|
return klass->get_objects (layer);
|
|
|
|
}
|
|
|
|
|
2010-12-16 11:41:26 +00:00
|
|
|
for (tmp = layer->priv->objects_start; tmp; tmp = tmp->next) {
|
2010-09-22 11:29:26 +00:00
|
|
|
ret = g_list_prepend (ret, tmp->data);
|
|
|
|
g_object_ref (tmp->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = g_list_reverse (ret);
|
|
|
|
return ret;
|
|
|
|
}
|