summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <thibault.saunier@collabora.com>2013-06-07 18:58:24 -0400
committerThibault Saunier <thibault.saunier@collabora.com>2013-06-23 16:56:35 -0400
commitc99cc0ef17d5040105958bfc6085fe298cba2096 (patch)
tree0b317a359852b0b477c253da08b0b7f95bdfac41
parentd66b29d55d7506e0c0fed84439876f7e56c60127 (diff)
gnl: First implementation of the commit based API
Currently, the only safe way to modify a composition, or an object, is to pause the pipeline first. We think that this limitation eliminates many use cases for GNonLin. Few video editors let you create a draft of your video by applying multi-cam technic. Also people could want to eventually consider doing live video production, which obviously require being able to change the composition in playing state (and increase compositon duration as we go). This commit is a first step making GNL fully commit base. Objects, Operations and Compositon keep a copy of modified values, and only apply those changes when a commit is executed. This potentially allows making the changes (or group of changes) fully 'atomic' without having to pause the pipeline. Added API: ---------- GnlObject::commit action signal Removed API: ------------ GnlComposition:update property + Fix the tests https://bugzilla.gnome.org/show_bug.cgi?id=701287
-rw-r--r--gnl/gnlcomposition.c326
-rw-r--r--gnl/gnlobject.c187
-rw-r--r--gnl/gnlobject.h31
-rw-r--r--tests/check/gnl/common.c1
-rw-r--r--tests/check/gnl/complex.c35
-rw-r--r--tests/check/gnl/gnlcomposition.c21
-rw-r--r--tests/check/gnl/gnloperation.c81
-rw-r--r--tests/check/gnl/gnlsource.c1
-rw-r--r--tests/check/gnl/seek.c31
-rw-r--r--tests/check/gnl/simple.c133
10 files changed, 458 insertions, 389 deletions
diff --git a/gnl/gnlcomposition.c b/gnl/gnlcomposition.c
index ada5c44..d8e1fa0 100644
--- a/gnl/gnlcomposition.c
+++ b/gnl/gnlcomposition.c
@@ -62,6 +62,12 @@ enum
GNLOBJECT_PROP_LAST
};
+enum
+{
+ COMMIT_SIGNAL,
+ LAST_SIGNAL
+};
+
typedef struct _GnlCompositionEntry GnlCompositionEntry;
struct _GnlCompositionPrivate
@@ -80,14 +86,6 @@ struct _GnlCompositionPrivate
GHashTable *objects_hash;
GMutex objects_lock;
- /* Update properties
- * can_update: If True, updates should be taken into account immediatly, else
- * they should be postponed until it is set to True again.
- * update_required: Set to True if an update is required when the
- * can_update property just above is set back to True. */
- gboolean can_update;
- gboolean update_required;
-
/*
thread-safe Seek handling.
flushing_lock : mutex to access flushing and pending_idle
@@ -150,6 +148,8 @@ struct _GnlCompositionPrivate
gboolean running;
};
+static guint _signals[LAST_SIGNAL] = { 0 };
+
static GParamSpec *gnlobject_properties[GNLOBJECT_PROP_LAST];
#define OBJECT_IN_ACTIVE_SEGMENT(comp,element) \
@@ -185,12 +185,14 @@ static gint objects_start_compare (GnlObject * a, GnlObject * b);
static gint objects_stop_compare (GnlObject * a, GnlObject * b);
static GstClockTime get_current_position (GnlComposition * comp);
-static void gnl_composition_set_update (GnlComposition * comp, gboolean update);
static gboolean update_pipeline (GnlComposition * comp,
GstClockTime currenttime, gboolean initial, gboolean change_state,
gboolean modify);
static void no_more_pads_object_cb (GstElement * element,
GnlComposition * comp);
+static gboolean gnl_composition_commit_func (GnlObject * object,
+ gboolean recurse);
+static void update_start_stop_duration (GnlComposition * comp);
/* COMP_REAL_START: actual position to start current playback at. */
@@ -257,12 +259,6 @@ struct _GnlCompositionEntry
{
GnlObject *object;
- /* handler ids for property notifications */
- gulong starthandler;
- gulong stophandler;
- gulong priorityhandler;
- gulong activehandler;
-
/* handler id for 'no-more-pads' signal */
gulong nomorepadshandler;
gulong padaddedhandler;
@@ -278,10 +274,12 @@ gnl_composition_class_init (GnlCompositionClass * klass)
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBinClass *gstbin_class;
+ GnlObjectClass *gnlobject_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbin_class = (GstBinClass *) klass;
+ gnlobject_class = (GnlObjectClass *) klass;
g_type_class_add_private (klass, sizeof (GnlCompositionPrivate));
@@ -307,26 +305,6 @@ gnl_composition_class_init (GnlCompositionClass * klass)
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gnl_composition_src_template));
- /**
- * GnlComposition:update:
- *
- * If %TRUE, then all modifications to objects within the composition will
- * cause a internal pipeline update (if required).
- * If %FALSE, then only the composition's start/duration/stop properties
- * will be updated, and the internal pipeline will only be updated when the
- * property is set back to %TRUE.
- *
- * It is recommended to temporarily set this property to %FALSE before doing
- * more than one modification in the composition (like adding/moving/removing
- * several objects at once) in order to speed up the process, and then setting
- * back the property to %TRUE when done.
- */
-
- g_object_class_install_property (gobject_class, PROP_UPDATE,
- g_param_spec_boolean ("update", "Update",
- "Update the internal pipeline on every modification", TRUE,
- G_PARAM_READWRITE));
-
/* Get the paramspec of the GnlObject klass so we can do
* fast notifies */
gnlobject_properties[GNLOBJECT_PROP_START] =
@@ -335,18 +313,32 @@ gnl_composition_class_init (GnlCompositionClass * klass)
g_object_class_find_property (gobject_class, "stop");
gnlobject_properties[GNLOBJECT_PROP_DURATION] =
g_object_class_find_property (gobject_class, "duration");
+
+ /**
+ * GnlComposition::commit
+ * @comp: a #GnlComposition
+ * @recurse: Whether to commit recursiverly into (GnlComposition) children of
+ * @object. This is used in case we have composition inside
+ * a gnlsource composition, telling it to commit the included
+ * composition state.
+ *
+ * Action signal to commit all the pending changes of the composition and
+ * its children timing properties
+ *
+ * Returns: %TRUE if changes have been commited, %FALSE if nothing had to
+ * be commited
+ */
+ _signals[COMMIT_SIGNAL] = g_signal_new ("commit", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GnlObjectClass, commit_signal_handler), NULL, NULL, NULL,
+ G_TYPE_BOOLEAN, 1, G_TYPE_BOOLEAN);
+
+ gnlobject_class->commit = gnl_composition_commit_func;
}
static void
hash_value_destroy (GnlCompositionEntry * entry)
{
- if (entry->starthandler)
- g_signal_handler_disconnect (entry->object, entry->starthandler);
- if (entry->stophandler)
- g_signal_handler_disconnect (entry->object, entry->stophandler);
- if (entry->priorityhandler)
- g_signal_handler_disconnect (entry->object, entry->priorityhandler);
- g_signal_handler_disconnect (entry->object, entry->activehandler);
g_signal_handler_disconnect (entry->object, entry->padremovedhandler);
g_signal_handler_disconnect (entry->object, entry->padaddedhandler);
@@ -361,6 +353,7 @@ gnl_composition_init (GnlComposition * comp)
GnlCompositionPrivate *priv;
GST_OBJECT_FLAG_SET (comp, GNL_OBJECT_SOURCE);
+ GST_OBJECT_FLAG_SET (comp, GNL_OBJECT_COMPOSITION);
priv = G_TYPE_INSTANCE_GET_PRIVATE (comp, GNL_TYPE_COMPOSITION,
GnlCompositionPrivate);
@@ -368,9 +361,6 @@ gnl_composition_init (GnlComposition * comp)
priv->objects_start = NULL;
priv->objects_stop = NULL;
- priv->can_update = TRUE;
- priv->update_required = FALSE;
-
g_mutex_init (&priv->flushing_lock);
priv->flushing = FALSE;
@@ -401,9 +391,6 @@ gnl_composition_dispose (GObject * object)
priv->dispose_has_run = TRUE;
- priv->can_update = TRUE;
- priv->update_required = FALSE;
-
if (priv->ghostpad)
gnl_composition_remove_ghostpad (comp);
@@ -454,12 +441,7 @@ static void
gnl_composition_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
- GnlComposition *comp = (GnlComposition *) object;
-
switch (prop_id) {
- case PROP_UPDATE:
- gnl_composition_set_update (comp, g_value_get_boolean (value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -470,12 +452,7 @@ static void
gnl_composition_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
- GnlComposition *comp = (GnlComposition *) object;
-
switch (prop_id) {
- case PROP_UPDATE:
- g_value_set_boolean (value, comp->priv->can_update);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -637,7 +614,6 @@ gnl_composition_reset (GnlComposition * comp)
priv->reset_time = FALSE;
- priv->update_required = FALSE;
priv->send_stream_start = TRUE;
GST_DEBUG_OBJECT (comp, "Composition now resetted");
@@ -842,37 +818,61 @@ have_to_update_pipeline (GnlComposition * comp)
return FALSE;
}
-static void
-gnl_composition_set_update (GnlComposition * comp, gboolean update)
+/* OBJECTS LOCK must be taken when calling this ! */
+static gboolean
+update_pipeline_at_current_position (GnlComposition * comp)
{
- GnlCompositionPrivate *priv = comp->priv;
+ GstClockTime curpos;
- if (G_UNLIKELY (update == priv->can_update))
- return;
+ /* Get current position */
+ if ((curpos = get_current_position (comp)) == GST_CLOCK_TIME_NONE) {
+ if (GST_CLOCK_TIME_IS_VALID (comp->priv->segment_start))
+ curpos = comp->priv->segment->start = comp->priv->segment_start;
+ else
+ curpos = 0;
+ }
- GST_DEBUG_OBJECT (comp, "update:%d [currently %d], update_required:%d",
- update, priv->can_update, priv->update_required);
- COMP_OBJECTS_LOCK (comp);
+ update_start_stop_duration (comp);
- priv->can_update = update;
+ return update_pipeline (comp, curpos, TRUE, TRUE, TRUE);
+}
- if (update && priv->update_required) {
- GstClockTime curpos;
+static gboolean
+gnl_composition_commit_func (GnlObject * object, gboolean recurse)
+{
+ GList *tmp;
+ gboolean commited = FALSE;
+ GnlComposition *comp = GNL_COMPOSITION (object);
+ GnlCompositionPrivate *priv = comp->priv;
- /* Get current position */
- if ((curpos = get_current_position (comp)) == GST_CLOCK_TIME_NONE) {
- if (GST_CLOCK_TIME_IS_VALID (priv->segment_start))
- curpos = priv->segment->start = priv->segment_start;
- else
- curpos = 0;
- }
- COMP_OBJECTS_UNLOCK (comp);
+ GST_DEBUG_OBJECT (object, "Commiting state");
+ COMP_OBJECTS_LOCK (comp);
+ for (tmp = priv->objects_start; tmp; tmp = tmp->next) {
+ if (gnl_object_commit (tmp->data, recurse))
+ commited = TRUE;
+ }
- /* update pipeline to that position */
- update_pipeline (comp, curpos, TRUE, TRUE, TRUE);
- } else
+ GST_DEBUG_OBJECT (object, "Linking up commit vmethod");
+ if (commited == FALSE &&
+ (GNL_OBJECT_CLASS (parent_class)->commit (object, recurse) == FALSE)) {
COMP_OBJECTS_UNLOCK (comp);
+ GST_DEBUG_OBJECT (object, "Nothing to commit, leaving");
+ return FALSE;
+ }
+ COMP_OBJECTS_UNLOCK (comp);
+
+ /* The topology of the composition might have changed, update the lists */
+ priv->objects_start = g_list_sort
+ (priv->objects_start, (GCompareFunc) objects_start_compare);
+ priv->objects_stop = g_list_sort
+ (priv->objects_stop, (GCompareFunc) objects_stop_compare);
+
+ /* And update the pipeline at current position if needed */
+ update_pipeline_at_current_position (comp);
+
+ GST_DEBUG_OBJECT (object, "Done commiting");
+ return TRUE;
}
/*
@@ -1960,13 +1960,13 @@ update_start_stop_duration (GnlComposition * comp)
GST_LOG ("no objects, resetting everything to 0");
if (cobj->start) {
- cobj->start = 0;
+ cobj->start = cobj->pending_start = 0;
g_object_notify_by_pspec (G_OBJECT (cobj),
gnlobject_properties[GNLOBJECT_PROP_START]);
}
if (cobj->duration) {
- cobj->duration = 0;
+ cobj->pending_duration = cobj->duration = 0;
g_object_notify_by_pspec (G_OBJECT (cobj),
gnlobject_properties[GNLOBJECT_PROP_DURATION]);
signal_duration_change (comp);
@@ -1987,7 +1987,7 @@ update_start_stop_duration (GnlComposition * comp)
"Setting start to 0 because we have a default object");
if (cobj->start != 0) {
- cobj->start = 0;
+ cobj->pending_start = cobj->start = 0;
g_object_notify_by_pspec (G_OBJECT (cobj),
gnlobject_properties[GNLOBJECT_PROP_START]);
}
@@ -2000,7 +2000,7 @@ update_start_stop_duration (GnlComposition * comp)
if (obj->start != cobj->start) {
GST_LOG_OBJECT (obj, "setting start from %s to %" GST_TIME_FORMAT,
GST_OBJECT_NAME (obj), GST_TIME_ARGS (obj->start));
- cobj->start = obj->start;
+ cobj->pending_start = cobj->start = obj->start;
g_object_notify_by_pspec (G_OBJECT (cobj),
gnlobject_properties[GNLOBJECT_PROP_START]);
}
@@ -2016,8 +2016,10 @@ update_start_stop_duration (GnlComposition * comp)
if (priv->expandables) {
GList *tmp;
+ GST_INFO_OBJECT (comp, "RE-setting all expandables duration and commit");
for (tmp = priv->expandables; tmp; tmp = tmp->next) {
g_object_set (tmp->data, "duration", obj->stop, NULL);
+ gnl_object_commit (GNL_OBJECT (tmp->data), FALSE);
}
}
@@ -2028,7 +2030,7 @@ update_start_stop_duration (GnlComposition * comp)
}
if ((cobj->stop - cobj->start) != cobj->duration) {
- cobj->duration = cobj->stop - cobj->start;
+ cobj->pending_duration = cobj->duration = cobj->stop - cobj->start;
g_object_notify_by_pspec (G_OBJECT (cobj),
gnlobject_properties[GNLOBJECT_PROP_DURATION]);
signal_duration_change (comp);
@@ -2582,13 +2584,6 @@ update_pipeline (GnlComposition * comp, GstClockTime currenttime,
COMP_OBJECTS_LOCK (comp);
- if (G_UNLIKELY (!priv->can_update)) {
- COMP_OBJECTS_UNLOCK (comp);
- return TRUE;
- }
-
- update_start_stop_duration (comp);
-
if (GST_CLOCK_TIME_IS_VALID (currenttime)) {
GstState state = GST_STATE (comp);
GstState nextstate =
@@ -2781,67 +2776,6 @@ update_pipeline (GnlComposition * comp, GstClockTime currenttime,
*/
static void
-object_start_stop_priority_changed (GnlObject * object,
- GParamSpec * arg G_GNUC_UNUSED, GnlComposition * comp)
-{
- GnlCompositionPrivate *priv = comp->priv;
-
- GST_DEBUG_OBJECT (object,
- "start/stop/priority changed (%" GST_TIME_FORMAT "/%" GST_TIME_FORMAT
- "/%d), evaluating pipeline update", GST_TIME_ARGS (object->start),
- GST_TIME_ARGS (object->stop), object->priority);
-
- /* The topology of the ocmposition might have changed, update the lists */
- priv->objects_start = g_list_sort
- (priv->objects_start, (GCompareFunc) objects_start_compare);
- priv->objects_stop = g_list_sort
- (priv->objects_stop, (GCompareFunc) objects_stop_compare);
-
- if (!priv->can_update) {
- priv->update_required = TRUE;
- update_start_stop_duration (comp);
- return;
- }
-
- /* Update pipeline if needed */
- if (priv->current &&
- (OBJECT_IN_ACTIVE_SEGMENT (comp, object) ||
- g_node_find (priv->current, G_IN_ORDER, G_TRAVERSE_ALL, object))) {
- GstClockTime curpos = get_current_position (comp);
-
- if (curpos == GST_CLOCK_TIME_NONE)
- curpos = priv->segment->start = priv->segment_start;
-
- update_pipeline (comp, curpos, TRUE, TRUE, TRUE);
- } else
- update_start_stop_duration (comp);
-}
-
-static void
-object_active_changed (GnlObject * object, GParamSpec * arg G_GNUC_UNUSED,
- GnlComposition * comp)
-{
- GnlCompositionPrivate *priv = comp->priv;
-
- GST_DEBUG_OBJECT (object,
- "active flag changed (%d), evaluating pipeline update", object->active);
-
- if (!priv->can_update) {
- priv->update_required = TRUE;
- return;
- }
-
- if (priv->current && OBJECT_IN_ACTIVE_SEGMENT (comp, object)) {
- GstClockTime curpos = get_current_position (comp);
-
- if (curpos == GST_CLOCK_TIME_NONE)
- curpos = priv->segment->start = priv->segment_start;
- update_pipeline (comp, curpos, TRUE, TRUE, TRUE);
- } else
- update_start_stop_duration (comp);
-}
-
-static void
object_pad_removed (GnlObject * object, GstPad * pad, GnlComposition * comp)
{
GnlCompositionPrivate *priv = comp->priv;
@@ -2888,12 +2822,10 @@ object_pad_added (GnlObject * object G_GNUC_UNUSED, GstPad * pad,
static gboolean
gnl_composition_add_object (GstBin * bin, GstElement * element)
{
- GnlComposition *comp = (GnlComposition *) bin;
+ gboolean ret;
GnlCompositionEntry *entry;
- GstClockTime curpos = GST_CLOCK_TIME_NONE;
+ GnlComposition *comp = (GnlComposition *) bin;
GnlCompositionPrivate *priv = comp->priv;
- gboolean ret;
- gboolean update_required;
/* we only accept GnlObject */
g_return_val_if_fail (GNL_IS_OBJECT (element), FALSE);
@@ -2920,6 +2852,8 @@ gnl_composition_add_object (GstBin * bin, GstElement * element)
/* Call parent class ::add_element() */
ret = GST_BIN_CLASS (parent_class)->add_element (bin, element);
+ gnl_object_set_commit_needed (GNL_OBJECT (comp));
+
if (!ret) {
GST_WARNING_OBJECT (bin, "couldn't add element");
goto chiringuito;
@@ -2933,27 +2867,18 @@ gnl_composition_add_object (GstBin * bin, GstElement * element)
entry = g_slice_new0 (GnlCompositionEntry);
entry->object = (GnlObject *) element;
- if (G_LIKELY ((GNL_OBJECT_PRIORITY (element) != G_MAXUINT32) &&
- !GNL_OBJECT_IS_EXPANDABLE (element))) {
+ if (G_LIKELY ((GNL_OBJECT_PRIORITY (element) == G_MAXUINT32) ||
+ GNL_OBJECT_IS_EXPANDABLE (element))) {
/* Only react on non-default objects properties */
- entry->starthandler = g_signal_connect (G_OBJECT (element),
- "notify::start", G_CALLBACK (object_start_stop_priority_changed), comp);
- entry->stophandler =
- g_signal_connect (G_OBJECT (element), "notify::stop",
- G_CALLBACK (object_start_stop_priority_changed), comp);
- entry->priorityhandler =
- g_signal_connect (G_OBJECT (element), "notify::priority",
- G_CALLBACK (object_start_stop_priority_changed), comp);
- } else {
- /* We set the default source start/stop values to 0 and composition-stop */
g_object_set (element,
"start", (GstClockTime) 0,
"inpoint", (GstClockTime) 0,
"duration", (GstClockTimeDiff) GNL_OBJECT_STOP (comp), NULL);
+
+ GST_INFO_OBJECT (element, "Used as expandable, commiting now");
+ gnl_object_commit (GNL_OBJECT (element), FALSE);
}
- entry->activehandler = g_signal_connect (G_OBJECT (element),
- "notify::active", G_CALLBACK (object_active_changed), comp);
entry->padremovedhandler = g_signal_connect (G_OBJECT (element),
"pad-removed", G_CALLBACK (object_pad_removed), comp);
entry->padaddedhandler = g_signal_connect (G_OBJECT (element),
@@ -2971,7 +2896,7 @@ gnl_composition_add_object (GstBin * bin, GstElement * element)
GNL_OBJECT_IS_EXPANDABLE (element)) {
/* It doesn't get added to objects_start and objects_stop. */
priv->expandables = g_list_prepend (priv->expandables, element);
- goto check_update;
+ goto beach;
}
/* add it sorted to the objects list */
@@ -2989,41 +2914,11 @@ gnl_composition_add_object (GstBin * bin, GstElement * element)
priv->objects_stop = g_list_insert_sorted
(priv->objects_stop, element, (GCompareFunc) objects_stop_compare);
- if (priv->objects_stop)
- GST_LOG_OBJECT (comp,
- "Head of objects_stop is now %s [%" GST_TIME_FORMAT "--%"
- GST_TIME_FORMAT "]", GST_OBJECT_NAME (priv->objects_stop->data),
- GST_TIME_ARGS (GNL_OBJECT_START (priv->objects_stop->data)),
- GST_TIME_ARGS (GNL_OBJECT_STOP (priv->objects_stop->data)));
-
- GST_DEBUG_OBJECT (comp,
- "segment_start:%" GST_TIME_FORMAT " segment_stop:%" GST_TIME_FORMAT,
- GST_TIME_ARGS (priv->segment_start), GST_TIME_ARGS (priv->segment_stop));
-
-check_update:
- update_required = OBJECT_IN_ACTIVE_SEGMENT (comp, element) ||
- (!priv->current) ||
- (GNL_OBJECT_PRIORITY (element) == G_MAXUINT32) ||
- GNL_OBJECT_IS_EXPANDABLE (element);
-
- /* We only need the current position if we're going to update */
- if (update_required && priv->can_update)
- if ((curpos = get_current_position (comp)) == GST_CLOCK_TIME_NONE)
- curpos = priv->segment_start;
+ /* Now the object is ready to be commited and then used */
+beach:
COMP_OBJECTS_UNLOCK (comp);
- /* If we added within currently configured segment OR the pipeline was *
- * previously empty, THEN update pipeline */
- if (G_LIKELY (update_required && priv->can_update))
- update_pipeline (comp, curpos, TRUE, TRUE, TRUE);
- else {
- if (!priv->can_update)
- priv->update_required |= update_required;
- update_start_stop_duration (comp);
- }
-
-beach:
gst_object_unref (element);
return ret;
@@ -3041,7 +2936,6 @@ gnl_composition_remove_object (GstBin * bin, GstElement * element)
{
GnlComposition *comp = (GnlComposition *) bin;
GnlCompositionPrivate *priv = comp->priv;
- GstClockTime curpos = GST_CLOCK_TIME_NONE;
gboolean ret = FALSE;
gboolean update_required;
GnlCompositionEntry *entry;
@@ -3082,25 +2976,15 @@ gnl_composition_remove_object (GstBin * bin, GstElement * element)
update_required = OBJECT_IN_ACTIVE_SEGMENT (comp, element) ||
(GNL_OBJECT_PRIORITY (element) == G_MAXUINT32) ||
GNL_OBJECT_IS_EXPANDABLE (element);
- if (update_required && priv->can_update) {
- curpos = get_current_position (comp);
- if (G_UNLIKELY (curpos == GST_CLOCK_TIME_NONE))
- curpos = priv->segment_start;
- }
COMP_OBJECTS_UNLOCK (comp);
- /* If we removed within currently configured segment, or it was the default source, *
- * update pipeline */
- if (G_LIKELY (update_required))
- update_pipeline (comp, curpos, TRUE, TRUE, TRUE);
- else {
- if (!priv->can_update)
- priv->update_required |= update_required;
- update_start_stop_duration (comp);
+ if (G_LIKELY (update_required)) {
+ /* And update the pipeline at current position if needed */
+ update_pipeline_at_current_position (comp);
}
ret = GST_BIN_CLASS (parent_class)->remove_element (bin, element);
- GST_LOG_OBJECT (element, "Done removing from the composition");
+ GST_LOG_OBJECT (element, "Done removing from the composition, now updating");
/* unblock source pad */
if (probeid && (srcpad = get_src_pad (element))) {
@@ -3108,6 +2992,8 @@ gnl_composition_remove_object (GstBin * bin, GstElement * element)
gst_object_unref (srcpad);
}
+ /* Make it possible to reuse the same object later */
+ gnl_object_reset (GNL_OBJECT (element));
gst_object_unref (element);
out:
return ret;
diff --git a/gnl/gnlobject.c b/gnl/gnlobject.c
index d86a467..60b4a10 100644
--- a/gnl/gnlobject.c
+++ b/gnl/gnlobject.c
@@ -46,6 +46,35 @@ GST_DEBUG_CATEGORY_STATIC (gnlobject_debug);
GST_DEBUG_CATEGORY_INIT (gnlobject_debug, "gnlobject", GST_DEBUG_FG_BLUE | GST_DEBUG_BOLD, "GNonLin Object base class");
#define gnl_object_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GnlObject, gnl_object, GST_TYPE_BIN, _do_init);
+
+/****************************************************
+ * Helper macros *
+ ****************************************************/
+#define CHECK_AND_SET(PROPERTY, property, prop_str, print_format) \
+{ \
+GstObject *parent = gst_object_get_parent (GST_OBJECT (object)); \
+if (parent == NULL && !GNL_OBJECT_IS_COMPOSITION (object)) { \
+ GST_INFO_OBJECT (object, "Not in a composition yet, " \
+ "not commiting" prop_str); \
+} else if (object->pending_##property != object->property) { \
+ object->property = object->pending_##property; \
+ GST_DEBUG_OBJECT(object, "Setting " prop_str " to %" \
+ print_format, object->property); \
+} else \
+ GST_DEBUG_OBJECT(object, "Nothing to do for " prop_str); \
+if (parent) \
+ gst_object_unref (parent); \
+}
+
+#define SET_PENDING_VALUE(property, property_str, type, print_format) \
+gnlobject->pending_##property = g_value_get_##type (value); \
+if (gnlobject->property != gnlobject->pending_##property) { \
+ GST_DEBUG_OBJECT(object, "Setting pending " property_str " to %" \
+ print_format, gnlobject->pending_##property); \
+ gnl_object_set_commit_needed (gnlobject); \
+} else \
+ GST_DEBUG_OBJECT(object, "Pending " property_str " did not change");
+
enum
{
PROP_0,
@@ -62,7 +91,6 @@ enum
static GParamSpec *properties[PROP_LAST];
-
static void gnl_object_dispose (GObject * object);
static void gnl_object_set_property (GObject * object, guint prop_id,
@@ -75,6 +103,7 @@ static GstStateChangeReturn gnl_object_change_state (GstElement * element,
static gboolean gnl_object_prepare_func (GnlObject * object);
static gboolean gnl_object_cleanup_func (GnlObject * object);
+static gboolean gnl_object_commit_func (GnlObject * object, gboolean recurse);
static GstStateChangeReturn gnl_object_prepare (GnlObject * object);
@@ -97,6 +126,9 @@ gnl_object_class_init (GnlObjectClass * klass)
gnlobject_class->prepare = GST_DEBUG_FUNCPTR (gnl_object_prepare_func);
gnlobject_class->cleanup = GST_DEBUG_FUNCPTR (gnl_object_cleanup_func);
+ gnlobject_class->commit_signal_handler =
+ GST_DEBUG_FUNCPTR (gnl_object_commit);
+ gnlobject_class->commit = GST_DEBUG_FUNCPTR (gnl_object_commit_func);
/**
* GnlObject:start
@@ -213,13 +245,13 @@ gnl_object_class_init (GnlObjectClass * klass)
static void
gnl_object_init (GnlObject * object)
{
- object->start = 0;
- object->duration = 0;
+ object->start = object->pending_start = 0;
+ object->duration = object->pending_duration = 0;
object->stop = 0;
- object->inpoint = GST_CLOCK_TIME_NONE;
- object->priority = 0;
- object->active = TRUE;
+ object->inpoint = object->pending_inpoint = GST_CLOCK_TIME_NONE;
+ object->priority = object->pending_priority = 0;
+ object->active = object->pending_active = TRUE;
object->caps = gst_caps_new_any ();
@@ -395,21 +427,55 @@ gnl_object_set_caps (GnlObject * object, const GstCaps * caps)
object->caps = gst_caps_copy (caps);
}
-static void
-update_values (GnlObject * object)
+static inline void
+_update_stop (GnlObject * gnlobject)
{
/* check if start/duration has changed */
- if ((object->start + object->duration) != object->stop) {
- object->stop = object->start + object->duration;
- GST_LOG_OBJECT (object,
+
+ if ((gnlobject->pending_start + gnlobject->pending_duration) !=
+ gnlobject->stop) {
+ gnlobject->stop = gnlobject->pending_start + gnlobject->pending_duration;
+
+ GST_LOG_OBJECT (gnlobject,
"Updating stop value : %" GST_TIME_FORMAT " [start:%" GST_TIME_FORMAT
- ", duration:%" GST_TIME_FORMAT "]", GST_TIME_ARGS (object->stop),
- GST_TIME_ARGS (object->start), GST_TIME_ARGS (object->duration));
- g_object_notify_by_pspec (G_OBJECT (object), properties[PROP_STOP]);
+ ", duration:%" GST_TIME_FORMAT "]", GST_TIME_ARGS (gnlobject->stop),
+ GST_TIME_ARGS (gnlobject->pending_start),
+ GST_TIME_ARGS (gnlobject->pending_duration));
+ g_object_notify_by_pspec (G_OBJECT (gnlobject), properties[PROP_STOP]);
}
}
static void
+update_values (GnlObject * object)
+{
+ CHECK_AND_SET (START, start, "start", G_GUINT64_FORMAT);
+ CHECK_AND_SET (INPOINT, inpoint, "inpoint", G_GUINT64_FORMAT);
+ CHECK_AND_SET (DURATION, duration, "duration", G_GINT64_FORMAT);
+ CHECK_AND_SET (PRIORITY, priority, "priority", G_GUINT32_FORMAT);
+ CHECK_AND_SET (ACTIVE, active, "active", G_GUINT32_FORMAT);
+
+ _update_stop (object);
+}
+
+static gboolean
+gnl_object_commit_func (GnlObject * object, gboolean recurse)
+{
+ GST_INFO_OBJECT (object, "Commiting object changed");
+
+ if (object->commit_needed == FALSE) {
+ GST_INFO_OBJECT (object, "No changes to commit");
+
+ return FALSE;
+ }
+
+ update_values (object);
+
+ GST_INFO_OBJECT (object, "Done commiting");
+
+ return TRUE;
+}
+
+static void
gnl_object_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
@@ -417,23 +483,29 @@ gnl_object_set_property (GObject * object, guint prop_id,
g_return_if_fail (GNL_IS_OBJECT (object));
+ GST_OBJECT_LOCK (object);
switch (prop_id) {
case PROP_START:
- gnlobject->start = g_value_get_uint64 (value);
- update_values (gnlobject);
+ SET_PENDING_VALUE (start, "start", uint64, G_GUINT64_FORMAT);
break;
case PROP_DURATION:
- gnlobject->duration = g_value_get_int64 (value);
- update_values (gnlobject);
+ SET_PENDING_VALUE (duration, "duration", int64, G_GINT64_FORMAT);
break;
case PROP_INPOINT:
- gnlobject->inpoint = g_value_get_uint64 (value);
+ SET_PENDING_VALUE (inpoint, "inpoint", uint64, G_GUINT64_FORMAT);
break;
case PROP_PRIORITY:
- gnlobject->priority = g_value_get_uint (value);
+ if (g_value_get_uint (value) == G_MAXUINT32) {
+ GST_DEBUG_OBJECT (object, "Setting priority to G_MAXUINT32, which means"
+ "'Default object', commiting right now");
+ /* This is not the cleanast thing to do but we anyway plan to remove
+ * that behaviour soon. */
+ gnlobject->pending_priority = gnlobject->priority = G_MAXUINT32;
+ } else
+ SET_PENDING_VALUE (priority, "priority", uint, G_GUINT32_FORMAT);
break;
case PROP_ACTIVE:
- gnlobject->active = g_value_get_boolean (value);
+ SET_PENDING_VALUE (active, "active", boolean, G_GUINT32_FORMAT);
break;
case PROP_CAPS:
gnl_object_set_caps (gnlobject, gst_value_get_caps (value));
@@ -448,6 +520,9 @@ gnl_object_set_property (GObject * object, guint prop_id,
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
+ GST_OBJECT_UNLOCK (object);
+
+ _update_stop (gnlobject);
}
static void
@@ -458,22 +533,22 @@ gnl_object_get_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_START:
- g_value_set_uint64 (value, gnlobject->start);
+ g_value_set_uint64 (value, gnlobject->pending_start);
break;
case PROP_DURATION:
- g_value_set_int64 (value, gnlobject->duration);
+ g_value_set_int64 (value, gnlobject->pending_duration);
break;
case PROP_STOP:
g_value_set_uint64 (value, gnlobject->stop);
break;
case PROP_INPOINT:
- g_value_set_uint64 (value, gnlobject->inpoint);
+ g_value_set_uint64 (value, gnlobject->pending_inpoint);
break;
case PROP_PRIORITY:
- g_value_set_uint (value, gnlobject->priority);
+ g_value_set_uint (value, gnlobject->pending_priority);
break;
case PROP_ACTIVE:
- g_value_set_boolean (value, gnlobject->active);
+ g_value_set_boolean (value, gnlobject->pending_active);
break;
case PROP_CAPS:
gst_value_set_caps (value, gnlobject->caps);
@@ -493,6 +568,24 @@ gnl_object_change_state (GstElement * element, GstStateChange transition)
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
+ {
+ GstObject *parent = gst_object_get_parent (GST_OBJECT (element));
+
+ /* Going to READY and if we are not in a composition, we need to make
+ * sure that the object positioning state is properly commited */
+ if (parent) {
+ if (!GNL_OBJECT_IS_COMPOSITION (parent) &&
+ !GNL_OBJECT_IS_COMPOSITION (GNL_OBJECT (element))) {
+ GST_DEBUG ("Adding gnlobject to something that is not a composition,"
+ " commiting ourself");
+ gnl_object_commit (GNL_OBJECT (element), FALSE);
+ }
+
+ gst_object_unref (parent);
+ }
+ }
+ break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
if (gnl_object_prepare (GNL_OBJECT (element)) == GST_STATE_CHANGE_FAILURE) {
ret = GST_STATE_CHANGE_FAILURE;
@@ -525,3 +618,45 @@ gnl_object_change_state (GstElement * element, GstStateChange transition)
beach:
return ret;
}
+
+void
+gnl_object_set_commit_needed (GnlObject * object)
+{
+ if (G_UNLIKELY (object->commiting)) {
+ GST_WARNING_OBJECT (object,
+ "Trying to set 'commit-needed' while commiting");
+
+ return;
+ }
+
+ GST_DEBUG_OBJECT (object, "Setting 'commit_needed'");
+ object->commit_needed = TRUE;
+}
+
+gboolean
+gnl_object_commit (GnlObject * object, gboolean recurse)
+{
+ gboolean ret;
+
+ GST_DEBUG_OBJECT (object, "Commiting object state");
+
+ object->commiting = TRUE;
+ ret = GNL_OBJECT_GET_CLASS (object)->commit (object, recurse);
+ object->commiting = FALSE;
+
+ return ret;
+
+}
+
+void
+gnl_object_reset (GnlObject * object)
+{
+ GST_INFO_OBJECT (object, "Resetting child timing values to default");
+
+ object->start = 0;
+ object->duration = 0;
+ object->stop = 0;
+ object->inpoint = GST_CLOCK_TIME_NONE;
+ object->priority = 0;
+ object->active = TRUE;
+}
diff --git a/gnl/gnlobject.h b/gnl/gnlobject.h
index 72f7cdd..4ba7dd8 100644
--- a/gnl/gnlobject.h
+++ b/gnl/gnlobject.h
@@ -56,6 +56,7 @@ typedef enum
GNL_OBJECT_SOURCE = (GST_BIN_FLAG_LAST << 0),
GNL_OBJECT_OPERATION = (GST_BIN_FLAG_LAST << 1),
GNL_OBJECT_EXPANDABLE = (GST_BIN_FLAG_LAST << 2),
+ GNL_OBJECT_COMPOSITION = (GST_BIN_FLAG_LAST << 3),
/* padding */
GNL_OBJECT_LAST_FLAG = (GST_BIN_FLAG_LAST << 5)
} GnlObjectFlags;
@@ -67,6 +68,8 @@ typedef enum
(GST_OBJECT_FLAG_IS_SET(obj, GNL_OBJECT_OPERATION))
#define GNL_OBJECT_IS_EXPANDABLE(obj) \
(GST_OBJECT_FLAG_IS_SET(obj, GNL_OBJECT_EXPANDABLE))
+#define GNL_OBJECT_IS_COMPOSITION(obj) \
+ (GST_OBJECT_FLAG_IS_SET(obj, GNL_OBJECT_COMPOSITION))
/* For internal usage only */
#define GNL_OBJECT_START(obj) (GNL_OBJECT_CAST (obj)->start)
@@ -75,6 +78,8 @@ typedef enum
#define GNL_OBJECT_INPOINT(obj) (GNL_OBJECT_CAST (obj)->inpoint)
#define GNL_OBJECT_PRIORITY(obj) (GNL_OBJECT_CAST (obj)->priority)
+#define GNL_OBJECT_IS_COMMITING(obj) (GNL_OBJECT_CAST (obj)->commiting)
+
struct _GnlObject
{
GstBin parent;
@@ -84,6 +89,20 @@ struct _GnlObject
GstClockTime inpoint;
GstClockTimeDiff duration;
+ /* Pending time positionning
+ * Should be == GST_CLOCK_TIME_NONE when nothing to do
+ */
+ GstClockTime pending_start;
+ GstClockTime pending_inpoint;
+ GstClockTimeDiff pending_duration;
+ guint32 pending_priority;
+ gboolean pending_active;
+
+ gboolean commit_needed;
+ gboolean commiting; /* Set to TRUE during the commiting time only */
+
+ gboolean expandable;
+
/* read-only */
GstClockTime stop;
@@ -107,9 +126,13 @@ struct _GnlObjectClass
{
GstBinClass parent_class;
+ /* Signal method handler */
+ gboolean (*commit_signal_handler) (GnlObject * object, gboolean recurse);
+
/* virtual methods for subclasses */
gboolean (*prepare) (GnlObject * object);
gboolean (*cleanup) (GnlObject * object);
+ gboolean (*commit) (GnlObject * object, gboolean recurse);
};
GType gnl_object_get_type (void);
@@ -125,5 +148,13 @@ gnl_media_to_object_time (GnlObject * object, GstClockTime mtime,
void
gnl_object_set_caps (GnlObject * object, const GstCaps * caps);
+void
+gnl_object_set_commit_needed (GnlObject *object);
+
+gboolean
+gnl_object_commit (GnlObject *object, gboolean recurse);
+
+void
+gnl_object_reset (GnlObject *object);
G_END_DECLS
#endif /* __GNL_OBJECT_H__ */
diff --git a/tests/check/gnl/common.c b/tests/check/gnl/common.c
index 7b21a00..a163adc 100644
--- a/tests/check/gnl/common.c
+++ b/tests/check/gnl/common.c
@@ -207,6 +207,7 @@ videotest_gnl_src_full (const gchar * name, guint64 start, gint64 duration,
g_object_set (G_OBJECT (gnls), "inpoint", inpoint, NULL);
}
+
return gnls;
}
diff --git a/tests/check/gnl/complex.c b/tests/check/gnl/complex.c
index 423903c..4dcecc3 100644
--- a/tests/check/gnl/complex.c
+++ b/tests/check/gnl/complex.c
@@ -128,6 +128,7 @@ fill_pipeline_and_check (GstElement * comp, GList * segments)
GST_START_TEST (test_one_space_another)
{
GstElement *comp, *source1, *source2;
+ gboolean ret = FALSE;
GList *segments = NULL;
comp =
@@ -165,12 +166,15 @@ GST_START_TEST (test_one_space_another)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
+ check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
@@ -185,6 +189,7 @@ GST_START_TEST (test_one_space_another)
/* Re-add first source */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
gst_object_unref (source1);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
@@ -203,6 +208,7 @@ GST_END_TEST;
GST_START_TEST (test_one_default_another)
{
+ gboolean ret = FALSE;
GstElement *comp, *source1, *source2, *source3, *defaultsrc;
GList *segments = NULL;
@@ -228,6 +234,7 @@ GST_START_TEST (test_one_default_another)
defaultsrc =
videotest_gnl_src ("defaultsrc", 0, 5 * GST_SECOND, 2, G_MAXUINT32);
+ g_object_set (defaultsrc, "expandable", TRUE, NULL);
fail_if (defaultsrc == NULL);
check_start_stop_duration (defaultsrc, 0, 5 * GST_SECOND, 5 * GST_SECOND);
@@ -268,13 +275,14 @@ GST_START_TEST (test_one_default_another)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
/* defaultsrc source */
-
gst_bin_add (GST_BIN (comp), defaultsrc);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
check_start_stop_duration (defaultsrc, 0, 2 * GST_SECOND, 2 * GST_SECOND);
@@ -283,15 +291,11 @@ GST_START_TEST (test_one_default_another)
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
- check_start_stop_duration (comp, 0, 4 * GST_SECOND, 4 * GST_SECOND);
- check_start_stop_duration (defaultsrc, 0, 4 * GST_SECOND, 4 * GST_SECOND);
-
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
-
-
/* Third source */
-
gst_bin_add (GST_BIN (comp), source3);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ fail_unless (ret);
check_start_stop_duration (comp, 0, 5 * GST_SECOND, 5 * GST_SECOND);
check_start_stop_duration (defaultsrc, 0, 5 * GST_SECOND, 5 * GST_SECOND);
@@ -322,6 +326,7 @@ GST_START_TEST (test_one_expandable_another)
{
GstElement *comp, *source1, *source2, *source3, *defaultsrc;
GList *segments = NULL;
+ gboolean ret = FALSE;
comp =
gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
@@ -384,6 +389,7 @@ GST_START_TEST (test_one_expandable_another)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
@@ -391,6 +397,7 @@ GST_START_TEST (test_one_expandable_another)
/* defaultsrc source */
gst_bin_add (GST_BIN (comp), defaultsrc);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
check_start_stop_duration (defaultsrc, 0, 2 * GST_SECOND, 2 * GST_SECOND);
@@ -399,6 +406,7 @@ GST_START_TEST (test_one_expandable_another)
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 4 * GST_SECOND, 4 * GST_SECOND);
check_start_stop_duration (defaultsrc, 0, 4 * GST_SECOND, 4 * GST_SECOND);
@@ -408,6 +416,7 @@ GST_START_TEST (test_one_expandable_another)
/* Third source */
gst_bin_add (GST_BIN (comp), source3);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 5 * GST_SECOND, 5 * GST_SECOND);
check_start_stop_duration (defaultsrc, 0, 5 * GST_SECOND, 5 * GST_SECOND);
@@ -438,6 +447,7 @@ GST_END_TEST;
GST_START_TEST (test_renegotiation)
{
+ gboolean ret;
GstElement *pipeline;
GstElement *comp, *sink, *source1, *source2, *source3;
GstElement *audioconvert;
@@ -489,6 +499,7 @@ GST_START_TEST (test_renegotiation)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
@@ -496,6 +507,7 @@ GST_START_TEST (test_renegotiation)
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
@@ -504,6 +516,7 @@ GST_START_TEST (test_renegotiation)
/* Third source */
gst_bin_add (GST_BIN (comp), source3);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source3, "source3", 1);
@@ -649,6 +662,7 @@ GST_END_TEST;
GST_START_TEST (test_one_bin_space_another)
{
GstElement *comp, *source1, *source2;
+ gboolean ret = FALSE;
GList *segments = NULL;
comp =
@@ -681,11 +695,13 @@ GST_START_TEST (test_one_bin_space_another)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
/* Remove second source */
@@ -698,6 +714,7 @@ GST_START_TEST (test_one_bin_space_another)
/* Re-add second source */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
gst_object_unref (source1);
@@ -717,6 +734,7 @@ GST_END_TEST;
GST_START_TEST (test_one_above_another)
{
GstElement *comp, *source1, *source2;
+ gboolean ret = FALSE;
GList *segments = NULL;
comp =
@@ -747,11 +765,13 @@ GST_START_TEST (test_one_above_another)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
/* Remove second source */
@@ -764,6 +784,7 @@ GST_START_TEST (test_one_above_another)
/* Re-add second source */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
gst_object_unref (source1);
diff --git a/tests/check/gnl/gnlcomposition.c b/tests/check/gnl/gnlcomposition.c
index 5353409..58a9770 100644
--- a/tests/check/gnl/gnlcomposition.c
+++ b/tests/check/gnl/gnlcomposition.c
@@ -69,7 +69,7 @@ GST_START_TEST (test_change_object_start_stop_in_current_stack)
GstElement *comp, *source1, *def, *sink;
GstBus *bus;
GstMessage *message;
- gboolean carry_on;
+ gboolean carry_on, ret = FALSE;
int seek_events_before;
pipeline = gst_pipeline_new ("test_pipeline");
@@ -96,8 +96,6 @@ GST_START_TEST (test_change_object_start_stop_in_current_stack)
g_object_connect (source1, "signal::pad-added",
on_source1_pad_added_cb, NULL, NULL);
- check_start_stop_duration (source1, 0, 2 * GST_SECOND, 2 * GST_SECOND);
-
/*
def (default source)
Priority = G_MAXUINT32
@@ -105,6 +103,7 @@ GST_START_TEST (test_change_object_start_stop_in_current_stack)
def =
videotest_gnl_src ("default", 0 * GST_SECOND, 0 * GST_SECOND, 2,
G_MAXUINT32);
+ g_object_set (def, "expandable", TRUE, NULL);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
ASSERT_OBJECT_REFCOUNT (def, "default", 1);
@@ -114,11 +113,11 @@ GST_START_TEST (test_change_object_start_stop_in_current_stack)
/* keep an extra ref to source1 as we remove it from the bin */
gst_object_ref (source1);
gst_bin_add (GST_BIN (comp), source1);
- check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
/* Add default */
-
gst_bin_add (GST_BIN (comp), def);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ check_start_stop_duration (source1, 0, 2 * GST_SECOND, 2 * GST_SECOND);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
bus = gst_element_get_bus (GST_ELEMENT (pipeline));
@@ -166,6 +165,7 @@ GST_START_TEST (test_change_object_start_stop_in_current_stack)
/* move source1 out of the active segment */
g_object_set (source1, "start", 4 * GST_SECOND, NULL);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
fail_unless (seek_events > seek_events_before);
/* remove source1 from the composition, which will become empty and remove the
@@ -184,6 +184,7 @@ GST_START_TEST (test_change_object_start_stop_in_current_stack)
g_object_set (source1, "start", 0 * GST_SECOND, NULL);
/* add the source again and check that the ghostpad is added again */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
fail_unless_equals_int (composition_pad_added, 2);
fail_unless_equals_int (composition_pad_removed, 1);
@@ -191,6 +192,7 @@ GST_START_TEST (test_change_object_start_stop_in_current_stack)
seek_events_before = seek_events;
g_object_set (source1, "duration", 1 * GST_SECOND, NULL);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
fail_unless (seek_events > seek_events_before);
GST_DEBUG ("Setting pipeline to NULL");
@@ -251,12 +253,16 @@ pad_block (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
static void
no_more_pads_test_cb (GObject * object, TestClosure * c)
{
+ gboolean ret;
+
GST_WARNING ("NO MORE PADS");
gst_bin_add (GST_BIN (c->composition), c->source3);
+ g_signal_emit_by_name (c->composition, "commit", TRUE, &ret);
}
GST_START_TEST (test_no_more_pads_race)
{
+ gboolean ret;
GstElement *source1, *source2, *source3;
GstBin *bin;
GstElement *videotestsrc1, *videotestsrc2;
@@ -346,6 +352,7 @@ GST_START_TEST (test_no_more_pads_race)
no_more_pads_test_cb, &closure, NULL);
gst_bin_add (GST_BIN (composition), source1);
+ g_signal_emit_by_name (composition, "commit", TRUE, &ret);
g_object_connect (composition, "signal::pad-added",
on_composition_pad_added_cb, fakesink, NULL);
g_object_connect (composition, "signal::pad-removed",
@@ -371,6 +378,7 @@ GST_START_TEST (test_no_more_pads_race)
/* FIXME: maybe slow down the videotestsrc steaming thread */
gst_bin_add (GST_BIN (composition), source2);
+ g_signal_emit_by_name (composition, "commit", TRUE, &ret);
message =
gst_bus_timed_pop_filtered (bus, GST_SECOND / 10, GST_MESSAGE_ERROR);
@@ -403,7 +411,7 @@ GST_START_TEST (test_simple_adder)
GstElement *gnlsource1, *gnlsource2;
GstElement *audiotestsrc1, *audiotestsrc2;
- gboolean carry_on = TRUE;
+ gboolean carry_on = TRUE, ret;
GstClockTime total_time = 10 * GST_SECOND;
pipeline = GST_ELEMENT (gst_pipeline_new (NULL));
@@ -451,6 +459,7 @@ GST_START_TEST (test_simple_adder)
GST_DEBUG ("Setting pipeline to PAUSED");
+ g_signal_emit_by_name (composition, "commit", TRUE, &ret);
fail_if (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING)
== GST_STATE_CHANGE_FAILURE);
diff --git a/tests/check/gnl/gnloperation.c b/tests/check/gnl/gnloperation.c
index e017938..d6f7a78 100644
--- a/tests/check/gnl/gnloperation.c
+++ b/tests/check/gnl/gnloperation.c
@@ -127,6 +127,7 @@ fill_pipeline_and_check (GstElement * comp, GList * segments)
GST_START_TEST (test_simple_operation)
{
+ gboolean ret = FALSE;
GstElement *comp, *oper, *source;
GList *segments = NULL;
@@ -150,7 +151,6 @@ GST_START_TEST (test_simple_operation)
source = videotest_gnl_src ("source", 0, 3 * GST_SECOND, 2, 1);
fail_if (source == NULL);
- check_start_stop_duration (source, 0, 3 * GST_SECOND, 3 * GST_SECOND);
/*
operation
@@ -161,14 +161,13 @@ GST_START_TEST (test_simple_operation)
oper = new_operation ("oper", "identity", 1 * GST_SECOND, 1 * GST_SECOND, 0);
fail_if (oper == NULL);
- check_start_stop_duration (oper, 1 * GST_SECOND, 2 * GST_SECOND,
- 1 * GST_SECOND);
/* Add source */
ASSERT_OBJECT_REFCOUNT (source, "source", 1);
ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
gst_bin_add (GST_BIN (comp), source);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source, "source", 1);
@@ -176,6 +175,7 @@ GST_START_TEST (test_simple_operation)
/* Add operaton */
gst_bin_add (GST_BIN (comp), oper);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
@@ -191,6 +191,7 @@ GST_START_TEST (test_simple_operation)
/* re-add source */
gst_bin_add (GST_BIN (comp), source);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
gst_object_unref (source);
@@ -214,6 +215,7 @@ GST_END_TEST;
GST_START_TEST (test_pyramid_operations)
{
GstElement *comp, *oper1, *oper2, *source;
+ gboolean ret = FALSE;
GList *segments = NULL;
comp =
@@ -227,7 +229,6 @@ GST_START_TEST (test_pyramid_operations)
*/
source = videotest_gnl_src ("source", 0, 10 * GST_SECOND, 2, 2);
- check_start_stop_duration (source, 0, 10 * GST_SECOND, 10 * GST_SECOND);
/*
operation1
@@ -238,8 +239,6 @@ GST_START_TEST (test_pyramid_operations)
oper1 =
new_operation ("oper1", "identity", 4 * GST_SECOND, 2 * GST_SECOND, 1);
- check_start_stop_duration (oper1, 4 * GST_SECOND, 6 * GST_SECOND,
- 2 * GST_SECOND);
/*
operation2
@@ -250,8 +249,6 @@ GST_START_TEST (test_pyramid_operations)
oper2 =
new_operation ("oper2", "identity", 2 * GST_SECOND, 6 * GST_SECOND, 0);
- check_start_stop_duration (oper2, 2 * GST_SECOND, 8 * GST_SECOND,
- 6 * GST_SECOND);
/* Add source */
ASSERT_OBJECT_REFCOUNT (source, "source", 1);
@@ -259,6 +256,8 @@ GST_START_TEST (test_pyramid_operations)
ASSERT_OBJECT_REFCOUNT (oper2, "oper2", 1);
gst_bin_add (GST_BIN (comp), source);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ check_start_stop_duration (source, 0, 10 * GST_SECOND, 10 * GST_SECOND);
check_start_stop_duration (comp, 0, 10 * GST_SECOND, 10 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source, "source", 1);
@@ -266,6 +265,9 @@ GST_START_TEST (test_pyramid_operations)
/* Add operation 1 */
gst_bin_add (GST_BIN (comp), oper1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ check_start_stop_duration (oper1, 4 * GST_SECOND, 6 * GST_SECOND,
+ 2 * GST_SECOND);
check_start_stop_duration (comp, 0, 10 * GST_SECOND, 10 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (oper1, "oper1", 1);
@@ -273,6 +275,9 @@ GST_START_TEST (test_pyramid_operations)
/* Add operation 2 */
gst_bin_add (GST_BIN (comp), oper2);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ check_start_stop_duration (oper2, 2 * GST_SECOND, 8 * GST_SECOND,
+ 6 * GST_SECOND);
check_start_stop_duration (comp, 0, 10 * GST_SECOND, 10 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (oper1, "oper2", 1);
@@ -300,6 +305,7 @@ GST_END_TEST;
GST_START_TEST (test_pyramid_operations2)
{
+ gboolean ret;
GstElement *comp, *oper, *source1, *source2, *def;
GList *segments = NULL;
@@ -314,7 +320,6 @@ GST_START_TEST (test_pyramid_operations2)
*/
source1 = videotest_gnl_src ("source1", 0, 2 * GST_SECOND, 2, 2);
- check_start_stop_duration (source1, 0, 2 * GST_SECOND, 2 * GST_SECOND);
/*
operation
@@ -324,8 +329,6 @@ GST_START_TEST (test_pyramid_operations2)
*/
oper = new_operation ("oper", "identity", 1 * GST_SECOND, 4 * GST_SECOND, 1);
- check_start_stop_duration (oper, 1 * GST_SECOND, 5 * GST_SECOND,
- 4 * GST_SECOND);
/*
source2
@@ -335,8 +338,6 @@ GST_START_TEST (test_pyramid_operations2)
*/
source2 = videotest_gnl_src ("source2", 4 * GST_SECOND, 2 * GST_SECOND, 2, 2);
- check_start_stop_duration (source2, 4 * GST_SECOND, 6 * GST_SECOND,
- 2 * GST_SECOND);
/*
def (default source)
@@ -345,6 +346,7 @@ GST_START_TEST (test_pyramid_operations2)
def =
videotest_gnl_src ("default", 0 * GST_SECOND, 0 * GST_SECOND, 2,
G_MAXUINT32);
+ g_object_set (def, "expandable", TRUE, NULL);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
@@ -354,21 +356,25 @@ GST_START_TEST (test_pyramid_operations2)
/* Add source 1 */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
/* Add source 2 */
gst_bin_add (GST_BIN (comp), source2);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
/* Add operation */
gst_bin_add (GST_BIN (comp), oper);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
/* Add default */
gst_bin_add (GST_BIN (comp), def);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
@@ -396,6 +402,7 @@ GST_END_TEST;
GST_START_TEST (test_pyramid_operations_expandable)
{
GstElement *comp, *oper, *source1, *source2, *def;
+ gboolean ret = FALSE;
GList *segments = NULL;
comp =
@@ -409,7 +416,6 @@ GST_START_TEST (test_pyramid_operations_expandable)
*/
source1 = videotest_gnl_src ("source1", 0, 2 * GST_SECOND, 2, 2);
- check_start_stop_duration (source1, 0, 2 * GST_SECOND, 2 * GST_SECOND);
/*
operation (expandable)
@@ -420,8 +426,6 @@ GST_START_TEST (test_pyramid_operations_expandable)
oper = new_operation ("oper", "identity", 1 * GST_SECOND, 4 * GST_SECOND, 1);
g_object_set (oper, "expandable", TRUE, NULL);
- check_start_stop_duration (oper, 1 * GST_SECOND, 5 * GST_SECOND,
- 4 * GST_SECOND);
/*
source2
@@ -431,8 +435,6 @@ GST_START_TEST (test_pyramid_operations_expandable)
*/
source2 = videotest_gnl_src ("source2", 4 * GST_SECOND, 2 * GST_SECOND, 2, 2);
- check_start_stop_duration (source2, 4 * GST_SECOND, 6 * GST_SECOND,
- 2 * GST_SECOND);
/*
def (default source)
@@ -441,6 +443,7 @@ GST_START_TEST (test_pyramid_operations_expandable)
def =
videotest_gnl_src ("default", 0 * GST_SECOND, 0 * GST_SECOND, 2,
G_MAXUINT32);
+ g_object_set (def, "expandable", TRUE, NULL);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
@@ -448,23 +451,20 @@ GST_START_TEST (test_pyramid_operations_expandable)
ASSERT_OBJECT_REFCOUNT (def, "default", 1);
/* Add source 1 */
-
gst_bin_add (GST_BIN (comp), source1);
- check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
-
/* Add source 2 */
-
gst_bin_add (GST_BIN (comp), source2);
- check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
-
/* Add operation */
-
gst_bin_add (GST_BIN (comp), oper);
- check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
-
/* Add default */
-
gst_bin_add (GST_BIN (comp), def);
+
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ check_start_stop_duration (source1, 0, 2 * GST_SECOND, 2 * GST_SECOND);
+ check_start_stop_duration (oper, 0 * GST_SECOND, 6 * GST_SECOND,
+ 6 * GST_SECOND);
+ check_start_stop_duration (source2, 4 * GST_SECOND, 6 * GST_SECOND,
+ 2 * GST_SECOND);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
/* Expected segments */
@@ -486,6 +486,7 @@ GST_END_TEST;
GST_START_TEST (test_complex_operations)
{
GstElement *comp, *oper, *source1, *source2;
+ gboolean ret = FALSE;
GList *segments = NULL;
comp =
@@ -509,7 +510,6 @@ GST_START_TEST (test_complex_operations)
source1 = videotest_in_bin_gnl_src ("source1", 0, 4 * GST_SECOND, 2, 3);
fail_if (source1 == NULL);
- check_start_stop_duration (source1, 0, 4 * GST_SECOND, 4 * GST_SECOND);
/*
source2
@@ -522,8 +522,6 @@ GST_START_TEST (test_complex_operations)
videotest_in_bin_gnl_src ("source2", 2 * GST_SECOND, 4 * GST_SECOND, 2,
2);
fail_if (source2 == NULL);
- check_start_stop_duration (source2, 2 * GST_SECOND, 6 * GST_SECOND,
- 4 * GST_SECOND);
/*
operation
@@ -535,8 +533,6 @@ GST_START_TEST (test_complex_operations)
oper =
new_operation ("oper", "videomixer", 2 * GST_SECOND, 2 * GST_SECOND, 1);
fail_if (oper == NULL);
- check_start_stop_duration (oper, 2 * GST_SECOND, 4 * GST_SECOND,
- 2 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
@@ -544,19 +540,19 @@ GST_START_TEST (test_complex_operations)
/* Add source1 */
gst_bin_add (GST_BIN (comp), source1);
- check_start_stop_duration (comp, 0, 4 * GST_SECOND, 4 * GST_SECOND);
-
+ check_start_stop_duration (comp, 0, 0, 0);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
/* Add source2 */
gst_bin_add (GST_BIN (comp), source2);
- check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
-
+ check_start_stop_duration (comp, 0, 0, 0);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
/* Add operaton */
-
gst_bin_add (GST_BIN (comp), oper);
+ check_start_stop_duration (comp, 0, 0, 0);
+
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
@@ -580,6 +576,7 @@ GST_END_TEST;
GST_START_TEST (test_complex_operations_bis)
{
GstElement *comp, *oper, *source1, *source2;
+ gboolean ret;
GList *segments = NULL;
comp =
@@ -604,7 +601,6 @@ GST_START_TEST (test_complex_operations_bis)
source1 = videotest_in_bin_gnl_src ("source1", 0, 4 * GST_SECOND, 3, 2);
fail_if (source1 == NULL);
- check_start_stop_duration (source1, 0, 4 * GST_SECOND, 4 * GST_SECOND);
/*
source2
@@ -617,8 +613,6 @@ GST_START_TEST (test_complex_operations_bis)
videotest_in_bin_gnl_src ("source2", 2 * GST_SECOND, 4 * GST_SECOND, 2,
3);
fail_if (source2 == NULL);
- check_start_stop_duration (source2, 2 * GST_SECOND, 6 * GST_SECOND,
- 4 * GST_SECOND);
/*
operation
@@ -631,8 +625,6 @@ GST_START_TEST (test_complex_operations_bis)
oper =
new_operation ("oper", "videomixer", 2 * GST_SECOND, 2 * GST_SECOND, 1);
fail_if (oper == NULL);
- check_start_stop_duration (oper, 2 * GST_SECOND, 4 * GST_SECOND,
- 2 * GST_SECOND);
g_object_set (oper, "expandable", TRUE, NULL);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
@@ -641,12 +633,14 @@ GST_START_TEST (test_complex_operations_bis)
/* Add source1 */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 4 * GST_SECOND, 4 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
/* Add source2 */
gst_bin_add (GST_BIN (comp), source2);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
@@ -654,6 +648,7 @@ GST_START_TEST (test_complex_operations_bis)
/* Add operaton */
gst_bin_add (GST_BIN (comp), oper);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
/* Since it's expandable, it should have changed to full length */
check_start_stop_duration (oper, 0 * GST_SECOND, 6 * GST_SECOND,
diff --git a/tests/check/gnl/gnlsource.c b/tests/check/gnl/gnlsource.c
index 07bb7aa..e2d568a 100644
--- a/tests/check/gnl/gnlsource.c
+++ b/tests/check/gnl/gnlsource.c
@@ -124,7 +124,6 @@ GST_START_TEST (test_videotestsrc_in_bin)
/* Handle systems which don't have alpha available */
if (gnlsource == NULL)
return;
- check_start_stop_duration (gnlsource, 0, 1 * GST_SECOND, 1 * GST_SECOND);
sink = gst_element_factory_make_or_warn ("fakesink", "sink");
fail_if (sink == NULL);
diff --git a/tests/check/gnl/seek.c b/tests/check/gnl/seek.c
index fa6b724..a173f47 100644
--- a/tests/check/gnl/seek.c
+++ b/tests/check/gnl/seek.c
@@ -157,6 +157,7 @@ fill_pipeline_and_check (GstElement * comp, GList * segments, GList * seeks)
static void
test_simplest_full (void)
{
+ gboolean ret;
GstElement *comp, *source1;
GList *segments = NULL;
GList *seeks = NULL;
@@ -181,6 +182,7 @@ test_simplest_full (void)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
@@ -220,6 +222,7 @@ test_simplest_full (void)
static void
test_one_after_other_full (void)
{
+ gboolean ret;
GstElement *comp, *source1, *source2;
GList *segments = NULL, *seeks = NULL;
@@ -264,6 +267,10 @@ test_one_after_other_full (void)
/* Add sources */
gst_bin_add (GST_BIN (comp), source1);
gst_bin_add (GST_BIN (comp), source2);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
+ check_start_stop_duration (source2, 1 * GST_SECOND, 2 * GST_SECOND,
+ 1 * GST_SECOND);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
@@ -300,6 +307,7 @@ test_one_after_other_full (void)
static void
test_one_under_another_full (void)
{
+ gboolean ret;
GstElement *comp, *source1, *source2;
GList *segments = NULL, *seeks = NULL;
@@ -341,6 +349,10 @@ test_one_under_another_full (void)
gst_bin_add (GST_BIN (comp), source1);
gst_bin_add (GST_BIN (comp), source2);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ check_start_stop_duration (source1, 0, 2 * GST_SECOND, 2 * GST_SECOND);
+ check_start_stop_duration (source2, 1 * GST_SECOND, 3 * GST_SECOND,
+ 2 * GST_SECOND);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
/* Expected segments */
@@ -376,6 +388,7 @@ test_one_under_another_full (void)
static void
test_one_bin_after_other_full (void)
{
+ gboolean ret = FALSE;
GstElement *comp, *source1, *source2;
GList *segments = NULL, *seeks = NULL;
@@ -403,19 +416,20 @@ test_one_bin_after_other_full (void)
videotest_in_bin_gnl_src ("source2", 1 * GST_SECOND, 1 * GST_SECOND, 2,
1);
fail_if (source2 == NULL);
- check_start_stop_duration (source2, 1 * GST_SECOND, 2 * GST_SECOND,
- 1 * GST_SECOND);
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
- check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
+ check_start_stop_duration (source2, 1 * GST_SECOND, 2 * GST_SECOND,
+ 1 * GST_SECOND);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
@@ -455,6 +469,7 @@ test_one_bin_after_other_full (void)
GST_START_TEST (test_complex_operations)
{
+ gboolean ret = FALSE;
GstElement *comp, *oper, *source1, *source2;
GList *segments = NULL, *seeks = NULL;
@@ -514,12 +529,14 @@ GST_START_TEST (test_complex_operations)
/* Add source1 */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 4 * GST_SECOND, 4 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
/* Add source2 */
gst_bin_add (GST_BIN (comp), source2);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
@@ -527,6 +544,7 @@ GST_START_TEST (test_complex_operations)
/* Add operaton */
gst_bin_add (GST_BIN (comp), oper);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
@@ -567,6 +585,7 @@ GST_END_TEST;
GST_START_TEST (test_complex_operations_bis)
{
+ gboolean ret = FALSE;
GstElement *comp, *oper, *source1, *source2;
GList *segments = NULL, *seeks = NULL;
@@ -629,12 +648,14 @@ GST_START_TEST (test_complex_operations_bis)
/* Add source1 */
gst_bin_add (GST_BIN (comp), source1);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 4 * GST_SECOND, 4 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
/* Add source2 */
gst_bin_add (GST_BIN (comp), source2);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
@@ -642,6 +663,10 @@ GST_START_TEST (test_complex_operations_bis)
/* Add operaton */
gst_bin_add (GST_BIN (comp), oper);
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ check_start_stop_duration (source1, 0, 4 * GST_SECOND, 4 * GST_SECOND);
+ check_start_stop_duration (source2, 2 * GST_SECOND, 6 * GST_SECOND,
+ 4 * GST_SECOND);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
check_start_stop_duration (oper, 0 * GST_SECOND, 6 * GST_SECOND,
6 * GST_SECOND);
diff --git a/tests/check/gnl/simple.c b/tests/check/gnl/simple.c
index 93fce7b..c305a6c 100644
--- a/tests/check/gnl/simple.c
+++ b/tests/check/gnl/simple.c
@@ -1,12 +1,9 @@
#include "common.h"
-/* macros for 'update' property enabling */
-#define DISABLE_ASYNC_UPDATE { if (async) g_object_set(comp, "update", FALSE, NULL); }
-#define ENABLE_ASYNC_UPDATE { if (async) g_object_set(comp, "update", TRUE, NULL); }
-
static void
-test_simplest_full (gboolean async)
+test_simplest_full (void)
{
+ gboolean ret = FALSE;
GstElement *pipeline;
GstElement *comp, *sink, *source1;
CollectStructure *collect;
@@ -34,11 +31,11 @@ test_simplest_full (gboolean async)
/* Add one source */
- DISABLE_ASYNC_UPDATE;
gst_bin_add (GST_BIN (comp), source1);
- ENABLE_ASYNC_UPDATE;
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ fail_unless (ret);
+ check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
-
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
sink = gst_element_factory_make_or_warn ("fakesink", "sink");
@@ -114,8 +111,9 @@ test_simplest_full (gboolean async)
}
static void
-test_time_duration_full (gboolean async)
+test_time_duration_full (void)
{
+ gboolean ret = FALSE;
GstElement *comp, *source1, *source2;
comp =
@@ -146,18 +144,19 @@ test_time_duration_full (gboolean async)
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
- DISABLE_ASYNC_UPDATE;
gst_bin_add (GST_BIN (comp), source1);
- ENABLE_ASYNC_UPDATE;
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ fail_unless (ret == TRUE);
check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
/* Second source */
- DISABLE_ASYNC_UPDATE;
+ ret = FALSE;
gst_bin_add (GST_BIN (comp), source2);
- ENABLE_ASYNC_UPDATE;
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ fail_unless (ret == TRUE);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
@@ -165,9 +164,8 @@ test_time_duration_full (gboolean async)
/* Remove first source */
gst_object_ref (source1);
- DISABLE_ASYNC_UPDATE;
gst_bin_remove (GST_BIN (comp), source1);
- ENABLE_ASYNC_UPDATE;
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 1 * GST_SECOND, 2 * GST_SECOND,
1 * GST_SECOND);
@@ -175,9 +173,8 @@ test_time_duration_full (gboolean async)
/* Re-add first source */
- DISABLE_ASYNC_UPDATE;
gst_bin_add (GST_BIN (comp), source1);
- ENABLE_ASYNC_UPDATE;
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
gst_object_unref (source1);
@@ -187,7 +184,7 @@ test_time_duration_full (gboolean async)
}
static void
-test_one_after_other_full (gboolean async)
+test_one_after_other_full (void)
{
GstElement *pipeline;
GstElement *comp, *sink, *source1, *source2;
@@ -197,6 +194,8 @@ test_one_after_other_full (gboolean async)
gboolean carry_on = TRUE;
GstPad *sinkpad;
+ gboolean ret = FALSE;
+
pipeline = gst_pipeline_new ("test_pipeline");
comp =
gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
@@ -207,7 +206,6 @@ test_one_after_other_full (gboolean async)
Start : 0s
Duration : 1s
Media start : 5s
- Media Duartion : 1s
Priority : 1
*/
source1 =
@@ -230,19 +228,21 @@ test_one_after_other_full (gboolean async)
1 * GST_SECOND);
/* Add one source */
-
- DISABLE_ASYNC_UPDATE;
gst_bin_add (GST_BIN (comp), source1);
- ENABLE_ASYNC_UPDATE;
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
/* Second source */
-
- DISABLE_ASYNC_UPDATE;
gst_bin_add (GST_BIN (comp), source2);
- ENABLE_ASYNC_UPDATE;
+
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ fail_unless (ret);
+ check_start_stop_duration (source1, 0 * GST_SECOND, 1 * GST_SECOND,
+ 1 * GST_SECOND);
+ check_start_stop_duration (source2, 1 * GST_SECOND, 2 * GST_SECOND,
+ 1 * GST_SECOND);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
@@ -250,9 +250,7 @@ test_one_after_other_full (gboolean async)
/* Remove first source */
gst_object_ref (source1);
- DISABLE_ASYNC_UPDATE;
gst_bin_remove (GST_BIN (comp), source1);
- ENABLE_ASYNC_UPDATE;
check_start_stop_duration (comp, 1 * GST_SECOND, 2 * GST_SECOND,
1 * GST_SECOND);
@@ -260,9 +258,8 @@ test_one_after_other_full (gboolean async)
/* Re-add first source */
- DISABLE_ASYNC_UPDATE;
gst_bin_add (GST_BIN (comp), source1);
- ENABLE_ASYNC_UPDATE;
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
gst_object_unref (source1);
@@ -395,8 +392,9 @@ test_one_after_other_full (gboolean async)
}
static void
-test_one_under_another_full (gboolean async)
+test_one_under_another_full (void)
{
+ gboolean ret = FALSE;
GstElement *pipeline;
GstElement *comp, *sink, *source1, *source2;
CollectStructure *collect;
@@ -441,26 +439,27 @@ test_one_under_another_full (gboolean async)
/* Add two sources */
- DISABLE_ASYNC_UPDATE;
gst_bin_add (GST_BIN (comp), source1);
gst_bin_add (GST_BIN (comp), source2);
- ENABLE_ASYNC_UPDATE;
+ check_start_stop_duration (comp, 0, 0 * GST_SECOND, 0 * GST_SECOND);
+ /* Now commiting changes */
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
+ check_start_stop_duration (source1, 0, 2 * GST_SECOND, 2 * GST_SECOND);
+ check_start_stop_duration (source2, 1 * GST_SECOND, 3 * GST_SECOND,
+ 2 * GST_SECOND);
/* Remove second source */
gst_object_ref (source1);
- DISABLE_ASYNC_UPDATE;
gst_bin_remove (GST_BIN (comp), source1);
- ENABLE_ASYNC_UPDATE;
check_start_stop_duration (comp, 1 * GST_SECOND, 3 * GST_SECOND,
2 * GST_SECOND);
/* Re-add second source */
- DISABLE_ASYNC_UPDATE;
gst_bin_add (GST_BIN (comp), source1);
- ENABLE_ASYNC_UPDATE;
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
gst_object_unref (source1);
@@ -536,8 +535,9 @@ test_one_under_another_full (gboolean async)
}
static void
-test_one_bin_after_other_full (gboolean async)
+test_one_bin_after_other_full (void)
{
+ gboolean ret = FALSE;
GstElement *pipeline;
GstElement *comp, *sink, *source1, *source2;
CollectStructure *collect;
@@ -580,28 +580,29 @@ test_one_bin_after_other_full (gboolean async)
/* Add one source */
- DISABLE_ASYNC_UPDATE;
gst_bin_add (GST_BIN (comp), source1);
- ENABLE_ASYNC_UPDATE;
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
+ fail_unless (ret);
check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
+ check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
/* Second source */
- DISABLE_ASYNC_UPDATE;
gst_bin_add (GST_BIN (comp), source2);
- ENABLE_ASYNC_UPDATE;
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
+ check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
+ check_start_stop_duration (source2, 1 * GST_SECOND, 2 * GST_SECOND,
+ 1 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
/* Remove first source */
gst_object_ref (source1);
- DISABLE_ASYNC_UPDATE;
gst_bin_remove (GST_BIN (comp), source1);
- ENABLE_ASYNC_UPDATE;
check_start_stop_duration (comp, 1 * GST_SECOND, 2 * GST_SECOND,
1 * GST_SECOND);
@@ -609,9 +610,8 @@ test_one_bin_after_other_full (gboolean async)
/* Re-add first source */
- DISABLE_ASYNC_UPDATE;
gst_bin_add (GST_BIN (comp), source1);
- ENABLE_ASYNC_UPDATE;
+ g_signal_emit_by_name (comp, "commit", TRUE, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
gst_object_unref (source1);
@@ -739,63 +739,35 @@ test_one_bin_after_other_full (gboolean async)
GST_START_TEST (test_simplest)
{
- test_simplest_full (FALSE);
-}
-
-GST_END_TEST;
-
-GST_START_TEST (test_simplest_async)
-{
- test_simplest_full (TRUE);
+ test_simplest_full ();
}
GST_END_TEST;
GST_START_TEST (test_time_duration)
{
- test_time_duration_full (FALSE);
-}
-
-GST_END_TEST;
-
-GST_START_TEST (test_time_duration_async)
-{
- test_time_duration_full (TRUE);
+ test_time_duration_full ();
}
GST_END_TEST;
GST_START_TEST (test_one_after_other)
{
- test_one_after_other_full (FALSE);
-}
-
-GST_END_TEST;
-
-GST_START_TEST (test_one_after_other_async)
-{
- test_one_after_other_full (TRUE);
+ test_one_after_other_full ();
}
GST_END_TEST;
GST_START_TEST (test_one_under_another)
{
- test_one_under_another_full (FALSE);
-}
-
-GST_END_TEST;
-
-GST_START_TEST (test_one_under_another_async)
-{
- test_one_under_another_full (TRUE);
+ test_one_under_another_full ();
}
GST_END_TEST;
GST_START_TEST (test_one_bin_after_other)
{
- test_one_bin_after_other_full (FALSE);
+ test_one_bin_after_other_full ();
}
GST_END_TEST;
@@ -809,15 +781,10 @@ gnonlin_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_time_duration);
- tcase_add_test (tc_chain, test_time_duration_async);
tcase_add_test (tc_chain, test_simplest);
- tcase_add_test (tc_chain, test_simplest_async);
tcase_add_test (tc_chain, test_one_after_other);
- tcase_add_test (tc_chain, test_one_after_other_async);
tcase_add_test (tc_chain, test_one_under_another);
- tcase_add_test (tc_chain, test_one_under_another_async);
tcase_add_test (tc_chain, test_one_bin_after_other);
- tcase_add_test (tc_chain, test_one_bin_after_other_full);
return s;
}