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>
|
2013-01-10 14:58:59 +00:00
|
|
|
* 2013 Thibault Saunier <thibault.saunier@collabora.com>
|
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
|
2012-11-04 00:25:20 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2009-08-04 15:13:11 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2009-09-10 16:40:51 +00:00
|
|
|
* SECTION:ges-timeline-layer
|
2013-01-20 15:42:29 +00:00
|
|
|
* @short_description: Non-overlapping sequence of GESClip
|
2009-08-04 15:13:11 +00:00
|
|
|
*
|
2013-01-20 15:42:29 +00:00
|
|
|
* Responsible for the ordering of the various contained Clip(s). A
|
2010-05-31 16:59:12 +00:00
|
|
|
* timeline layer has a "priority" property, which is used to manage the
|
2013-01-20 15:42:29 +00:00
|
|
|
* priorities of individual Clips. Two layers should not have the
|
2010-05-31 16:59:12 +00:00
|
|
|
* 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 "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
|
|
|
|
2012-12-17 18:24:52 +00:00
|
|
|
static void ges_meta_container_interface_init
|
|
|
|
(GESMetaContainerInterface * iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GESTimelineLayer, ges_timeline_layer,
|
2012-11-29 20:07:24 +00:00
|
|
|
G_TYPE_INITIALLY_UNOWNED, G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE, NULL)
|
2012-12-17 18:24:52 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (GES_TYPE_META_CONTAINER,
|
|
|
|
ges_meta_container_interface_init));
|
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 > */
|
2013-01-20 15:42:29 +00:00
|
|
|
GList *objects_start; /* The Clips sorted by start and
|
2010-12-16 11:41:26 +00:00
|
|
|
* priority */
|
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
guint32 priority; /* The priority of the layer within the
|
2010-12-16 11:41:26 +00:00
|
|
|
* containing timeline */
|
2011-07-24 00:49:36 +00:00
|
|
|
gboolean auto_transition;
|
2010-12-04 18:54:13 +00:00
|
|
|
};
|
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *object;
|
2012-12-17 20:05:56 +00:00
|
|
|
GESTimelineLayer *layer;
|
|
|
|
} NewAssetUData;
|
|
|
|
|
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 };
|
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
/* GObject standard vmethods */
|
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,
|
2013-01-20 15:42:29 +00:00
|
|
|
(GESClip *) 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);
|
|
|
|
}
|
|
|
|
|
2012-12-17 18:24:52 +00:00
|
|
|
static void
|
|
|
|
ges_meta_container_interface_init (GESMetaContainerInterface * iface)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
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
|
|
|
/**
|
2012-08-10 16:39:10 +00:00
|
|
|
* GESTimelineLayer:priority:
|
2010-03-12 18:06:42 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
/**
|
2012-08-10 16:39:10 +00:00
|
|
|
* GESTimelineLayer:auto-transition:
|
2011-07-24 00:49:36 +00:00
|
|
|
*
|
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
|
|
|
/**
|
2012-08-10 16:39:10 +00:00
|
|
|
* GESTimelineLayer::object-added:
|
2009-09-16 10:37:45 +00:00
|
|
|
* @layer: the #GESTimelineLayer
|
2013-01-20 15:42:29 +00:00
|
|
|
* @object: the #GESClip that was added.
|
2009-09-16 10:37:45 +00:00
|
|
|
*
|
|
|
|
* 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),
|
2013-01-20 15:42:29 +00:00
|
|
|
NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GES_TYPE_CLIP);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
2012-08-10 16:39:10 +00:00
|
|
|
* GESTimelineLayer::object-removed:
|
2009-09-16 10:37:45 +00:00
|
|
|
* @layer: the #GESTimelineLayer
|
2013-01-20 15:42:29 +00:00
|
|
|
* @object: the #GESClip that was removed
|
2009-09-16 10:37:45 +00:00
|
|
|
*
|
|
|
|
* 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,
|
2012-03-12 15:46:42 +00:00
|
|
|
object_removed), NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE,
|
2013-01-20 15:42:29 +00:00
|
|
|
1, GES_TYPE_CLIP);
|
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;
|
2009-08-06 15:38:43 +00:00
|
|
|
}
|
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_layer_resync_priorities:
|
|
|
|
* @layer: a #GESTimelineLayer
|
|
|
|
*
|
|
|
|
* Resyncs the priorities of the objects controlled by @layer.
|
|
|
|
* This method
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
ges_timeline_layer_resync_priorities (GESTimelineLayer * layer)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
2013-01-15 13:52:17 +00:00
|
|
|
GESTimelineElement *obj;
|
2011-07-24 00:49:36 +00:00
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
GST_DEBUG ("Resync priorities of %p", layer);
|
2011-07-24 00:49:36 +00:00
|
|
|
|
2012-04-08 01:24:18 +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. */
|
|
|
|
|
|
|
|
for (tmp = layer->priv->objects_start; tmp; tmp = tmp->next) {
|
2013-01-15 13:52:17 +00:00
|
|
|
obj = GES_TIMELINE_ELEMENT (tmp->data);
|
|
|
|
_set_priority0 (obj, _PRIORITY (obj));
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
return TRUE;
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
static void
|
|
|
|
new_asset_cb (GESAsset * source, GAsyncResult * res, NewAssetUData * udata)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
GESAsset *asset = ges_asset_request_finish (res, &error);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (udata->layer, "%" GST_PTR_FORMAT " Asset loaded, "
|
|
|
|
"setting its asset", udata->object);
|
|
|
|
|
|
|
|
if (error) {
|
2012-12-17 20:06:33 +00:00
|
|
|
GESProject *project = udata->layer->timeline ?
|
|
|
|
GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE
|
|
|
|
(udata->layer->timeline))) : NULL;
|
|
|
|
if (project) {
|
|
|
|
gchar *possible_id;
|
|
|
|
|
|
|
|
possible_id = ges_project_try_updating_id (project, source, error);
|
|
|
|
if (possible_id) {
|
|
|
|
ges_asset_request_async (ges_asset_get_extractable_type (source),
|
|
|
|
possible_id, NULL, (GAsyncReadyCallback) new_asset_cb, udata);
|
|
|
|
g_free (possible_id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-01-11 14:49:02 +00:00
|
|
|
|
|
|
|
GST_ERROR ("Asset could not be created for uri %s, error: %s",
|
|
|
|
ges_asset_get_id (asset), error->message);
|
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
} else {
|
2012-12-17 20:06:33 +00:00
|
|
|
GESProject *project = udata->layer->timeline ?
|
|
|
|
GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE
|
|
|
|
(udata->layer->timeline))) : NULL;
|
|
|
|
ges_extractable_set_asset (GES_EXTRACTABLE (udata->object), asset);
|
|
|
|
|
|
|
|
ges_project_add_asset (project, asset);
|
2012-12-17 20:05:56 +00:00
|
|
|
ges_timeline_layer_add_object (udata->layer, udata->object);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (asset);
|
|
|
|
g_slice_free (NewAssetUData, udata);
|
|
|
|
}
|
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
/* Public methods */
|
2009-09-14 17:23:52 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_layer_remove_object:
|
|
|
|
* @layer: a #GESTimelineLayer
|
2013-01-20 15:42:29 +00:00
|
|
|
* @object: the #GESClip to remove
|
2009-09-14 17:23:52 +00:00
|
|
|
*
|
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
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_timeline_layer_remove_object (GESTimelineLayer * layer, GESClip * object)
|
2009-08-07 14:39:09 +00:00
|
|
|
{
|
2012-12-17 20:05:56 +00:00
|
|
|
GESTimelineLayer *current_layer;
|
2010-12-20 11:01:04 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), FALSE);
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), FALSE);
|
2010-12-20 11:01:04 +00:00
|
|
|
|
2009-08-07 14:39:09 +00:00
|
|
|
GST_DEBUG ("layer:%p, object:%p", layer, object);
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
current_layer = ges_clip_get_layer (object);
|
2012-12-17 20:05:56 +00:00
|
|
|
if (G_UNLIKELY (current_layer != layer)) {
|
2013-01-20 15:42:29 +00:00
|
|
|
GST_WARNING ("Clip doesn't belong to this layer");
|
2012-04-08 01:40:07 +00:00
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
if (current_layer != NULL)
|
|
|
|
g_object_unref (current_layer);
|
2012-04-08 01:40:07 +00:00
|
|
|
|
2009-08-07 14:39:09 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2012-12-17 20:05:56 +00:00
|
|
|
g_object_unref (current_layer);
|
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 */
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_set_layer (object, NULL);
|
2009-08-07 14:39:09 +00:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
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
|
|
|
|
*
|
2012-01-12 15:34:13 +00:00
|
|
|
* Gets whether transitions are automatically added when objects
|
|
|
|
* overlap or not.
|
2011-07-24 00:49:36 +00:00
|
|
|
*
|
2012-01-12 15:34:13 +00:00
|
|
|
* Returns: %TRUE if transitions are automatically added, else %FALSE.
|
2011-07-24 00:49:36 +00:00
|
|
|
*/
|
|
|
|
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
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
g_return_if_fail (GES_IS_TIMELINE_LAYER (layer));
|
|
|
|
|
|
|
|
layer->priv->auto_transition = auto_transition;
|
2013-01-10 14:58:59 +00:00
|
|
|
g_object_notify (G_OBJECT (layer), "auto-transition");
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*
|
2013-01-20 15:42:29 +00:00
|
|
|
* Returns: (transfer full) (element-type GESClip): a #GList of
|
2010-12-15 18:40:11 +00:00
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2013-01-10 14:15:32 +00:00
|
|
|
return g_list_sort (g_list_copy_deep (layer->priv->objects_start,
|
|
|
|
(GCopyFunc) gst_object_ref, NULL),
|
2013-01-15 13:52:17 +00:00
|
|
|
(GCompareFunc) element_start_compare);
|
2010-09-22 11:29:26 +00:00
|
|
|
}
|
2012-01-20 17:36:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_layer_is_empty:
|
|
|
|
* @layer: The #GESTimelineLayer to check
|
|
|
|
*
|
|
|
|
* Convenience method to check if @layer is empty (doesn't contain any object),
|
|
|
|
* or not.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @layer is empty, %FALSE if it already contains at least
|
2013-01-20 15:42:29 +00:00
|
|
|
* one #GESClip
|
2012-01-20 17:36:36 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_timeline_layer_is_empty (GESTimelineLayer * layer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), FALSE);
|
|
|
|
|
|
|
|
return (layer->priv->objects_start == NULL);
|
|
|
|
}
|
2012-04-08 01:24:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_layer_add_object:
|
|
|
|
* @layer: a #GESTimelineLayer
|
2013-01-20 15:42:29 +00:00
|
|
|
* @object: (transfer full): the #GESClip to add.
|
2012-04-08 01:24:18 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Calling this method will construct and properly set all the media related
|
|
|
|
* elements on @object. If you need to know when those objects (actually #GESTrackObject)
|
|
|
|
* are constructed, you should connect to the object::track-object-added signal which
|
|
|
|
* is emited right after those elements are ready to be used.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the object was properly added to the layer, or FALSE
|
|
|
|
* if the @layer refuses to add the object.
|
|
|
|
*/
|
|
|
|
gboolean
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_timeline_layer_add_object (GESTimelineLayer * layer, GESClip * object)
|
2012-04-08 01:24:18 +00:00
|
|
|
{
|
2012-12-17 20:05:56 +00:00
|
|
|
GESAsset *asset;
|
2013-01-10 15:41:13 +00:00
|
|
|
GESTimelineLayerPrivate *priv;
|
2012-12-17 20:05:56 +00:00
|
|
|
GESTimelineLayer *current_layer;
|
2012-04-08 01:24:18 +00:00
|
|
|
guint32 maxprio, minprio, prio;
|
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), FALSE);
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), FALSE);
|
2012-04-08 01:24:18 +00:00
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
GST_DEBUG_OBJECT (layer, "adding object:%p", object);
|
2012-04-08 01:24:18 +00:00
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
priv = layer->priv;
|
2013-01-20 15:42:29 +00:00
|
|
|
current_layer = ges_clip_get_layer (object);
|
2012-12-17 20:05:56 +00:00
|
|
|
if (G_UNLIKELY (current_layer)) {
|
2013-01-20 15:42:29 +00:00
|
|
|
GST_WARNING ("Clip %p already belongs to another layer", object);
|
2012-12-17 20:05:56 +00:00
|
|
|
g_object_unref (current_layer);
|
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
asset = ges_extractable_get_asset (GES_EXTRACTABLE (object));
|
|
|
|
if (asset == NULL) {
|
|
|
|
gchar *id;
|
|
|
|
NewAssetUData *mudata = g_slice_new (NewAssetUData);
|
|
|
|
|
|
|
|
mudata->object = object;
|
|
|
|
mudata->layer = layer;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (layer, "%" GST_PTR_FORMAT " as no reference to any "
|
|
|
|
"assets creating a asset... trying sync", object);
|
|
|
|
|
|
|
|
id = ges_extractable_get_id (GES_EXTRACTABLE (object));
|
|
|
|
asset = ges_asset_request (G_OBJECT_TYPE (object), id, NULL);
|
|
|
|
if (asset == NULL) {
|
2013-01-11 22:10:31 +00:00
|
|
|
GESProject *project = layer->timeline ?
|
|
|
|
GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE
|
|
|
|
(layer->timeline))) : NULL;
|
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
ges_asset_request_async (G_OBJECT_TYPE (object),
|
|
|
|
id, NULL, (GAsyncReadyCallback) new_asset_cb, mudata);
|
2013-01-11 22:10:31 +00:00
|
|
|
|
|
|
|
if (project)
|
|
|
|
ges_project_add_loading_asset (project, G_OBJECT_TYPE (object), id);
|
2012-12-17 20:05:56 +00:00
|
|
|
g_free (id);
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (layer, "Object added async");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
g_free (id);
|
|
|
|
|
|
|
|
ges_extractable_set_asset (GES_EXTRACTABLE (object), asset);
|
|
|
|
|
|
|
|
g_slice_free (NewAssetUData, mudata);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
g_object_ref_sink (object);
|
|
|
|
|
|
|
|
/* Take a reference to the object and store it stored by start/priority */
|
2012-12-17 20:05:56 +00:00
|
|
|
priv->objects_start = g_list_insert_sorted (priv->objects_start, object,
|
2013-01-15 13:52:17 +00:00
|
|
|
(GCompareFunc) element_start_compare);
|
2012-04-08 01:24:18 +00:00
|
|
|
|
|
|
|
/* Inform the object it's now in this layer */
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_set_layer (object, layer);
|
2012-04-08 01:24:18 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("current object priority : %d, layer min/max : %d/%d",
|
2013-01-15 13:52:17 +00:00
|
|
|
_PRIORITY (object), layer->min_gnl_priority, layer->max_gnl_priority);
|
2012-04-08 01:24:18 +00:00
|
|
|
|
|
|
|
/* Set the priority. */
|
|
|
|
maxprio = layer->max_gnl_priority;
|
|
|
|
minprio = layer->min_gnl_priority;
|
2013-01-15 13:52:17 +00:00
|
|
|
prio = _PRIORITY (object);
|
2012-12-17 20:05:56 +00:00
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
if (minprio + prio > (maxprio)) {
|
2012-12-17 20:05:56 +00:00
|
|
|
GST_WARNING_OBJECT (layer,
|
|
|
|
"%p is out of the layer space, setting its priority to "
|
|
|
|
"%d, setting it to the maximum priority of the layer: %d", object, prio,
|
|
|
|
maxprio - minprio);
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_priority0 (GES_TIMELINE_ELEMENT (object), LAYER_HEIGHT - 1);
|
2012-04-08 01:24:18 +00:00
|
|
|
}
|
2012-12-17 20:05:56 +00:00
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
/* If the object has an acceptable priority, we just let it with its current
|
|
|
|
* priority */
|
|
|
|
ges_timeline_layer_resync_priorities (layer);
|
|
|
|
|
|
|
|
/* emit 'object-added' */
|
|
|
|
g_signal_emit (layer, ges_timeline_layer_signals[OBJECT_ADDED], 0, object);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_layer_add_asset:
|
|
|
|
* @layer: a #GESTimelineLayer
|
|
|
|
* @asset: The asset to add to
|
2013-01-20 15:42:29 +00:00
|
|
|
* @start: The start value to set on the new #GESClip
|
|
|
|
* @inpoint: The inpoint value to set on the new #GESClip
|
|
|
|
* @duration: The duration value to set on the new #GESClip
|
|
|
|
* @rate: The rate value to set on the new #GESClip
|
|
|
|
* @track_types: The #GESTrackType to set on the the new #GESClip
|
2012-12-17 20:05:56 +00:00
|
|
|
*
|
2013-01-20 15:42:29 +00:00
|
|
|
* Creates Clip from asset, adds it to layer and
|
2012-12-17 20:05:56 +00:00
|
|
|
* returns a reference to it.
|
|
|
|
*
|
2013-01-20 15:42:29 +00:00
|
|
|
* Returns: (transfer none): Created #GESClip
|
2012-12-29 21:24:05 +00:00
|
|
|
*/
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *
|
2012-12-17 20:05:56 +00:00
|
|
|
ges_timeline_layer_add_asset (GESTimelineLayer * layer,
|
|
|
|
GESAsset * asset, GstClockTime start, GstClockTime inpoint,
|
|
|
|
GstClockTime duration, gdouble rate, GESTrackType track_types)
|
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *clip;
|
2012-12-17 20:05:56 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), NULL);
|
|
|
|
g_return_val_if_fail (GES_IS_ASSET (asset), NULL);
|
|
|
|
g_return_val_if_fail (g_type_is_a (ges_asset_get_extractable_type
|
2013-01-20 15:42:29 +00:00
|
|
|
(asset), GES_TYPE_CLIP), NULL);
|
2012-12-17 20:05:56 +00:00
|
|
|
|
2013-01-10 15:41:13 +00:00
|
|
|
GST_DEBUG_OBJECT (layer, "Adding asset %s with: start: %" GST_TIME_FORMAT
|
2013-01-22 19:51:25 +00:00
|
|
|
" inpoint: %" GST_TIME_FORMAT " duration: %" GST_TIME_FORMAT " rate %f"
|
2013-01-10 15:41:13 +00:00
|
|
|
" track types: %d (%s)", ges_asset_get_id (asset), GST_TIME_ARGS (start),
|
2013-01-11 14:49:02 +00:00
|
|
|
GST_TIME_ARGS (inpoint), GST_TIME_ARGS (duration), rate, track_types,
|
2013-01-10 15:41:13 +00:00
|
|
|
ges_track_type_name (track_types));
|
2012-12-17 20:05:56 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
clip = GES_CLIP (ges_asset_extract (asset, NULL));
|
|
|
|
_set_start0 (GES_TIMELINE_ELEMENT (clip), start);
|
|
|
|
_set_inpoint0 (GES_TIMELINE_ELEMENT (clip), inpoint);
|
2012-12-17 20:05:56 +00:00
|
|
|
if (track_types != GES_TRACK_TYPE_UNKNOWN)
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_set_supported_formats (clip, track_types);
|
2012-12-17 20:05:56 +00:00
|
|
|
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (duration)) {
|
2013-01-20 15:42:29 +00:00
|
|
|
_set_duration0 (GES_TIMELINE_ELEMENT (clip), duration);
|
2012-12-17 20:05:56 +00:00
|
|
|
}
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
if (!ges_timeline_layer_add_object (layer, clip)) {
|
|
|
|
gst_object_unref (clip);
|
2012-12-17 20:05:56 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
return clip;
|
2012-12-17 20:05:56 +00:00
|
|
|
}
|
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_layer_new:
|
|
|
|
*
|
|
|
|
* Creates a new #GESTimelineLayer.
|
|
|
|
*
|
|
|
|
* Returns: A new #GESTimelineLayer
|
|
|
|
*/
|
|
|
|
GESTimelineLayer *
|
|
|
|
ges_timeline_layer_new (void)
|
|
|
|
{
|
|
|
|
return g_object_new (GES_TYPE_TIMELINE_LAYER, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_layer_get_timeline:
|
|
|
|
* @layer: The #GESTimelineLayer to get the parent #GESTimeline from
|
|
|
|
*
|
|
|
|
* Get the #GESTimeline in which #GESTimelineLayer currently is.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): the #GESTimeline in which #GESTimelineLayer
|
|
|
|
* currently is or %NULL if not in any timeline yet.
|
|
|
|
*/
|
|
|
|
GESTimeline *
|
|
|
|
ges_timeline_layer_get_timeline (GESTimelineLayer * layer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), NULL);
|
|
|
|
|
|
|
|
return layer->timeline;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ges_timeline_layer_set_timeline (GESTimelineLayer * layer,
|
|
|
|
GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
GST_DEBUG ("layer:%p, timeline:%p", layer, timeline);
|
|
|
|
|
2013-01-10 21:50:54 +00:00
|
|
|
layer->timeline = timeline;
|
2012-04-08 01:24:18 +00:00
|
|
|
}
|