diff options
author | Pablo Neira Ayuso <pablo@gnumonks.org> | 2012-10-20 20:10:31 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@gnumonks.org> | 2012-10-20 20:17:28 +0200 |
commit | 5654c43f80a48b99bdbd5179d87f9b1a5cf55fa4 (patch) | |
tree | 868d9dc6713c5d96a0d3038a749bd78dee998ba4 /tests/osmo-pcap-test | |
parent | 631c6fe0ad8a20c33dc4395806f8ef14603987d6 (diff) |
osmux: remove generic functions to register and get ccid
Remove these functions:
- osmux_xfrm_input_get_ccid
- osmux_xfrm_input_register_ccid
The ccid will be managed by the BSC and it will be stored in the
mgcp_endpoint structure.
Also adjust all tests and examples using the API.
Diffstat (limited to 'tests/osmo-pcap-test')
-rw-r--r-- | tests/osmo-pcap-test/osmux_test.c | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/tests/osmo-pcap-test/osmux_test.c b/tests/osmo-pcap-test/osmux_test.c index 96cb478..4554430 100644 --- a/tests/osmo-pcap-test/osmux_test.c +++ b/tests/osmo-pcap-test/osmux_test.c @@ -73,19 +73,60 @@ struct osmux_in_handle h_input = { .deliver = deliver, }; +#define MAX_CONCURRENT_CALLS 8 + +static int ccid[MAX_CONCURRENT_CALLS]; + +static void register_ccid(uint32_t ssrc) +{ + int i, found = 0; + + for (i=0; i<MAX_CONCURRENT_CALLS; i++) { + if (ccid[i] == ssrc) + continue; + if (ccid[i] < 0) { + found = 1; + break; + } + } + + if (found) { + ccid[i] = ssrc; + LOGP(DOSMUXTEST, LOGL_DEBUG, "mapping ssrc=%u to ccid=%d\n", + ntohl(ssrc), i); + } else { + LOGP(DOSMUXTEST, LOGL_ERROR, "cannot map ssrc to ccid!\n"); + } +} + +static int get_ccid(uint32_t ssrc) +{ + int i, found = 0; + + for (i=0; i<MAX_CONCURRENT_CALLS; i++) { + if (ccid[i] == ssrc) { + found = 1; + break; + } + } + + return found ? i : -1; +} + static int pcap_test_run(struct msgb *msg) { - int ret; + int ret, ccid; struct rtp_hdr *rtph; rtph = osmo_rtp_get_hdr(msg); if (rtph == NULL) return 0; - if (osmux_xfrm_input_get_ccid(&h_input, rtph->ssrc) < 0) - osmux_xfrm_input_register_ccid(&h_input, rtph->ssrc); + ccid = get_ccid(&h_input, rtph->ssrc); + if (ccid < 0) + register_ccid(&h_input, rtph->ssrc); - while ((ret = osmux_xfrm_input(&h_input, msg)) > 1) { + while ((ret = osmux_xfrm_input(&h_input, msg, ccid)) > 1) { /* batch full, deliver it */ osmux_xfrm_input_deliver(&h_input); } |