mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
test: rtpbin_buffer_list: add a test for lange jump in seqnums with recovery
This commit is contained in:
parent
ae5d4b8cf0
commit
1d337b704e
1 changed files with 124 additions and 0 deletions
|
@ -556,6 +556,81 @@ sink_chain_list_large_jump_discarded (GstPad * pad, GstObject * parent,
|
|||
}
|
||||
|
||||
|
||||
/* Large jump, with recovery. */
|
||||
static GstBufferList *
|
||||
create_buffer_list_large_jump_recovery (void)
|
||||
{
|
||||
GstBufferList *list;
|
||||
GstBuffer *orig_buffer;
|
||||
GstBuffer *buffer;
|
||||
|
||||
/*
|
||||
* Probation succeeds, but then a large jump happens.
|
||||
* A consecutive next packet makes the session manager recover: it assumes
|
||||
* that the other side restarted without telling.
|
||||
*/
|
||||
guint16 seqnums[] = { 1, 2, 3, 4, 50000, 50001 };
|
||||
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++) {
|
||||
/*
|
||||
* Make the timestamps proportional to seqnums, to make it easier to predict
|
||||
* the packet rate.
|
||||
*/
|
||||
guint32 timestamp = seqnums[i] * 100;
|
||||
|
||||
buffer =
|
||||
create_rtp_buffer_fields (&rtp_header[0], rtp_header_len[0],
|
||||
orig_buffer, payload_offset[0], payload_len[0], seqnums[i], timestamp);
|
||||
gst_buffer_list_add (list, buffer);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/* All buffers should have been pushed. */
|
||||
static GstFlowReturn
|
||||
sink_chain_list_large_jump_recovery (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) == 6);
|
||||
|
||||
/* Verify sequence numbers */
|
||||
buffer = gst_buffer_list_get (list, 0);
|
||||
check_seqnum (buffer, 1);
|
||||
|
||||
buffer = gst_buffer_list_get (list, 1);
|
||||
check_seqnum (buffer, 2);
|
||||
|
||||
buffer = gst_buffer_list_get (list, 2);
|
||||
check_seqnum (buffer, 3);
|
||||
|
||||
buffer = gst_buffer_list_get (list, 3);
|
||||
check_seqnum (buffer, 4);
|
||||
|
||||
buffer = gst_buffer_list_get (list, 4);
|
||||
check_seqnum (buffer, 50000);
|
||||
|
||||
buffer = gst_buffer_list_get (list, 5);
|
||||
check_seqnum (buffer, 50001);
|
||||
|
||||
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,
|
||||
|
@ -926,6 +1001,54 @@ GST_START_TEST (test_bufferlist_recv_large_jump_discarded)
|
|||
GST_END_TEST;
|
||||
|
||||
|
||||
GST_START_TEST (test_bufferlist_recv_large_jump_recovery)
|
||||
{
|
||||
GstElement *rtpbin;
|
||||
GstPad *srcpad;
|
||||
GstPad *sinkpad;
|
||||
GstCaps *caps;
|
||||
GstBufferList *list;
|
||||
|
||||
list = create_buffer_list_large_jump_recovery ();
|
||||
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_large_jump_recovery));
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -943,6 +1066,7 @@ bufferlist_suite (void)
|
|||
tcase_add_test (tc_chain, test_bufferlist_recv_permissible_gap);
|
||||
tcase_add_test (tc_chain, test_bufferlist_recv_wrapping_seqnums);
|
||||
tcase_add_test (tc_chain, test_bufferlist_recv_large_jump_discarded);
|
||||
tcase_add_test (tc_chain, test_bufferlist_recv_large_jump_recovery);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue