summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-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
@@ -301,3 +301,18 @@ segment_new (gdouble rate, GstFormat format, gint64 start, gint64 stop, gint64 p
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,74 +1,17 @@
#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);
@@ -80,11 +23,7 @@ GST_START_TEST (test_one_space_another)
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);
@@ -97,13 +36,11 @@ GST_START_TEST (test_one_space_another)
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) {
@@ -129,7 +66,7 @@ GST_START_TEST (test_one_space_another)
}
}
- 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);
@@ -138,15 +75,9 @@ GST_START_TEST (test_one_space_another)
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),
@@ -196,21 +127,92 @@ GST_START_TEST (test_one_space_another)
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);
@@ -302,172 +304,46 @@ GST_START_TEST (test_one_default_another)
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
@@ -546,151 +422,23 @@ GST_START_TEST (test_one_expandable_another)
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;
@@ -914,17 +662,11 @@ 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);
@@ -936,11 +678,7 @@ GST_START_TEST (test_one_bin_space_another)
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);
/*
@@ -979,89 +717,26 @@ GST_START_TEST (test_one_bin_space_another)
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);
@@ -1110,69 +785,15 @@ GST_START_TEST (test_one_above_another)
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;