test: rtpbin_buffer_list: add a test for different timestamps in buffer list

Buffers with different timestamps (e.g. packets belonging to different
frames) can arrive together in the same buffer list,

Add a test to cover this case.
This commit is contained in:
Antonio Ospite 2019-03-11 15:09:27 +01:00 committed by Olivier Crête
parent b158be0d98
commit 6a5f38a325

View file

@ -711,6 +711,68 @@ sink_chain_list_reordered_packets (GstPad * pad, GstObject * parent,
}
/* Frames with different timestamps in the same buffer list. */
static GstBufferList *
create_buffer_list_different_frames (void)
{
GstBufferList *list;
GstBuffer *orig_buffer;
GstBuffer *buffer;
guint32 timestamps[] = { 0, 0, 1000, 1000 };
guint i;
orig_buffer = create_original_buffer ();
fail_if (orig_buffer == NULL);
list = gst_buffer_list_new ();
fail_if (list == NULL);
for (i = 0; i < sizeof (timestamps) / sizeof (timestamps[0]); i++) {
buffer =
create_rtp_buffer_fields (&rtp_header[0], rtp_header_len[0],
orig_buffer, payload_offset[0], payload_len[0], i, timestamps[i]);
gst_buffer_list_add (list, buffer);
}
return list;
}
/* All buffers should have been pushed, regardless of the timestamp. */
static GstFlowReturn
sink_chain_list_different_frames (GstPad * pad, GstObject * parent,
GstBufferList * list)
{
GstBuffer *buffer;
chain_list_func_called = TRUE;
fail_unless (GST_IS_BUFFER_LIST (list));
fail_unless (gst_buffer_list_length (list) == 4);
/* Verify seqnums and timestamps. */
buffer = gst_buffer_list_get (list, 0);
check_seqnum (buffer, 0);
check_timestamp (buffer, 0);
buffer = gst_buffer_list_get (list, 1);
check_seqnum (buffer, 1);
check_timestamp (buffer, 0);
buffer = gst_buffer_list_get (list, 2);
check_seqnum (buffer, 2);
check_timestamp (buffer, 1000);
buffer = gst_buffer_list_get (list, 3);
check_seqnum (buffer, 3);
check_timestamp (buffer, 1000);
gst_buffer_list_unref (list);
return GST_FLOW_OK;
}
/* Get the stats of the **first** source of the given type (get_sender) */
static void
get_source_stats (GstElement * rtpsession,
@ -1176,6 +1238,53 @@ GST_START_TEST (test_bufferlist_recv_reordered_packets)
GST_END_TEST;
GST_START_TEST (test_bufferlist_recv_different_frames)
{
GstElement *rtpbin;
GstPad *srcpad;
GstPad *sinkpad;
GstCaps *caps;
GstBufferList *list;
list = create_buffer_list_different_frames ();
fail_unless (list != NULL);
rtpbin = gst_check_setup_element ("rtpsession");
srcpad =
gst_check_setup_src_pad_by_name (rtpbin, &srctemplate, "recv_rtp_sink");
fail_if (srcpad == NULL);
sinkpad =
gst_check_setup_sink_pad_by_name (rtpbin, &sinktemplate, "recv_rtp_src");
fail_if (sinkpad == NULL);
gst_pad_set_chain_list_function (sinkpad,
GST_DEBUG_FUNCPTR (sink_chain_list_different_frames));
gst_pad_set_active (srcpad, TRUE);
gst_pad_set_active (sinkpad, TRUE);
caps = gst_caps_from_string (TEST_CAPS);
gst_check_setup_events (srcpad, rtpbin, caps, GST_FORMAT_TIME);
gst_caps_unref (caps);
gst_element_set_state (rtpbin, GST_STATE_PLAYING);
chain_list_func_called = FALSE;
fail_unless (gst_pad_push_list (srcpad, list) == GST_FLOW_OK);
fail_if (chain_list_func_called == FALSE);
gst_pad_set_active (sinkpad, FALSE);
gst_pad_set_active (srcpad, FALSE);
gst_check_teardown_pad_by_name (rtpbin, "recv_rtp_src");
gst_check_teardown_pad_by_name (rtpbin, "recv_rtp_sink");
gst_check_teardown_element (rtpbin);
}
GST_END_TEST;
static Suite *
bufferlist_suite (void)
@ -1196,6 +1305,7 @@ bufferlist_suite (void)
tcase_add_test (tc_chain, test_bufferlist_recv_large_jump_discarded);
tcase_add_test (tc_chain, test_bufferlist_recv_large_jump_recovery);
tcase_add_test (tc_chain, test_bufferlist_recv_reordered_packets);
tcase_add_test (tc_chain, test_bufferlist_recv_different_frames);
return s;
}