GESTimelineLayer: Hide the object list and priority

Add needed setters/getters
This commit is contained in:
Edward Hervey 2010-12-16 12:41:26 +01:00
parent 3eadc4aa31
commit 5a170091e6
6 changed files with 62 additions and 37 deletions

View file

@ -244,6 +244,7 @@ ges_timeline_layer_add_object
ges_timeline_layer_new ges_timeline_layer_new
ges_timeline_layer_remove_object ges_timeline_layer_remove_object
ges_timeline_layer_set_priority ges_timeline_layer_set_priority
ges_timeline_layer_get_priority
ges_timeline_layer_get_objects ges_timeline_layer_get_objects
<SUBSECTION Standard> <SUBSECTION Standard>
GESTimelineLayerPrivate GESTimelineLayerPrivate

View file

@ -117,7 +117,8 @@ save_keyfile (GESFormatter * keyfile_formatter, GESTimeline * timeline)
type = "default"; type = "default";
} }
g_key_file_set_integer (kf, buffer, "priority", layer->priority); g_key_file_set_integer (kf, buffer, "priority",
ges_timeline_layer_get_priority (layer));
g_key_file_set_value (kf, buffer, "type", type); g_key_file_set_value (kf, buffer, "type", type);
objs = ges_timeline_layer_get_objects (layer); objs = ges_timeline_layer_get_objects (layer);

View file

@ -37,8 +37,12 @@ G_DEFINE_TYPE (GESTimelineLayer, ges_timeline_layer, G_TYPE_OBJECT);
struct _GESTimelineLayerPrivate struct _GESTimelineLayerPrivate
{ {
/* Dummy variable */ /*< private > */
void *nothing; GSList *objects_start; /* The TimelineObjects sorted by start and
* priority */
guint32 priority; /* The priority of the layer within the
* containing timeline */
}; };
enum enum
@ -66,7 +70,7 @@ ges_timeline_layer_get_property (GObject * object, guint property_id,
switch (property_id) { switch (property_id) {
case PROP_PRIORITY: case PROP_PRIORITY:
g_value_set_uint (value, layer->priority); g_value_set_uint (value, layer->priv->priority);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -92,13 +96,13 @@ static void
ges_timeline_layer_dispose (GObject * object) ges_timeline_layer_dispose (GObject * object)
{ {
GESTimelineLayer *layer = GES_TIMELINE_LAYER (object); GESTimelineLayer *layer = GES_TIMELINE_LAYER (object);
GESTimelineLayerPrivate *priv = layer->priv;
GST_DEBUG ("Disposing layer"); GST_DEBUG ("Disposing layer");
while (layer->objects_start) { while (priv->objects_start)
GESTimelineObject *obj = (GESTimelineObject *) layer->objects_start->data; ges_timeline_layer_remove_object (layer,
ges_timeline_layer_remove_object (layer, obj); (GESTimelineObject *) priv->objects_start->data);
}
G_OBJECT_CLASS (ges_timeline_layer_parent_class)->dispose (object); G_OBJECT_CLASS (ges_timeline_layer_parent_class)->dispose (object);
} }
@ -161,7 +165,7 @@ ges_timeline_layer_init (GESTimelineLayer * self)
GES_TYPE_TIMELINE_LAYER, GESTimelineLayerPrivate); GES_TYPE_TIMELINE_LAYER, GESTimelineLayerPrivate);
/* TODO : Keep those 3 values in sync */ /* TODO : Keep those 3 values in sync */
self->priority = 0; self->priv->priority = 0;
self->min_gnl_priority = 0; self->min_gnl_priority = 0;
self->max_gnl_priority = 9; self->max_gnl_priority = 9;
} }
@ -233,8 +237,8 @@ ges_timeline_layer_add_object (GESTimelineLayer * layer,
} }
/* Take a reference to the object and store it stored by start/priority */ /* Take a reference to the object and store it stored by start/priority */
layer->objects_start = layer->priv->objects_start =
g_slist_insert_sorted (layer->objects_start, object, g_slist_insert_sorted (layer->priv->objects_start, object,
(GCompareFunc) objects_start_compare); (GCompareFunc) objects_start_compare);
/* Inform the object it's now in this layer */ /* Inform the object it's now in this layer */
@ -294,7 +298,8 @@ ges_timeline_layer_remove_object (GESTimelineLayer * layer,
ges_timeline_object_set_layer (object, NULL); ges_timeline_object_set_layer (object, NULL);
/* Remove it from our list of controlled objects */ /* Remove it from our list of controlled objects */
layer->objects_start = g_slist_remove (layer->objects_start, object); layer->priv->objects_start =
g_slist_remove (layer->priv->objects_start, object);
/* Remove our reference to the object */ /* Remove our reference to the object */
g_object_unref (object); g_object_unref (object);
@ -307,7 +312,8 @@ ges_timeline_layer_remove_object (GESTimelineLayer * layer,
* @layer: a #GESTimelineLayer * @layer: a #GESTimelineLayer
* *
* Resyncs the priorities of the objects controlled by @layer. * Resyncs the priorities of the objects controlled by @layer.
* This method */ * This method
*/
gboolean gboolean
ges_timeline_layer_resync_priorities (GESTimelineLayer * layer) ges_timeline_layer_resync_priorities (GESTimelineLayer * layer)
{ {
@ -320,7 +326,7 @@ ges_timeline_layer_resync_priorities (GESTimelineLayer * layer)
/* TODO : This is the dumb version where we put everything linearly, /* TODO : This is the dumb version where we put everything linearly,
* will need to be adjusted for more complex usages (like with * will need to be adjusted for more complex usages (like with
* transitions). */ * transitions). */
for (tmp = layer->objects_start; tmp; tmp = tmp->next) { for (tmp = layer->priv->objects_start; tmp; tmp = tmp->next) {
ges_timeline_object_set_priority ((GESTimelineObject *) tmp->data, ges_timeline_object_set_priority ((GESTimelineObject *) tmp->data,
layer->min_gnl_priority); layer->min_gnl_priority);
} }
@ -333,16 +339,18 @@ ges_timeline_layer_resync_priorities (GESTimelineLayer * layer)
* @layer: a #GESTimelineLayer * @layer: a #GESTimelineLayer
* @priority: the priority to set * @priority: the priority to set
* *
* Sets the layer to the given @priority. See the documentation of * Sets the layer to the given @priority. See the documentation of the
* the "priority" property for more information. * priority property for more information.
*/ */
void void
ges_timeline_layer_set_priority (GESTimelineLayer * layer, guint priority) ges_timeline_layer_set_priority (GESTimelineLayer * layer, guint priority)
{ {
g_return_if_fail (GES_IS_TIMELINE_LAYER (layer));
GST_DEBUG ("layer:%p, priority:%d", layer, priority); GST_DEBUG ("layer:%p, priority:%d", layer, priority);
if (priority != layer->priority) { if (priority != layer->priv->priority) {
layer->priority = priority; layer->priv->priority = priority;
layer->min_gnl_priority = (priority * 10); layer->min_gnl_priority = (priority * 10);
layer->max_gnl_priority = ((priority + 1) * 10) - 1; layer->max_gnl_priority = ((priority + 1) * 10) - 1;
@ -351,6 +359,20 @@ ges_timeline_layer_set_priority (GESTimelineLayer * layer, guint priority)
} }
} }
/**
* ges_timeline_layer_get_priority:
* @layer: a #GESTimelineLayer
*
* Returns: the priority of the @layer within the timeline.
*/
guint
ges_timeline_layer_get_priority (GESTimelineLayer * layer)
{
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), 0);
return layer->priv->priority;
}
/** /**
* ges_timeline_layer_get_objects: * ges_timeline_layer_get_objects:
* @layer: a #GESTimelineLayer * @layer: a #GESTimelineLayer
@ -369,13 +391,15 @@ ges_timeline_layer_get_objects (GESTimelineLayer * layer)
GSList *tmp; GSList *tmp;
GESTimelineLayerClass *klass; GESTimelineLayerClass *klass;
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), NULL);
klass = GES_TIMELINE_LAYER_GET_CLASS (layer); klass = GES_TIMELINE_LAYER_GET_CLASS (layer);
if (klass->get_objects) { if (klass->get_objects) {
return klass->get_objects (layer); return klass->get_objects (layer);
} }
for (tmp = layer->objects_start; tmp; tmp = tmp->next) { for (tmp = layer->priv->objects_start; tmp; tmp = tmp->next) {
ret = g_list_prepend (ret, tmp->data); ret = g_list_prepend (ret, tmp->data);
g_object_ref (tmp->data); g_object_ref (tmp->data);
} }

View file

@ -56,13 +56,7 @@ struct _GESTimelineLayer {
GESTimeline *timeline; GESTimeline *timeline;
/*< private >*/ /*< protected >*/
GSList * objects_start; /* The TimelineObjects sorted by start and
* priority */
guint32 priority; /* The priority of the layer within the
* containing timeline */
guint32 min_gnl_priority, max_gnl_priority; guint32 min_gnl_priority, max_gnl_priority;
GESTimelineLayerPrivate *priv; GESTimelineLayerPrivate *priv;
@ -99,12 +93,17 @@ GType ges_timeline_layer_get_type (void);
GESTimelineLayer* ges_timeline_layer_new (void); GESTimelineLayer* ges_timeline_layer_new (void);
void ges_timeline_layer_set_timeline (GESTimelineLayer * layer, GESTimeline * timeline); void ges_timeline_layer_set_timeline (GESTimelineLayer * layer,
gboolean ges_timeline_layer_add_object (GESTimelineLayer * layer, GESTimelineObject * object); GESTimeline * timeline);
gboolean ges_timeline_layer_remove_object (GESTimelineLayer * layer, GESTimelineObject * object); gboolean ges_timeline_layer_add_object (GESTimelineLayer * layer,
GESTimelineObject * object);
gboolean ges_timeline_layer_remove_object (GESTimelineLayer * layer,
GESTimelineObject * object);
void ges_timeline_layer_set_priority (GESTimelineLayer * layer, guint priority); void ges_timeline_layer_set_priority (GESTimelineLayer * layer,
GList * ges_timeline_layer_get_objects (GESTimelineLayer * layer); guint priority);
guint ges_timeline_layer_get_priority (GESTimelineLayer * layer);
GList* ges_timeline_layer_get_objects (GESTimelineLayer * layer);
G_END_DECLS G_END_DECLS

View file

@ -253,8 +253,8 @@ ges_timeline_pipeline_change_state (GstElement * element,
ret = GST_STATE_CHANGE_FAILURE; ret = GST_STATE_CHANGE_FAILURE;
goto done; goto done;
} }
if (self-> if (self->priv->
priv->mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER)) mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER))
GST_DEBUG ("rendering => Updating pipeline caps"); GST_DEBUG ("rendering => Updating pipeline caps");
if (!ges_timeline_pipeline_update_caps (self)) { if (!ges_timeline_pipeline_update_caps (self)) {
GST_ERROR_OBJECT (element, "Error setting the caps for rendering"); GST_ERROR_OBJECT (element, "Error setting the caps for rendering");

View file

@ -71,7 +71,7 @@ GST_START_TEST (test_layer_properties)
layer = (GESTimelineLayer *) ges_timeline_layer_new (); layer = (GESTimelineLayer *) ges_timeline_layer_new ();
/* The default priority is 0 */ /* The default priority is 0 */
fail_unless_equals_int (layer->priority, 0); fail_unless_equals_int (ges_timeline_layer_get_priority (layer), 0);
fail_unless (ges_timeline_add_layer (timeline, layer)); fail_unless (ges_timeline_add_layer (timeline, layer));
@ -108,19 +108,19 @@ GST_START_TEST (test_layer_properties)
/* Change the priority of the layer */ /* Change the priority of the layer */
g_object_set (layer, "priority", 1, NULL); g_object_set (layer, "priority", 1, NULL);
assert_equals_int (layer->priority, 1); assert_equals_int (ges_timeline_layer_get_priority (layer), 1);
assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 10); assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 10);
gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 10, TRUE); gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 10, TRUE);
/* Change it to an insanely high value */ /* Change it to an insanely high value */
g_object_set (layer, "priority", 1000000, NULL); g_object_set (layer, "priority", 1000000, NULL);
assert_equals_int (layer->priority, 1000000); assert_equals_int (ges_timeline_layer_get_priority (layer), 1000000);
assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 10000000); assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 10000000);
gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 10000000, TRUE); gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 10000000, TRUE);
/* and back to 0 */ /* and back to 0 */
g_object_set (layer, "priority", 0, NULL); g_object_set (layer, "priority", 0, NULL);
assert_equals_int (layer->priority, 0); assert_equals_int (ges_timeline_layer_get_priority (layer), 0);
assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 0); assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 0);
gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 0, TRUE); gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 0, TRUE);