composition: switch to using an action signal to add and remove objects.

This commit is contained in:
Thibault Saunier 2014-06-30 16:21:30 +02:00
parent be269c833f
commit 5faa417583
9 changed files with 261 additions and 106 deletions

View file

@ -69,6 +69,8 @@ enum
{
COMMIT_SIGNAL,
COMMITED_SIGNAL,
ADD_OBJECT_SIGNAL,
REMOVE_OBJECT_SIGNAL,
LAST_SIGNAL
};
@ -90,6 +92,11 @@ struct _GnlCompositionPrivate
GHashTable *objects_hash;
GMutex objects_lock;
/* List of GnlObject to be inserted or removed from the composition on the
* next commit */
GHashTable *pending_io;
GMutex pending_io_lock;
/*
thread-safe Seek handling.
flushing_lock : mutex to access flushing and pending_idle
@ -142,13 +149,14 @@ struct _GnlCompositionPrivate
* "g_source_attach: assertion '!SOURCE_DESTROYED (source)' failed" */
GMutex mcontext_lock;
gboolean reset_time;
gboolean running;
gboolean initialized;
GstState deactivated_elements_state;
gboolean external_gst_bin_add_remove; /* When people try to call gst_bin_add/remove themselves */
};
static guint _signals[LAST_SIGNAL] = { 0 };
@ -234,6 +242,13 @@ set_child_caps (GValue * item, GValue * ret G_GNUC_UNUSED, GnlObject * comp);
g_mutex_unlock (&comp->priv->objects_lock); \
} G_STMT_END
#define COMP_PENDING_IO_LOCK(comp) G_STMT_START { \
GST_LOG_OBJECT (comp, "locking pending_io_lock from thread %p", \
g_thread_self()); \
g_mutex_lock (&comp->priv->pending_io_lock); \
GST_LOG_OBJECT (comp, "locked pending_io_lock from thread %p", \
g_thread_self()); \
} G_STMT_END
#define COMP_FLUSHING_LOCK(comp) G_STMT_START { \
GST_LOG_OBJECT (comp, "locking flushing_lock from thread %p", \
@ -242,7 +257,6 @@ set_child_caps (GValue * item, GValue * ret G_GNUC_UNUSED, GnlObject * comp);
GST_LOG_OBJECT (comp, "locked flushing_lock from thread %p", \
g_thread_self()); \
} G_STMT_END
#define COMP_FLUSHING_UNLOCK(comp) G_STMT_START { \
GST_LOG_OBJECT (comp, "unlocking flushing_lock from thread %p", \
g_thread_self()); \
@ -433,6 +447,83 @@ _add_initialize_stack_gsource (GnlComposition * comp)
MAIN_CONTEXT_UNLOCK (comp);
}
static gboolean
remove_object_handler (GnlComposition * comp, GnlObject * object)
{
GnlCompositionPrivate *priv = comp->priv;
GnlCompositionEntry *entry;
GnlObject *in_pending_io;
COMP_OBJECTS_LOCK (comp);
entry = COMP_ENTRY (comp, object);
in_pending_io = g_hash_table_lookup (priv->pending_io, object);
if (!entry) {
if (in_pending_io) {
GST_INFO_OBJECT (comp, "Object %" GST_PTR_FORMAT " was marked"
" for addition, removing it from the addition list", object);
g_hash_table_remove (priv->pending_io, object);
COMP_OBJECTS_UNLOCK (comp);
return TRUE;
}
GST_ERROR_OBJECT (comp, "Object %" GST_PTR_FORMAT " is "
" not in the composition", object);
COMP_OBJECTS_UNLOCK (comp);
return FALSE;
}
if (in_pending_io) {
GST_WARNING_OBJECT (comp, "Object %" GST_PTR_FORMAT " is already marked"
" for removal", object);
COMP_OBJECTS_UNLOCK (comp);
return FALSE;
}
g_hash_table_add (priv->pending_io, object);
COMP_OBJECTS_UNLOCK (comp);
return TRUE;
}
static gboolean
add_object_handler (GnlComposition * comp, GnlObject * object)
{
GnlCompositionPrivate *priv = comp->priv;
GnlCompositionEntry *entry;
GnlObject *in_pending_io;
COMP_OBJECTS_LOCK (comp);
entry = COMP_ENTRY (comp, object);
in_pending_io = g_hash_table_lookup (priv->pending_io, object);
if (entry) {
GST_ERROR_OBJECT (comp, "Object %" GST_PTR_FORMAT " is "
" already in the composition", object);
COMP_OBJECTS_UNLOCK (comp);
return FALSE;
}
if (in_pending_io) {
GST_WARNING_OBJECT (comp, "Object %" GST_PTR_FORMAT " is already marked"
" for addition", object);
COMP_OBJECTS_UNLOCK (comp);
return FALSE;
}
g_hash_table_add (priv->pending_io, object);
COMP_OBJECTS_UNLOCK (comp);
return TRUE;
}
static void
gnl_composition_class_init (GnlCompositionClass * klass)
{
@ -522,7 +613,22 @@ gnl_composition_class_init (GnlCompositionClass * klass)
0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
_signals[REMOVE_OBJECT_SIGNAL] =
g_signal_new ("remove-object", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GnlCompositionClass, remove_object_handler), NULL, NULL,
NULL, G_TYPE_BOOLEAN, 1, GNL_TYPE_OBJECT);
_signals[ADD_OBJECT_SIGNAL] =
g_signal_new ("add-object", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GnlCompositionClass, add_object_handler), NULL, NULL,
NULL, G_TYPE_BOOLEAN, 1, GNL_TYPE_OBJECT);
gnlobject_class->commit = gnl_composition_commit_func;
klass->remove_object_handler = remove_object_handler;
klass->add_object_handler = add_object_handler;
}
static void
@ -576,6 +682,13 @@ gnl_composition_init (GnlComposition * comp)
priv->deactivated_elements_state = GST_STATE_READY;
priv->mcontext = g_main_context_new ();
g_mutex_init (&priv->mcontext_lock);
priv->objects_hash = g_hash_table_new_full
(g_direct_hash,
g_direct_equal, NULL, (GDestroyNotify) hash_value_destroy);
g_mutex_init (&priv->pending_io_lock);
priv->pending_io = g_hash_table_new (g_direct_hash, g_direct_equal);
priv->external_gst_bin_add_remove = TRUE;
comp->priv = priv;
@ -610,7 +723,9 @@ gnl_composition_dispose (GObject * object)
}
gnl_composition_reset_target_pad (comp);
priv->external_gst_bin_add_remove = FALSE;
G_OBJECT_CLASS (parent_class)->dispose (object);
priv->external_gst_bin_add_remove = TRUE;
}
static void
@ -632,6 +747,7 @@ gnl_composition_finalize (GObject * object)
g_mutex_clear (&priv->objects_lock);
g_mutex_clear (&priv->flushing_lock);
g_mutex_clear (&priv->pending_io_lock);
_stop_task (comp, FALSE);
g_rec_mutex_clear (&comp->task_rec_lock);
@ -1898,6 +2014,23 @@ set_child_caps (GValue * item, GValue * ret G_GNUC_UNUSED, GnlObject * comp)
return TRUE;
}
/* Must be called with OBJECTS_LOCK and PENDING_IO_LOCK taken */
static gboolean
_process_pending_entry (GnlObject * object,
GnlObject * unused_object G_GNUC_UNUSED, GnlComposition * comp)
{
GnlCompositionEntry *entry = COMP_ENTRY (comp, object);
comp->priv->external_gst_bin_add_remove = FALSE;
if (entry)
gst_bin_remove (GST_BIN (comp), GST_ELEMENT (object));
else
gst_bin_add (GST_BIN (comp), GST_ELEMENT (object));
comp->priv->external_gst_bin_add_remove = TRUE;
return TRUE;
}
static gboolean
commit_pipeline_func (GnlComposition * comp)
{
@ -1908,6 +2041,10 @@ commit_pipeline_func (GnlComposition * comp)
GST_ERROR_OBJECT (object, "Commiting state");
COMP_OBJECTS_LOCK (comp);
g_hash_table_foreach_remove (priv->pending_io,
(GHRFunc) _process_pending_entry, comp);
for (tmp = priv->objects_start; tmp; tmp = tmp->next) {
if (gnl_object_commit (tmp->data, TRUE))
commited = TRUE;
@ -2737,6 +2874,7 @@ gnl_composition_add_object (GstBin * bin, GstElement * element)
/* we only accept GnlObject */
g_return_val_if_fail (GNL_IS_OBJECT (element), FALSE);
g_return_val_if_fail (priv->external_gst_bin_add_remove == FALSE, FALSE);
GST_DEBUG_OBJECT (bin, "element %s", GST_OBJECT_NAME (element));
GST_DEBUG_OBJECT (element, "%" GST_TIME_FORMAT "--%" GST_TIME_FORMAT,
@ -2745,8 +2883,6 @@ gnl_composition_add_object (GstBin * bin, GstElement * element)
gst_object_ref (element);
COMP_OBJECTS_LOCK (comp);
if ((GNL_OBJECT_IS_EXPANDABLE (element)) &&
g_list_find (priv->expandables, element)) {
GST_WARNING_OBJECT (comp,
@ -2820,8 +2956,6 @@ gnl_composition_add_object (GstBin * bin, GstElement * element)
/* Now the object is ready to be commited and then used */
beach:
COMP_OBJECTS_UNLOCK (comp);
gst_object_unref (element);
return ret;
@ -2838,17 +2972,16 @@ gnl_composition_remove_object (GstBin * bin, GstElement * element)
GnlComposition *comp = (GnlComposition *) bin;
GnlCompositionPrivate *priv = comp->priv;
gboolean ret = FALSE;
gboolean update_required;
GnlCompositionEntry *entry;
GST_DEBUG_OBJECT (bin, "element %s", GST_OBJECT_NAME (element));
/* we only accept GnlObject */
g_return_val_if_fail (GNL_IS_OBJECT (element), FALSE);
COMP_OBJECTS_LOCK (comp);
g_return_val_if_fail (priv->external_gst_bin_add_remove == FALSE, FALSE);
entry = COMP_ENTRY (comp, element);
if (entry == NULL) {
COMP_OBJECTS_UNLOCK (comp);
goto out;
}
@ -2870,20 +3003,9 @@ gnl_composition_remove_object (GstBin * bin, GstElement * element)
gnl_composition_reset_target_pad (comp);
g_hash_table_remove (priv->objects_hash, element);
update_required = OBJECT_IN_ACTIVE_SEGMENT (comp, element) ||
(GNL_OBJECT_PRIORITY (element) == G_MAXUINT32) ||
GNL_OBJECT_IS_EXPANDABLE (element);
if (G_LIKELY (update_required)) {
/* And update the pipeline at current position if needed */
update_pipeline_at_current_position (comp);
} else
update_start_stop_duration (comp);
ret = GST_BIN_CLASS (parent_class)->remove_element (bin, element);
GST_LOG_OBJECT (element, "Done removing from the composition, now updating");
COMP_OBJECTS_UNLOCK (comp);
/* Make it possible to reuse the same object later */
gnl_object_reset (GNL_OBJECT (element));

View file

@ -49,14 +49,19 @@ struct _GnlComposition
GstTask * task;
GRecMutex task_rec_lock;
/*< private >*/
/*< private >*/
GnlCompositionPrivate * priv;
};
struct _GnlCompositionClass
{
GnlObjectClass parent_class;
/* Signal vmethods */
gboolean (*remove_object_handler) (GnlComposition * comp, GnlObject *object);
gboolean (*add_object_handler) (GnlComposition * comp, GnlObject *object);
};
GType gnl_composition_get_type (void);

View file

@ -361,10 +361,35 @@ commited_cb (GstElement * comp, gboolean changed)
void
commit_and_wait (GstElement * comp, gboolean * ret)
{
gulong handler_id = g_signal_connect (comp, "commited", (GCallback) commited_cb, NULL);
gulong handler_id =
g_signal_connect (comp, "commited", (GCallback) commited_cb, NULL);
g_mutex_lock (&lock);
g_signal_emit_by_name (comp, "commit", TRUE, ret);
g_cond_wait (&cond, &lock);
g_mutex_unlock (&lock);
g_signal_handler_disconnect (comp, handler_id);
}
gboolean
gnl_composition_remove (GstBin * comp, GstElement * object)
{
gboolean ret;
g_signal_emit_by_name (GST_BIN (comp), "remove-object", object, &ret);
if (!ret)
return ret;
commit_and_wait ((GstElement *) comp, &ret);
return ret;
}
gboolean
gnl_composition_add (GstBin * comp, GstElement * object)
{
gboolean ret;
g_signal_emit_by_name (comp, "add-object", object, &ret);
return ret;
}

View file

@ -73,3 +73,5 @@ Segment *
segment_new (gdouble rate, GstFormat format, gint64 start, gint64 stop, gint64 position);
void commit_and_wait (GstElement *comp, gboolean *ret);
gboolean gnl_composition_remove (GstBin * comp, GstElement * object);
gboolean gnl_composition_add (GstBin * comp, GstElement * object);

View file

@ -184,14 +184,14 @@ GST_START_TEST (test_one_space_another)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &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);
gnl_composition_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);
commit_and_wait (comp, &ret);
@ -200,14 +200,14 @@ GST_START_TEST (test_one_space_another)
/* Remove first source */
gst_object_ref (source1);
gst_bin_remove (GST_BIN (comp), source1);
gnl_composition_remove (GST_BIN (comp), source1);
check_start_stop_duration (comp, 2 * GST_SECOND, 3 * GST_SECOND,
1 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
/* Re-add first source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
gst_object_unref (source1);
@ -290,14 +290,14 @@ GST_START_TEST (test_one_default_another)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &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);
gnl_composition_add (GST_BIN (comp), defaultsrc);
commit_and_wait (comp, &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);
@ -306,10 +306,10 @@ GST_START_TEST (test_one_default_another)
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source2);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
/* Third source */
gst_bin_add (GST_BIN (comp), source3);
gnl_composition_add (GST_BIN (comp), source3);
commit_and_wait (comp, &ret);
fail_unless (ret);
check_start_stop_duration (comp, 0, 5 * GST_SECOND, 5 * GST_SECOND);
@ -404,7 +404,7 @@ GST_START_TEST (test_one_expandable_another)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND);
@ -412,7 +412,7 @@ GST_START_TEST (test_one_expandable_another)
/* defaultsrc source */
gst_bin_add (GST_BIN (comp), defaultsrc);
gnl_composition_add (GST_BIN (comp), defaultsrc);
commit_and_wait (comp, &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);
@ -421,7 +421,7 @@ GST_START_TEST (test_one_expandable_another)
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &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);
@ -431,7 +431,7 @@ GST_START_TEST (test_one_expandable_another)
/* Third source */
gst_bin_add (GST_BIN (comp), source3);
gnl_composition_add (GST_BIN (comp), source3);
commit_and_wait (comp, &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);
@ -514,7 +514,7 @@ GST_START_TEST (test_renegotiation)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
@ -522,7 +522,7 @@ GST_START_TEST (test_renegotiation)
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
@ -531,7 +531,7 @@ GST_START_TEST (test_renegotiation)
/* Third source */
gst_bin_add (GST_BIN (comp), source3);
gnl_composition_add (GST_BIN (comp), source3);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
@ -709,26 +709,26 @@ GST_START_TEST (test_one_bin_space_another)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
/* Remove second source */
gst_object_ref (source1);
gst_bin_remove (GST_BIN (comp), source1);
gnl_composition_remove (GST_BIN (comp), source1);
check_start_stop_duration (comp, 2 * GST_SECOND, 3 * GST_SECOND,
1 * GST_SECOND);
/* Re-add second source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
gst_object_unref (source1);
@ -775,26 +775,26 @@ GST_START_TEST (test_one_above_another)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
/* Remove second source */
gst_object_ref (source1);
gst_bin_remove (GST_BIN (comp), source1);
gnl_composition_remove (GST_BIN (comp), source1);
check_start_stop_duration (comp, 1 * GST_SECOND, 3 * GST_SECOND,
2 * GST_SECOND);
/* Re-add second source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
gst_object_unref (source1);

View file

@ -83,10 +83,10 @@ 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);
gnl_composition_add (GST_BIN (comp), source1);
/* Add default */
gst_bin_add (GST_BIN (comp), def);
gnl_composition_add (GST_BIN (comp), def);
commit_and_wait (comp, &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);
@ -139,11 +139,12 @@ GST_START_TEST (test_change_object_start_stop_in_current_stack)
/* remove source1 from the composition, which will become empty and remove the
* ghostpad */
gst_bin_remove (GST_BIN (comp), source1);
fail_unless (gnl_composition_remove (GST_BIN (comp), source1));
g_object_set (source1, "start", (guint64) 0 * GST_SECOND, NULL);
/* add the source again and check that the ghostpad is added again */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
g_mutex_lock (&pad_added_lock);
@ -185,9 +186,9 @@ GST_START_TEST (test_remove_invalid_object)
source1 = gst_element_factory_make ("gnlsource", "source1");
source2 = gst_element_factory_make ("gnlsource", "source2");
gst_bin_add (composition, source1);
fail_if (gst_bin_remove (composition, source2));
fail_unless (gst_bin_remove (composition, source1));
gnl_composition_add (composition, source1);
fail_if (gnl_composition_remove (composition, source2));
fail_unless (gnl_composition_remove (composition, source1));
gst_object_unref (composition);
gst_object_unref (source2);
@ -225,7 +226,7 @@ GST_START_TEST (test_simple_adder)
g_object_set (gnl_adder, "start", (guint64) 0 * GST_SECOND,
"duration", total_time, "inpoint", (guint64) 0 * GST_SECOND,
"priority", 0, NULL);
gst_bin_add (GST_BIN (composition), gnl_adder);
gnl_composition_add (GST_BIN (composition), gnl_adder);
GST_ERROR ("Pipeline refcounts: %i", ((GObject *) pipeline)->ref_count);
/* source 1 */
@ -234,7 +235,7 @@ GST_START_TEST (test_simple_adder)
gst_bin_add (GST_BIN (gnlsource1), audiotestsrc1);
g_object_set (gnlsource1, "start", (guint64) 0 * GST_SECOND,
"duration", total_time / 2, "inpoint", (guint64) 0, "priority", 1, NULL);
fail_unless (gst_bin_add (GST_BIN (composition), gnlsource1));
fail_unless (gnl_composition_add (GST_BIN (composition), gnlsource1));
/* gnlsource2 */
gnlsource2 = gst_element_factory_make ("gnlsource", "gnlsource2");
@ -249,7 +250,7 @@ GST_START_TEST (test_simple_adder)
GST_ERROR ("Pipeline refcounts: %i", ((GObject *) pipeline)->ref_count);
fail_unless (gst_bin_add (GST_BIN (composition), gnlsource2));
fail_unless (gnl_composition_add (GST_BIN (composition), gnlsource2));
fail_unless (gst_element_link (composition, fakesink) == TRUE);
GST_DEBUG ("Setting pipeline to PLAYING");

View file

@ -165,7 +165,7 @@ GST_START_TEST (test_simple_operation)
ASSERT_OBJECT_REFCOUNT (source, "source", 1);
ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
gst_bin_add (GST_BIN (comp), source);
gnl_composition_add (GST_BIN (comp), source);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
@ -173,7 +173,7 @@ GST_START_TEST (test_simple_operation)
/* Add operaton */
gst_bin_add (GST_BIN (comp), oper);
gnl_composition_add (GST_BIN (comp), oper);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
@ -182,14 +182,14 @@ GST_START_TEST (test_simple_operation)
/* remove source */
gst_object_ref (source);
gst_bin_remove (GST_BIN (comp), source);
gnl_composition_remove (GST_BIN (comp), source);
check_start_stop_duration (comp, 1 * GST_SECOND, 2 * GST_SECOND,
1 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source, "source", 1);
/* re-add source */
gst_bin_add (GST_BIN (comp), source);
gnl_composition_add (GST_BIN (comp), source);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
gst_object_unref (source);
@ -254,7 +254,7 @@ GST_START_TEST (test_pyramid_operations)
ASSERT_OBJECT_REFCOUNT (oper1, "oper1", 1);
ASSERT_OBJECT_REFCOUNT (oper2, "oper2", 1);
gst_bin_add (GST_BIN (comp), source);
gnl_composition_add (GST_BIN (comp), source);
commit_and_wait (comp, &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);
@ -263,7 +263,7 @@ GST_START_TEST (test_pyramid_operations)
/* Add operation 1 */
gst_bin_add (GST_BIN (comp), oper1);
gnl_composition_add (GST_BIN (comp), oper1);
commit_and_wait (comp, &ret);
check_start_stop_duration (oper1, 4 * GST_SECOND, 6 * GST_SECOND,
2 * GST_SECOND);
@ -273,7 +273,7 @@ GST_START_TEST (test_pyramid_operations)
/* Add operation 2 */
gst_bin_add (GST_BIN (comp), oper2);
gnl_composition_add (GST_BIN (comp), oper2);
commit_and_wait (comp, &ret);
check_start_stop_duration (oper2, 2 * GST_SECOND, 8 * GST_SECOND,
6 * GST_SECOND);
@ -354,25 +354,25 @@ GST_START_TEST (test_pyramid_operations2)
/* Add source 1 */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
/* Add source 2 */
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
/* Add operation */
gst_bin_add (GST_BIN (comp), oper);
gnl_composition_add (GST_BIN (comp), oper);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
/* Add default */
gst_bin_add (GST_BIN (comp), def);
gnl_composition_add (GST_BIN (comp), def);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
@ -450,13 +450,13 @@ GST_START_TEST (test_pyramid_operations_expandable)
ASSERT_OBJECT_REFCOUNT (def, "default", 1);
/* Add source 1 */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
/* Add source 2 */
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source2);
/* Add operation */
gst_bin_add (GST_BIN (comp), oper);
gnl_composition_add (GST_BIN (comp), oper);
/* Add default */
gst_bin_add (GST_BIN (comp), def);
gnl_composition_add (GST_BIN (comp), def);
commit_and_wait (comp, &ret);
check_start_stop_duration (source1, 0, 2 * GST_SECOND, 2 * GST_SECOND);
@ -538,17 +538,17 @@ GST_START_TEST (test_complex_operations)
ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
/* Add source1 */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
check_start_stop_duration (comp, 0, 0, 0);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
/* Add source2 */
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source2);
check_start_stop_duration (comp, 0, 0, 0);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
/* Add operaton */
gst_bin_add (GST_BIN (comp), oper);
gnl_composition_add (GST_BIN (comp), oper);
check_start_stop_duration (comp, 0, 0, 0);
commit_and_wait (comp, &ret);
@ -631,14 +631,14 @@ GST_START_TEST (test_complex_operations_bis)
ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
/* Add source1 */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &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);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
@ -646,7 +646,7 @@ GST_START_TEST (test_complex_operations_bis)
/* Add operaton */
gst_bin_add (GST_BIN (comp), oper);
gnl_composition_add (GST_BIN (comp), oper);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
/* Since it's expandable, it should have changed to full length */

View file

@ -184,7 +184,7 @@ test_simplest_full (void)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
@ -268,8 +268,8 @@ test_one_after_other_full (void)
1 * GST_SECOND);
/* Add sources */
gst_bin_add (GST_BIN (comp), source1);
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &ret);
check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
check_start_stop_duration (source2, 1 * GST_SECOND, 2 * GST_SECOND,
@ -350,8 +350,8 @@ test_one_under_another_full (void)
/* Add two sources */
gst_bin_add (GST_BIN (comp), source1);
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &ret);
check_start_stop_duration (source1, 0, 2 * GST_SECOND, 2 * GST_SECOND);
check_start_stop_duration (source2, 1 * GST_SECOND, 3 * GST_SECOND,
@ -422,13 +422,13 @@ test_one_bin_after_other_full (void)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &ret);
check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
check_start_stop_duration (source2, 1 * GST_SECOND, 2 * GST_SECOND,
@ -532,14 +532,14 @@ GST_START_TEST (test_complex_operations)
ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
/* Add source1 */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &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);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
@ -547,7 +547,7 @@ GST_START_TEST (test_complex_operations)
/* Add operaton */
gst_bin_add (GST_BIN (comp), oper);
gnl_composition_add (GST_BIN (comp), oper);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
@ -652,14 +652,14 @@ GST_START_TEST (test_complex_operations_bis)
ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
/* Add source1 */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &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);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
@ -667,7 +667,7 @@ GST_START_TEST (test_complex_operations_bis)
/* Add operaton */
gst_bin_add (GST_BIN (comp), oper);
gnl_composition_add (GST_BIN (comp), oper);
commit_and_wait (comp, &ret);
check_start_stop_duration (source1, 0, 4 * GST_SECOND, 4 * GST_SECOND);
check_start_stop_duration (source2, 2 * GST_SECOND, 6 * GST_SECOND,

View file

@ -31,7 +31,7 @@ test_simplest_full (void)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
fail_unless (ret);
check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
@ -142,7 +142,7 @@ test_time_duration_full (void)
ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
fail_unless (ret == TRUE);
check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
@ -152,7 +152,7 @@ test_time_duration_full (void)
/* Second source */
ret = FALSE;
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &ret);
fail_unless (ret == TRUE);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
@ -162,7 +162,7 @@ test_time_duration_full (void)
/* Remove first source */
gst_object_ref (source1);
gst_bin_remove (GST_BIN (comp), source1);
gnl_composition_remove (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 1 * GST_SECOND, 2 * GST_SECOND,
1 * GST_SECOND);
@ -171,7 +171,7 @@ test_time_duration_full (void)
/* Re-add first source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
gst_object_unref (source1);
@ -226,14 +226,14 @@ test_one_after_other_full (void)
1 * GST_SECOND);
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &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);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &ret);
fail_unless (ret);
@ -248,7 +248,7 @@ test_one_after_other_full (void)
/* Remove first source */
gst_object_ref (source1);
gst_bin_remove (GST_BIN (comp), source1);
gnl_composition_remove (GST_BIN (comp), source1);
check_start_stop_duration (comp, 1 * GST_SECOND, 2 * GST_SECOND,
1 * GST_SECOND);
@ -256,7 +256,7 @@ test_one_after_other_full (void)
/* Re-add first source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
gst_object_unref (source1);
@ -436,8 +436,8 @@ test_one_under_another_full (void)
/* Add two sources */
gst_bin_add (GST_BIN (comp), source1);
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source2);
check_start_stop_duration (comp, 0, 0 * GST_SECOND, 0 * GST_SECOND);
/* Now commiting changes */
commit_and_wait (comp, &ret);
@ -449,13 +449,13 @@ test_one_under_another_full (void)
/* Remove second source */
gst_object_ref (source1);
gst_bin_remove (GST_BIN (comp), source1);
gnl_composition_remove (GST_BIN (comp), source1);
check_start_stop_duration (comp, 1 * GST_SECOND, 3 * GST_SECOND,
2 * GST_SECOND);
/* Re-add second source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
gst_object_unref (source1);
@ -576,7 +576,7 @@ test_one_bin_after_other_full (void)
/* Add one source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
fail_unless (ret);
check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
@ -586,7 +586,7 @@ test_one_bin_after_other_full (void)
/* Second source */
gst_bin_add (GST_BIN (comp), source2);
gnl_composition_add (GST_BIN (comp), source2);
commit_and_wait (comp, &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);
@ -598,7 +598,7 @@ test_one_bin_after_other_full (void)
/* Remove first source */
gst_object_ref (source1);
gst_bin_remove (GST_BIN (comp), source1);
gnl_composition_remove (GST_BIN (comp), source1);
check_start_stop_duration (comp, 1 * GST_SECOND, 2 * GST_SECOND,
1 * GST_SECOND);
@ -606,7 +606,7 @@ test_one_bin_after_other_full (void)
/* Re-add first source */
gst_bin_add (GST_BIN (comp), source1);
gnl_composition_add (GST_BIN (comp), source1);
commit_and_wait (comp, &ret);
check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
gst_object_unref (source1);