audiomixer: Add test for discont going backwards

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1180>
This commit is contained in:
Olivier Crête 2021-05-26 22:50:22 -04:00
parent fd73fd05ca
commit 78e7612eb0

View file

@ -1452,6 +1452,83 @@ GST_START_TEST (test_sync_discont)
GST_END_TEST;
static void
send_buffers_sync_discont_backwards (GstPad * pad1, GstPad * pad2)
{
GstBuffer *buffer;
GstFlowReturn ret;
buffer = new_buffer (2300, 1, 1 * GST_SECOND, 1.25 * GST_SECOND, 0);
ret = gst_pad_chain (pad1, buffer);
ck_assert_int_eq (ret, GST_FLOW_OK);
buffer = new_buffer (2000, 1, 2 * GST_SECOND, 1 * GST_SECOND,
GST_BUFFER_FLAG_DISCONT);
ret = gst_pad_chain (pad1, buffer);
ck_assert_int_eq (ret, GST_FLOW_OK);
gst_pad_send_event (pad1, gst_event_new_eos ());
buffer = new_buffer (2000, 1, 2 * GST_SECOND, 1 * GST_SECOND, 0);
ret = gst_pad_chain (pad2, buffer);
ck_assert_int_eq (ret, GST_FLOW_OK);
gst_pad_send_event (pad2, gst_event_new_eos ());
}
static void
check_buffers_sync_discont_backwards (GList * received_buffers)
{
GstBuffer *buffer;
GList *l;
gint i;
GstMapInfo map;
/* Should have 6 * 0.5s buffers */
fail_unless_equals_int (g_list_length (received_buffers), 6);
for (i = 0, l = received_buffers; l; l = l->next, i++) {
buffer = l->data;
gst_buffer_map (buffer, &map, GST_MAP_READ);
if (i == 0 && GST_BUFFER_TIMESTAMP (buffer) == 0) {
fail_unless (map.data[0] == 0);
fail_unless (map.data[map.size - 1] == 0);
} else if (i == 1 && GST_BUFFER_TIMESTAMP (buffer) == 500 * GST_MSECOND) {
fail_unless (map.data[0] == 0);
fail_unless (map.data[map.size - 1] == 0);
} else if (i == 2 && GST_BUFFER_TIMESTAMP (buffer) == 1000 * GST_MSECOND) {
fail_unless (map.data[0] == 1);
fail_unless (map.data[map.size - 1] == 1);
} else if (i == 3 && GST_BUFFER_TIMESTAMP (buffer) == 1500 * GST_MSECOND) {
fail_unless (map.data[0] == 1);
fail_unless (map.data[map.size - 1] == 1);
} else if (i == 4 && GST_BUFFER_TIMESTAMP (buffer) == 2000 * GST_MSECOND) {
fail_unless (map.data[0] == 2);
fail_unless (map.data[map.size - 1] == 2);
} else if (i == 5 && GST_BUFFER_TIMESTAMP (buffer) == 2500 * GST_MSECOND) {
fail_unless (map.data[0] == 2);
fail_unless (map.data[map.size - 1] == 2);
} else {
g_assert_not_reached ();
}
gst_buffer_unmap (buffer, &map);
}
}
GST_START_TEST (test_sync_discont_backwards)
{
run_sync_test (send_buffers_sync_discont_backwards,
check_buffers_sync_discont_backwards);
}
GST_END_TEST;
static void
send_buffers_sync_unaligned (GstPad * pad1, GstPad * pad2)
{
@ -1969,6 +2046,7 @@ audiomixer_suite (void)
tcase_add_test (tc_chain, test_flush_start_flush_stop);
tcase_add_test (tc_chain, test_sync);
tcase_add_test (tc_chain, test_sync_discont);
tcase_add_test (tc_chain, test_sync_discont_backwards);
tcase_add_test (tc_chain, test_sync_unaligned);
tcase_add_test (tc_chain, test_segment_base_handling);
tcase_add_test (tc_chain, test_sinkpad_property_controller);