diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/jibuf/jibuf_test.c | 51 | ||||
-rw-r--r-- | tests/jibuf/jibuf_test.ok | 17 | ||||
-rw-r--r-- | tests/jibuf/jibuf_tool.c | 8 |
3 files changed, 74 insertions, 2 deletions
diff --git a/tests/jibuf/jibuf_test.c b/tests/jibuf/jibuf_test.c index 69a6d2f..a6fe1b9 100644 --- a/tests/jibuf/jibuf_test.c +++ b/tests/jibuf/jibuf_test.c @@ -564,6 +564,56 @@ static void test_timestamp_wraparound(void) osmo_jibuf_delete(jb); } +static void test_rtp_marker(void) +{ + int min_delay = 60; + struct msgb *msg; + struct rtp_hdr *rtph; + + printf("===test_rtp_marker===\n"); + + clock_override_enable(true); + clock_override_set(0, 0); + rtp_init(32, 400); + jb = osmo_jibuf_alloc(NULL); + osmo_jibuf_set_dequeue_cb(jb, dequeue_cb, NULL); + osmo_jibuf_set_min_delay(jb, min_delay); + osmo_jibuf_set_max_delay(jb, 200); + + /* First rtp at t=0, should be scheduled in min_delay time */ + clock_debug("enqueue 1st packet"); + ENQUEUE_NEXT(jb); + clock_override_add(0, TIME_RTP_PKT_MS*1000); + clock_debug("enqueue 2nd packet"); + ENQUEUE_NEXT(jb); + clock_override_add(0, min_delay*1000); + clock_debug("2 packets dequeued"); + osmo_select_main(0); + + clock_override_add(0, 40*1000); + /* We are at t=120, next non-marked (consecutive seq) packet arriving at + * this time should be dropped, but since marker establishes new ref, + * it will be accepted as well an ext paket */ + clock_debug("enqueue late pkt with marker=1, will be enqueued"); + msg = rtp_next(); + rtph = osmo_rtp_get_hdr(msg); + rtph->marker = 1; + OSMO_ASSERT(osmo_jibuf_enqueue(jb, msg) == 0); + + clock_debug("enqueue late pkt after pkt with marker=1, will be enqueued"); + clock_override_add(0, TIME_RTP_PKT_MS*1000); + ENQUEUE_NEXT(jb); + + clock_debug("2 packets dequeued"); + clock_override_add(0, min_delay*1000); + osmo_select_main(0); + + /* t=120, 4 enqueued, 4 dequeued.*/ + OSMO_ASSERT(osmo_jibuf_empty(jb)); + + osmo_jibuf_delete(jb); +} + int main(int argc, char **argv) { @@ -588,6 +638,7 @@ int main(int argc, char **argv) test_buffer_threshold_change(); test_seq_wraparound(); test_timestamp_wraparound(); + test_rtp_marker(); fprintf(stdout, "OK: Test passed\n"); return EXIT_SUCCESS; diff --git a/tests/jibuf/jibuf_test.ok b/tests/jibuf/jibuf_test.ok index 5a0f121..3103781 100644 --- a/tests/jibuf/jibuf_test.ok +++ b/tests/jibuf/jibuf_test.ok @@ -348,4 +348,21 @@ sys={0.140000}, mono={0.140000}: dequeue: seq=36 ts=174 INTERMEDIATE sys={0.160000}, mono={0.160000}: clock_override_add sys={0.160000}, mono={0.160000}: dequeue 5th packet (ts=334) sys={0.160000}, mono={0.160000}: dequeue: seq=37 ts=334 LATEST +===test_rtp_marker=== +sys={0.000000}, mono={0.000000}: clock_override_set +sys={0.000000}, mono={0.000000}: enqueue 1st packet +sys={0.020000}, mono={0.020000}: clock_override_add +sys={0.020000}, mono={0.020000}: enqueue 2nd packet +sys={0.080000}, mono={0.080000}: clock_override_add +sys={0.080000}, mono={0.080000}: 2 packets dequeued +sys={0.080000}, mono={0.080000}: dequeue: seq=33 ts=560 INTERMEDIATE +sys={0.080000}, mono={0.080000}: dequeue: seq=34 ts=720 LATEST +sys={0.120000}, mono={0.120000}: clock_override_add +sys={0.120000}, mono={0.120000}: enqueue late pkt with marker=1, will be enqueued +sys={0.120000}, mono={0.120000}: enqueue late pkt after pkt with marker=1, will be enqueued +sys={0.140000}, mono={0.140000}: clock_override_add +sys={0.140000}, mono={0.140000}: 2 packets dequeued +sys={0.200000}, mono={0.200000}: clock_override_add +sys={0.200000}, mono={0.200000}: dequeue: seq=35 ts=880 INTERMEDIATE +sys={0.200000}, mono={0.200000}: dequeue: seq=36 ts=1040 LATEST OK: Test passed diff --git a/tests/jibuf/jibuf_tool.c b/tests/jibuf/jibuf_tool.c index 78eece0..4a35a94 100644 --- a/tests/jibuf/jibuf_tool.c +++ b/tests/jibuf/jibuf_tool.c @@ -214,7 +214,9 @@ void dequeue_cb(struct msgb *msg, void *data) gettimeofday(&pinfo->postqueue.ts, NULL); pinfo->postqueue.timestamp = htonl(rtph->timestamp); - if (postqueue_started) { + /* If pkt->marker -> init of talkspurt, there may be missing packets before, + * better to start calculating the jitter from here */ + if (postqueue_started && !rtph->marker) { /* In random test mode we now the sender time, so we get real * jitter results using it */ if(opt_test_rand) { @@ -265,7 +267,9 @@ void pkt_arrived_cb(void *data) gettimeofday(&pinfo->prequeue.ts, NULL); pinfo->prequeue.timestamp = htonl(rtph->timestamp); - if (prequeue_started) { + /* If pkt->marker -> init of talkspurt, there may be missing packets before, + * better to start calculating the jitter from here */ + if (prequeue_started && !rtph->marker) { /* In random test mode we now the sender time, so we get real * jitter results using it */ if(opt_test_rand) { |