summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2011-02-08 09:12:35 +0100
committerEdward Hervey <bilboed@bilboed.com>2011-02-09 11:02:18 +0100
commit158a35a9e0e9b79b8d4399b42f501676f5d1a1e4 (patch)
tree38719e13e769a065d177fadeb3f04f0d4232f038
parent2422274c652ff2947af895872fe6f7cfad8fc424 (diff)
tests: refactor 'complex' test
-rw-r--r--tests/check/gnl/common.h15
-rw-r--r--tests/check/gnl/complex.c615
2 files changed, 133 insertions, 497 deletions
diff --git a/tests/check/gnl/common.h b/tests/check/gnl/common.h
index 987c9eb..6ee967d 100644
--- a/tests/check/gnl/common.h
+++ b/tests/check/gnl/common.h
@@ -298,6 +298,21 @@ segment_new (gdouble rate, GstFormat format, gint64 start, gint64 stop, gint64 p
segment->stop = stop;
segment->position = position;
return segment;
}
+static GList *
+copy_segment_list (GList *list)
+{
+ GList *res = NULL;
+
+ while (list) {
+ Segment *pdata = (Segment*) list->data;
+
+ res = g_list_append(res, segment_new(pdata->rate, pdata->format, pdata->start, pdata->stop, pdata->position));
+
+ list = list->next;
+ }
+
+ return res;
+}
diff --git a/tests/check/gnl/complex.c b/tests/check/gnl/complex.c
index c9c4ef4..f750f2b 100644
--- a/tests/check/gnl/complex.c
+++ b/tests/check/gnl/complex.c
@@ -1,112 +1,49 @@
#include "common.h"
-GST_START_TEST (test_one_space_another)
+static void
+fill_pipeline_and_check (GstElement * comp, GList * segments)
{
- GstElement *pipeline;
- GstElement *comp, *sink, *source1, *source2;
+ GstElement *pipeline, *sink;
CollectStructure *collect;
GstBus *bus;
GstMessage *message;
gboolean carry_on = TRUE;
- guint64 start, stop;
- gint64 duration;
GstPad *sinkpad;
+ GList *listcopy = copy_segment_list (segments);
pipeline = gst_pipeline_new ("test_pipeline");
- comp =
- gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
- fail_if (comp == NULL);
-
- /*
- Source 1
- Start : 0s
- Duration : 1s
- Priority : 1
- */
- source1 = videotest_gnl_src ("source1", 0, 1 * GST_SECOND, 2, 1);
- fail_if (source1 == NULL);
- check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
-
- /*
- Source 2
- Start : 2s
- Duration : 1s
- Priority : 1
- */
- source2 = videotest_gnl_src ("source2", 2 * GST_SECOND, 1 * GST_SECOND, 3, 1);
- fail_if (source2 == NULL);
- check_start_stop_duration (source2, 2 * GST_SECOND, 3 * 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);
- check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
-
- ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
-
- /* Remove first source */
-
- gst_object_ref (source1);
- gst_bin_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);
- check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
- gst_object_unref (source1);
-
- ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
-
sink = gst_element_factory_make_or_warn ("fakesink", "sink");
fail_if (sink == NULL);
gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
/* Shared data */
collect = g_new0 (CollectStructure, 1);
collect->comp = comp;
collect->sink = sink;
/* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND));
+ collect->expected_segments = segments;
g_signal_connect (G_OBJECT (comp), "pad-added",
G_CALLBACK (composition_pad_added_cb), collect);
sinkpad = gst_element_get_pad (sink, "sink");
gst_pad_add_event_probe (sinkpad, G_CALLBACK (sinkpad_event_probe), collect);
gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (sinkpad_buffer_probe),
collect);
bus = gst_element_get_bus (GST_ELEMENT (pipeline));
GST_DEBUG ("Setting pipeline to PLAYING");
- ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
GST_DEBUG ("Let's poll the bus");
-
while (carry_on) {
message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
if (message) {
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_EOS:
/* we should check if we really finished here */
@@ -126,30 +63,24 @@ GST_START_TEST (test_one_space_another)
break;
}
gst_mini_object_unref (GST_MINI_OBJECT (message));
}
}
- GST_DEBUG ("Setting pipeline to NULL");
+ GST_DEBUG ("Setting pipeline to READY");
fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
fail_if (collect->expected_segments != NULL);
GST_DEBUG ("Resetted pipeline to READY");
- /* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND));
+ collect->expected_segments = listcopy;
collect->gotsegment = FALSE;
-
GST_DEBUG ("Setting pipeline to PLAYING again");
fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
carry_on = TRUE;
@@ -193,27 +124,98 @@ GST_START_TEST (test_one_space_another)
ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
gst_object_unref (bus);
g_free (collect);
}
+GST_START_TEST (test_one_space_another)
+{
+ GstElement *comp, *source1, *source2;
+ guint64 start, stop;
+ gint64 duration;
+ GList *segments = NULL;
+
+ comp =
+ gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
+ fail_if (comp == NULL);
+
+ /* TOPOLOGY
+ *
+ * 0 1 2 3 4 5 | Priority
+ * ----------------------------------------------------------------------------
+ * [-source1--] [-source2--] | 1
+ * */
+
+ /*
+ Source 1
+ Start : 0s
+ Duration : 1s
+ Priority : 1
+ */
+ source1 = videotest_gnl_src ("source1", 0, 1 * GST_SECOND, 2, 1);
+ fail_if (source1 == NULL);
+ check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
+
+ /*
+ Source 2
+ Start : 2s
+ Duration : 1s
+ Priority : 1
+ */
+ source2 = videotest_gnl_src ("source2", 2 * GST_SECOND, 1 * GST_SECOND, 3, 1);
+ fail_if (source2 == NULL);
+ check_start_stop_duration (source2, 2 * GST_SECOND, 3 * 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);
+ check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
+ ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
+
+ /* Remove first source */
+
+ gst_object_ref (source1);
+ gst_bin_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);
+ check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
+ gst_object_unref (source1);
+ ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
+
+ /* Expected segments */
+ segments = g_list_append (segments,
+ segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
+ segments = g_list_append (segments,
+ segment_new (1.0, GST_FORMAT_TIME,
+ 2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND));
+
+ fill_pipeline_and_check (comp, segments);
+}
+
GST_END_TEST;
GST_START_TEST (test_one_default_another)
{
- GstElement *pipeline;
- GstElement *comp, *sink, *source1, *source2, *source3, *defaultsrc;
- CollectStructure *collect;
- GstBus *bus;
- GstMessage *message;
+ GstElement *comp, *source1, *source2, *source3, *defaultsrc;
gboolean carry_on = TRUE;
guint64 start, stop;
gint64 duration;
- GstPad *sinkpad;
+ GList *segments = NULL;
- pipeline = gst_pipeline_new ("test_pipeline");
comp =
gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
fail_if (comp == NULL);
/* TOPOLOGY
*
@@ -299,178 +301,52 @@ GST_START_TEST (test_one_default_another)
gst_bin_add (GST_BIN (comp), source3);
check_start_stop_duration (comp, 0, 5 * GST_SECOND, 5 * GST_SECOND);
check_start_stop_duration (defaultsrc, 0, 5 * GST_SECOND, 5 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source3, "source3", 1);
-
- sink = gst_element_factory_make_or_warn ("fakesink", "sink");
- fail_if (sink == NULL);
-
- gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
-
- /* Shared data */
- collect = g_new0 (CollectStructure, 1);
- collect->comp = comp;
- collect->sink = sink;
-
- /* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 3 * GST_SECOND, 4 * GST_SECOND, 3 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 4 * GST_SECOND, 5 * GST_SECOND, 4 * GST_SECOND));
-
- g_signal_connect (G_OBJECT (comp), "pad-added",
- G_CALLBACK (composition_pad_added_cb), collect);
-
- sinkpad = gst_element_get_pad (sink, "sink");
- gst_pad_add_event_probe (sinkpad, G_CALLBACK (sinkpad_event_probe), collect);
- gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (sinkpad_buffer_probe),
- collect);
-
- bus = gst_element_get_bus (GST_ELEMENT (pipeline));
-
- GST_DEBUG ("Setting pipeline to PLAYING");
- ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- GST_WARNING ("Got an EOS");
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_WARNING ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- }
- }
-
- GST_DEBUG ("Setting pipeline to NULL");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
-
- fail_if (collect->expected_segments != NULL);
-
- GST_DEBUG ("Resetted pipeline to READY");
-
/* Expected segments */
- /* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
3 * GST_SECOND, 4 * GST_SECOND, 3 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
4 * GST_SECOND, 5 * GST_SECOND, 4 * GST_SECOND));
- collect->gotsegment = FALSE;
-
-
- GST_DEBUG ("Setting pipeline to PLAYING again");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- carry_on = TRUE;
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_ERROR ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- } else {
- GST_DEBUG ("bus_poll responded, but there wasn't any message...");
- }
- }
-
- fail_if (collect->expected_segments != NULL);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE);
-
- gst_object_unref (GST_OBJECT (sinkpad));
- ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "main pipeline", 1, 2);
- gst_object_unref (pipeline);
- ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
- gst_object_unref (bus);
- g_free (collect);
+ fill_pipeline_and_check (comp, segments);
}
GST_END_TEST;
GST_START_TEST (test_one_expandable_another)
{
- GstElement *pipeline;
- GstElement *comp, *sink, *source1, *source2, *source3, *defaultsrc;
- CollectStructure *collect;
- GstBus *bus;
- GstMessage *message;
- gboolean carry_on = TRUE;
+ GstElement *comp, *source1, *source2, *source3, *defaultsrc;
guint64 start, stop;
gint64 duration;
- GstPad *sinkpad;
+ GList *segments = NULL;
- pipeline = gst_pipeline_new ("test_pipeline");
comp =
gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
fail_if (comp == NULL);
+ /* TOPOLOGY
+ *
+ * 0 1 2 3 4 5 | Priority
+ * ----------------------------------------------------------------------------
+ * [ source1 ] [ source2 ][ source3 ] | 1
+ * [--------------------- defaultsrc ------------------------] | 1000 EXPANDABLE
+ * */
+
/*
defaultsrc source
Start : 0s
Duration : 5s
Priority : 1000
*/
@@ -543,157 +419,29 @@ GST_START_TEST (test_one_expandable_another)
gst_bin_add (GST_BIN (comp), source3);
check_start_stop_duration (comp, 0, 5 * GST_SECOND, 5 * GST_SECOND);
check_start_stop_duration (defaultsrc, 0, 5 * GST_SECOND, 5 * GST_SECOND);
ASSERT_OBJECT_REFCOUNT (source3, "source3", 1);
-
- sink = gst_element_factory_make_or_warn ("fakesink", "sink");
- fail_if (sink == NULL);
-
- gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
-
- /* Shared data */
- collect = g_new0 (CollectStructure, 1);
- collect->comp = comp;
- collect->sink = sink;
-
- /* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 3 * GST_SECOND, 4 * GST_SECOND, 3 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 4 * GST_SECOND, 5 * GST_SECOND, 4 * GST_SECOND));
-
- g_signal_connect (G_OBJECT (comp), "pad-added",
- G_CALLBACK (composition_pad_added_cb), collect);
-
- sinkpad = gst_element_get_pad (sink, "sink");
- gst_pad_add_event_probe (sinkpad, G_CALLBACK (sinkpad_event_probe), collect);
- gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (sinkpad_buffer_probe),
- collect);
-
- bus = gst_element_get_bus (GST_ELEMENT (pipeline));
-
- GST_DEBUG ("Setting pipeline to PLAYING");
- ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- GST_WARNING ("Got an EOS");
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_WARNING ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- }
- }
-
- GST_DEBUG ("Setting pipeline to NULL");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
-
- fail_if (collect->expected_segments != NULL);
-
- GST_DEBUG ("Resetted pipeline to READY");
-
/* Expected segments */
- /* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
3 * GST_SECOND, 4 * GST_SECOND, 3 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
4 * GST_SECOND, 5 * GST_SECOND, 4 * GST_SECOND));
- collect->gotsegment = FALSE;
-
-
- GST_DEBUG ("Setting pipeline to PLAYING again");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- carry_on = TRUE;
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_ERROR ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- } else {
- GST_DEBUG ("bus_poll responded, but there wasn't any message...");
- }
- }
-
- fail_if (collect->expected_segments != NULL);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE);
-
- gst_object_unref (GST_OBJECT (sinkpad));
- ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "main pipeline", 1, 2);
- gst_object_unref (pipeline);
- ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
- gst_object_unref (bus);
- g_free (collect);
+ fill_pipeline_and_check (comp, segments);
}
GST_END_TEST;
@@ -911,39 +659,29 @@ GST_START_TEST (test_renegotiation)
GST_END_TEST;
GST_START_TEST (test_one_bin_space_another)
{
- GstElement *pipeline;
- GstElement *comp, *sink, *source1, *source2;
- CollectStructure *collect;
- GstBus *bus;
- GstMessage *message;
- gboolean carry_on = TRUE;
+ GstElement *comp, *source1, *source2;
guint64 start, stop;
gint64 duration;
- GstPad *sinkpad;
+ GList *segments = NULL;
- pipeline = gst_pipeline_new ("test_pipeline");
comp =
gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
fail_if (comp == NULL);
/*
Source 1
Start : 0s
Duration : 1s
Priority : 1
*/
source1 = videotest_in_bin_gnl_src ("source1", 0, 1 * GST_SECOND, 3, 1);
- if (source1 == NULL) {
- gst_object_unref (pipeline);
- gst_object_unref (comp);
- return;
- }
+ fail_if (source1 == NULL);
check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
/*
Source 2
Start : 2s
Duration : 1s
@@ -976,95 +714,32 @@ GST_START_TEST (test_one_bin_space_another)
/* Re-add second source */
gst_bin_add (GST_BIN (comp), source1);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
gst_object_unref (source1);
- sink = gst_element_factory_make_or_warn ("fakesink", "sink");
- fail_if (sink == NULL);
-
- gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
-
- /* Shared data */
- collect = g_new0 (CollectStructure, 1);
- collect->comp = comp;
- collect->sink = sink;
-
/* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND));
- g_signal_connect (G_OBJECT (comp), "pad-added",
- G_CALLBACK (composition_pad_added_cb), collect);
-
- sinkpad = gst_element_get_pad (sink, "sink");
- gst_pad_add_event_probe (sinkpad, G_CALLBACK (sinkpad_event_probe), collect);
- gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (sinkpad_buffer_probe),
- collect);
-
- bus = gst_element_get_bus (GST_ELEMENT (pipeline));
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* check if the segment is the correct one (0s-4s) */
- carry_on = FALSE;
- break;
- case GST_MESSAGE_ERROR:
- fail_if (TRUE);
- default:
- break;
- }
- gst_message_unref (message);
- }
- }
-
- fail_if (collect->expected_segments != NULL);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE);
-
- gst_object_unref (GST_OBJECT (sinkpad));
- gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "main pipeline", 1, 2);
- gst_object_unref (pipeline);
- ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
- gst_object_unref (bus);
-
- g_free (collect);
+ fill_pipeline_and_check (comp, segments);
}
GST_END_TEST;
GST_START_TEST (test_one_above_another)
{
- GstElement *pipeline;
- GstElement *comp, *sink, *source1, *source2;
- CollectStructure *collect;
- GstBus *bus;
- GstMessage *message;
- gboolean carry_on = TRUE;
+ GstElement *comp, *source1, *source2;
guint64 start, stop;
gint64 duration;
- GstPad *sinkpad;
+ GList *segments = NULL;
- pipeline = gst_pipeline_new ("test_pipeline");
comp =
gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
fail_if (comp == NULL);
/*
Source 1
@@ -1107,75 +782,21 @@ GST_START_TEST (test_one_above_another)
/* Re-add second source */
gst_bin_add (GST_BIN (comp), source1);
check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
gst_object_unref (source1);
- sink = gst_element_factory_make_or_warn ("fakesink", "sink");
- fail_if (sink == NULL);
-
- gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
-
- /* Shared data */
- collect = g_new0 (CollectStructure, 1);
- collect->comp = comp;
- collect->sink = sink;
-
/* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
1 * GST_SECOND, 3 * GST_SECOND, 1 * GST_SECOND));
- g_signal_connect (G_OBJECT (comp), "pad-added",
- G_CALLBACK (composition_pad_added_cb), collect);
-
- sinkpad = gst_element_get_pad (sink, "sink");
- gst_pad_add_event_probe (sinkpad, G_CALLBACK (sinkpad_event_probe), collect);
- gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (sinkpad_buffer_probe),
- collect);
-
- bus = gst_element_get_bus (GST_ELEMENT (pipeline));
-
- gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* check if the segment is the correct one (0s-4s) */
- carry_on = FALSE;
- break;
- case GST_MESSAGE_ERROR:
- fail_if (TRUE);
- default:
- break;
- }
- gst_message_unref (message);
- }
- }
-
- fail_if (collect->expected_segments != NULL);
-
- gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
-
- gst_object_unref (GST_OBJECT (sinkpad));
- ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "main pipeline", 1, 2);
- gst_object_unref (pipeline);
- ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
- gst_object_unref (bus);
-
- g_free (collect);
+ fill_pipeline_and_check (comp, segments);
}
GST_END_TEST;
Suite *
gnonlin_suite (void)