diff options
author | Reynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com> | 2015-03-27 18:32:27 -0300 |
---|---|---|
committer | Reynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com> | 2015-04-03 18:17:35 -0300 |
commit | b24971f2ddf661e0754eae1e97ad82586ef1fdf3 (patch) | |
tree | 93352a6f81eb5250f6df521b9c42688e862b4285 /tests | |
parent | 931fbf5e12c464aee9114980d3dae3d87eaf514c (diff) | |
download | gstreamer-plugins-bad-b24971f2ddf661e0754eae1e97ad82586ef1fdf3.tar.gz |
aggregator: add gap event handling unit test
https://bugzilla.gnome.org/show_bug.cgi?id=746249
Diffstat (limited to 'tests')
-rw-r--r-- | tests/check/libs/aggregator.c | 76 |
1 files changed, 71 insertions, 5 deletions
diff --git a/tests/check/libs/aggregator.c b/tests/check/libs/aggregator.c index 62be4ee93..1932f09cc 100644 --- a/tests/check/libs/aggregator.c +++ b/tests/check/libs/aggregator.c @@ -49,12 +49,15 @@ typedef struct _GstTestAggregatorClass GstTestAggregatorClass; static GType gst_test_aggregator_get_type (void); #define BUFFER_DURATION 100000000 /* 10 frames per second */ +#define TEST_GAP_PTS 0 +#define TEST_GAP_DURATION (5 * GST_SECOND) struct _GstTestAggregator { GstAggregator parent; guint64 timestamp; + gboolean gap_expected; }; struct _GstTestAggregatorClass @@ -85,6 +88,18 @@ gst_test_aggregator_aggregate (GstAggregator * aggregator, gboolean timeout) if (gst_aggregator_pad_is_eos (pad) == FALSE) all_eos = FALSE; + + if (testagg->gap_expected == TRUE) { + buf = gst_aggregator_pad_get_buffer (pad); + fail_unless (buf); + fail_unless (GST_BUFFER_PTS (buf) == TEST_GAP_PTS); + fail_unless (GST_BUFFER_DURATION (buf) == TEST_GAP_DURATION); + fail_unless (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)); + fail_unless (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DROPPABLE)); + gst_buffer_unref (buf); + testagg->gap_expected = FALSE; + } + gst_aggregator_pad_drop_buffer (pad); g_value_reset (&value); @@ -156,6 +171,7 @@ gst_test_aggregator_init (GstTestAggregator * self) GstAggregator *agg = GST_AGGREGATOR (self); gst_segment_init (&agg->segment, GST_FORMAT_BYTES); self->timestamp = 0; + self->gap_expected = FALSE; } static gboolean @@ -221,13 +237,11 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY); -static gpointer -push_buffer (gpointer user_data) +static void +start_flow (ChainData * chain_data) { - GstFlowReturn flow; - GstCaps *caps; - ChainData *chain_data = (ChainData *) user_data; GstSegment segment; + GstCaps *caps; gst_pad_push_event (chain_data->srcpad, gst_event_new_stream_start ("test")); @@ -237,6 +251,15 @@ push_buffer (gpointer user_data) gst_segment_init (&segment, GST_FORMAT_TIME); gst_pad_push_event (chain_data->srcpad, gst_event_new_segment (&segment)); +} + +static gpointer +push_buffer (gpointer user_data) +{ + GstFlowReturn flow; + ChainData *chain_data = (ChainData *) user_data; + + start_flow (chain_data); GST_DEBUG ("Pushing buffer on pad: %s:%s", GST_DEBUG_PAD_NAME (chain_data->sinkpad)); @@ -254,12 +277,27 @@ static gpointer push_event (gpointer user_data) { ChainData *chain_data = (ChainData *) user_data; + GstTestAggregator *aggregator = (GstTestAggregator *) chain_data->aggregator; + GstEventType event_type; + + start_flow (chain_data); GST_INFO_OBJECT (chain_data->srcpad, "Pushing event: %" GST_PTR_FORMAT, chain_data->event); + + event_type = GST_EVENT_TYPE (chain_data->event); + switch (event_type) { + case GST_EVENT_GAP: + aggregator->gap_expected = TRUE; + break; + default: + break; + } + fail_unless (gst_pad_push_event (chain_data->srcpad, chain_data->event) == TRUE); + return NULL; } @@ -451,6 +489,33 @@ GST_START_TEST (test_aggregate_eos) GST_END_TEST; +GST_START_TEST (test_aggregate_gap) +{ + GThread *thread; + + ChainData data = { 0, }; + TestData test = { 0, }; + + _test_data_init (&test, FALSE); + _chain_data_init (&data, test.aggregator); + + data.event = gst_event_new_gap (TEST_GAP_PTS, TEST_GAP_DURATION); + + thread = g_thread_try_new ("gst-check", push_event, &data, NULL); + + g_main_loop_run (test.ml); + g_source_remove (test.timeout_id); + + /* these will return immediately as when the data is popped the threads are + * unlocked and will terminate */ + g_thread_join (thread); + + _chain_data_clear (&data); + _test_data_clear (&test); +} + +GST_END_TEST; + #define NUM_BUFFERS 3 static void handoff (GstElement * fakesink, GstBuffer * buf, GstPad * pad, guint * count) @@ -1099,6 +1164,7 @@ gst_aggregator_suite (void) suite_add_tcase (suite, general); tcase_add_test (general, test_aggregate); tcase_add_test (general, test_aggregate_eos); + tcase_add_test (general, test_aggregate_gap); tcase_add_test (general, test_flushing_seek); tcase_add_test (general, test_infinite_seek); tcase_add_test (general, test_infinite_seek_50_src); |