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
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-04-07 19:02:48 +00:00
|
|
|
* SECTION:geslayer
|
2017-03-08 21:13:48 +00:00
|
|
|
* @title: GESLayer
|
2019-12-18 20:33:45 +00:00
|
|
|
* @short_description: Non-overlapping sequence of #GESClip
|
|
|
|
*
|
|
|
|
* #GESLayer-s are responsible for collecting and ordering #GESClip-s.
|
|
|
|
*
|
|
|
|
* A layer within a timeline will have an associated priority,
|
|
|
|
* corresponding to their index within the timeline. A layer with the
|
|
|
|
* index/priority 0 will have the highest priority and the layer with the
|
|
|
|
* largest index will have the lowest priority (the order of priorities,
|
|
|
|
* in this sense, is the _reverse_ of the numerical ordering of the
|
|
|
|
* indices). ges_timeline_move_layer() should be used if you wish to
|
|
|
|
* change how layers are prioritised in a timeline.
|
|
|
|
*
|
|
|
|
* Layers with higher priorities will have their content priorities
|
|
|
|
* over content from lower priority layers, similar to how layers are
|
|
|
|
* used in image editing. For example, if two separate layers both
|
|
|
|
* display video content, then the layer with the higher priority will
|
|
|
|
* have its images shown first. The other layer will only have its image
|
|
|
|
* shown if the higher priority layer has no content at the given
|
|
|
|
* playtime, or is transparent in some way. Audio content in separate
|
|
|
|
* layers will simply play in addition.
|
2009-08-04 15:13:11 +00:00
|
|
|
*/
|
2018-09-24 14:41:24 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2009-09-10 16:40:51 +00:00
|
|
|
#include "ges-internal.h"
|
2013-04-23 23:04:04 +00:00
|
|
|
#include "ges-layer.h"
|
2009-09-10 16:40:51 +00:00
|
|
|
#include "ges.h"
|
2013-01-17 03:35:39 +00:00
|
|
|
#include "ges-source-clip.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);
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
struct _GESLayerPrivate
|
2010-12-04 18:54:13 +00:00
|
|
|
{
|
2010-12-16 11:41:26 +00:00
|
|
|
/*< private > */
|
2013-02-15 02:34:48 +00:00
|
|
|
GList *clips_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;
|
2020-03-06 21:56:52 +00:00
|
|
|
|
|
|
|
GHashTable *tracks_activness;
|
2010-12-04 18:54:13 +00:00
|
|
|
};
|
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-02-15 02:34:48 +00:00
|
|
|
GESClip *clip;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer;
|
2012-12-17 20:05:56 +00:00
|
|
|
} NewAssetUData;
|
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GESTrack *track;
|
|
|
|
GESLayer *layer;
|
|
|
|
gboolean active;
|
|
|
|
gboolean track_disposed;
|
|
|
|
} LayerActivnessData;
|
|
|
|
|
|
|
|
static void
|
|
|
|
_track_disposed_cb (LayerActivnessData * data, GObject * disposed_track)
|
|
|
|
{
|
|
|
|
data->track_disposed = TRUE;
|
|
|
|
g_hash_table_remove (data->layer->priv->tracks_activness, data->track);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
layer_activness_data_free (LayerActivnessData * data)
|
|
|
|
{
|
|
|
|
if (!data->track_disposed)
|
|
|
|
g_object_weak_unref ((GObject *) data->track,
|
|
|
|
(GWeakNotify) _track_disposed_cb, data);
|
|
|
|
g_free (data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LayerActivnessData *
|
|
|
|
layer_activness_data_new (GESTrack * track, GESLayer * layer, gboolean active)
|
|
|
|
{
|
|
|
|
LayerActivnessData *data = g_new0 (LayerActivnessData, 1);
|
|
|
|
|
|
|
|
data->layer = layer;
|
|
|
|
data->track = track;
|
|
|
|
data->active = active;
|
|
|
|
g_object_weak_ref (G_OBJECT (track), (GWeakNotify) _track_disposed_cb, data);
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
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,
|
2020-03-06 21:56:52 +00:00
|
|
|
ACTIVE_CHANGED,
|
2009-08-06 15:38:43 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
static guint ges_layer_signals[LAST_SIGNAL] = { 0 };
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2018-09-06 01:55:02 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GESLayer, ges_layer,
|
2019-08-17 15:59:02 +00:00
|
|
|
G_TYPE_INITIALLY_UNOWNED, G_ADD_PRIVATE (GESLayer)
|
|
|
|
G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE, NULL)
|
2018-09-06 01:55:02 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (GES_TYPE_META_CONTAINER,
|
|
|
|
ges_meta_container_interface_init));
|
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
/* GObject standard vmethods */
|
2009-08-06 15:38:43 +00:00
|
|
|
static void
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_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
|
|
|
{
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer = GES_LAYER (object);
|
2010-03-12 18:06:42 +00:00
|
|
|
|
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
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_set_property (GObject * object, guint property_id,
|
2009-08-04 15:16:31 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer = GES_LAYER (object);
|
2010-03-12 18:06:42 +00:00
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
switch (property_id) {
|
2010-03-12 18:06:42 +00:00
|
|
|
case PROP_PRIORITY:
|
2018-03-31 16:39:54 +00:00
|
|
|
GST_FIXME ("Deprecated, use ges_timeline_move_layer instead");
|
|
|
|
layer_set_priority (layer, g_value_get_uint (value), FALSE);
|
2010-03-12 18:06:42 +00:00
|
|
|
break;
|
2011-07-24 00:49:36 +00:00
|
|
|
case PROP_AUTO_TRANSITION:
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_set_auto_transition (layer, g_value_get_boolean (value));
|
2011-07-24 00:49:36 +00:00
|
|
|
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
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_dispose (GObject * object)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer = GES_LAYER (object);
|
|
|
|
GESLayerPrivate *priv = layer->priv;
|
2009-09-14 17:23:52 +00:00
|
|
|
|
2010-06-09 11:52:08 +00:00
|
|
|
GST_DEBUG ("Disposing layer");
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
while (priv->clips_start)
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_remove_clip (layer, (GESClip *) priv->clips_start->data);
|
2010-06-09 11:52:08 +00:00
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
g_clear_pointer (&layer->priv->tracks_activness, g_hash_table_unref);
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
G_OBJECT_CLASS (ges_layer_parent_class)->dispose (object);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
2013-04-22 03:21:58 +00:00
|
|
|
static gboolean
|
|
|
|
_register_metas (GESLayer * layer)
|
|
|
|
{
|
|
|
|
ges_meta_container_register_meta_float (GES_META_CONTAINER (layer),
|
|
|
|
GES_META_READ_WRITE, GES_META_VOLUME, 1.0);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_class_init (GESLayerClass * klass)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
object_class->get_property = ges_layer_get_property;
|
|
|
|
object_class->set_property = ges_layer_set_property;
|
|
|
|
object_class->dispose = ges_layer_dispose;
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2010-03-12 18:06:42 +00:00
|
|
|
/**
|
2013-04-23 23:04:04 +00:00
|
|
|
* GESLayer:priority:
|
2010-03-12 18:06:42 +00:00
|
|
|
*
|
|
|
|
* The priority of the layer in the #GESTimeline. 0 is the highest
|
2019-12-18 20:33:45 +00:00
|
|
|
* priority. Conceptually, a timeline is a stack of layers,
|
2010-05-31 16:59:12 +00:00
|
|
|
* and the priority of the layer represents its position in the stack. Two
|
|
|
|
* layers should not have the same priority within a given GESTimeline.
|
2015-05-19 16:18:30 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Note that the timeline needs to be committed (with #ges_timeline_commit)
|
2015-05-19 16:18:30 +00:00
|
|
|
* for the change to be taken into account.
|
2018-03-31 16:39:54 +00:00
|
|
|
*
|
|
|
|
* Deprecated:1.16.0: use #ges_timeline_move_layer instead. This deprecation means
|
|
|
|
* that you will not need to handle layer priorities at all yourself, GES
|
|
|
|
* will make sure there is never 'gaps' between layer priorities.
|
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
|
|
|
/**
|
2013-04-23 23:04:04 +00:00
|
|
|
* GESLayer:auto-transition:
|
2011-07-24 00:49:36 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Whether to automatically create a #GESTransitionClip whenever two
|
2020-05-15 13:25:01 +00:00
|
|
|
* #GESSource-s that both belong to a #GESClip in the layer overlap.
|
|
|
|
* See #GESTimeline for what counts as an overlap.
|
2019-12-18 20:33:45 +00:00
|
|
|
*
|
|
|
|
* When a layer is added to a #GESTimeline, if this property is left as
|
|
|
|
* %FALSE, but the timeline's #GESTimeline:auto-transition is %TRUE, it
|
|
|
|
* will be set to %TRUE as well.
|
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
|
|
|
/**
|
2013-04-23 23:04:04 +00:00
|
|
|
* GESLayer::clip-added:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The #GESLayer
|
|
|
|
* @clip: The clip that was added
|
2009-09-16 10:37:45 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Will be emitted after the clip is added to the layer.
|
2009-09-16 10:37:45 +00:00
|
|
|
*/
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_signals[OBJECT_ADDED] =
|
2013-02-08 20:19:39 +00:00
|
|
|
g_signal_new ("clip-added", G_TYPE_FROM_CLASS (klass),
|
2013-04-23 23:04:04 +00:00
|
|
|
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESLayerClass, object_added),
|
2019-08-29 05:45:45 +00:00
|
|
|
NULL, NULL, NULL, G_TYPE_NONE, 1, GES_TYPE_CLIP);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
2013-04-23 23:04:04 +00:00
|
|
|
* GESLayer::clip-removed:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The #GESLayer
|
|
|
|
* @clip: The clip that was removed
|
2009-09-16 10:37:45 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Will be emitted after the clip is removed from the layer.
|
2009-09-16 10:37:45 +00:00
|
|
|
*/
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_signals[OBJECT_REMOVED] =
|
2013-02-08 20:19:39 +00:00
|
|
|
g_signal_new ("clip-removed", G_TYPE_FROM_CLASS (klass),
|
2013-04-23 23:04:04 +00:00
|
|
|
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESLayerClass,
|
2019-08-29 05:45:45 +00:00
|
|
|
object_removed), NULL, NULL, NULL, G_TYPE_NONE, 1, GES_TYPE_CLIP);
|
2020-03-06 21:56:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GESLayer::active-changed:
|
|
|
|
* @layer: The #GESLayer
|
|
|
|
* @active: Whether @layer has been made active or de-active in the @tracks
|
|
|
|
* @tracks: (element-type GESTrack) (transfer none): A list of #GESTrack
|
|
|
|
* which have been activated or deactivated
|
|
|
|
*
|
|
|
|
* Will be emitted whenever the layer is activated or deactivated
|
|
|
|
* for some #GESTrack. See ges_layer_set_active_for_tracks().
|
2020-06-19 15:13:24 +00:00
|
|
|
*
|
|
|
|
* Since: 1.18
|
2020-03-06 21:56:52 +00:00
|
|
|
*/
|
|
|
|
ges_layer_signals[ACTIVE_CHANGED] =
|
|
|
|
g_signal_new ("active-changed", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, 2,
|
|
|
|
G_TYPE_BOOLEAN, G_TYPE_PTR_ARRAY);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_init (GESLayer * self)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2018-09-06 01:55:02 +00:00
|
|
|
self->priv = ges_layer_get_instance_private (self);
|
2010-12-04 18:54:13 +00:00
|
|
|
|
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;
|
2014-08-15 13:48:14 +00:00
|
|
|
self->min_nle_priority = MIN_NLE_PRIO;
|
|
|
|
self->max_nle_priority = LAYER_HEIGHT + MIN_NLE_PRIO;
|
2013-04-22 03:21:58 +00:00
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
self->priv->tracks_activness =
|
|
|
|
g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
|
|
|
NULL, (GDestroyNotify) layer_activness_data_free);
|
|
|
|
|
2013-04-22 03:21:58 +00:00
|
|
|
_register_metas (self);
|
2009-08-06 15:38:43 +00:00
|
|
|
}
|
|
|
|
|
2016-08-11 14:36:44 +00:00
|
|
|
static gint
|
|
|
|
ges_layer_resync_priorities_by_type (GESLayer * layer,
|
|
|
|
gint starting_priority, GType type)
|
2012-04-08 01:24:18 +00:00
|
|
|
{
|
2016-08-11 13:14:42 +00:00
|
|
|
GstClockTime next_reset = 0;
|
2016-08-11 14:36:44 +00:00
|
|
|
gint priority = starting_priority, max_priority = priority;
|
2012-04-08 01:24:18 +00:00
|
|
|
GList *tmp;
|
2013-03-29 17:56:31 +00:00
|
|
|
GESTimelineElement *element;
|
2011-07-24 00:49:36 +00:00
|
|
|
|
2019-01-28 21:59:40 +00:00
|
|
|
layer->priv->clips_start =
|
|
|
|
g_list_sort (layer->priv->clips_start,
|
|
|
|
(GCompareFunc) element_start_compare);
|
2013-02-15 02:34:48 +00:00
|
|
|
for (tmp = layer->priv->clips_start; tmp; tmp = tmp->next) {
|
2016-08-11 13:14:42 +00:00
|
|
|
|
2013-03-29 17:56:31 +00:00
|
|
|
element = GES_TIMELINE_ELEMENT (tmp->data);
|
2016-08-11 13:14:42 +00:00
|
|
|
|
|
|
|
if (GES_IS_TRANSITION_CLIP (element)) {
|
2016-08-11 14:36:44 +00:00
|
|
|
/* Blindly set transitions priorities to 0 */
|
2016-08-11 13:14:42 +00:00
|
|
|
_set_priority0 (element, 0);
|
|
|
|
continue;
|
2016-08-11 14:36:44 +00:00
|
|
|
} else if (!g_type_is_a (G_OBJECT_TYPE (element), type))
|
|
|
|
continue;
|
2016-08-11 13:14:42 +00:00
|
|
|
|
|
|
|
if (element->start > next_reset) {
|
2016-08-11 14:36:44 +00:00
|
|
|
priority = starting_priority;
|
2016-08-11 13:14:42 +00:00
|
|
|
next_reset = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (element->start + element->duration > next_reset)
|
|
|
|
next_reset = element->start + element->duration;
|
|
|
|
|
|
|
|
_set_priority0 (element, priority);
|
|
|
|
priority = priority + GES_CONTAINER_HEIGHT (element);
|
2016-08-11 14:36:44 +00:00
|
|
|
|
|
|
|
if (priority > max_priority)
|
|
|
|
max_priority = priority;
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
|
|
|
|
2016-08-11 14:36:44 +00:00
|
|
|
return max_priority;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_layer_resync_priorities:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The #GESLayer
|
2016-08-11 14:36:44 +00:00
|
|
|
*
|
|
|
|
* Resyncs the priorities of the clips controlled by @layer.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_layer_resync_priorities (GESLayer * layer)
|
|
|
|
{
|
|
|
|
gint min_source_prios;
|
|
|
|
|
2017-11-07 06:34:03 +00:00
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), FALSE);
|
|
|
|
|
2016-08-11 14:36:44 +00:00
|
|
|
GST_INFO_OBJECT (layer, "Resync priorities (prio: %d)",
|
|
|
|
layer->priv->priority);
|
|
|
|
|
|
|
|
min_source_prios = ges_layer_resync_priorities_by_type (layer, 1,
|
|
|
|
GES_TYPE_OPERATION_CLIP);
|
|
|
|
|
|
|
|
ges_layer_resync_priorities_by_type (layer, min_source_prios,
|
|
|
|
GES_TYPE_SOURCE_CLIP);
|
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
return TRUE;
|
2011-07-24 00:49:36 +00:00
|
|
|
}
|
|
|
|
|
2018-03-31 16:39:54 +00:00
|
|
|
void
|
|
|
|
layer_set_priority (GESLayer * layer, guint priority, gboolean emit)
|
|
|
|
{
|
|
|
|
GST_DEBUG ("layer:%p, priority:%d", layer, priority);
|
|
|
|
|
|
|
|
if (priority != layer->priv->priority) {
|
|
|
|
layer->priv->priority = priority;
|
|
|
|
layer->min_nle_priority = (priority * LAYER_HEIGHT) + MIN_NLE_PRIO;
|
|
|
|
layer->max_nle_priority = ((priority + 1) * LAYER_HEIGHT) + MIN_NLE_PRIO;
|
|
|
|
|
|
|
|
ges_layer_resync_priorities (layer);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (emit)
|
|
|
|
g_object_notify (G_OBJECT (layer), "priority");
|
|
|
|
}
|
|
|
|
|
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, "
|
2013-02-15 02:34:48 +00:00
|
|
|
"setting its asset", udata->clip);
|
2012-12-17 20:05:56 +00:00
|
|
|
|
|
|
|
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;
|
2013-02-15 02:34:48 +00:00
|
|
|
ges_extractable_set_asset (GES_EXTRACTABLE (udata->clip), asset);
|
2012-12-17 20:06:33 +00:00
|
|
|
|
|
|
|
ges_project_add_asset (project, asset);
|
2017-05-15 07:13:38 +00:00
|
|
|
|
|
|
|
/* clip was already ref-sinked when creating udata,
|
|
|
|
* gst_layer_add_clip() creates a new ref as such and
|
|
|
|
* below we unref the ref from udata */
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_add_clip (udata->layer, udata->clip);
|
2012-12-17 20:05:56 +00:00
|
|
|
}
|
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (asset);
|
2017-05-15 07:13:38 +00:00
|
|
|
gst_object_unref (udata->clip);
|
2023-01-24 20:22:28 +00:00
|
|
|
g_free (udata);
|
2012-12-17 20:05:56 +00:00
|
|
|
}
|
|
|
|
|
2013-11-22 20:33:18 +00:00
|
|
|
/**
|
|
|
|
* ges_layer_get_duration:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The layer to get the duration from
|
2013-11-22 20:33:18 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Retrieves the duration of the layer, which is the difference
|
|
|
|
* between the start of the layer (always time 0) and the end (which will
|
|
|
|
* be the end time of the final clip).
|
2013-11-22 20:33:18 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: The duration of @layer.
|
2013-11-22 20:33:18 +00:00
|
|
|
*/
|
|
|
|
GstClockTime
|
|
|
|
ges_layer_get_duration (GESLayer * layer)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
GstClockTime duration = 0;
|
|
|
|
|
2017-11-07 06:34:03 +00:00
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), 0);
|
|
|
|
|
2013-11-22 20:33:18 +00:00
|
|
|
for (tmp = layer->priv->clips_start; tmp; tmp = tmp->next) {
|
|
|
|
duration = MAX (duration, _END (tmp->data));
|
|
|
|
}
|
|
|
|
|
|
|
|
return duration;
|
|
|
|
}
|
|
|
|
|
2019-02-08 20:48:26 +00:00
|
|
|
static gboolean
|
|
|
|
ges_layer_remove_clip_internal (GESLayer * layer, GESClip * clip,
|
|
|
|
gboolean emit_removed)
|
2009-08-07 14:39:09 +00:00
|
|
|
{
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *current_layer;
|
2020-03-06 21:56:52 +00:00
|
|
|
GList *tmp;
|
timeline: re-handle clip children track selection
The way a clip's track elements are added to tracks was re-handled. This
doesn't affect the normal usage of a simple audio-video timeline, where
the tracks are added before any clips, but usage for multi-track
timelines has improved. The main changes are:
+ We can now handle a track being selected for more than one track,
including a full copy of their children properties and bindings.
(Previously broken.)
+ When a clip is split, we copy the new elements directly into the same
track, avoiding select-tracks-for-object.
+ When a clip is grouped or ungrouped, we avoid moving the elements to
or from tracks.
+ Added API to allow users to copy the core elements of a clip directly
into a track, complementing select-tracks-for-object.
+ Enforced the rule that a clip can only contain one core child in a
track, and all the non-core children must be added to tracks that
already contains a core child. This extends the previous condition
that two sources from the same clip should not be added to the same
track.
+ Made ges_track_add_element check that the newly added track element
does not break the configuration rules of the timeline.
+ When adding a track to a timeline, we only use
select-tracks-for-object to check whether track elements should be
added to the new track, not existing ones.
+ When removing a track from a timeline, we empty it of all the track
elements that are controlled by a clip. Thus, we ensure that a clip
only contains elements that are in the tracks of the same timeline, or
no track. Similarly, when removing a clip from a timeline.
+ We can now avoid unsupported timeline configurations when a layer is
added to a timeline, and already contains clips.
+ We can now avoid unsupported timeline configurations when a track is
added to a timeline, and the timeline already contains clips.
Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/issues/84
2020-04-06 11:09:54 +00:00
|
|
|
GESTimeline *timeline = layer->timeline;
|
2010-12-20 11:01:04 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
GST_DEBUG ("layer:%p, clip:%p", layer, clip);
|
2009-08-07 14:39:09 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
current_layer = ges_clip_get_layer (clip);
|
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)
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (current_layer);
|
2012-04-08 01:40:07 +00:00
|
|
|
|
2009-08-07 14:39:09 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (current_layer);
|
2009-08-07 14:39:09 +00:00
|
|
|
|
2015-01-27 20:16:05 +00:00
|
|
|
/* Remove it from our list of controlled objects */
|
|
|
|
layer->priv->clips_start = g_list_remove (layer->priv->clips_start, clip);
|
|
|
|
|
2019-02-08 20:48:26 +00:00
|
|
|
if (emit_removed) {
|
|
|
|
/* emit 'clip-removed' */
|
|
|
|
g_signal_emit (layer, ges_layer_signals[OBJECT_REMOVED], 0, clip);
|
|
|
|
}
|
2009-08-07 14:39:09 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
/* inform the clip it's no longer in a layer */
|
|
|
|
ges_clip_set_layer (clip, NULL);
|
2013-02-28 18:12:15 +00:00
|
|
|
/* so neither in a timeline */
|
2020-04-23 16:30:17 +00:00
|
|
|
if (timeline)
|
timeline: re-handle clip children track selection
The way a clip's track elements are added to tracks was re-handled. This
doesn't affect the normal usage of a simple audio-video timeline, where
the tracks are added before any clips, but usage for multi-track
timelines has improved. The main changes are:
+ We can now handle a track being selected for more than one track,
including a full copy of their children properties and bindings.
(Previously broken.)
+ When a clip is split, we copy the new elements directly into the same
track, avoiding select-tracks-for-object.
+ When a clip is grouped or ungrouped, we avoid moving the elements to
or from tracks.
+ Added API to allow users to copy the core elements of a clip directly
into a track, complementing select-tracks-for-object.
+ Enforced the rule that a clip can only contain one core child in a
track, and all the non-core children must be added to tracks that
already contains a core child. This extends the previous condition
that two sources from the same clip should not be added to the same
track.
+ Made ges_track_add_element check that the newly added track element
does not break the configuration rules of the timeline.
+ When adding a track to a timeline, we only use
select-tracks-for-object to check whether track elements should be
added to the new track, not existing ones.
+ When removing a track from a timeline, we empty it of all the track
elements that are controlled by a clip. Thus, we ensure that a clip
only contains elements that are in the tracks of the same timeline, or
no track. Similarly, when removing a clip from a timeline.
+ We can now avoid unsupported timeline configurations when a layer is
added to a timeline, and already contains clips.
+ We can now avoid unsupported timeline configurations when a track is
added to a timeline, and the timeline already contains clips.
Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/issues/84
2020-04-06 11:09:54 +00:00
|
|
|
ges_timeline_remove_clip (timeline, clip);
|
2009-08-07 14:39:09 +00:00
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
for (tmp = GES_CONTAINER_CHILDREN (clip); tmp; tmp = tmp->next)
|
|
|
|
ges_track_element_set_layer_active (tmp->data, TRUE);
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
/* Remove our reference to the clip */
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (clip);
|
2009-08-07 14:39:09 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2010-03-12 18:06:42 +00:00
|
|
|
|
2019-02-08 20:48:26 +00:00
|
|
|
/* Public methods */
|
|
|
|
/**
|
|
|
|
* ges_layer_remove_clip:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The #GESLayer
|
|
|
|
* @clip: The clip to remove
|
2019-02-08 20:48:26 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Removes the given clip from the layer.
|
2019-02-08 20:48:26 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: %TRUE if @clip was removed from @layer, or %FALSE if the
|
|
|
|
* operation failed.
|
2019-02-08 20:48:26 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_layer_remove_clip (GESLayer * layer, GESClip * clip)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), FALSE);
|
|
|
|
g_return_val_if_fail (GES_IS_CLIP (clip), FALSE);
|
|
|
|
|
|
|
|
return ges_layer_remove_clip_internal (layer, clip, TRUE);
|
|
|
|
}
|
|
|
|
|
2010-07-06 14:27:08 +00:00
|
|
|
/**
|
2013-04-23 23:04:04 +00:00
|
|
|
* ges_layer_set_priority:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The #GESLayer
|
|
|
|
* @priority: The priority to set
|
2010-07-06 14:27:08 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Sets the layer to the given priority. See #GESLayer:priority.
|
2018-03-31 16:39:54 +00:00
|
|
|
*
|
|
|
|
* Deprecated:1.16.0: use #ges_timeline_move_layer instead. This deprecation means
|
|
|
|
* that you will not need to handle layer priorities at all yourself, GES
|
|
|
|
* will make sure there is never 'gaps' between layer priorities.
|
2010-07-06 14:27:08 +00:00
|
|
|
*/
|
2010-03-12 18:06:42 +00:00
|
|
|
void
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_set_priority (GESLayer * layer, guint priority)
|
2010-03-12 18:06:42 +00:00
|
|
|
{
|
2013-04-23 23:04:04 +00:00
|
|
|
g_return_if_fail (GES_IS_LAYER (layer));
|
2010-12-16 11:41:26 +00:00
|
|
|
|
2018-03-31 16:39:54 +00:00
|
|
|
GST_FIXME ("Deprecated, use ges_timeline_move_layer instead");
|
2013-04-30 17:19:39 +00:00
|
|
|
|
2018-03-31 16:39:54 +00:00
|
|
|
layer_set_priority (layer, priority, TRUE);
|
2010-03-12 18:06:42 +00:00
|
|
|
}
|
2010-09-22 11:29:26 +00:00
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
/**
|
2013-04-23 23:04:04 +00:00
|
|
|
* ges_layer_get_auto_transition:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The #GESLayer
|
2011-07-24 00:49:36 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Gets the #GESLayer:auto-transition of the layer.
|
2011-07-24 00:49:36 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: %TRUE if transitions are automatically added to @layer.
|
2011-07-24 00:49:36 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_get_auto_transition (GESLayer * layer)
|
2011-07-24 00:49:36 +00:00
|
|
|
{
|
2013-04-23 23:04:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), 0);
|
2011-07-24 00:49:36 +00:00
|
|
|
|
|
|
|
return layer->priv->auto_transition;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-04-23 23:04:04 +00:00
|
|
|
* ges_layer_set_auto_transition:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The #GESLayer
|
|
|
|
* @auto_transition: Whether transitions should be automatically added to
|
|
|
|
* the layer
|
|
|
|
*
|
|
|
|
* Sets #GESLayer:auto-transition for the layer. Use
|
|
|
|
* ges_timeline_set_auto_transition() if you want all layers within a
|
|
|
|
* #GESTimeline to have #GESLayer:auto-transition set to %TRUE. Use this
|
|
|
|
* method if you want different values for different layers (and make sure
|
|
|
|
* to keep #GESTimeline:auto-transition as %FALSE for the corresponding
|
|
|
|
* timeline).
|
2011-07-24 00:49:36 +00:00
|
|
|
*/
|
|
|
|
void
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_set_auto_transition (GESLayer * layer, gboolean auto_transition)
|
2011-07-24 00:49:36 +00:00
|
|
|
{
|
2011-11-02 16:51:36 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
g_return_if_fail (GES_IS_LAYER (layer));
|
2011-07-24 00:49:36 +00:00
|
|
|
|
2018-06-23 15:26:03 +00:00
|
|
|
if (layer->priv->auto_transition == auto_transition)
|
|
|
|
return;
|
|
|
|
|
2011-07-24 00:49:36 +00:00
|
|
|
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
|
|
|
/**
|
2013-04-23 23:04:04 +00:00
|
|
|
* ges_layer_get_priority:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The #GESLayer
|
2010-12-16 11:41:26 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Get the priority of the layer. When inside a timeline, this is its
|
|
|
|
* index in the timeline. See ges_timeline_move_layer().
|
2011-01-10 13:28:35 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: The priority of @layer within its timeline.
|
2010-12-16 11:41:26 +00:00
|
|
|
*/
|
|
|
|
guint
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_get_priority (GESLayer * layer)
|
2010-12-16 11:41:26 +00:00
|
|
|
{
|
2013-04-23 23:04:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), 0);
|
2010-12-16 11:41:26 +00:00
|
|
|
|
|
|
|
return layer->priv->priority;
|
|
|
|
}
|
|
|
|
|
2010-09-22 11:29:26 +00:00
|
|
|
/**
|
2013-04-23 23:04:04 +00:00
|
|
|
* ges_layer_get_clips:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The #GESLayer
|
2010-09-22 11:29:26 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Get the #GESClip-s contained in this layer.
|
2010-09-22 11:29:26 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: (transfer full) (element-type GESClip): A list of clips in
|
|
|
|
* @layer.
|
2010-09-22 11:29:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
GList *
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_get_clips (GESLayer * layer)
|
2010-09-22 11:29:26 +00:00
|
|
|
{
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayerClass *klass;
|
2010-09-22 11:29:26 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), NULL);
|
2010-12-16 11:41:26 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
klass = GES_LAYER_GET_CLASS (layer);
|
2010-09-22 11:29:26 +00:00
|
|
|
|
|
|
|
if (klass->get_objects) {
|
|
|
|
return klass->get_objects (layer);
|
|
|
|
}
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
return g_list_sort (g_list_copy_deep (layer->priv->clips_start,
|
2013-01-10 14:15:32 +00:00
|
|
|
(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
|
|
|
|
|
|
|
/**
|
2013-04-23 23:04:04 +00:00
|
|
|
* ges_layer_is_empty:
|
|
|
|
* @layer: The #GESLayer to check
|
2012-01-20 17:36:36 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Convenience method to check if the layer is empty (doesn't contain
|
|
|
|
* any #GESClip), or not.
|
2012-01-20 17:36:36 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: %TRUE if @layer is empty, %FALSE if it contains at least
|
|
|
|
* one clip.
|
2012-01-20 17:36:36 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_is_empty (GESLayer * layer)
|
2012-01-20 17:36:36 +00:00
|
|
|
{
|
2013-04-23 23:04:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), FALSE);
|
2012-01-20 17:36:36 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
return (layer->priv->clips_start == NULL);
|
2012-01-20 17:36:36 +00:00
|
|
|
}
|
2012-04-08 01:24:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-05-15 13:25:01 +00:00
|
|
|
* ges_layer_add_clip_full:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The #GESLayer
|
|
|
|
* @clip: (transfer floating): The clip to add
|
2020-05-15 13:25:01 +00:00
|
|
|
* @error: (nullable): Return location for an error
|
2012-04-08 01:24:18 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Adds the given clip to the layer. If the method succeeds, the layer
|
|
|
|
* will take ownership of the clip.
|
2012-04-08 01:24:18 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* This method will fail and return %FALSE if @clip already resides in
|
|
|
|
* some layer. It can also fail if the additional clip breaks some
|
|
|
|
* compositional rules (see #GESTimelineElement).
|
2012-04-08 01:24:18 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: %TRUE if @clip was properly added to @layer, or %FALSE
|
|
|
|
* if @layer refused to add @clip.
|
2020-06-03 07:57:06 +00:00
|
|
|
* Since: 1.18
|
2012-04-08 01:24:18 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2020-05-15 13:25:01 +00:00
|
|
|
ges_layer_add_clip_full (GESLayer * layer, GESClip * clip, GError ** error)
|
2012-04-08 01:24:18 +00:00
|
|
|
{
|
2020-05-15 13:25:01 +00:00
|
|
|
GList *tmp, *prev_children, *new_children;
|
2012-12-17 20:05:56 +00:00
|
|
|
GESAsset *asset;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayerPrivate *priv;
|
|
|
|
GESLayer *current_layer;
|
2020-04-21 13:05:55 +00:00
|
|
|
GESTimeline *timeline;
|
|
|
|
GESContainer *container;
|
2020-05-15 13:25:01 +00:00
|
|
|
GError *timeline_error = NULL;
|
2012-04-08 01:24:18 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), FALSE);
|
2013-02-15 02:34:48 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (clip), FALSE);
|
2020-05-15 13:25:01 +00:00
|
|
|
g_return_val_if_fail (!error || !*error, FALSE);
|
2012-04-08 01:24:18 +00:00
|
|
|
|
2020-04-21 13:05:55 +00:00
|
|
|
timeline = GES_TIMELINE_ELEMENT_TIMELINE (clip);
|
|
|
|
container = GES_CONTAINER (clip);
|
|
|
|
|
2016-08-11 14:36:44 +00:00
|
|
|
GST_DEBUG_OBJECT (layer, "adding clip:%p", clip);
|
2020-04-06 11:42:03 +00:00
|
|
|
gst_object_ref_sink (clip);
|
2012-04-08 01:24:18 +00:00
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
priv = layer->priv;
|
2013-02-15 02:34:48 +00:00
|
|
|
current_layer = ges_clip_get_layer (clip);
|
2012-12-17 20:05:56 +00:00
|
|
|
if (G_UNLIKELY (current_layer)) {
|
2020-04-06 11:42:03 +00:00
|
|
|
GST_WARNING_OBJECT (layer, "Clip %" GES_FORMAT " already belongs to "
|
|
|
|
"another layer", GES_ARGS (clip));
|
2020-02-18 09:17:09 +00:00
|
|
|
gst_object_unref (clip);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (current_layer);
|
2020-04-06 11:42:03 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2012-12-17 20:05:56 +00:00
|
|
|
|
2020-04-06 11:42:03 +00:00
|
|
|
if (timeline && timeline != layer->timeline) {
|
|
|
|
/* if a clip is not in any layer, its timeline should not be set */
|
|
|
|
GST_ERROR_OBJECT (layer, "Clip %" GES_FORMAT " timeline %"
|
|
|
|
GST_PTR_FORMAT " does not match that of the layer %"
|
|
|
|
GST_PTR_FORMAT, GES_ARGS (clip), timeline, layer->timeline);
|
|
|
|
gst_object_unref (clip);
|
2012-04-08 01:24:18 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-04-06 11:42:03 +00:00
|
|
|
timeline = layer->timeline;
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
asset = ges_extractable_get_asset (GES_EXTRACTABLE (clip));
|
2012-12-17 20:05:56 +00:00
|
|
|
if (asset == NULL) {
|
|
|
|
gchar *id;
|
2023-01-24 20:22:28 +00:00
|
|
|
NewAssetUData *mudata = g_new (NewAssetUData, 1);
|
2012-12-17 20:05:56 +00:00
|
|
|
|
2020-04-06 11:42:03 +00:00
|
|
|
mudata->clip = clip;
|
2012-12-17 20:05:56 +00:00
|
|
|
mudata->layer = layer;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (layer, "%" GST_PTR_FORMAT " as no reference to any "
|
2013-02-15 02:34:48 +00:00
|
|
|
"assets creating a asset... trying sync", clip);
|
2012-12-17 20:05:56 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
id = ges_extractable_get_id (GES_EXTRACTABLE (clip));
|
|
|
|
asset = ges_asset_request (G_OBJECT_TYPE (clip), id, NULL);
|
2012-12-17 20:05:56 +00:00
|
|
|
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;
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
ges_asset_request_async (G_OBJECT_TYPE (clip),
|
2012-12-17 20:05:56 +00:00
|
|
|
id, NULL, (GAsyncReadyCallback) new_asset_cb, mudata);
|
2013-01-11 22:10:31 +00:00
|
|
|
|
|
|
|
if (project)
|
2013-02-15 02:34:48 +00:00
|
|
|
ges_project_add_loading_asset (project, G_OBJECT_TYPE (clip), id);
|
2012-12-17 20:05:56 +00:00
|
|
|
g_free (id);
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (layer, "Object added async");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
g_free (id);
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
ges_extractable_set_asset (GES_EXTRACTABLE (clip), asset);
|
2012-12-17 20:05:56 +00:00
|
|
|
|
2023-01-24 20:22:28 +00:00
|
|
|
g_free (mudata);
|
2019-01-26 10:50:48 +00:00
|
|
|
gst_clear_object (&asset);
|
2012-12-17 20:05:56 +00:00
|
|
|
}
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
/* Take a reference to the clip and store it stored by start/priority */
|
|
|
|
priv->clips_start = g_list_insert_sorted (priv->clips_start, clip,
|
2013-01-15 13:52:17 +00:00
|
|
|
(GCompareFunc) element_start_compare);
|
2012-04-08 01:24:18 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
/* Inform the clip it's now in this layer */
|
|
|
|
ges_clip_set_layer (clip, layer);
|
2012-04-08 01:24:18 +00:00
|
|
|
|
2013-03-29 17:55:27 +00:00
|
|
|
GST_DEBUG ("current clip priority : %d, Height: %d", _PRIORITY (clip),
|
|
|
|
LAYER_HEIGHT);
|
2012-04-08 01:24:18 +00:00
|
|
|
|
|
|
|
/* Set the priority. */
|
2013-03-29 17:55:27 +00:00
|
|
|
if (_PRIORITY (clip) > LAYER_HEIGHT) {
|
2012-12-17 20:05:56 +00:00
|
|
|
GST_WARNING_OBJECT (layer,
|
|
|
|
"%p is out of the layer space, setting its priority to "
|
2013-03-29 17:55:27 +00:00
|
|
|
"%d, setting it to the maximum priority of the layer: %d", clip,
|
|
|
|
_PRIORITY (clip), LAYER_HEIGHT - 1);
|
2013-02-15 02:34:48 +00:00
|
|
|
_set_priority0 (GES_TIMELINE_ELEMENT (clip), LAYER_HEIGHT - 1);
|
2012-04-08 01:24:18 +00:00
|
|
|
}
|
2012-12-17 20:05:56 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_resync_priorities (layer);
|
2016-10-06 17:14:57 +00:00
|
|
|
|
timeline: re-handle clip children track selection
The way a clip's track elements are added to tracks was re-handled. This
doesn't affect the normal usage of a simple audio-video timeline, where
the tracks are added before any clips, but usage for multi-track
timelines has improved. The main changes are:
+ We can now handle a track being selected for more than one track,
including a full copy of their children properties and bindings.
(Previously broken.)
+ When a clip is split, we copy the new elements directly into the same
track, avoiding select-tracks-for-object.
+ When a clip is grouped or ungrouped, we avoid moving the elements to
or from tracks.
+ Added API to allow users to copy the core elements of a clip directly
into a track, complementing select-tracks-for-object.
+ Enforced the rule that a clip can only contain one core child in a
track, and all the non-core children must be added to tracks that
already contains a core child. This extends the previous condition
that two sources from the same clip should not be added to the same
track.
+ Made ges_track_add_element check that the newly added track element
does not break the configuration rules of the timeline.
+ When adding a track to a timeline, we only use
select-tracks-for-object to check whether track elements should be
added to the new track, not existing ones.
+ When removing a track from a timeline, we empty it of all the track
elements that are controlled by a clip. Thus, we ensure that a clip
only contains elements that are in the tracks of the same timeline, or
no track. Similarly, when removing a clip from a timeline.
+ We can now avoid unsupported timeline configurations when a layer is
added to a timeline, and already contains clips.
+ We can now avoid unsupported timeline configurations when a track is
added to a timeline, and the timeline already contains clips.
Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/issues/84
2020-04-06 11:09:54 +00:00
|
|
|
/* FIXME: ideally we would only emit if we are going to return TRUE.
|
|
|
|
* However, for backward-compatibility, we ensure the "clip-added"
|
|
|
|
* signal is released before the clip's "child-added" signal, which is
|
|
|
|
* invoked by ges_timeline_add_clip */
|
2013-04-23 23:04:04 +00:00
|
|
|
g_signal_emit (layer, ges_layer_signals[OBJECT_ADDED], 0, clip);
|
2012-04-08 01:24:18 +00:00
|
|
|
|
2020-04-21 13:05:55 +00:00
|
|
|
prev_children = ges_container_get_children (container, FALSE);
|
|
|
|
|
2020-05-15 13:25:01 +00:00
|
|
|
if (timeline && !ges_timeline_add_clip (timeline, clip, &timeline_error)) {
|
|
|
|
GST_INFO_OBJECT (layer, "Could not add the clip %" GES_FORMAT
|
|
|
|
" to the timeline %" GST_PTR_FORMAT, GES_ARGS (clip), timeline);
|
|
|
|
|
|
|
|
if (timeline_error) {
|
|
|
|
if (error) {
|
|
|
|
*error = timeline_error;
|
|
|
|
} else {
|
|
|
|
GST_WARNING_OBJECT (timeline, "Adding the clip %" GES_FORMAT
|
|
|
|
" to the timeline failed: %s", GES_ARGS (clip),
|
|
|
|
timeline_error->message);
|
|
|
|
g_error_free (timeline_error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-21 13:05:55 +00:00
|
|
|
/* remove any track elements that were newly created */
|
2020-05-15 13:25:01 +00:00
|
|
|
new_children = ges_container_get_children (container, FALSE);
|
2020-04-21 13:05:55 +00:00
|
|
|
for (tmp = new_children; tmp; tmp = tmp->next) {
|
|
|
|
if (!g_list_find (prev_children, tmp->data))
|
|
|
|
ges_container_remove (container, tmp->data);
|
|
|
|
}
|
|
|
|
g_list_free_full (prev_children, gst_object_unref);
|
|
|
|
g_list_free_full (new_children, gst_object_unref);
|
|
|
|
|
timeline: re-handle clip children track selection
The way a clip's track elements are added to tracks was re-handled. This
doesn't affect the normal usage of a simple audio-video timeline, where
the tracks are added before any clips, but usage for multi-track
timelines has improved. The main changes are:
+ We can now handle a track being selected for more than one track,
including a full copy of their children properties and bindings.
(Previously broken.)
+ When a clip is split, we copy the new elements directly into the same
track, avoiding select-tracks-for-object.
+ When a clip is grouped or ungrouped, we avoid moving the elements to
or from tracks.
+ Added API to allow users to copy the core elements of a clip directly
into a track, complementing select-tracks-for-object.
+ Enforced the rule that a clip can only contain one core child in a
track, and all the non-core children must be added to tracks that
already contains a core child. This extends the previous condition
that two sources from the same clip should not be added to the same
track.
+ Made ges_track_add_element check that the newly added track element
does not break the configuration rules of the timeline.
+ When adding a track to a timeline, we only use
select-tracks-for-object to check whether track elements should be
added to the new track, not existing ones.
+ When removing a track from a timeline, we empty it of all the track
elements that are controlled by a clip. Thus, we ensure that a clip
only contains elements that are in the tracks of the same timeline, or
no track. Similarly, when removing a clip from a timeline.
+ We can now avoid unsupported timeline configurations when a layer is
added to a timeline, and already contains clips.
+ We can now avoid unsupported timeline configurations when a track is
added to a timeline, and the timeline already contains clips.
Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/issues/84
2020-04-06 11:09:54 +00:00
|
|
|
/* FIXME: change emit signal to FALSE once we are able to delay the
|
|
|
|
* "clip-added" signal until after ges_timeline_add_clip */
|
2019-03-01 22:32:19 +00:00
|
|
|
ges_layer_remove_clip_internal (layer, clip, TRUE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-04-21 13:05:55 +00:00
|
|
|
g_list_free_full (prev_children, gst_object_unref);
|
|
|
|
|
|
|
|
for (tmp = container->children; tmp; tmp = tmp->next) {
|
2020-03-06 21:56:52 +00:00
|
|
|
GESTrack *track = ges_track_element_get_track (tmp->data);
|
|
|
|
|
|
|
|
if (track)
|
|
|
|
ges_track_element_set_layer_active (tmp->data,
|
|
|
|
ges_layer_get_active_for_track (layer, track));
|
|
|
|
}
|
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
/**
|
2020-05-15 13:25:01 +00:00
|
|
|
* ges_layer_add_clip:
|
|
|
|
* @layer: The #GESLayer
|
|
|
|
* @clip: (transfer floating): The clip to add
|
|
|
|
*
|
|
|
|
* See ges_layer_add_clip_full(), which also gives an error.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @clip was properly added to @layer, or %FALSE
|
|
|
|
* if @layer refused to add @clip.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_layer_add_clip (GESLayer * layer, GESClip * clip)
|
|
|
|
{
|
|
|
|
return ges_layer_add_clip_full (layer, clip, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_layer_add_asset_full:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The #GESLayer
|
|
|
|
* @asset: The asset to extract the new clip from
|
|
|
|
* @start: The #GESTimelineElement:start value to set on the new clip
|
|
|
|
* If `start == #GST_CLOCK_TIME_NONE`, it will be added to the end
|
|
|
|
* of @layer, i.e. it will be set to @layer's duration
|
|
|
|
* @inpoint: The #GESTimelineElement:in-point value to set on the new
|
|
|
|
* clip
|
|
|
|
* @duration: The #GESTimelineElement:duration value to set on the new
|
|
|
|
* clip
|
|
|
|
* @track_types: The #GESClip:supported-formats to set on the the new
|
|
|
|
* clip, or #GES_TRACK_TYPE_UNKNOWN to use the default
|
2020-05-15 13:25:01 +00:00
|
|
|
* @error: (nullable): Return location for an error
|
2019-12-18 20:33:45 +00:00
|
|
|
*
|
|
|
|
* Extracts a new clip from an asset and adds it to the layer with
|
|
|
|
* the given properties.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The newly created clip.
|
2020-06-03 07:57:06 +00:00
|
|
|
* Since: 1.18
|
2012-12-29 21:24:05 +00:00
|
|
|
*/
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *
|
2020-05-15 13:25:01 +00:00
|
|
|
ges_layer_add_asset_full (GESLayer * layer,
|
2012-12-17 20:05:56 +00:00
|
|
|
GESAsset * asset, GstClockTime start, GstClockTime inpoint,
|
2020-05-15 13:25:01 +00:00
|
|
|
GstClockTime duration, GESTrackType track_types, GError ** error)
|
2012-12-17 20:05:56 +00:00
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *clip;
|
2012-12-17 20:05:56 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), NULL);
|
2012-12-17 20:05:56 +00:00
|
|
|
g_return_val_if_fail (GES_IS_ASSET (asset), NULL);
|
2020-05-15 13:25:01 +00:00
|
|
|
g_return_val_if_fail (!error || !*error, NULL);
|
2012-12-17 20:05:56 +00:00
|
|
|
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
|
layer: Remove the "rate" property of ges_timeline_layer_add_asset
API:
- ges_timeline_layer_add_asset (layer, asset, start, inpoint, duration, rate, track_types);
+ ges_timeline_layer_add_asset (layer, asset, start, inpoint, duration, track_types);
2013-04-23 22:57:44 +00:00
|
|
|
" inpoint: %" GST_TIME_FORMAT " duration: %" GST_TIME_FORMAT
|
2013-01-10 15:41:13 +00:00
|
|
|
" track types: %d (%s)", ges_asset_get_id (asset), GST_TIME_ARGS (start),
|
layer: Remove the "rate" property of ges_timeline_layer_add_asset
API:
- ges_timeline_layer_add_asset (layer, asset, start, inpoint, duration, rate, track_types);
+ ges_timeline_layer_add_asset (layer, asset, start, inpoint, duration, track_types);
2013-04-23 22:57:44 +00:00
|
|
|
GST_TIME_ARGS (inpoint), GST_TIME_ARGS (duration), 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));
|
2013-11-22 20:36:12 +00:00
|
|
|
|
|
|
|
if (!GST_CLOCK_TIME_IS_VALID (start)) {
|
|
|
|
start = ges_layer_get_duration (layer);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (layer,
|
|
|
|
"No start specified, setting it to %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (start));
|
|
|
|
}
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
_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
|
|
|
}
|
|
|
|
|
2020-05-15 13:25:01 +00:00
|
|
|
if (!ges_layer_add_clip_full (layer, clip, error)) {
|
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
|
|
|
}
|
|
|
|
|
2020-05-15 13:25:01 +00:00
|
|
|
/**
|
|
|
|
* ges_layer_add_asset:
|
|
|
|
* @layer: The #GESLayer
|
|
|
|
* @asset: The asset to extract the new clip from
|
|
|
|
* @start: The #GESTimelineElement:start value to set on the new clip
|
|
|
|
* If `start == #GST_CLOCK_TIME_NONE`, it will be added to the end
|
|
|
|
* of @layer, i.e. it will be set to @layer's duration
|
|
|
|
* @inpoint: The #GESTimelineElement:in-point value to set on the new
|
|
|
|
* clip
|
|
|
|
* @duration: The #GESTimelineElement:duration value to set on the new
|
|
|
|
* clip
|
|
|
|
* @track_types: The #GESClip:supported-formats to set on the the new
|
|
|
|
* clip, or #GES_TRACK_TYPE_UNKNOWN to use the default
|
|
|
|
*
|
|
|
|
* See ges_layer_add_asset_full(), which also gives an error.
|
|
|
|
*
|
2022-10-15 16:36:47 +00:00
|
|
|
* Returns: (transfer none) (nullable): The newly created clip.
|
2020-05-15 13:25:01 +00:00
|
|
|
*/
|
|
|
|
GESClip *
|
|
|
|
ges_layer_add_asset (GESLayer * layer,
|
|
|
|
GESAsset * asset, GstClockTime start, GstClockTime inpoint,
|
|
|
|
GstClockTime duration, GESTrackType track_types)
|
|
|
|
{
|
|
|
|
return ges_layer_add_asset_full (layer, asset, start, inpoint, duration,
|
|
|
|
track_types, NULL);
|
|
|
|
}
|
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
/**
|
2013-04-23 23:04:04 +00:00
|
|
|
* ges_layer_new:
|
2012-04-08 01:24:18 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Creates a new layer.
|
2012-04-08 01:24:18 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: (transfer floating): A new layer.
|
2012-04-08 01:24:18 +00:00
|
|
|
*/
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *
|
|
|
|
ges_layer_new (void)
|
2012-04-08 01:24:18 +00:00
|
|
|
{
|
2013-04-23 23:04:04 +00:00
|
|
|
return g_object_new (GES_TYPE_LAYER, NULL);
|
2012-04-08 01:24:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-04-23 23:04:04 +00:00
|
|
|
* ges_layer_get_timeline:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The #GESLayer
|
2012-04-08 01:24:18 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Gets the timeline that the layer is a part of.
|
2012-04-08 01:24:18 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: (transfer none) (nullable): The timeline that @layer
|
|
|
|
* is currently part of, or %NULL if it is not associated with any
|
|
|
|
* timeline.
|
2012-04-08 01:24:18 +00:00
|
|
|
*/
|
|
|
|
GESTimeline *
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_get_timeline (GESLayer * layer)
|
2012-04-08 01:24:18 +00:00
|
|
|
{
|
2013-04-23 23:04:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), NULL);
|
2012-04-08 01:24:18 +00:00
|
|
|
|
|
|
|
return layer->timeline;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_set_timeline (GESLayer * layer, GESTimeline * timeline)
|
2012-04-08 01:24:18 +00:00
|
|
|
{
|
2015-04-07 20:48:27 +00:00
|
|
|
GList *tmp;
|
|
|
|
|
2017-11-07 06:34:03 +00:00
|
|
|
g_return_if_fail (GES_IS_LAYER (layer));
|
|
|
|
|
2012-04-08 01:24:18 +00:00
|
|
|
GST_DEBUG ("layer:%p, timeline:%p", layer, timeline);
|
|
|
|
|
2015-04-07 20:48:27 +00:00
|
|
|
for (tmp = layer->priv->clips_start; tmp; tmp = tmp->next) {
|
|
|
|
ges_timeline_element_set_timeline (tmp->data, timeline);
|
|
|
|
}
|
|
|
|
|
2013-01-10 21:50:54 +00:00
|
|
|
layer->timeline = timeline;
|
2012-04-08 01:24:18 +00:00
|
|
|
}
|
2017-03-17 19:02:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_layer_get_clips_in_interval:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @layer: The #GESLayer
|
|
|
|
* @start: Start of the interval
|
|
|
|
* @end: End of the interval
|
2017-03-17 19:02:56 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Gets the clips within the layer that appear between @start and @end.
|
2017-03-17 19:02:56 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: (transfer full) (element-type GESClip): A list of #GESClip-s
|
|
|
|
* that intersect the interval `[start, end)` in @layer.
|
2017-03-17 19:02:56 +00:00
|
|
|
*/
|
|
|
|
GList *
|
|
|
|
ges_layer_get_clips_in_interval (GESLayer * layer, GstClockTime start,
|
|
|
|
GstClockTime end)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
GList *intersecting_clips = NULL;
|
|
|
|
GstClockTime clip_start, clip_end;
|
|
|
|
gboolean clip_intersects;
|
2017-11-07 06:34:03 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), NULL);
|
|
|
|
|
2019-01-28 21:59:40 +00:00
|
|
|
layer->priv->clips_start =
|
|
|
|
g_list_sort (layer->priv->clips_start,
|
|
|
|
(GCompareFunc) element_start_compare);
|
2017-03-17 19:02:56 +00:00
|
|
|
for (tmp = layer->priv->clips_start; tmp; tmp = tmp->next) {
|
|
|
|
clip_intersects = FALSE;
|
|
|
|
clip_start = ges_timeline_element_get_start (tmp->data);
|
|
|
|
clip_end = clip_start + ges_timeline_element_get_duration (tmp->data);
|
|
|
|
if (start <= clip_start && clip_start < end)
|
|
|
|
clip_intersects = TRUE;
|
|
|
|
else if (start < clip_end && clip_end <= end)
|
|
|
|
clip_intersects = TRUE;
|
|
|
|
else if (clip_start < start && clip_end > end)
|
|
|
|
clip_intersects = TRUE;
|
|
|
|
|
|
|
|
if (clip_intersects)
|
|
|
|
intersecting_clips =
|
2018-02-27 09:56:29 +00:00
|
|
|
g_list_insert_sorted (intersecting_clips,
|
|
|
|
gst_object_ref (tmp->data), (GCompareFunc) element_start_compare);
|
2017-03-17 19:02:56 +00:00
|
|
|
}
|
|
|
|
return intersecting_clips;
|
|
|
|
}
|
2020-03-06 21:56:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_layer_get_active_for_track:
|
|
|
|
* @layer: The #GESLayer
|
|
|
|
* @track: The #GESTrack to check if @layer is currently active for
|
|
|
|
*
|
|
|
|
* Gets whether the layer is active for the given track. See
|
|
|
|
* ges_layer_set_active_for_tracks().
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @layer is active for @track, or %FALSE otherwise.
|
2020-06-19 15:13:24 +00:00
|
|
|
*
|
|
|
|
* Since: 1.18
|
2020-03-06 21:56:52 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_layer_get_active_for_track (GESLayer * layer, GESTrack * track)
|
|
|
|
{
|
|
|
|
LayerActivnessData *d;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), FALSE);
|
|
|
|
g_return_val_if_fail (GES_IS_TRACK (track), FALSE);
|
|
|
|
g_return_val_if_fail (layer->timeline == ges_track_get_timeline (track),
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
d = g_hash_table_lookup (layer->priv->tracks_activness, track);
|
|
|
|
|
|
|
|
return d ? d->active : TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_layer_set_active_for_tracks:
|
|
|
|
* @layer: The #GESLayer
|
|
|
|
* @active: Whether elements in @tracks should be active or not
|
|
|
|
* @tracks: (transfer none) (element-type GESTrack) (allow-none): The list of
|
|
|
|
* tracks @layer should be (de-)active in, or %NULL to include all the tracks
|
|
|
|
* in the @layer's timeline
|
|
|
|
*
|
|
|
|
* Activate or deactivate track elements in @tracks (or in all tracks if @tracks
|
|
|
|
* is %NULL).
|
|
|
|
*
|
|
|
|
* When a layer is deactivated for a track, all the #GESTrackElement-s in
|
|
|
|
* the track that belong to a #GESClip in the layer will no longer be
|
|
|
|
* active in the track, regardless of their individual
|
|
|
|
* #GESTrackElement:active value.
|
|
|
|
*
|
|
|
|
* Note that by default a layer will be active for all of its
|
|
|
|
* timeline's tracks.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the operation worked %FALSE otherwise.
|
2020-06-19 15:13:24 +00:00
|
|
|
*
|
|
|
|
* Since: 1.18
|
2020-03-06 21:56:52 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_layer_set_active_for_tracks (GESLayer * layer, gboolean active,
|
|
|
|
GList * tracks)
|
|
|
|
{
|
|
|
|
GList *tmp, *owned_tracks = NULL;
|
|
|
|
GPtrArray *changed_tracks = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), FALSE);
|
|
|
|
|
|
|
|
if (!tracks && layer->timeline)
|
|
|
|
owned_tracks = tracks = ges_timeline_get_tracks (layer->timeline);
|
|
|
|
|
|
|
|
for (tmp = tracks; tmp; tmp = tmp->next) {
|
|
|
|
GESTrack *track = tmp->data;
|
|
|
|
|
|
|
|
/* Handle setting timeline later */
|
|
|
|
g_return_val_if_fail (layer->timeline == ges_track_get_timeline (track),
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
if (ges_layer_get_active_for_track (layer, track) != active) {
|
|
|
|
if (changed_tracks == NULL)
|
|
|
|
changed_tracks = g_ptr_array_new ();
|
|
|
|
g_ptr_array_add (changed_tracks, track);
|
|
|
|
}
|
|
|
|
g_hash_table_insert (layer->priv->tracks_activness, track,
|
|
|
|
layer_activness_data_new (track, layer, active));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed_tracks) {
|
|
|
|
g_signal_emit (layer, ges_layer_signals[ACTIVE_CHANGED], 0, active,
|
|
|
|
changed_tracks);
|
|
|
|
g_ptr_array_unref (changed_tracks);
|
|
|
|
}
|
|
|
|
g_list_free_full (owned_tracks, gst_object_unref);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|