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
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* SECTION:ges-track-element
|
2012-12-21 23:17:41 +00:00
|
|
|
* @short_description: Base Class for objects contained in a GESTrack
|
2009-09-10 16:40:51 +00:00
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* #GESTrackElement is the Base Class for any object that can be contained in a
|
2009-09-10 16:40:51 +00:00
|
|
|
* #GESTrack.
|
2009-09-14 14:33:25 +00:00
|
|
|
*
|
|
|
|
* It contains the basic information as to the location of the object within
|
2013-01-15 13:52:17 +00:00
|
|
|
* its container, like the start position, the inpoint, the duration and the
|
2009-09-14 14:33:25 +00:00
|
|
|
* priority.
|
2009-09-10 16:40:51 +00:00
|
|
|
*/
|
|
|
|
|
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"
|
2011-02-25 11:13:03 +00:00
|
|
|
#include <gobject/gvaluecollector.h>
|
2009-08-04 15:16:31 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
G_DEFINE_ABSTRACT_TYPE (GESTrackElement, ges_track_element,
|
2013-01-15 13:52:17 +00:00
|
|
|
GES_TYPE_TIMELINE_ELEMENT);
|
2009-08-06 10:14:37 +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;
|
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
/* These fields are only used before the gnlobject is available */
|
|
|
|
guint64 pending_start;
|
|
|
|
guint64 pending_inpoint;
|
|
|
|
guint64 pending_duration;
|
2010-12-16 18:24:25 +00:00
|
|
|
guint32 pending_priority;
|
2010-12-16 14:00:46 +00:00
|
|
|
gboolean pending_active;
|
|
|
|
|
|
|
|
GstElement *gnlobject; /* The GnlObject */
|
|
|
|
GstElement *element; /* The element contained in the gnlobject (can be NULL) */
|
|
|
|
|
2011-02-07 16:06:01 +00:00
|
|
|
/* We keep a link between properties name and elements internally
|
|
|
|
* The hashtable should look like
|
2011-02-23 19:30:04 +00:00
|
|
|
* {GParamaSpec ---> element,}*/
|
2011-02-07 16:06:01 +00:00
|
|
|
GHashTable *properties_hashtable;
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *timelineobj;
|
2010-12-16 14:00:46 +00:00
|
|
|
GESTrack *track;
|
|
|
|
|
|
|
|
gboolean valid;
|
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 */
|
2013-04-23 20:38:23 +00:00
|
|
|
|
|
|
|
GList *pending_bindings;
|
2010-12-04 18:54:13 +00:00
|
|
|
};
|
|
|
|
|
2013-04-23 20:38:23 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GESTrackElement *element;
|
|
|
|
GstControlSource *source;
|
|
|
|
gchar *propname;
|
|
|
|
gchar *binding_type;
|
|
|
|
} PendingBinding;
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
DEEP_NOTIFY,
|
|
|
|
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
|
|
|
|
2013-01-26 15:31:33 +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-26 15:31:33 +00:00
|
|
|
static void connect_properties_signals (GESTrackElement * object);
|
2011-02-08 14:29:21 +00:00
|
|
|
static void connect_signal (gpointer key, gpointer value, gpointer user_data);
|
|
|
|
static void gst_element_prop_changed_cb (GstElement * element, GParamSpec * arg
|
2013-02-15 02:34:48 +00:00
|
|
|
G_GNUC_UNUSED, GESTrackElement * track_element);
|
2011-02-08 14:29:21 +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);
|
|
|
|
static void _deep_copy (GESTimelineElement * element,
|
|
|
|
GESTimelineElement * copy);
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
static GParamSpec **default_list_children_properties (GESTrackElement * object,
|
2011-02-25 16:10:00 +00:00
|
|
|
guint * n_properties);
|
|
|
|
|
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-01-26 15:31:33 +00:00
|
|
|
GESTrackElementPrivate *priv = GES_TRACK_ELEMENT (object)->priv;
|
2012-05-10 16:40:23 +00:00
|
|
|
|
2011-02-07 16:06:01 +00:00
|
|
|
if (priv->properties_hashtable)
|
|
|
|
g_hash_table_destroy (priv->properties_hashtable);
|
|
|
|
|
2013-03-30 17:54:50 +00:00
|
|
|
if (priv->bindings_hashtable)
|
|
|
|
g_hash_table_destroy (priv->bindings_hashtable);
|
|
|
|
|
2012-05-10 16:40:23 +00:00
|
|
|
if (priv->gnlobject) {
|
|
|
|
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);
|
2012-05-10 16:40:23 +00:00
|
|
|
gst_element_get_state (priv->gnlobject, &cstate, NULL, 0);
|
|
|
|
if (cstate != GST_STATE_NULL)
|
|
|
|
gst_element_set_state (priv->gnlobject, GST_STATE_NULL);
|
|
|
|
}
|
|
|
|
|
2013-03-30 18:01:26 +00:00
|
|
|
g_object_set_qdata (G_OBJECT (priv->gnlobject),
|
|
|
|
GNL_OBJECT_TRACK_ELEMENT_QUARK, NULL);
|
2012-05-10 16:40:23 +00:00
|
|
|
gst_object_unref (priv->gnlobject);
|
|
|
|
priv->gnlobject = NULL;
|
|
|
|
}
|
|
|
|
|
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
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_finalize (GObject * object)
|
2009-08-06 10:14:37 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
G_OBJECT_CLASS (ges_track_element_parent_class)->finalize (object);
|
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
|
|
|
g_type_class_add_private (klass, sizeof (GESTrackElementPrivate));
|
2010-12-04 18:54:13 +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;
|
|
|
|
object_class->finalize = ges_track_element_finalize;
|
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
|
|
|
*
|
2010-07-01 14:48:45 +00:00
|
|
|
* Whether the object should be taken into account in the #GESTrack output.
|
2009-09-30 14:40:59 +00:00
|
|
|
* If #FALSE, then its contents will not be used in the resulting track.
|
|
|
|
*/
|
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
|
|
|
|
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]);
|
|
|
|
|
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]);
|
|
|
|
|
2012-01-16 12:37:22 +00:00
|
|
|
|
2011-02-08 14:29:21 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* GESTrackElement::deep-notify:
|
|
|
|
* @track_element: a #GESTrackElement
|
2011-02-08 14:29:21 +00:00
|
|
|
* @prop_object: the object that originated the signal
|
|
|
|
* @prop: the property that changed
|
|
|
|
*
|
|
|
|
* The deep notify signal is used to be notified of property changes of all
|
2013-01-26 15:31:33 +00:00
|
|
|
* the childs of @track_element
|
2011-08-13 22:52:23 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
2011-02-08 14:29:21 +00:00
|
|
|
*/
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_signals[DEEP_NOTIFY] =
|
2011-02-08 14:29:21 +00:00
|
|
|
g_signal_new ("deep-notify", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED |
|
2012-03-12 15:46:42 +00:00
|
|
|
G_SIGNAL_NO_HOOKS, 0, NULL, NULL, g_cclosure_marshal_generic,
|
2011-02-08 14:29:21 +00:00
|
|
|
G_TYPE_NONE, 2, GST_TYPE_ELEMENT, G_TYPE_PARAM);
|
|
|
|
|
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->deep_copy = _deep_copy;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
klass->create_gnl_object = ges_track_element_create_gnl_object_func;
|
2011-05-06 17:38:26 +00:00
|
|
|
/* There is no 'get_props_hashtable' default implementation */
|
2011-02-16 14:51:20 +00:00
|
|
|
klass->get_props_hastable = NULL;
|
2011-02-25 16:10:00 +00:00
|
|
|
klass->list_children_properties = default_list_children_properties;
|
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
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElementPrivate *priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
|
|
|
GES_TYPE_TRACK_ELEMENT, GESTrackElementPrivate);
|
2010-12-04 18:54:13 +00:00
|
|
|
|
2009-09-30 14:42:08 +00:00
|
|
|
/* Sane default values */
|
2012-04-24 00:17:42 +00:00
|
|
|
priv->pending_start = 0;
|
|
|
|
priv->pending_inpoint = 0;
|
|
|
|
priv->pending_duration = GST_SECOND;
|
2013-03-29 18:23:00 +00:00
|
|
|
priv->pending_priority = MIN_GNL_PRIO;
|
2012-04-24 00:17:42 +00:00
|
|
|
priv->pending_active = TRUE;
|
|
|
|
priv->properties_hashtable = NULL;
|
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);
|
2012-11-20 02:42:47 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
if (object->priv->gnlobject != NULL) {
|
2013-01-15 13:52:17 +00:00
|
|
|
if (G_UNLIKELY (start == _START (object)))
|
2009-12-11 14:13:19 +00:00
|
|
|
return FALSE;
|
2009-08-06 10:14:37 +00:00
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
g_object_set (object->priv->gnlobject, "start", start, NULL);
|
2009-12-11 14:13:19 +00:00
|
|
|
} else
|
2010-12-16 14:00:46 +00:00
|
|
|
object->priv->pending_start = start;
|
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
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
if (object->priv->gnlobject != NULL) {
|
2013-01-15 13:52:17 +00:00
|
|
|
if (G_UNLIKELY (inpoint == _INPOINT (object)))
|
|
|
|
|
2009-12-11 14:13:19 +00:00
|
|
|
return FALSE;
|
2009-08-06 10:14:37 +00:00
|
|
|
|
2013-06-09 16:29:05 +00:00
|
|
|
g_object_set (object->priv->gnlobject, "inpoint", inpoint, NULL);
|
2009-12-11 14:13:19 +00:00
|
|
|
} else
|
2010-12-16 14:00:46 +00:00
|
|
|
object->priv->pending_inpoint = inpoint;
|
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
|
|
|
|
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
|
|
|
|
|
|
|
if (priv->gnlobject != NULL) {
|
2013-01-15 13:52:17 +00:00
|
|
|
if (G_UNLIKELY (duration == _DURATION (object)))
|
2009-12-11 14:13:19 +00:00
|
|
|
return FALSE;
|
2009-08-06 10:14:37 +00:00
|
|
|
|
2013-06-09 16:29:05 +00:00
|
|
|
g_object_set (priv->gnlobject, "duration", duration, NULL);
|
2009-12-11 14:13:19 +00:00
|
|
|
} else
|
2012-04-24 00:17:42 +00:00
|
|
|
priv->pending_duration = 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
|
|
|
|
2013-03-29 18:23:00 +00:00
|
|
|
if (priority <= MIN_GNL_PRIO) {
|
|
|
|
GST_INFO_OBJECT (element, "Priority (%d) < MIN_GNL_PRIO, setting it to %d",
|
|
|
|
priority, MIN_GNL_PRIO);
|
|
|
|
priority = MIN_GNL_PRIO;
|
|
|
|
}
|
|
|
|
|
2011-03-01 16:38:52 +00:00
|
|
|
GST_DEBUG ("object:%p, priority:%" G_GUINT32_FORMAT, object, priority);
|
2010-12-16 17:20:47 +00:00
|
|
|
|
2010-12-16 18:24:25 +00:00
|
|
|
if (object->priv->gnlobject != NULL) {
|
2013-01-15 13:52:17 +00:00
|
|
|
if (G_UNLIKELY (priority == _PRIORITY (object)))
|
2010-12-16 18:24:25 +00:00
|
|
|
return FALSE;
|
2009-08-07 18:33:40 +00:00
|
|
|
|
2010-12-16 18:24:25 +00:00
|
|
|
g_object_set (object->priv->gnlobject, "priority", priority, NULL);
|
|
|
|
} else
|
|
|
|
object->priv->pending_priority = priority;
|
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
|
|
|
}
|
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_set_active:
|
|
|
|
* @object: a #GESTrackElement
|
2010-12-16 14:00:46 +00:00
|
|
|
* @active: visibility
|
|
|
|
*
|
|
|
|
* Sets the usage of the @object. If @active is %TRUE, the object will be used for
|
|
|
|
* playback and rendering, else it will be ignored.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the property was toggled, else %FALSE
|
|
|
|
*/
|
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);
|
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
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
if (object->priv->gnlobject != NULL) {
|
2009-12-11 14:13:19 +00:00
|
|
|
if (G_UNLIKELY (active == object->active))
|
|
|
|
return FALSE;
|
2009-09-30 14:40:59 +00:00
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
g_object_set (object->priv->gnlobject, "active", active, NULL);
|
2013-06-09 16:29:05 +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);
|
|
|
|
}
|
2009-12-11 14:13:19 +00:00
|
|
|
} else
|
2010-12-16 14:00:46 +00:00
|
|
|
object->priv->pending_active = active;
|
2013-06-09 16:29:05 +00:00
|
|
|
|
2009-09-30 14:40:59 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-02-08 14:29:21 +00:00
|
|
|
static void
|
|
|
|
gst_element_prop_changed_cb (GstElement * element, GParamSpec * arg
|
2013-02-15 02:34:48 +00:00
|
|
|
G_GNUC_UNUSED, GESTrackElement * track_element)
|
2011-02-08 14:29:21 +00:00
|
|
|
{
|
2013-02-15 02:34:48 +00:00
|
|
|
g_signal_emit (track_element, ges_track_element_signals[DEEP_NOTIFY], 0,
|
2011-02-08 14:29:21 +00:00
|
|
|
GST_ELEMENT (element), arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
connect_signal (gpointer key, gpointer value, gpointer user_data)
|
|
|
|
{
|
2011-03-16 20:23:53 +00:00
|
|
|
gchar *signame = g_strconcat ("notify::", G_PARAM_SPEC (key)->name, NULL);
|
2011-02-08 14:29:21 +00:00
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (value),
|
|
|
|
signame, G_CALLBACK (gst_element_prop_changed_cb),
|
2013-01-26 15:31:33 +00:00
|
|
|
GES_TRACK_ELEMENT (user_data));
|
2011-02-08 14:29:21 +00:00
|
|
|
|
|
|
|
g_free (signame);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-26 15:31:33 +00:00
|
|
|
connect_properties_signals (GESTrackElement * object)
|
2011-02-08 14:29:21 +00:00
|
|
|
{
|
2011-02-25 09:54:55 +00:00
|
|
|
if (G_UNLIKELY (!object->priv->properties_hashtable)) {
|
2011-02-08 14:29:21 +00:00
|
|
|
GST_WARNING ("The properties_hashtable hasn't been set");
|
2011-02-25 09:54:55 +00:00
|
|
|
return;
|
2011-02-08 14:29:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_hash_table_foreach (object->priv->properties_hashtable,
|
|
|
|
(GHFunc) connect_signal, object);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
/* default 'create_gnl_object' virtual method implementation */
|
2010-12-16 14:00:46 +00:00
|
|
|
static GstElement *
|
2013-01-26 15:31:33 +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;
|
|
|
|
GstElement *gnlobject;
|
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
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
if (G_UNLIKELY (self->priv->gnlobject != NULL))
|
2010-12-10 11:15:54 +00:00
|
|
|
goto already_have_gnlobject;
|
|
|
|
|
|
|
|
if (G_UNLIKELY (klass->gnlobject_factorytype == NULL))
|
|
|
|
goto no_gnlfactory;
|
|
|
|
|
|
|
|
GST_DEBUG ("Creating a supporting gnlobject of type '%s'",
|
|
|
|
klass->gnlobject_factorytype);
|
|
|
|
|
|
|
|
gnlobject = gst_element_factory_make (klass->gnlobject_factorytype, NULL);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (gnlobject == NULL))
|
|
|
|
goto no_gnlobject;
|
|
|
|
|
|
|
|
if (klass->create_element) {
|
|
|
|
GST_DEBUG ("Calling subclass 'create_element' vmethod");
|
|
|
|
child = klass->create_element (self);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!child))
|
|
|
|
goto child_failure;
|
|
|
|
|
|
|
|
if (!gst_bin_add (GST_BIN (gnlobject), child))
|
|
|
|
goto add_failure;
|
|
|
|
|
|
|
|
GST_DEBUG ("Succesfully got the element to put in the gnlobject");
|
2010-12-16 14:00:46 +00:00
|
|
|
self->priv->element = child;
|
2010-12-10 11:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG ("done");
|
2010-12-16 14:00:46 +00:00
|
|
|
return gnlobject;
|
2010-12-10 11:15:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* ERROR CASES */
|
|
|
|
|
|
|
|
already_have_gnlobject:
|
|
|
|
{
|
|
|
|
GST_ERROR ("Already controlling a GnlObject %s",
|
2010-12-16 14:00:46 +00:00
|
|
|
GST_ELEMENT_NAME (self->priv->gnlobject));
|
|
|
|
return NULL;
|
2010-12-10 11:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
no_gnlfactory:
|
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_ERROR ("No GESTrackElement::gnlobject_factorytype implementation!");
|
2010-12-16 14:00:46 +00:00
|
|
|
return NULL;
|
2010-12-10 11:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
no_gnlobject:
|
|
|
|
{
|
|
|
|
GST_ERROR ("Error creating a gnlobject of type '%s'",
|
|
|
|
klass->gnlobject_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");
|
|
|
|
gst_object_unref (gnlobject);
|
2010-12-16 14:00:46 +00:00
|
|
|
return NULL;
|
2010-12-10 11:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
add_failure:
|
|
|
|
{
|
|
|
|
GST_ERROR ("Error adding the contents to the gnlobject");
|
|
|
|
gst_object_unref (child);
|
|
|
|
gst_object_unref (gnlobject);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-01-26 15:31:33 +00:00
|
|
|
ensure_gnl_object (GESTrackElement * object)
|
2009-08-06 15:38:43 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElementClass *class;
|
2010-12-16 14:00:46 +00:00
|
|
|
GstElement *gnlobject;
|
2011-02-07 16:06:01 +00:00
|
|
|
GHashTable *props_hash;
|
2012-01-26 10:53:54 +00:00
|
|
|
gboolean res = TRUE;
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
if (object->priv->gnlobject && object->priv->valid)
|
|
|
|
return FALSE;
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2009-08-07 14:43:01 +00:00
|
|
|
/* 1. Create the GnlObject */
|
|
|
|
GST_DEBUG ("Creating GnlObject");
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
class = GES_TRACK_ELEMENT_GET_CLASS (object);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
|
|
|
if (G_UNLIKELY (class->create_gnl_object == NULL)) {
|
|
|
|
GST_ERROR ("No 'create_gnl_object' implementation !");
|
2011-01-10 14:10:01 +00:00
|
|
|
goto done;
|
2009-08-06 15:38:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG ("Calling virtual method");
|
|
|
|
|
2012-04-17 22:42:41 +00:00
|
|
|
/* 2. Fill in the GnlObject */
|
|
|
|
if (object->priv->gnlobject == NULL) {
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2012-04-17 22:42:41 +00:00
|
|
|
/* call the create_gnl_object virtual method */
|
|
|
|
gnlobject = class->create_gnl_object (object);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2012-04-17 22:42:41 +00:00
|
|
|
if (G_UNLIKELY (gnlobject == NULL)) {
|
|
|
|
GST_ERROR
|
|
|
|
("'create_gnl_object' implementation returned TRUE but no GnlObject is available");
|
|
|
|
goto done;
|
|
|
|
}
|
2010-12-16 14:00:46 +00:00
|
|
|
|
2012-04-17 22:42:41 +00:00
|
|
|
GST_DEBUG_OBJECT (object, "Got a valid GnlObject, now filling it in");
|
|
|
|
|
2012-05-10 16:40:23 +00:00
|
|
|
object->priv->gnlobject = gst_object_ref (gnlobject);
|
2013-03-30 18:01:26 +00:00
|
|
|
g_object_set_qdata (G_OBJECT (gnlobject), GNL_OBJECT_TRACK_ELEMENT_QUARK,
|
|
|
|
object);
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2012-01-26 10:53:54 +00:00
|
|
|
if (object->priv->timelineobj)
|
2013-01-26 15:31:33 +00:00
|
|
|
res = ges_clip_fill_track_element (object->priv->timelineobj,
|
2012-01-26 10:53:54 +00:00
|
|
|
object, object->priv->gnlobject);
|
|
|
|
else
|
|
|
|
res = TRUE;
|
|
|
|
|
2009-08-07 16:18:42 +00:00
|
|
|
if (res) {
|
|
|
|
/* Set some properties on the GnlObject */
|
2010-12-16 14:00:46 +00:00
|
|
|
g_object_set (object->priv->gnlobject,
|
|
|
|
"duration", object->priv->pending_duration,
|
|
|
|
"start", object->priv->pending_start,
|
2013-06-09 16:29:05 +00:00
|
|
|
"inpoint", object->priv->pending_inpoint,
|
2010-12-16 18:24:25 +00:00
|
|
|
"priority", object->priv->pending_priority,
|
2010-12-16 14:00:46 +00:00
|
|
|
"active", object->priv->pending_active, NULL);
|
2009-12-11 14:13:19 +00:00
|
|
|
|
2013-06-09 16:29:05 +00:00
|
|
|
/* Pendings values are not pending anymore */
|
|
|
|
GES_TIMELINE_ELEMENT_START (object) = object->priv->pending_start;
|
|
|
|
GES_TIMELINE_ELEMENT_INPOINT (object) = object->priv->pending_inpoint;
|
|
|
|
GES_TIMELINE_ELEMENT_DURATION (object) = object->priv->pending_duration;
|
|
|
|
GES_TIMELINE_ELEMENT_PRIORITY (object) = object->priv->pending_priority;
|
|
|
|
object->active = object->priv->pending_active;
|
|
|
|
|
|
|
|
|
2012-04-17 22:42:41 +00:00
|
|
|
if (object->priv->track != NULL)
|
|
|
|
g_object_set (object->priv->gnlobject,
|
|
|
|
"caps", ges_track_get_caps (object->priv->track), NULL);
|
|
|
|
|
2011-02-07 16:06:01 +00:00
|
|
|
/* We feed up the props_hashtable if possible */
|
|
|
|
if (class->get_props_hastable) {
|
|
|
|
props_hash = class->get_props_hastable (object);
|
|
|
|
|
|
|
|
if (props_hash == NULL) {
|
2011-05-06 09:56:30 +00:00
|
|
|
GST_DEBUG ("'get_props_hastable' implementation returned TRUE but no"
|
|
|
|
"properties_hashtable is available");
|
2011-02-07 16:06:01 +00:00
|
|
|
} else {
|
|
|
|
object->priv->properties_hashtable = props_hash;
|
2011-02-08 14:29:21 +00:00
|
|
|
connect_properties_signals (object);
|
2011-02-07 16:06:01 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-07 16:18:42 +00:00
|
|
|
}
|
2009-08-06 15:38:43 +00:00
|
|
|
}
|
|
|
|
|
2011-01-10 14:10:01 +00:00
|
|
|
done:
|
2010-12-16 14:00:46 +00:00
|
|
|
object->priv->valid = res;
|
2009-08-07 14:43:01 +00:00
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
GST_DEBUG ("Returning res:%d", res);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
/* INTERNAL USAGE */
|
2013-04-23 20:38:23 +00:00
|
|
|
static void
|
|
|
|
_free_pending_binding (PendingBinding * pend)
|
|
|
|
{
|
|
|
|
g_slice_free (PendingBinding, pend);
|
|
|
|
}
|
|
|
|
|
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;
|
2009-08-06 15:38:43 +00:00
|
|
|
GST_DEBUG ("object:%p, track:%p", object, track);
|
|
|
|
|
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) {
|
|
|
|
/* If we already have a gnlobject, we just set its caps properly */
|
|
|
|
if (object->priv->gnlobject) {
|
|
|
|
g_object_set (object->priv->gnlobject,
|
|
|
|
"caps", ges_track_get_caps (object->priv->track), NULL);
|
|
|
|
} else {
|
2013-01-10 21:09:23 +00:00
|
|
|
ret = ensure_gnl_object (object);
|
2013-04-23 20:38:23 +00:00
|
|
|
|
|
|
|
/* if we had pending control bindings, add them and free them */
|
|
|
|
if (ret && object->priv->pending_bindings) {
|
|
|
|
GList *tmp;
|
|
|
|
PendingBinding *pbinding;
|
|
|
|
|
|
|
|
GST_INFO_OBJECT (object, "Asynchronously adding bindings");
|
|
|
|
for (tmp = object->priv->pending_bindings; tmp; tmp = tmp->next) {
|
|
|
|
pbinding = tmp->data;
|
|
|
|
ges_track_element_set_control_source (pbinding->element,
|
|
|
|
pbinding->source, pbinding->propname, pbinding->binding_type);
|
|
|
|
g_free (pbinding->propname);
|
|
|
|
g_free (pbinding->binding_type);
|
|
|
|
}
|
|
|
|
g_list_free_full (object->priv->pending_bindings,
|
|
|
|
(GDestroyNotify) _free_pending_binding);
|
|
|
|
object->priv->pending_bindings = 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
|
|
|
}
|
|
|
|
|
2013-03-30 17:54:50 +00:00
|
|
|
GHashTable *
|
|
|
|
ges_track_element_get_bindings_hashtable (GESTrackElement * trackelement)
|
|
|
|
{
|
|
|
|
GESTrackElementPrivate *priv = GES_TRACK_ELEMENT (trackelement)->priv;
|
|
|
|
|
|
|
|
return priv->bindings_hashtable;
|
|
|
|
}
|
|
|
|
|
2013-03-29 18:23:00 +00:00
|
|
|
guint32
|
|
|
|
_ges_track_element_get_layer_priority (GESTrackElement * element)
|
|
|
|
{
|
|
|
|
if (_PRIORITY (element) < LAYER_HEIGHT + MIN_GNL_PRIO)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return (_PRIORITY (element) - MIN_GNL_PRIO) / LAYER_HEIGHT;
|
|
|
|
}
|
|
|
|
|
2010-12-16 14:00:46 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_get_track:
|
|
|
|
* @object: a #GESTrackElement
|
2010-12-16 14:00:46 +00:00
|
|
|
*
|
2011-02-25 09:54:55 +00:00
|
|
|
* Get the #GESTrack to which this object belongs.
|
2011-01-10 13:28:35 +00:00
|
|
|
*
|
2010-12-16 14:00:46 +00:00
|
|
|
* Returns: (transfer none): The #GESTrack to which this object belongs. Can be %NULL if it
|
|
|
|
* is not in any track
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_get_gnlobject:
|
|
|
|
* @object: a #GESTrackElement
|
2010-12-16 14:00:46 +00:00
|
|
|
*
|
2011-01-10 13:28:35 +00:00
|
|
|
* Get the GNonLin object this object is controlling.
|
|
|
|
*
|
2010-12-16 14:00:46 +00:00
|
|
|
* Returns: (transfer none): the GNonLin object this object is controlling.
|
|
|
|
*/
|
|
|
|
GstElement *
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_get_gnlobject (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->gnlobject;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_get_element:
|
|
|
|
* @object: a #GESTrackElement
|
2010-12-16 14:00:46 +00:00
|
|
|
*
|
2013-02-08 19:39:18 +00:00
|
|
|
* Get the #GstElement this track element is controlling within GNonLin.
|
2011-01-10 13:28:35 +00:00
|
|
|
*
|
2013-02-08 19:39:18 +00:00
|
|
|
* Returns: (transfer none): the #GstElement this track element is controlling
|
2010-12-16 14:00:46 +00:00
|
|
|
* within GNonLin.
|
|
|
|
*/
|
|
|
|
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:
|
|
|
|
* @object: a #GESTrackElement
|
2011-02-03 14:11:54 +00:00
|
|
|
*
|
|
|
|
* Lets you know if @object will be used for playback and rendering,
|
|
|
|
* or not.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @object is active, %FALSE otherwize
|
2011-05-20 14:02:58 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
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);
|
2012-04-23 23:20:18 +00:00
|
|
|
|
2011-02-03 14:11:54 +00:00
|
|
|
if (G_UNLIKELY (object->priv->gnlobject == NULL))
|
|
|
|
return object->priv->pending_active;
|
|
|
|
else
|
|
|
|
return object->active;
|
|
|
|
}
|
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:
|
2011-02-25 10:32:44 +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
|
|
|
|
* @pspec: (out) (allow-none) (transfer full): pointer to take the #GParamSpec
|
|
|
|
* 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.
|
2011-05-20 14:02:58 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
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
|
|
|
{
|
|
|
|
GHashTableIter iter;
|
|
|
|
gpointer key, value;
|
|
|
|
gchar **names, *name, *classename;
|
|
|
|
gboolean res;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElementPrivate *priv;
|
2012-04-23 23:20:18 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
priv = object->priv;
|
2011-02-25 10:32:44 +00:00
|
|
|
|
2012-12-19 13:37:02 +00:00
|
|
|
if (!priv->properties_hashtable)
|
|
|
|
goto prop_hash_not_set;
|
|
|
|
|
2011-02-25 10:32:44 +00:00
|
|
|
classename = NULL;
|
|
|
|
res = FALSE;
|
|
|
|
|
|
|
|
names = g_strsplit (prop_name, "::", 2);
|
|
|
|
if (names[1] != NULL) {
|
|
|
|
classename = names[0];
|
|
|
|
name = names[1];
|
|
|
|
} else
|
|
|
|
name = names[0];
|
|
|
|
|
|
|
|
g_hash_table_iter_init (&iter, priv->properties_hashtable);
|
|
|
|
while (g_hash_table_iter_next (&iter, &key, &value)) {
|
|
|
|
if (g_strcmp0 (G_PARAM_SPEC (key)->name, name) == 0) {
|
|
|
|
if (classename == NULL ||
|
|
|
|
g_strcmp0 (G_OBJECT_TYPE_NAME (G_OBJECT (value)), classename) == 0) {
|
2011-11-16 18:22:33 +00:00
|
|
|
GST_DEBUG ("The %s property from %s has been found", name, classename);
|
2011-02-25 10:32:44 +00:00
|
|
|
if (element)
|
2013-03-16 22:05:04 +00:00
|
|
|
*element = gst_object_ref (value);
|
2011-02-25 10:32:44 +00:00
|
|
|
|
|
|
|
*pspec = g_param_spec_ref (key);
|
|
|
|
res = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_strfreev (names);
|
|
|
|
|
|
|
|
return res;
|
2012-12-19 13:37:02 +00:00
|
|
|
|
|
|
|
prop_hash_not_set:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (object, "The child properties haven't been set yet");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-02-25 10:32:44 +00:00
|
|
|
}
|
|
|
|
|
2011-02-08 09:25:41 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_set_child_property_by_pspec:
|
|
|
|
* @object: a #GESTrackElement
|
2011-02-25 11:13:03 +00:00
|
|
|
* @pspec: The #GParamSpec that specifies the property you want to set
|
2011-02-08 09:25:41 +00:00
|
|
|
* @value: the value
|
|
|
|
*
|
2011-02-25 11:13:03 +00:00
|
|
|
* Sets a property of a child of @object.
|
2011-05-20 14:02:58 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
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
|
|
|
{
|
2011-02-25 11:13:03 +00:00
|
|
|
GstElement *element;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElementPrivate *priv;
|
2011-02-25 11:13:03 +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
|
|
|
|
2012-04-23 23:20:18 +00:00
|
|
|
priv = object->priv;
|
2011-02-08 09:25:41 +00:00
|
|
|
|
2011-02-25 11:13:03 +00:00
|
|
|
if (!priv->properties_hashtable)
|
|
|
|
goto prop_hash_not_set;
|
|
|
|
|
|
|
|
element = g_hash_table_lookup (priv->properties_hashtable, pspec);
|
|
|
|
if (!element)
|
|
|
|
goto not_found;
|
|
|
|
|
|
|
|
g_object_set_property (G_OBJECT (element), pspec->name, value);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
not_found:
|
|
|
|
{
|
|
|
|
GST_ERROR ("The %s property doesn't exist", pspec->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
prop_hash_not_set:
|
|
|
|
{
|
2011-02-08 09:25:41 +00:00
|
|
|
GST_DEBUG ("The child properties haven't been set on %p", object);
|
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
|
|
|
|
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_set_child_property_valist:
|
|
|
|
* @object: The #GESTrackElement parent object
|
2011-02-25 11:13:03 +00:00
|
|
|
* @first_property_name: The name of the first property to set
|
|
|
|
* @var_args: 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.
|
2011-05-20 14:02:58 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
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)
|
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
GParamSpec *pspec;
|
|
|
|
GstElement *element;
|
|
|
|
|
|
|
|
gchar *error = NULL;
|
|
|
|
GValue value = { 0, };
|
|
|
|
|
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
|
|
|
|
|
|
|
name = first_property_name;
|
|
|
|
|
|
|
|
/* Note: This part is in big part copied from the gst_child_object_set_valist
|
|
|
|
* method. */
|
|
|
|
|
|
|
|
/* iterate over pairs */
|
|
|
|
while (name) {
|
2013-01-26 15:31:33 +00:00
|
|
|
if (!ges_track_element_lookup_child (object, name, &element, &pspec))
|
2011-02-25 11:13:03 +00:00
|
|
|
goto not_found;
|
|
|
|
|
|
|
|
#if GLIB_CHECK_VERSION(2,23,3)
|
|
|
|
G_VALUE_COLLECT_INIT (&value, pspec->value_type, var_args,
|
|
|
|
G_VALUE_NOCOPY_CONTENTS, &error);
|
|
|
|
#else
|
|
|
|
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
|
|
|
G_VALUE_COLLECT (&value, var_args, G_VALUE_NOCOPY_CONTENTS, &error);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
goto cant_copy;
|
|
|
|
|
|
|
|
g_object_set_property (G_OBJECT (element), pspec->name, &value);
|
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (element);
|
2011-02-25 11:13:03 +00:00
|
|
|
g_value_unset (&value);
|
|
|
|
|
|
|
|
name = va_arg (var_args, gchar *);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
not_found:
|
|
|
|
{
|
|
|
|
GST_WARNING ("No property %s in OBJECT\n", name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cant_copy:
|
|
|
|
{
|
|
|
|
GST_WARNING ("error copying value %s in object %p: %s", pspec->name, object,
|
|
|
|
error);
|
|
|
|
g_value_unset (&value);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_set_child_properties:
|
|
|
|
* @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.
|
2011-05-20 14:02:58 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_get_child_property_valist:
|
|
|
|
* @object: The #GESTrackElement parent object
|
2011-02-25 11:13:03 +00:00
|
|
|
* @first_property_name: The name of the first property to get
|
|
|
|
* @var_args: value for the first property, followed optionally by more
|
|
|
|
* 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.
|
2011-05-20 14:02:58 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
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)
|
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
gchar *error = NULL;
|
|
|
|
GValue value = { 0, };
|
|
|
|
GParamSpec *pspec;
|
|
|
|
GstElement *element;
|
|
|
|
|
|
|
|
g_return_if_fail (G_IS_OBJECT (object));
|
|
|
|
|
|
|
|
name = first_property_name;
|
|
|
|
|
|
|
|
/* This part is in big part copied from the gst_child_object_get_valist method */
|
|
|
|
while (name) {
|
2013-01-26 15:31:33 +00:00
|
|
|
if (!ges_track_element_lookup_child (object, name, &element, &pspec))
|
2011-02-25 11:13:03 +00:00
|
|
|
goto not_found;
|
|
|
|
|
|
|
|
g_value_init (&value, pspec->value_type);
|
|
|
|
g_object_get_property (G_OBJECT (element), pspec->name, &value);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (element);
|
2011-02-25 11:13:03 +00:00
|
|
|
|
|
|
|
G_VALUE_LCOPY (&value, var_args, 0, &error);
|
|
|
|
if (error)
|
|
|
|
goto cant_copy;
|
|
|
|
g_value_unset (&value);
|
|
|
|
name = va_arg (var_args, gchar *);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
not_found:
|
|
|
|
{
|
|
|
|
GST_WARNING ("no property %s in object", name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cant_copy:
|
|
|
|
{
|
|
|
|
GST_WARNING ("error copying value %s in object %p: %s", pspec->name, object,
|
|
|
|
error);
|
|
|
|
g_value_unset (&value);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*
|
2012-08-15 00:33:57 +00:00
|
|
|
* Returns: (transfer full) (array length=n_properties): an array of #GParamSpec* which should be freed after use or
|
2011-05-07 14:59:06 +00:00
|
|
|
* %NULL if something went wrong
|
2011-05-20 14:02:58 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
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)
|
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElementClass *class;
|
2011-05-06 17:41:38 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), NULL);
|
2011-05-06 17:41:38 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
class = GES_TRACK_ELEMENT_GET_CLASS (object);
|
2011-02-25 16:10:00 +00:00
|
|
|
|
|
|
|
return class->list_children_properties (object, n_properties);
|
|
|
|
}
|
|
|
|
|
2011-02-25 11:13:03 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_get_child_properties:
|
|
|
|
* @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.
|
2011-05-20 14:02:58 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_get_child_property_by_pspec:
|
|
|
|
* @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.
|
2011-05-20 14:02:58 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.2
|
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)
|
|
|
|
{
|
|
|
|
GstElement *element;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElementPrivate *priv;
|
2011-02-25 11:13:03 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
priv = object->priv;
|
2011-02-08 10:06:57 +00:00
|
|
|
|
2011-02-25 11:13:03 +00:00
|
|
|
if (!priv->properties_hashtable)
|
|
|
|
goto prop_hash_not_set;
|
|
|
|
|
|
|
|
element = g_hash_table_lookup (priv->properties_hashtable, pspec);
|
|
|
|
if (!element)
|
|
|
|
goto not_found;
|
|
|
|
|
|
|
|
g_object_get_property (G_OBJECT (element), pspec->name, value);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
not_found:
|
|
|
|
{
|
|
|
|
GST_ERROR ("The %s property doesn't exist", pspec->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
prop_hash_not_set:
|
|
|
|
{
|
|
|
|
GST_ERROR ("The child properties haven't been set on %p", object);
|
|
|
|
return;
|
2011-02-08 10:06:57 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-25 16:10:00 +00:00
|
|
|
|
2012-12-19 13:37:02 +00:00
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_set_child_property:
|
|
|
|
* @object: The origin #GESTrackElement
|
2012-12-19 13:37:02 +00:00
|
|
|
* @property_name: The name of the property
|
|
|
|
* @value: the value
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the property was set, %FALSE otherwize
|
|
|
|
*/
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
GParamSpec *pspec;
|
|
|
|
GstElement *element;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), FALSE);
|
2012-12-19 13:37:02 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (!ges_track_element_lookup_child (object, property_name, &element, &pspec))
|
2012-12-19 13:37:02 +00:00
|
|
|
goto not_found;
|
|
|
|
|
|
|
|
g_object_set_property (G_OBJECT (element), pspec->name, value);
|
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (element);
|
2012-12-19 13:37:02 +00:00
|
|
|
g_param_spec_unref (pspec);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
not_found:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (object, "The %s property doesn't exist", property_name);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_get_child_property:
|
|
|
|
* @object: The origin #GESTrackElement
|
2012-12-19 13:37:02 +00:00
|
|
|
* @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.
|
|
|
|
*
|
2013-01-26 15:31:33 +00:00
|
|
|
* Note that #ges_track_element_get_child_property is really
|
|
|
|
* intended for language bindings, #ges_track_element_get_child_properties
|
2012-12-19 13:37:02 +00:00
|
|
|
* is much more convenient for C programming.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the property was found, %FALSE otherwize
|
|
|
|
*/
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
GParamSpec *pspec;
|
|
|
|
GstElement *element;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), FALSE);
|
2012-12-19 13:37:02 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (!ges_track_element_lookup_child (object, property_name, &element, &pspec))
|
2012-12-19 13:37:02 +00:00
|
|
|
goto not_found;
|
|
|
|
|
|
|
|
if (G_VALUE_TYPE (value) == G_TYPE_INVALID)
|
|
|
|
g_value_init (value, pspec->value_type);
|
|
|
|
|
|
|
|
g_object_get_property (G_OBJECT (element), pspec->name, value);
|
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (element);
|
2012-12-19 13:37:02 +00:00
|
|
|
g_param_spec_unref (pspec);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
not_found:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (object, "The %s property doesn't exist", property_name);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-06 17:41:16 +00:00
|
|
|
static GParamSpec **
|
2013-01-26 15:31:33 +00:00
|
|
|
default_list_children_properties (GESTrackElement * object,
|
|
|
|
guint * n_properties)
|
2011-02-25 16:10:00 +00:00
|
|
|
{
|
|
|
|
GParamSpec **pspec, *spec;
|
|
|
|
GHashTableIter iter;
|
|
|
|
gpointer key, value;
|
|
|
|
|
|
|
|
guint i = 0;
|
|
|
|
|
|
|
|
if (!object->priv->properties_hashtable)
|
|
|
|
goto prop_hash_not_set;
|
|
|
|
|
|
|
|
*n_properties = g_hash_table_size (object->priv->properties_hashtable);
|
|
|
|
pspec = g_new (GParamSpec *, *n_properties);
|
|
|
|
|
|
|
|
g_hash_table_iter_init (&iter, object->priv->properties_hashtable);
|
|
|
|
while (g_hash_table_iter_next (&iter, &key, &value)) {
|
|
|
|
spec = G_PARAM_SPEC (key);
|
|
|
|
pspec[i] = g_param_spec_ref (spec);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pspec;
|
|
|
|
|
|
|
|
prop_hash_not_set:
|
|
|
|
{
|
2011-06-06 22:49:58 +00:00
|
|
|
*n_properties = 0;
|
2013-01-22 19:51:25 +00:00
|
|
|
GST_DEBUG_OBJECT (object, "No child properties have been set yet");
|
2011-02-25 16:10:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2012-01-16 12:37:22 +00:00
|
|
|
|
|
|
|
void
|
2013-01-15 13:52:17 +00:00
|
|
|
_deep_copy (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
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
ensure_gnl_object (copy);
|
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) {
|
|
|
|
g_value_init (&val, specs[n]->value_type);
|
2013-01-15 13:52:17 +00:00
|
|
|
g_object_get_property (G_OBJECT (element), specs[n]->name, &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
|
|
|
|
|
|
|
/**
|
2013-01-26 15:31:33 +00:00
|
|
|
* ges_track_element_edit:
|
|
|
|
* @object: the #GESTrackElement to edit
|
2013-04-23 23:04:04 +00:00
|
|
|
* @layers: (element-type GESLayer): The layers you want the edit to
|
2012-04-24 00:52:45 +00:00
|
|
|
* happen in, %NULL means that the edition is done in all the
|
2013-04-23 23:04:04 +00:00
|
|
|
* #GESLayers contained in the current timeline.
|
2012-04-24 00:52:45 +00:00
|
|
|
* FIXME: This is not implemented yet.
|
|
|
|
* @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-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
|
|
|
GESTrack *track = ges_track_element_get_track (object);
|
2012-04-24 00:52:45 +00:00
|
|
|
GESTimeline *timeline;
|
|
|
|
|
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
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
if (G_UNLIKELY (!track)) {
|
|
|
|
GST_WARNING_OBJECT (object, "Trying to edit in %d mode but not in"
|
|
|
|
"any Track yet.", mode);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
timeline = GES_TIMELINE (ges_track_get_timeline (track));
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!timeline)) {
|
|
|
|
GST_WARNING_OBJECT (object, "Trying to edit in %d mode but not in"
|
|
|
|
"track %p no in any timeline yet.", mode, track);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case GES_EDIT_MODE_NORMAL:
|
|
|
|
timeline_move_object (timeline, object, layers, edge, position);
|
|
|
|
break;
|
|
|
|
case GES_EDIT_MODE_TRIM:
|
|
|
|
timeline_trim_object (timeline, object, layers, edge, position);
|
|
|
|
break;
|
|
|
|
case GES_EDIT_MODE_RIPPLE:
|
|
|
|
timeline_ripple_object (timeline, object, layers, edge, position);
|
|
|
|
break;
|
|
|
|
case GES_EDIT_MODE_ROLL:
|
|
|
|
timeline_roll_object (timeline, object, layers, edge, position);
|
|
|
|
break;
|
|
|
|
case GES_EDIT_MODE_SLIDE:
|
|
|
|
timeline_slide_object (timeline, object, layers, edge, position);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GST_ERROR ("Unkown edit mode: %d", mode);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2013-03-30 17:54:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2013-03-31 14:07:14 +00:00
|
|
|
* ges_track_element_set_control_source:
|
2013-03-30 17:54:50 +00:00
|
|
|
* @object: the #GESTrackElement on which to set a control binding
|
|
|
|
* @source: (element-type GstControlSource): the #GstControlSource to set on the binding.
|
|
|
|
* @property_name: The name of the property to control.
|
|
|
|
* @binding_type: The type of binding to create. Only "direct" is available for now.
|
|
|
|
*
|
|
|
|
* Creates a #GstControlBinding and adds it to the #GstElement concerned by the
|
|
|
|
* property. Use the same syntax as #ges_track_element_lookup_child for
|
|
|
|
* the property name.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the binding could be created and added, %FALSE if an error
|
|
|
|
* occured
|
|
|
|
*
|
|
|
|
* Since: 1.0.XX
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-04-23 20:38:23 +00:00
|
|
|
if (!priv->track) {
|
|
|
|
PendingBinding *pbinding;
|
|
|
|
|
|
|
|
GST_INFO ("Adding this source to the future bindings");
|
|
|
|
pbinding = g_slice_new0 (PendingBinding);
|
|
|
|
pbinding->element = object;
|
|
|
|
pbinding->source = source;
|
|
|
|
pbinding->propname = g_strdup (property_name);
|
|
|
|
pbinding->binding_type = g_strdup (binding_type);
|
|
|
|
priv->pending_bindings = g_list_append (priv->pending_bindings, pbinding);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-03-30 17:54:50 +00:00
|
|
|
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 */
|
|
|
|
if (!g_strcmp0 (binding_type, "direct")) {
|
|
|
|
/* First remove existing binding */
|
|
|
|
binding =
|
|
|
|
(GstControlBinding *) g_hash_table_lookup (priv->bindings_hashtable,
|
|
|
|
property_name);
|
|
|
|
if (binding) {
|
|
|
|
GST_LOG ("Removing old binding %p for property %s", binding,
|
|
|
|
property_name);
|
|
|
|
gst_object_remove_control_binding (GST_OBJECT (element), binding);
|
|
|
|
}
|
|
|
|
binding =
|
|
|
|
gst_direct_control_binding_new (GST_OBJECT (element), property_name,
|
|
|
|
source);
|
|
|
|
gst_object_add_control_binding (GST_OBJECT (element), binding);
|
|
|
|
g_hash_table_insert (priv->bindings_hashtable, g_strdup (property_name),
|
|
|
|
binding);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_WARNING ("Binding type must be in [direct]");
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_track_element_get_control_binding:
|
|
|
|
* @object: the #GESTrackElement in which to lookup the bindings.
|
|
|
|
* @property_name: The property_name to which the binding is associated.
|
|
|
|
*
|
|
|
|
* Looks up the various controlled properties for that #GESTrackElement,
|
|
|
|
* and returns the #GstControlBinding which controls @property_name.
|
|
|
|
*
|
2013-04-23 20:38:23 +00:00
|
|
|
* Returns: (transfer none): the #GstControlBinding associated with @property_name, or %NULL
|
2013-03-30 17:54:50 +00:00
|
|
|
* if that property is not controlled.
|
|
|
|
*
|
|
|
|
* Since: 1.0.XX
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|