From 282aee422f27795a8445c1d78f9463f2a15d0573 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 12 May 2013 18:03:50 +0200 Subject: [PATCH] osmux: allow to set initial RTP SSRC Instead of using the osmuxh->circuit_id. --- examples/osmux-test-output.c | 2 +- include/osmocom/netif/osmux.h | 3 ++- src/osmux.c | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/osmux-test-output.c b/examples/osmux-test-output.c index ea07606..ff5f04c 100644 --- a/examples/osmux-test-output.c +++ b/examples/osmux-test-output.c @@ -157,7 +157,7 @@ int main(int argc, char *argv[]) /* * initialize OSMUX handlers. */ - osmux_xfrm_output_init(&h_output); + osmux_xfrm_output_init(&h_output, random()); /* * initialize datagram server. diff --git a/include/osmocom/netif/osmux.h b/include/osmocom/netif/osmux.h index d50c7d5..9ef79d2 100644 --- a/include/osmocom/netif/osmux.h +++ b/include/osmocom/netif/osmux.h @@ -54,6 +54,7 @@ struct osmux_in_handle { struct osmux_out_handle { uint16_t rtp_seq; uint32_t rtp_timestamp; + uint32_t rtp_ssrc; }; struct osmux_hdr *osmux_get_hdr(struct msgb *msg); @@ -70,7 +71,7 @@ void osmux_xfrm_input_init(struct osmux_in_handle *h); int osmux_xfrm_input(struct osmux_in_handle *h, struct msgb *msg, int ccid); void osmux_xfrm_input_deliver(struct osmux_in_handle *h); -void osmux_xfrm_output_init(struct osmux_out_handle *h); +void osmux_xfrm_output_init(struct osmux_out_handle *h, uint32_t rtp_ssrc); int osmux_xfrm_output(struct osmux_hdr *osmuxh, struct osmux_out_handle *h, struct llist_head *list); struct osmux_hdr *osmux_xfrm_output_pull(struct msgb *msg); diff --git a/src/osmux.c b/src/osmux.c index 5dd0210..61aebb5 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -75,7 +75,6 @@ osmux_rebuild_rtp(struct osmux_out_handle *h, struct msgb *out_msg; struct rtp_hdr *rtph; struct amr_hdr *amrh; - uint32_t ssrc_from_ccid = osmuxh->circuit_id; char buf[4096]; out_msg = msgb_alloc(sizeof(struct rtp_hdr) + @@ -94,7 +93,7 @@ osmux_rebuild_rtp(struct osmux_out_handle *h, /* ... emulate timestamp and ssrc */ rtph->timestamp = htonl(h->rtp_timestamp); rtph->sequence = htons(h->rtp_seq); - rtph->ssrc = htonl(ssrc_from_ccid); + rtph->ssrc = htonl(h->rtp_ssrc); msgb_put(out_msg, sizeof(struct rtp_hdr)); @@ -517,10 +516,11 @@ osmux_tx_sched(struct llist_head *list, } } -void osmux_xfrm_output_init(struct osmux_out_handle *h) +void osmux_xfrm_output_init(struct osmux_out_handle *h, uint32_t rtp_ssrc) { h->rtp_seq = (uint16_t)random(); h->rtp_timestamp = (uint32_t)random(); + h->rtp_ssrc = rtp_ssrc; } #define SNPRINTF_BUFFER_SIZE(ret, size, len, offset) \