From b936278b2ee022231c11a0da69b4c916aba8a50a Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 4 Jul 2014 20:55:20 +0200 Subject: mgcp: Fix/test the case of a time jump and the resync In case the sender didn't send a couple of frames we will have a time gap that is bigger than the accepted delta. Add a new testcase for this and update the next_time. --- openbsc/tests/mgcp/mgcp_transcoding_test.c | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'openbsc/tests/mgcp') diff --git a/openbsc/tests/mgcp/mgcp_transcoding_test.c b/openbsc/tests/mgcp/mgcp_transcoding_test.c index e163f7162..2e857a13f 100644 --- a/openbsc/tests/mgcp/mgcp_transcoding_test.c +++ b/openbsc/tests/mgcp/mgcp_transcoding_test.c @@ -384,6 +384,53 @@ static void test_transcode_result(void) talloc_free(ctx); } + + { + /* from PCMA to GSM with a big time jump */ + struct rtp_hdr *hdr; + uint32_t ts; + + given_configured_endpoint(80, 160, "pcma", "gsm", &ctx, &endp); + state = endp->bts_end.rtp_process_data; + + /* Add the first sample */ + len = audio_packets_pcma[1].len; + memcpy(buf, audio_packets_pcma[1].data, len); + res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf)); + OSMO_ASSERT(state->sample_cnt == 80); + OSMO_ASSERT(state->next_time == 232640); + OSMO_ASSERT(state->next_seq == 26527); + OSMO_ASSERT(res < 0); + + /* Add a skip to the packet to force a 'resync' */ + len = audio_packets_pcma[2].len; + memcpy(buf, audio_packets_pcma[2].data, len); + hdr = (struct rtp_hdr *) &buf[0]; + /* jump the time and add alignment error */ + ts = ntohl(hdr->timestamp) + 123 * 80 + 2; + hdr->timestamp = htonl(ts); + res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf)); + OSMO_ASSERT(res < 0); + OSMO_ASSERT(state->sample_cnt == 80); + OSMO_ASSERT(state->next_time == ts); + OSMO_ASSERT(state->next_seq == 26527); + /* TODO: this can create alignment errors */ + + + /* Now attempt to consume 160 samples */ + len = audio_packets_pcma[2].len; + memcpy(buf, audio_packets_pcma[2].data, len); + hdr = (struct rtp_hdr *) &buf[0]; + ts += 80; + hdr->timestamp = htonl(ts); + res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf)); + OSMO_ASSERT(res == 12); + OSMO_ASSERT(state->sample_cnt == 0); + OSMO_ASSERT(state->next_time == ts + 160); + OSMO_ASSERT(state->next_seq == 26528); + + talloc_free(ctx); + } } static int test_repacking(int in_samples, int out_samples, int no_transcode) -- cgit v1.2.3