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
|
2012-12-20 14:28:39 +00:00
|
|
|
* 2012 Thibault Saunier <tsaunier@gnome.org>
|
2012-12-20 23:23:54 +00:00
|
|
|
* 2012 Collabora Ltd.
|
|
|
|
* Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
2019-03-01 22:32:19 +00:00
|
|
|
* 2019 Igalia S.L
|
|
|
|
* Author: Thibault Saunier <tsaunier@igalia.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
|
|
|
/**
|
2014-04-07 19:02:48 +00:00
|
|
|
* SECTION:gestimeline
|
2017-03-08 21:13:48 +00:00
|
|
|
* @title: GESTimeline
|
2009-09-10 16:40:51 +00:00
|
|
|
* @short_description: Multimedia timeline
|
|
|
|
*
|
|
|
|
* #GESTimeline is the central object for any multimedia timeline.
|
2011-01-08 10:22:36 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* A timeline is composed of a set of #GESTrack-s and a set of
|
|
|
|
* #GESLayer-s, which are added to the timeline using
|
|
|
|
* ges_timeline_add_track() and ges_timeline_append_layer(), respectively.
|
2009-09-10 16:40:51 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* The contained tracks define the supported types of the timeline
|
|
|
|
* and provide the media output. Essentially, each track provides an
|
|
|
|
* additional source #GstPad.
|
2010-11-26 17:38:49 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Most usage of a timeline will likely only need a single #GESAudioTrack
|
|
|
|
* and/or a single #GESVideoTrack. You can create such a timeline with
|
|
|
|
* ges_timeline_new_audio_video(). After this, you are unlikely to need to
|
|
|
|
* work with the tracks directly.
|
2013-06-09 16:29:05 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* A timeline's layers contain #GESClip-s, which in turn control the
|
|
|
|
* creation of #GESTrackElement-s, which are added to the timeline's
|
|
|
|
* tracks. See #GESTimeline::select-tracks-for-object if you wish to have
|
|
|
|
* more control over which track a clip's elements are added to.
|
|
|
|
*
|
|
|
|
* The layers are ordered, with higher priority layers having their
|
|
|
|
* content prioritised in the tracks. This ordering can be changed using
|
|
|
|
* ges_timeline_move_layer().
|
|
|
|
*
|
|
|
|
* ## Saving
|
|
|
|
*
|
|
|
|
* To save/load a timeline, you can use the ges_timeline_load_from_uri()
|
|
|
|
* and ges_timeline_save_to_uri() methods that use the default format.
|
|
|
|
*
|
|
|
|
* ## Editing
|
|
|
|
*
|
|
|
|
* If you change the timing or ordering of a timeline's
|
|
|
|
* #GESTimelineElement-s, then these changes will not actually be taken
|
|
|
|
* into account in the timeline until the ges_timeline_commit() method is
|
|
|
|
* called. This allows you to move its elements around, say, in
|
|
|
|
* response to an end user's mouse dragging, with little expense before
|
|
|
|
* finalising their effect.
|
|
|
|
*
|
|
|
|
* ## Playing
|
|
|
|
*
|
|
|
|
* A timeline is a #GstBin with a source #GstPad for each of its
|
|
|
|
* tracks, which you can fetch with ges_timeline_get_pad_for_track(). You
|
|
|
|
* will likely want to link these to some compatible sink #GstElement-s to
|
|
|
|
* be able to play or capture the content of the timeline.
|
|
|
|
*
|
|
|
|
* You can use a #GESPipeline to easily preview/play the timeline's
|
|
|
|
* content, or render it to a file.
|
2009-09-10 16:40:51 +00:00
|
|
|
*/
|
2018-09-24 14:41:24 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2009-09-10 16:40:51 +00:00
|
|
|
|
2009-08-06 17:51:29 +00:00
|
|
|
#include "ges-internal.h"
|
2012-09-23 00:11:46 +00:00
|
|
|
#include "ges-project.h"
|
2013-03-01 01:27:50 +00:00
|
|
|
#include "ges-container.h"
|
2009-08-04 15:13:11 +00:00
|
|
|
#include "ges-timeline.h"
|
2019-03-01 22:32:19 +00:00
|
|
|
#include "ges-timeline-tree.h"
|
2009-08-06 15:38:43 +00:00
|
|
|
#include "ges-track.h"
|
2013-04-23 23:04:04 +00:00
|
|
|
#include "ges-layer.h"
|
2013-01-10 21:50:54 +00:00
|
|
|
#include "ges-auto-transition.h"
|
2009-08-06 15:38:43 +00:00
|
|
|
#include "ges.h"
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2012-12-20 23:23:54 +00:00
|
|
|
static GPtrArray *select_tracks_for_object_default (GESTimeline * timeline,
|
2013-01-26 15:31:33 +00:00
|
|
|
GESClip * clip, GESTrackElement * tr_obj, gpointer user_data);
|
2012-09-23 00:11:46 +00:00
|
|
|
static void ges_extractable_interface_init (GESExtractableInterface * iface);
|
2012-11-20 21:23:59 +00:00
|
|
|
static void ges_meta_container_interface_init
|
|
|
|
(GESMetaContainerInterface * iface);
|
2012-09-23 00:11:46 +00:00
|
|
|
|
2012-05-18 14:28:26 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (ges_timeline_debug);
|
|
|
|
#undef GST_CAT_DEFAULT
|
|
|
|
#define GST_CAT_DEFAULT ges_timeline_debug
|
|
|
|
|
2013-05-29 18:05:52 +00:00
|
|
|
/* lock to protect dynamic callbacks, like pad-added */
|
|
|
|
#define DYN_LOCK(timeline) (&GES_TIMELINE (timeline)->priv->dyn_mutex)
|
|
|
|
#define LOCK_DYN(timeline) G_STMT_START { \
|
2016-08-14 15:44:36 +00:00
|
|
|
GST_LOG_OBJECT (timeline, "Getting dynamic lock from %p", \
|
2013-05-29 18:05:52 +00:00
|
|
|
g_thread_self()); \
|
|
|
|
g_rec_mutex_lock (DYN_LOCK (timeline)); \
|
2016-08-14 15:44:36 +00:00
|
|
|
GST_LOG_OBJECT (timeline, "Got Dynamic lock from %p", \
|
2013-05-29 18:05:52 +00:00
|
|
|
g_thread_self()); \
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
#define UNLOCK_DYN(timeline) G_STMT_START { \
|
2016-08-14 15:44:36 +00:00
|
|
|
GST_LOG_OBJECT (timeline, "Unlocking dynamic lock from %p", \
|
2013-05-29 18:05:52 +00:00
|
|
|
g_thread_self()); \
|
|
|
|
g_rec_mutex_unlock (DYN_LOCK (timeline)); \
|
2016-08-14 15:44:36 +00:00
|
|
|
GST_LOG_OBJECT (timeline, "Unlocked Dynamic lock from %p", \
|
2013-05-29 18:05:52 +00:00
|
|
|
g_thread_self()); \
|
|
|
|
} G_STMT_END
|
|
|
|
|
2018-11-02 17:32:04 +00:00
|
|
|
#define CHECK_THREAD(timeline) g_assert(timeline->priv->valid_thread == g_thread_self())
|
|
|
|
|
2011-01-08 10:22:36 +00:00
|
|
|
struct _GESTimelinePrivate
|
|
|
|
{
|
2019-03-01 22:32:19 +00:00
|
|
|
GNode *tree;
|
|
|
|
|
2011-12-16 08:35:31 +00:00
|
|
|
/* The duration of the timeline */
|
|
|
|
gint64 duration;
|
|
|
|
|
2013-04-24 12:18:01 +00:00
|
|
|
/* The auto-transition of the timeline */
|
|
|
|
gboolean auto_transition;
|
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
/* Timeline edition modes and snapping management */
|
|
|
|
guint64 snapping_distance;
|
|
|
|
|
2013-05-29 18:05:52 +00:00
|
|
|
GRecMutex dyn_mutex;
|
2012-12-20 14:28:39 +00:00
|
|
|
GList *priv_tracks;
|
|
|
|
|
2015-12-12 11:29:50 +00:00
|
|
|
/* Avoid sorting layers when we are actually resyncing them ourself */
|
|
|
|
gboolean resyncing_layers;
|
2015-05-29 13:15:25 +00:00
|
|
|
GList *auto_transitions;
|
2013-01-10 21:50:54 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
/* Last snapping properties */
|
|
|
|
GstClockTime last_snap_ts;
|
|
|
|
GESTrackElement *last_snaped1;
|
|
|
|
GESTrackElement *last_snaped2;
|
2013-01-10 15:24:20 +00:00
|
|
|
|
2013-01-10 21:50:54 +00:00
|
|
|
/* This variable is set to %TRUE when it makes sense to update the transitions,
|
|
|
|
* and %FALSE otherwize */
|
|
|
|
gboolean needs_transitions_update;
|
|
|
|
|
2013-03-29 14:50:12 +00:00
|
|
|
/* While we are creating and adding the TrackElements for a clip, we need to
|
|
|
|
* ignore the child-added signal */
|
2013-03-14 16:53:25 +00:00
|
|
|
GESClip *ignore_track_element_added;
|
2013-06-26 21:08:57 +00:00
|
|
|
GList *groups;
|
2013-08-02 12:16:26 +00:00
|
|
|
|
2019-03-03 23:59:12 +00:00
|
|
|
guint stream_start_group_id;
|
2014-02-18 14:14:40 +00:00
|
|
|
|
|
|
|
GHashTable *all_elements;
|
2014-07-25 12:47:07 +00:00
|
|
|
|
2015-04-08 19:38:48 +00:00
|
|
|
/* With GST_OBJECT_LOCK */
|
2014-07-25 12:47:07 +00:00
|
|
|
guint expected_async_done;
|
2015-04-08 19:38:48 +00:00
|
|
|
/* With GST_OBJECT_LOCK */
|
|
|
|
guint expected_commited;
|
|
|
|
|
|
|
|
/* For ges_timeline_commit_sync */
|
|
|
|
GMutex commited_lock;
|
|
|
|
GCond commited_cond;
|
2018-11-02 17:32:04 +00:00
|
|
|
|
|
|
|
GThread *valid_thread;
|
2019-06-07 03:19:38 +00:00
|
|
|
|
|
|
|
GstStreamCollection *stream_collection;
|
2011-01-08 10:22:36 +00:00
|
|
|
};
|
|
|
|
|
2009-09-08 17:44:03 +00:00
|
|
|
/* private structure to contain our track-related information */
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
|
|
|
GESTrack *track;
|
|
|
|
GstPad *pad; /* Pad from the track */
|
|
|
|
GstPad *ghostpad;
|
2013-08-02 12:16:26 +00:00
|
|
|
|
|
|
|
gulong probe_id;
|
2019-06-07 03:19:38 +00:00
|
|
|
GstStream *stream;
|
2009-09-08 17:44:03 +00:00
|
|
|
} TrackPrivate;
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2011-12-16 08:35:31 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_DURATION,
|
2013-04-24 12:18:01 +00:00
|
|
|
PROP_AUTO_TRANSITION,
|
2012-04-24 00:52:45 +00:00
|
|
|
PROP_SNAPPING_DISTANCE,
|
2012-05-18 17:16:50 +00:00
|
|
|
PROP_UPDATE,
|
2011-12-16 08:35:31 +00:00
|
|
|
PROP_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
static GParamSpec *properties[PROP_LAST];
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TRACK_ADDED,
|
|
|
|
TRACK_REMOVED,
|
|
|
|
LAYER_ADDED,
|
|
|
|
LAYER_REMOVED,
|
2016-02-16 12:49:57 +00:00
|
|
|
GROUP_ADDED,
|
|
|
|
GROUP_REMOVED,
|
2012-04-25 18:55:46 +00:00
|
|
|
SNAPING_STARTED,
|
|
|
|
SNAPING_ENDED,
|
2012-12-20 23:23:54 +00:00
|
|
|
SELECT_TRACKS_FOR_OBJECT,
|
2013-09-28 13:42:20 +00:00
|
|
|
COMMITED,
|
2009-08-06 15:38:43 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2018-09-06 01:55:02 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GESTimeline, ges_timeline, GST_TYPE_BIN,
|
|
|
|
G_ADD_PRIVATE (GESTimeline)
|
|
|
|
G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE, ges_extractable_interface_init)
|
|
|
|
G_IMPLEMENT_INTERFACE (GES_TYPE_META_CONTAINER,
|
|
|
|
ges_meta_container_interface_init));
|
|
|
|
|
2010-05-19 10:36:11 +00:00
|
|
|
static GstBinClass *parent_class;
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
static guint ges_timeline_signals[LAST_SIGNAL] = { 0 };
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2011-01-11 15:35:05 +00:00
|
|
|
static gint custom_find_track (TrackPrivate * tr_priv, GESTrack * track);
|
2010-05-19 10:36:11 +00:00
|
|
|
|
2012-09-23 00:11:46 +00:00
|
|
|
static guint nb_assets = 0;
|
|
|
|
|
|
|
|
/* GESExtractable implementation */
|
|
|
|
static gchar *
|
|
|
|
extractable_check_id (GType type, const gchar * id)
|
|
|
|
{
|
|
|
|
gchar *res;
|
|
|
|
|
|
|
|
if (id == NULL)
|
|
|
|
res = g_strdup_printf ("%s-%i", "project", nb_assets);
|
|
|
|
else
|
|
|
|
res = g_strdup (id);
|
|
|
|
|
|
|
|
nb_assets++;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
extractable_get_id (GESExtractable * self)
|
|
|
|
{
|
|
|
|
GESAsset *asset;
|
|
|
|
|
|
|
|
if (!(asset = ges_extractable_get_asset (self)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return g_strdup (ges_asset_get_id (asset));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_extractable_interface_init (GESExtractableInterface * iface)
|
|
|
|
{
|
|
|
|
iface->asset_type = GES_TYPE_PROJECT;
|
|
|
|
iface->check_id = (GESExtractableCheckId) extractable_check_id;
|
|
|
|
iface->get_id = extractable_get_id;
|
|
|
|
}
|
|
|
|
|
2012-11-20 21:23:59 +00:00
|
|
|
static void
|
|
|
|
ges_meta_container_interface_init (GESMetaContainerInterface * iface)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-03-31 17:57:04 +00:00
|
|
|
/* GObject Standard vmethods*/
|
2009-08-06 15:38:43 +00:00
|
|
|
static void
|
|
|
|
ges_timeline_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
|
|
|
{
|
2011-12-16 08:35:31 +00:00
|
|
|
GESTimeline *timeline = GES_TIMELINE (object);
|
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
switch (property_id) {
|
2011-12-16 08:35:31 +00:00
|
|
|
case PROP_DURATION:
|
|
|
|
g_value_set_uint64 (value, timeline->priv->duration);
|
|
|
|
break;
|
2013-04-24 12:18:01 +00:00
|
|
|
case PROP_AUTO_TRANSITION:
|
|
|
|
g_value_set_boolean (value, timeline->priv->auto_transition);
|
|
|
|
break;
|
2012-04-24 00:52:45 +00:00
|
|
|
case PROP_SNAPPING_DISTANCE:
|
|
|
|
g_value_set_uint64 (value, timeline->priv->snapping_distance);
|
|
|
|
break;
|
2013-01-10 15:24:20 +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_set_property (GObject * object, guint property_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2012-04-24 00:52:45 +00:00
|
|
|
GESTimeline *timeline = GES_TIMELINE (object);
|
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
switch (property_id) {
|
2013-04-24 12:18:01 +00:00
|
|
|
case PROP_AUTO_TRANSITION:
|
|
|
|
ges_timeline_set_auto_transition (timeline, g_value_get_boolean (value));
|
|
|
|
break;
|
2012-04-24 00:52:45 +00:00
|
|
|
case PROP_SNAPPING_DISTANCE:
|
|
|
|
timeline->priv->snapping_distance = g_value_get_uint64 (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_dispose (GObject * object)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2012-11-11 16:51:45 +00:00
|
|
|
GESTimeline *tl = GES_TIMELINE (object);
|
|
|
|
GESTimelinePrivate *priv = tl->priv;
|
2016-01-19 10:22:57 +00:00
|
|
|
GList *tmp, *groups;
|
2010-05-19 10:36:11 +00:00
|
|
|
|
2012-11-11 16:51:45 +00:00
|
|
|
while (tl->layers) {
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer = (GESLayer *) tl->layers->data;
|
2011-01-08 10:22:36 +00:00
|
|
|
ges_timeline_remove_layer (GES_TIMELINE (object), layer);
|
2010-06-09 11:52:35 +00:00
|
|
|
}
|
|
|
|
|
2010-09-23 13:47:48 +00:00
|
|
|
/* FIXME: it should be possible to remove tracks before removing
|
|
|
|
* layers, but at the moment this creates a problem because the track
|
2014-08-15 13:48:14 +00:00
|
|
|
* objects aren't notified that their nleobjects have been destroyed.
|
2010-09-23 13:47:48 +00:00
|
|
|
*/
|
|
|
|
|
2019-06-21 14:47:34 +00:00
|
|
|
LOCK_DYN (tl);
|
2013-06-26 21:08:57 +00:00
|
|
|
while (tl->tracks)
|
2012-12-20 14:28:39 +00:00
|
|
|
ges_timeline_remove_track (GES_TIMELINE (object), tl->tracks->data);
|
2019-06-21 14:47:34 +00:00
|
|
|
UNLOCK_DYN (tl);
|
2013-06-26 21:08:57 +00:00
|
|
|
|
2016-01-19 10:22:57 +00:00
|
|
|
groups = g_list_copy (priv->groups);
|
|
|
|
for (tmp = groups; tmp; tmp = tmp->next) {
|
|
|
|
GList *elems = ges_container_ungroup (tmp->data, FALSE);
|
2010-09-23 13:47:48 +00:00
|
|
|
|
2016-01-19 10:22:57 +00:00
|
|
|
g_list_free_full (elems, gst_object_unref);
|
|
|
|
}
|
2016-01-06 17:14:07 +00:00
|
|
|
g_list_free (priv->groups);
|
2016-01-19 10:22:57 +00:00
|
|
|
g_list_free (groups);
|
2016-01-06 17:14:07 +00:00
|
|
|
|
2015-05-29 13:15:25 +00:00
|
|
|
g_list_free_full (priv->auto_transitions, gst_object_unref);
|
2013-01-10 21:50:54 +00:00
|
|
|
|
2014-10-26 20:34:29 +00:00
|
|
|
g_hash_table_unref (priv->all_elements);
|
2019-06-07 03:19:38 +00:00
|
|
|
gst_object_unref (priv->stream_collection);
|
2014-10-26 20:34:29 +00:00
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
G_OBJECT_CLASS (ges_timeline_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_finalize (GObject * object)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2014-10-26 20:34:29 +00:00
|
|
|
GESTimeline *tl = GES_TIMELINE (object);
|
|
|
|
|
|
|
|
g_rec_mutex_clear (&tl->priv->dyn_mutex);
|
2019-03-01 22:32:19 +00:00
|
|
|
g_node_destroy (tl->priv->tree);
|
2014-10-26 20:34:29 +00:00
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
G_OBJECT_CLASS (ges_timeline_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2014-07-25 12:47:07 +00:00
|
|
|
static void
|
|
|
|
ges_timeline_handle_message (GstBin * bin, GstMessage * message)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline = GES_TIMELINE (bin);
|
|
|
|
|
2019-06-17 03:00:31 +00:00
|
|
|
if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_START) {
|
|
|
|
GST_INFO_OBJECT (timeline, "Dropping %" GST_PTR_FORMAT, message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE) {
|
|
|
|
GST_INFO_OBJECT (timeline, "Dropping %" GST_PTR_FORMAT, message);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-25 22:31:32 +00:00
|
|
|
if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) {
|
|
|
|
GstMessage *amessage = NULL;
|
2014-07-25 12:47:07 +00:00
|
|
|
const GstStructure *mstructure = gst_message_get_structure (message);
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
if (gst_structure_has_name (mstructure, "NleCompositionStartUpdate")) {
|
2014-07-25 22:31:32 +00:00
|
|
|
if (g_strcmp0 (gst_structure_get_string (mstructure, "reason"), "Seek")) {
|
|
|
|
GST_INFO_OBJECT (timeline,
|
|
|
|
"A composition is starting an update because of %s"
|
2016-11-09 09:48:09 +00:00
|
|
|
" not considering async", gst_structure_get_string (mstructure,
|
2014-07-25 22:31:32 +00:00
|
|
|
"reason"));
|
2014-07-25 12:47:07 +00:00
|
|
|
|
2014-07-25 22:31:32 +00:00
|
|
|
goto forward;
|
|
|
|
}
|
2014-07-25 12:47:07 +00:00
|
|
|
|
|
|
|
GST_OBJECT_LOCK (timeline);
|
|
|
|
if (timeline->priv->expected_async_done == 0) {
|
2014-07-25 22:31:32 +00:00
|
|
|
amessage = gst_message_new_async_start (GST_OBJECT_CAST (bin));
|
2019-06-21 14:47:34 +00:00
|
|
|
LOCK_DYN (timeline);
|
2014-07-25 12:47:07 +00:00
|
|
|
timeline->priv->expected_async_done = g_list_length (timeline->tracks);
|
2019-06-21 14:47:34 +00:00
|
|
|
UNLOCK_DYN (timeline);
|
2014-07-25 22:31:32 +00:00
|
|
|
GST_INFO_OBJECT (timeline, "Posting ASYNC_START %s",
|
|
|
|
gst_structure_get_string (mstructure, "reason"));
|
|
|
|
}
|
|
|
|
GST_OBJECT_UNLOCK (timeline);
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
} else if (gst_structure_has_name (mstructure, "NleCompositionUpdateDone")) {
|
2014-07-25 22:31:32 +00:00
|
|
|
if (g_strcmp0 (gst_structure_get_string (mstructure, "reason"), "Seek")) {
|
|
|
|
GST_INFO_OBJECT (timeline,
|
|
|
|
"A composition is done updating because of %s"
|
2016-11-09 09:48:09 +00:00
|
|
|
" not considering async", gst_structure_get_string (mstructure,
|
2014-07-25 22:31:32 +00:00
|
|
|
"reason"));
|
|
|
|
|
|
|
|
goto forward;
|
2014-07-25 12:47:07 +00:00
|
|
|
}
|
2014-07-25 22:31:32 +00:00
|
|
|
|
2014-07-25 12:47:07 +00:00
|
|
|
GST_OBJECT_LOCK (timeline);
|
|
|
|
timeline->priv->expected_async_done -= 1;
|
|
|
|
if (timeline->priv->expected_async_done == 0) {
|
2014-07-25 22:31:32 +00:00
|
|
|
amessage = gst_message_new_async_done (GST_OBJECT_CAST (bin),
|
2014-07-25 12:47:07 +00:00
|
|
|
GST_CLOCK_TIME_NONE);
|
2014-07-25 22:31:32 +00:00
|
|
|
GST_INFO_OBJECT (timeline, "Posting ASYNC_DONE %s",
|
|
|
|
gst_structure_get_string (mstructure, "reason"));
|
2014-07-25 12:47:07 +00:00
|
|
|
}
|
2014-07-25 22:31:32 +00:00
|
|
|
GST_OBJECT_UNLOCK (timeline);
|
|
|
|
}
|
|
|
|
|
2019-06-07 20:06:39 +00:00
|
|
|
if (amessage) {
|
2014-07-25 22:31:32 +00:00
|
|
|
gst_element_post_message (GST_ELEMENT_CAST (bin), amessage);
|
2019-06-07 20:06:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-07-25 12:47:07 +00:00
|
|
|
}
|
2014-07-25 22:31:32 +00:00
|
|
|
|
|
|
|
forward:
|
|
|
|
gst_element_post_message (GST_ELEMENT_CAST (bin), message);
|
2014-07-25 12:47:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-07 03:19:38 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
ges_timeline_change_state (GstElement * element, GstStateChange transition)
|
|
|
|
{
|
|
|
|
GstStateChangeReturn res;
|
|
|
|
GESTimeline *timeline = GES_TIMELINE (element);
|
|
|
|
|
|
|
|
res = GST_ELEMENT_CLASS (ges_timeline_parent_class)->change_state (element,
|
|
|
|
transition);
|
|
|
|
|
|
|
|
if (transition == GST_STATE_CHANGE_READY_TO_PAUSED)
|
|
|
|
gst_element_post_message ((GstElement *) timeline,
|
|
|
|
gst_message_new_stream_collection ((GstObject *) timeline,
|
|
|
|
timeline->priv->stream_collection));
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
ges_timeline_send_event (GstElement * element, GstEvent * event)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline = GES_TIMELINE (element);
|
|
|
|
|
|
|
|
if (GST_EVENT_TYPE (event) == GST_EVENT_SELECT_STREAMS) {
|
|
|
|
GList *stream_ids = NULL, *tmp, *to_remove =
|
|
|
|
ges_timeline_get_tracks (timeline);
|
|
|
|
|
|
|
|
gst_event_parse_select_streams (event, &stream_ids);
|
|
|
|
for (tmp = stream_ids; tmp; tmp = tmp->next) {
|
|
|
|
GList *trackit;
|
|
|
|
gchar *stream_id = tmp->data;
|
|
|
|
|
|
|
|
LOCK_DYN (timeline);
|
|
|
|
for (trackit = timeline->priv->priv_tracks; trackit;
|
|
|
|
trackit = trackit->next) {
|
|
|
|
TrackPrivate *tr_priv = trackit->data;
|
|
|
|
|
|
|
|
if (!g_strcmp0 (gst_stream_get_stream_id (tr_priv->stream), stream_id)) {
|
|
|
|
to_remove = g_list_remove (to_remove, tr_priv->track);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UNLOCK_DYN (timeline);
|
|
|
|
}
|
|
|
|
for (tmp = to_remove; tmp; tmp = tmp->next) {
|
|
|
|
GST_INFO_OBJECT (timeline, "Removed unselected track: %" GST_PTR_FORMAT,
|
|
|
|
tmp->data);
|
|
|
|
ges_timeline_remove_track (timeline, tmp->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free_full (stream_ids, g_free);
|
|
|
|
g_list_free (to_remove);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GST_ELEMENT_CLASS (ges_timeline_parent_class)->send_event (element,
|
|
|
|
event);
|
|
|
|
}
|
|
|
|
|
2012-12-20 23:23:54 +00:00
|
|
|
/* we collect the first result */
|
|
|
|
static gboolean
|
|
|
|
_gst_array_accumulator (GSignalInvocationHint * ihint,
|
|
|
|
GValue * return_accu, const GValue * handler_return, gpointer dummy)
|
|
|
|
{
|
|
|
|
gpointer array;
|
|
|
|
|
|
|
|
array = g_value_get_boxed (handler_return);
|
|
|
|
if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP))
|
|
|
|
g_value_set_boxed (return_accu, array);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
static void
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_class_init (GESTimelineClass * klass)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2019-06-07 03:19:38 +00:00
|
|
|
GstElementClass *element_class = (GstElementClass *) klass;
|
2014-07-25 12:47:07 +00:00
|
|
|
GstBinClass *bin_class = GST_BIN_CLASS (klass);
|
2010-05-19 10:36:11 +00:00
|
|
|
|
2012-09-23 00:11:46 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (ges_timeline_debug, "gestimeline",
|
|
|
|
GST_DEBUG_FG_YELLOW, "ges timeline");
|
2019-03-01 22:32:19 +00:00
|
|
|
timeline_tree_init_debug ();
|
2012-09-23 00:11:46 +00:00
|
|
|
|
2010-05-19 10:36:11 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
object_class->get_property = ges_timeline_get_property;
|
|
|
|
object_class->set_property = ges_timeline_set_property;
|
|
|
|
object_class->dispose = ges_timeline_dispose;
|
|
|
|
object_class->finalize = ges_timeline_finalize;
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2019-06-07 03:19:38 +00:00
|
|
|
element_class->change_state = GST_DEBUG_FUNCPTR (ges_timeline_change_state);
|
|
|
|
element_class->send_event = GST_DEBUG_FUNCPTR (ges_timeline_send_event);
|
|
|
|
|
2014-07-25 12:47:07 +00:00
|
|
|
bin_class->handle_message = GST_DEBUG_FUNCPTR (ges_timeline_handle_message);
|
|
|
|
|
2011-12-16 08:35:31 +00:00
|
|
|
/**
|
2012-08-10 16:39:10 +00:00
|
|
|
* GESTimeline:duration:
|
2011-12-16 08:35:31 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* The current duration (in nanoseconds) of the timeline. A timeline
|
|
|
|
* 'starts' at time 0, so this is the maximum end time of all of its
|
|
|
|
* #GESTimelineElement-s.
|
2011-12-16 08:35:31 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_DURATION] =
|
|
|
|
g_param_spec_uint64 ("duration", "Duration",
|
|
|
|
"The duration of the timeline", 0, G_MAXUINT64,
|
|
|
|
GST_CLOCK_TIME_NONE, G_PARAM_READABLE);
|
|
|
|
g_object_class_install_property (object_class, PROP_DURATION,
|
|
|
|
properties[PROP_DURATION]);
|
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
/**
|
2013-04-24 12:18:01 +00:00
|
|
|
* GESTimeline:auto-transition:
|
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Whether to automatically create a transition whenever two clips
|
|
|
|
* overlap in the timeline. See #GESLayer:auto-transition.
|
2013-04-24 12:18:01 +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));
|
|
|
|
|
2013-05-29 18:05:52 +00:00
|
|
|
/**
|
2012-08-10 16:39:10 +00:00
|
|
|
* GESTimeline:snapping-distance:
|
2012-04-24 00:52:45 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* The distance (in nanoseconds) at which a #GESTimelineElement being
|
|
|
|
* moved within the timeline should snap to its neighbours. Note that
|
|
|
|
* such a neighbour includes any element in the timeline, including
|
|
|
|
* across separate layers. 0 means no snapping.
|
2012-04-24 00:52:45 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_SNAPPING_DISTANCE] =
|
|
|
|
g_param_spec_uint64 ("snapping-distance", "Snapping distance",
|
2019-12-18 20:33:45 +00:00
|
|
|
"Distance from which moving an object will snap with neighbours", 0,
|
2012-04-24 00:52:45 +00:00
|
|
|
G_MAXUINT64, 0, G_PARAM_READWRITE);
|
|
|
|
g_object_class_install_property (object_class, PROP_SNAPPING_DISTANCE,
|
|
|
|
properties[PROP_SNAPPING_DISTANCE]);
|
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
2012-08-10 16:39:10 +00:00
|
|
|
* GESTimeline::track-added:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @track: The track that was added to @timeline
|
|
|
|
*
|
|
|
|
* Will be emitted after the track is added to the timeline.
|
2009-09-16 10:37:45 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Note that this should not be emitted whilst a timeline is being
|
|
|
|
* loaded from its #GESProject asset. You should connect to the
|
|
|
|
* project's #GESProject::loaded signal if you want to know which
|
|
|
|
* tracks were created for the timeline.
|
2009-09-16 10:37:45 +00:00
|
|
|
*/
|
2009-08-06 15:38:43 +00:00
|
|
|
ges_timeline_signals[TRACK_ADDED] =
|
|
|
|
g_signal_new ("track-added", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, track_added), NULL,
|
2019-08-29 05:45:45 +00:00
|
|
|
NULL, NULL, G_TYPE_NONE, 1, GES_TYPE_TRACK);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
2012-08-10 16:39:10 +00:00
|
|
|
* GESTimeline::track-removed:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @track: The track that was removed from @timeline
|
2009-09-16 10:37:45 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Will be emitted after the track is removed from the timeline.
|
2009-09-16 10:37:45 +00:00
|
|
|
*/
|
2009-08-06 15:38:43 +00:00
|
|
|
ges_timeline_signals[TRACK_REMOVED] =
|
|
|
|
g_signal_new ("track-removed", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, track_removed),
|
2019-08-29 05:45:45 +00:00
|
|
|
NULL, NULL, NULL, G_TYPE_NONE, 1, GES_TYPE_TRACK);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
2012-08-10 16:39:10 +00:00
|
|
|
* GESTimeline::layer-added:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @layer: The layer that was added to @timeline
|
2009-09-16 10:37:45 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Will be emitted after the layer is added to the timeline.
|
|
|
|
*
|
|
|
|
* Note that this should not be emitted whilst a timeline is being
|
|
|
|
* loaded from its #GESProject asset. You should connect to the
|
|
|
|
* project's #GESProject::loaded signal if you want to know which
|
|
|
|
* layers were created for the timeline.
|
2009-09-16 10:37:45 +00:00
|
|
|
*/
|
2009-08-06 15:38:43 +00:00
|
|
|
ges_timeline_signals[LAYER_ADDED] =
|
|
|
|
g_signal_new ("layer-added", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, layer_added), NULL,
|
2019-08-29 05:45:45 +00:00
|
|
|
NULL, NULL, G_TYPE_NONE, 1, GES_TYPE_LAYER);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
2012-08-10 16:39:10 +00:00
|
|
|
* GESTimeline::layer-removed:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @layer: The layer that was removed from @timeline
|
2009-09-16 10:37:45 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Will be emitted after the layer is removed from the timeline.
|
2009-09-16 10:37:45 +00:00
|
|
|
*/
|
2009-08-06 15:38:43 +00:00
|
|
|
ges_timeline_signals[LAYER_REMOVED] =
|
|
|
|
g_signal_new ("layer-removed", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, layer_removed),
|
2019-08-29 05:45:45 +00:00
|
|
|
NULL, NULL, NULL, G_TYPE_NONE, 1, GES_TYPE_LAYER);
|
2012-01-04 17:46:54 +00:00
|
|
|
|
2016-02-16 12:49:57 +00:00
|
|
|
/**
|
|
|
|
* GESTimeline::group-added
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @group: The group that was added to @timeline
|
|
|
|
*
|
|
|
|
* Will be emitted after the group is added to to the timeline. This can
|
|
|
|
* happen when grouping with `ges_container_group`, or by adding
|
|
|
|
* containers to a newly created group.
|
2016-02-16 12:49:57 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Note that this should not be emitted whilst a timeline is being
|
|
|
|
* loaded from its #GESProject asset. You should connect to the
|
|
|
|
* project's #GESProject::loaded signal if you want to know which groups
|
|
|
|
* were created for the timeline.
|
2016-02-16 12:49:57 +00:00
|
|
|
*/
|
|
|
|
ges_timeline_signals[GROUP_ADDED] =
|
|
|
|
g_signal_new ("group-added", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, group_added), NULL,
|
2019-08-29 05:45:45 +00:00
|
|
|
NULL, NULL, G_TYPE_NONE, 1, GES_TYPE_GROUP);
|
2016-02-16 12:49:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GESTimeline::group-removed
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @group: The group that was removed from @timeline
|
|
|
|
* @children: (element-type GESContainer) (transfer none): A list
|
|
|
|
* of #GESContainer-s that _were_ the children of the removed @group
|
2016-02-16 12:49:57 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Will be emitted after the group is removed from the timeline through
|
|
|
|
* `ges_container_ungroup`. Note that @group will no longer contain its
|
|
|
|
* former children, these are held in @children.
|
|
|
|
*
|
|
|
|
* Note that if a group is emptied, then it will no longer belong to the
|
|
|
|
* timeline, but this signal will **not** be emitted in such a case.
|
2016-02-16 12:49:57 +00:00
|
|
|
*/
|
|
|
|
ges_timeline_signals[GROUP_REMOVED] =
|
|
|
|
g_signal_new ("group-removed", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, group_removed),
|
2019-08-29 05:45:45 +00:00
|
|
|
NULL, NULL, NULL, G_TYPE_NONE, 2, GES_TYPE_GROUP, G_TYPE_PTR_ARRAY);
|
2016-02-16 12:49:57 +00:00
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
/**
|
2019-01-21 13:14:06 +00:00
|
|
|
* GESTimeline::snapping-started:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @obj1: The first element that is snapping
|
|
|
|
* @obj2: The second element that is snapping
|
|
|
|
* @position: The position where the two objects will snap to
|
2012-04-24 00:52:45 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Will be emitted whenever an element's movement invokes a snapping
|
|
|
|
* event (usually by its controlling #GESClip being moved) because its
|
|
|
|
* start or end point lies within the #GESTimeline:snapping-distance of
|
|
|
|
* another element's start or end point.
|
2012-04-25 18:55:46 +00:00
|
|
|
*/
|
|
|
|
ges_timeline_signals[SNAPING_STARTED] =
|
|
|
|
g_signal_new ("snapping-started", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
|
2013-01-26 15:31:33 +00:00
|
|
|
G_TYPE_NONE, 3, GES_TYPE_TRACK_ELEMENT, GES_TYPE_TRACK_ELEMENT,
|
2012-04-25 18:55:46 +00:00
|
|
|
G_TYPE_UINT64);
|
|
|
|
|
|
|
|
/**
|
2019-01-21 13:14:06 +00:00
|
|
|
* GESTimeline::snapping-ended:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @obj1: The first element that was snapping
|
|
|
|
* @obj2: The second element that was snapping
|
|
|
|
* @position: The position where the two objects were to be snapped to
|
2012-04-25 18:55:46 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Will be emitted whenever a snapping event ends. After a snap event
|
|
|
|
* has started (see #GESTimeline::snapping-started), it can end because
|
|
|
|
* the element whose movement created the snap event has since moved
|
|
|
|
* outside of the #GESTimeline:snapping-distance before its position was
|
|
|
|
* committed. It can also end because the element's movement was ended
|
|
|
|
* by a timeline being committed.
|
2012-04-24 00:52:45 +00:00
|
|
|
*/
|
2012-04-25 18:55:46 +00:00
|
|
|
ges_timeline_signals[SNAPING_ENDED] =
|
|
|
|
g_signal_new ("snapping-ended", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
|
2013-01-26 15:31:33 +00:00
|
|
|
G_TYPE_NONE, 3, GES_TYPE_TRACK_ELEMENT, GES_TYPE_TRACK_ELEMENT,
|
2012-04-24 00:52:45 +00:00
|
|
|
G_TYPE_UINT64);
|
2012-12-20 23:23:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GESTimeline::select-tracks-for-object:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @clip: The clip that @track_element is being added to
|
|
|
|
* @track_element: The element being added
|
|
|
|
*
|
|
|
|
* This will be emitted whenever a new track element is added to a
|
|
|
|
* clip within the timeline.
|
|
|
|
*
|
|
|
|
* Connect to this signal once if you wish to control which element
|
|
|
|
* should be added to which track. Doing so will overwrite the default
|
|
|
|
* behaviour, which adds @track_element to all tracks whose
|
|
|
|
* #GESTrack:track-type includes the @track_element's
|
|
|
|
* #GESTrackElement:track-type.
|
2012-12-20 23:23:54 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* If you wish to use this, you should add all necessary tracks to the
|
|
|
|
* timeline before adding any clips. In particular, this signal is
|
|
|
|
* **not** re-emitted for the existing clips when a new track is added
|
|
|
|
* to the timeline.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full) (element-type GESTrack): An array of
|
|
|
|
* #GESTrack-s that @track_element should be added to. If this contains
|
|
|
|
* more than one track, a copy of @track_element will be added to the
|
|
|
|
* other tracks. If this is empty, @track_element will also be removed
|
|
|
|
* from @clip.
|
2012-12-20 23:23:54 +00:00
|
|
|
*/
|
|
|
|
ges_timeline_signals[SELECT_TRACKS_FOR_OBJECT] =
|
|
|
|
g_signal_new ("select-tracks-for-object", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, 0, _gst_array_accumulator, NULL, NULL,
|
2013-01-26 15:31:33 +00:00
|
|
|
G_TYPE_PTR_ARRAY, 2, GES_TYPE_CLIP, GES_TYPE_TRACK_ELEMENT);
|
2013-09-28 13:42:20 +00:00
|
|
|
|
|
|
|
/**
|
2013-11-13 12:18:00 +00:00
|
|
|
* GESTimeline::commited:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
2015-04-08 19:38:48 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* This signal will be emitted once the changes initiated by
|
|
|
|
* ges_timeline_commit() have been executed in the backend. Use
|
|
|
|
* ges_timeline_commit_sync() if you do not want to have to connect
|
|
|
|
* to this signal.
|
2013-09-28 13:42:20 +00:00
|
|
|
*/
|
|
|
|
ges_timeline_signals[COMMITED] =
|
|
|
|
g_signal_new ("commited", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_init (GESTimeline * self)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2012-11-11 16:51:45 +00:00
|
|
|
GESTimelinePrivate *priv = self->priv;
|
2011-01-08 10:22:36 +00:00
|
|
|
|
2018-09-06 01:55:02 +00:00
|
|
|
self->priv = ges_timeline_get_instance_private (self);
|
2019-03-01 22:32:19 +00:00
|
|
|
self->priv->tree = g_node_new (self);
|
2011-01-08 10:22:36 +00:00
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
priv = self->priv;
|
2012-11-11 16:51:45 +00:00
|
|
|
self->layers = NULL;
|
|
|
|
self->tracks = NULL;
|
2013-01-15 13:52:17 +00:00
|
|
|
self->priv->duration = 0;
|
2013-04-24 12:18:01 +00:00
|
|
|
self->priv->auto_transition = FALSE;
|
2012-04-24 00:52:45 +00:00
|
|
|
priv->snapping_distance = 0;
|
2014-07-25 12:47:07 +00:00
|
|
|
priv->expected_async_done = 0;
|
2015-04-08 19:38:48 +00:00
|
|
|
priv->expected_commited = 0;
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
self->priv->last_snap_ts = GST_CLOCK_TIME_NONE;
|
2010-05-19 10:36:11 +00:00
|
|
|
|
2012-12-20 14:28:39 +00:00
|
|
|
priv->priv_tracks = NULL;
|
2013-01-10 21:50:54 +00:00
|
|
|
priv->needs_transitions_update = TRUE;
|
|
|
|
|
2014-02-18 14:14:40 +00:00
|
|
|
priv->all_elements =
|
|
|
|
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, gst_object_unref);
|
|
|
|
|
2019-03-03 23:59:12 +00:00
|
|
|
priv->stream_start_group_id = -1;
|
2019-06-07 03:19:38 +00:00
|
|
|
priv->stream_collection = gst_stream_collection_new (NULL);
|
2013-08-02 12:16:26 +00:00
|
|
|
|
2012-12-20 23:23:54 +00:00
|
|
|
g_signal_connect_after (self, "select-tracks-for-object",
|
|
|
|
G_CALLBACK (select_tracks_for_object_default), NULL);
|
2014-10-26 20:34:29 +00:00
|
|
|
|
|
|
|
g_rec_mutex_init (&priv->dyn_mutex);
|
2015-04-08 19:38:48 +00:00
|
|
|
g_mutex_init (&priv->commited_lock);
|
2018-11-02 17:32:04 +00:00
|
|
|
priv->valid_thread = g_thread_self ();
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
2012-03-31 17:57:04 +00:00
|
|
|
/* Private methods */
|
|
|
|
|
|
|
|
/* Sorting utils*/
|
2011-06-03 02:03:19 +00:00
|
|
|
static gint
|
|
|
|
sort_layers (gpointer a, gpointer b)
|
|
|
|
{
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer_a, *layer_b;
|
2011-06-03 02:03:19 +00:00
|
|
|
guint prio_a, prio_b;
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
layer_a = GES_LAYER (a);
|
|
|
|
layer_b = GES_LAYER (b);
|
2011-06-03 02:03:19 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
prio_a = ges_layer_get_priority (layer_a);
|
|
|
|
prio_b = ges_layer_get_priority (layer_b);
|
2011-06-03 02:03:19 +00:00
|
|
|
|
|
|
|
if ((gint) prio_a > (guint) prio_b)
|
|
|
|
return 1;
|
|
|
|
if ((guint) prio_a < (guint) prio_b)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-12 11:29:50 +00:00
|
|
|
static void
|
|
|
|
_resync_layers (GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
gint i = 0;
|
|
|
|
|
|
|
|
timeline->priv->resyncing_layers = TRUE;
|
|
|
|
for (tmp = timeline->layers; tmp; tmp = tmp->next) {
|
2018-03-31 16:39:54 +00:00
|
|
|
layer_set_priority (tmp->data, i, TRUE);
|
2015-12-12 11:29:50 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
timeline->priv->resyncing_layers = FALSE;
|
|
|
|
}
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
void
|
2012-05-16 16:59:33 +00:00
|
|
|
timeline_update_duration (GESTimeline * timeline)
|
|
|
|
{
|
2019-03-01 22:32:19 +00:00
|
|
|
GstClockTime duration = timeline_tree_get_duration (timeline->priv->tree);
|
2013-08-12 14:13:40 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
if (timeline->priv->duration != duration) {
|
2012-05-16 16:59:33 +00:00
|
|
|
GST_DEBUG ("track duration : %" GST_TIME_FORMAT " current : %"
|
2019-03-01 22:32:19 +00:00
|
|
|
GST_TIME_FORMAT, GST_TIME_ARGS (duration),
|
2012-05-16 16:59:33 +00:00
|
|
|
GST_TIME_ARGS (timeline->priv->duration));
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
timeline->priv->duration = duration;
|
2012-05-16 16:59:33 +00:00
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (timeline), properties[PROP_DURATION]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-31 17:57:04 +00:00
|
|
|
static gint
|
|
|
|
custom_find_track (TrackPrivate * tr_priv, GESTrack * track)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2012-03-31 17:57:04 +00:00
|
|
|
if (tr_priv->track == track)
|
|
|
|
return 0;
|
|
|
|
return -1;
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
2013-01-10 21:50:54 +00:00
|
|
|
static void
|
|
|
|
_destroy_auto_transition_cb (GESAutoTransition * auto_transition,
|
|
|
|
GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
GESTimelinePrivate *priv = timeline->priv;
|
2013-01-17 02:16:02 +00:00
|
|
|
GESClip *transition = auto_transition->transition_clip;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer = ges_clip_get_layer (transition);
|
2016-07-29 01:50:58 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_remove_clip (layer, transition);
|
2013-01-10 21:50:54 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (auto_transition,
|
|
|
|
_destroy_auto_transition_cb, timeline);
|
|
|
|
|
2015-05-29 13:15:25 +00:00
|
|
|
priv->auto_transitions =
|
|
|
|
g_list_remove (priv->auto_transitions, auto_transition);
|
|
|
|
gst_object_unref (auto_transition);
|
2013-01-10 21:50:54 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
GESAutoTransition *
|
|
|
|
ges_timeline_create_transition (GESTimeline * timeline,
|
|
|
|
GESTrackElement * previous, GESTrackElement * next, GESClip * transition,
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer * layer, guint64 start, guint64 duration)
|
2013-01-10 21:50:54 +00:00
|
|
|
{
|
|
|
|
GESAsset *asset;
|
|
|
|
GESAutoTransition *auto_transition;
|
|
|
|
|
|
|
|
if (transition == NULL) {
|
|
|
|
/* TODO make it possible to specify a Transition asset in the API */
|
2013-01-25 18:16:21 +00:00
|
|
|
asset = ges_asset_request (GES_TYPE_TRANSITION_CLIP, "crossfade", NULL);
|
2013-01-10 21:50:54 +00:00
|
|
|
transition =
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_add_asset (layer, asset, start, 0, duration,
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_get_track_type (next));
|
2019-04-08 20:25:59 +00:00
|
|
|
g_object_unref (asset);
|
2013-01-10 21:50:54 +00:00
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (timeline,
|
|
|
|
"Reusing already existing transition: %" GST_PTR_FORMAT, transition);
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
/* We know there is only 1 TrackElement */
|
|
|
|
auto_transition =
|
2013-03-01 01:27:50 +00:00
|
|
|
ges_auto_transition_new (GES_CONTAINER_CHILDREN (transition)->data,
|
|
|
|
previous, next);
|
2013-01-10 21:50:54 +00:00
|
|
|
|
|
|
|
g_signal_connect (auto_transition, "destroy-me",
|
|
|
|
G_CALLBACK (_destroy_auto_transition_cb), timeline);
|
|
|
|
|
2015-05-29 13:15:25 +00:00
|
|
|
timeline->priv->auto_transitions =
|
|
|
|
g_list_prepend (timeline->priv->auto_transitions, auto_transition);
|
2013-01-10 21:50:54 +00:00
|
|
|
|
|
|
|
return auto_transition;
|
|
|
|
}
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
GESAutoTransition *
|
|
|
|
ges_timeline_find_auto_transition (GESTimeline * timeline,
|
|
|
|
GESTrackElement * prev, GESTrackElement * next,
|
|
|
|
GstClockTime transition_duration)
|
2013-01-10 21:50:54 +00:00
|
|
|
{
|
2015-05-29 13:15:25 +00:00
|
|
|
GList *tmp;
|
2013-01-10 21:50:54 +00:00
|
|
|
|
2015-05-29 13:15:25 +00:00
|
|
|
for (tmp = timeline->priv->auto_transitions; tmp; tmp = tmp->next) {
|
2015-06-23 14:11:26 +00:00
|
|
|
GESAutoTransition *auto_trans = (GESAutoTransition *) tmp->data;
|
|
|
|
|
|
|
|
/* We already have a transition linked to one of the elements we want to
|
|
|
|
* find a transition for */
|
|
|
|
if (auto_trans->previous_source == prev || auto_trans->next_source == next) {
|
|
|
|
if (auto_trans->previous_source != prev
|
|
|
|
|| auto_trans->next_source != next) {
|
2019-03-01 22:32:19 +00:00
|
|
|
GST_ERROR_OBJECT (timeline, "Failed creating auto transition, "
|
2015-06-23 14:11:26 +00:00
|
|
|
" trying to have 3 clips overlapping, rolling back");
|
|
|
|
}
|
|
|
|
|
|
|
|
return auto_trans;
|
2015-05-29 13:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
2013-01-10 21:50:54 +00:00
|
|
|
|
2015-06-23 14:11:26 +00:00
|
|
|
return NULL;
|
2013-01-10 21:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GESAutoTransition *
|
|
|
|
_create_auto_transition_from_transitions (GESTimeline * timeline,
|
2019-03-01 22:32:19 +00:00
|
|
|
GESTrackElement * prev, GESTrackElement * next,
|
|
|
|
GstClockTime transition_duration)
|
2013-01-10 21:50:54 +00:00
|
|
|
{
|
2019-03-01 22:32:19 +00:00
|
|
|
GList *tmp, *elements;
|
|
|
|
GESLayer *layer;
|
|
|
|
guint32 layer_prio = GES_TIMELINE_ELEMENT_LAYER_PRIORITY (prev);
|
|
|
|
GESTrack *track;
|
2013-01-10 21:50:54 +00:00
|
|
|
GESAutoTransition *auto_transition =
|
2019-03-01 22:32:19 +00:00
|
|
|
ges_timeline_find_auto_transition (timeline, prev, next,
|
|
|
|
transition_duration);
|
2013-01-10 21:50:54 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
if (auto_transition)
|
|
|
|
return auto_transition;
|
2013-01-10 21:50:54 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
layer = ges_timeline_get_layer (timeline, layer_prio);
|
|
|
|
track = ges_track_element_get_track (prev);
|
|
|
|
elements = ges_track_get_elements (track);
|
|
|
|
for (tmp = elements; tmp; tmp = tmp->next) {
|
|
|
|
GESTrackElement *maybe_transition = tmp->data;
|
2013-01-10 21:50:54 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
if (ges_timeline_element_get_layer_priority (tmp->data) != layer_prio)
|
2013-01-10 21:50:54 +00:00
|
|
|
continue;
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
if (_START (maybe_transition) > _START (next))
|
2013-01-10 21:50:54 +00:00
|
|
|
break;
|
2013-01-15 13:52:17 +00:00
|
|
|
else if (_START (maybe_transition) != _START (next) ||
|
|
|
|
_DURATION (maybe_transition) != transition_duration)
|
2013-01-10 21:50:54 +00:00
|
|
|
continue;
|
2019-03-01 22:32:19 +00:00
|
|
|
else if (GES_IS_TRANSITION (maybe_transition)) {
|
|
|
|
/* Use that transition */
|
|
|
|
/* TODO We should make sure that the transition contains only
|
|
|
|
* TrackElement-s in @track and if it is not the case properly unlink the
|
|
|
|
* object to use it */
|
|
|
|
auto_transition = ges_timeline_create_transition (timeline, prev, next,
|
|
|
|
GES_CLIP (GES_TIMELINE_ELEMENT_PARENT (maybe_transition)), layer,
|
|
|
|
_START (next), transition_duration);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gst_object_unref (layer);
|
|
|
|
g_list_free_full (elements, gst_object_unref);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
return auto_transition;
|
|
|
|
}
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
void
|
|
|
|
ges_timeline_emit_snapping (GESTimeline * timeline, GESTimelineElement * elem1,
|
|
|
|
GESTimelineElement * elem2, GstClockTime snap_time)
|
|
|
|
{
|
|
|
|
GESTimelinePrivate *priv = timeline->priv;
|
|
|
|
GstClockTime last_snap_ts = timeline->priv->last_snap_ts;
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
if (!GST_CLOCK_TIME_IS_VALID (snap_time)) {
|
|
|
|
if (priv->last_snaped1 != NULL && priv->last_snaped2 != NULL) {
|
|
|
|
g_signal_emit (timeline, ges_timeline_signals[SNAPING_ENDED], 0,
|
|
|
|
priv->last_snaped1, priv->last_snaped2, last_snap_ts);
|
|
|
|
priv->last_snaped1 = NULL;
|
|
|
|
priv->last_snaped2 = NULL;
|
|
|
|
priv->last_snap_ts = GST_CLOCK_TIME_NONE;
|
|
|
|
}
|
2016-04-22 19:06:50 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-07-03 07:19:30 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
g_assert (elem1 != elem2);
|
|
|
|
if (GES_IS_CLIP (elem1)) {
|
|
|
|
g_assert (GES_CONTAINER_CHILDREN (elem1));
|
|
|
|
elem1 = GES_CONTAINER_CHILDREN (elem1)->data;
|
|
|
|
}
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
if (GES_IS_CLIP (elem2)) {
|
|
|
|
g_assert (GES_CONTAINER_CHILDREN (elem2));
|
|
|
|
elem2 = GES_CONTAINER_CHILDREN (elem2)->data;
|
|
|
|
}
|
2013-01-10 21:50:54 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
if (last_snap_ts != snap_time) {
|
|
|
|
g_signal_emit (timeline, ges_timeline_signals[SNAPING_ENDED], 0,
|
|
|
|
priv->last_snaped1, priv->last_snaped2, (last_snap_ts));
|
2013-09-07 06:11:23 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
/* We want the snap start signal to be emited anyway */
|
|
|
|
timeline->priv->last_snap_ts = GST_CLOCK_TIME_NONE;
|
|
|
|
}
|
2019-02-08 20:37:39 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
if (!GST_CLOCK_TIME_IS_VALID (timeline->priv->last_snap_ts)) {
|
|
|
|
priv->last_snaped1 = (GESTrackElement *) elem1;
|
|
|
|
priv->last_snaped2 = (GESTrackElement *) elem2;
|
|
|
|
timeline->priv->last_snap_ts = snap_time;
|
2013-09-07 16:59:17 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
g_signal_emit (timeline, ges_timeline_signals[SNAPING_STARTED], 0,
|
|
|
|
elem1, elem2, snap_time);
|
2012-04-24 00:52:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2019-03-01 22:32:19 +00:00
|
|
|
ges_timeline_trim_object_simple (GESTimeline * timeline,
|
|
|
|
GESTimelineElement * element, guint32 new_layer_priority,
|
|
|
|
GList * layers, GESEdge edge, guint64 position, gboolean snapping)
|
2012-04-24 00:52:45 +00:00
|
|
|
{
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
return timeline_trim_object (timeline, element, new_layer_priority, layers,
|
|
|
|
edge, position);
|
|
|
|
}
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
gboolean
|
|
|
|
timeline_ripple_object (GESTimeline * timeline, GESTimelineElement * obj,
|
|
|
|
gint new_layer_priority, GList * layers, GESEdge edge, guint64 position)
|
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
guint64 new_duration;
|
|
|
|
GstClockTimeDiff diff;
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
switch (edge) {
|
|
|
|
case GES_EDGE_NONE:
|
|
|
|
GST_DEBUG ("Simply rippling");
|
2019-03-01 22:32:19 +00:00
|
|
|
diff = GST_CLOCK_DIFF (position, _START (obj));
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
timeline->priv->needs_transitions_update = FALSE;
|
|
|
|
res = timeline_tree_ripple (timeline->priv->tree,
|
|
|
|
(gint64) GES_TIMELINE_ELEMENT_LAYER_PRIORITY (obj) -
|
|
|
|
(gint64) new_layer_priority, diff, obj,
|
|
|
|
GES_EDGE_NONE, timeline->priv->snapping_distance);
|
|
|
|
timeline->priv->needs_transitions_update = TRUE;
|
2015-06-23 14:11:26 +00:00
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
break;
|
|
|
|
case GES_EDGE_END:
|
|
|
|
GST_DEBUG ("Rippling end");
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
timeline->priv->needs_transitions_update = FALSE;
|
|
|
|
new_duration =
|
|
|
|
CLAMP (position - obj->start, 0, obj->maxduration - obj->inpoint);
|
|
|
|
res =
|
|
|
|
timeline_tree_ripple (timeline->priv->tree,
|
|
|
|
(gint64) GES_TIMELINE_ELEMENT_LAYER_PRIORITY (obj) -
|
|
|
|
(gint64) new_layer_priority,
|
|
|
|
_DURATION (obj) - new_duration, obj,
|
|
|
|
GES_EDGE_END, timeline->priv->snapping_distance);
|
2013-01-10 21:50:54 +00:00
|
|
|
timeline->priv->needs_transitions_update = TRUE;
|
2019-03-01 22:32:19 +00:00
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
GST_DEBUG ("Done Rippling end");
|
|
|
|
break;
|
|
|
|
case GES_EDGE_START:
|
2013-09-07 06:10:12 +00:00
|
|
|
GST_INFO ("Ripple start doesn't make sense, trimming instead");
|
2019-03-01 22:32:19 +00:00
|
|
|
if (!timeline_trim_object (timeline, obj, -1, layers, edge, position))
|
2019-02-08 20:44:40 +00:00
|
|
|
goto error;
|
2012-04-24 00:52:45 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GST_DEBUG ("Can not ripple edge: %i", edge);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
return res;
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
timeline_slide_object (GESTimeline * timeline, GESTrackElement * obj,
|
2012-04-24 00:52:45 +00:00
|
|
|
GList * layers, GESEdge edge, guint64 position)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* FIXME implement me! */
|
2013-01-10 15:41:13 +00:00
|
|
|
GST_FIXME_OBJECT (timeline, "Slide mode editing not implemented yet");
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
static gboolean
|
|
|
|
_trim_transition (GESTimeline * timeline, GESTimelineElement * element,
|
|
|
|
GESEdge edge, GstClockTime position)
|
2012-04-24 00:52:45 +00:00
|
|
|
{
|
|
|
|
GList *tmp;
|
2019-03-01 22:32:19 +00:00
|
|
|
GESLayer *layer = ges_timeline_get_layer (timeline,
|
|
|
|
GES_TIMELINE_ELEMENT_LAYER_PRIORITY (element));
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2020-03-05 18:56:28 +00:00
|
|
|
if (!ges_layer_get_auto_transition (layer)) {
|
|
|
|
gst_object_unref (layer);
|
|
|
|
return -1;
|
|
|
|
}
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
gst_object_unref (layer);
|
|
|
|
for (tmp = timeline->priv->auto_transitions; tmp; tmp = tmp->next) {
|
|
|
|
GESAutoTransition *auto_transition = tmp->data;
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
if (GES_TIMELINE_ELEMENT (auto_transition->transition) == element ||
|
|
|
|
GES_TIMELINE_ELEMENT (auto_transition->transition_clip) == element) {
|
|
|
|
/* Trimming an auto transition means trimming its neighboors */
|
|
|
|
if (!auto_transition->positioning) {
|
|
|
|
if (edge == GES_EDGE_END) {
|
|
|
|
ges_container_edit (GES_CONTAINER (auto_transition->previous_clip),
|
|
|
|
NULL, -1, GES_EDIT_MODE_TRIM, GES_EDGE_END, position);
|
|
|
|
} else {
|
|
|
|
ges_container_edit (GES_CONTAINER (auto_transition->next_clip),
|
|
|
|
NULL, -1, GES_EDIT_MODE_TRIM, GES_EDGE_START, position);
|
2012-04-24 00:52:45 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
return TRUE;
|
2013-09-07 16:59:17 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2012-04-24 00:52:45 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
return FALSE;
|
2012-04-24 00:52:45 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
gboolean
|
2019-03-01 22:32:19 +00:00
|
|
|
timeline_trim_object (GESTimeline * timeline, GESTimelineElement * object,
|
|
|
|
guint32 new_layer_priority, GList * layers, GESEdge edge, guint64 position)
|
2012-04-24 00:52:45 +00:00
|
|
|
{
|
2019-03-01 22:32:19 +00:00
|
|
|
if ((GES_IS_TRANSITION (object) || GES_IS_TRANSITION_CLIP (object)) &&
|
|
|
|
!ELEMENT_FLAG_IS_SET (object, GES_TIMELINE_ELEMENT_SET_SIMPLE)) {
|
|
|
|
return _trim_transition (timeline, object, edge, position);
|
2012-04-24 00:52:45 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
return timeline_tree_trim (timeline->priv->tree,
|
2020-02-27 16:08:45 +00:00
|
|
|
GES_TIMELINE_ELEMENT (object), new_layer_priority < 0 ? 0 : (gint64)
|
2019-03-01 22:32:19 +00:00
|
|
|
ges_timeline_element_get_layer_priority (GES_TIMELINE_ELEMENT (object)) -
|
2020-02-27 16:08:45 +00:00
|
|
|
new_layer_priority, edge == GES_EDGE_END ? GST_CLOCK_DIFF (position,
|
2019-03-01 22:32:19 +00:00
|
|
|
_START (object) + _DURATION (object)) : GST_CLOCK_DIFF (position,
|
|
|
|
GES_TIMELINE_ELEMENT_START (object)), edge,
|
|
|
|
timeline->priv->snapping_distance);
|
2012-04-24 00:52:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2019-03-01 22:32:19 +00:00
|
|
|
timeline_roll_object (GESTimeline * timeline, GESTimelineElement * element,
|
|
|
|
GList * layers, GESEdge edge, guint64 position)
|
2012-04-24 00:52:45 +00:00
|
|
|
{
|
2019-03-01 22:32:19 +00:00
|
|
|
return timeline_tree_roll (timeline->priv->tree,
|
|
|
|
element,
|
|
|
|
(edge == GES_EDGE_END) ?
|
|
|
|
GST_CLOCK_DIFF (position, _END (element)) :
|
|
|
|
GST_CLOCK_DIFF (position, _START (element)),
|
|
|
|
edge, timeline->priv->snapping_distance);
|
2012-04-24 00:52:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2019-03-01 22:32:19 +00:00
|
|
|
timeline_move_object (GESTimeline * timeline, GESTimelineElement * object,
|
|
|
|
guint32 new_layer_priority, GList * layers, GESEdge edge, guint64 position)
|
2012-04-24 00:52:45 +00:00
|
|
|
{
|
2019-03-01 22:32:19 +00:00
|
|
|
gboolean ret = FALSE;
|
|
|
|
GstClockTimeDiff offset = edge == GES_EDGE_END ?
|
|
|
|
GST_CLOCK_DIFF (position, _START (object) + _DURATION (object)) :
|
|
|
|
GST_CLOCK_DIFF (position, GES_TIMELINE_ELEMENT_START (object));
|
2015-06-23 14:11:26 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
ret = timeline_tree_move (timeline->priv->tree,
|
|
|
|
GES_TIMELINE_ELEMENT (object), new_layer_priority < 0 ? 0 : (gint64)
|
|
|
|
ges_timeline_element_get_layer_priority (GES_TIMELINE_ELEMENT (object)) -
|
|
|
|
new_layer_priority, offset, edge, timeline->priv->snapping_distance);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
gboolean
|
|
|
|
ges_timeline_move_object_simple (GESTimeline * timeline,
|
|
|
|
GESTimelineElement * element, GList * layers, GESEdge edge,
|
|
|
|
guint64 position)
|
|
|
|
{
|
|
|
|
return timeline_move_object (timeline, element,
|
|
|
|
ges_timeline_element_get_layer_priority (element), NULL, edge, position);
|
|
|
|
}
|
|
|
|
|
2013-06-26 21:08:57 +00:00
|
|
|
void
|
|
|
|
timeline_add_group (GESTimeline * timeline, GESGroup * group)
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (timeline, "Adding group %" GST_PTR_FORMAT, group);
|
|
|
|
|
|
|
|
timeline->priv->groups = g_list_prepend (timeline->priv->groups,
|
|
|
|
gst_object_ref_sink (group));
|
|
|
|
|
|
|
|
ges_timeline_element_set_timeline (GES_TIMELINE_ELEMENT (group), timeline);
|
2016-09-06 12:27:38 +00:00
|
|
|
}
|
2016-02-16 12:49:57 +00:00
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
void
|
|
|
|
timeline_update_transition (GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
GList *tmp, *auto_transs;
|
|
|
|
|
|
|
|
auto_transs = g_list_copy (timeline->priv->auto_transitions);
|
|
|
|
for (tmp = auto_transs; tmp; tmp = tmp->next)
|
|
|
|
ges_auto_transition_update (tmp->data);
|
|
|
|
g_list_free (auto_transs);
|
|
|
|
}
|
|
|
|
|
2016-09-06 12:27:38 +00:00
|
|
|
/**
|
|
|
|
* timeline_emit_group_added:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
2016-09-06 12:27:38 +00:00
|
|
|
* @group: group that was added
|
|
|
|
*
|
|
|
|
* Emit group-added signal.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
timeline_emit_group_added (GESTimeline * timeline, GESGroup * group)
|
|
|
|
{
|
2016-02-16 12:49:57 +00:00
|
|
|
g_signal_emit (timeline, ges_timeline_signals[GROUP_ADDED], 0, group);
|
|
|
|
}
|
|
|
|
|
2016-04-30 17:38:33 +00:00
|
|
|
/**
|
2016-09-06 11:03:11 +00:00
|
|
|
* timeline_emit_group_removed:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
2016-04-30 17:38:33 +00:00
|
|
|
* @group: group that was removed
|
|
|
|
*
|
|
|
|
* Emit group-removed signal.
|
|
|
|
*/
|
2016-02-16 12:49:57 +00:00
|
|
|
void
|
2016-05-06 18:18:50 +00:00
|
|
|
timeline_emit_group_removed (GESTimeline * timeline, GESGroup * group,
|
2016-02-16 12:49:57 +00:00
|
|
|
GPtrArray * array)
|
|
|
|
{
|
|
|
|
g_signal_emit (timeline, ges_timeline_signals[GROUP_REMOVED], 0, group,
|
|
|
|
array);
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
timeline_remove_group (GESTimeline * timeline, GESGroup * group)
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (timeline, "Removing group %" GST_PTR_FORMAT, group);
|
|
|
|
|
|
|
|
timeline->priv->groups = g_list_remove (timeline->priv->groups, group);
|
|
|
|
|
|
|
|
ges_timeline_element_set_timeline (GES_TIMELINE_ELEMENT (group), NULL);
|
|
|
|
gst_object_unref (group);
|
|
|
|
}
|
|
|
|
|
2012-12-20 23:23:54 +00:00
|
|
|
static GPtrArray *
|
|
|
|
select_tracks_for_object_default (GESTimeline * timeline,
|
2013-01-26 15:31:33 +00:00
|
|
|
GESClip * clip, GESTrackElement * tr_object, gpointer user_data)
|
2010-10-20 17:00:24 +00:00
|
|
|
{
|
2012-12-20 23:23:54 +00:00
|
|
|
GPtrArray *result;
|
|
|
|
GList *tmp;
|
|
|
|
|
|
|
|
result = g_ptr_array_new ();
|
|
|
|
|
2019-06-21 14:47:34 +00:00
|
|
|
LOCK_DYN (timeline);
|
2012-12-20 23:23:54 +00:00
|
|
|
for (tmp = timeline->tracks; tmp; tmp = tmp->next) {
|
|
|
|
GESTrack *track = GES_TRACK (tmp->data);
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if ((track->type & ges_track_element_get_track_type (tr_object))) {
|
2012-12-20 23:23:54 +00:00
|
|
|
gst_object_ref (track);
|
|
|
|
g_ptr_array_add (result, track);
|
2012-02-02 18:29:30 +00:00
|
|
|
}
|
2010-10-20 17:00:24 +00:00
|
|
|
}
|
2019-06-21 14:47:34 +00:00
|
|
|
UNLOCK_DYN (timeline);
|
2012-12-20 23:23:54 +00:00
|
|
|
|
|
|
|
return result;
|
2010-10-20 17:00:24 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
add_object_to_tracks (GESTimeline * timeline, GESClip * clip, GESTrack * track)
|
2009-08-06 15:38:43 +00:00
|
|
|
{
|
2012-12-20 23:23:54 +00:00
|
|
|
gint i;
|
2014-10-26 20:32:41 +00:00
|
|
|
GList *tmp, *list;
|
2012-12-29 21:24:05 +00:00
|
|
|
GESTrackType types, visited_type = GES_TRACK_TYPE_UNKNOWN;
|
2012-12-20 23:23:54 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (timeline, "Creating %" GST_PTR_FORMAT
|
2013-02-15 02:34:48 +00:00
|
|
|
" trackelements and adding them to our tracks", clip);
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
types = ges_clip_get_supported_formats (clip);
|
2012-12-20 23:23:54 +00:00
|
|
|
if (track) {
|
|
|
|
if ((types & track->type) == 0)
|
|
|
|
return;
|
|
|
|
types = track->type;
|
|
|
|
}
|
|
|
|
|
2019-06-21 14:47:34 +00:00
|
|
|
LOCK_DYN (timeline);
|
2012-12-20 23:23:54 +00:00
|
|
|
for (i = 0, tmp = timeline->tracks; tmp; tmp = tmp->next, i++) {
|
|
|
|
GESTrack *track = GES_TRACK (tmp->data);
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: visited_type is essentially unused */
|
2012-12-20 23:23:54 +00:00
|
|
|
if (((track->type & types) == 0 || (track->type & visited_type)))
|
|
|
|
continue;
|
|
|
|
|
2014-10-26 20:32:41 +00:00
|
|
|
list = ges_clip_create_track_elements (clip, track->type);
|
|
|
|
g_list_free (list);
|
2013-03-14 16:53:25 +00:00
|
|
|
}
|
2019-06-21 14:47:34 +00:00
|
|
|
UNLOCK_DYN (timeline);
|
2013-03-14 16:53:25 +00:00
|
|
|
}
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2013-03-14 16:53:25 +00:00
|
|
|
static void
|
2013-04-23 23:04:04 +00:00
|
|
|
layer_auto_transition_changed_cb (GESLayer * layer,
|
2013-03-14 16:53:25 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESTimeline * timeline)
|
|
|
|
{
|
2015-07-16 08:54:54 +00:00
|
|
|
GList *tmp, *clips;
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
timeline_tree_create_transitions (timeline->priv->tree,
|
2013-03-14 16:53:25 +00:00
|
|
|
_create_auto_transition_from_transitions);
|
2015-07-16 08:54:54 +00:00
|
|
|
clips = ges_layer_get_clips (layer);
|
|
|
|
for (tmp = clips; tmp; tmp = tmp->next) {
|
|
|
|
if (GES_IS_TRANSITION_CLIP (tmp->data)) {
|
|
|
|
GList *tmpautotrans;
|
|
|
|
gboolean found = FALSE;
|
|
|
|
|
|
|
|
for (tmpautotrans = timeline->priv->auto_transitions; tmpautotrans;
|
|
|
|
tmpautotrans = tmpautotrans->next) {
|
|
|
|
if (GES_AUTO_TRANSITION (tmpautotrans->data)->transition_clip ==
|
|
|
|
tmp->data) {
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
GST_ERROR_OBJECT (timeline,
|
|
|
|
"Transition %s could not be wrapped into an auto transition"
|
|
|
|
" REMOVING it", GES_TIMELINE_ELEMENT_NAME (tmp->data));
|
|
|
|
|
|
|
|
ges_layer_remove_clip (layer, tmp->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_list_free_full (clips, gst_object_unref);
|
2013-03-14 16:53:25 +00:00
|
|
|
}
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2013-03-14 16:53:25 +00:00
|
|
|
static void
|
2013-06-26 21:08:57 +00:00
|
|
|
clip_track_element_added_cb (GESClip * clip,
|
|
|
|
GESTrackElement * track_element, GESTimeline * timeline)
|
2013-03-14 16:53:25 +00:00
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
GESTrack *track;
|
2014-02-17 12:33:51 +00:00
|
|
|
gboolean is_source;
|
2013-03-14 16:53:25 +00:00
|
|
|
GPtrArray *tracks = NULL;
|
2014-02-17 12:33:51 +00:00
|
|
|
GESTrackElement *existing_src = NULL;
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2013-03-14 16:53:25 +00:00
|
|
|
if (timeline->priv->ignore_track_element_added == clip) {
|
|
|
|
GST_DEBUG_OBJECT (timeline, "Ignoring element added (%" GST_PTR_FORMAT
|
|
|
|
" in %" GST_PTR_FORMAT, track_element, clip);
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2013-03-14 16:53:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2013-03-14 16:53:25 +00:00
|
|
|
if (ges_track_element_get_track (track_element)) {
|
|
|
|
GST_WARNING_OBJECT (track_element, "Already in a track");
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2013-03-14 16:53:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2013-03-14 16:53:25 +00:00
|
|
|
g_signal_emit (G_OBJECT (timeline),
|
|
|
|
ges_timeline_signals[SELECT_TRACKS_FOR_OBJECT], 0, clip, track_element,
|
|
|
|
&tracks);
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: make sure each track in the list is unique */
|
|
|
|
/* FIXME: make sure each track is part of the same timeline as the clip,
|
|
|
|
* and warn and ignore the track if it isn't */
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2013-03-14 16:53:25 +00:00
|
|
|
if (!tracks || tracks->len == 0) {
|
|
|
|
GST_WARNING_OBJECT (timeline, "Got no Track to add %p (type %s), removing"
|
2015-09-24 11:21:15 +00:00
|
|
|
" from clip (stopping 'child-added' signal emission).",
|
2013-03-14 16:53:25 +00:00
|
|
|
track_element, ges_track_type_name (ges_track_element_get_track_type
|
|
|
|
(track_element)));
|
|
|
|
|
|
|
|
if (tracks)
|
|
|
|
g_ptr_array_unref (tracks);
|
|
|
|
|
2015-09-24 11:21:15 +00:00
|
|
|
g_signal_stop_emission_by_name (clip, "child-added");
|
2013-03-14 16:53:25 +00:00
|
|
|
ges_container_remove (GES_CONTAINER (clip),
|
|
|
|
GES_TIMELINE_ELEMENT (track_element));
|
|
|
|
|
|
|
|
return;
|
2009-08-06 15:38:43 +00:00
|
|
|
}
|
2010-05-19 10:36:11 +00:00
|
|
|
|
2013-03-14 16:53:25 +00:00
|
|
|
/* We add the current element to the first track */
|
|
|
|
track = g_ptr_array_index (tracks, 0);
|
2014-02-17 12:33:51 +00:00
|
|
|
|
|
|
|
is_source = g_type_is_a (G_OBJECT_TYPE (track_element), GES_TYPE_SOURCE);
|
|
|
|
if (is_source)
|
|
|
|
existing_src = ges_clip_find_track_element (clip, track, GES_TYPE_SOURCE);
|
|
|
|
|
|
|
|
if (existing_src == NULL) {
|
|
|
|
if (!ges_track_add_element (track, track_element)) {
|
|
|
|
GST_WARNING_OBJECT (clip, "Failed to add track element to track");
|
|
|
|
ges_container_remove (GES_CONTAINER (clip),
|
|
|
|
GES_TIMELINE_ELEMENT (track_element));
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: unref all the individual track in tracks */
|
2014-10-26 20:33:50 +00:00
|
|
|
g_ptr_array_unref (tracks);
|
2014-02-17 12:33:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
GST_INFO_OBJECT (clip, "Already had a Source Element in %" GST_PTR_FORMAT
|
2015-09-24 11:21:15 +00:00
|
|
|
" of type %s, removing new one. (stopping 'child-added' emission)",
|
|
|
|
track, G_OBJECT_TYPE_NAME (track_element));
|
|
|
|
g_signal_stop_emission_by_name (clip, "child-added");
|
2013-03-14 16:53:25 +00:00
|
|
|
ges_container_remove (GES_CONTAINER (clip),
|
|
|
|
GES_TIMELINE_ELEMENT (track_element));
|
|
|
|
}
|
|
|
|
gst_object_unref (track);
|
2014-02-17 12:33:51 +00:00
|
|
|
g_clear_object (&existing_src);
|
2013-03-14 16:53:25 +00:00
|
|
|
|
|
|
|
/* And create copies to add to other tracks */
|
|
|
|
timeline->priv->ignore_track_element_added = clip;
|
|
|
|
for (i = 1; i < tracks->len; i++) {
|
|
|
|
GESTrack *track;
|
|
|
|
GESTrackElement *track_element_copy;
|
|
|
|
|
|
|
|
track = g_ptr_array_index (tracks, i);
|
2014-02-17 12:33:51 +00:00
|
|
|
if (is_source)
|
|
|
|
existing_src = ges_clip_find_track_element (clip, track, GES_TYPE_SOURCE);
|
|
|
|
if (existing_src == NULL) {
|
|
|
|
ges_container_remove (GES_CONTAINER (clip),
|
|
|
|
GES_TIMELINE_ELEMENT (track_element));
|
|
|
|
gst_object_unref (track);
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: tracks is needed for the next loop after continue */
|
2014-10-26 20:33:50 +00:00
|
|
|
g_ptr_array_unref (tracks);
|
2014-02-17 12:33:51 +00:00
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
GST_INFO_OBJECT (clip, "Already had a Source Element in %" GST_PTR_FORMAT
|
2015-09-24 11:21:15 +00:00
|
|
|
" of type %s, removing new one. (stopping 'child-added' emission)",
|
|
|
|
track, G_OBJECT_TYPE_NAME (track_element));
|
|
|
|
g_signal_stop_emission_by_name (clip, "child-added");
|
2014-02-17 12:33:51 +00:00
|
|
|
ges_container_remove (GES_CONTAINER (clip),
|
|
|
|
GES_TIMELINE_ELEMENT (track_element));
|
|
|
|
}
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: in both cases track_element is removed from the clip! */
|
2014-02-17 12:33:51 +00:00
|
|
|
g_clear_object (&existing_src);
|
|
|
|
|
2013-03-14 16:53:25 +00:00
|
|
|
track_element_copy =
|
|
|
|
GES_TRACK_ELEMENT (ges_timeline_element_copy (GES_TIMELINE_ELEMENT
|
|
|
|
(track_element), TRUE));
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (timeline, "Trying to add %p to track %p",
|
|
|
|
track_element_copy, track);
|
|
|
|
|
|
|
|
if (!ges_container_add (GES_CONTAINER (clip),
|
|
|
|
GES_TIMELINE_ELEMENT (track_element_copy))) {
|
|
|
|
GST_WARNING_OBJECT (clip, "Failed to add track element to clip");
|
|
|
|
gst_object_unref (track_element_copy);
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: unref **all** the individual track in tracks */
|
2014-10-26 20:33:50 +00:00
|
|
|
g_ptr_array_unref (tracks);
|
2013-03-14 16:53:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ges_track_add_element (track, track_element_copy)) {
|
|
|
|
GST_WARNING_OBJECT (clip, "Failed to add track element to track");
|
|
|
|
ges_container_remove (GES_CONTAINER (clip),
|
|
|
|
GES_TIMELINE_ELEMENT (track_element_copy));
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: should we also stop the child-added and child-removed
|
|
|
|
* emissions? */
|
2013-03-14 16:53:25 +00:00
|
|
|
gst_object_unref (track_element_copy);
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: unref **all** the individual track in tracks */
|
2014-10-26 20:33:50 +00:00
|
|
|
g_ptr_array_unref (tracks);
|
2013-03-14 16:53:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-01-10 21:50:54 +00:00
|
|
|
|
2013-03-14 16:53:25 +00:00
|
|
|
gst_object_unref (track);
|
|
|
|
}
|
|
|
|
timeline->priv->ignore_track_element_added = NULL;
|
2014-10-26 20:33:50 +00:00
|
|
|
g_ptr_array_unref (tracks);
|
2019-03-01 22:32:19 +00:00
|
|
|
if (GES_IS_SOURCE (track_element))
|
|
|
|
timeline_tree_create_transitions (timeline->priv->tree,
|
|
|
|
ges_timeline_find_auto_transition);
|
2013-01-10 21:50:54 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 03:01:47 +00:00
|
|
|
static void
|
2013-06-26 21:08:57 +00:00
|
|
|
clip_track_element_removed_cb (GESClip * clip,
|
|
|
|
GESTrackElement * track_element, GESTimeline * timeline)
|
2013-03-15 03:01:47 +00:00
|
|
|
{
|
|
|
|
GESTrack *track = ges_track_element_get_track (track_element);
|
|
|
|
|
|
|
|
if (track)
|
|
|
|
ges_track_remove_element (track, track_element);
|
|
|
|
}
|
|
|
|
|
2010-05-19 10:36:11 +00:00
|
|
|
static void
|
2013-04-23 23:04:04 +00:00
|
|
|
layer_object_added_cb (GESLayer * layer, GESClip * clip, GESTimeline * timeline)
|
2010-05-19 10:36:11 +00:00
|
|
|
{
|
2013-11-25 18:17:33 +00:00
|
|
|
GESProject *project;
|
|
|
|
|
2013-03-15 03:01:47 +00:00
|
|
|
/* We make sure not to be connected twice */
|
|
|
|
g_signal_handlers_disconnect_by_func (clip, clip_track_element_added_cb,
|
|
|
|
timeline);
|
|
|
|
g_signal_handlers_disconnect_by_func (clip, clip_track_element_removed_cb,
|
|
|
|
timeline);
|
|
|
|
|
|
|
|
/* And we connect to the object */
|
|
|
|
g_signal_connect (clip, "child-added",
|
|
|
|
G_CALLBACK (clip_track_element_added_cb), timeline);
|
|
|
|
g_signal_connect (clip, "child-removed",
|
|
|
|
G_CALLBACK (clip_track_element_removed_cb), timeline);
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
if (ges_clip_is_moving_from_layer (clip)) {
|
2013-03-15 03:01:47 +00:00
|
|
|
GST_DEBUG ("Clip %p moving from one layer to another, not creating "
|
|
|
|
"TrackElement", clip);
|
2019-03-01 22:32:19 +00:00
|
|
|
timeline_tree_create_transitions (timeline->priv->tree,
|
|
|
|
ges_timeline_find_auto_transition);
|
2011-06-06 19:55:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
add_object_to_tracks (timeline, clip, NULL);
|
2013-11-25 18:17:33 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Making sure that the asset is in our project");
|
|
|
|
project =
|
|
|
|
GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE (timeline)));
|
|
|
|
ges_project_add_asset (project,
|
|
|
|
ges_extractable_get_asset (GES_EXTRACTABLE (clip)));
|
|
|
|
|
2012-12-17 20:05:56 +00:00
|
|
|
GST_DEBUG ("Done");
|
2009-08-06 15:38:43 +00:00
|
|
|
}
|
|
|
|
|
2011-06-03 02:03:19 +00:00
|
|
|
static void
|
2013-04-23 23:04:04 +00:00
|
|
|
layer_priority_changed_cb (GESLayer * layer,
|
2011-06-03 02:03:19 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESTimeline * timeline)
|
|
|
|
{
|
2018-03-31 16:39:54 +00:00
|
|
|
if (timeline->priv->resyncing_layers)
|
|
|
|
return;
|
|
|
|
|
2012-11-11 16:51:45 +00:00
|
|
|
timeline->layers = g_list_sort (timeline->layers, (GCompareFunc)
|
2011-06-03 02:03:19 +00:00
|
|
|
sort_layers);
|
|
|
|
}
|
2009-08-06 15:38:43 +00:00
|
|
|
|
|
|
|
static void
|
2013-04-23 23:04:04 +00:00
|
|
|
layer_object_removed_cb (GESLayer * layer, GESClip * clip,
|
2009-08-06 15:38:43 +00:00
|
|
|
GESTimeline * timeline)
|
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GList *trackelements, *tmp;
|
2009-08-07 14:41:23 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
if (ges_clip_is_moving_from_layer (clip)) {
|
2013-01-20 15:42:29 +00:00
|
|
|
GST_DEBUG ("Clip %p is moving from a layer to another, not doing"
|
2013-02-15 02:34:48 +00:00
|
|
|
" anything on it", clip);
|
2011-06-06 19:55:47 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-08-07 14:41:23 +00:00
|
|
|
|
2019-08-23 21:26:51 +00:00
|
|
|
GST_DEBUG_OBJECT (timeline, "Clip %" GES_FORMAT " removed from layer %p",
|
|
|
|
GES_ARGS (clip), layer);
|
2009-08-07 14:41:23 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
/* Go over the clip's track element and figure out which one belongs to
|
2009-08-07 14:41:23 +00:00
|
|
|
* the list of tracks we control */
|
|
|
|
|
2013-07-10 19:24:28 +00:00
|
|
|
trackelements = ges_container_get_children (GES_CONTAINER (clip), FALSE);
|
2013-01-26 15:31:33 +00:00
|
|
|
for (tmp = trackelements; tmp; tmp = tmp->next) {
|
2013-02-15 02:34:48 +00:00
|
|
|
GESTrackElement *track_element = (GESTrackElement *) tmp->data;
|
2013-03-23 07:14:55 +00:00
|
|
|
GESTrack *track = ges_track_element_get_track (track_element);
|
2009-08-07 14:41:23 +00:00
|
|
|
|
2016-06-18 20:16:00 +00:00
|
|
|
if (!track)
|
|
|
|
continue;
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
GST_DEBUG_OBJECT (timeline, "Trying to remove TrackElement %p",
|
|
|
|
track_element);
|
2013-03-23 07:14:55 +00:00
|
|
|
|
|
|
|
/* FIXME Check if we should actually check that we control the
|
|
|
|
* track in the new management of TrackElement context */
|
2013-05-29 18:05:52 +00:00
|
|
|
LOCK_DYN (timeline);
|
2013-03-23 07:14:55 +00:00
|
|
|
if (G_LIKELY (g_list_find_custom (timeline->priv->priv_tracks, track,
|
|
|
|
(GCompareFunc) custom_find_track) || track == NULL)) {
|
2009-08-07 14:41:23 +00:00
|
|
|
GST_DEBUG ("Belongs to one of the tracks we control");
|
|
|
|
|
2016-06-18 20:16:00 +00:00
|
|
|
ges_track_remove_element (track, track_element);
|
2009-08-07 14:41:23 +00:00
|
|
|
}
|
2013-05-29 18:05:52 +00:00
|
|
|
UNLOCK_DYN (timeline);
|
2009-08-07 14:41:23 +00:00
|
|
|
}
|
2013-03-14 16:53:25 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (clip, clip_track_element_added_cb,
|
|
|
|
timeline);
|
2013-03-15 03:01:47 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (clip, clip_track_element_removed_cb,
|
|
|
|
timeline);
|
2011-08-24 10:04:32 +00:00
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
g_list_free_full (trackelements, gst_object_unref);
|
2009-08-07 14:41:23 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Done");
|
2009-08-06 15:38:43 +00:00
|
|
|
}
|
|
|
|
|
2019-06-07 03:19:38 +00:00
|
|
|
static gboolean
|
|
|
|
update_stream_object (TrackPrivate * tr_priv)
|
|
|
|
{
|
|
|
|
gboolean res = FALSE;
|
|
|
|
GstStreamType type = GST_STREAM_TYPE_UNKNOWN;
|
|
|
|
gchar *stream_id;
|
|
|
|
|
|
|
|
g_object_get (tr_priv->track, "id", &stream_id, NULL);
|
|
|
|
if (tr_priv->track->type == GES_TRACK_TYPE_VIDEO)
|
|
|
|
type = GST_STREAM_TYPE_VIDEO;
|
|
|
|
if (tr_priv->track->type == GES_TRACK_TYPE_AUDIO)
|
|
|
|
type = GST_STREAM_TYPE_AUDIO;
|
|
|
|
|
|
|
|
if (!tr_priv->stream ||
|
|
|
|
g_strcmp0 (stream_id, gst_stream_get_stream_id (tr_priv->stream))) {
|
|
|
|
res = TRUE;
|
|
|
|
gst_object_replace ((GstObject **) & tr_priv->stream,
|
|
|
|
(GstObject *) gst_stream_new (stream_id,
|
|
|
|
(GstCaps *) ges_track_get_caps (tr_priv->track),
|
|
|
|
type, GST_STREAM_FLAG_NONE)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (stream_id);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
trackelement_start_changed_cb (GESTrackElement * child,
|
2012-04-24 00:52:45 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESTimeline * timeline)
|
|
|
|
{
|
2019-03-01 22:32:19 +00:00
|
|
|
timeline_update_duration (timeline);
|
2012-04-24 00:52:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
track_element_added_cb (GESTrack * track, GESTrackElement * track_element,
|
2012-04-24 00:52:45 +00:00
|
|
|
GESTimeline * timeline)
|
|
|
|
{
|
2013-01-10 14:39:46 +00:00
|
|
|
/* Auto transition should be updated before we receive the signal */
|
2013-02-15 02:34:48 +00:00
|
|
|
g_signal_connect_after (GES_TRACK_ELEMENT (track_element), "notify::start",
|
2013-01-26 15:31:33 +00:00
|
|
|
G_CALLBACK (trackelement_start_changed_cb), timeline);
|
2012-04-24 00:52:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-06-26 21:08:57 +00:00
|
|
|
track_element_removed_cb (GESTrack * track,
|
|
|
|
GESTrackElement * track_element, GESTimeline * timeline)
|
2012-04-24 00:52:45 +00:00
|
|
|
{
|
2013-01-10 14:39:46 +00:00
|
|
|
/* Disconnect all signal handlers */
|
2013-02-15 02:34:48 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (track_element,
|
2013-10-01 18:07:10 +00:00
|
|
|
trackelement_start_changed_cb, timeline);
|
2012-04-24 00:52:45 +00:00
|
|
|
}
|
|
|
|
|
2013-08-02 12:16:26 +00:00
|
|
|
static GstPadProbeReturn
|
|
|
|
_pad_probe_cb (GstPad * mixer_pad, GstPadProbeInfo * info,
|
2019-06-06 21:21:01 +00:00
|
|
|
TrackPrivate * tr_priv)
|
2013-08-02 12:16:26 +00:00
|
|
|
{
|
|
|
|
GstEvent *event = GST_PAD_PROBE_INFO_EVENT (info);
|
2019-06-06 21:21:01 +00:00
|
|
|
GESTimeline *timeline = tr_priv->timeline;
|
|
|
|
|
2013-08-02 12:16:26 +00:00
|
|
|
if (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START) {
|
|
|
|
LOCK_DYN (timeline);
|
2019-03-03 23:59:12 +00:00
|
|
|
if (timeline->priv->stream_start_group_id == -1) {
|
|
|
|
if (!gst_event_parse_group_id (event,
|
|
|
|
&timeline->priv->stream_start_group_id))
|
|
|
|
timeline->priv->stream_start_group_id = gst_util_group_id_next ();
|
2013-08-02 12:16:26 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 21:21:01 +00:00
|
|
|
gst_event_unref (event);
|
2019-06-07 03:19:38 +00:00
|
|
|
event = info->data =
|
|
|
|
gst_event_new_stream_start (gst_stream_get_stream_id (tr_priv->stream));
|
|
|
|
gst_event_set_stream (event, tr_priv->stream);
|
|
|
|
gst_event_set_group_id (event, timeline->priv->stream_start_group_id);
|
2013-08-02 12:16:26 +00:00
|
|
|
UNLOCK_DYN (timeline);
|
|
|
|
|
|
|
|
return GST_PAD_PROBE_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GST_PAD_PROBE_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-31 17:57:04 +00:00
|
|
|
static void
|
2014-10-21 08:59:43 +00:00
|
|
|
_ghost_track_srcpad (TrackPrivate * tr_priv)
|
2012-03-31 17:57:04 +00:00
|
|
|
{
|
2014-10-21 08:59:43 +00:00
|
|
|
GstPad *pad;
|
2012-05-18 17:17:17 +00:00
|
|
|
gchar *padname;
|
|
|
|
gboolean no_more;
|
2012-03-31 17:57:04 +00:00
|
|
|
GList *tmp;
|
2014-10-21 08:59:43 +00:00
|
|
|
GESTrack *track = tr_priv->track;
|
2012-03-31 17:57:04 +00:00
|
|
|
|
2014-10-21 08:59:43 +00:00
|
|
|
pad = gst_element_get_static_pad (GST_ELEMENT (track), "src");
|
2012-05-18 17:17:17 +00:00
|
|
|
|
2014-10-21 08:59:43 +00:00
|
|
|
GST_DEBUG ("track:%p, pad:%s:%s", track, GST_DEBUG_PAD_NAME (pad));
|
2012-05-18 17:17:17 +00:00
|
|
|
|
|
|
|
/* Remember the pad */
|
2013-05-29 18:05:52 +00:00
|
|
|
LOCK_DYN (tr_priv->timeline);
|
2012-05-18 17:17:17 +00:00
|
|
|
GST_OBJECT_LOCK (track);
|
|
|
|
tr_priv->pad = pad;
|
|
|
|
|
|
|
|
no_more = TRUE;
|
2012-12-20 14:28:39 +00:00
|
|
|
for (tmp = tr_priv->timeline->priv->priv_tracks; tmp; tmp = g_list_next (tmp)) {
|
2012-03-31 17:57:04 +00:00
|
|
|
TrackPrivate *tr_priv = (TrackPrivate *) tmp->data;
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2012-05-18 17:17:17 +00:00
|
|
|
if (!tr_priv->pad) {
|
|
|
|
GST_LOG ("Found track without pad %p", tr_priv->track);
|
|
|
|
no_more = FALSE;
|
|
|
|
}
|
2012-03-31 17:57:04 +00:00
|
|
|
}
|
2012-05-18 17:17:17 +00:00
|
|
|
GST_OBJECT_UNLOCK (track);
|
2012-03-31 17:57:04 +00:00
|
|
|
|
2012-05-18 17:17:17 +00:00
|
|
|
/* ghost it ! */
|
|
|
|
GST_DEBUG ("Ghosting pad and adding it to ourself");
|
|
|
|
padname = g_strdup_printf ("track_%p_src", track);
|
|
|
|
tr_priv->ghostpad = gst_ghost_pad_new (padname, pad);
|
|
|
|
g_free (padname);
|
|
|
|
gst_pad_set_active (tr_priv->ghostpad, TRUE);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (tr_priv->timeline), tr_priv->ghostpad);
|
2012-03-31 17:57:04 +00:00
|
|
|
|
2012-05-18 17:17:17 +00:00
|
|
|
if (no_more) {
|
|
|
|
GST_DEBUG ("Signaling no-more-pads");
|
|
|
|
gst_element_no_more_pads (GST_ELEMENT (tr_priv->timeline));
|
|
|
|
}
|
2013-08-02 12:16:26 +00:00
|
|
|
|
|
|
|
tr_priv->probe_id = gst_pad_add_probe (pad,
|
|
|
|
GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
|
2019-06-06 21:21:01 +00:00
|
|
|
(GstPadProbeCallback) _pad_probe_cb, tr_priv, NULL);
|
2013-08-02 12:16:26 +00:00
|
|
|
|
2013-05-29 18:05:52 +00:00
|
|
|
UNLOCK_DYN (tr_priv->timeline);
|
2012-05-18 17:17:17 +00:00
|
|
|
}
|
2012-03-31 17:57:04 +00:00
|
|
|
|
2014-02-18 14:14:40 +00:00
|
|
|
gboolean
|
|
|
|
timeline_add_element (GESTimeline * timeline, GESTimelineElement * element)
|
|
|
|
{
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: handle NULL element->name */
|
2014-05-14 20:06:55 +00:00
|
|
|
GESTimelineElement *same_name =
|
|
|
|
g_hash_table_lookup (timeline->priv->all_elements,
|
|
|
|
element->name);
|
|
|
|
|
2014-02-18 14:14:40 +00:00
|
|
|
GST_DEBUG_OBJECT (timeline, "Adding element: %s", element->name);
|
2014-05-14 20:06:55 +00:00
|
|
|
if (same_name) {
|
|
|
|
GST_ERROR_OBJECT (timeline, "%s Already in the timeline %" GST_PTR_FORMAT,
|
|
|
|
element->name, same_name);
|
2014-02-18 14:14:40 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: why is the hash table using the name of the element, rather than
|
|
|
|
* the pointer to the element itself as the key? This makes it awkward
|
|
|
|
* to change the name of an element after it has been added. See
|
|
|
|
* ges_timeline_element_set_name. It means we have to remove and then
|
|
|
|
* re-add the element. */
|
2014-02-18 14:14:40 +00:00
|
|
|
g_hash_table_insert (timeline->priv->all_elements,
|
|
|
|
ges_timeline_element_get_name (element), gst_object_ref (element));
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
timeline_tree_track_element (timeline->priv->tree, element);
|
|
|
|
|
2014-02-18 14:14:40 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
timeline_remove_element (GESTimeline * timeline, GESTimelineElement * element)
|
|
|
|
{
|
2019-03-01 22:32:19 +00:00
|
|
|
if (g_hash_table_remove (timeline->priv->all_elements, element->name)) {
|
|
|
|
timeline_tree_stop_tracking_element (timeline->priv->tree, element);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2014-02-18 14:14:40 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 15:12:18 +00:00
|
|
|
void
|
|
|
|
timeline_fill_gaps (GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
2019-06-21 14:47:34 +00:00
|
|
|
LOCK_DYN (timeline);
|
2014-09-19 15:12:18 +00:00
|
|
|
for (tmp = timeline->tracks; tmp; tmp = tmp->next) {
|
|
|
|
track_resort_and_fill_gaps (tmp->data);
|
|
|
|
}
|
2019-06-21 14:47:34 +00:00
|
|
|
UNLOCK_DYN (timeline);
|
2014-09-19 15:12:18 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
GNode *
|
|
|
|
timeline_get_tree (GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
return timeline->priv->tree;
|
|
|
|
}
|
|
|
|
|
2012-05-18 17:17:17 +00:00
|
|
|
/**** API *****/
|
2011-06-07 16:54:06 +00:00
|
|
|
/**
|
2012-03-31 17:57:04 +00:00
|
|
|
* ges_timeline_new:
|
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Creates a new empty timeline.
|
2012-03-31 17:57:04 +00:00
|
|
|
*
|
2016-05-14 23:04:17 +00:00
|
|
|
* Returns: (transfer floating): The new timeline.
|
2012-03-31 17:57:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
GESTimeline *
|
|
|
|
ges_timeline_new (void)
|
|
|
|
{
|
2013-11-28 18:13:06 +00:00
|
|
|
GESProject *project = ges_project_new (NULL);
|
|
|
|
GESExtractable *timeline = g_object_new (GES_TYPE_TIMELINE, NULL);
|
|
|
|
|
|
|
|
ges_extractable_set_asset (timeline, GES_ASSET (project));
|
|
|
|
gst_object_unref (project);
|
|
|
|
|
|
|
|
return GES_TIMELINE (timeline);
|
2012-03-31 17:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_new_from_uri:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @uri: The URI to load from
|
|
|
|
* @error: (out) (allow-none): An error to be set if loading fails, or
|
|
|
|
* %NULL to ignore
|
2012-03-31 17:57:04 +00:00
|
|
|
*
|
|
|
|
* Creates a timeline from the given URI.
|
|
|
|
*
|
2017-04-02 21:03:18 +00:00
|
|
|
* Returns: (transfer floating) (nullable): A new timeline if the uri was loaded
|
|
|
|
* successfully, or %NULL if the uri could not be loaded.
|
2012-03-31 17:57:04 +00:00
|
|
|
*/
|
|
|
|
GESTimeline *
|
2012-09-23 00:05:42 +00:00
|
|
|
ges_timeline_new_from_uri (const gchar * uri, GError ** error)
|
2012-03-31 17:57:04 +00:00
|
|
|
{
|
|
|
|
GESTimeline *ret;
|
2012-11-24 03:09:28 +00:00
|
|
|
GESProject *project = ges_project_new (uri);
|
2012-03-31 17:57:04 +00:00
|
|
|
|
2012-11-24 03:09:28 +00:00
|
|
|
ret = GES_TIMELINE (ges_asset_extract (GES_ASSET (project), error));
|
2013-03-30 12:34:36 +00:00
|
|
|
gst_object_unref (project);
|
2012-03-31 17:57:04 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_load_from_uri:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: An empty #GESTimeline into which to load the formatter
|
2012-03-31 17:57:04 +00:00
|
|
|
* @uri: The URI to load from
|
2019-12-18 20:33:45 +00:00
|
|
|
* @error: (out) (allow-none): An error to be set if loading fails, or
|
|
|
|
* %NULL to ignore
|
2012-03-31 17:57:04 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Loads the contents of URI into the timeline.
|
2012-03-31 17:57:04 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: %TRUE if the timeline was loaded successfully from @uri.
|
2012-03-31 17:57:04 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2012-09-23 00:05:42 +00:00
|
|
|
ges_timeline_load_from_uri (GESTimeline * timeline, const gchar * uri,
|
|
|
|
GError ** error)
|
2012-03-31 17:57:04 +00:00
|
|
|
{
|
2012-11-24 03:09:28 +00:00
|
|
|
GESProject *project;
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
|
|
|
|
g_return_val_if_fail ((ges_extractable_get_asset (GES_EXTRACTABLE
|
|
|
|
(timeline)) == NULL), FALSE);
|
|
|
|
|
|
|
|
project = ges_project_new (uri);
|
|
|
|
ret = ges_project_load (project, timeline, error);
|
|
|
|
gst_object_unref (project);
|
|
|
|
|
|
|
|
return ret;
|
2012-03-31 17:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_save_to_uri:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
2012-03-31 17:57:04 +00:00
|
|
|
* @uri: The location to save to
|
2019-12-18 20:33:45 +00:00
|
|
|
* @formatter_asset: (allow-none): The formatter asset to use, or %NULL
|
2012-11-24 03:09:28 +00:00
|
|
|
* @overwrite: %TRUE to overwrite file if it exists
|
2019-12-18 20:33:45 +00:00
|
|
|
* @error: (out) (allow-none): An error to be set if saving fails, or
|
|
|
|
* %NULL to ignore
|
2011-06-07 16:54:06 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Saves the timeline to the given location. If @formatter_asset is %NULL,
|
|
|
|
* the method will attempt to save in the same format the timeline was
|
|
|
|
* loaded from, before defaulting to the formatter with highest rank.
|
2011-06-07 16:54:06 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: %TRUE if @timeline was successfully saved to @uri.
|
2011-06-07 16:54:06 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2012-09-23 00:05:42 +00:00
|
|
|
ges_timeline_save_to_uri (GESTimeline * timeline, const gchar * uri,
|
2012-11-24 03:09:28 +00:00
|
|
|
GESAsset * formatter_asset, gboolean overwrite, GError ** error)
|
2012-03-31 17:57:04 +00:00
|
|
|
{
|
2012-11-24 03:09:28 +00:00
|
|
|
GESProject *project;
|
|
|
|
|
2013-04-22 00:11:52 +00:00
|
|
|
gboolean ret, created_proj = FALSE;
|
|
|
|
|
2012-11-24 03:09:28 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
|
|
|
|
project =
|
|
|
|
GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE (timeline)));
|
|
|
|
|
|
|
|
if (project == NULL) {
|
|
|
|
project = ges_project_new (NULL);
|
|
|
|
created_proj = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ges_project_save (project, timeline, uri, formatter_asset, overwrite,
|
|
|
|
error);
|
|
|
|
|
|
|
|
if (created_proj)
|
|
|
|
gst_object_unref (project);
|
|
|
|
|
|
|
|
return ret;
|
2012-03-31 17:57:04 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 12:27:38 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_get_groups:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
2016-09-06 12:27:38 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Get the list of #GESGroup-s present in the timeline.
|
2016-09-06 12:27:38 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: (transfer none) (element-type GESGroup): The list of
|
|
|
|
* groups that contain clips present in @timeline's layers.
|
2016-09-06 12:27:38 +00:00
|
|
|
* Must not be changed.
|
|
|
|
*/
|
|
|
|
GList *
|
|
|
|
ges_timeline_get_groups (GESTimeline * timeline)
|
|
|
|
{
|
2018-11-02 17:32:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), NULL);
|
|
|
|
CHECK_THREAD (timeline);
|
|
|
|
|
2016-09-06 12:27:38 +00:00
|
|
|
return timeline->priv->groups;
|
|
|
|
}
|
|
|
|
|
2011-06-07 16:54:06 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_append_layer:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
2011-06-07 16:54:06 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Append a newly created layer to the timeline. The layer will
|
|
|
|
* be added at the lowest #GESLayer:priority (numerically, the highest).
|
2011-06-07 16:54:06 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: (transfer none): The newly created layer.
|
2011-06-07 16:54:06 +00:00
|
|
|
*/
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *
|
2012-01-23 02:03:22 +00:00
|
|
|
ges_timeline_append_layer (GESTimeline * timeline)
|
2011-06-07 16:54:06 +00:00
|
|
|
{
|
|
|
|
guint32 priority;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer;
|
2011-06-07 16:54:06 +00:00
|
|
|
|
2018-11-02 17:32:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), NULL);
|
|
|
|
CHECK_THREAD (timeline);
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
layer = ges_layer_new ();
|
2012-11-11 16:51:45 +00:00
|
|
|
priority = g_list_length (timeline->layers);
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: if a timeline contains 2 layers with priority 0 and 2, then
|
|
|
|
* this will set the layer priority of the new layer to 2 as well! */
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_set_priority (layer, priority);
|
2011-06-07 16:54:06 +00:00
|
|
|
|
2012-01-23 02:03:22 +00:00
|
|
|
ges_timeline_add_layer (timeline, layer);
|
|
|
|
|
|
|
|
return layer;
|
2011-06-07 16:54:06 +00:00
|
|
|
}
|
|
|
|
|
2009-09-14 17:24:28 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_add_layer:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @layer: (transfer floating): The layer to add
|
|
|
|
*
|
|
|
|
* Add a layer to the timeline.
|
2009-09-14 17:24:28 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Deprecated: 1.18: This method requires you to ensure the layer's
|
|
|
|
* #GESLayer:priority will be unique to the timeline. Use
|
|
|
|
* ges_timeline_append_layer() and ges_timeline_move_layer() instead.
|
2009-09-14 17:24:28 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: %TRUE if @layer was properly added.
|
2009-09-14 17:24:28 +00:00
|
|
|
*/
|
2009-08-04 15:13:11 +00:00
|
|
|
gboolean
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_timeline_add_layer (GESTimeline * timeline, GESLayer * layer)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2013-04-24 12:18:01 +00:00
|
|
|
gboolean auto_transition;
|
2010-10-19 15:39:43 +00:00
|
|
|
GList *objects, *tmp;
|
|
|
|
|
2018-11-02 17:32:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
|
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), FALSE);
|
|
|
|
CHECK_THREAD (timeline);
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
GST_DEBUG ("timeline:%p, layer:%p", timeline, layer);
|
|
|
|
|
|
|
|
/* We can only add a layer that doesn't already belong to another timeline */
|
|
|
|
if (G_UNLIKELY (layer->timeline)) {
|
|
|
|
GST_WARNING ("Layer belongs to another timeline, can't add it");
|
2017-05-15 07:13:38 +00:00
|
|
|
gst_object_ref_sink (layer);
|
|
|
|
gst_object_unref (layer);
|
2009-08-06 15:38:43 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-08-04 15:13:11 +00:00
|
|
|
|
|
|
|
/* Add to the list of layers, make sure we don't already control it */
|
2012-11-11 16:51:45 +00:00
|
|
|
if (G_UNLIKELY (g_list_find (timeline->layers, (gconstpointer) layer))) {
|
2009-08-06 15:38:43 +00:00
|
|
|
GST_WARNING ("Layer is already controlled by this timeline");
|
2017-05-15 07:13:38 +00:00
|
|
|
gst_object_ref_sink (layer);
|
|
|
|
gst_object_unref (layer);
|
2009-08-06 15:38:43 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: ensure the layer->priority does not conflict with an existing
|
|
|
|
* layer in the timeline. Currently can add several layers with equal
|
|
|
|
* layer priorities */
|
|
|
|
|
2013-04-24 12:18:01 +00:00
|
|
|
auto_transition = ges_layer_get_auto_transition (layer);
|
|
|
|
|
|
|
|
/* If the user doesn't explicitely set layer auto_transition, then set our */
|
|
|
|
if (!auto_transition) {
|
|
|
|
auto_transition = ges_timeline_get_auto_transition (timeline);
|
|
|
|
ges_layer_set_auto_transition (layer, auto_transition);
|
|
|
|
}
|
|
|
|
|
2013-03-18 12:49:18 +00:00
|
|
|
gst_object_ref_sink (layer);
|
2012-11-11 16:51:45 +00:00
|
|
|
timeline->layers = g_list_insert_sorted (timeline->layers, layer,
|
2011-06-03 02:03:19 +00:00
|
|
|
(GCompareFunc) sort_layers);
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
/* Inform the layer that it belongs to a new timeline */
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_set_timeline (layer, timeline);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2013-02-08 20:19:39 +00:00
|
|
|
/* Connect to 'clip-added'/'clip-removed' signal from the new layer */
|
2014-10-29 12:25:06 +00:00
|
|
|
g_signal_connect_after (layer, "clip-added",
|
|
|
|
G_CALLBACK (layer_object_added_cb), timeline);
|
|
|
|
g_signal_connect_after (layer, "clip-removed",
|
2009-08-06 15:38:43 +00:00
|
|
|
G_CALLBACK (layer_object_removed_cb), timeline);
|
2011-06-03 02:03:19 +00:00
|
|
|
g_signal_connect (layer, "notify::priority",
|
|
|
|
G_CALLBACK (layer_priority_changed_cb), timeline);
|
2013-01-10 21:50:54 +00:00
|
|
|
g_signal_connect (layer, "notify::auto-transition",
|
|
|
|
G_CALLBACK (layer_auto_transition_changed_cb), timeline);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Done adding layer, emitting 'layer-added' signal");
|
|
|
|
g_signal_emit (timeline, ges_timeline_signals[LAYER_ADDED], 0, layer);
|
|
|
|
|
2013-02-08 20:11:22 +00:00
|
|
|
/* add any existing clips to the timeline */
|
2013-04-23 23:04:04 +00:00
|
|
|
objects = ges_layer_get_clips (layer);
|
2010-10-19 15:39:43 +00:00
|
|
|
for (tmp = objects; tmp; tmp = tmp->next) {
|
|
|
|
layer_object_added_cb (layer, tmp->data, timeline);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp->data);
|
2010-10-19 15:39:43 +00:00
|
|
|
tmp->data = NULL;
|
|
|
|
}
|
|
|
|
g_list_free (objects);
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
return TRUE;
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_remove_layer:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @layer: The layer to remove
|
2009-09-16 10:37:45 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Removes a layer from the timeline.
|
2009-09-16 10:37:45 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: %TRUE if @layer was properly removed.
|
2009-09-16 10:37:45 +00:00
|
|
|
*/
|
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
gboolean
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_timeline_remove_layer (GESTimeline * timeline, GESLayer * layer)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2010-10-07 11:29:05 +00:00
|
|
|
GList *layer_objects, *tmp;
|
|
|
|
|
2018-11-02 17:32:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
|
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), FALSE);
|
|
|
|
CHECK_THREAD (timeline);
|
|
|
|
|
2009-08-07 14:41:23 +00:00
|
|
|
GST_DEBUG ("timeline:%p, layer:%p", timeline, layer);
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2012-11-11 16:51:45 +00:00
|
|
|
if (G_UNLIKELY (!g_list_find (timeline->layers, layer))) {
|
2009-08-07 14:41:23 +00:00
|
|
|
GST_WARNING ("Layer doesn't belong to this timeline");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-10-07 11:29:05 +00:00
|
|
|
/* remove objects from any private data structures */
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
layer_objects = ges_layer_get_clips (layer);
|
2010-10-07 11:29:05 +00:00
|
|
|
for (tmp = layer_objects; tmp; tmp = tmp->next) {
|
2013-01-20 15:42:29 +00:00
|
|
|
layer_object_removed_cb (layer, GES_CLIP (tmp->data), timeline);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (G_OBJECT (tmp->data));
|
2010-10-07 11:29:05 +00:00
|
|
|
tmp->data = NULL;
|
|
|
|
}
|
|
|
|
g_list_free (layer_objects);
|
|
|
|
|
2009-08-07 14:41:23 +00:00
|
|
|
/* Disconnect signals */
|
|
|
|
GST_DEBUG ("Disconnecting signal callbacks");
|
|
|
|
g_signal_handlers_disconnect_by_func (layer, layer_object_added_cb, timeline);
|
|
|
|
g_signal_handlers_disconnect_by_func (layer, layer_object_removed_cb,
|
|
|
|
timeline);
|
2013-01-10 21:50:54 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (layer, layer_priority_changed_cb,
|
|
|
|
timeline);
|
|
|
|
g_signal_handlers_disconnect_by_func (layer,
|
|
|
|
layer_auto_transition_changed_cb, timeline);
|
2009-08-07 14:41:23 +00:00
|
|
|
|
2012-11-11 16:51:45 +00:00
|
|
|
timeline->layers = g_list_remove (timeline->layers, layer);
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_set_timeline (layer, NULL);
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: we should resync the layer priorities */
|
2009-08-07 14:41:23 +00:00
|
|
|
|
|
|
|
g_signal_emit (timeline, ges_timeline_signals[LAYER_REMOVED], 0, layer);
|
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (layer);
|
2009-08-07 14:41:23 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
2009-09-14 17:24:28 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_add_track:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @track: (transfer full): The track to add
|
2009-09-14 17:24:28 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Add a track to the timeline. Existing #GESClip-s in the timeline will,
|
|
|
|
* where appropriate, add their controlled elements to the new track.
|
2009-09-14 17:24:28 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: %TRUE if @track was properly added.
|
2009-09-14 17:24:28 +00:00
|
|
|
*/
|
|
|
|
|
2013-02-08 20:11:22 +00:00
|
|
|
/* FIXME: create track elements for clips which have already been
|
2010-10-19 12:35:58 +00:00
|
|
|
* added to existing layers.
|
|
|
|
*/
|
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
gboolean
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_add_track (GESTimeline * timeline, GESTrack * track)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2011-01-08 10:22:36 +00:00
|
|
|
TrackPrivate *tr_priv;
|
2010-10-20 17:00:24 +00:00
|
|
|
GList *tmp;
|
2009-09-08 17:44:03 +00:00
|
|
|
|
2018-11-02 17:32:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
|
|
|
|
g_return_val_if_fail (GES_IS_TRACK (track), FALSE);
|
|
|
|
CHECK_THREAD (timeline);
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
GST_DEBUG ("timeline:%p, track:%p", timeline, track);
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2009-08-07 14:41:23 +00:00
|
|
|
/* make sure we don't already control it */
|
2019-06-21 14:47:34 +00:00
|
|
|
LOCK_DYN (timeline);
|
2012-12-20 14:28:39 +00:00
|
|
|
if (G_UNLIKELY (g_list_find (timeline->tracks, (gconstpointer) track))) {
|
2019-06-21 14:47:34 +00:00
|
|
|
UNLOCK_DYN (timeline);
|
2009-08-06 15:38:43 +00:00
|
|
|
GST_WARNING ("Track is already controlled by this timeline");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2011-01-08 10:22:36 +00:00
|
|
|
/* Add the track to ourself (as a GstBin)
|
2009-09-14 17:24:28 +00:00
|
|
|
* Reference is stolen ! */
|
2009-08-06 15:38:43 +00:00
|
|
|
if (G_UNLIKELY (!gst_bin_add (GST_BIN (timeline), GST_ELEMENT (track)))) {
|
2019-06-21 14:47:34 +00:00
|
|
|
UNLOCK_DYN (timeline);
|
2009-08-06 15:38:43 +00:00
|
|
|
GST_WARNING ("Couldn't add track to ourself (GST)");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2011-01-08 10:22:36 +00:00
|
|
|
tr_priv = g_new0 (TrackPrivate, 1);
|
|
|
|
tr_priv->timeline = timeline;
|
|
|
|
tr_priv->track = track;
|
2009-09-08 17:44:03 +00:00
|
|
|
|
2019-06-07 03:19:38 +00:00
|
|
|
update_stream_object (tr_priv);
|
|
|
|
gst_stream_collection_add_stream (timeline->priv->stream_collection,
|
|
|
|
gst_object_ref (tr_priv->stream));
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
/* Add the track to the list of tracks we track */
|
2012-12-20 14:28:39 +00:00
|
|
|
timeline->priv->priv_tracks = g_list_append (timeline->priv->priv_tracks,
|
|
|
|
tr_priv);
|
|
|
|
timeline->tracks = g_list_append (timeline->tracks, track);
|
2009-09-08 17:44:03 +00:00
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
/* Inform the track that it's currently being used by ourself */
|
|
|
|
ges_track_set_timeline (track, timeline);
|
|
|
|
|
|
|
|
GST_DEBUG ("Done adding track, emitting 'track-added' signal");
|
|
|
|
|
2014-10-28 17:36:55 +00:00
|
|
|
_ghost_track_srcpad (tr_priv);
|
2019-06-21 14:47:34 +00:00
|
|
|
UNLOCK_DYN (timeline);
|
2014-10-28 17:36:55 +00:00
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
/* emit 'track-added' */
|
|
|
|
g_signal_emit (timeline, ges_timeline_signals[TRACK_ADDED], 0, track);
|
|
|
|
|
2013-02-08 20:11:22 +00:00
|
|
|
/* ensure that each existing clip has the opportunity to create a
|
2013-02-08 19:39:18 +00:00
|
|
|
* track element for this track*/
|
2010-10-20 17:00:24 +00:00
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
/* We connect to the object for the timeline editing mode management */
|
2013-02-08 19:39:18 +00:00
|
|
|
g_signal_connect (G_OBJECT (track), "track-element-added",
|
2013-01-26 15:31:33 +00:00
|
|
|
G_CALLBACK (track_element_added_cb), timeline);
|
2013-02-08 19:39:18 +00:00
|
|
|
g_signal_connect (G_OBJECT (track), "track-element-removed",
|
2013-01-26 15:31:33 +00:00
|
|
|
G_CALLBACK (track_element_removed_cb), timeline);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2012-11-11 16:51:45 +00:00
|
|
|
for (tmp = timeline->layers; tmp; tmp = tmp->next) {
|
2010-10-20 17:00:24 +00:00
|
|
|
GList *objects, *obj;
|
2013-04-23 23:04:04 +00:00
|
|
|
objects = ges_layer_get_clips (tmp->data);
|
2010-10-20 17:00:24 +00:00
|
|
|
|
|
|
|
for (obj = objects; obj; obj = obj->next) {
|
2013-02-15 02:34:48 +00:00
|
|
|
GESClip *clip = obj->data;
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
add_object_to_tracks (timeline, clip, track);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (clip);
|
2010-10-20 17:00:24 +00:00
|
|
|
}
|
|
|
|
g_list_free (objects);
|
|
|
|
}
|
|
|
|
|
2013-04-09 03:02:14 +00:00
|
|
|
/* FIXME Check if we should rollback if we can't sync state */
|
|
|
|
gst_element_sync_state_with_parent (GST_ELEMENT (track));
|
2014-07-25 12:47:07 +00:00
|
|
|
g_object_set (track, "message-forward", TRUE, NULL);
|
2013-04-09 03:02:14 +00:00
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
return TRUE;
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
2009-08-04 15:16:31 +00:00
|
|
|
|
2009-09-14 17:24:28 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_remove_track:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @track: The track to remove
|
2009-09-14 17:24:28 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Remove a track from the timeline.
|
2009-09-14 17:24:28 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: %TRUE if @track was properly removed.
|
2009-09-14 17:24:28 +00:00
|
|
|
*/
|
2010-10-19 12:35:58 +00:00
|
|
|
|
2013-02-08 19:39:18 +00:00
|
|
|
/* FIXME: release any track elements associated with this layer. currenly this
|
2010-10-19 12:35:58 +00:00
|
|
|
* will not happen if you remove the track before removing *all*
|
2013-02-08 19:39:18 +00:00
|
|
|
* clips which have a track element in this track.
|
2010-10-19 12:35:58 +00:00
|
|
|
*/
|
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
gboolean
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_remove_track (GESTimeline * timeline, GESTrack * track)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2009-09-08 17:44:03 +00:00
|
|
|
GList *tmp;
|
2011-01-08 10:22:36 +00:00
|
|
|
TrackPrivate *tr_priv;
|
2012-12-20 14:28:39 +00:00
|
|
|
GESTimelinePrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_TRACK (track), FALSE);
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
|
2009-09-08 17:44:03 +00:00
|
|
|
|
2009-08-07 14:41:23 +00:00
|
|
|
GST_DEBUG ("timeline:%p, track:%p", timeline, track);
|
|
|
|
|
2012-12-20 14:28:39 +00:00
|
|
|
priv = timeline->priv;
|
2013-05-29 18:05:52 +00:00
|
|
|
LOCK_DYN (timeline);
|
2012-12-20 14:28:39 +00:00
|
|
|
if (G_UNLIKELY (!(tmp = g_list_find_custom (priv->priv_tracks,
|
|
|
|
track, (GCompareFunc) custom_find_track)))) {
|
2009-08-07 14:41:23 +00:00
|
|
|
GST_WARNING ("Track doesn't belong to this timeline");
|
2013-05-29 18:05:52 +00:00
|
|
|
UNLOCK_DYN (timeline);
|
2009-08-07 14:41:23 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-01-08 10:22:36 +00:00
|
|
|
tr_priv = tmp->data;
|
2015-09-11 07:11:40 +00:00
|
|
|
gst_object_unref (tr_priv->pad);
|
2012-12-20 14:28:39 +00:00
|
|
|
priv->priv_tracks = g_list_remove (priv->priv_tracks, tr_priv);
|
2013-05-29 18:05:52 +00:00
|
|
|
UNLOCK_DYN (timeline);
|
2012-12-20 14:28:39 +00:00
|
|
|
timeline->tracks = g_list_remove (timeline->tracks, track);
|
2009-08-07 14:41:23 +00:00
|
|
|
|
|
|
|
ges_track_set_timeline (track, NULL);
|
|
|
|
|
2009-09-08 17:44:03 +00:00
|
|
|
/* Remove ghost pad */
|
2011-01-08 10:22:36 +00:00
|
|
|
if (tr_priv->ghostpad) {
|
2009-09-08 17:44:03 +00:00
|
|
|
GST_DEBUG ("Removing ghostpad");
|
2011-01-08 10:22:36 +00:00
|
|
|
gst_pad_set_active (tr_priv->ghostpad, FALSE);
|
|
|
|
gst_ghost_pad_set_target ((GstGhostPad *) tr_priv->ghostpad, NULL);
|
|
|
|
gst_element_remove_pad (GST_ELEMENT (timeline), tr_priv->ghostpad);
|
2009-09-08 17:44:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove pad-added/-removed handlers */
|
2013-01-26 15:31:33 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (track, track_element_added_cb,
|
|
|
|
timeline);
|
|
|
|
g_signal_handlers_disconnect_by_func (track, track_element_removed_cb,
|
2012-04-24 00:52:45 +00:00
|
|
|
timeline);
|
2009-09-08 17:44:03 +00:00
|
|
|
|
|
|
|
/* Signal track removal to all layers/objects */
|
|
|
|
g_signal_emit (timeline, ges_timeline_signals[TRACK_REMOVED], 0, track);
|
|
|
|
|
2009-08-07 14:41:23 +00:00
|
|
|
/* remove track from our bin */
|
2010-10-22 14:58:22 +00:00
|
|
|
gst_object_ref (track);
|
2009-08-07 14:41:23 +00:00
|
|
|
if (G_UNLIKELY (!gst_bin_remove (GST_BIN (timeline), GST_ELEMENT (track)))) {
|
|
|
|
GST_WARNING ("Couldn't remove track to ourself (GST)");
|
2010-10-22 14:58:22 +00:00
|
|
|
gst_object_unref (track);
|
2009-08-07 14:41:23 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2010-10-22 14:58:22 +00:00
|
|
|
/* set track state to NULL */
|
|
|
|
gst_element_set_state (GST_ELEMENT (track), GST_STATE_NULL);
|
|
|
|
|
|
|
|
gst_object_unref (track);
|
|
|
|
|
2011-01-08 10:22:36 +00:00
|
|
|
g_free (tr_priv);
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2009-08-07 14:41:23 +00:00
|
|
|
return TRUE;
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
2009-09-08 17:44:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_get_track_for_pad:
|
|
|
|
* @timeline: The #GESTimeline
|
2019-12-18 20:33:45 +00:00
|
|
|
* @pad: A pad
|
2009-09-08 17:44:03 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Search for the #GESTrack corresponding to the given timeline's pad.
|
2009-09-08 17:44:03 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: (transfer none) (nullable): The track corresponding to @pad,
|
|
|
|
* or %NULL if there is an error.
|
2009-09-08 17:44:03 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
GESTrack *
|
|
|
|
ges_timeline_get_track_for_pad (GESTimeline * timeline, GstPad * pad)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
2018-11-02 17:32:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), NULL);
|
|
|
|
|
2013-05-29 18:05:52 +00:00
|
|
|
LOCK_DYN (timeline);
|
2012-12-20 14:28:39 +00:00
|
|
|
for (tmp = timeline->priv->priv_tracks; tmp; tmp = g_list_next (tmp)) {
|
2011-01-08 10:22:36 +00:00
|
|
|
TrackPrivate *tr_priv = (TrackPrivate *) tmp->data;
|
2013-05-29 18:05:52 +00:00
|
|
|
if (pad == tr_priv->ghostpad) {
|
|
|
|
UNLOCK_DYN (timeline);
|
2011-01-08 10:22:36 +00:00
|
|
|
return tr_priv->track;
|
2013-05-29 18:05:52 +00:00
|
|
|
}
|
2009-09-08 17:44:03 +00:00
|
|
|
}
|
2013-05-29 18:05:52 +00:00
|
|
|
UNLOCK_DYN (timeline);
|
2009-09-08 17:44:03 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-04-20 09:48:21 +00:00
|
|
|
|
2014-08-13 11:15:02 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_get_pad_for_track:
|
|
|
|
* @timeline: The #GESTimeline
|
2019-12-18 20:33:45 +00:00
|
|
|
* @track: A track
|
2014-08-13 11:15:02 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Search for the #GstPad corresponding to the given timeline's track.
|
|
|
|
* You can link to this pad to receive the output data of the given track.
|
2014-08-13 11:15:02 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: (transfer none) (nullable): The pad corresponding to @track,
|
|
|
|
* or %NULL if there is an error.
|
2014-08-13 11:15:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
GstPad *
|
|
|
|
ges_timeline_get_pad_for_track (GESTimeline * timeline, GESTrack * track)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
|
|
|
LOCK_DYN (timeline);
|
|
|
|
for (tmp = timeline->priv->priv_tracks; tmp; tmp = g_list_next (tmp)) {
|
|
|
|
TrackPrivate *tr_priv = (TrackPrivate *) tmp->data;
|
|
|
|
|
|
|
|
if (track == tr_priv->track) {
|
|
|
|
if (tr_priv->ghostpad)
|
|
|
|
gst_object_ref (tr_priv->ghostpad);
|
|
|
|
|
|
|
|
UNLOCK_DYN (timeline);
|
|
|
|
return tr_priv->ghostpad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UNLOCK_DYN (timeline);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-04-20 09:48:21 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_get_tracks:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
2010-04-20 09:48:21 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Get the list of #GESTrack-s used by the timeline.
|
2010-04-20 09:48:21 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: (transfer full) (element-type GESTrack): The list of tracks
|
|
|
|
* used by @timeline.
|
2010-12-08 14:36:55 +00:00
|
|
|
*/
|
2010-04-20 09:48:21 +00:00
|
|
|
GList *
|
|
|
|
ges_timeline_get_tracks (GESTimeline * timeline)
|
|
|
|
{
|
2019-06-21 14:47:34 +00:00
|
|
|
GList *res = NULL;
|
2012-12-20 14:28:39 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), NULL);
|
2011-01-08 10:22:36 +00:00
|
|
|
|
2019-06-21 14:47:34 +00:00
|
|
|
LOCK_DYN (timeline);
|
|
|
|
res = g_list_copy_deep (timeline->tracks, (GCopyFunc) gst_object_ref, NULL);
|
|
|
|
UNLOCK_DYN (timeline);
|
|
|
|
|
|
|
|
return res;
|
2011-01-08 10:22:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_get_layers:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
2011-01-08 10:22:36 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Get the list of #GESLayer-s present in the timeline.
|
2011-01-10 13:28:35 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: (transfer full) (element-type GESLayer): The list of
|
|
|
|
* layers present in @timeline sorted by priority.
|
2011-01-08 10:22:36 +00:00
|
|
|
*/
|
|
|
|
GList *
|
|
|
|
ges_timeline_get_layers (GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
GList *tmp, *res = NULL;
|
|
|
|
|
2018-11-02 17:32:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), NULL);
|
|
|
|
CHECK_THREAD (timeline);
|
|
|
|
|
2012-11-11 16:51:45 +00:00
|
|
|
for (tmp = timeline->layers; tmp; tmp = g_list_next (tmp)) {
|
2013-03-16 22:05:04 +00:00
|
|
|
res = g_list_insert_sorted (res, gst_object_ref (tmp->data),
|
2011-06-03 02:03:19 +00:00
|
|
|
(GCompareFunc) sort_layers);
|
2010-04-20 09:48:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2011-08-03 00:33:10 +00:00
|
|
|
|
2015-04-08 19:38:48 +00:00
|
|
|
static void
|
|
|
|
track_commited_cb (GESTrack * track, GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
gboolean emit_commited = FALSE;
|
|
|
|
GST_OBJECT_LOCK (timeline);
|
|
|
|
timeline->priv->expected_commited -= 1;
|
|
|
|
if (timeline->priv->expected_commited == 0)
|
|
|
|
emit_commited = TRUE;
|
|
|
|
g_signal_handlers_disconnect_by_func (track, track_commited_cb, timeline);
|
|
|
|
GST_OBJECT_UNLOCK (timeline);
|
|
|
|
|
|
|
|
if (emit_commited) {
|
|
|
|
g_signal_emit (timeline, ges_timeline_signals[COMMITED], 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Must be called with the timeline's DYN_LOCK */
|
|
|
|
static gboolean
|
|
|
|
ges_timeline_commit_unlocked (GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
gboolean res = TRUE;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (timeline, "commiting changes");
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
timeline_tree_create_transitions (timeline->priv->tree,
|
|
|
|
ges_timeline_find_auto_transition);
|
2015-04-08 19:38:48 +00:00
|
|
|
for (tmp = timeline->layers; tmp; tmp = tmp->next) {
|
2016-08-11 13:42:32 +00:00
|
|
|
GESLayer *layer = tmp->data;
|
|
|
|
|
|
|
|
/* Ensure clip priorities are correct after an edit */
|
|
|
|
ges_layer_resync_priorities (layer);
|
2015-04-08 19:38:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
timeline->priv->expected_commited =
|
|
|
|
g_list_length (timeline->priv->priv_tracks);
|
|
|
|
|
|
|
|
if (timeline->priv->expected_commited == 0) {
|
|
|
|
g_signal_emit (timeline, ges_timeline_signals[COMMITED], 0);
|
|
|
|
} else {
|
2019-06-07 03:19:38 +00:00
|
|
|
GstStreamCollection *collection = gst_stream_collection_new (NULL);
|
|
|
|
|
2019-06-21 14:47:34 +00:00
|
|
|
LOCK_DYN (timeline);
|
2015-04-08 19:38:48 +00:00
|
|
|
for (tmp = timeline->tracks; tmp; tmp = tmp->next) {
|
2019-06-07 03:19:38 +00:00
|
|
|
TrackPrivate *tr_priv =
|
|
|
|
g_list_find_custom (timeline->priv->priv_tracks, tmp->data,
|
|
|
|
(GCompareFunc) custom_find_track)->data;
|
|
|
|
|
|
|
|
update_stream_object (tr_priv);
|
|
|
|
gst_stream_collection_add_stream (collection,
|
|
|
|
gst_object_ref (tr_priv->stream));
|
2015-04-08 19:38:48 +00:00
|
|
|
g_signal_connect (tmp->data, "commited", G_CALLBACK (track_commited_cb),
|
|
|
|
timeline);
|
|
|
|
if (!ges_track_commit (GES_TRACK (tmp->data)))
|
|
|
|
res = FALSE;
|
|
|
|
}
|
2019-06-07 03:19:38 +00:00
|
|
|
|
|
|
|
gst_object_unref (timeline->priv->stream_collection);
|
|
|
|
timeline->priv->stream_collection = collection;
|
2019-06-21 14:47:34 +00:00
|
|
|
UNLOCK_DYN (timeline);
|
2015-04-08 19:38:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-01-23 01:50:24 +00:00
|
|
|
/**
|
2013-06-09 16:29:05 +00:00
|
|
|
* ges_timeline_commit:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: A #GESTimeline
|
2012-01-23 01:50:24 +00:00
|
|
|
*
|
2015-04-08 19:38:48 +00:00
|
|
|
* Commit all the pending changes of the clips contained in the
|
2019-12-18 20:33:45 +00:00
|
|
|
* timeline.
|
2015-04-08 19:38:48 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* When changes happen in a timeline, they are not immediately executed
|
|
|
|
* internally, in a way that effects the output data of the timeline. You
|
|
|
|
* should call this method when you are done with a set of changes and you
|
|
|
|
* want them to be executed.
|
2011-08-03 00:33:10 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Any pending changes will be executed in the backend. The
|
|
|
|
* #GESTimeline::commited signal will be emitted once this has completed.
|
2015-04-08 19:38:48 +00:00
|
|
|
* You should not try to change the state of the timeline, seek it or add
|
2019-12-18 20:33:45 +00:00
|
|
|
* tracks to it before receiving this signal. You can use
|
|
|
|
* ges_timeline_commit_sync() if you do not want to perform other tasks in
|
|
|
|
* the mean time.
|
2015-04-08 19:38:48 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Note that all the pending changes will automatically be executed when
|
|
|
|
* the timeline goes from #GST_STATE_READY to #GST_STATE_PAUSED, which is
|
|
|
|
* usually triggered by a corresponding state changes in a containing
|
|
|
|
* #GESPipeline.
|
2015-04-08 19:38:48 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: %TRUE if pending changes were committed, or %FALSE if nothing
|
|
|
|
* needed to be committed.
|
2011-08-03 00:33:10 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2013-06-09 16:29:05 +00:00
|
|
|
ges_timeline_commit (GESTimeline * timeline)
|
2011-08-03 00:33:10 +00:00
|
|
|
{
|
2015-04-08 19:38:48 +00:00
|
|
|
gboolean ret;
|
2019-06-07 03:19:38 +00:00
|
|
|
GstStreamCollection *pcollection = timeline->priv->stream_collection;
|
2011-12-16 08:54:58 +00:00
|
|
|
|
2018-11-02 17:32:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
|
|
|
|
|
2015-04-08 19:38:48 +00:00
|
|
|
LOCK_DYN (timeline);
|
|
|
|
ret = ges_timeline_commit_unlocked (timeline);
|
|
|
|
UNLOCK_DYN (timeline);
|
2016-07-24 12:32:06 +00:00
|
|
|
|
2019-06-07 03:19:38 +00:00
|
|
|
if (pcollection != timeline->priv->stream_collection) {
|
|
|
|
gst_element_post_message ((GstElement *) timeline,
|
|
|
|
gst_message_new_stream_collection ((GstObject *) timeline,
|
|
|
|
timeline->priv->stream_collection));
|
|
|
|
}
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
ges_timeline_emit_snapping (timeline, NULL, NULL, GST_CLOCK_TIME_NONE);
|
2015-04-08 19:38:48 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2013-01-10 15:24:20 +00:00
|
|
|
|
2015-04-08 19:38:48 +00:00
|
|
|
static void
|
|
|
|
commited_cb (GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
g_mutex_lock (&timeline->priv->commited_lock);
|
|
|
|
g_cond_signal (&timeline->priv->commited_cond);
|
|
|
|
g_mutex_unlock (&timeline->priv->commited_lock);
|
|
|
|
}
|
2013-06-28 22:17:31 +00:00
|
|
|
|
2015-04-08 19:38:48 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_commit_sync:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: A #GESTimeline
|
2015-04-08 19:38:48 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Commit all the pending changes of the clips contained in the
|
|
|
|
* timeline and wait for the changes to complete.
|
2015-04-08 19:38:48 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* See ges_timeline_commit().
|
2015-04-08 19:38:48 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: %TRUE if pending changes were committed, or %FALSE if nothing
|
|
|
|
* needed to be committed.
|
2015-04-08 19:38:48 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_timeline_commit_sync (GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
gboolean ret;
|
|
|
|
gboolean wait_for_signal;
|
2010-04-20 09:48:21 +00:00
|
|
|
|
2018-11-02 17:32:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
|
|
|
|
|
2015-04-08 19:38:48 +00:00
|
|
|
/* Let's make sure our state is stable */
|
|
|
|
gst_element_get_state (GST_ELEMENT (timeline), NULL, NULL,
|
|
|
|
GST_CLOCK_TIME_NONE);
|
2013-01-10 21:50:54 +00:00
|
|
|
|
2015-04-08 19:38:48 +00:00
|
|
|
/* Let's make sure no track gets added between now and the actual commiting */
|
|
|
|
LOCK_DYN (timeline);
|
|
|
|
wait_for_signal = g_list_length (timeline->priv->priv_tracks) > 0
|
|
|
|
&& GST_STATE (timeline) >= GST_STATE_PAUSED;
|
2013-09-28 13:42:20 +00:00
|
|
|
|
2015-04-08 19:38:48 +00:00
|
|
|
if (!wait_for_signal) {
|
|
|
|
ret = ges_timeline_commit_unlocked (timeline);
|
|
|
|
} else {
|
|
|
|
gulong handler_id =
|
|
|
|
g_signal_connect (timeline, "commited", (GCallback) commited_cb, NULL);
|
|
|
|
|
|
|
|
g_mutex_lock (&timeline->priv->commited_lock);
|
|
|
|
|
|
|
|
ret = ges_timeline_commit_unlocked (timeline);
|
|
|
|
g_cond_wait (&timeline->priv->commited_cond,
|
|
|
|
&timeline->priv->commited_lock);
|
|
|
|
g_mutex_unlock (&timeline->priv->commited_lock);
|
|
|
|
g_signal_handler_disconnect (timeline, handler_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
UNLOCK_DYN (timeline);
|
|
|
|
|
|
|
|
return ret;
|
2011-08-03 00:33:10 +00:00
|
|
|
}
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2012-05-18 00:49:01 +00:00
|
|
|
/**
|
2012-08-10 16:39:10 +00:00
|
|
|
* ges_timeline_get_duration:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
2012-05-18 00:49:01 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Get the current #GESTimeline:duration of the timeline
|
2012-05-18 00:49:01 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: The current duration of @timeline.
|
2012-05-18 00:49:01 +00:00
|
|
|
*/
|
|
|
|
GstClockTime
|
|
|
|
ges_timeline_get_duration (GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), GST_CLOCK_TIME_NONE);
|
2018-11-02 17:32:04 +00:00
|
|
|
CHECK_THREAD (timeline);
|
2012-05-18 00:49:01 +00:00
|
|
|
|
|
|
|
return timeline->priv->duration;
|
2010-04-20 09:48:21 +00:00
|
|
|
}
|
2013-04-24 12:18:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_get_auto_transition:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
2013-04-24 12:18:01 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Gets #GESTimeline:auto-transition for the timeline.
|
2013-04-24 12:18:01 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: The auto-transition of @self.
|
2013-04-24 12:18:01 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_timeline_get_auto_transition (GESTimeline * timeline)
|
|
|
|
{
|
2018-11-02 17:32:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
|
|
|
|
CHECK_THREAD (timeline);
|
2013-04-24 12:18:01 +00:00
|
|
|
|
|
|
|
return timeline->priv->auto_transition;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_set_auto_transition:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @auto_transition: Whether transitions should be automatically added
|
|
|
|
* to @timeline's layers
|
2013-04-24 12:18:01 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Sets #GESTimeline:auto-transition for the timeline. This will also set
|
|
|
|
* the corresponding #GESLayer:auto-transition for all of the timeline's
|
|
|
|
* layers to the same value. See ges_layer_set_auto_transition() if you
|
|
|
|
* wish to set the layer's #GESLayer:auto-transition individually.
|
2013-04-24 12:18:01 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ges_timeline_set_auto_transition (GESTimeline * timeline,
|
|
|
|
gboolean auto_transition)
|
|
|
|
{
|
|
|
|
GList *layers;
|
|
|
|
GESLayer *layer;
|
|
|
|
|
|
|
|
g_return_if_fail (GES_IS_TIMELINE (timeline));
|
2018-11-02 17:32:04 +00:00
|
|
|
CHECK_THREAD (timeline);
|
2013-04-24 12:18:01 +00:00
|
|
|
|
|
|
|
timeline->priv->auto_transition = auto_transition;
|
|
|
|
g_object_notify (G_OBJECT (timeline), "auto-transition");
|
|
|
|
|
|
|
|
layers = timeline->layers;
|
|
|
|
for (; layers; layers = layers->next) {
|
|
|
|
layer = layers->data;
|
|
|
|
ges_layer_set_auto_transition (layer, auto_transition);
|
|
|
|
}
|
|
|
|
}
|
2013-07-25 02:37:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_get_snapping_distance:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
2013-07-25 02:37:06 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Gets the #GESTimeline:snapping-distance for the timeline.
|
2013-07-25 02:37:06 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: The snapping distance (in nanoseconds) of @timeline.
|
2013-07-25 02:37:06 +00:00
|
|
|
*/
|
|
|
|
GstClockTime
|
|
|
|
ges_timeline_get_snapping_distance (GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), GST_CLOCK_TIME_NONE);
|
2018-11-02 17:32:04 +00:00
|
|
|
CHECK_THREAD (timeline);
|
2013-07-25 02:37:06 +00:00
|
|
|
|
|
|
|
return timeline->priv->snapping_distance;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_set_snapping_distance:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @snapping_distance: The snapping distance to use (in nanoseconds)
|
2013-07-25 02:37:06 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Sets #GESTimeline:snapping-distance for the timeline. This new value
|
|
|
|
* will only effect future snappings and will not be used to snap the
|
|
|
|
* current element positions within the timeline.
|
2013-07-25 02:37:06 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ges_timeline_set_snapping_distance (GESTimeline * timeline,
|
|
|
|
GstClockTime snapping_distance)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GES_IS_TIMELINE (timeline));
|
2018-11-02 17:32:04 +00:00
|
|
|
CHECK_THREAD (timeline);
|
2013-07-25 02:37:06 +00:00
|
|
|
|
|
|
|
timeline->priv->snapping_distance = snapping_distance;
|
|
|
|
}
|
2014-02-18 14:14:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_get_element:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
|
|
|
* @name: The name of the element to find
|
2014-02-18 14:14:40 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Gets the element contained in the timeline with the given name.
|
2014-02-18 14:14:40 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: (transfer full) (nullable): The timeline element in @timeline
|
|
|
|
* with the given @name, or %NULL if it was not found.
|
2014-02-18 14:14:40 +00:00
|
|
|
*/
|
|
|
|
GESTimelineElement *
|
|
|
|
ges_timeline_get_element (GESTimeline * timeline, const gchar * name)
|
|
|
|
{
|
|
|
|
GESTimelineElement *ret;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), NULL);
|
2018-11-02 17:32:04 +00:00
|
|
|
CHECK_THREAD (timeline);
|
2014-02-18 14:14:40 +00:00
|
|
|
|
2019-12-18 20:33:45 +00:00
|
|
|
/* FIXME: handle NULL name */
|
2014-02-18 14:14:40 +00:00
|
|
|
ret = g_hash_table_lookup (timeline->priv->all_elements, name);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return gst_object_ref (ret);
|
|
|
|
|
2015-04-20 15:42:44 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
|
|
|
{
|
|
|
|
GList *element_names, *tmp;
|
|
|
|
element_names = g_hash_table_get_keys (timeline->priv->all_elements);
|
|
|
|
|
|
|
|
GST_INFO_OBJECT (timeline, "Does not contain element %s", name);
|
|
|
|
|
|
|
|
for (tmp = element_names; tmp; tmp = tmp->next) {
|
|
|
|
GST_DEBUG_OBJECT (timeline, "Containes: %s", (gchar *) tmp->data);
|
|
|
|
}
|
|
|
|
g_list_free (element_names);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-02-18 14:14:40 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2014-11-30 23:38:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_is_empty:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline
|
2014-11-30 23:38:07 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Check whether the timeline is empty or not.
|
2014-11-30 23:38:07 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: %TRUE if @timeline is empty.
|
2014-11-30 23:38:07 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_timeline_is_empty (GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
GHashTableIter iter;
|
|
|
|
gpointer key, value;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
|
2018-11-02 17:32:04 +00:00
|
|
|
CHECK_THREAD (timeline);
|
2014-11-30 23:38:07 +00:00
|
|
|
|
|
|
|
if (g_hash_table_size (timeline->priv->all_elements) == 0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
g_hash_table_iter_init (&iter, timeline->priv->all_elements);
|
|
|
|
while (g_hash_table_iter_next (&iter, &key, &value)) {
|
|
|
|
if (GES_IS_SOURCE (value) &&
|
|
|
|
ges_track_element_is_active (GES_TRACK_ELEMENT (value)))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2015-02-20 11:24:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_get_layer:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline to retrieve a layer from
|
|
|
|
* @priority: The priority/index of the layer to find
|
2015-02-20 11:24:49 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Retrieve the layer whose index in the timeline matches the given
|
|
|
|
* priority.
|
2015-02-20 11:24:49 +00:00
|
|
|
*
|
2019-12-18 20:33:45 +00:00
|
|
|
* Returns: (transfer full) (nullable): The layer with the given
|
|
|
|
* @priority, or %NULL if none was found.
|
2015-02-20 11:24:49 +00:00
|
|
|
*
|
|
|
|
* Since 1.6
|
|
|
|
*/
|
|
|
|
GESLayer *
|
|
|
|
ges_timeline_get_layer (GESTimeline * timeline, guint priority)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
GESLayer *layer = NULL;
|
|
|
|
|
2018-11-02 17:32:04 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), NULL);
|
|
|
|
CHECK_THREAD (timeline);
|
|
|
|
|
2015-02-20 11:24:49 +00:00
|
|
|
for (tmp = timeline->layers; tmp; tmp = tmp->next) {
|
|
|
|
GESLayer *tmp_layer = GES_LAYER (tmp->data);
|
|
|
|
guint tmp_priority;
|
|
|
|
|
|
|
|
g_object_get (tmp_layer, "priority", &tmp_priority, NULL);
|
|
|
|
if (tmp_priority == priority) {
|
|
|
|
layer = gst_object_ref (tmp_layer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return layer;
|
|
|
|
}
|
2018-02-25 22:31:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_paste_element:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: The #GESTimeline onto which @element should be pasted
|
|
|
|
* @element: The element to paste
|
|
|
|
* @position: The position in the timeline @element should be pasted to,
|
|
|
|
* i.e. the #GESTimelineElement:start value for the pasted element.
|
|
|
|
* @layer_priority: The layer into which the element should be pasted.
|
|
|
|
* -1 means paste to the same layer from which @element has been copied from
|
|
|
|
*
|
|
|
|
* Paste an element inside the timeline. @element **must** be the return of
|
|
|
|
* ges_timeline_element_copy() with `deep=TRUE`,
|
|
|
|
* and it should not be changed before pasting. @element itself is not
|
|
|
|
* placed in the timeline, instead a new element is created, alike to the
|
|
|
|
* originally copied element. Note that the originally copied element must
|
|
|
|
* also lie within @timeline, at both the point of copying and pasting.
|
|
|
|
*
|
|
|
|
* Pasting may fail if it would place the timeline in an unsupported
|
|
|
|
* configuration.
|
|
|
|
*
|
|
|
|
* After calling this function @element should not be used. In particular,
|
|
|
|
* @element can **not** be pasted again. Instead, you can copy the
|
|
|
|
* returned element and paste that copy (although, this is only possible
|
|
|
|
* if the paste was successful).
|
|
|
|
*
|
|
|
|
* See also ges_timeline_element_paste().
|
|
|
|
*
|
|
|
|
* Returns: (transfer full) (nullable): The newly created element, or
|
|
|
|
* %NULL if pasting fails.
|
2018-02-25 22:31:33 +00:00
|
|
|
*/
|
|
|
|
GESTimelineElement *
|
|
|
|
ges_timeline_paste_element (GESTimeline * timeline,
|
|
|
|
GESTimelineElement * element, GstClockTime position, gint layer_priority)
|
|
|
|
{
|
|
|
|
GESTimelineElement *res, *copied_from;
|
|
|
|
GESTimelineElementClass *element_class;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE_ELEMENT (element), FALSE);
|
2018-11-02 17:32:04 +00:00
|
|
|
CHECK_THREAD (timeline);
|
2018-02-25 22:31:33 +00:00
|
|
|
|
|
|
|
element_class = GES_TIMELINE_ELEMENT_GET_CLASS (element);
|
2019-12-20 11:20:49 +00:00
|
|
|
/* steal ownership of the copied element */
|
2018-02-25 22:31:33 +00:00
|
|
|
copied_from = ges_timeline_element_get_copied_from (element);
|
|
|
|
|
|
|
|
if (!copied_from) {
|
|
|
|
GST_ERROR_OBJECT (element, "Is not being 'deeply' copied!");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!element_class->paste) {
|
|
|
|
GST_ERROR_OBJECT (element, "No paste vmethod implemented");
|
2019-12-20 11:20:49 +00:00
|
|
|
gst_object_unref (copied_from);
|
2018-02-25 22:31:33 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Currently the API only supports pasting onto the same layer from which
|
|
|
|
* the @element has been copied from, i.e., @layer_priority needs to be -1.
|
|
|
|
*/
|
|
|
|
if (layer_priority != -1) {
|
|
|
|
GST_WARNING_OBJECT (timeline,
|
|
|
|
"Only -1 value for layer priority is supported");
|
2019-12-20 11:20:49 +00:00
|
|
|
gst_object_unref (copied_from);
|
|
|
|
return NULL;
|
2018-02-25 22:31:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
res = element_class->paste (element, copied_from, position);
|
|
|
|
|
2019-12-20 11:20:49 +00:00
|
|
|
gst_object_unref (copied_from);
|
2018-02-25 22:31:33 +00:00
|
|
|
|
2019-12-20 11:20:49 +00:00
|
|
|
return res ? g_object_ref (res) : res;
|
2018-02-25 22:31:33 +00:00
|
|
|
}
|
2015-12-12 11:29:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_move_layer:
|
2019-12-18 20:33:45 +00:00
|
|
|
* @timeline: A #GESTimeline
|
|
|
|
* @layer: A layer within @timeline, whose priority should be changed
|
|
|
|
* @new_layer_priority: The new index for @layer
|
|
|
|
*
|
|
|
|
* Moves a layer within the timeline to the index given by
|
|
|
|
* @new_layer_priority.
|
|
|
|
* An index of 0 corresponds to the layer with the highest priority in a
|
|
|
|
* timeline. If @new_layer_priority is greater than the number of layers
|
|
|
|
* present in the timeline, it will become the lowest priority layer.
|
2019-05-16 12:06:14 +00:00
|
|
|
*
|
|
|
|
* Since: 1.16
|
2015-12-12 11:29:50 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_timeline_move_layer (GESTimeline * timeline, GESLayer * layer,
|
|
|
|
guint new_layer_priority)
|
|
|
|
{
|
|
|
|
gint current_priority;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
|
|
|
|
g_return_val_if_fail (GES_IS_LAYER (layer), FALSE);
|
|
|
|
g_return_val_if_fail (ges_layer_get_timeline (layer) == timeline, FALSE);
|
2018-11-02 17:32:04 +00:00
|
|
|
CHECK_THREAD (timeline);
|
2015-12-12 11:29:50 +00:00
|
|
|
|
|
|
|
current_priority = ges_layer_get_priority (layer);
|
|
|
|
|
|
|
|
if (new_layer_priority == current_priority) {
|
|
|
|
GST_DEBUG_OBJECT (timeline,
|
|
|
|
"Nothing to do for %" GST_PTR_FORMAT ", same priorities", layer);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
timeline->layers = g_list_remove (timeline->layers, layer);
|
|
|
|
timeline->layers = g_list_insert (timeline->layers, layer,
|
|
|
|
(gint) new_layer_priority);
|
|
|
|
|
|
|
|
_resync_layers (timeline);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|