1 /* GStreamer Editing Services
2 * Copyright (C) 2009 Edward Hervey <bilboed@bilboed.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include "ges-internal.h"
21 #include "gesmarshal.h"
22 #include "ges-timeline-layer.h"
28 * Responsible for the ordering of the various contained TimelineObject(s)
31 G_DEFINE_TYPE (GESTimelineLayer, ges_timeline_layer, G_TYPE_OBJECT);
33 #define GET_PRIVATE(o) \
34 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GES_TYPE_TIMELINE_LAYER, GESTimelineLayerPrivate));
36 typedef struct _GESTimelineLayerPrivate GESTimelineLayerPrivate;
38 struct _GESTimelineLayerPrivate
50 static guint ges_timeline_layer_signals[LAST_SIGNAL] = { 0 };
53 ges_timeline_layer_get_property (GObject * object, guint property_id,
54 GValue * value, GParamSpec * pspec)
56 switch (property_id) {
58 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
63 ges_timeline_layer_set_property (GObject * object, guint property_id,
64 const GValue * value, GParamSpec * pspec)
66 switch (property_id) {
68 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
73 ges_timeline_layer_dispose (GObject * object)
75 G_OBJECT_CLASS (ges_timeline_layer_parent_class)->dispose (object);
79 ges_timeline_layer_finalize (GObject * object)
81 G_OBJECT_CLASS (ges_timeline_layer_parent_class)->finalize (object);
85 ges_timeline_layer_class_init (GESTimelineLayerClass * klass)
87 GObjectClass *object_class = G_OBJECT_CLASS (klass);
89 g_type_class_add_private (klass, sizeof (GESTimelineLayerPrivate));
91 object_class->get_property = ges_timeline_layer_get_property;
92 object_class->set_property = ges_timeline_layer_set_property;
93 object_class->dispose = ges_timeline_layer_dispose;
94 object_class->finalize = ges_timeline_layer_finalize;
96 ges_timeline_layer_signals[OBJECT_ADDED] =
97 g_signal_new ("object-added", G_TYPE_FROM_CLASS (klass),
98 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineLayerClass, object_added),
99 NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
100 GES_TYPE_TIMELINE_OBJECT);
102 ges_timeline_layer_signals[OBJECT_REMOVED] =
103 g_signal_new ("object-removed", G_TYPE_FROM_CLASS (klass),
104 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineLayerClass,
105 object_removed), NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
106 GES_TYPE_TIMELINE_OBJECT);
111 ges_timeline_layer_init (GESTimelineLayer * self)
116 ges_timeline_layer_new (void)
118 return g_object_new (GES_TYPE_TIMELINE_LAYER, NULL);
122 ges_timeline_layer_set_timeline (GESTimelineLayer * layer,
123 GESTimeline * timeline)
125 GST_DEBUG ("layer:%p, timeline:%p", layer, timeline);
127 layer->timeline = timeline;
131 objects_start_compare (GESTimelineObject * a, GESTimelineObject * b)
133 if (a->start == b->start) {
134 if (a->priority < b->priority)
136 if (a->priority > b->priority)
140 if (a->start < b->start)
142 if (a->start > b->start)
148 ges_timeline_layer_add_object (GESTimelineLayer * layer,
149 GESTimelineObject * object)
151 GST_DEBUG ("layer:%p, object:%p", layer, object);
153 if (G_UNLIKELY (object->layer)) {
154 GST_WARNING ("TimelineObject %p already belongs to another layer");
158 /* Take a reference to the object and store it stored by start/priority */
159 layer->objects_start =
160 g_slist_insert_sorted (layer->objects_start, g_object_ref (object),
161 (GCompareFunc) objects_start_compare);
163 /* Inform the object it's now in this layer */
164 ges_timeline_object_set_layer (object, layer);
166 /* emit 'object-added' */
167 g_signal_emit (layer, ges_timeline_layer_signals[OBJECT_ADDED], 0, object);