check: fix jitterbuffer check

Make sure we set a base_time on the element.
Fix the timeout to at least twice the jitterbuffer latency.
Enable previously failing tests.
Remove impossible checks.
This commit is contained in:
Wim Taymans 2009-11-28 12:25:06 +01:00 committed by Wim Taymans
parent 2c694abd8e
commit 5c8527bb20

View file

@ -127,6 +127,23 @@ setup_jitterbuffer (gint num_buffers)
return jitterbuffer; return jitterbuffer;
} }
static GstStateChangeReturn
start_jitterbuffer (GstElement * jitterbuffer)
{
GstStateChangeReturn ret;
GstClockTime now;
GstClock *clock;
clock = gst_element_get_clock (jitterbuffer);
now = gst_clock_get_time (clock);
gst_object_unref (clock);
gst_element_set_base_time (jitterbuffer, now);
ret = gst_element_set_state (jitterbuffer, GST_STATE_PLAYING);
return ret;
}
static void static void
cleanup_jitterbuffer (GstElement * jitterbuffer) cleanup_jitterbuffer (GstElement * jitterbuffer)
{ {
@ -153,13 +170,12 @@ check_jitterbuffer_results (GstElement * jitterbuffer, gint num_buffers)
GList *node; GList *node;
GstClockTime ts = G_GUINT64_CONSTANT (0); GstClockTime ts = G_GUINT64_CONSTANT (0);
GstClockTime tso = gst_util_uint64_scale (RTP_FRAME_SIZE, GST_SECOND, 8000); GstClockTime tso = gst_util_uint64_scale (RTP_FRAME_SIZE, GST_SECOND, 8000);
guint test_duration = GST_TIME_AS_USECONDS (num_buffers * tso);
guint8 *data; guint8 *data;
guint16 prev_sn = 0, cur_sn; guint16 prev_sn = 0, cur_sn;
guint32 prev_ts = 0, cur_ts; guint32 prev_ts = 0, cur_ts;
/* sleep for twice the duration of the tested buffers */ /* sleep for twice the latency */
g_usleep (2 * test_duration); g_usleep (400 * 1000);
GST_INFO ("of %d buffer %d/%d received/dropped", num_buffers, GST_INFO ("of %d buffer %d/%d received/dropped", num_buffers,
g_list_length (buffers), num_dropped); g_list_length (buffers), num_dropped);
@ -195,9 +211,8 @@ GST_START_TEST (test_push_forward_seq)
GList *node; GList *node;
jitterbuffer = setup_jitterbuffer (num_buffers); jitterbuffer = setup_jitterbuffer (num_buffers);
fail_unless (gst_element_set_state (jitterbuffer, fail_unless (start_jitterbuffer (jitterbuffer)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, == GST_STATE_CHANGE_SUCCESS, "could not set to playing");
"could not set to playing");
/* push buffers: 0,1,2, */ /* push buffers: 0,1,2, */
for (node = inbuffers; node; node = g_list_next (node)) { for (node = inbuffers; node; node = g_list_next (node)) {
@ -222,9 +237,8 @@ GST_START_TEST (test_push_backward_seq)
GList *node; GList *node;
jitterbuffer = setup_jitterbuffer (num_buffers); jitterbuffer = setup_jitterbuffer (num_buffers);
fail_unless (gst_element_set_state (jitterbuffer, fail_unless (start_jitterbuffer (jitterbuffer)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, == GST_STATE_CHANGE_SUCCESS, "could not set to playing");
"could not set to playing");
/* push buffers: 0,3,2,1 */ /* push buffers: 0,3,2,1 */
buffer = (GstBuffer *) inbuffers->data; buffer = (GstBuffer *) inbuffers->data;
@ -251,9 +265,8 @@ GST_START_TEST (test_push_unordered)
GstBuffer *buffer; GstBuffer *buffer;
jitterbuffer = setup_jitterbuffer (num_buffers); jitterbuffer = setup_jitterbuffer (num_buffers);
fail_unless (gst_element_set_state (jitterbuffer, fail_unless (start_jitterbuffer (jitterbuffer)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, == GST_STATE_CHANGE_SUCCESS, "could not set to playing");
"could not set to playing");
/* push buffers; 0,2,1,3 */ /* push buffers; 0,2,1,3 */
buffer = (GstBuffer *) inbuffers->data; buffer = (GstBuffer *) inbuffers->data;
@ -281,12 +294,10 @@ GST_START_TEST (test_basetime)
GstBuffer *buffer; GstBuffer *buffer;
GList *node; GList *node;
GstClockTime tso = gst_util_uint64_scale (RTP_FRAME_SIZE, GST_SECOND, 8000); GstClockTime tso = gst_util_uint64_scale (RTP_FRAME_SIZE, GST_SECOND, 8000);
guint test_duration = GST_TIME_AS_USECONDS (num_buffers * tso);
jitterbuffer = setup_jitterbuffer (num_buffers); jitterbuffer = setup_jitterbuffer (num_buffers);
fail_unless (gst_element_set_state (jitterbuffer, fail_unless (start_jitterbuffer (jitterbuffer)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, == GST_STATE_CHANGE_SUCCESS, "could not set to playing");
"could not set to playing");
/* push buffers: 2,1,0 */ /* push buffers: 2,1,0 */
for (node = g_list_last (inbuffers); node; node = g_list_previous (node)) { for (node = g_list_last (inbuffers); node; node = g_list_previous (node)) {
@ -294,15 +305,12 @@ GST_START_TEST (test_basetime)
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK); fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
} }
/* sleep for twice the duration of the tested buffers */ /* sleep for twice the latency */
g_usleep (2 * test_duration); g_usleep (400 * 1000);
/* if this fails, not all buffers have been processed */ /* if this fails, not all buffers have been processed */
fail_unless_equals_int ((g_list_length (buffers) + num_dropped), num_buffers); fail_unless_equals_int ((g_list_length (buffers) + num_dropped), num_buffers);
/* check the buffer list */
fail_unless_equals_int (g_list_length (buffers), 1);
buffer = (GstBuffer *) buffers->data; buffer = (GstBuffer *) buffers->data;
fail_unless (GST_BUFFER_TIMESTAMP (buffer) != (num_buffers * tso)); fail_unless (GST_BUFFER_TIMESTAMP (buffer) != (num_buffers * tso));
@ -321,32 +329,9 @@ rtpjitterbuffer_suite (void)
suite_add_tcase (s, tc_chain); suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_push_forward_seq); tcase_add_test (tc_chain, test_push_forward_seq);
if (0) { tcase_add_test (tc_chain, test_push_backward_seq);
/* this one does not work yet (bug in test or jitter buffer?), sometimes I get tcase_add_test (tc_chain, test_push_unordered);
elements/rtpjitterbuffer.c:168:F:general:test_push_backward_seq:0: 'g_list_length (buffers)' (1) is not equal to 'num_buffers' (3) tcase_add_test (tc_chain, test_basetime);
0:00:00.113317818 761 0x9a74008 WARN rtpjitterbuffer rtpjitterbuffer.c:249:calculate_skew: backward timestamps at server, taking new base time
0:00:00.113547177 761 0x9a74008 WARN rtpjitterbuffer rtpjitterbuffer.c:249:calculate_skew: backward timestamps at server, taking new base time
and now we actually sent the first one always first to get a basetime set
*/
tcase_add_test (tc_chain, test_push_backward_seq);
}
if (0) {
/* this one does not work yet (bug in test or jitter buffer?), sometimes I get
elements/rtpjitterbuffer.c:168:F:general:test_push_unordered:0: 'g_list_length (buffers)' (2) is not equal to 'num_buffers' (3)
0:00:00.090439642 1216 0x9096008 WARN gstrtpjitterbuffer gstrtpjitterbuffer.c:1309:gst_rtp_jitter_buffer_chain:<gstrtpjitterbuffer> Packet #7205 too late as #7206 was already popped, dropping
0:00:00.090674798 1216 0x9096008 WARN gstrtpjitterbuffer gstrtpjitterbuffer.c:1309:gst_rtp_jitter_buffer_chain:<gstrtpjitterbuffer> Packet #7204 too late as #7206 was already popped, dropping
*/
tcase_add_test (tc_chain, test_push_unordered);
}
if (0) {
/* this shows that there is a bug in jitterbuffers, as the way this sometimes failes would mean that test_push_backward_seq() should work
https://bugzilla.gnome.org/show_bug.cgi?id=602940
elements/rtpjitterbuffer.c:303:F:general:test_basetime:0: 'g_list_length (buffers)' (3) is not equal to '1' (1)
0:00:00.104181601 23943 0x99f1008 WARN rtpjitterbuffer rtpjitterbuffer.c:249:calculate_skew: backward timestamps at server, taking new base time
0:00:00.104412426 23943 0x99f1008 WARN rtpjitterbuffer rtpjitterbuffer.c:249:calculate_skew: backward timestamps at server, taking new base time
*/
tcase_add_test (tc_chain, test_basetime);
}
/* FIXME: test buffer lists */ /* FIXME: test buffer lists */