mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
aggregator: add gap event handling unit test
https://bugzilla.gnome.org/show_bug.cgi?id=746249
This commit is contained in:
parent
c955254758
commit
1bd000fb2b
1 changed files with 71 additions and 5 deletions
|
@ -49,12 +49,15 @@ typedef struct _GstTestAggregatorClass GstTestAggregatorClass;
|
||||||
static GType gst_test_aggregator_get_type (void);
|
static GType gst_test_aggregator_get_type (void);
|
||||||
|
|
||||||
#define BUFFER_DURATION 100000000 /* 10 frames per second */
|
#define BUFFER_DURATION 100000000 /* 10 frames per second */
|
||||||
|
#define TEST_GAP_PTS 0
|
||||||
|
#define TEST_GAP_DURATION (5 * GST_SECOND)
|
||||||
|
|
||||||
struct _GstTestAggregator
|
struct _GstTestAggregator
|
||||||
{
|
{
|
||||||
GstAggregator parent;
|
GstAggregator parent;
|
||||||
|
|
||||||
guint64 timestamp;
|
guint64 timestamp;
|
||||||
|
gboolean gap_expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstTestAggregatorClass
|
struct _GstTestAggregatorClass
|
||||||
|
@ -85,6 +88,18 @@ gst_test_aggregator_aggregate (GstAggregator * aggregator, gboolean timeout)
|
||||||
|
|
||||||
if (gst_aggregator_pad_is_eos (pad) == FALSE)
|
if (gst_aggregator_pad_is_eos (pad) == FALSE)
|
||||||
all_eos = 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);
|
gst_aggregator_pad_drop_buffer (pad);
|
||||||
|
|
||||||
g_value_reset (&value);
|
g_value_reset (&value);
|
||||||
|
@ -156,6 +171,7 @@ gst_test_aggregator_init (GstTestAggregator * self)
|
||||||
GstAggregator *agg = GST_AGGREGATOR (self);
|
GstAggregator *agg = GST_AGGREGATOR (self);
|
||||||
gst_segment_init (&agg->segment, GST_FORMAT_BYTES);
|
gst_segment_init (&agg->segment, GST_FORMAT_BYTES);
|
||||||
self->timestamp = 0;
|
self->timestamp = 0;
|
||||||
|
self->gap_expected = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -221,13 +237,11 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS_ANY);
|
GST_STATIC_CAPS_ANY);
|
||||||
|
|
||||||
static gpointer
|
static void
|
||||||
push_buffer (gpointer user_data)
|
start_flow (ChainData * chain_data)
|
||||||
{
|
{
|
||||||
GstFlowReturn flow;
|
|
||||||
GstCaps *caps;
|
|
||||||
ChainData *chain_data = (ChainData *) user_data;
|
|
||||||
GstSegment segment;
|
GstSegment segment;
|
||||||
|
GstCaps *caps;
|
||||||
|
|
||||||
gst_pad_push_event (chain_data->srcpad, gst_event_new_stream_start ("test"));
|
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_segment_init (&segment, GST_FORMAT_TIME);
|
||||||
gst_pad_push_event (chain_data->srcpad, gst_event_new_segment (&segment));
|
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 ("Pushing buffer on pad: %s:%s",
|
||||||
GST_DEBUG_PAD_NAME (chain_data->sinkpad));
|
GST_DEBUG_PAD_NAME (chain_data->sinkpad));
|
||||||
|
@ -254,12 +277,27 @@ static gpointer
|
||||||
push_event (gpointer user_data)
|
push_event (gpointer user_data)
|
||||||
{
|
{
|
||||||
ChainData *chain_data = (ChainData *) 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_INFO_OBJECT (chain_data->srcpad, "Pushing event: %"
|
||||||
GST_PTR_FORMAT, chain_data->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,
|
fail_unless (gst_pad_push_event (chain_data->srcpad,
|
||||||
chain_data->event) == TRUE);
|
chain_data->event) == TRUE);
|
||||||
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,6 +489,33 @@ GST_START_TEST (test_aggregate_eos)
|
||||||
|
|
||||||
GST_END_TEST;
|
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
|
#define NUM_BUFFERS 3
|
||||||
static void
|
static void
|
||||||
handoff (GstElement * fakesink, GstBuffer * buf, GstPad * pad, guint * count)
|
handoff (GstElement * fakesink, GstBuffer * buf, GstPad * pad, guint * count)
|
||||||
|
@ -1099,6 +1164,7 @@ gst_aggregator_suite (void)
|
||||||
suite_add_tcase (suite, general);
|
suite_add_tcase (suite, general);
|
||||||
tcase_add_test (general, test_aggregate);
|
tcase_add_test (general, test_aggregate);
|
||||||
tcase_add_test (general, test_aggregate_eos);
|
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_flushing_seek);
|
||||||
tcase_add_test (general, test_infinite_seek);
|
tcase_add_test (general, test_infinite_seek);
|
||||||
tcase_add_test (general, test_infinite_seek_50_src);
|
tcase_add_test (general, test_infinite_seek_50_src);
|
||||||
|
|
Loading…
Reference in a new issue