2009-08-04 15:16:31 +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
|
2009-08-04 15:16:31 +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:16:31 +00:00
|
|
|
*/
|
|
|
|
|
2009-09-10 16:40:51 +00:00
|
|
|
/**
|
2014-04-07 19:02:48 +00:00
|
|
|
* SECTION:gestrackelement
|
2017-03-08 21:13:48 +00:00
|
|
|
* @title: GESTrackElement
|
2020-01-15 14:46:02 +00:00
|
|
|
* @short_description: Base Class for the elements of a #GESTrack
|
2009-09-10 16:40:51 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* A #GESTrackElement is a #GESTimelineElement that specifically belongs
|
|
|
|
* to a single #GESTrack of its #GESTimelineElement:timeline. Its
|
|
|
|
* #GESTimelineElement:start and #GESTimelineElement:duration specify its
|
|
|
|
* temporal extent in the track. Specifically, a track element wraps some
|
|
|
|
* nleobject, such as an #nlesource or #nleoperation, which can be
|
|
|
|
* retrieved with ges_track_element_get_nleobject(), and its
|
|
|
|
* #GESTimelineElement:start, #GESTimelineElement:duration,
|
|
|
|
* #GESTimelineElement:in-point, #GESTimelineElement:priority and
|
|
|
|
* #GESTrackElement:active properties expose the corresponding nleobject
|
|
|
|
* properties. When a track element is added to a track, its nleobject is
|
|
|
|
* added to the corresponding #nlecomposition that the track wraps.
|
2009-09-14 14:33:25 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Most users will not have to work directly with track elements since a
|
|
|
|
* #GESClip will automatically create track elements for its timeline's
|
|
|
|
* tracks and take responsibility for updating them. The only track
|
|
|
|
* elements that are not automatically created by clips, but a user is
|
|
|
|
* likely to want to create, are #GESEffect-s.
|
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-08-06 17:51:29 +00:00
|
|
|
#include "ges-internal.h"
|
2012-11-20 02:42:47 +00:00
|
|
|
#include "ges-extractable.h"
|
2013-01-26 15:31:33 +00:00
|
|
|
#include "ges-track-element.h"
|
2013-01-20 15:42:29 +00:00
|
|
|
#include "ges-clip.h"
|
2012-11-20 21:25:31 +00:00
|
|
|
#include "ges-meta-container.h"
|
2009-08-04 15:16:31 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
struct _GESTrackElementPrivate
|
2010-12-04 18:54:13 +00:00
|
|
|
{
|
2012-12-20 23:23:54 +00:00
|
|
|
GESTrackType track_type;
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
GstElement *nleobject; /* The NleObject */
|
|
|
|
GstElement *element; /* The element contained in the nleobject (can be NULL) */
|
2010-12-16 14:00:46 +00:00
|
|
|
|
|
|
|
GESTrack *track;
|
|
|
|
|
2010-12-16 15:27:26 +00:00
|
|
|
gboolean locked; /* If TRUE, then moves in sync with its controlling
|
2013-01-20 15:42:29 +00:00
|
|
|
* GESClip */
|
2013-03-30 17:54:50 +00:00
|
|
|
|
|
|
|
GHashTable *bindings_hashtable; /* We need this if we want to be able to serialize
|
|
|
|
and deserialize keyframes */
|
2010-12-04 18:54:13 +00:00
|
|
|
};
|
|
|
|
|
2009-08-06 10:14:37 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2010-12-16 17:20:47 +00:00
|
|
|
PROP_ACTIVE,
|
2012-12-20 23:23:54 +00:00
|
|
|
PROP_TRACK_TYPE,
|
2013-01-10 21:09:23 +00:00
|
|
|
PROP_TRACK,
|
2010-12-16 17:20:47 +00:00
|
|
|
PROP_LAST
|
2009-08-06 10:14:37 +00:00
|
|
|
};
|
|
|
|
|
2010-12-16 17:20:47 +00:00
|
|
|
static GParamSpec *properties[PROP_LAST];
|
|
|
|
|
2011-02-08 14:29:21 +00:00
|
|
|
enum
|
|
|
|
{
|
2014-10-01 07:54:49 +00:00
|
|
|
CONTROL_BINDING_ADDED,
|
2015-06-16 13:02:18 +00:00
|
|
|
CONTROL_BINDING_REMOVED,
|
2011-02-08 14:29:21 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
static guint ges_track_element_signals[LAST_SIGNAL] = { 0 };
|
2011-02-08 14:29:21 +00:00
|
|
|
|
2018-09-06 01:55:02 +00:00
|
|
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GESTrackElement, ges_track_element,
|
|
|
|
GES_TYPE_TIMELINE_ELEMENT);
|
|
|
|
|
2015-06-25 08:32:46 +00:00
|
|
|
static GstElement *ges_track_element_create_gnl_object_func (GESTrackElement *
|
2010-12-16 14:00:46 +00:00
|
|
|
object);
|
2009-08-06 15:38:43 +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);
|
2015-06-23 11:27:00 +00:00
|
|
|
GESTrackType _get_track_types (GESTimelineElement * object);
|
2013-01-15 13:52:17 +00:00
|
|
|
|
2013-08-13 15:57:33 +00:00
|
|
|
static void
|
|
|
|
_update_control_bindings (GESTimelineElement * element, GstClockTime inpoint,
|
|
|
|
GstClockTime duration);
|
|
|
|
|
2014-10-29 12:40:55 +00:00
|
|
|
static gboolean
|
|
|
|
_lookup_child (GESTrackElement * object,
|
|
|
|
const gchar * prop_name, GstElement ** element, GParamSpec ** pspec)
|
|
|
|
{
|
2015-02-19 15:30:18 +00:00
|
|
|
return
|
|
|
|
GES_TIMELINE_ELEMENT_GET_CLASS (object)->lookup_child
|
|
|
|
(GES_TIMELINE_ELEMENT (object), prop_name, (GObject **) element, pspec);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
strv_find_str (const gchar ** strv, const char *str)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
if (strv == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for (i = 0; strv[i]; i++) {
|
|
|
|
if (g_strcmp0 (strv[i], str) == 0)
|
|
|
|
return TRUE;
|
2014-10-29 12:40:55 +00:00
|
|
|
}
|
|
|
|
|
2015-02-19 15:30:18 +00:00
|
|
|
return FALSE;
|
2014-10-29 12:40:55 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 22:08:39 +00:00
|
|
|
static guint32
|
|
|
|
_get_layer_priority (GESTimelineElement * element)
|
|
|
|
{
|
|
|
|
if (!element->parent)
|
|
|
|
return GES_TIMELINE_ELEMENT_NO_LAYER_PRIORITY;
|
|
|
|
|
|
|
|
return ges_timeline_element_get_layer_priority (element->parent);
|
|
|
|
}
|
|
|
|
|
2009-08-06 10:14:37 +00:00
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_get_property (GObject * object, guint property_id,
|
2009-08-06 10:14:37 +00:00
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2013-02-15 02:34:48 +00:00
|
|
|
GESTrackElement *track_element = GES_TRACK_ELEMENT (object);
|
2009-08-06 10:14:37 +00:00
|
|
|
|
|
|
|
switch (property_id) {
|
2009-09-30 14:40:59 +00:00
|
|
|
case PROP_ACTIVE:
|
2013-02-15 02:34:48 +00:00
|
|
|
g_value_set_boolean (value, ges_track_element_is_active (track_element));
|
2009-09-30 14:40:59 +00:00
|
|
|
break;
|
2012-12-20 23:23:54 +00:00
|
|
|
case PROP_TRACK_TYPE:
|
2013-02-15 02:34:48 +00:00
|
|
|
g_value_set_flags (value, track_element->priv->track_type);
|
2012-12-20 23:23:54 +00:00
|
|
|
break;
|
2013-01-10 21:09:23 +00:00
|
|
|
case PROP_TRACK:
|
2013-02-15 02:34:48 +00:00
|
|
|
g_value_set_object (value, track_element->priv->track);
|
2013-01-10 21:09:23 +00:00
|
|
|
break;
|
2009-08-06 10:14:37 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_property (GObject * object, guint property_id,
|
2009-08-06 10:14:37 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2013-02-15 02:34:48 +00:00
|
|
|
GESTrackElement *track_element = GES_TRACK_ELEMENT (object);
|
2009-08-06 10:14:37 +00:00
|
|
|
|
|
|
|
switch (property_id) {
|
2009-09-30 14:40:59 +00:00
|
|
|
case PROP_ACTIVE:
|
2013-02-15 02:34:48 +00:00
|
|
|
ges_track_element_set_active (track_element, g_value_get_boolean (value));
|
2009-09-30 14:40:59 +00:00
|
|
|
break;
|
2012-12-20 23:23:54 +00:00
|
|
|
case PROP_TRACK_TYPE:
|
2013-02-15 02:34:48 +00:00
|
|
|
track_element->priv->track_type = g_value_get_flags (value);
|
2012-12-20 23:23:54 +00:00
|
|
|
break;
|
2009-08-06 10:14:37 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_dispose (GObject * object)
|
2009-08-06 10:14:37 +00:00
|
|
|
{
|
2013-08-27 03:31:14 +00:00
|
|
|
GESTrackElement *element = GES_TRACK_ELEMENT (object);
|
|
|
|
GESTrackElementPrivate *priv = element->priv;
|
2011-02-07 16:06:01 +00:00
|
|
|
|
2013-03-30 17:54:50 +00:00
|
|
|
if (priv->bindings_hashtable)
|
|
|
|
g_hash_table_destroy (priv->bindings_hashtable);
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
if (priv->nleobject) {
|
2012-05-10 16:40:23 +00:00
|
|
|
GstState cstate;
|
|
|
|
|
|
|
|
if (priv->track != NULL) {
|
2013-03-15 03:01:47 +00:00
|
|
|
g_error ("%p Still in %p, this means that you forgot"
|
2012-05-10 16:40:23 +00:00
|
|
|
" to remove it from the GESTrack it is contained in. You always need"
|
2013-01-26 15:31:33 +00:00
|
|
|
" to remove a GESTrackElement from its track before dropping the last"
|
2012-05-10 16:40:23 +00:00
|
|
|
" reference\n"
|
|
|
|
"This problem may also be caused by a refcounting bug in"
|
2013-03-15 03:01:47 +00:00
|
|
|
" the application or GES itself.", object, priv->track);
|
2014-08-15 13:48:14 +00:00
|
|
|
gst_element_get_state (priv->nleobject, &cstate, NULL, 0);
|
2012-05-10 16:40:23 +00:00
|
|
|
if (cstate != GST_STATE_NULL)
|
2014-08-15 13:48:14 +00:00
|
|
|
gst_element_set_state (priv->nleobject, GST_STATE_NULL);
|
2012-05-10 16:40:23 +00:00
|
|
|
}
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
g_object_set_qdata (G_OBJECT (priv->nleobject),
|
|
|
|
NLE_OBJECT_TRACK_ELEMENT_QUARK, NULL);
|
|
|
|
gst_object_unref (priv->nleobject);
|
|
|
|
priv->nleobject = NULL;
|
2012-05-10 16:40:23 +00:00
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
G_OBJECT_CLASS (ges_track_element_parent_class)->dispose (object);
|
2009-08-06 10:14:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-01-25 15:11:14 +00:00
|
|
|
ges_track_element_constructed (GObject * gobject)
|
2009-08-06 10:14:37 +00:00
|
|
|
{
|
2016-01-25 15:11:14 +00:00
|
|
|
GESTrackElementClass *class;
|
|
|
|
GstElement *nleobject;
|
Handle changing playback rate
Before this patch, NLE and GES did not support NleOperations (respectively
GESEffects) that changed the speed/tempo/rate at which the source plays. For
example, the 'pitch' element can make audio play faster or slower. In GES 1.5.90
and before, an NleOperation containing the pitch element to change the rate (or
tempo) would cause a pipeline state change to PAUSED after that stack; that has
been fixed in 1.5.91 (see #755012 [0]). But even then, in 1.5.91 and later,
NleComposition would send segment events to its NleSources assuming that one
source second is equal to one pipeline second. The resulting early EOS event
(in the case of a source rate higher than 1.0) would cause it to switch stacks
too early, causing confusion in the timeline and spectacularly messed up
output.
This patch fixes that by searching for rate-changing elements in
GESTrackElements such as GESEffects. If such rate-changing elements are found,
their final effect on the playing rate is stored in the corresponding NleObject
as the 'media duration factor', named like this because the 'media duration',
or source duration, of an NleObject can be computed by multiplying the duration
with the media duration factor of that object and its parents (this is called
the 'recursive media duration factor'). For example, a 4-second NleSource with
an NleOperation with a media duration factor of 2.0 will have an 8-second media
duration, which means that for playing 4 seconds in the pipeline, the seek
event sent to it must span 8 seconds of media. (So, the 'duration' of an
NleObject or GES object always refers to its duration in the timeline, not the
media duration.)
To summarize:
* Rate-changing elements are registered in the GESEffectClass (pitch::tempo and
pitch::rate are registered by default);
* GESTimelineElement is responsible for detecting rate-changing elements and
computing the media_duration_factor;
* GESTrackElement is responsible for storing the media_duration_factor in
NleObject;
* NleComposition is responsible for the recursive_media_duration_factor;
* The latter property finally fixes media time computations in NleObject.
NLE and GES tests are included.
[0] https://bugzilla.gnome.org/show_bug.cgi?id=755012
Differential Revision: https://phabricator.freedesktop.org/D276
2015-12-20 13:03:57 +00:00
|
|
|
gdouble media_duration_factor;
|
2016-02-09 11:14:15 +00:00
|
|
|
gchar *tmp;
|
2016-01-25 15:11:14 +00:00
|
|
|
GESTrackElement *object = GES_TRACK_ELEMENT (gobject);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (object, "Creating NleObject");
|
|
|
|
|
|
|
|
class = GES_TRACK_ELEMENT_GET_CLASS (object);
|
|
|
|
g_assert (class->create_gnl_object);
|
|
|
|
|
|
|
|
nleobject = class->create_gnl_object (object);
|
|
|
|
if (G_UNLIKELY (nleobject == NULL)) {
|
|
|
|
GST_ERROR_OBJECT (object, "Could not create NleObject");
|
2016-01-25 10:56:57 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-02-09 11:14:15 +00:00
|
|
|
tmp = g_strdup_printf ("%s:%s", G_OBJECT_TYPE_NAME (object),
|
|
|
|
GST_OBJECT_NAME (nleobject));
|
|
|
|
gst_object_set_name (GST_OBJECT (nleobject), tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
GST_DEBUG_OBJECT (object, "Got a valid NleObject, now filling it in");
|
|
|
|
|
|
|
|
object->priv->nleobject = gst_object_ref (nleobject);
|
|
|
|
g_object_set_qdata (G_OBJECT (nleobject), NLE_OBJECT_TRACK_ELEMENT_QUARK,
|
|
|
|
object);
|
|
|
|
|
|
|
|
/* Set some properties on the NleObject */
|
|
|
|
g_object_set (object->priv->nleobject,
|
|
|
|
"start", GES_TIMELINE_ELEMENT_START (object),
|
|
|
|
"inpoint", GES_TIMELINE_ELEMENT_INPOINT (object),
|
|
|
|
"duration", GES_TIMELINE_ELEMENT_DURATION (object),
|
|
|
|
"priority", GES_TIMELINE_ELEMENT_PRIORITY (object),
|
|
|
|
"active", object->active, NULL);
|
|
|
|
|
Handle changing playback rate
Before this patch, NLE and GES did not support NleOperations (respectively
GESEffects) that changed the speed/tempo/rate at which the source plays. For
example, the 'pitch' element can make audio play faster or slower. In GES 1.5.90
and before, an NleOperation containing the pitch element to change the rate (or
tempo) would cause a pipeline state change to PAUSED after that stack; that has
been fixed in 1.5.91 (see #755012 [0]). But even then, in 1.5.91 and later,
NleComposition would send segment events to its NleSources assuming that one
source second is equal to one pipeline second. The resulting early EOS event
(in the case of a source rate higher than 1.0) would cause it to switch stacks
too early, causing confusion in the timeline and spectacularly messed up
output.
This patch fixes that by searching for rate-changing elements in
GESTrackElements such as GESEffects. If such rate-changing elements are found,
their final effect on the playing rate is stored in the corresponding NleObject
as the 'media duration factor', named like this because the 'media duration',
or source duration, of an NleObject can be computed by multiplying the duration
with the media duration factor of that object and its parents (this is called
the 'recursive media duration factor'). For example, a 4-second NleSource with
an NleOperation with a media duration factor of 2.0 will have an 8-second media
duration, which means that for playing 4 seconds in the pipeline, the seek
event sent to it must span 8 seconds of media. (So, the 'duration' of an
NleObject or GES object always refers to its duration in the timeline, not the
media duration.)
To summarize:
* Rate-changing elements are registered in the GESEffectClass (pitch::tempo and
pitch::rate are registered by default);
* GESTimelineElement is responsible for detecting rate-changing elements and
computing the media_duration_factor;
* GESTrackElement is responsible for storing the media_duration_factor in
NleObject;
* NleComposition is responsible for the recursive_media_duration_factor;
* The latter property finally fixes media time computations in NleObject.
NLE and GES tests are included.
[0] https://bugzilla.gnome.org/show_bug.cgi?id=755012
Differential Revision: https://phabricator.freedesktop.org/D276
2015-12-20 13:03:57 +00:00
|
|
|
media_duration_factor =
|
|
|
|
ges_timeline_element_get_media_duration_factor (GES_TIMELINE_ELEMENT
|
|
|
|
(object));
|
|
|
|
g_object_set (object->priv->nleobject,
|
|
|
|
"media-duration-factor", media_duration_factor, NULL);
|
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
G_OBJECT_CLASS (ges_track_element_parent_class)->constructed (gobject);
|
2009-08-06 10:14:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_class_init (GESTrackElementClass * klass)
|
2009-08-06 10:14:37 +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-06 10:14:37 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
object_class->get_property = ges_track_element_get_property;
|
|
|
|
object_class->set_property = ges_track_element_set_property;
|
|
|
|
object_class->dispose = ges_track_element_dispose;
|
2016-01-25 10:56:57 +00:00
|
|
|
object_class->constructed = ges_track_element_constructed;
|
2009-08-06 10:14:37 +00:00
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2009-09-30 14:40:59 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* GESTrackElement:active:
|
2009-09-30 14:40:59 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Whether the effect of the element should be applied in its
|
|
|
|
* #GESTrackElement:track. If set to %FALSE, it will not be used in
|
|
|
|
* the output of the track.
|
2009-09-30 14:40:59 +00:00
|
|
|
*/
|
2010-12-16 17:20:47 +00:00
|
|
|
properties[PROP_ACTIVE] =
|
|
|
|
g_param_spec_boolean ("active", "Active", "Use object in output", TRUE,
|
|
|
|
G_PARAM_READWRITE);
|
2009-09-30 14:40:59 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_ACTIVE,
|
2010-12-16 17:20:47 +00:00
|
|
|
properties[PROP_ACTIVE]);
|
2009-09-30 14:40:59 +00:00
|
|
|
|
2020-01-15 14:46:02 +00:00
|
|
|
/**
|
|
|
|
* GESTrackElement:track-type:
|
|
|
|
*
|
|
|
|
* The track type of the element, which determines the type of track the
|
|
|
|
* element can be added to (see #GESTrack:track-type). This should
|
|
|
|
* correspond to the type of data that the element can produce or
|
|
|
|
* process.
|
|
|
|
*/
|
2012-12-20 23:23:54 +00:00
|
|
|
properties[PROP_TRACK_TYPE] = g_param_spec_flags ("track-type", "Track Type",
|
|
|
|
"The track type of the object", GES_TYPE_TRACK_TYPE,
|
|
|
|
GES_TRACK_TYPE_UNKNOWN, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
|
|
|
g_object_class_install_property (object_class, PROP_TRACK_TYPE,
|
|
|
|
properties[PROP_TRACK_TYPE]);
|
|
|
|
|
2020-01-15 14:46:02 +00:00
|
|
|
/**
|
|
|
|
* GESTrackElement:track:
|
|
|
|
*
|
|
|
|
* The track that this element belongs to, or %NULL if it does not
|
|
|
|
* belong to a track.
|
|
|
|
*/
|
2013-01-10 21:09:23 +00:00
|
|
|
properties[PROP_TRACK] = g_param_spec_object ("track", "Track",
|
|
|
|
"The track the object is in", GES_TYPE_TRACK, G_PARAM_READABLE);
|
|
|
|
g_object_class_install_property (object_class, PROP_TRACK,
|
|
|
|
properties[PROP_TRACK]);
|
|
|
|
|
2014-10-01 07:54:49 +00:00
|
|
|
/**
|
|
|
|
* GESTrackElement::control-binding-added:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @track_element: A #GESTrackElement
|
|
|
|
* @control_binding: The control binding that has been added
|
2014-10-01 07:54:49 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* This is emitted when a control binding is added to a child property
|
|
|
|
* of the track element.
|
2014-10-01 07:54:49 +00:00
|
|
|
*/
|
|
|
|
ges_track_element_signals[CONTROL_BINDING_ADDED] =
|
|
|
|
g_signal_new ("control-binding-added", G_TYPE_FROM_CLASS (klass),
|
2019-08-29 05:45:45 +00:00
|
|
|
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL,
|
2014-10-01 07:54:49 +00:00
|
|
|
G_TYPE_NONE, 1, GST_TYPE_CONTROL_BINDING);
|
|
|
|
|
2015-06-16 13:02:18 +00:00
|
|
|
/**
|
2015-12-26 08:43:11 +00:00
|
|
|
* GESTrackElement::control-binding-removed:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @track_element: A #GESTrackElement
|
|
|
|
* @control_binding: The control binding that has been removed
|
2015-06-16 13:02:18 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* This is emitted when a control binding is removed from a child
|
|
|
|
* property of the track element.
|
2015-06-16 13:02:18 +00:00
|
|
|
*/
|
|
|
|
ges_track_element_signals[CONTROL_BINDING_REMOVED] =
|
2016-08-18 16:43:08 +00:00
|
|
|
g_signal_new ("control-binding-removed", G_TYPE_FROM_CLASS (klass),
|
2019-08-29 05:45:45 +00:00
|
|
|
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL,
|
2015-06-16 13:02:18 +00:00
|
|
|
G_TYPE_NONE, 1, GST_TYPE_CONTROL_BINDING);
|
|
|
|
|
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;
|
2015-06-23 11:27:00 +00:00
|
|
|
element_class->get_track_types = _get_track_types;
|
2013-07-24 18:26:18 +00:00
|
|
|
element_class->deep_copy = ges_track_element_copy_properties;
|
2019-03-01 22:08:39 +00:00
|
|
|
element_class->get_layer_priority = _get_layer_priority;
|
2013-01-15 13:52:17 +00:00
|
|
|
|
2015-06-25 08:32:46 +00:00
|
|
|
klass->create_gnl_object = ges_track_element_create_gnl_object_func;
|
2014-10-29 12:40:55 +00:00
|
|
|
klass->lookup_child = _lookup_child;
|
2009-08-06 10:14:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_init (GESTrackElement * self)
|
2009-08-06 10:14:37 +00:00
|
|
|
{
|
2018-09-06 01:55:02 +00:00
|
|
|
GESTrackElementPrivate *priv = self->priv =
|
|
|
|
ges_track_element_get_instance_private (self);
|
2010-12-04 18:54:13 +00:00
|
|
|
|
2009-09-30 14:42:08 +00:00
|
|
|
/* Sane default values */
|
2016-01-25 15:11:14 +00:00
|
|
|
GES_TIMELINE_ELEMENT_START (self) = 0;
|
|
|
|
GES_TIMELINE_ELEMENT_INPOINT (self) = 0;
|
|
|
|
GES_TIMELINE_ELEMENT_DURATION (self) = GST_SECOND;
|
|
|
|
GES_TIMELINE_ELEMENT_PRIORITY (self) = 0;
|
|
|
|
self->active = TRUE;
|
|
|
|
|
2013-03-30 17:54:50 +00:00
|
|
|
priv->bindings_hashtable = g_hash_table_new_full (g_str_hash, g_str_equal,
|
|
|
|
g_free, NULL);
|
2014-03-20 16:04:31 +00:00
|
|
|
}
|
|
|
|
|
2013-08-13 15:57:33 +00:00
|
|
|
static gfloat
|
|
|
|
interpolate_values_for_position (GstTimedValue * first_value,
|
2015-06-16 11:25:32 +00:00
|
|
|
GstTimedValue * second_value, guint64 position, gboolean absolute)
|
2013-08-13 15:57:33 +00:00
|
|
|
{
|
|
|
|
gfloat diff;
|
|
|
|
GstClockTime interval;
|
|
|
|
gfloat value_at_pos;
|
|
|
|
|
2015-07-08 16:59:00 +00:00
|
|
|
g_assert (second_value || first_value);
|
|
|
|
|
|
|
|
if (first_value == NULL)
|
|
|
|
return second_value->value;
|
|
|
|
|
|
|
|
if (second_value == NULL)
|
|
|
|
return first_value->value;
|
|
|
|
|
2013-08-13 15:57:33 +00:00
|
|
|
diff = second_value->value - first_value->value;
|
|
|
|
interval = second_value->timestamp - first_value->timestamp;
|
|
|
|
|
|
|
|
if (position > first_value->timestamp)
|
|
|
|
value_at_pos =
|
|
|
|
first_value->value + ((float) (position -
|
|
|
|
first_value->timestamp) / (float) interval) * diff;
|
|
|
|
else
|
|
|
|
value_at_pos =
|
|
|
|
first_value->value - ((float) (first_value->timestamp -
|
|
|
|
position) / (float) interval) * diff;
|
|
|
|
|
2015-06-16 11:25:32 +00:00
|
|
|
if (!absolute)
|
|
|
|
value_at_pos = CLAMP (value_at_pos, 0.0, 1.0);
|
2014-01-09 17:13:00 +00:00
|
|
|
|
2013-08-13 15:57:33 +00:00
|
|
|
return value_at_pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_update_control_bindings (GESTimelineElement * element, GstClockTime inpoint,
|
|
|
|
GstClockTime duration)
|
|
|
|
{
|
|
|
|
GParamSpec **specs;
|
|
|
|
guint n, n_specs;
|
|
|
|
GstControlBinding *binding;
|
|
|
|
GstTimedValueControlSource *source;
|
|
|
|
GESTrackElement *self = GES_TRACK_ELEMENT (element);
|
|
|
|
|
|
|
|
specs = ges_track_element_list_children_properties (self, &n_specs);
|
|
|
|
|
|
|
|
for (n = 0; n < n_specs; ++n) {
|
|
|
|
GList *values, *tmp;
|
2015-06-16 11:25:32 +00:00
|
|
|
gboolean absolute;
|
2013-08-13 15:57:33 +00:00
|
|
|
GstTimedValue *last, *first, *prev = NULL, *next = NULL;
|
|
|
|
gfloat value_at_pos;
|
|
|
|
|
|
|
|
binding = ges_track_element_get_control_binding (self, specs[n]->name);
|
|
|
|
|
|
|
|
if (!binding)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
g_object_get (binding, "control_source", &source, NULL);
|
|
|
|
|
2015-06-16 11:25:32 +00:00
|
|
|
g_object_get (binding, "absolute", &absolute, NULL);
|
2013-08-13 15:57:33 +00:00
|
|
|
if (duration == 0) {
|
|
|
|
gst_timed_value_control_source_unset_all (GST_TIMED_VALUE_CONTROL_SOURCE
|
|
|
|
(source));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
values =
|
|
|
|
gst_timed_value_control_source_get_all (GST_TIMED_VALUE_CONTROL_SOURCE
|
|
|
|
(source));
|
|
|
|
|
|
|
|
if (g_list_length (values) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
first = values->data;
|
|
|
|
|
|
|
|
for (tmp = values->next; tmp; tmp = tmp->next) {
|
|
|
|
next = tmp->data;
|
|
|
|
|
|
|
|
if (next->timestamp > inpoint)
|
|
|
|
break;
|
|
|
|
}
|
2019-03-28 14:29:05 +00:00
|
|
|
g_list_free (values);
|
2013-08-13 15:57:33 +00:00
|
|
|
|
2015-06-16 11:25:32 +00:00
|
|
|
value_at_pos =
|
|
|
|
interpolate_values_for_position (first, next, inpoint, absolute);
|
2013-08-13 15:57:33 +00:00
|
|
|
gst_timed_value_control_source_unset (source, first->timestamp);
|
|
|
|
gst_timed_value_control_source_set (source, inpoint, value_at_pos);
|
|
|
|
|
|
|
|
values =
|
|
|
|
gst_timed_value_control_source_get_all (GST_TIMED_VALUE_CONTROL_SOURCE
|
|
|
|
(source));
|
|
|
|
|
|
|
|
if (duration != GST_CLOCK_TIME_NONE) {
|
|
|
|
last = g_list_last (values)->data;
|
|
|
|
|
|
|
|
for (tmp = g_list_last (values)->prev; tmp; tmp = tmp->prev) {
|
|
|
|
prev = tmp->data;
|
|
|
|
|
|
|
|
if (prev->timestamp < duration + inpoint)
|
|
|
|
break;
|
|
|
|
}
|
2019-03-28 14:29:05 +00:00
|
|
|
g_list_free (values);
|
2013-08-13 15:57:33 +00:00
|
|
|
|
|
|
|
value_at_pos =
|
2015-06-16 11:25:32 +00:00
|
|
|
interpolate_values_for_position (prev, last, duration + inpoint,
|
|
|
|
absolute);
|
2013-08-13 15:57:33 +00:00
|
|
|
|
|
|
|
gst_timed_value_control_source_unset (source, last->timestamp);
|
|
|
|
gst_timed_value_control_source_set (source, duration + inpoint,
|
|
|
|
value_at_pos);
|
|
|
|
values =
|
|
|
|
gst_timed_value_control_source_get_all (GST_TIMED_VALUE_CONTROL_SOURCE
|
|
|
|
(source));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (tmp = values; tmp; tmp = tmp->next) {
|
|
|
|
GstTimedValue *value = tmp->data;
|
|
|
|
if (value->timestamp < inpoint)
|
|
|
|
gst_timed_value_control_source_unset (source, value->timestamp);
|
|
|
|
else if (duration != GST_CLOCK_TIME_NONE
|
|
|
|
&& value->timestamp > duration + inpoint)
|
|
|
|
gst_timed_value_control_source_unset (source, value->timestamp);
|
|
|
|
}
|
2019-03-28 14:29:05 +00:00
|
|
|
g_list_free (values);
|
2013-08-13 15:57:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (specs);
|
|
|
|
}
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
static gboolean
|
|
|
|
_set_start (GESTimelineElement * element, GstClockTime start)
|
2012-11-20 21:25:31 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *object = GES_TRACK_ELEMENT (element);
|
2012-11-20 21:25:31 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
g_return_val_if_fail (object->priv->nleobject, FALSE);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (start == _START (object)))
|
2019-05-02 15:41:10 +00:00
|
|
|
return -1;
|
2009-08-06 10:14:37 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
g_object_set (object->priv->nleobject, "start", start, NULL);
|
2012-04-23 23:20:18 +00:00
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
return TRUE;
|
2010-12-16 17:20:47 +00:00
|
|
|
}
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
static gboolean
|
|
|
|
_set_inpoint (GESTimelineElement * element, GstClockTime inpoint)
|
2009-08-06 10:14:37 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *object = GES_TRACK_ELEMENT (element);
|
2009-08-06 10:14:37 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
g_return_val_if_fail (object->priv->nleobject, FALSE);
|
2013-01-15 13:52:17 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
if (G_UNLIKELY (inpoint == _INPOINT (object)))
|
2019-05-02 15:41:10 +00:00
|
|
|
return -1;
|
2009-08-06 10:14:37 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
g_object_set (object->priv->nleobject, "inpoint", inpoint, NULL);
|
2013-08-13 15:57:33 +00:00
|
|
|
_update_control_bindings (element, inpoint, GST_CLOCK_TIME_NONE);
|
|
|
|
|
2009-08-06 10:14:37 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
static gboolean
|
|
|
|
_set_duration (GESTimelineElement * element, GstClockTime duration)
|
2009-08-06 10:14:37 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *object = GES_TRACK_ELEMENT (element);
|
|
|
|
GESTrackElementPrivate *priv = object->priv;
|
2012-04-24 00:17:42 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
g_return_val_if_fail (object->priv->nleobject, FALSE);
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
if (GST_CLOCK_TIME_IS_VALID (_MAXDURATION (element)) &&
|
|
|
|
duration > _INPOINT (object) + _MAXDURATION (element))
|
|
|
|
duration = _MAXDURATION (element) - _INPOINT (object);
|
2012-04-24 00:17:42 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
if (G_UNLIKELY (duration == _DURATION (object)))
|
2019-05-02 15:41:10 +00:00
|
|
|
return -1;
|
2009-08-06 10:14:37 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
g_object_set (priv->nleobject, "duration", duration, NULL);
|
2012-04-24 00:17:42 +00:00
|
|
|
|
2013-08-13 15:57:33 +00:00
|
|
|
_update_control_bindings (element, ges_timeline_element_get_inpoint (element),
|
|
|
|
duration);
|
|
|
|
|
2009-08-06 10:14:37 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
static gboolean
|
|
|
|
_set_priority (GESTimelineElement * element, guint32 priority)
|
2010-12-16 17:20:47 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *object = GES_TRACK_ELEMENT (element);
|
2010-12-16 17:20:47 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
g_return_val_if_fail (object->priv->nleobject, FALSE);
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
if (priority < MIN_NLE_PRIO) {
|
|
|
|
GST_INFO_OBJECT (element, "Priority (%d) < MIN_NLE_PRIO, setting it to %d",
|
|
|
|
priority, MIN_NLE_PRIO);
|
|
|
|
priority = MIN_NLE_PRIO;
|
2013-03-29 18:23:00 +00:00
|
|
|
}
|
|
|
|
|
2016-02-09 11:14:15 +00:00
|
|
|
GST_DEBUG_OBJECT (object, "priority:%" G_GUINT32_FORMAT, priority);
|
2010-12-16 17:20:47 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
if (G_UNLIKELY (priority == _PRIORITY (object)))
|
|
|
|
return FALSE;
|
2009-08-07 18:33:40 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
g_object_set (object->priv->nleobject, "priority", priority, NULL);
|
2010-07-08 16:51:38 +00:00
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
return TRUE;
|
2010-12-16 17:20:47 +00:00
|
|
|
}
|
|
|
|
|
2015-06-23 11:27:00 +00:00
|
|
|
GESTrackType
|
|
|
|
_get_track_types (GESTimelineElement * object)
|
|
|
|
{
|
|
|
|
return ges_track_element_get_track_type (GES_TRACK_ELEMENT (object));
|
|
|
|
}
|
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_set_active:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @object: A #GESTrackElement
|
|
|
|
* @active: Whether @object should be active in its track
|
2010-12-16 14:00:46 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Sets #GESTrackElement:active for the element.
|
2010-12-16 14:00:46 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Returns: %TRUE if the property was *toggled*.
|
2010-12-16 14:00:46 +00:00
|
|
|
*/
|
2009-09-30 14:40:59 +00:00
|
|
|
gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_active (GESTrackElement * object, gboolean active)
|
2009-09-30 14:40:59 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), FALSE);
|
2016-01-25 15:11:14 +00:00
|
|
|
g_return_val_if_fail (object->priv->nleobject, FALSE);
|
2012-04-23 23:20:18 +00:00
|
|
|
|
2013-06-09 16:29:05 +00:00
|
|
|
GST_DEBUG_OBJECT (object, "object:%p, active:%d", object, active);
|
2009-09-30 14:40:59 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
if (G_UNLIKELY (active == object->active))
|
|
|
|
return FALSE;
|
2009-09-30 14:40:59 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
g_object_set (object->priv->nleobject, "active", active, NULL);
|
2013-06-09 16:29:05 +00:00
|
|
|
|
2020-01-15 14:46:02 +00:00
|
|
|
/* FIXME: no need to check again at this point */
|
2016-01-25 15:11:14 +00:00
|
|
|
if (active != object->active) {
|
|
|
|
object->active = active;
|
|
|
|
if (GES_TRACK_ELEMENT_GET_CLASS (object)->active_changed)
|
|
|
|
GES_TRACK_ELEMENT_GET_CLASS (object)->active_changed (object, active);
|
|
|
|
}
|
2013-06-09 16:29:05 +00:00
|
|
|
|
2009-09-30 14:40:59 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-01-15 14:46:02 +00:00
|
|
|
/**
|
|
|
|
* ges_track_element_set_track_type:
|
|
|
|
* @object: A #GESTrackElement
|
|
|
|
* @type: The new track-type for @object
|
|
|
|
*
|
|
|
|
* Sets the #GESTrackElement:track-type for the element.
|
|
|
|
*/
|
2012-12-20 23:23:54 +00:00
|
|
|
void
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_track_type (GESTrackElement * object, GESTrackType type)
|
2012-12-20 23:23:54 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_if_fail (GES_IS_TRACK_ELEMENT (object));
|
2012-12-20 23:23:54 +00:00
|
|
|
|
|
|
|
if (object->priv->track_type != type) {
|
|
|
|
object->priv->track_type = type;
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (object), properties[PROP_TRACK_TYPE]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-15 14:46:02 +00:00
|
|
|
/**
|
|
|
|
* ges_track_element_get_track_type:
|
|
|
|
* @object: A #GESTrackElement
|
|
|
|
*
|
|
|
|
* Gets the #GESTrackElement:track-type for the element.
|
|
|
|
*
|
|
|
|
* Returns: The track-type of @object.
|
|
|
|
*/
|
2012-12-20 23:23:54 +00:00
|
|
|
GESTrackType
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_get_track_type (GESTrackElement * object)
|
2012-12-20 23:23:54 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), GES_TRACK_TYPE_UNKNOWN);
|
2012-12-20 23:23:54 +00:00
|
|
|
|
|
|
|
return object->priv->track_type;
|
|
|
|
}
|
|
|
|
|
2015-06-25 08:32:46 +00:00
|
|
|
/* default 'create_gnl_object' virtual method implementation */
|
2010-12-16 14:00:46 +00:00
|
|
|
static GstElement *
|
2015-06-25 08:32:46 +00:00
|
|
|
ges_track_element_create_gnl_object_func (GESTrackElement * self)
|
2009-08-06 15:38:43 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElementClass *klass = NULL;
|
2010-12-10 11:15:54 +00:00
|
|
|
GstElement *child = NULL;
|
2014-08-15 13:48:14 +00:00
|
|
|
GstElement *nleobject;
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
klass = GES_TRACK_ELEMENT_GET_CLASS (self);
|
2010-12-10 11:15:54 +00:00
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
if (G_UNLIKELY (self->priv->nleobject != NULL))
|
|
|
|
goto already_have_nleobject;
|
2010-12-10 11:15:54 +00:00
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
if (G_UNLIKELY (klass->nleobject_factorytype == NULL))
|
|
|
|
goto no_nlefactory;
|
2010-12-10 11:15:54 +00:00
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
GST_DEBUG ("Creating a supporting nleobject of type '%s'",
|
|
|
|
klass->nleobject_factorytype);
|
2010-12-10 11:15:54 +00:00
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
nleobject = gst_element_factory_make (klass->nleobject_factorytype, NULL);
|
2010-12-10 11:15:54 +00:00
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
if (G_UNLIKELY (nleobject == NULL))
|
|
|
|
goto no_nleobject;
|
2010-12-10 11:15:54 +00:00
|
|
|
|
|
|
|
if (klass->create_element) {
|
|
|
|
GST_DEBUG ("Calling subclass 'create_element' vmethod");
|
|
|
|
child = klass->create_element (self);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!child))
|
|
|
|
goto child_failure;
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
if (!gst_bin_add (GST_BIN (nleobject), child))
|
2010-12-10 11:15:54 +00:00
|
|
|
goto add_failure;
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
GST_DEBUG ("Succesfully got the element to put in the nleobject");
|
2010-12-16 14:00:46 +00:00
|
|
|
self->priv->element = child;
|
2010-12-10 11:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG ("done");
|
2014-08-15 13:48:14 +00:00
|
|
|
return nleobject;
|
2010-12-10 11:15:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* ERROR CASES */
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
already_have_nleobject:
|
2010-12-10 11:15:54 +00:00
|
|
|
{
|
2014-08-15 13:48:14 +00:00
|
|
|
GST_ERROR ("Already controlling a NleObject %s",
|
|
|
|
GST_ELEMENT_NAME (self->priv->nleobject));
|
2010-12-16 14:00:46 +00:00
|
|
|
return NULL;
|
2010-12-10 11:15:54 +00:00
|
|
|
}
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
no_nlefactory:
|
2010-12-10 11:15:54 +00:00
|
|
|
{
|
2014-08-15 13:48:14 +00:00
|
|
|
GST_ERROR ("No GESTrackElement::nleobject_factorytype implementation!");
|
2010-12-16 14:00:46 +00:00
|
|
|
return NULL;
|
2010-12-10 11:15:54 +00:00
|
|
|
}
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
no_nleobject:
|
2010-12-10 11:15:54 +00:00
|
|
|
{
|
2014-08-15 13:48:14 +00:00
|
|
|
GST_ERROR ("Error creating a nleobject of type '%s'",
|
|
|
|
klass->nleobject_factorytype);
|
2010-12-16 14:00:46 +00:00
|
|
|
return NULL;
|
2010-12-10 11:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
child_failure:
|
|
|
|
{
|
|
|
|
GST_ERROR ("create_element returned NULL");
|
2014-08-15 13:48:14 +00:00
|
|
|
gst_object_unref (nleobject);
|
2010-12-16 14:00:46 +00:00
|
|
|
return NULL;
|
2010-12-10 11:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
add_failure:
|
|
|
|
{
|
2014-08-15 13:48:14 +00:00
|
|
|
GST_ERROR ("Error adding the contents to the nleobject");
|
2010-12-10 11:15:54 +00:00
|
|
|
gst_object_unref (child);
|
2014-08-15 13:48:14 +00:00
|
|
|
gst_object_unref (nleobject);
|
2010-12-16 14:00:46 +00:00
|
|
|
return NULL;
|
2010-12-10 11:15:54 +00:00
|
|
|
}
|
2009-08-06 15:38:43 +00:00
|
|
|
}
|
|
|
|
|
2018-04-20 20:54:12 +00:00
|
|
|
static void
|
|
|
|
ges_track_element_add_child_props (GESTrackElement * self,
|
|
|
|
GstElement * child, const gchar ** wanted_categories,
|
|
|
|
const gchar ** blacklist, const gchar ** whitelist)
|
|
|
|
{
|
|
|
|
GstElementFactory *factory;
|
|
|
|
const gchar *klass;
|
|
|
|
GParamSpec **parray;
|
|
|
|
GObjectClass *gobject_klass;
|
|
|
|
gchar **categories;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
factory = gst_element_get_factory (child);
|
2020-01-15 14:46:02 +00:00
|
|
|
/* FIXME: handle NULL factory */
|
2018-04-20 20:54:12 +00:00
|
|
|
klass = gst_element_factory_get_metadata (factory,
|
|
|
|
GST_ELEMENT_METADATA_KLASS);
|
|
|
|
|
|
|
|
if (strv_find_str (blacklist, GST_OBJECT_NAME (factory))) {
|
|
|
|
GST_DEBUG_OBJECT (self, "%s blacklisted", GST_OBJECT_NAME (factory));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (self, "Looking at element '%s' of klass '%s'",
|
|
|
|
GST_ELEMENT_NAME (child), klass);
|
|
|
|
|
|
|
|
categories = g_strsplit (klass, "/", 0);
|
|
|
|
|
|
|
|
for (i = 0; categories[i]; i++) {
|
|
|
|
if ((!wanted_categories ||
|
|
|
|
strv_find_str (wanted_categories, categories[i]))) {
|
|
|
|
guint i, nb_specs;
|
|
|
|
|
|
|
|
gobject_klass = G_OBJECT_GET_CLASS (child);
|
|
|
|
parray = g_object_class_list_properties (gobject_klass, &nb_specs);
|
|
|
|
for (i = 0; i < nb_specs; i++) {
|
2019-01-04 11:36:20 +00:00
|
|
|
if ((!whitelist && (parray[i]->flags & G_PARAM_WRITABLE))
|
|
|
|
|| (strv_find_str (whitelist, parray[i]->name))) {
|
2018-04-20 20:54:12 +00:00
|
|
|
ges_timeline_element_add_child_property (GES_TIMELINE_ELEMENT
|
|
|
|
(self), parray[i], G_OBJECT (child));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_free (parray);
|
|
|
|
|
|
|
|
GST_DEBUG
|
|
|
|
("%d configurable properties of '%s' added to property hashtable",
|
|
|
|
nb_specs, GST_ELEMENT_NAME (child));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_strfreev (categories);
|
|
|
|
}
|
|
|
|
|
2013-08-27 03:31:14 +00:00
|
|
|
/**
|
|
|
|
* ges_track_element_add_children_props:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @self: A #GESTrackElement
|
|
|
|
* @element: The child object to retrieve properties from
|
2013-08-27 03:31:14 +00:00
|
|
|
* @wanted_categories: (array zero-terminated=1) (transfer none) (allow-none):
|
2020-01-15 14:46:02 +00:00
|
|
|
* An array of element factory "klass" categories to whitelist, or %NULL
|
|
|
|
* to accept all categories
|
2013-08-27 03:31:14 +00:00
|
|
|
* @blacklist: (array zero-terminated=1) (transfer none) (allow-none): A
|
2020-01-15 14:46:02 +00:00
|
|
|
* blacklist of element factory names, or %NULL to not blacklist any
|
|
|
|
* element factory
|
|
|
|
* @whitelist: (array zero-terminated=1) (transfer none) (allow-none): A
|
|
|
|
* whitelist of element property names, or %NULL to whitelist all
|
|
|
|
* writeable properties
|
2013-08-27 03:31:14 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Adds all the properties of a #GstElement that match the criteria as
|
|
|
|
* children properties of the track element. If the name of @element's
|
|
|
|
* #GstElementFactory is not in @blacklist, and the factory's
|
|
|
|
* #GST_ELEMENT_METADATA_KLASS contains at least one member of
|
|
|
|
* @wanted_categories (e.g. #GST_ELEMENT_FACTORY_KLASS_DECODER), then
|
|
|
|
* all the properties of @element that are also in @whitelist are added as
|
|
|
|
* child properties of @self using
|
|
|
|
* ges_timeline_element_add_child_property().
|
2013-08-27 03:31:14 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* This is intended to be used by subclasses when constructing.
|
2013-08-27 03:31:14 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ges_track_element_add_children_props (GESTrackElement * self,
|
|
|
|
GstElement * element, const gchar ** wanted_categories,
|
|
|
|
const gchar ** blacklist, const gchar ** whitelist)
|
|
|
|
{
|
|
|
|
GValue item = { 0, };
|
|
|
|
GstIterator *it;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
if (!GST_IS_BIN (element)) {
|
2018-04-20 20:54:12 +00:00
|
|
|
ges_track_element_add_child_props (self, element, wanted_categories,
|
|
|
|
blacklist, whitelist);
|
2013-08-27 03:31:14 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We go over child elements recursivly, and add writable properties to the
|
|
|
|
* hashtable */
|
|
|
|
it = gst_bin_iterate_recurse (GST_BIN (element));
|
|
|
|
while (!done) {
|
|
|
|
switch (gst_iterator_next (it, &item)) {
|
|
|
|
case GST_ITERATOR_OK:
|
|
|
|
{
|
|
|
|
GstElement *child = g_value_get_object (&item);
|
2018-04-20 20:54:12 +00:00
|
|
|
ges_track_element_add_child_props (self, child, wanted_categories,
|
|
|
|
blacklist, whitelist);
|
2013-08-27 03:31:14 +00:00
|
|
|
g_value_reset (&item);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_ITERATOR_RESYNC:
|
|
|
|
/* FIXME, properly restart the process */
|
|
|
|
GST_DEBUG ("iterator resync");
|
|
|
|
gst_iterator_resync (it);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GST_ITERATOR_DONE:
|
|
|
|
GST_DEBUG ("iterator done");
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_value_unset (&item);
|
|
|
|
}
|
|
|
|
gst_iterator_free (it);
|
|
|
|
}
|
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
/* INTERNAL USAGE */
|
2009-08-07 14:43:01 +00:00
|
|
|
gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_track (GESTrackElement * object, GESTrack * track)
|
2009-08-06 15:38:43 +00:00
|
|
|
{
|
2013-01-10 21:09:23 +00:00
|
|
|
gboolean ret = TRUE;
|
2016-01-25 15:11:14 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (object->priv->nleobject, FALSE);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (object, "new track: %" GST_PTR_FORMAT, track);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
object->priv->track = track;
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2012-04-17 22:42:41 +00:00
|
|
|
if (object->priv->track) {
|
2016-10-10 22:59:47 +00:00
|
|
|
ges_track_element_set_track_type (object, track->type);
|
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
g_object_set (object->priv->nleobject,
|
|
|
|
"caps", ges_track_get_caps (object->priv->track), NULL);
|
2012-04-17 22:42:41 +00:00
|
|
|
}
|
2009-08-07 14:43:01 +00:00
|
|
|
|
2013-01-10 21:09:23 +00:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (object), properties[PROP_TRACK]);
|
|
|
|
return ret;
|
2009-08-06 15:38:43 +00:00
|
|
|
}
|
|
|
|
|
2014-10-01 07:53:44 +00:00
|
|
|
/**
|
|
|
|
* ges_track_element_get_all_control_bindings
|
2020-01-15 14:46:02 +00:00
|
|
|
* @trackelement: A #GESTrackElement
|
|
|
|
*
|
|
|
|
* Get all the control bindings that have been created for the children
|
|
|
|
* properties of the track element using
|
|
|
|
* ges_track_element_set_control_source(). The keys used in the returned
|
|
|
|
* hash table are the child property names that were passed to
|
|
|
|
* ges_track_element_set_control_source(), and their values are the
|
|
|
|
* corresponding created #GstControlBinding.
|
2014-10-01 07:53:44 +00:00
|
|
|
*
|
|
|
|
* Returns: (element-type gchar* GstControlBinding)(transfer none): A
|
2020-01-15 14:46:02 +00:00
|
|
|
* hash table containing all child-property-name/control-binding pairs
|
|
|
|
* for @trackelement.
|
2014-10-01 07:53:44 +00:00
|
|
|
*/
|
2013-03-30 17:54:50 +00:00
|
|
|
GHashTable *
|
2014-10-01 07:53:44 +00:00
|
|
|
ges_track_element_get_all_control_bindings (GESTrackElement * trackelement)
|
2013-03-30 17:54:50 +00:00
|
|
|
{
|
|
|
|
GESTrackElementPrivate *priv = GES_TRACK_ELEMENT (trackelement)->priv;
|
|
|
|
|
|
|
|
return priv->bindings_hashtable;
|
|
|
|
}
|
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_get_track:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @object: A #GESTrackElement
|
2010-12-16 14:00:46 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Get the #GESTrackElement:track for the element.
|
2011-01-10 13:28:35 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Returns: (transfer none) (nullable): The track that @object belongs to,
|
|
|
|
* or %NULL if it does not belong to a track.
|
2010-12-16 14:00:46 +00:00
|
|
|
*/
|
|
|
|
GESTrack *
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_get_track (GESTrackElement * object)
|
2010-12-16 14:00:46 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), NULL);
|
2010-12-16 14:00:46 +00:00
|
|
|
|
|
|
|
return object->priv->track;
|
|
|
|
}
|
|
|
|
|
2015-06-25 08:32:46 +00:00
|
|
|
/**
|
|
|
|
* ges_track_element_get_gnlobject:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @object: A #GESTrackElement
|
2015-06-25 08:32:46 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Get the GNonLin object this object is controlling.
|
2015-06-25 08:32:46 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Returns: (transfer none): The GNonLin object this object is controlling.
|
2015-06-25 08:32:46 +00:00
|
|
|
*
|
|
|
|
* Deprecated: use #ges_track_element_get_nleobject instead.
|
|
|
|
*/
|
|
|
|
GstElement *
|
|
|
|
ges_track_element_get_gnlobject (GESTrackElement * object)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), NULL);
|
|
|
|
|
|
|
|
return object->priv->nleobject;
|
|
|
|
}
|
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
/**
|
2014-08-15 13:48:14 +00:00
|
|
|
* ges_track_element_get_nleobject:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @object: A #GESTrackElement
|
2010-12-16 14:00:46 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Get the nleobject that this element wraps.
|
2011-01-10 13:28:35 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Returns: (transfer none): The nleobject that @object wraps.
|
2015-06-25 08:32:46 +00:00
|
|
|
*
|
|
|
|
* Since: 1.6
|
2010-12-16 14:00:46 +00:00
|
|
|
*/
|
|
|
|
GstElement *
|
2014-08-15 13:48:14 +00:00
|
|
|
ges_track_element_get_nleobject (GESTrackElement * object)
|
2010-12-16 14:00:46 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), NULL);
|
2012-05-10 16:40:23 +00:00
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
return object->priv->nleobject;
|
2010-12-16 14:00:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_get_element:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @object: A #GESTrackElement
|
2010-12-16 14:00:46 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Get the #GstElement that the track element's underlying nleobject
|
|
|
|
* controls.
|
2011-01-10 13:28:35 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Returns: (transfer none): The #GstElement being controlled by the
|
|
|
|
* nleobject that @object wraps.
|
2010-12-16 14:00:46 +00:00
|
|
|
*/
|
|
|
|
GstElement *
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_get_element (GESTrackElement * object)
|
2010-12-16 14:00:46 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), NULL);
|
2012-05-10 16:40:23 +00:00
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
return object->priv->element;
|
|
|
|
}
|
2010-12-16 15:27:26 +00:00
|
|
|
|
2011-02-03 14:11:54 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_is_active:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @object: A #GESTrackElement
|
2011-02-03 14:11:54 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Gets #GESTrackElement:active for the element.
|
2011-02-03 14:11:54 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Returns: %TRUE if @object is active in its track.
|
2011-02-03 14:11:54 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_is_active (GESTrackElement * object)
|
2011-02-03 14:11:54 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), FALSE);
|
2016-01-25 15:11:14 +00:00
|
|
|
g_return_val_if_fail (object->priv->nleobject, FALSE);
|
2012-04-23 23:20:18 +00:00
|
|
|
|
2016-01-25 15:11:14 +00:00
|
|
|
return object->active;
|
2011-02-03 14:11:54 +00:00
|
|
|
}
|
2011-02-08 09:25:41 +00:00
|
|
|
|
2011-05-06 17:38:26 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_lookup_child:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @object: Object to lookup the property in
|
|
|
|
* @prop_name: Name of the property to look up. You can specify the name of the
|
2011-05-06 17:38:26 +00:00
|
|
|
* class as such: "ClassName::property-name", to guarantee that you get the
|
2011-02-25 10:32:44 +00:00
|
|
|
* proper GParamSpec in case various GstElement-s contain the same property
|
|
|
|
* name. If you don't do so, you will get the first element found, having
|
|
|
|
* this property and the and the corresponding GParamSpec.
|
|
|
|
* @element: (out) (allow-none) (transfer full): pointer to a #GstElement that
|
|
|
|
* takes the real object to set property on
|
2020-01-15 14:46:02 +00:00
|
|
|
* @pspec: (out) (allow-none) (transfer full): pointer to take the specification
|
2011-02-25 10:32:44 +00:00
|
|
|
* describing the property
|
|
|
|
*
|
|
|
|
* Looks up which @element and @pspec would be effected by the given @name. If various
|
|
|
|
* contained elements have this property name you will get the first one, unless you
|
|
|
|
* specify the class name in @name.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if @element and @pspec could be found. FALSE otherwise. In that
|
|
|
|
* case the values for @pspec and @element are not modified. Unref @element after
|
|
|
|
* usage.
|
2015-02-19 15:30:18 +00:00
|
|
|
*
|
|
|
|
* Deprecated: Use #ges_timeline_element_lookup_child
|
2011-02-25 10:32:44 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_lookup_child (GESTrackElement * object,
|
|
|
|
const gchar * prop_name, GstElement ** element, GParamSpec ** pspec)
|
2011-02-25 10:32:44 +00:00
|
|
|
{
|
2015-02-19 15:30:18 +00:00
|
|
|
return ges_timeline_element_lookup_child (GES_TIMELINE_ELEMENT (object),
|
|
|
|
prop_name, ((GObject **) element), pspec);
|
2011-02-25 10:32:44 +00:00
|
|
|
}
|
|
|
|
|
2011-02-08 09:25:41 +00:00
|
|
|
/**
|
2016-05-06 21:21:17 +00:00
|
|
|
* ges_track_element_set_child_property_by_pspec: (skip):
|
2020-01-15 14:46:02 +00:00
|
|
|
* @object: A #GESTrackElement
|
2011-02-25 11:13:03 +00:00
|
|
|
* @pspec: The #GParamSpec that specifies the property you want to set
|
2020-01-15 14:46:02 +00:00
|
|
|
* @value: The value
|
2011-02-08 09:25:41 +00:00
|
|
|
*
|
2011-02-25 11:13:03 +00:00
|
|
|
* Sets a property of a child of @object.
|
2015-02-19 15:30:18 +00:00
|
|
|
*
|
|
|
|
* Deprecated: Use #ges_timeline_element_set_child_property_by_spec
|
2011-02-08 09:25:41 +00:00
|
|
|
*/
|
|
|
|
void
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_child_property_by_pspec (GESTrackElement * object,
|
2011-02-25 11:13:03 +00:00
|
|
|
GParamSpec * pspec, GValue * value)
|
2011-02-08 09:25:41 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_if_fail (GES_IS_TRACK_ELEMENT (object));
|
2011-02-25 11:13:03 +00:00
|
|
|
|
2015-02-19 15:30:18 +00:00
|
|
|
ges_timeline_element_set_child_property_by_pspec (GES_TIMELINE_ELEMENT
|
|
|
|
(object), pspec, value);
|
2011-02-25 11:13:03 +00:00
|
|
|
|
|
|
|
return;
|
2011-02-08 09:25:41 +00:00
|
|
|
}
|
2011-02-08 10:06:57 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-06 21:21:17 +00:00
|
|
|
* ges_track_element_set_child_property_valist: (skip):
|
2013-01-26 15:31:33 +00:00
|
|
|
* @object: The #GESTrackElement parent object
|
2011-02-25 11:13:03 +00:00
|
|
|
* @first_property_name: The name of the first property to set
|
2020-01-15 14:46:02 +00:00
|
|
|
* @var_args: Value for the first property, followed optionally by more
|
2011-02-25 11:13:03 +00:00
|
|
|
* name/return location pairs, followed by NULL
|
|
|
|
*
|
|
|
|
* Sets a property of a child of @object. If there are various child elements
|
|
|
|
* that have the same property name, you can distinguish them using the following
|
2011-08-13 22:52:23 +00:00
|
|
|
* syntax: 'ClasseName::property_name' as property name. If you don't, the
|
2011-02-25 11:13:03 +00:00
|
|
|
* corresponding property of the first element found will be set.
|
2015-02-19 15:30:18 +00:00
|
|
|
*
|
|
|
|
* Deprecated: Use #ges_timeline_element_set_child_property_valist
|
2011-02-25 11:13:03 +00:00
|
|
|
*/
|
|
|
|
void
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_child_property_valist (GESTrackElement * object,
|
2011-02-25 11:13:03 +00:00
|
|
|
const gchar * first_property_name, va_list var_args)
|
|
|
|
{
|
2015-02-19 15:30:18 +00:00
|
|
|
ges_timeline_element_set_child_property_valist (GES_TIMELINE_ELEMENT (object),
|
|
|
|
first_property_name, var_args);
|
2011-02-25 11:13:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-06 21:21:17 +00:00
|
|
|
* ges_track_element_set_child_properties: (skip):
|
2013-01-26 15:31:33 +00:00
|
|
|
* @object: The #GESTrackElement parent object
|
2011-02-25 11:13:03 +00:00
|
|
|
* @first_property_name: The name of the first property to set
|
|
|
|
* @...: value for the first property, followed optionally by more
|
|
|
|
* name/return location pairs, followed by NULL
|
|
|
|
*
|
|
|
|
* Sets a property of a child of @object. If there are various child elements
|
|
|
|
* that have the same property name, you can distinguish them using the following
|
2011-08-13 22:52:23 +00:00
|
|
|
* syntax: 'ClasseName::property_name' as property name. If you don't, the
|
2011-02-25 11:13:03 +00:00
|
|
|
* corresponding property of the first element found will be set.
|
2015-02-19 15:30:18 +00:00
|
|
|
*
|
|
|
|
* Deprecated: Use #ges_timeline_element_set_child_properties
|
2011-02-25 11:13:03 +00:00
|
|
|
*/
|
|
|
|
void
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_child_properties (GESTrackElement * object,
|
2011-02-25 11:13:03 +00:00
|
|
|
const gchar * first_property_name, ...)
|
|
|
|
{
|
|
|
|
va_list var_args;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_if_fail (GES_IS_TRACK_ELEMENT (object));
|
2012-04-23 23:20:18 +00:00
|
|
|
|
2011-02-25 11:13:03 +00:00
|
|
|
va_start (var_args, first_property_name);
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_child_property_valist (object, first_property_name,
|
2011-02-25 11:13:03 +00:00
|
|
|
var_args);
|
|
|
|
va_end (var_args);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-06 21:21:17 +00:00
|
|
|
* ges_track_element_get_child_property_valist: (skip):
|
2013-01-26 15:31:33 +00:00
|
|
|
* @object: The #GESTrackElement parent object
|
2011-02-25 11:13:03 +00:00
|
|
|
* @first_property_name: The name of the first property to get
|
2020-01-15 14:46:02 +00:00
|
|
|
* @var_args: Value for the first property, followed optionally by more
|
2011-02-25 11:13:03 +00:00
|
|
|
* name/return location pairs, followed by NULL
|
|
|
|
*
|
|
|
|
* Gets a property of a child of @object. If there are various child elements
|
|
|
|
* that have the same property name, you can distinguish them using the following
|
2011-08-13 22:52:23 +00:00
|
|
|
* syntax: 'ClasseName::property_name' as property name. If you don't, the
|
2011-02-25 11:13:03 +00:00
|
|
|
* corresponding property of the first element found will be set.
|
2015-02-19 15:30:18 +00:00
|
|
|
*
|
|
|
|
* Deprecated: Use #ges_timeline_element_get_child_property_valist
|
2011-02-25 11:13:03 +00:00
|
|
|
*/
|
|
|
|
void
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_get_child_property_valist (GESTrackElement * object,
|
2011-02-25 11:13:03 +00:00
|
|
|
const gchar * first_property_name, va_list var_args)
|
|
|
|
{
|
2015-02-19 15:30:18 +00:00
|
|
|
ges_timeline_element_get_child_property_valist (GES_TIMELINE_ELEMENT (object),
|
|
|
|
first_property_name, var_args);
|
2011-02-25 11:13:03 +00:00
|
|
|
}
|
|
|
|
|
2011-02-25 16:10:00 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_list_children_properties:
|
|
|
|
* @object: The #GESTrackElement to get the list of children properties from
|
2012-08-15 00:33:57 +00:00
|
|
|
* @n_properties: (out): return location for the length of the returned array
|
2011-02-25 16:10:00 +00:00
|
|
|
*
|
|
|
|
* Gets an array of #GParamSpec* for all configurable properties of the
|
|
|
|
* children of @object.
|
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Returns: (transfer full) (array length=n_properties): An array of #GParamSpec* which should be freed after use or
|
|
|
|
* %NULL if something went wrong.
|
2015-02-19 15:30:18 +00:00
|
|
|
*
|
|
|
|
* Deprecated: Use #ges_timeline_element_list_children_properties
|
2011-02-25 16:10:00 +00:00
|
|
|
*/
|
|
|
|
GParamSpec **
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_list_children_properties (GESTrackElement * object,
|
2011-02-25 16:10:00 +00:00
|
|
|
guint * n_properties)
|
|
|
|
{
|
2015-02-19 15:30:18 +00:00
|
|
|
return
|
|
|
|
ges_timeline_element_list_children_properties (GES_TIMELINE_ELEMENT
|
|
|
|
(object), n_properties);
|
2011-02-25 16:10:00 +00:00
|
|
|
}
|
|
|
|
|
2011-02-25 11:13:03 +00:00
|
|
|
/**
|
2016-05-06 21:21:17 +00:00
|
|
|
* ges_track_element_get_child_properties: (skip):
|
2013-01-26 15:31:33 +00:00
|
|
|
* @object: The origin #GESTrackElement
|
2011-02-25 11:13:03 +00:00
|
|
|
* @first_property_name: The name of the first property to get
|
|
|
|
* @...: return location for the first property, followed optionally by more
|
|
|
|
* name/return location pairs, followed by NULL
|
|
|
|
*
|
|
|
|
* Gets properties of a child of @object.
|
2015-02-19 15:30:18 +00:00
|
|
|
*
|
|
|
|
* Deprecated: Use #ges_timeline_element_get_child_properties
|
2011-02-25 11:13:03 +00:00
|
|
|
*/
|
2011-02-08 10:06:57 +00:00
|
|
|
void
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_get_child_properties (GESTrackElement * object,
|
2011-02-25 11:13:03 +00:00
|
|
|
const gchar * first_property_name, ...)
|
2011-02-08 10:06:57 +00:00
|
|
|
{
|
2011-02-25 11:13:03 +00:00
|
|
|
va_list var_args;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_if_fail (GES_IS_TRACK_ELEMENT (object));
|
2012-04-23 23:20:18 +00:00
|
|
|
|
2011-02-25 11:13:03 +00:00
|
|
|
va_start (var_args, first_property_name);
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_get_child_property_valist (object, first_property_name,
|
2011-02-25 11:13:03 +00:00
|
|
|
var_args);
|
|
|
|
va_end (var_args);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-06 21:21:17 +00:00
|
|
|
* ges_track_element_get_child_property_by_pspec: (skip):
|
2020-01-15 14:46:02 +00:00
|
|
|
* @object: A #GESTrackElement
|
2011-02-25 11:13:03 +00:00
|
|
|
* @pspec: The #GParamSpec that specifies the property you want to get
|
2012-12-18 22:47:50 +00:00
|
|
|
* @value: (out): return location for the value
|
2011-02-25 11:13:03 +00:00
|
|
|
*
|
|
|
|
* Gets a property of a child of @object.
|
2015-02-19 15:30:18 +00:00
|
|
|
*
|
|
|
|
* Deprecated: Use #ges_timeline_element_get_child_property_by_pspec
|
2011-02-25 11:13:03 +00:00
|
|
|
*/
|
|
|
|
void
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_get_child_property_by_pspec (GESTrackElement * object,
|
2011-02-25 11:13:03 +00:00
|
|
|
GParamSpec * pspec, GValue * value)
|
|
|
|
{
|
2015-02-19 15:30:18 +00:00
|
|
|
ges_timeline_element_get_child_property_by_pspec (GES_TIMELINE_ELEMENT
|
|
|
|
(object), pspec, value);
|
2011-02-08 10:06:57 +00:00
|
|
|
}
|
2011-02-25 16:10:00 +00:00
|
|
|
|
2012-12-19 13:37:02 +00:00
|
|
|
/**
|
2016-05-06 21:21:17 +00:00
|
|
|
* ges_track_element_set_child_property: (skip):
|
2013-01-26 15:31:33 +00:00
|
|
|
* @object: The origin #GESTrackElement
|
2012-12-19 13:37:02 +00:00
|
|
|
* @property_name: The name of the property
|
2020-01-15 14:46:02 +00:00
|
|
|
* @value: The value
|
2012-12-19 13:37:02 +00:00
|
|
|
*
|
|
|
|
* Sets a property of a GstElement contained in @object.
|
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Note that #ges_track_element_set_child_property is really
|
|
|
|
* intended for language bindings, #ges_track_element_set_child_properties
|
2012-12-19 13:37:02 +00:00
|
|
|
* is much more convenient for C programming.
|
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Returns: %TRUE if the property was set, %FALSE otherwize.
|
2015-02-19 15:30:18 +00:00
|
|
|
*
|
|
|
|
* Deprecated: use #ges_timeline_element_set_child_property instead
|
2012-12-19 13:37:02 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_child_property (GESTrackElement * object,
|
2012-12-19 13:37:02 +00:00
|
|
|
const gchar * property_name, GValue * value)
|
|
|
|
{
|
2015-02-19 15:30:18 +00:00
|
|
|
return ges_timeline_element_set_child_property (GES_TIMELINE_ELEMENT (object),
|
|
|
|
property_name, value);
|
2012-12-19 13:37:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-06 21:21:17 +00:00
|
|
|
* ges_track_element_get_child_property: (skip):
|
2015-02-19 15:30:18 +00:00
|
|
|
* @object: The origin #GESTrackElement
|
|
|
|
* @property_name: The name of the property
|
|
|
|
* @value: (out): return location for the property value, it will
|
|
|
|
* be initialized if it is initialized with 0
|
|
|
|
*
|
|
|
|
* In general, a copy is made of the property contents and
|
|
|
|
* the caller is responsible for freeing the memory by calling
|
|
|
|
* g_value_unset().
|
|
|
|
*
|
|
|
|
* Gets a property of a GstElement contained in @object.
|
|
|
|
*
|
|
|
|
* Note that #ges_track_element_get_child_property is really
|
|
|
|
* intended for language bindings, #ges_track_element_get_child_properties
|
|
|
|
* is much more convenient for C programming.
|
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Returns: %TRUE if the property was found, %FALSE otherwize.
|
2015-02-19 15:30:18 +00:00
|
|
|
*
|
|
|
|
* Deprecated: Use #ges_timeline_element_get_child_property
|
|
|
|
*/
|
2012-12-19 13:37:02 +00:00
|
|
|
gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_get_child_property (GESTrackElement * object,
|
2012-12-19 13:37:02 +00:00
|
|
|
const gchar * property_name, GValue * value)
|
|
|
|
{
|
2015-02-19 15:30:18 +00:00
|
|
|
return ges_timeline_element_get_child_property (GES_TIMELINE_ELEMENT (object),
|
|
|
|
property_name, value);
|
2012-12-19 13:37:02 +00:00
|
|
|
}
|
|
|
|
|
2012-01-16 12:37:22 +00:00
|
|
|
void
|
2013-07-24 18:26:18 +00:00
|
|
|
ges_track_element_copy_properties (GESTimelineElement * element,
|
|
|
|
GESTimelineElement * elementcopy)
|
2012-04-19 04:34:59 +00:00
|
|
|
{
|
|
|
|
GParamSpec **specs;
|
2013-01-15 13:52:17 +00:00
|
|
|
guint n, n_specs;
|
2012-04-19 04:34:59 +00:00
|
|
|
GValue val = { 0 };
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *copy = GES_TRACK_ELEMENT (elementcopy);
|
2012-04-19 04:34:59 +00:00
|
|
|
|
|
|
|
specs =
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_list_children_properties (GES_TRACK_ELEMENT (element),
|
2013-01-15 13:52:17 +00:00
|
|
|
&n_specs);
|
2012-04-19 04:34:59 +00:00
|
|
|
for (n = 0; n < n_specs; ++n) {
|
2016-04-10 00:12:00 +00:00
|
|
|
if (!(specs[n]->flags & G_PARAM_WRITABLE))
|
|
|
|
continue;
|
2012-04-19 04:34:59 +00:00
|
|
|
g_value_init (&val, specs[n]->value_type);
|
2013-07-24 18:26:18 +00:00
|
|
|
ges_track_element_get_child_property_by_pspec (GES_TRACK_ELEMENT (element),
|
|
|
|
specs[n], &val);
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_child_property_by_pspec (copy, specs[n], &val);
|
2012-04-19 04:34:59 +00:00
|
|
|
g_value_unset (&val);
|
|
|
|
}
|
|
|
|
|
2012-04-23 23:17:51 +00:00
|
|
|
g_free (specs);
|
2012-04-19 04:34:59 +00:00
|
|
|
}
|
2012-04-24 00:52:45 +00:00
|
|
|
|
2015-06-29 16:04:32 +00:00
|
|
|
static void
|
|
|
|
_split_binding (GESTrackElement * element, GESTrackElement * new_element,
|
|
|
|
guint64 position, GstTimedValueControlSource * source,
|
|
|
|
GstTimedValueControlSource * new_source, gboolean absolute)
|
|
|
|
{
|
|
|
|
GstTimedValue *last_value = NULL;
|
|
|
|
gboolean past_position = FALSE;
|
|
|
|
GList *values, *tmp;
|
|
|
|
|
|
|
|
values =
|
|
|
|
gst_timed_value_control_source_get_all (GST_TIMED_VALUE_CONTROL_SOURCE
|
|
|
|
(source));
|
|
|
|
|
|
|
|
for (tmp = values; tmp; tmp = tmp->next) {
|
|
|
|
GstTimedValue *value = tmp->data;
|
2015-07-03 11:49:57 +00:00
|
|
|
|
|
|
|
if (value->timestamp > position && !past_position) {
|
2015-06-29 16:04:32 +00:00
|
|
|
gfloat value_at_pos;
|
|
|
|
|
|
|
|
/* FIXME We should be able to use gst_control_source_get_value so
|
|
|
|
* all modes are handled. Right now that method only works if the value
|
|
|
|
* we are looking for is between two actual keyframes which is not enough
|
|
|
|
* in our case. bug #706621 */
|
|
|
|
value_at_pos =
|
|
|
|
interpolate_values_for_position (last_value, value, position,
|
|
|
|
absolute);
|
|
|
|
|
|
|
|
past_position = TRUE;
|
|
|
|
|
|
|
|
gst_timed_value_control_source_set (new_source, position, value_at_pos);
|
|
|
|
gst_timed_value_control_source_set (new_source, value->timestamp,
|
|
|
|
value->value);
|
2015-07-03 11:49:57 +00:00
|
|
|
|
2015-06-29 16:04:32 +00:00
|
|
|
gst_timed_value_control_source_unset (source, value->timestamp);
|
|
|
|
gst_timed_value_control_source_set (source, position, value_at_pos);
|
|
|
|
} else if (past_position) {
|
|
|
|
gst_timed_value_control_source_set (new_source, value->timestamp,
|
|
|
|
value->value);
|
2015-07-03 11:49:57 +00:00
|
|
|
gst_timed_value_control_source_unset (source, value->timestamp);
|
2015-06-29 16:04:32 +00:00
|
|
|
}
|
|
|
|
last_value = value;
|
2015-07-03 11:49:57 +00:00
|
|
|
|
2015-06-29 16:04:32 +00:00
|
|
|
}
|
2019-03-28 14:29:05 +00:00
|
|
|
g_list_free (values);
|
2015-06-29 16:04:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_copy_binding (GESTrackElement * element, GESTrackElement * new_element,
|
|
|
|
guint64 position, GstTimedValueControlSource * source,
|
|
|
|
GstTimedValueControlSource * new_source, gboolean absolute)
|
|
|
|
{
|
|
|
|
GList *values, *tmp;
|
|
|
|
|
|
|
|
values =
|
|
|
|
gst_timed_value_control_source_get_all (GST_TIMED_VALUE_CONTROL_SOURCE
|
|
|
|
(source));
|
|
|
|
for (tmp = values; tmp; tmp = tmp->next) {
|
|
|
|
GstTimedValue *value = tmp->data;
|
|
|
|
|
|
|
|
gst_timed_value_control_source_set (new_source, value->timestamp,
|
|
|
|
value->value);
|
|
|
|
}
|
2019-03-28 14:29:05 +00:00
|
|
|
g_list_free (values);
|
2015-06-29 16:04:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* position == GST_CLOCK_TIME_NONE means that we do a simple copy
|
|
|
|
* other position means that the function will do a splitting
|
|
|
|
* and thus interpollate the values in the element and new_element
|
|
|
|
*/
|
2013-08-13 16:05:55 +00:00
|
|
|
void
|
2015-06-29 16:04:32 +00:00
|
|
|
ges_track_element_copy_bindings (GESTrackElement * element,
|
2013-08-13 16:05:55 +00:00
|
|
|
GESTrackElement * new_element, guint64 position)
|
|
|
|
{
|
|
|
|
GParamSpec **specs;
|
|
|
|
guint n, n_specs;
|
2015-06-29 16:04:32 +00:00
|
|
|
gboolean absolute;
|
2013-08-13 16:05:55 +00:00
|
|
|
GstControlBinding *binding;
|
|
|
|
GstTimedValueControlSource *source, *new_source;
|
|
|
|
|
|
|
|
specs =
|
|
|
|
ges_track_element_list_children_properties (GES_TRACK_ELEMENT (element),
|
|
|
|
&n_specs);
|
|
|
|
for (n = 0; n < n_specs; ++n) {
|
|
|
|
GstInterpolationMode mode;
|
|
|
|
|
|
|
|
binding = ges_track_element_get_control_binding (element, specs[n]->name);
|
|
|
|
if (!binding)
|
|
|
|
continue;
|
|
|
|
|
2015-06-29 16:04:32 +00:00
|
|
|
g_object_get (binding, "control_source", &source, NULL);
|
2020-02-24 11:47:11 +00:00
|
|
|
if (!GST_IS_TIMED_VALUE_CONTROL_SOURCE (source)) {
|
|
|
|
GST_FIXME_OBJECT (element,
|
|
|
|
"Implement support for control source type: %s",
|
|
|
|
G_OBJECT_TYPE_NAME (source));
|
2013-08-13 16:05:55 +00:00
|
|
|
continue;
|
2020-02-24 11:47:11 +00:00
|
|
|
}
|
2013-08-13 16:05:55 +00:00
|
|
|
|
2015-06-16 11:25:32 +00:00
|
|
|
g_object_get (binding, "absolute", &absolute, NULL);
|
2015-06-29 16:04:32 +00:00
|
|
|
g_object_get (source, "mode", &mode, NULL);
|
2015-06-16 11:25:32 +00:00
|
|
|
|
2013-08-13 16:05:55 +00:00
|
|
|
new_source =
|
|
|
|
GST_TIMED_VALUE_CONTROL_SOURCE (gst_interpolation_control_source_new
|
|
|
|
());
|
|
|
|
g_object_set (new_source, "mode", mode, NULL);
|
|
|
|
|
2015-06-29 16:04:32 +00:00
|
|
|
if (GST_CLOCK_TIME_IS_VALID (position))
|
|
|
|
_split_binding (element, new_element, position, source, new_source,
|
|
|
|
absolute);
|
|
|
|
else
|
|
|
|
_copy_binding (element, new_element, position, source, new_source,
|
|
|
|
absolute);
|
2013-08-13 16:05:55 +00:00
|
|
|
|
2015-06-16 11:25:32 +00:00
|
|
|
/* We only manage direct (absolute) bindings, see TODO in set_control_source */
|
|
|
|
if (absolute)
|
|
|
|
ges_track_element_set_control_source (new_element,
|
|
|
|
GST_CONTROL_SOURCE (new_source), specs[n]->name, "direct-absolute");
|
|
|
|
else
|
|
|
|
ges_track_element_set_control_source (new_element,
|
|
|
|
GST_CONTROL_SOURCE (new_source), specs[n]->name, "direct");
|
2013-08-13 16:05:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (specs);
|
|
|
|
}
|
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_edit:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @object: The #GESTrackElement to edit
|
|
|
|
* @layers: (element-type GESLayer) (nullable): A whitelist of layers
|
|
|
|
* where the edit can be performed, %NULL allows all layers in the
|
|
|
|
* timeline
|
|
|
|
* @mode: The edit mode
|
|
|
|
* @edge: The edge of @object where the edit should occur
|
|
|
|
* @position: The edit position: a new location for the edge of @object
|
|
|
|
* (in nanoseconds)
|
2012-04-24 00:52:45 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Edits the element within its track.
|
2012-04-24 00:52:45 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Returns: %TRUE if the edit of @object completed, %FALSE on failure.
|
2019-05-01 16:09:45 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 1.18: use #ges_timeline_element_edit instead.
|
2012-04-24 00:52:45 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_edit (GESTrackElement * object,
|
2012-04-24 00:52:45 +00:00
|
|
|
GList * layers, GESEditMode mode, GESEdge edge, guint64 position)
|
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), FALSE);
|
2012-04-23 23:20:18 +00:00
|
|
|
|
2019-05-01 16:09:45 +00:00
|
|
|
return ges_timeline_element_edit (GES_TIMELINE_ELEMENT (object),
|
|
|
|
layers, -1, mode, edge, position);
|
2012-04-24 00:52:45 +00:00
|
|
|
}
|
2013-03-30 17:54:50 +00:00
|
|
|
|
2015-06-16 13:02:18 +00:00
|
|
|
/**
|
|
|
|
* ges_track_element_remove_control_binding:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @object: A #GESTrackElement
|
|
|
|
* @property_name: The name of the child property to remove the control
|
|
|
|
* binding from
|
2015-06-16 13:02:18 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Removes the #GstControlBinding that was created for the specified child
|
|
|
|
* property of the track element using
|
|
|
|
* ges_track_element_set_control_source(). The given @property_name must
|
|
|
|
* be the same name of the child property that was passed to
|
|
|
|
* ges_track_element_set_control_source().
|
2015-06-16 13:02:18 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Returns: %TRUE if the control binding was removed from the specified
|
|
|
|
* child property of @object, or %FALSE if an error occurred.
|
2015-06-16 13:02:18 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_track_element_remove_control_binding (GESTrackElement * object,
|
|
|
|
const gchar * property_name)
|
|
|
|
{
|
|
|
|
GESTrackElementPrivate *priv;
|
|
|
|
GstControlBinding *binding;
|
|
|
|
GstObject *target;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), FALSE);
|
|
|
|
|
|
|
|
priv = GES_TRACK_ELEMENT (object)->priv;
|
|
|
|
binding =
|
|
|
|
(GstControlBinding *) g_hash_table_lookup (priv->bindings_hashtable,
|
|
|
|
property_name);
|
|
|
|
|
|
|
|
if (binding) {
|
|
|
|
g_object_get (binding, "object", &target, NULL);
|
|
|
|
GST_DEBUG_OBJECT (object, "Removing binding %p for property %s", binding,
|
|
|
|
property_name);
|
|
|
|
|
|
|
|
gst_object_ref (binding);
|
|
|
|
gst_object_remove_control_binding (target, binding);
|
|
|
|
|
|
|
|
g_signal_emit (object, ges_track_element_signals[CONTROL_BINDING_REMOVED],
|
|
|
|
0, binding);
|
|
|
|
|
|
|
|
gst_object_unref (target);
|
|
|
|
gst_object_unref (binding);
|
|
|
|
g_hash_table_remove (priv->bindings_hashtable, property_name);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2013-03-30 17:54:50 +00:00
|
|
|
|
|
|
|
/**
|
2013-03-31 14:07:14 +00:00
|
|
|
* ges_track_element_set_control_source:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @object: A #GESTrackElement
|
|
|
|
* @source: The control source to bind the child property to
|
|
|
|
* @property_name: The name of the child property to control
|
|
|
|
* @binding_type: The type of binding to create ("direct" or
|
|
|
|
* "direct-absolute")
|
|
|
|
*
|
|
|
|
* Creates a #GstControlBinding for the specified child property of the
|
|
|
|
* track element using the given control source. The given @property_name
|
|
|
|
* should refer to an existing child property of the track element, as
|
|
|
|
* used in ges_timeline_element_lookup_child().
|
2013-03-30 17:54:50 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* If @binding_type is "direct", then the control binding is created with
|
|
|
|
* gst_direct_control_binding_new() using the given control source. If
|
|
|
|
* @binding_type is "direct-absolute", it is created with
|
|
|
|
* gst_direct_control_binding_new_absolute() instead.
|
2013-03-30 17:54:50 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Returns: %TRUE if the specified child property could be bound to
|
|
|
|
* @source, or %FALSE if an error occurred.
|
2013-03-30 17:54:50 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2013-03-31 14:07:14 +00:00
|
|
|
ges_track_element_set_control_source (GESTrackElement * object,
|
2013-03-30 17:54:50 +00:00
|
|
|
GstControlSource * source,
|
|
|
|
const gchar * property_name, const gchar * binding_type)
|
|
|
|
{
|
|
|
|
GESTrackElementPrivate *priv;
|
|
|
|
GstElement *element;
|
|
|
|
GParamSpec *pspec;
|
|
|
|
GstControlBinding *binding;
|
2015-06-16 11:25:32 +00:00
|
|
|
gboolean direct, direct_absolute;
|
2013-03-30 17:54:50 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), FALSE);
|
|
|
|
priv = GES_TRACK_ELEMENT (object)->priv;
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!(GST_IS_CONTROL_SOURCE (source)))) {
|
|
|
|
GST_WARNING
|
|
|
|
("You need to provide a non-null control source to build a new control binding");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ges_track_element_lookup_child (object, property_name, &element, &pspec)) {
|
|
|
|
GST_WARNING ("You need to provide a valid and controllable property name");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO : update this according to new types of bindings */
|
2015-06-16 11:25:32 +00:00
|
|
|
direct = !g_strcmp0 (binding_type, "direct");
|
|
|
|
direct_absolute = !g_strcmp0 (binding_type, "direct-absolute");
|
|
|
|
|
|
|
|
if (direct || direct_absolute) {
|
2013-03-30 17:54:50 +00:00
|
|
|
/* First remove existing binding */
|
2017-08-17 07:28:46 +00:00
|
|
|
if (ges_track_element_remove_control_binding (object, property_name)) {
|
|
|
|
GST_LOG ("Removed old binding for property %s", property_name);
|
2013-03-30 17:54:50 +00:00
|
|
|
}
|
2015-06-16 11:25:32 +00:00
|
|
|
|
|
|
|
if (direct_absolute)
|
|
|
|
binding =
|
|
|
|
gst_direct_control_binding_new_absolute (GST_OBJECT (element),
|
|
|
|
property_name, source);
|
|
|
|
else
|
|
|
|
binding =
|
|
|
|
gst_direct_control_binding_new (GST_OBJECT (element), property_name,
|
|
|
|
source);
|
|
|
|
|
2013-03-30 17:54:50 +00:00
|
|
|
gst_object_add_control_binding (GST_OBJECT (element), binding);
|
2020-01-15 14:46:02 +00:00
|
|
|
/* FIXME: maybe we should force the
|
|
|
|
* "ChildTypeName:property-name"
|
|
|
|
* format convention for child property names in bindings_hashtable.
|
|
|
|
* Currently the table may also contain
|
|
|
|
* "property-name"
|
|
|
|
* as keys.
|
|
|
|
*/
|
2013-03-30 17:54:50 +00:00
|
|
|
g_hash_table_insert (priv->bindings_hashtable, g_strdup (property_name),
|
|
|
|
binding);
|
2014-10-01 07:54:49 +00:00
|
|
|
g_signal_emit (object, ges_track_element_signals[CONTROL_BINDING_ADDED],
|
|
|
|
0, binding);
|
2013-03-30 17:54:50 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_WARNING ("Binding type must be in [direct]");
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_track_element_get_control_binding:
|
2020-01-15 14:46:02 +00:00
|
|
|
* @object: A #GESTrackElement
|
|
|
|
* @property_name: The name of the child property to return the control
|
|
|
|
* binding of
|
2013-03-30 17:54:50 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Gets the control binding that was created for the specified child
|
|
|
|
* property of the track element using
|
|
|
|
* ges_track_element_set_control_source(). The given @property_name must
|
|
|
|
* be the same name of the child property that was passed to
|
|
|
|
* ges_track_element_set_control_source().
|
2013-03-30 17:54:50 +00:00
|
|
|
*
|
2020-01-15 14:46:02 +00:00
|
|
|
* Returns: (transfer none) (nullable): The control binding that was
|
|
|
|
* created for the specified child property of @object, or %NULL if
|
|
|
|
* @property_name does not correspond to any control binding.
|
2013-03-30 17:54:50 +00:00
|
|
|
*/
|
|
|
|
GstControlBinding *
|
|
|
|
ges_track_element_get_control_binding (GESTrackElement * object,
|
|
|
|
const gchar * property_name)
|
|
|
|
{
|
|
|
|
GESTrackElementPrivate *priv;
|
|
|
|
GstControlBinding *binding;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), NULL);
|
|
|
|
|
|
|
|
priv = GES_TRACK_ELEMENT (object)->priv;
|
|
|
|
|
|
|
|
binding =
|
|
|
|
(GstControlBinding *) g_hash_table_lookup (priv->bindings_hashtable,
|
|
|
|
property_name);
|
|
|
|
return binding;
|
|
|
|
}
|