summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu.duponchelle@epitech.eu>2013-07-10 23:33:51 +0200
committerMathieu Duponchelle <mathieu.duponchelle@epitech.eu>2013-07-11 23:47:36 +0200
commit2723ef561e2f13dc463dc632a47cf62cf71ebdb6 (patch)
treea296be50d2561d1a6407f90412dc52a40f399039
parent96204ac1d26885e15ac79d07a0f40d4eae91de76 (diff)
container/group/clip: Allow creating an empty group.
This is a legitimate use case.
-rw-r--r--ges/ges-clip.c3
-rw-r--r--ges/ges-container.c11
-rw-r--r--ges/ges-group.c15
3 files changed, 21 insertions, 8 deletions
diff --git a/ges/ges-clip.c b/ges/ges-clip.c
index de40280..bcc3cdf 100644
--- a/ges/ges-clip.c
+++ b/ges/ges-clip.c
@@ -440,6 +440,9 @@ _group (GList * containers)
start = inpoint = duration = GST_CLOCK_TIME_NONE;
+ if (!containers)
+ return NULL;
+
/* First check if all the containers are clips, if they
* all have the same start/inpoint/duration and are in the same
* layer.
diff --git a/ges/ges-container.c b/ges/ges-container.c
index 7f0e956..b9cdb69 100644
--- a/ges/ges-container.c
+++ b/ges/ges-container.c
@@ -643,7 +643,7 @@ ges_container_ungroup (GESContainer * container, gboolean recursive)
/**
* ges_container_group:
- * @containers: (transfer none)(element-type GESContainer): The
+ * @containers: (transfer none)(element-type GESContainer) (allow-none): The
* #GESContainer to group, they must all be in a same #GESTimeline
*
* Groups the #GESContainer-s provided in @containers. It creates a subclass
@@ -669,10 +669,11 @@ ges_container_group (GList * containers)
guint i = 0;
GESContainer *ret = NULL;
- g_return_val_if_fail (containers, NULL);
- element = GES_TIMELINE_ELEMENT (containers->data);
- timeline = GES_TIMELINE_ELEMENT_TIMELINE (element);
- g_return_val_if_fail (timeline, NULL);
+ if (containers) {
+ element = GES_TIMELINE_ELEMENT (containers->data);
+ timeline = GES_TIMELINE_ELEMENT_TIMELINE (element);
+ g_return_val_if_fail (timeline, NULL);
+ }
if (g_list_length (containers) == 1)
return containers->data;
diff --git a/ges/ges-group.c b/ges/ges-group.c
index 4410f66..63f2577 100644
--- a/ges/ges-group.c
+++ b/ges/ges-group.c
@@ -380,6 +380,11 @@ _child_added (GESContainer * group, GESTimelineElement * child)
GESGroupPrivate *priv = GES_GROUP (group)->priv;
GstClockTime last_child_end = 0, first_child_start = G_MAXUINT64;
+ if (!GES_TIMELINE_ELEMENT_TIMELINE (group)) {
+ timeline_add_group (GES_TIMELINE_ELEMENT_TIMELINE (child),
+ GES_GROUP (group));
+ }
+
children = GES_CONTAINER_CHILDREN (group);
for (tmp = children; tmp; tmp = tmp->next) {
@@ -432,6 +437,8 @@ _child_removed (GESContainer * group, GESTimelineElement * child)
if (children == NULL) {
GST_FIXME_OBJECT (group, "Auto destroy myself?");
+ timeline_remove_group (GES_TIMELINE_ELEMENT_TIMELINE (group),
+ GES_GROUP (group));
return;
}
@@ -460,8 +467,7 @@ _ungroup (GESContainer * group, gboolean recursive)
}
g_list_free_full (children, gst_object_unref);
- timeline_remove_group (GES_TIMELINE_ELEMENT_TIMELINE (group),
- GES_GROUP (group));
+ /* No need to remove from the timeline here, this will be done in _child_removed */
return ret;
}
@@ -473,6 +479,9 @@ _group (GList * containers)
GESTimeline *timeline = NULL;
GESContainer *ret = g_object_new (GES_TYPE_GROUP, NULL);
+ if (!containers)
+ return ret;
+
for (tmp = containers; tmp; tmp = tmp->next) {
if (!timeline) {
timeline = GES_TIMELINE_ELEMENT_TIMELINE (tmp->data);
@@ -485,7 +494,7 @@ _group (GList * containers)
ges_container_add (ret, tmp->data);
}
- timeline_add_group (timeline, GES_GROUP (ret));
+ /* No need to add to the timeline here, this will be done in _child_added */
return ret;
}