element: Add a property allowing user to avoid serializing TimelineElements on demand

This commit is contained in:
Thibault Saunier 2014-11-10 16:20:29 +01:00
parent 5665e3abb1
commit fd268f0387
2 changed files with 57 additions and 2 deletions

View file

@ -63,6 +63,7 @@ enum
PROP_MAX_DURATION,
PROP_PRIORITY,
PROP_NAME,
PROP_SERIALIZE,
PROP_LAST
};
@ -70,7 +71,7 @@ static GParamSpec *properties[PROP_LAST] = { NULL, };
struct _GESTimelineElementPrivate
{
gpointer dummy;
gboolean serialize;
};
static void
@ -104,6 +105,9 @@ _get_property (GObject * object, guint property_id,
case PROP_NAME:
g_value_take_string (value, ges_timeline_element_get_name (self));
break;
case PROP_SERIALIZE:
g_value_set_boolean (value, self->priv->serialize);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, property_id, pspec);
}
@ -140,6 +144,9 @@ _set_property (GObject * object, guint property_id,
case PROP_NAME:
ges_timeline_element_set_name (self, g_value_get_string (value));
break;
case PROP_SERIALIZE:
self->priv->serialize = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, property_id, pspec);
}
@ -156,8 +163,12 @@ ges_timeline_element_finalize (GObject * self)
}
static void
ges_timeline_element_init (GESTimelineElement * ges_timeline_element)
ges_timeline_element_init (GESTimelineElement * self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
GES_TYPE_TIMELINE_ELEMENT, GESTimelineElementPrivate);
self->priv->serialize = TRUE;
}
static void
@ -165,6 +176,8 @@ ges_timeline_element_class_init (GESTimelineElementClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (GESTimelineElementPrivate));
object_class->get_property = _get_property;
object_class->set_property = _set_property;
@ -244,6 +257,15 @@ ges_timeline_element_class_init (GESTimelineElementClass * klass)
g_param_spec_string ("name", "Name", "The name of the timeline object",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
/**
* GESTimelineElement:serialize:
*
* Whether the element should be serialized.
*/
properties[PROP_SERIALIZE] = g_param_spec_boolean ("serialize", "Serialize",
"Whether the element should be serialized", TRUE,
G_PARAM_READWRITE | GES_PARAM_NO_SERIALIZATION);
g_object_class_install_properties (object_class, PROP_LAST, properties);
object_class->finalize = ges_timeline_element_finalize;

View file

@ -1030,6 +1030,15 @@ _save_effect (GString * str, guint clip_id, GESTrackElement * trackelement,
GList *tmp, *tracks;
gchar *properties, *metas;
guint track_id = 0;
gboolean serialize;
g_object_get (trackelement, "serialize", &serialize, NULL);
if (!serialize) {
GST_DEBUG_OBJECT (trackelement, "Should not be serialized");
return;
}
tck = ges_track_element_get_track (trackelement);
if (tck == NULL) {
@ -1095,8 +1104,16 @@ _save_layers (GESXmlFormatter * self, GString * str, GESTimeline * timeline)
GList *effects, *tmpeffect;
GList *tmptrackelement;
GList *tracks;
gboolean serialize;
clip = GES_CLIP (tmpclip->data);
g_object_get (clip, "serialize", &serialize, NULL);
if (!serialize) {
GST_DEBUG_OBJECT (clip, "Should not be serialized");
continue;
}
effects = ges_clip_get_top_effects (clip);
/* We escape all mandatrorry properties that are handled sparetely
@ -1127,10 +1144,17 @@ _save_layers (GESXmlFormatter * self, GString * str, GESTimeline * timeline)
for (tmptrackelement = GES_CONTAINER_CHILDREN (clip); tmptrackelement;
tmptrackelement = tmptrackelement->next) {
gint index;
gboolean serialize;
if (!GES_IS_SOURCE (tmptrackelement->data))
continue;
g_object_get (tmptrackelement->data, "serialize", &serialize, NULL);
if (!serialize) {
GST_DEBUG_OBJECT (tmptrackelement->data, "Should not be serialized");
continue;
}
index =
g_list_index (tracks,
ges_track_element_get_track (tmptrackelement->data));
@ -1157,8 +1181,17 @@ _save_group (GESXmlFormatter * self, GString * str, GList ** seen_groups,
GESGroup * group)
{
GList *tmp;
gboolean serialize;
gchar *properties;
g_object_get (group, "serialize", &serialize, NULL);
if (!serialize) {
GST_DEBUG_OBJECT (group, "Should not be serialized");
return;
}
if (g_list_find (*seen_groups, group)) {
GST_DEBUG_OBJECT (group, "Already serialized");