mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
test: rtpbin_buffer_list: add a test for wrapping sequence numbers
This commit is contained in:
parent
d9d0461aeb
commit
fb46c6bf08
1 changed files with 108 additions and 0 deletions
|
@ -426,6 +426,65 @@ sink_chain_list_permissible_gap (GstPad * pad, GstObject * parent,
|
|||
}
|
||||
|
||||
|
||||
/* After probation succeeds, wrapping seqnum is allowed. */
|
||||
static GstBufferList *
|
||||
create_buffer_list_wrapping_seqnums (void)
|
||||
{
|
||||
GstBufferList *list;
|
||||
GstBuffer *orig_buffer;
|
||||
GstBuffer *buffer;
|
||||
|
||||
/* probation succeeds, but then seqnum wraps around */
|
||||
guint16 seqnums[] = { 65533, 65534, 65535, 0 };
|
||||
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 (seqnums) / sizeof (seqnums[0]); i++) {
|
||||
buffer =
|
||||
create_rtp_buffer_fields (&rtp_header[0], rtp_header_len[0],
|
||||
orig_buffer, payload_offset[0], payload_len[0], seqnums[i], 0);
|
||||
gst_buffer_list_add (list, buffer);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/* All buffers should have been pushed. */
|
||||
static GstFlowReturn
|
||||
sink_chain_list_wrapping_seqnums (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 sequence numbers */
|
||||
buffer = gst_buffer_list_get (list, 0);
|
||||
check_seqnum (buffer, 65533);
|
||||
|
||||
buffer = gst_buffer_list_get (list, 1);
|
||||
check_seqnum (buffer, 65534);
|
||||
|
||||
buffer = gst_buffer_list_get (list, 2);
|
||||
check_seqnum (buffer, 65535);
|
||||
|
||||
buffer = gst_buffer_list_get (list, 3);
|
||||
check_seqnum (buffer, 0);
|
||||
|
||||
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,
|
||||
|
@ -700,6 +759,54 @@ GST_START_TEST (test_bufferlist_recv_permissible_gap)
|
|||
GST_END_TEST;
|
||||
|
||||
|
||||
GST_START_TEST (test_bufferlist_recv_wrapping_seqnums)
|
||||
{
|
||||
GstElement *rtpbin;
|
||||
GstPad *srcpad;
|
||||
GstPad *sinkpad;
|
||||
GstCaps *caps;
|
||||
GstBufferList *list;
|
||||
|
||||
list = create_buffer_list_wrapping_seqnums ();
|
||||
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_wrapping_seqnums));
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -715,6 +822,7 @@ bufferlist_suite (void)
|
|||
tcase_add_test (tc_chain, test_bufferlist_recv);
|
||||
tcase_add_test (tc_chain, test_bufferlist_recv_probation_failed);
|
||||
tcase_add_test (tc_chain, test_bufferlist_recv_permissible_gap);
|
||||
tcase_add_test (tc_chain, test_bufferlist_recv_wrapping_seqnums);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue