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 23:23:54 +00:00
|
|
|
* 2012 Collabora Ltd.
|
|
|
|
* Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
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
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* SECTION:ges-clip
|
2012-12-21 23:17:41 +00:00
|
|
|
* @short_description: Base Class for objects in a GESTimelineLayer
|
2009-08-04 15:13:11 +00:00
|
|
|
*
|
2013-01-20 15:42:29 +00:00
|
|
|
* A #GESClip is a 'natural' object which controls one or more
|
2013-01-26 15:31:33 +00:00
|
|
|
* #GESTrackElement(s) in one or more #GESTrack(s).
|
2009-08-04 15:13:11 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Keeps a reference to the #GESTrackElement(s) it created and
|
2010-12-09 11:53:07 +00:00
|
|
|
* sets/updates their properties.
|
2009-08-04 15:13:11 +00:00
|
|
|
*/
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
#include "ges-clip.h"
|
2009-09-10 16:40:51 +00:00
|
|
|
#include "ges.h"
|
|
|
|
#include "ges-internal.h"
|
|
|
|
|
2012-03-12 15:46:42 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2010-06-09 14:27:43 +00:00
|
|
|
gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_clip_fill_track_element_func (GESClip * object,
|
|
|
|
GESTrackElement * trackelement, GstElement * gnlobj);
|
2010-06-09 14:27:43 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GList *ges_clip_create_track_elements_func (GESClip * object,
|
|
|
|
GESTrackType type);
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
static gboolean _set_max_duration (GESTimelineElement * element,
|
|
|
|
GstClockTime maxduration);
|
2012-01-16 12:37:22 +00:00
|
|
|
|
2010-07-09 11:49:23 +00:00
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
track_element_start_changed_cb (GESTrackElement * child,
|
2013-01-20 15:42:29 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESClip * object);
|
2010-12-16 18:29:14 +00:00
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
track_element_inpoint_changed_cb (GESTrackElement * child,
|
2013-01-20 15:42:29 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESClip * object);
|
2010-12-16 18:29:14 +00:00
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
track_element_duration_changed_cb (GESTrackElement * child,
|
2013-01-20 15:42:29 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESClip * object);
|
2010-12-16 18:29:14 +00:00
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
track_element_priority_changed_cb (GESTrackElement * child,
|
2013-01-20 15:42:29 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESClip * object);
|
|
|
|
static void update_height (GESClip * object);
|
2010-07-09 11:49:23 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
static gint sort_track_effects (gpointer a, gpointer b, GESClip * object);
|
2011-04-15 23:34:28 +00:00
|
|
|
static void
|
|
|
|
get_layer_priorities (GESTimelineLayer * layer, guint32 * layer_min_gnl_prio,
|
|
|
|
guint32 * layer_max_gnl_prio);
|
2011-01-31 10:15:33 +00:00
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
static gboolean _set_start (GESTimelineElement * element, GstClockTime start);
|
|
|
|
static gboolean _set_inpoint (GESTimelineElement * element,
|
|
|
|
GstClockTime inpoint);
|
|
|
|
static gboolean _set_duration (GESTimelineElement * element,
|
|
|
|
GstClockTime duration);
|
|
|
|
static gboolean _set_priority (GESTimelineElement * element, guint32 priority);
|
2011-06-09 00:36:58 +00:00
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
static gboolean _ripple (GESTimelineElement * element, GstClockTime start);
|
|
|
|
static gboolean _ripple_end (GESTimelineElement * element, GstClockTime end);
|
|
|
|
static gboolean _roll_start (GESTimelineElement * element, GstClockTime start);
|
|
|
|
static gboolean _roll_end (GESTimelineElement * element, GstClockTime end);
|
|
|
|
static gboolean _trim (GESTimelineElement * element, GstClockTime start);
|
2012-09-10 00:20:46 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
G_DEFINE_ABSTRACT_TYPE (GESClip, ges_clip, GES_TYPE_TIMELINE_ELEMENT);
|
2009-08-06 10:14:37 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
/* Mapping of relationship between a Clip and the TrackElements
|
2010-12-16 18:29:14 +00:00
|
|
|
* it controls
|
|
|
|
*
|
|
|
|
* NOTE : how do we make this public in the future ?
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *object;
|
2010-12-16 18:29:14 +00:00
|
|
|
gint64 start_offset;
|
|
|
|
gint64 duration_offset;
|
|
|
|
gint64 inpoint_offset;
|
|
|
|
gint32 priority_offset;
|
|
|
|
|
|
|
|
guint start_notifyid;
|
|
|
|
guint duration_notifyid;
|
|
|
|
guint inpoint_notifyid;
|
|
|
|
guint priority_notifyid;
|
|
|
|
|
|
|
|
/* track mapping ?? */
|
|
|
|
} ObjectMapping;
|
|
|
|
|
2011-02-08 13:04:39 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
EFFECT_ADDED,
|
|
|
|
EFFECT_REMOVED,
|
2013-01-26 15:31:33 +00:00
|
|
|
TRACK_ELEMENT_ADDED,
|
|
|
|
TRACK_ELEMENT_REMOVED,
|
2011-02-08 13:04:39 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
static guint ges_clip_signals[LAST_SIGNAL] = { 0 };
|
2011-02-08 13:04:39 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
struct _GESClipPrivate
|
2010-11-28 12:24:07 +00:00
|
|
|
{
|
|
|
|
/*< public > */
|
|
|
|
GESTimelineLayer *layer;
|
|
|
|
|
|
|
|
/*< private > */
|
2010-12-16 18:29:14 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
/* Set to TRUE when the clip is doing updates of track object
|
2010-12-16 18:29:14 +00:00
|
|
|
* properties so we don't end up in infinite property update loops
|
|
|
|
*/
|
|
|
|
gboolean ignore_notifies;
|
2011-06-06 19:55:47 +00:00
|
|
|
gboolean is_moving;
|
2010-12-16 18:29:14 +00:00
|
|
|
|
|
|
|
GList *mappings;
|
2011-01-31 10:10:35 +00:00
|
|
|
|
|
|
|
guint nb_effects;
|
2011-12-01 03:18:30 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *initiated_move;
|
2011-12-16 07:23:58 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
/* The formats supported by this Clip */
|
2011-12-01 03:18:30 +00:00
|
|
|
GESTrackType supportedformats;
|
2012-09-10 00:20:46 +00:00
|
|
|
|
|
|
|
GESAsset *asset;
|
2010-11-28 12:24:07 +00:00
|
|
|
};
|
|
|
|
|
2009-08-07 18:33:18 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2010-07-09 09:51:21 +00:00
|
|
|
PROP_HEIGHT,
|
2010-11-28 12:24:07 +00:00
|
|
|
PROP_LAYER,
|
2011-12-01 03:18:30 +00:00
|
|
|
PROP_SUPPORTED_FORMATS,
|
2010-12-16 18:29:14 +00:00
|
|
|
PROP_LAST
|
2009-08-07 18:33:18 +00:00
|
|
|
};
|
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
static GParamSpec *properties[PROP_LAST];
|
|
|
|
|
2009-08-06 10:14:37 +00:00
|
|
|
static void
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_get_property (GObject * object, guint property_id,
|
2009-08-04 15:16:31 +00:00
|
|
|
GValue * value, GParamSpec * pspec)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *tobj = GES_CLIP (object);
|
2009-08-07 18:33:18 +00:00
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
switch (property_id) {
|
2010-07-09 09:51:21 +00:00
|
|
|
case PROP_HEIGHT:
|
|
|
|
g_value_set_uint (value, tobj->height);
|
2009-08-07 18:33:18 +00:00
|
|
|
break;
|
2010-11-28 12:24:07 +00:00
|
|
|
case PROP_LAYER:
|
|
|
|
g_value_set_object (value, tobj->priv->layer);
|
|
|
|
break;
|
2011-12-01 03:18:30 +00:00
|
|
|
case PROP_SUPPORTED_FORMATS:
|
|
|
|
g_value_set_flags (value, tobj->priv->supportedformats);
|
|
|
|
break;
|
2009-08-04 15:16:31 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_set_property (GObject * object, guint property_id,
|
2009-08-04 15:16:31 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *tobj = GES_CLIP (object);
|
2009-08-07 18:33:18 +00:00
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
switch (property_id) {
|
2011-12-01 03:18:30 +00:00
|
|
|
case PROP_SUPPORTED_FORMATS:
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_set_supported_formats (tobj, g_value_get_flags (value));
|
2011-12-01 03:18:30 +00:00
|
|
|
break;
|
2009-08-04 15:16:31 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_class_init (GESClipClass * klass)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2013-01-15 13:52:17 +00:00
|
|
|
GESTimelineElementClass *element_class = GES_TIMELINE_ELEMENT_CLASS (klass);
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_type_class_add_private (klass, sizeof (GESClipPrivate));
|
2010-11-28 12:24:07 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
object_class->get_property = ges_clip_get_property;
|
|
|
|
object_class->set_property = ges_clip_set_property;
|
2013-01-26 15:31:33 +00:00
|
|
|
klass->create_track_elements = ges_clip_create_track_elements_func;
|
|
|
|
klass->create_track_element = NULL;
|
|
|
|
klass->track_element_added = NULL;
|
|
|
|
klass->track_element_released = NULL;
|
2009-08-07 18:33:18 +00:00
|
|
|
|
2010-07-09 09:51:21 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* GESClip:height:
|
2010-07-09 09:51:21 +00:00
|
|
|
*
|
|
|
|
* The span of layer priorities which this object occupies.
|
|
|
|
*/
|
2011-02-09 10:21:02 +00:00
|
|
|
properties[PROP_HEIGHT] = g_param_spec_uint ("height", "Height",
|
|
|
|
"The span of priorities this object occupies", 0, G_MAXUINT, 1,
|
|
|
|
G_PARAM_READABLE);
|
2010-07-09 09:51:21 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_HEIGHT,
|
2011-02-09 10:21:02 +00:00
|
|
|
properties[PROP_HEIGHT]);
|
2010-07-09 09:51:21 +00:00
|
|
|
|
2011-12-01 03:18:30 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* GESClip:supported-formats:
|
2011-12-01 03:18:30 +00:00
|
|
|
*
|
|
|
|
* The formats supported by the object.
|
|
|
|
*
|
|
|
|
* Since: 0.10.XX
|
|
|
|
*/
|
|
|
|
properties[PROP_SUPPORTED_FORMATS] = g_param_spec_flags ("supported-formats",
|
|
|
|
"Supported formats", "Formats supported by the file",
|
2012-11-18 15:46:05 +00:00
|
|
|
GES_TYPE_TRACK_TYPE, GES_TRACK_TYPE_AUDIO | GES_TRACK_TYPE_VIDEO,
|
2011-12-01 03:18:30 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_SUPPORTED_FORMATS,
|
|
|
|
properties[PROP_SUPPORTED_FORMATS]);
|
|
|
|
|
2011-02-09 10:21:02 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* GESClip:layer:
|
2010-11-28 12:24:07 +00:00
|
|
|
*
|
|
|
|
* The GESTimelineLayer where this object is being used.
|
|
|
|
*/
|
2011-02-09 10:21:02 +00:00
|
|
|
properties[PROP_LAYER] = g_param_spec_object ("layer", "Layer",
|
|
|
|
"The GESTimelineLayer where this object is being used.",
|
|
|
|
GES_TYPE_TIMELINE_LAYER, G_PARAM_READABLE);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_LAYER,
|
2011-02-09 10:21:02 +00:00
|
|
|
properties[PROP_LAYER]);
|
2010-11-28 12:24:07 +00:00
|
|
|
|
2011-02-08 13:04:39 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* GESClip::effect-added:
|
|
|
|
* @object: the #GESClip
|
2011-02-16 13:05:14 +00:00
|
|
|
* @effect: the #GESTrackEffect that was added.
|
2011-02-08 13:04:39 +00:00
|
|
|
*
|
|
|
|
* Will be emitted after an effect was added to the object.
|
2011-05-06 17:55:31 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
2011-02-08 13:04:39 +00:00
|
|
|
*/
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_signals[EFFECT_ADDED] =
|
2011-02-08 13:04:39 +00:00
|
|
|
g_signal_new ("effect-added", G_TYPE_FROM_CLASS (klass),
|
2012-03-12 15:46:42 +00:00
|
|
|
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
|
2011-02-16 13:05:14 +00:00
|
|
|
G_TYPE_NONE, 1, GES_TYPE_TRACK_EFFECT);
|
2011-02-08 13:04:39 +00:00
|
|
|
|
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* GESClip::effect-removed:
|
|
|
|
* @object: the #GESClip
|
2011-02-16 13:05:14 +00:00
|
|
|
* @effect: the #GESTrackEffect that was added.
|
2011-02-08 13:04:39 +00:00
|
|
|
*
|
|
|
|
* Will be emitted after an effect was remove from the object.
|
2011-05-06 17:55:31 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
2011-02-08 13:04:39 +00:00
|
|
|
*/
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_signals[EFFECT_REMOVED] =
|
2011-02-08 13:04:39 +00:00
|
|
|
g_signal_new ("effect-removed", G_TYPE_FROM_CLASS (klass),
|
2012-03-12 15:46:42 +00:00
|
|
|
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
|
2011-02-16 13:05:14 +00:00
|
|
|
G_TYPE_NONE, 1, GES_TYPE_TRACK_EFFECT);
|
2011-02-08 13:04:39 +00:00
|
|
|
|
2011-08-28 04:25:37 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* GESClip::track-object-added:
|
|
|
|
* @object: the #GESClip
|
2013-01-26 15:31:33 +00:00
|
|
|
* @trackelement: the #GESTrackElement that was added.
|
2011-08-28 04:25:37 +00:00
|
|
|
*
|
|
|
|
* Will be emitted after a track object was added to the object.
|
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
|
|
|
*/
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_clip_signals[TRACK_ELEMENT_ADDED] =
|
2011-08-28 04:25:37 +00:00
|
|
|
g_signal_new ("track-object-added", G_TYPE_FROM_CLASS (klass),
|
2012-03-12 15:46:42 +00:00
|
|
|
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
|
2013-01-26 15:31:33 +00:00
|
|
|
G_TYPE_NONE, 1, GES_TYPE_TRACK_ELEMENT);
|
2011-08-28 04:25:37 +00:00
|
|
|
|
2011-12-06 17:10:14 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* GESClip::track-object-removed:
|
|
|
|
* @object: the #GESClip
|
2013-01-26 15:31:33 +00:00
|
|
|
* @trackelement: the #GESTrackElement that was removed.
|
2011-12-06 17:10:14 +00:00
|
|
|
*
|
2011-12-07 02:11:25 +00:00
|
|
|
* Will be emitted after a track object was removed from @object.
|
2011-12-06 17:10:14 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
|
|
|
*/
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_clip_signals[TRACK_ELEMENT_REMOVED] =
|
2011-12-06 17:10:14 +00:00
|
|
|
g_signal_new ("track-object-removed", G_TYPE_FROM_CLASS (klass),
|
2012-03-12 15:46:42 +00:00
|
|
|
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
|
2013-01-26 15:31:33 +00:00
|
|
|
G_TYPE_NONE, 1, GES_TYPE_TRACK_ELEMENT);
|
2011-12-06 17:10:14 +00:00
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
|
|
|
|
element_class->set_start = _set_start;
|
|
|
|
element_class->set_duration = _set_duration;
|
|
|
|
element_class->set_inpoint = _set_inpoint;
|
|
|
|
element_class->set_priority = _set_priority;
|
|
|
|
|
|
|
|
element_class->ripple = _ripple;
|
|
|
|
element_class->ripple_end = _ripple_end;
|
|
|
|
element_class->roll_start = _roll_start;
|
|
|
|
element_class->roll_end = _roll_end;
|
|
|
|
element_class->trim = _trim;
|
|
|
|
element_class->set_max_duration = _set_max_duration;
|
|
|
|
/* TODO implement the deep_copy Virtual method */
|
2012-01-16 12:37:22 +00:00
|
|
|
|
2009-09-21 10:51:16 +00:00
|
|
|
klass->need_fill_track = TRUE;
|
2012-04-22 17:09:11 +00:00
|
|
|
klass->snaps = FALSE;
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_init (GESClip * self)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2010-11-28 12:24:07 +00:00
|
|
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
2013-01-20 15:42:29 +00:00
|
|
|
GES_TYPE_CLIP, GESClipPrivate);
|
2013-01-15 13:52:17 +00:00
|
|
|
/* FIXME, check why it was done this way _DURATION (self) = GST_SECOND; */
|
2010-07-09 10:09:29 +00:00
|
|
|
self->height = 1;
|
2013-01-26 15:31:33 +00:00
|
|
|
self->trackelements = NULL;
|
2010-11-28 12:24:07 +00:00
|
|
|
self->priv->layer = NULL;
|
2011-01-31 10:10:35 +00:00
|
|
|
self->priv->nb_effects = 0;
|
2011-06-06 19:55:47 +00:00
|
|
|
self->priv->is_moving = FALSE;
|
2012-11-20 03:29:23 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 09:23:01 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_clip_create_track_element:
|
2013-01-20 15:42:29 +00:00
|
|
|
* @object: The origin #GESClip
|
2013-01-26 15:31:33 +00:00
|
|
|
* @type: The #GESTrackType to create a #GESTrackElement for.
|
2009-08-06 09:23:01 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Creates a #GESTrackElement for the provided @type. The timeline object
|
|
|
|
* keep a reference to the newly created trackelement, you therefore need to
|
|
|
|
* call @ges_clip_release_track_element when you are done with it.
|
2009-08-06 09:23:01 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Returns: (transfer none): A #GESTrackElement. Returns NULL if the #GESTrackElement could not
|
2009-08-06 09:23:01 +00:00
|
|
|
* be created.
|
|
|
|
*/
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *
|
|
|
|
ges_clip_create_track_element (GESClip * object, GESTrackType type)
|
2009-08-06 09:23:01 +00:00
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClipClass *class;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *res;
|
2009-08-06 09:23:01 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), NULL);
|
2011-12-07 23:50:13 +00:00
|
|
|
|
2012-12-20 23:23:54 +00:00
|
|
|
GST_DEBUG_OBJECT (object, "Creating track object for %s",
|
|
|
|
ges_track_type_name (type));
|
|
|
|
if (!(type & object->priv->supportedformats)) {
|
|
|
|
GST_DEBUG_OBJECT (object, "We don't support this track type %i", type);
|
2012-11-18 15:46:05 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
class = GES_CLIP_GET_CLASS (object);
|
2009-08-06 09:23:01 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (G_UNLIKELY (class->create_track_element == NULL)) {
|
|
|
|
GST_ERROR ("No 'create_track_element' implementation available fo type %s",
|
2012-12-21 17:28:16 +00:00
|
|
|
G_OBJECT_TYPE_NAME (object));
|
2009-08-06 15:38:43 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
res = class->create_track_element (object, type);
|
2009-08-06 15:38:43 +00:00
|
|
|
return res;
|
2010-07-07 15:07:33 +00:00
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
}
|
|
|
|
|
2010-07-07 14:51:39 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_clip_create_track_elements:
|
2013-01-20 15:42:29 +00:00
|
|
|
* @object: The origin #GESClip
|
2013-01-26 15:31:33 +00:00
|
|
|
* @type: The #GESTrackType to create each #GESTrackElement for.
|
2010-07-07 14:51:39 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Creates all #GESTrackElements supported by this object for the track type.
|
2010-07-07 14:51:39 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Returns: (element-type GESTrackElement) (transfer full): A #GList of
|
|
|
|
* newly created #GESTrackElement-s
|
2010-07-07 14:51:39 +00:00
|
|
|
*/
|
|
|
|
|
2012-12-20 23:23:54 +00:00
|
|
|
GList *
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_clip_create_track_elements (GESClip * object, GESTrackType type)
|
2010-07-07 14:51:39 +00:00
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClipClass *klass;
|
2010-07-07 14:51:39 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), NULL);
|
2011-12-07 23:50:13 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
klass = GES_CLIP_GET_CLASS (object);
|
2010-07-07 14:51:39 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (!(klass->create_track_elements)) {
|
|
|
|
GST_WARNING ("no GESClip::create_track_elements implentation");
|
2012-12-20 23:23:54 +00:00
|
|
|
return NULL;
|
2010-07-07 14:51:39 +00:00
|
|
|
}
|
2012-04-20 23:02:19 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_DEBUG_OBJECT (object, "Creating TrackElements for type: %s",
|
2012-12-20 23:23:54 +00:00
|
|
|
ges_track_type_name (type));
|
2013-01-26 15:31:33 +00:00
|
|
|
return klass->create_track_elements (object, type);
|
2010-07-07 14:51:39 +00:00
|
|
|
}
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
gboolean
|
|
|
|
_set_max_duration (GESTimelineElement * element, GstClockTime maxduration)
|
2012-01-16 12:37:22 +00:00
|
|
|
{
|
|
|
|
GList *tmp;
|
2013-01-15 13:52:17 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
for (tmp = GES_CLIP (element)->trackelements; tmp; tmp = g_list_next (tmp))
|
2013-01-15 13:52:17 +00:00
|
|
|
ges_timeline_element_set_max_duration (GES_TIMELINE_ELEMENT (tmp->data),
|
|
|
|
maxduration);
|
|
|
|
|
|
|
|
return TRUE;
|
2012-01-16 12:37:22 +00:00
|
|
|
}
|
|
|
|
|
2010-12-09 11:53:07 +00:00
|
|
|
/*
|
2013-01-26 15:31:33 +00:00
|
|
|
* default implementation of GESClipClass::create_track_elements
|
2010-12-09 11:53:07 +00:00
|
|
|
*/
|
2012-12-20 23:23:54 +00:00
|
|
|
GList *
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_clip_create_track_elements_func (GESClip * object, GESTrackType type)
|
2010-07-07 14:51:39 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *result;
|
2010-07-07 14:51:39 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_DEBUG_OBJECT (object, "Creating trackelement for track: %s",
|
2012-12-20 23:23:54 +00:00
|
|
|
ges_track_type_name (type));
|
2013-01-26 15:31:33 +00:00
|
|
|
result = ges_clip_create_track_element (object, type);
|
2010-07-07 14:51:39 +00:00
|
|
|
if (!result) {
|
2011-12-01 00:47:54 +00:00
|
|
|
GST_DEBUG ("Did not create track object");
|
2012-12-20 23:23:54 +00:00
|
|
|
return NULL;
|
2010-07-07 14:51:39 +00:00
|
|
|
}
|
2012-01-30 16:47:42 +00:00
|
|
|
|
2012-12-20 23:23:54 +00:00
|
|
|
return g_list_append (NULL, result);
|
2010-07-07 14:51:39 +00:00
|
|
|
}
|
|
|
|
|
2010-07-07 15:07:33 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_clip_add_track_element:
|
2013-01-20 15:42:29 +00:00
|
|
|
* @object: a #GESClip
|
2013-01-26 15:31:33 +00:00
|
|
|
* @trobj: the GESTrackElement
|
2010-11-28 12:24:07 +00:00
|
|
|
*
|
2010-07-07 15:07:33 +00:00
|
|
|
* Add a track object to the timeline object. Should only be called by
|
2013-01-26 15:31:33 +00:00
|
|
|
* subclasses implementing the create_track_elements (plural) vmethod.
|
2010-07-07 15:07:33 +00:00
|
|
|
*
|
2010-12-20 10:56:37 +00:00
|
|
|
* Takes a reference on @trobj.
|
|
|
|
*
|
2010-07-07 15:07:33 +00:00
|
|
|
* Returns: %TRUE on success, %FALSE on failure.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_clip_add_track_element (GESClip * object, GESTrackElement * trobj)
|
2010-07-07 15:07:33 +00:00
|
|
|
{
|
2011-01-31 10:22:31 +00:00
|
|
|
GList *tmp;
|
2012-11-27 15:18:27 +00:00
|
|
|
gboolean is_effect;
|
|
|
|
ObjectMapping *mapping;
|
2011-04-15 23:34:28 +00:00
|
|
|
guint max_prio, min_prio;
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClipClass *klass;
|
|
|
|
GESClipPrivate *priv;
|
2010-12-16 18:29:14 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), FALSE);
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (trobj), FALSE);
|
2011-12-07 23:50:13 +00:00
|
|
|
|
2012-11-27 15:18:27 +00:00
|
|
|
priv = object->priv;
|
|
|
|
is_effect = GES_IS_TRACK_EFFECT (trobj);
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_LOG ("Got a TrackElement : %p , setting the timeline object as its"
|
2011-02-16 13:05:14 +00:00
|
|
|
"creator. Is a TrackEffect %i", trobj, is_effect);
|
2010-07-07 15:07:33 +00:00
|
|
|
|
|
|
|
if (!trobj)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_clip (trobj, object);
|
2011-07-27 00:02:20 +00:00
|
|
|
|
2010-12-20 10:56:37 +00:00
|
|
|
g_object_ref (trobj);
|
2010-07-07 15:07:33 +00:00
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
mapping = g_slice_new0 (ObjectMapping);
|
|
|
|
mapping->object = trobj;
|
2011-01-31 10:22:31 +00:00
|
|
|
priv->mappings = g_list_append (priv->mappings, mapping);
|
2010-12-16 18:29:14 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_DEBUG ("Adding TrackElement to the list of controlled track objects");
|
2010-07-07 15:07:33 +00:00
|
|
|
/* We steal the initial reference */
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_DEBUG ("Setting properties on newly created TrackElement");
|
2010-07-07 15:07:33 +00:00
|
|
|
|
2011-01-31 10:22:31 +00:00
|
|
|
mapping->priority_offset = priv->nb_effects;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
/* If the trackelement is an effect:
|
2011-02-16 13:05:14 +00:00
|
|
|
* - We add it on top of the list of TrackEffect
|
2013-01-26 15:31:33 +00:00
|
|
|
* - We put all TrackElement present in the Clip
|
2011-01-31 10:22:31 +00:00
|
|
|
* which are not TrackEffect on top of them
|
|
|
|
*
|
|
|
|
* FIXME: Let the full control over priorities to the user
|
|
|
|
*/
|
2011-02-16 13:05:14 +00:00
|
|
|
if (is_effect) {
|
2011-02-03 14:30:30 +00:00
|
|
|
GST_DEBUG
|
2013-01-26 15:31:33 +00:00
|
|
|
("Moving non on top effect under other TrackElement-s, nb effects %i",
|
2011-02-03 14:30:30 +00:00
|
|
|
priv->nb_effects);
|
2013-01-26 15:31:33 +00:00
|
|
|
for (tmp = g_list_nth (object->trackelements, priv->nb_effects); tmp;
|
2011-01-31 10:22:31 +00:00
|
|
|
tmp = tmp->next) {
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *tmpo = GES_TRACK_ELEMENT (tmp->data);
|
2011-01-31 10:22:31 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
/* We make sure not to move the entire #Clip */
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_locked (tmpo, FALSE);
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_priority0 (GES_TIMELINE_ELEMENT (tmpo), _PRIORITY (tmpo) + 1);
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_locked (tmpo, TRUE);
|
2011-01-31 10:22:31 +00:00
|
|
|
}
|
2011-02-01 20:14:29 +00:00
|
|
|
|
2011-01-31 10:22:31 +00:00
|
|
|
priv->nb_effects++;
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
object->trackelements =
|
|
|
|
g_list_insert_sorted_with_data (object->trackelements, trobj,
|
2011-01-31 10:22:31 +00:00
|
|
|
(GCompareDataFunc) sort_track_effects, object);
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_start0 (GES_TIMELINE_ELEMENT (trobj), _START (object));
|
|
|
|
_set_duration0 (GES_TIMELINE_ELEMENT (trobj), _DURATION (object));
|
|
|
|
_set_inpoint0 (GES_TIMELINE_ELEMENT (trobj), _INPOINT (object));
|
|
|
|
ges_timeline_element_set_max_duration (GES_TIMELINE_ELEMENT (trobj),
|
|
|
|
_MAXDURATION (object));
|
2010-07-07 15:07:33 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
klass = GES_CLIP_GET_CLASS (object);
|
2013-01-26 15:31:33 +00:00
|
|
|
if (klass->track_element_added) {
|
|
|
|
GST_DEBUG ("Calling track_element_added subclass method");
|
|
|
|
klass->track_element_added (object, trobj);
|
2011-04-26 23:39:56 +00:00
|
|
|
} else {
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_DEBUG ("%s doesn't have any track_element_added vfunc implementation",
|
2011-04-26 23:39:56 +00:00
|
|
|
G_OBJECT_CLASS_NAME (klass));
|
|
|
|
}
|
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
/* Listen to all property changes */
|
|
|
|
mapping->start_notifyid =
|
|
|
|
g_signal_connect (G_OBJECT (trobj), "notify::start",
|
2013-01-26 15:31:33 +00:00
|
|
|
G_CALLBACK (track_element_start_changed_cb), object);
|
2010-12-16 18:29:14 +00:00
|
|
|
mapping->duration_notifyid =
|
|
|
|
g_signal_connect (G_OBJECT (trobj), "notify::duration",
|
2013-01-26 15:31:33 +00:00
|
|
|
G_CALLBACK (track_element_duration_changed_cb), object);
|
2010-12-16 18:29:14 +00:00
|
|
|
mapping->inpoint_notifyid =
|
2013-01-15 13:52:17 +00:00
|
|
|
g_signal_connect (G_OBJECT (trobj), "notify::inpoint",
|
2013-01-26 15:31:33 +00:00
|
|
|
G_CALLBACK (track_element_inpoint_changed_cb), object);
|
2010-12-16 18:29:14 +00:00
|
|
|
mapping->priority_notifyid =
|
|
|
|
g_signal_connect (G_OBJECT (trobj), "notify::priority",
|
2013-01-26 15:31:33 +00:00
|
|
|
G_CALLBACK (track_element_priority_changed_cb), object);
|
2010-07-09 11:49:23 +00:00
|
|
|
|
2011-04-15 23:34:28 +00:00
|
|
|
get_layer_priorities (priv->layer, &min_prio, &max_prio);
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_priority0 (GES_TIMELINE_ELEMENT (trobj), min_prio +
|
|
|
|
_PRIORITY (object) + mapping->priority_offset);
|
2011-02-03 14:40:05 +00:00
|
|
|
|
2011-02-03 14:30:30 +00:00
|
|
|
GST_DEBUG ("Returning trobj:%p", trobj);
|
2012-01-25 14:12:05 +00:00
|
|
|
if (!GES_IS_TRACK_EFFECT (trobj)) {
|
2013-01-26 15:31:33 +00:00
|
|
|
g_signal_emit (object, ges_clip_signals[TRACK_ELEMENT_ADDED], 0,
|
|
|
|
GES_TRACK_ELEMENT (trobj));
|
2011-12-18 00:49:24 +00:00
|
|
|
} else {
|
|
|
|
/* emit 'effect-added' */
|
2013-01-20 15:42:29 +00:00
|
|
|
g_signal_emit (object, ges_clip_signals[EFFECT_ADDED], 0,
|
2011-12-18 00:49:24 +00:00
|
|
|
GES_TRACK_EFFECT (trobj));
|
2011-08-28 04:25:37 +00:00
|
|
|
}
|
2011-12-18 00:49:24 +00:00
|
|
|
|
2010-07-07 15:07:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-09-21 10:51:16 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_clip_release_track_element:
|
2013-01-20 15:42:29 +00:00
|
|
|
* @object: a #GESClip
|
2013-01-26 15:31:33 +00:00
|
|
|
* @trackelement: the #GESTrackElement to release
|
2010-12-16 18:29:14 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Release the @trackelement from the control of @object.
|
2010-12-16 18:29:14 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Returns: %TRUE if the @trackelement was properly released, else %FALSE.
|
2009-09-21 10:51:16 +00:00
|
|
|
*/
|
2009-08-07 14:39:45 +00:00
|
|
|
gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_clip_release_track_element (GESClip * object,
|
|
|
|
GESTrackElement * trackelement)
|
2009-08-07 14:39:45 +00:00
|
|
|
{
|
2010-12-16 18:29:14 +00:00
|
|
|
GList *tmp;
|
|
|
|
ObjectMapping *mapping = NULL;
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClipClass *klass;
|
2010-12-16 18:29:14 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), FALSE);
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (trackelement), FALSE);
|
2011-12-07 23:50:13 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_DEBUG ("object:%p, trackelement:%p", object, trackelement);
|
2013-01-20 15:42:29 +00:00
|
|
|
klass = GES_CLIP_GET_CLASS (object);
|
2009-08-07 14:39:45 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (!(g_list_find (object->trackelements, trackelement))) {
|
|
|
|
GST_WARNING ("TrackElement isn't controlled by this object");
|
2009-08-07 14:39:45 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
for (tmp = object->priv->mappings; tmp; tmp = tmp->next) {
|
|
|
|
mapping = (ObjectMapping *) tmp->data;
|
2013-01-26 15:31:33 +00:00
|
|
|
if (mapping->object == trackelement)
|
2010-12-16 18:29:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tmp && mapping) {
|
|
|
|
|
|
|
|
/* Disconnect all notify listeners */
|
2013-01-26 15:31:33 +00:00
|
|
|
g_signal_handler_disconnect (trackelement, mapping->start_notifyid);
|
|
|
|
g_signal_handler_disconnect (trackelement, mapping->duration_notifyid);
|
|
|
|
g_signal_handler_disconnect (trackelement, mapping->inpoint_notifyid);
|
|
|
|
g_signal_handler_disconnect (trackelement, mapping->priority_notifyid);
|
2010-12-16 18:29:14 +00:00
|
|
|
|
|
|
|
g_slice_free (ObjectMapping, mapping);
|
|
|
|
|
|
|
|
object->priv->mappings = g_list_delete_link (object->priv->mappings, tmp);
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
object->trackelements = g_list_remove (object->trackelements, trackelement);
|
2009-08-07 14:39:45 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (GES_IS_TRACK_EFFECT (trackelement)) {
|
2011-02-08 13:04:39 +00:00
|
|
|
/* emit 'object-removed' */
|
2012-01-27 16:09:08 +00:00
|
|
|
object->priv->nb_effects--;
|
2013-01-20 15:42:29 +00:00
|
|
|
g_signal_emit (object, ges_clip_signals[EFFECT_REMOVED], 0,
|
2013-01-26 15:31:33 +00:00
|
|
|
GES_TRACK_EFFECT (trackelement));
|
2011-12-06 17:10:14 +00:00
|
|
|
} else
|
2013-01-26 15:31:33 +00:00
|
|
|
g_signal_emit (object, ges_clip_signals[TRACK_ELEMENT_REMOVED], 0,
|
|
|
|
GES_TRACK_ELEMENT (trackelement));
|
2011-02-08 13:04:39 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_clip (trackelement, NULL);
|
2009-08-07 14:39:45 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_DEBUG ("Removing reference to track object %p", trackelement);
|
2010-12-20 10:56:37 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (klass->track_element_released) {
|
|
|
|
GST_DEBUG ("Calling track_element_released subclass method");
|
|
|
|
klass->track_element_released (object, trackelement);
|
2011-04-26 23:39:56 +00:00
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
g_object_unref (trackelement);
|
2009-09-21 10:51:16 +00:00
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
/* FIXME : resync properties ? */
|
|
|
|
|
2009-08-07 14:39:45 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
void
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_set_layer (GESClip * object, GESTimelineLayer * layer)
|
2009-08-06 15:38:43 +00:00
|
|
|
{
|
|
|
|
GST_DEBUG ("object:%p, layer:%p", object, layer);
|
|
|
|
|
2010-11-28 12:24:07 +00:00
|
|
|
object->priv->layer = layer;
|
2009-08-06 15:38:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_clip_fill_track_element (GESClip * object,
|
|
|
|
GESTrackElement * trackelement, GstElement * gnlobj)
|
2009-08-06 15:38:43 +00:00
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClipClass *class;
|
2009-09-21 10:51:16 +00:00
|
|
|
gboolean res = TRUE;
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_DEBUG ("object:%p, trackelement:%p, gnlobject:%p",
|
|
|
|
object, trackelement, gnlobj);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
class = GES_CLIP_GET_CLASS (object);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2009-09-21 10:51:16 +00:00
|
|
|
if (class->need_fill_track) {
|
2013-01-26 15:31:33 +00:00
|
|
|
if (G_UNLIKELY (class->fill_track_element == NULL)) {
|
|
|
|
GST_WARNING ("No 'fill_track_element' implementation available");
|
2009-09-21 10:51:16 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
res = class->fill_track_element (object, trackelement, gnlobj);
|
2009-09-21 10:51:16 +00:00
|
|
|
}
|
2009-08-06 15:38:43 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Returning res:%d", res);
|
2009-08-06 09:23:01 +00:00
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
return res;
|
2009-08-06 09:23:01 +00:00
|
|
|
}
|
2009-08-07 14:39:45 +00:00
|
|
|
|
|
|
|
gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_clip_fill_track_element_func (GESClip * object,
|
|
|
|
GESTrackElement * trackelement, GstElement * gnlobj)
|
2009-08-07 14:39:45 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_WARNING ("No 'fill_track_element' implementation !");
|
2009-08-07 14:39:45 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-08-07 18:33:18 +00:00
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
static ObjectMapping *
|
2013-01-26 15:31:33 +00:00
|
|
|
find_object_mapping (GESClip * object, GESTrackElement * child)
|
2010-12-16 18:29:14 +00:00
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
|
|
|
for (tmp = object->priv->mappings; tmp; tmp = tmp->next) {
|
|
|
|
ObjectMapping *map = (ObjectMapping *) tmp->data;
|
|
|
|
if (map->object == child)
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-11-08 22:29:38 +00:00
|
|
|
static gboolean
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_start (GESTimelineElement * element, GstClockTime start)
|
2009-08-07 18:33:18 +00:00
|
|
|
{
|
2010-12-16 15:27:26 +00:00
|
|
|
GList *tmp;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *tr;
|
2010-12-16 18:29:14 +00:00
|
|
|
ObjectMapping *map;
|
2012-04-22 17:09:11 +00:00
|
|
|
gboolean snap = FALSE;
|
2013-01-15 13:52:17 +00:00
|
|
|
GESTimeline *timeline = NULL;
|
2010-12-16 15:27:26 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *object = GES_CLIP (element);
|
|
|
|
GESClipPrivate *priv = object->priv;
|
2009-08-07 18:33:18 +00:00
|
|
|
|
2012-04-22 17:09:11 +00:00
|
|
|
/* If the class has snapping enabled and the object is in a timeline,
|
|
|
|
* we snap */
|
2013-01-20 15:42:29 +00:00
|
|
|
if (priv->layer && GES_CLIP_GET_CLASS (object)->snaps)
|
2012-04-22 17:09:11 +00:00
|
|
|
timeline = ges_timeline_layer_get_timeline (object->priv->layer);
|
|
|
|
snap = timeline && priv->initiated_move == NULL ? TRUE : FALSE;
|
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
object->priv->ignore_notifies = TRUE;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
for (tmp = object->trackelements; tmp; tmp = g_list_next (tmp)) {
|
|
|
|
tr = (GESTrackElement *) tmp->data;
|
2010-12-16 18:29:14 +00:00
|
|
|
map = find_object_mapping (object, tr);
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (ges_track_element_is_locked (tr) && tr != object->priv->initiated_move) {
|
2011-12-16 07:23:58 +00:00
|
|
|
gint64 new_start = start - map->start_offset;
|
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
/* Move the child... */
|
2011-12-16 07:23:58 +00:00
|
|
|
if (new_start < 0) {
|
|
|
|
GST_ERROR ("Trying to set start to a negative value %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (-(start + map->start_offset)));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-04-22 17:09:11 +00:00
|
|
|
/* Make the snapping happen if in a timeline */
|
|
|
|
if (snap)
|
|
|
|
ges_timeline_move_object_simple (timeline, tr, NULL, GES_EDGE_NONE,
|
|
|
|
start);
|
|
|
|
else
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_start0 (GES_TIMELINE_ELEMENT (tr), start);
|
2010-12-16 18:29:14 +00:00
|
|
|
} else {
|
|
|
|
/* ... or update the offset */
|
2013-01-15 13:52:17 +00:00
|
|
|
map->start_offset = start - _START (tr);
|
2010-12-16 18:29:14 +00:00
|
|
|
}
|
2009-08-07 18:33:18 +00:00
|
|
|
}
|
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
object->priv->ignore_notifies = FALSE;
|
|
|
|
|
2011-11-08 22:29:38 +00:00
|
|
|
return TRUE;
|
2009-08-07 18:33:18 +00:00
|
|
|
}
|
|
|
|
|
2011-11-08 22:29:38 +00:00
|
|
|
static gboolean
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_inpoint (GESTimelineElement * element, GstClockTime inpoint)
|
2009-08-07 18:33:18 +00:00
|
|
|
{
|
2010-12-16 15:27:26 +00:00
|
|
|
GList *tmp;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *tr;
|
2010-12-16 15:27:26 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *object = GES_CLIP (element);
|
2009-08-07 18:33:18 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
for (tmp = object->trackelements; tmp; tmp = g_list_next (tmp)) {
|
|
|
|
tr = (GESTrackElement *) tmp->data;
|
2009-08-07 18:33:18 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (ges_track_element_is_locked (tr))
|
|
|
|
/* call set_inpoint on each trackelement */
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_inpoint0 (GES_TIMELINE_ELEMENT (tr), inpoint);
|
2009-08-07 18:33:18 +00:00
|
|
|
}
|
|
|
|
|
2011-11-08 22:29:38 +00:00
|
|
|
return TRUE;
|
2009-08-07 18:33:18 +00:00
|
|
|
}
|
|
|
|
|
2011-11-08 22:29:38 +00:00
|
|
|
static gboolean
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_duration (GESTimelineElement * element, GstClockTime duration)
|
2009-08-07 18:33:18 +00:00
|
|
|
{
|
2010-12-16 15:27:26 +00:00
|
|
|
GList *tmp;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *tr;
|
2012-04-22 17:09:11 +00:00
|
|
|
GESTimeline *timeline = NULL;
|
|
|
|
gboolean snap = FALSE;
|
2010-12-16 15:27:26 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *object = GES_CLIP (element);
|
|
|
|
GESClipPrivate *priv = object->priv;
|
2009-08-07 18:33:18 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
if (priv->layer && GES_CLIP_GET_CLASS (object)->snaps)
|
2012-04-22 17:09:11 +00:00
|
|
|
timeline = ges_timeline_layer_get_timeline (object->priv->layer);
|
|
|
|
|
2012-04-23 23:10:16 +00:00
|
|
|
/* If the class has snapping enabled, the object is in a timeline,
|
2013-01-26 15:31:33 +00:00
|
|
|
* and we are not following a moved TrackElement, we snap */
|
2012-04-22 17:09:11 +00:00
|
|
|
snap = timeline && priv->initiated_move == NULL ? TRUE : FALSE;
|
|
|
|
|
2012-04-23 23:10:16 +00:00
|
|
|
object->priv->ignore_notifies = TRUE;
|
2013-01-26 15:31:33 +00:00
|
|
|
for (tmp = object->trackelements; tmp; tmp = g_list_next (tmp)) {
|
|
|
|
tr = (GESTrackElement *) tmp->data;
|
2009-08-07 18:33:18 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (ges_track_element_is_locked (tr)) {
|
|
|
|
/* call set_duration on each trackelement
|
2012-04-22 17:09:11 +00:00
|
|
|
* and make the snapping happen if in a timeline */
|
|
|
|
if (G_LIKELY (snap))
|
|
|
|
ges_timeline_trim_object_simple (timeline, tr, NULL, GES_EDGE_END,
|
2013-01-15 13:52:17 +00:00
|
|
|
_START (tr) + duration, TRUE);
|
2012-04-22 17:09:11 +00:00
|
|
|
else
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_duration0 (GES_TIMELINE_ELEMENT (tr), duration);
|
2012-04-22 17:09:11 +00:00
|
|
|
}
|
2009-08-07 18:33:18 +00:00
|
|
|
}
|
2012-04-23 23:10:16 +00:00
|
|
|
object->priv->ignore_notifies = FALSE;
|
2009-08-07 18:33:18 +00:00
|
|
|
|
2011-11-08 22:29:38 +00:00
|
|
|
return TRUE;
|
2009-08-07 18:33:18 +00:00
|
|
|
}
|
|
|
|
|
2011-11-08 22:29:38 +00:00
|
|
|
static gboolean
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_priority (GESTimelineElement * element, guint32 priority)
|
2009-08-07 18:33:18 +00:00
|
|
|
{
|
2010-12-16 15:27:26 +00:00
|
|
|
GList *tmp;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *tr;
|
2010-12-16 18:29:14 +00:00
|
|
|
ObjectMapping *map;
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClipPrivate *priv;
|
2011-04-15 23:34:28 +00:00
|
|
|
guint32 layer_min_gnl_prio, layer_max_gnl_prio;
|
2010-12-16 18:29:14 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *object = GES_CLIP (element);
|
2009-08-07 18:33:18 +00:00
|
|
|
|
2011-12-07 23:50:13 +00:00
|
|
|
priv = object->priv;
|
2011-04-15 23:34:28 +00:00
|
|
|
|
|
|
|
get_layer_priorities (priv->layer, &layer_min_gnl_prio, &layer_max_gnl_prio);
|
|
|
|
|
2012-04-23 23:10:16 +00:00
|
|
|
priv->ignore_notifies = TRUE;
|
2013-01-26 15:31:33 +00:00
|
|
|
for (tmp = object->trackelements; tmp; tmp = g_list_next (tmp)) {
|
|
|
|
tr = (GESTrackElement *) tmp->data;
|
2010-12-16 18:29:14 +00:00
|
|
|
map = find_object_mapping (object, tr);
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (ges_track_element_is_locked (tr)) {
|
2011-04-15 23:34:28 +00:00
|
|
|
guint32 real_tck_prio;
|
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
/* Move the child... */
|
2011-04-15 23:34:28 +00:00
|
|
|
real_tck_prio = layer_min_gnl_prio + priority + map->priority_offset;
|
|
|
|
|
|
|
|
if (real_tck_prio > layer_max_gnl_prio) {
|
|
|
|
GST_WARNING ("%p priority of %i, is outside of the its containing "
|
|
|
|
"layer space. (%d/%d) setting it to the maximum it can be", object,
|
|
|
|
priority, layer_min_gnl_prio, layer_max_gnl_prio);
|
|
|
|
|
|
|
|
real_tck_prio = layer_max_gnl_prio;
|
|
|
|
}
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_priority0 (GES_TIMELINE_ELEMENT (tr), real_tck_prio);
|
2011-04-15 23:34:28 +00:00
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
} else {
|
|
|
|
/* ... or update the offset */
|
2013-01-15 13:52:17 +00:00
|
|
|
map->priority_offset = _PRIORITY (tr) - layer_min_gnl_prio + priority;
|
2010-12-16 18:29:14 +00:00
|
|
|
}
|
2009-08-07 18:33:18 +00:00
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
object->trackelements = g_list_sort_with_data (object->trackelements,
|
2011-02-16 13:30:22 +00:00
|
|
|
(GCompareDataFunc) sort_track_effects, object);
|
|
|
|
priv->ignore_notifies = FALSE;
|
2010-12-16 18:29:14 +00:00
|
|
|
|
2011-11-08 22:29:38 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-06-06 19:55:47 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_set_moving_from_layer:
|
|
|
|
* @object: a #GESClip
|
2011-06-06 19:55:47 +00:00
|
|
|
* @is_moving: %TRUE if you want to start moving @object to another layer
|
|
|
|
* %FALSE when you finished moving it.
|
|
|
|
*
|
|
|
|
* Sets the object in a moving to layer state. You might rather use the
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_move_to_layer function to move #GESClip-s
|
2011-06-06 19:55:47 +00:00
|
|
|
* from a layer to another.
|
|
|
|
**/
|
|
|
|
void
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_set_moving_from_layer (GESClip * object, gboolean is_moving)
|
2011-06-06 19:55:47 +00:00
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_if_fail (GES_IS_CLIP (object));
|
2011-12-07 23:50:13 +00:00
|
|
|
|
2011-06-06 19:55:47 +00:00
|
|
|
object->priv->is_moving = is_moving;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_is_moving_from_layer:
|
|
|
|
* @object: a #GESClip
|
2011-06-06 19:55:47 +00:00
|
|
|
*
|
|
|
|
* Tells you if the object is currently moving from a layer to another.
|
2013-01-20 15:42:29 +00:00
|
|
|
* You might rather use the ges_clip_move_to_layer function to
|
|
|
|
* move #GESClip-s from a layer to another.
|
2011-06-06 19:55:47 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @object is currently moving from its current layer
|
|
|
|
* %FALSE otherwize
|
|
|
|
**/
|
|
|
|
gboolean
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_is_moving_from_layer (GESClip * object)
|
2011-06-06 19:55:47 +00:00
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), FALSE);
|
2012-04-20 23:02:19 +00:00
|
|
|
|
2011-06-06 19:55:47 +00:00
|
|
|
return object->priv->is_moving;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_move_to_layer:
|
|
|
|
* @object: a #GESClip
|
2011-06-06 19:55:47 +00:00
|
|
|
* @layer: the new #GESTimelineLayer
|
|
|
|
*
|
|
|
|
* Moves @object to @layer. If @object is not in any layer, it adds it to
|
|
|
|
* @layer, else, it removes it from its current layer, and adds it to @layer.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @object could be moved %FALSE otherwize
|
|
|
|
*/
|
|
|
|
gboolean
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_move_to_layer (GESClip * object, GESTimelineLayer * layer)
|
2011-06-06 19:55:47 +00:00
|
|
|
{
|
|
|
|
gboolean ret;
|
2011-12-07 23:50:13 +00:00
|
|
|
GESTimelineLayer *current_layer;
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), FALSE);
|
2011-12-07 23:50:13 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), FALSE);
|
|
|
|
|
|
|
|
current_layer = object->priv->layer;
|
2011-06-06 19:55:47 +00:00
|
|
|
|
|
|
|
if (current_layer == NULL) {
|
|
|
|
GST_DEBUG ("Not moving %p, only adding it to %p", object, layer);
|
|
|
|
|
|
|
|
return ges_timeline_layer_add_object (layer, object);
|
|
|
|
}
|
|
|
|
|
2012-01-20 20:03:58 +00:00
|
|
|
GST_DEBUG_OBJECT (object, "moving to layer %p, priority: %d", layer,
|
|
|
|
ges_timeline_layer_get_priority (layer));
|
|
|
|
|
2011-06-06 19:55:47 +00:00
|
|
|
object->priv->is_moving = TRUE;
|
|
|
|
g_object_ref (object);
|
|
|
|
ret = ges_timeline_layer_remove_object (current_layer, object);
|
|
|
|
|
|
|
|
if (!ret) {
|
|
|
|
g_object_unref (object);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ges_timeline_layer_add_object (layer, object);
|
|
|
|
object->priv->is_moving = FALSE;
|
|
|
|
|
|
|
|
g_object_unref (object);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-03-12 16:17:30 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_clip_find_track_element:
|
2013-01-20 15:42:29 +00:00
|
|
|
* @object: a #GESClip
|
2010-07-13 16:42:46 +00:00
|
|
|
* @track: a #GESTrack or NULL
|
|
|
|
* @type: a #GType indicating the type of track object you are looking
|
|
|
|
* for or %G_TYPE_NONE if you do not care about the track type.
|
2010-03-12 16:17:30 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Finds the #GESTrackElement controlled by @object that is used in @track. You
|
2010-07-13 16:42:46 +00:00
|
|
|
* may optionally specify a GType to further narrow search criteria.
|
2010-03-12 16:17:30 +00:00
|
|
|
*
|
2011-05-06 17:38:26 +00:00
|
|
|
* Note: If many objects match, then the one with the highest priority will be
|
|
|
|
* returned.
|
2010-03-12 16:17:30 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Returns: (transfer full): The #GESTrackElement used by @track, else %NULL.
|
2011-05-06 17:38:26 +00:00
|
|
|
* Unref after usage.
|
2010-03-12 16:17:30 +00:00
|
|
|
*/
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *
|
|
|
|
ges_clip_find_track_element (GESClip * object, GESTrack * track, GType type)
|
2010-03-12 16:17:30 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *ret = NULL;
|
2010-12-16 15:27:26 +00:00
|
|
|
GList *tmp;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *otmp;
|
2010-03-12 16:17:30 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), NULL);
|
2011-05-06 17:40:22 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TRACK (track), NULL);
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
for (tmp = object->trackelements; tmp; tmp = g_list_next (tmp)) {
|
|
|
|
otmp = (GESTrackElement *) tmp->data;
|
2010-12-16 14:00:46 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (ges_track_element_get_track (otmp) == track) {
|
2011-05-06 17:40:22 +00:00
|
|
|
if ((type != G_TYPE_NONE) &&
|
|
|
|
!G_TYPE_CHECK_INSTANCE_TYPE (tmp->data, type))
|
2010-12-16 15:27:26 +00:00
|
|
|
continue;
|
2010-07-13 16:42:46 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
ret = GES_TRACK_ELEMENT (tmp->data);
|
2010-12-16 15:27:26 +00:00
|
|
|
g_object_ref (ret);
|
|
|
|
break;
|
2010-12-16 14:00:46 +00:00
|
|
|
}
|
2010-03-12 16:17:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2010-07-09 11:49:23 +00:00
|
|
|
|
2010-11-28 12:24:07 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_get_layer:
|
|
|
|
* @object: a #GESClip
|
2010-11-28 12:24:07 +00:00
|
|
|
*
|
2011-05-06 17:38:26 +00:00
|
|
|
* Get the #GESTimelineLayer to which this object belongs.
|
2010-11-28 12:24:07 +00:00
|
|
|
*
|
2011-05-06 17:38:26 +00:00
|
|
|
* Returns: (transfer full): The #GESTimelineLayer where this @object is being
|
2011-05-09 12:24:26 +00:00
|
|
|
* used, or %NULL if it is not used on any layer. The caller should unref it
|
2011-05-06 17:38:26 +00:00
|
|
|
* usage.
|
2010-11-28 12:24:07 +00:00
|
|
|
*/
|
|
|
|
GESTimelineLayer *
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_get_layer (GESClip * object)
|
2010-11-28 12:24:07 +00:00
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), NULL);
|
2010-11-28 12:24:07 +00:00
|
|
|
|
|
|
|
if (object->priv->layer != NULL)
|
|
|
|
g_object_ref (G_OBJECT (object->priv->layer));
|
|
|
|
|
|
|
|
return object->priv->layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_clip_get_track_elements:
|
2013-01-20 15:42:29 +00:00
|
|
|
* @object: a #GESClip
|
2010-11-28 12:24:07 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Get the list of #GESTrackElement contained in @object
|
2011-01-10 13:28:35 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Returns: (transfer full) (element-type GESTrackElement): The list of
|
|
|
|
* trackelement contained in @object.
|
2011-01-31 10:33:56 +00:00
|
|
|
* The user is responsible for unreffing the contained objects
|
2010-11-28 12:24:07 +00:00
|
|
|
* and freeing the list.
|
|
|
|
*/
|
|
|
|
GList *
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_clip_get_track_elements (GESClip * object)
|
2010-11-28 12:24:07 +00:00
|
|
|
{
|
|
|
|
GList *ret;
|
|
|
|
GList *tmp;
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), NULL);
|
2010-11-28 12:24:07 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
ret = g_list_copy (object->trackelements);
|
2010-11-28 12:24:07 +00:00
|
|
|
|
|
|
|
for (tmp = ret; tmp; tmp = tmp->next) {
|
|
|
|
g_object_ref (tmp->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-02-16 13:30:22 +00:00
|
|
|
static gint
|
2013-01-20 15:42:29 +00:00
|
|
|
sort_track_effects (gpointer a, gpointer b, GESClip * object)
|
2011-01-31 10:15:33 +00:00
|
|
|
{
|
|
|
|
guint prio_offset_a, prio_offset_b;
|
|
|
|
ObjectMapping *map_a, *map_b;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *obj_a, *obj_b;
|
2011-01-31 10:15:33 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
obj_a = GES_TRACK_ELEMENT (a);
|
|
|
|
obj_b = GES_TRACK_ELEMENT (b);
|
2011-01-31 10:15:33 +00:00
|
|
|
|
|
|
|
map_a = find_object_mapping (object, obj_a);
|
|
|
|
map_b = find_object_mapping (object, obj_b);
|
|
|
|
|
|
|
|
prio_offset_a = map_a->priority_offset;
|
|
|
|
prio_offset_b = map_b->priority_offset;
|
|
|
|
|
|
|
|
if ((gint) prio_offset_a > (guint) prio_offset_b)
|
|
|
|
return 1;
|
|
|
|
if ((guint) prio_offset_a < (guint) prio_offset_b)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-31 10:32:14 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_get_top_effects:
|
|
|
|
* @object: The origin #GESClip
|
2011-05-07 14:59:06 +00:00
|
|
|
*
|
|
|
|
* Get effects applied on @object
|
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Returns: (transfer full) (element-type GESTrackElement): a #GList of the
|
2011-05-07 14:59:06 +00:00
|
|
|
* #GESTrackEffect that are applied on @object order by ascendant priorities.
|
|
|
|
* The refcount of the objects will be increased. The user will have to
|
|
|
|
* unref each #GESTrackEffect and free the #GList.
|
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
|
|
|
*/
|
2011-01-31 10:32:14 +00:00
|
|
|
GList *
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_get_top_effects (GESClip * object)
|
2011-01-31 10:32:14 +00:00
|
|
|
{
|
|
|
|
GList *tmp, *ret;
|
2011-02-16 16:45:05 +00:00
|
|
|
guint i;
|
2011-01-31 10:32:14 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), NULL);
|
2011-12-07 23:50:13 +00:00
|
|
|
|
2011-12-18 00:49:24 +00:00
|
|
|
GST_DEBUG_OBJECT (object, "Getting the %i top effects",
|
|
|
|
object->priv->nb_effects);
|
2011-01-31 10:32:14 +00:00
|
|
|
ret = NULL;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
for (tmp = object->trackelements, i = 0; i < object->priv->nb_effects;
|
2011-02-16 16:45:05 +00:00
|
|
|
tmp = tmp->next, i++) {
|
2011-12-18 00:49:24 +00:00
|
|
|
ret = g_list_append (ret, g_object_ref (tmp->data));
|
2011-01-31 10:32:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2010-12-16 15:27:26 +00:00
|
|
|
|
2011-01-31 10:41:37 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_get_top_effect_position:
|
|
|
|
* @object: The origin #GESClip
|
2011-05-07 14:59:06 +00:00
|
|
|
* @effect: The #GESTrackEffect we want to get the top position from
|
|
|
|
*
|
|
|
|
* Gets the top position of an effect.
|
|
|
|
*
|
|
|
|
* Returns: The top position of the effect, -1 if something went wrong.
|
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
|
|
|
*/
|
2011-01-31 10:41:37 +00:00
|
|
|
gint
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_get_top_effect_position (GESClip * object, GESTrackEffect * effect)
|
2011-01-31 10:41:37 +00:00
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), -1);
|
2011-12-07 23:50:13 +00:00
|
|
|
|
2011-01-31 10:41:37 +00:00
|
|
|
return find_object_mapping (object,
|
2013-01-26 15:31:33 +00:00
|
|
|
GES_TRACK_ELEMENT (effect))->priority_offset;
|
2011-01-31 10:41:37 +00:00
|
|
|
}
|
|
|
|
|
2011-02-04 10:44:19 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_set_top_effect_priority:
|
|
|
|
* @object: The origin #GESClip
|
2011-05-07 14:59:06 +00:00
|
|
|
* @effect: The #GESTrackEffect to move
|
|
|
|
* @newpriority: the new position at which to move the @effect inside this
|
2013-01-20 15:42:29 +00:00
|
|
|
* #GESClip
|
2011-05-07 14:59:06 +00:00
|
|
|
*
|
|
|
|
* This is a convenience method that lets you set the priority of a top effect.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @effect was successfuly moved, %FALSE otherwise.
|
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
|
|
|
*/
|
2011-02-04 10:44:19 +00:00
|
|
|
gboolean
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_set_top_effect_priority (GESClip * object,
|
2011-02-16 13:05:14 +00:00
|
|
|
GESTrackEffect * effect, guint newpriority)
|
2011-02-04 10:44:19 +00:00
|
|
|
{
|
2011-02-16 16:51:21 +00:00
|
|
|
gint inc;
|
2011-12-07 23:50:13 +00:00
|
|
|
GList *tmp;
|
|
|
|
guint current_prio;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *tck_obj;
|
2011-12-07 23:50:13 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), FALSE);
|
2011-12-07 23:50:13 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
tck_obj = GES_TRACK_ELEMENT (effect);
|
2013-01-15 13:52:17 +00:00
|
|
|
current_prio = _PRIORITY (tck_obj);
|
2011-02-04 10:44:19 +00:00
|
|
|
|
|
|
|
/* We don't change the priority */
|
2011-02-16 16:51:21 +00:00
|
|
|
if (current_prio == newpriority ||
|
2013-01-26 15:31:33 +00:00
|
|
|
(G_UNLIKELY (ges_track_element_get_clip (tck_obj) != object)))
|
2011-02-04 10:44:19 +00:00
|
|
|
return FALSE;
|
2011-02-16 16:51:21 +00:00
|
|
|
|
|
|
|
if (newpriority > (object->priv->nb_effects - 1)) {
|
|
|
|
GST_DEBUG ("You are trying to make %p not a top effect", effect);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (current_prio > object->priv->nb_effects) {
|
2012-04-17 15:18:21 +00:00
|
|
|
GST_DEBUG ("%p is not a top effect", effect);
|
2011-02-16 16:51:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
if (_PRIORITY (tck_obj) < newpriority)
|
2011-02-04 10:44:19 +00:00
|
|
|
inc = -1;
|
|
|
|
else
|
|
|
|
inc = +1;
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_priority0 (GES_TIMELINE_ELEMENT (tck_obj), newpriority);
|
2013-01-26 15:31:33 +00:00
|
|
|
for (tmp = object->trackelements; tmp; tmp = tmp->next) {
|
|
|
|
GESTrackElement *tmpo = GES_TRACK_ELEMENT (tmp->data);
|
2013-01-15 13:52:17 +00:00
|
|
|
guint tck_priority = _PRIORITY (tmpo);
|
2011-02-04 10:44:19 +00:00
|
|
|
|
|
|
|
if ((inc == +1 && tck_priority >= newpriority) ||
|
|
|
|
(inc == -1 && tck_priority <= newpriority)) {
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_priority0 (GES_TIMELINE_ELEMENT (tmpo), tck_priority + inc);
|
2011-02-04 10:44:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
object->trackelements = g_list_sort_with_data (object->trackelements,
|
2011-02-04 10:44:19 +00:00
|
|
|
(GCompareDataFunc) sort_track_effects, object);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_edit:
|
|
|
|
* @object: the #GESClip to edit
|
2012-04-24 00:52:45 +00:00
|
|
|
* @layers: (element-type GESTimelineLayer): The layers you want the edit to
|
|
|
|
* happen in, %NULL means that the edition is done in all the
|
|
|
|
* #GESTimelineLayers contained in the current timeline.
|
|
|
|
* @new_layer_priority: The priority of the layer @object should land in.
|
|
|
|
* If the layer you're trying to move the object to doesn't exist, it will
|
|
|
|
* be created automatically. -1 means no move.
|
|
|
|
* @mode: The #GESEditMode in which the editition will happen.
|
|
|
|
* @edge: The #GESEdge the edit should happen on.
|
|
|
|
* @position: The position at which to edit @object (in nanosecond)
|
|
|
|
*
|
|
|
|
* Edit @object in the different exisiting #GESEditMode modes. In the case of
|
|
|
|
* slide, and roll, you need to specify a #GESEdge
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the object as been edited properly, %FALSE if an error
|
|
|
|
* occured
|
|
|
|
*
|
|
|
|
* Since: 0.10.XX
|
|
|
|
*/
|
|
|
|
gboolean
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_edit (GESClip * object, GList * layers,
|
2012-04-24 00:52:45 +00:00
|
|
|
gint new_layer_priority, GESEditMode mode, GESEdge edge, guint64 position)
|
2011-08-24 09:48:14 +00:00
|
|
|
{
|
|
|
|
GList *tmp;
|
2012-04-24 00:52:45 +00:00
|
|
|
gboolean ret = TRUE;
|
|
|
|
GESTimelineLayer *layer;
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), FALSE);
|
2011-08-24 09:48:14 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (!G_UNLIKELY (object->trackelements)) {
|
2012-04-24 00:52:45 +00:00
|
|
|
GST_WARNING_OBJECT (object, "Trying to edit, but not containing"
|
2013-01-26 15:31:33 +00:00
|
|
|
"any TrackElement yet.");
|
2012-04-24 00:52:45 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
for (tmp = object->trackelements; tmp; tmp = g_list_next (tmp)) {
|
|
|
|
if (ges_track_element_is_locked (tmp->data)
|
2012-12-01 16:51:33 +00:00
|
|
|
&& GES_IS_TRACK_SOURCE (tmp->data)) {
|
2013-01-26 15:31:33 +00:00
|
|
|
ret &= ges_track_element_edit (tmp->data, layers, mode, edge, position);
|
2012-04-24 00:52:45 +00:00
|
|
|
break;
|
2011-08-24 09:48:14 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
/* Moving to layer */
|
|
|
|
if (new_layer_priority == -1) {
|
|
|
|
GST_DEBUG_OBJECT (object, "Not moving new prio %d", new_layer_priority);
|
|
|
|
} else {
|
|
|
|
gint priority_offset;
|
|
|
|
|
|
|
|
layer = object->priv->layer;
|
|
|
|
if (layer == NULL) {
|
|
|
|
GST_WARNING_OBJECT (object, "Not in any layer yet, not moving");
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
priority_offset = new_layer_priority -
|
|
|
|
ges_timeline_layer_get_priority (layer);
|
|
|
|
|
2012-04-22 17:09:11 +00:00
|
|
|
ret &= timeline_context_to_layer (layer->timeline, priority_offset);
|
2012-04-24 00:52:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2011-08-24 09:48:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_split:
|
|
|
|
* @object: the #GESClip to split
|
2012-04-20 23:22:56 +00:00
|
|
|
* @position: a #GstClockTime representing the position at which to split
|
2011-08-24 09:48:14 +00:00
|
|
|
*
|
2013-01-20 15:42:29 +00:00
|
|
|
* The function modifies @object, and creates another #GESClip so
|
2011-08-24 09:48:14 +00:00
|
|
|
* we have two clips at the end, splitted at the time specified by @position.
|
|
|
|
*
|
2013-01-20 15:42:29 +00:00
|
|
|
* Returns: (transfer floating): The newly created #GESClip resulting from the splitting
|
2011-08-24 09:48:14 +00:00
|
|
|
*/
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *
|
|
|
|
ges_clip_split (GESClip * object, guint64 position)
|
2011-08-24 09:48:14 +00:00
|
|
|
{
|
2012-04-20 23:19:49 +00:00
|
|
|
GList *tmp;
|
|
|
|
gboolean locked;
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *new_object;
|
2012-04-20 23:19:49 +00:00
|
|
|
|
|
|
|
GstClockTime start, inpoint, duration;
|
2011-08-24 09:48:14 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), NULL);
|
2012-04-20 23:22:56 +00:00
|
|
|
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (position), NULL);
|
2011-08-24 09:48:14 +00:00
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
duration = _DURATION (object);
|
|
|
|
start = _START (object);
|
|
|
|
inpoint = _INPOINT (object);
|
2011-08-24 09:48:14 +00:00
|
|
|
|
2012-04-20 23:19:49 +00:00
|
|
|
if (position >= start + duration || position <= start) {
|
|
|
|
GST_WARNING_OBJECT (object, "Can not split %" GST_TIME_FORMAT
|
|
|
|
" out of boundaries", GST_TIME_ARGS (position));
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-08-24 09:48:14 +00:00
|
|
|
|
2012-04-20 23:19:49 +00:00
|
|
|
GST_DEBUG_OBJECT (object, "Spliting at %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (position));
|
2011-08-24 09:48:14 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
/* Create the new Clip */
|
2013-01-15 13:52:17 +00:00
|
|
|
new_object =
|
2013-01-20 15:42:29 +00:00
|
|
|
GES_CLIP (ges_timeline_element_copy (GES_TIMELINE_ELEMENT
|
2013-01-15 13:52:17 +00:00
|
|
|
(object), FALSE));
|
2011-08-24 09:48:14 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
/* Set new timing properties on the Clip */
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_start0 (GES_TIMELINE_ELEMENT (new_object), position);
|
|
|
|
_set_inpoint0 (GES_TIMELINE_ELEMENT (new_object),
|
|
|
|
_INPOINT (object) + duration - (duration + start - position));
|
|
|
|
_set_duration0 (GES_TIMELINE_ELEMENT (new_object),
|
|
|
|
duration + start - position);
|
2012-04-20 23:19:49 +00:00
|
|
|
|
|
|
|
if (object->priv->layer) {
|
2013-01-26 15:31:33 +00:00
|
|
|
/* We do not want the timeline to create again TrackElement-s */
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_set_moving_from_layer (new_object, TRUE);
|
2012-04-20 23:19:49 +00:00
|
|
|
ges_timeline_layer_add_object (object->priv->layer, new_object);
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_set_moving_from_layer (new_object, FALSE);
|
2011-08-24 09:48:14 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 23:19:49 +00:00
|
|
|
/* We first set the new duration and the child mapping will be updated
|
2013-01-15 13:52:17 +00:00
|
|
|
* properly in the following loop
|
|
|
|
* FIXME: Avoid setting it oureself reworking the API */
|
|
|
|
GES_TIMELINE_ELEMENT (object)->duration = position - _START (object);
|
2013-01-26 15:31:33 +00:00
|
|
|
for (tmp = object->trackelements; tmp; tmp = tmp->next) {
|
2012-04-20 23:19:49 +00:00
|
|
|
GESTrack *track;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *new_trackelement, *trackelement =
|
|
|
|
GES_TRACK_ELEMENT (tmp->data);
|
2012-04-20 23:19:49 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
duration = _DURATION (trackelement);
|
|
|
|
start = _START (trackelement);
|
|
|
|
inpoint = _INPOINT (trackelement);
|
2012-04-20 23:19:49 +00:00
|
|
|
|
|
|
|
if (position <= start || position >= (start + duration)) {
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_DEBUG_OBJECT (trackelement,
|
|
|
|
"Outside %" GST_TIME_FORMAT "the boundaries "
|
2012-04-20 23:19:49 +00:00
|
|
|
"not copying it ( start %" GST_TIME_FORMAT ", end %" GST_TIME_FORMAT
|
2013-01-26 15:31:33 +00:00
|
|
|
")", GST_TIME_ARGS (position), GST_TIME_ARGS (_START (trackelement)),
|
|
|
|
GST_TIME_ARGS (_START (trackelement) + _DURATION (trackelement)));
|
2012-04-20 23:19:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
new_trackelement =
|
|
|
|
GES_TRACK_ELEMENT (ges_timeline_element_copy (GES_TIMELINE_ELEMENT
|
|
|
|
(trackelement), TRUE));
|
|
|
|
if (new_trackelement == NULL) {
|
|
|
|
GST_WARNING_OBJECT (trackelement, "Could not create a copy");
|
2012-04-20 23:19:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_clip_add_track_element (new_object, new_trackelement);
|
2012-04-20 23:19:49 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
track = ges_track_element_get_track (trackelement);
|
2012-04-20 23:19:49 +00:00
|
|
|
if (track == NULL)
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_DEBUG_OBJECT (trackelement, "Was not in a track, not adding %p to"
|
|
|
|
"any track", new_trackelement);
|
2012-04-20 23:19:49 +00:00
|
|
|
else
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_add_object (track, new_trackelement);
|
2012-04-20 23:19:49 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
/* Unlock TrackElement-s as we do not want the container to move
|
2012-04-20 23:19:49 +00:00
|
|
|
* syncronously */
|
2013-01-26 15:31:33 +00:00
|
|
|
locked = ges_track_element_is_locked (trackelement);
|
|
|
|
ges_track_element_set_locked (new_trackelement, FALSE);
|
|
|
|
ges_track_element_set_locked (trackelement, FALSE);
|
2012-04-20 23:19:49 +00:00
|
|
|
|
|
|
|
/* Set 'new' track object timing propeties */
|
2013-01-26 15:31:33 +00:00
|
|
|
_set_start0 (GES_TIMELINE_ELEMENT (new_trackelement), position);
|
|
|
|
_set_inpoint0 (GES_TIMELINE_ELEMENT (new_trackelement),
|
2013-01-15 13:52:17 +00:00
|
|
|
inpoint + duration - (duration + start - position));
|
2013-01-26 15:31:33 +00:00
|
|
|
_set_duration0 (GES_TIMELINE_ELEMENT (new_trackelement),
|
2013-01-15 13:52:17 +00:00
|
|
|
duration + start - position);
|
2012-04-20 23:19:49 +00:00
|
|
|
|
|
|
|
/* Set 'old' track object duration */
|
2013-01-26 15:31:33 +00:00
|
|
|
_set_duration0 (GES_TIMELINE_ELEMENT (trackelement), position - start);
|
2012-04-20 23:19:49 +00:00
|
|
|
|
|
|
|
/* And let track objects in the same locking state as before. */
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_locked (trackelement, locked);
|
|
|
|
ges_track_element_set_locked (new_trackelement, locked);
|
2012-04-20 23:19:49 +00:00
|
|
|
}
|
2011-08-24 09:48:14 +00:00
|
|
|
|
|
|
|
return new_object;
|
|
|
|
}
|
|
|
|
|
2011-12-07 23:17:55 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_set_supported_formats:
|
|
|
|
* @object: the #GESClip to set supported formats on
|
2011-12-07 23:17:55 +00:00
|
|
|
* @supportedformats: the #GESTrackType defining formats supported by @object
|
|
|
|
*
|
|
|
|
* Sets the formats supported by the file.
|
|
|
|
*
|
|
|
|
* Since: 0.10.XX
|
|
|
|
*/
|
|
|
|
void
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_set_supported_formats (GESClip * object, GESTrackType supportedformats)
|
2011-12-07 23:17:55 +00:00
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_if_fail (GES_IS_CLIP (object));
|
2011-12-07 23:17:55 +00:00
|
|
|
|
|
|
|
object->priv->supportedformats = supportedformats;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_get_supported_formats:
|
|
|
|
* @object: the #GESClip
|
2011-12-07 23:17:55 +00:00
|
|
|
*
|
|
|
|
* Get the formats supported by @object.
|
|
|
|
*
|
|
|
|
* Returns: The formats supported by @object.
|
|
|
|
*
|
|
|
|
* Since: 0.10.XX
|
|
|
|
*/
|
|
|
|
GESTrackType
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_get_supported_formats (GESClip * object)
|
2011-12-07 23:17:55 +00:00
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), GES_TRACK_TYPE_UNKNOWN);
|
2011-12-07 23:17:55 +00:00
|
|
|
|
|
|
|
return object->priv->supportedformats;
|
|
|
|
}
|
|
|
|
|
2011-12-07 23:36:24 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_objects_set_locked:
|
|
|
|
* @object: the #GESClip
|
2013-01-26 15:31:33 +00:00
|
|
|
* @locked: whether the #GESTrackElement contained in @object are locked to it.
|
2011-12-07 23:36:24 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Set the locking status of all the #GESTrackElement contained in @object to @locked.
|
|
|
|
* See the ges_track_element_set_locked documentation for more details.
|
2011-12-07 23:36:24 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.XX
|
|
|
|
*/
|
|
|
|
void
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_objects_set_locked (GESClip * object, gboolean locked)
|
2011-12-07 23:36:24 +00:00
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_if_fail (GES_IS_CLIP (object));
|
2011-12-07 23:36:24 +00:00
|
|
|
|
|
|
|
for (tmp = object->priv->mappings; tmp; tmp = g_list_next (tmp)) {
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_locked (((ObjectMapping *) tmp->data)->object,
|
|
|
|
locked);
|
2011-12-07 23:36:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
gboolean
|
2013-01-15 13:52:17 +00:00
|
|
|
_ripple (GESTimelineElement * element, GstClockTime start)
|
2012-04-24 00:52:45 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GList *tmp, *trackelements;
|
2012-04-24 00:52:45 +00:00
|
|
|
gboolean ret = TRUE;
|
|
|
|
GESTimeline *timeline;
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *object = GES_CLIP (element);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
timeline = ges_timeline_layer_get_timeline (object->priv->layer);
|
|
|
|
|
|
|
|
if (timeline == NULL) {
|
|
|
|
GST_DEBUG ("Not in a timeline yet");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
trackelements = ges_clip_get_track_elements (object);
|
|
|
|
for (tmp = trackelements; tmp; tmp = g_list_next (tmp)) {
|
|
|
|
if (ges_track_element_is_locked (tmp->data)) {
|
|
|
|
ret = timeline_ripple_object (timeline, GES_TRACK_ELEMENT (tmp->data),
|
2012-04-24 00:52:45 +00:00
|
|
|
NULL, GES_EDGE_NONE, start);
|
|
|
|
/* As we work only with locked objects, the changes will be reflected
|
2013-01-26 15:31:33 +00:00
|
|
|
* to others controlled TrackElements */
|
2012-04-24 00:52:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-01-26 15:31:33 +00:00
|
|
|
g_list_free_full (trackelements, g_object_unref);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
static gboolean
|
|
|
|
_ripple_end (GESTimelineElement * element, GstClockTime end)
|
2012-04-24 00:52:45 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GList *tmp, *trackelements;
|
2012-04-24 00:52:45 +00:00
|
|
|
gboolean ret = TRUE;
|
|
|
|
GESTimeline *timeline;
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *object = GES_CLIP (element);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
timeline = ges_timeline_layer_get_timeline (object->priv->layer);
|
|
|
|
|
|
|
|
if (timeline == NULL) {
|
|
|
|
GST_DEBUG ("Not in a timeline yet");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
trackelements = ges_clip_get_track_elements (object);
|
|
|
|
for (tmp = trackelements; tmp; tmp = g_list_next (tmp)) {
|
|
|
|
if (ges_track_element_is_locked (tmp->data)) {
|
|
|
|
ret = timeline_ripple_object (timeline, GES_TRACK_ELEMENT (tmp->data),
|
2012-04-24 00:52:45 +00:00
|
|
|
NULL, GES_EDGE_END, end);
|
|
|
|
/* As we work only with locked objects, the changes will be reflected
|
2013-01-26 15:31:33 +00:00
|
|
|
* to others controlled TrackElements */
|
2012-04-24 00:52:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-01-26 15:31:33 +00:00
|
|
|
g_list_free_full (trackelements, g_object_unref);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2013-01-15 13:52:17 +00:00
|
|
|
_roll_start (GESTimelineElement * element, GstClockTime start)
|
2012-04-24 00:52:45 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GList *tmp, *trackelements;
|
2012-04-24 00:52:45 +00:00
|
|
|
gboolean ret = TRUE;
|
|
|
|
GESTimeline *timeline;
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *object = GES_CLIP (element);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
timeline = ges_timeline_layer_get_timeline (object->priv->layer);
|
|
|
|
|
|
|
|
if (timeline == NULL) {
|
|
|
|
GST_DEBUG ("Not in a timeline yet");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
trackelements = ges_clip_get_track_elements (object);
|
|
|
|
for (tmp = trackelements; tmp; tmp = g_list_next (tmp)) {
|
|
|
|
if (ges_track_element_is_locked (tmp->data)) {
|
|
|
|
ret = timeline_roll_object (timeline, GES_TRACK_ELEMENT (tmp->data),
|
2012-04-24 00:52:45 +00:00
|
|
|
NULL, GES_EDGE_START, start);
|
|
|
|
/* As we work only with locked objects, the changes will be reflected
|
2013-01-26 15:31:33 +00:00
|
|
|
* to others controlled TrackElements */
|
2012-04-24 00:52:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-01-26 15:31:33 +00:00
|
|
|
g_list_free_full (trackelements, g_object_unref);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2013-01-15 13:52:17 +00:00
|
|
|
_roll_end (GESTimelineElement * element, GstClockTime end)
|
2012-04-24 00:52:45 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GList *tmp, *trackelements;
|
2012-04-24 00:52:45 +00:00
|
|
|
gboolean ret = TRUE;
|
|
|
|
GESTimeline *timeline;
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *object = GES_CLIP (element);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
timeline = ges_timeline_layer_get_timeline (object->priv->layer);
|
|
|
|
if (timeline == NULL) {
|
|
|
|
GST_DEBUG ("Not in a timeline yet");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
trackelements = ges_clip_get_track_elements (object);
|
|
|
|
for (tmp = trackelements; tmp; tmp = g_list_next (tmp)) {
|
|
|
|
if (ges_track_element_is_locked (tmp->data)) {
|
|
|
|
ret = timeline_roll_object (timeline, GES_TRACK_ELEMENT (tmp->data),
|
2012-04-24 00:52:45 +00:00
|
|
|
NULL, GES_EDGE_END, end);
|
|
|
|
/* As we work only with locked objects, the changes will be reflected
|
2013-01-26 15:31:33 +00:00
|
|
|
* to others controlled TrackElements */
|
2012-04-24 00:52:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-01-26 15:31:33 +00:00
|
|
|
g_list_free_full (trackelements, g_object_unref);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2013-01-15 13:52:17 +00:00
|
|
|
_trim (GESTimelineElement * element, GstClockTime start)
|
2012-04-24 00:52:45 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GList *tmp, *trackelements;
|
2012-04-24 00:52:45 +00:00
|
|
|
gboolean ret = TRUE;
|
|
|
|
GESTimeline *timeline;
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *object = GES_CLIP (element);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
timeline = ges_timeline_layer_get_timeline (object->priv->layer);
|
|
|
|
|
|
|
|
if (timeline == NULL) {
|
|
|
|
GST_DEBUG ("Not in a timeline yet");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
trackelements = ges_clip_get_track_elements (object);
|
|
|
|
for (tmp = trackelements; tmp; tmp = g_list_next (tmp)) {
|
|
|
|
if (ges_track_element_is_locked (tmp->data)) {
|
|
|
|
ret = timeline_trim_object (timeline, GES_TRACK_ELEMENT (tmp->data),
|
2012-04-24 00:52:45 +00:00
|
|
|
NULL, GES_EDGE_START, start);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-01-26 15:31:33 +00:00
|
|
|
g_list_free_full (trackelements, g_object_unref);
|
2012-04-24 00:52:45 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-11-27 15:18:27 +00:00
|
|
|
/**
|
2013-01-20 15:42:29 +00:00
|
|
|
* ges_clip_add_asset:
|
|
|
|
* @object: a #GESClip
|
2013-01-26 15:31:33 +00:00
|
|
|
* @asset: a #GESAsset with #GES_TYPE_TRACK_ELEMENT as extractable_type
|
2012-11-27 15:18:27 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Extracts a #GESTrackElement from @asset and adds it to the @object.
|
2013-01-20 15:42:29 +00:00
|
|
|
* Should only be called in order to add operations to a #GESClip,
|
2013-01-26 15:31:33 +00:00
|
|
|
* ni other cases TrackElement are added automatically when adding the
|
2013-01-20 15:42:29 +00:00
|
|
|
* #GESClip/#GESAsset to a layer.
|
2012-11-27 15:18:27 +00:00
|
|
|
*
|
|
|
|
* Takes a reference on @trobj.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE on success, %FALSE on failure.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_add_asset (GESClip * object, GESAsset * asset)
|
2012-11-27 15:18:27 +00:00
|
|
|
{
|
2013-01-20 15:42:29 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CLIP (object), FALSE);
|
2012-11-27 15:18:27 +00:00
|
|
|
g_return_val_if_fail (GES_IS_ASSET (asset), FALSE);
|
|
|
|
g_return_val_if_fail (g_type_is_a (ges_asset_get_extractable_type
|
2013-01-26 15:31:33 +00:00
|
|
|
(asset), GES_TYPE_TRACK_ELEMENT), FALSE);
|
2012-11-27 15:18:27 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
return ges_clip_add_track_element (object,
|
|
|
|
GES_TRACK_ELEMENT (ges_asset_extract (asset, NULL)));
|
2012-11-27 15:18:27 +00:00
|
|
|
}
|
|
|
|
|
2011-02-01 20:14:29 +00:00
|
|
|
static void
|
2013-01-20 15:42:29 +00:00
|
|
|
update_height (GESClip * object)
|
2011-02-01 20:14:29 +00:00
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
guint32 min_prio = G_MAXUINT32, max_prio = 0;
|
|
|
|
|
|
|
|
/* Go over all childs and check if height has changed */
|
2013-01-26 15:31:33 +00:00
|
|
|
for (tmp = object->trackelements; tmp; tmp = tmp->next) {
|
2013-01-15 13:52:17 +00:00
|
|
|
guint tck_priority = _PRIORITY (tmp->data);
|
2011-02-01 20:14:29 +00:00
|
|
|
|
2011-02-03 14:40:05 +00:00
|
|
|
if (tck_priority < min_prio)
|
|
|
|
min_prio = tck_priority;
|
|
|
|
if (tck_priority > max_prio)
|
|
|
|
max_prio = tck_priority;
|
2011-02-01 20:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME : We only grow the height */
|
|
|
|
if (object->height < (max_prio - min_prio + 1)) {
|
|
|
|
object->height = max_prio - min_prio + 1;
|
2011-02-03 14:30:30 +00:00
|
|
|
GST_DEBUG ("Updating height %i", object->height);
|
2011-02-01 20:14:29 +00:00
|
|
|
#if GLIB_CHECK_VERSION(2,26,0)
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (object), properties[PROP_HEIGHT]);
|
|
|
|
#else
|
|
|
|
g_object_notify (G_OBJECT (object), "height");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-16 15:27:26 +00:00
|
|
|
/*
|
|
|
|
* PROPERTY NOTIFICATIONS FROM TRACK OBJECTS
|
|
|
|
*/
|
2010-12-16 18:29:14 +00:00
|
|
|
|
2010-07-09 11:49:23 +00:00
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
track_element_start_changed_cb (GESTrackElement * child,
|
2013-01-20 15:42:29 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESClip * object)
|
2010-07-09 11:49:23 +00:00
|
|
|
{
|
2010-12-16 18:29:14 +00:00
|
|
|
ObjectMapping *map;
|
2013-01-15 13:52:17 +00:00
|
|
|
GESTimelineElement *element = GES_TIMELINE_ELEMENT (object);
|
2010-12-16 18:29:14 +00:00
|
|
|
|
|
|
|
if (object->priv->ignore_notifies)
|
|
|
|
return;
|
|
|
|
|
|
|
|
map = find_object_mapping (object, child);
|
|
|
|
if (G_UNLIKELY (map == NULL))
|
|
|
|
/* something massively screwed up if we get this */
|
|
|
|
return;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (!ges_track_element_is_locked (child)) {
|
2010-12-16 18:29:14 +00:00
|
|
|
/* Update the internal start_offset */
|
2013-01-15 13:52:17 +00:00
|
|
|
map->start_offset = _START (element) - _START (child);
|
2010-12-16 18:29:14 +00:00
|
|
|
} else {
|
|
|
|
/* Or update the parent start */
|
2011-12-16 07:23:58 +00:00
|
|
|
object->priv->initiated_move = child;
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_start0 (element, _START (child) + map->start_offset);
|
2011-12-16 07:23:58 +00:00
|
|
|
object->priv->initiated_move = NULL;
|
2010-12-16 18:29:14 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-09 11:49:23 +00:00
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
track_element_inpoint_changed_cb (GESTrackElement * child,
|
2013-01-20 15:42:29 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESClip * object)
|
2010-12-16 18:29:14 +00:00
|
|
|
{
|
2012-03-30 07:40:50 +00:00
|
|
|
ObjectMapping *map;
|
2013-01-15 13:52:17 +00:00
|
|
|
GESTimelineElement *element = GES_TIMELINE_ELEMENT (object);
|
2012-03-30 07:40:50 +00:00
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
if (object->priv->ignore_notifies)
|
|
|
|
return;
|
2010-07-09 11:49:23 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
map = find_object_mapping (GES_CLIP (element), child);
|
2012-03-30 07:40:50 +00:00
|
|
|
if (G_UNLIKELY (map == NULL))
|
|
|
|
/* something massively screwed up if we get this */
|
|
|
|
return;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (!ges_track_element_is_locked (child)) {
|
2012-03-30 07:40:50 +00:00
|
|
|
/* Update the internal start_offset */
|
2013-01-15 13:52:17 +00:00
|
|
|
map->inpoint_offset = _INPOINT (element) - _INPOINT (child);
|
2012-03-30 07:40:50 +00:00
|
|
|
} else {
|
|
|
|
/* Or update the parent start */
|
|
|
|
object->priv->initiated_move = child;
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_inpoint0 (element, _INPOINT (child) + map->inpoint_offset);
|
2012-03-30 07:40:50 +00:00
|
|
|
object->priv->initiated_move = NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
}
|
2010-07-09 11:49:23 +00:00
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
track_element_duration_changed_cb (GESTrackElement * child,
|
2013-01-20 15:42:29 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESClip * object)
|
2010-12-16 18:29:14 +00:00
|
|
|
{
|
2012-03-30 07:40:50 +00:00
|
|
|
ObjectMapping *map;
|
2013-01-15 13:52:17 +00:00
|
|
|
GESTimelineElement *element = GES_TIMELINE_ELEMENT (object);
|
2012-03-30 07:40:50 +00:00
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
if (object->priv->ignore_notifies)
|
|
|
|
return;
|
|
|
|
|
2012-03-30 07:40:50 +00:00
|
|
|
map = find_object_mapping (object, child);
|
|
|
|
if (G_UNLIKELY (map == NULL))
|
|
|
|
/* something massively screwed up if we get this */
|
|
|
|
return;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (!ges_track_element_is_locked (child)) {
|
2012-03-30 07:40:50 +00:00
|
|
|
/* Update the internal start_offset */
|
2013-01-15 13:52:17 +00:00
|
|
|
map->duration_offset = _DURATION (element) - _DURATION (child);
|
2012-03-30 07:40:50 +00:00
|
|
|
} else {
|
|
|
|
/* Or update the parent start */
|
|
|
|
object->priv->initiated_move = child;
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_duration0 (element, _DURATION (child) + map->duration_offset);
|
2012-03-30 07:40:50 +00:00
|
|
|
object->priv->initiated_move = NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
track_element_priority_changed_cb (GESTrackElement * child,
|
2013-01-20 15:42:29 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESClip * object)
|
2010-12-16 18:29:14 +00:00
|
|
|
{
|
|
|
|
ObjectMapping *map;
|
2013-01-15 13:52:17 +00:00
|
|
|
GESTimelineElement *element = GES_TIMELINE_ELEMENT (object);
|
2011-04-15 23:34:28 +00:00
|
|
|
guint32 layer_min_gnl_prio, layer_max_gnl_prio;
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
guint tck_priority = _PRIORITY (child);
|
2011-02-03 14:40:05 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_DEBUG ("TrackElement %p priority changed to %i", child,
|
|
|
|
_PRIORITY (child));
|
2010-12-16 18:29:14 +00:00
|
|
|
|
|
|
|
if (object->priv->ignore_notifies)
|
|
|
|
return;
|
|
|
|
|
2011-02-03 14:40:05 +00:00
|
|
|
update_height (object);
|
2010-12-16 18:29:14 +00:00
|
|
|
map = find_object_mapping (object, child);
|
2011-04-15 23:34:28 +00:00
|
|
|
get_layer_priorities (object->priv->layer, &layer_min_gnl_prio,
|
|
|
|
&layer_max_gnl_prio);
|
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
if (G_UNLIKELY (map == NULL))
|
|
|
|
/* something massively screwed up if we get this */
|
|
|
|
return;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (!ges_track_element_is_locked (child)) {
|
2011-04-15 23:34:28 +00:00
|
|
|
if (tck_priority < layer_min_gnl_prio || tck_priority > layer_max_gnl_prio) {
|
|
|
|
GST_WARNING ("%p priority of %i, is outside of its containing "
|
2013-01-15 13:52:17 +00:00
|
|
|
"layer space. (%d/%d). This is a bug in the program.", element,
|
2011-04-15 23:34:28 +00:00
|
|
|
tck_priority, layer_min_gnl_prio, layer_max_gnl_prio);
|
|
|
|
}
|
|
|
|
|
2010-12-16 18:29:14 +00:00
|
|
|
/* Update the internal priority_offset */
|
2013-01-15 13:52:17 +00:00
|
|
|
map->priority_offset = tck_priority - (layer_min_gnl_prio +
|
|
|
|
_PRIORITY (element));
|
2011-04-15 23:34:28 +00:00
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
} else if (tck_priority < layer_min_gnl_prio + _PRIORITY (element)) {
|
|
|
|
/* Or update the parent priority, the element priority is always the
|
2011-02-03 14:40:05 +00:00
|
|
|
* highest priority (smaller number) */
|
2012-03-06 14:35:51 +00:00
|
|
|
if (tck_priority < layer_min_gnl_prio || layer_max_gnl_prio < tck_priority) {
|
2011-04-15 23:34:28 +00:00
|
|
|
|
|
|
|
GST_WARNING ("%p priority of %i, is outside of its containing "
|
2013-01-15 13:52:17 +00:00
|
|
|
"layer space. (%d/%d). This is a bug in the program.", element,
|
2011-04-15 23:34:28 +00:00
|
|
|
tck_priority, layer_min_gnl_prio, layer_max_gnl_prio);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
_set_priority0 (element, tck_priority - layer_min_gnl_prio);
|
2011-04-15 23:34:28 +00:00
|
|
|
}
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
GST_DEBUG_OBJECT (element, "priority %d child %p priority %d",
|
|
|
|
_PRIORITY (element), child, _PRIORITY (child));
|
2011-04-15 23:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_layer_priorities (GESTimelineLayer * layer, guint32 * layer_min_gnl_prio,
|
|
|
|
guint32 * layer_max_gnl_prio)
|
|
|
|
{
|
|
|
|
if (layer) {
|
|
|
|
*layer_min_gnl_prio = layer->min_gnl_priority;
|
|
|
|
*layer_max_gnl_prio = layer->max_gnl_priority;
|
|
|
|
} else {
|
|
|
|
*layer_min_gnl_prio = 0;
|
|
|
|
*layer_max_gnl_prio = G_MAXUINT32;
|
2010-07-09 11:49:23 +00:00
|
|
|
}
|
|
|
|
}
|