From fbca4ea1171abb65fd8e1f121469adaeb57104df Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 1 Nov 2010 19:49:48 +0100 Subject: mgcp: Fix the indetion of this code. it should use tabs --- openbsc/src/mgcp/mgcp_protocol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'openbsc/src/mgcp/mgcp_protocol.c') diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c index 840bc14c2..c73031c08 100644 --- a/openbsc/src/mgcp/mgcp_protocol.c +++ b/openbsc/src/mgcp/mgcp_protocol.c @@ -422,7 +422,7 @@ static int allocate_ports(struct mgcp_endpoint *endp) } if (endp->cfg->transcoder_ip && - allocate_port(endp, &endp->transcoder_end, &endp->cfg->transcoder_ports, + allocate_port(endp, &endp->transcoder_end, &endp->cfg->transcoder_ports, mgcp_bind_transcoder_rtp_port) != 0) { mgcp_rtp_end_reset(&endp->net_end); mgcp_rtp_end_reset(&endp->bts_end); -- cgit v1.2.3 From b54048fe25a28c47149f916ae293654b5330ff78 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 1 Nov 2010 19:57:50 +0100 Subject: mgcp: Make transcoding a per Endpoint configuration This allows to switch off transcoding on the fly, or only enable it for certain vessels with known problems. --- openbsc/src/mgcp/mgcp_protocol.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'openbsc/src/mgcp/mgcp_protocol.c') diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c index c73031c08..4e7ebf8bb 100644 --- a/openbsc/src/mgcp/mgcp_protocol.c +++ b/openbsc/src/mgcp/mgcp_protocol.c @@ -421,12 +421,17 @@ static int allocate_ports(struct mgcp_endpoint *endp) return -1; } - if (endp->cfg->transcoder_ip && - allocate_port(endp, &endp->transcoder_end, &endp->cfg->transcoder_ports, - mgcp_bind_transcoder_rtp_port) != 0) { - mgcp_rtp_end_reset(&endp->net_end); - mgcp_rtp_end_reset(&endp->bts_end); - return -1; + if (endp->cfg->transcoder_ip) { + if (allocate_port(endp, &endp->transcoder_end, + &endp->cfg->transcoder_ports, + mgcp_bind_transcoder_rtp_port) != 0) { + mgcp_rtp_end_reset(&endp->net_end); + mgcp_rtp_end_reset(&endp->bts_end); + return -1; + } + + /* remember that we have set up transcoding */ + endp->is_transcoded = 1; } return 0; @@ -848,6 +853,7 @@ void mgcp_free_endp(struct mgcp_endpoint *endp) mgcp_rtp_end_reset(&endp->bts_end); mgcp_rtp_end_reset(&endp->net_end); mgcp_rtp_end_reset(&endp->transcoder_end); + endp->is_transcoded = 0; memset(&endp->net_state, 0, sizeof(endp->net_state)); memset(&endp->bts_state, 0, sizeof(endp->bts_state)); @@ -927,7 +933,7 @@ static void create_transcoder(struct mgcp_endpoint *endp) int in_endp = ENDPOINT_NUMBER(endp); int out_endp = back_channel(in_endp); - if (!endp->cfg->transcoder_ip) + if (!endp->is_transcoded) return; send_msg(endp, in_endp, endp->bts_end.local_port, "CRCX", "recvonly"); @@ -945,7 +951,7 @@ static void delete_transcoder(struct mgcp_endpoint *endp) int in_endp = ENDPOINT_NUMBER(endp); int out_endp = back_channel(in_endp); - if (!endp->cfg->transcoder_ip) + if (!endp->is_transcoded) return; send_dlcx(endp, in_endp); -- cgit v1.2.3 From 21262335907f2aa621742e87d596e4278b0f3d86 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 1 Nov 2010 20:53:31 +0100 Subject: mgcp: Rename transcoder_end to trans_net Packets arriving for trans_net will be send out to the networking. We will introduce a trans_bts in a second. --- openbsc/src/mgcp/mgcp_protocol.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'openbsc/src/mgcp/mgcp_protocol.c') diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c index 4e7ebf8bb..435ceeee2 100644 --- a/openbsc/src/mgcp/mgcp_protocol.c +++ b/openbsc/src/mgcp/mgcp_protocol.c @@ -422,7 +422,7 @@ static int allocate_ports(struct mgcp_endpoint *endp) } if (endp->cfg->transcoder_ip) { - if (allocate_port(endp, &endp->transcoder_end, + if (allocate_port(endp, &endp->trans_net, &endp->cfg->transcoder_ports, mgcp_bind_transcoder_rtp_port) != 0) { mgcp_rtp_end_reset(&endp->net_end); @@ -828,7 +828,7 @@ int mgcp_endpoints_allocate(struct mgcp_config *cfg) cfg->endpoints[i].cfg = cfg; mgcp_rtp_end_init(&cfg->endpoints[i].net_end); mgcp_rtp_end_init(&cfg->endpoints[i].bts_end); - mgcp_rtp_end_init(&cfg->endpoints[i].transcoder_end); + mgcp_rtp_end_init(&cfg->endpoints[i].trans_net); } return 0; @@ -852,7 +852,7 @@ void mgcp_free_endp(struct mgcp_endpoint *endp) mgcp_rtp_end_reset(&endp->bts_end); mgcp_rtp_end_reset(&endp->net_end); - mgcp_rtp_end_reset(&endp->transcoder_end); + mgcp_rtp_end_reset(&endp->trans_net); endp->is_transcoded = 0; memset(&endp->net_state, 0, sizeof(endp->net_state)); @@ -938,12 +938,12 @@ static void create_transcoder(struct mgcp_endpoint *endp) send_msg(endp, in_endp, endp->bts_end.local_port, "CRCX", "recvonly"); send_msg(endp, in_endp, endp->bts_end.local_port, "MDCX", "recvonly"); - send_msg(endp, out_endp, endp->transcoder_end.local_port, "CRCX", "sendrecv"); - send_msg(endp, out_endp, endp->transcoder_end.local_port, "MDCX", "sendrecv"); + send_msg(endp, out_endp, endp->trans_net.local_port, "CRCX", "sendrecv"); + send_msg(endp, out_endp, endp->trans_net.local_port, "MDCX", "sendrecv"); port = rtp_calculate_port(out_endp, endp->cfg->transcoder_remote_base); - endp->transcoder_end.rtp_port = htons(port); - endp->transcoder_end.rtcp_port = htons(port + 1); + endp->trans_net.rtp_port = htons(port); + endp->trans_net.rtcp_port = htons(port + 1); } static void delete_transcoder(struct mgcp_endpoint *endp) -- cgit v1.2.3 From e97155a2af793aa709f897e8766cccd20e86964c Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 2 Nov 2010 19:06:13 +0100 Subject: mgcp: Keep the local_port like it was set on allocation Do not reset statically allocated local_port. The port might be different to the calculation of endpoint number and base port. This might be the case for the coming remote transcoding. --- openbsc/src/mgcp/mgcp_protocol.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'openbsc/src/mgcp/mgcp_protocol.c') diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c index 435ceeee2..ddcbfafcb 100644 --- a/openbsc/src/mgcp/mgcp_protocol.c +++ b/openbsc/src/mgcp/mgcp_protocol.c @@ -382,7 +382,6 @@ static int allocate_port(struct mgcp_endpoint *endp, struct mgcp_rtp_end *end, int i; if (range->mode == PORT_ALLOC_STATIC) { - end->local_port = rtp_calculate_port(ENDPOINT_NUMBER(endp), range->base_port); end->local_alloc = PORT_ALLOC_STATIC; return 0; } @@ -795,12 +794,14 @@ struct mgcp_config *mgcp_config_alloc(void) static void mgcp_rtp_end_reset(struct mgcp_rtp_end *end) { - if (end->local_alloc == PORT_ALLOC_DYNAMIC) + if (end->local_alloc == PORT_ALLOC_DYNAMIC) { mgcp_free_rtp_port(end); + end->local_port = 0; + } end->packets = 0; memset(&end->addr, 0, sizeof(end->addr)); - end->rtp_port = end->rtcp_port = end->local_port = 0; + end->rtp_port = end->rtcp_port = 0; end->payload_type = -1; end->local_alloc = -1; } -- cgit v1.2.3 From bd7b3c5e45426efc79b4dd685d1e818de3550d0a Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 1 Nov 2010 21:04:54 +0100 Subject: mgcp: Introduce trans_bts and send BTS packets from this port Introduce the trans_bts. Right now only a port is allocated and the packets from the BTS are sent from this socket. --- openbsc/src/mgcp/mgcp_protocol.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'openbsc/src/mgcp/mgcp_protocol.c') diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c index ddcbfafcb..84fd1551e 100644 --- a/openbsc/src/mgcp/mgcp_protocol.c +++ b/openbsc/src/mgcp/mgcp_protocol.c @@ -423,12 +423,21 @@ static int allocate_ports(struct mgcp_endpoint *endp) if (endp->cfg->transcoder_ip) { if (allocate_port(endp, &endp->trans_net, &endp->cfg->transcoder_ports, - mgcp_bind_transcoder_rtp_port) != 0) { + mgcp_bind_trans_net_rtp_port) != 0) { mgcp_rtp_end_reset(&endp->net_end); mgcp_rtp_end_reset(&endp->bts_end); return -1; } + if (allocate_port(endp, &endp->trans_bts, + &endp->cfg->transcoder_ports, + mgcp_bind_trans_bts_rtp_port) != 0) { + mgcp_rtp_end_reset(&endp->net_end); + mgcp_rtp_end_reset(&endp->bts_end); + mgcp_rtp_end_reset(&endp->trans_net); + return -1; + } + /* remember that we have set up transcoding */ endp->is_transcoded = 1; } @@ -830,6 +839,7 @@ int mgcp_endpoints_allocate(struct mgcp_config *cfg) mgcp_rtp_end_init(&cfg->endpoints[i].net_end); mgcp_rtp_end_init(&cfg->endpoints[i].bts_end); mgcp_rtp_end_init(&cfg->endpoints[i].trans_net); + mgcp_rtp_end_init(&cfg->endpoints[i].trans_bts); } return 0; @@ -854,6 +864,7 @@ void mgcp_free_endp(struct mgcp_endpoint *endp) mgcp_rtp_end_reset(&endp->bts_end); mgcp_rtp_end_reset(&endp->net_end); mgcp_rtp_end_reset(&endp->trans_net); + mgcp_rtp_end_reset(&endp->trans_bts); endp->is_transcoded = 0; memset(&endp->net_state, 0, sizeof(endp->net_state)); @@ -865,12 +876,6 @@ void mgcp_free_endp(struct mgcp_endpoint *endp) memset(&endp->taps, 0, sizeof(endp->taps)); } -/* For transcoding we need to manage an in and an output that are connected */ -static int back_channel(int endpoint) -{ - return endpoint + 60; -} - static int send_trans(struct mgcp_config *cfg, const char *buf, int len) { struct sockaddr_in addr; @@ -932,16 +937,20 @@ static void create_transcoder(struct mgcp_endpoint *endp) { int port; int in_endp = ENDPOINT_NUMBER(endp); - int out_endp = back_channel(in_endp); + int out_endp = endp_back_channel(in_endp); if (!endp->is_transcoded) return; - send_msg(endp, in_endp, endp->bts_end.local_port, "CRCX", "recvonly"); - send_msg(endp, in_endp, endp->bts_end.local_port, "MDCX", "recvonly"); + send_msg(endp, in_endp, endp->trans_bts.local_port, "CRCX", "recvonly"); + send_msg(endp, in_endp, endp->trans_bts.local_port, "MDCX", "recvonly"); send_msg(endp, out_endp, endp->trans_net.local_port, "CRCX", "sendrecv"); send_msg(endp, out_endp, endp->trans_net.local_port, "MDCX", "sendrecv"); + port = rtp_calculate_port(in_endp, endp->cfg->transcoder_remote_base); + endp->trans_bts.rtp_port = htons(port); + endp->trans_bts.rtcp_port = htons(port + 1); + port = rtp_calculate_port(out_endp, endp->cfg->transcoder_remote_base); endp->trans_net.rtp_port = htons(port); endp->trans_net.rtcp_port = htons(port + 1); @@ -950,7 +959,7 @@ static void create_transcoder(struct mgcp_endpoint *endp) static void delete_transcoder(struct mgcp_endpoint *endp) { int in_endp = ENDPOINT_NUMBER(endp); - int out_endp = back_channel(in_endp); + int out_endp = endp_back_channel(in_endp); if (!endp->is_transcoded) return; -- cgit v1.2.3 From 8b19dee437cdd73f75413d5f936e768939e3db71 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 1 Nov 2010 22:38:25 +0100 Subject: mgcp: Send data from the network to the transcoder too We now should be able to transcode in both directions. --- openbsc/src/mgcp/mgcp_protocol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'openbsc/src/mgcp/mgcp_protocol.c') diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c index 84fd1551e..f8f70679e 100644 --- a/openbsc/src/mgcp/mgcp_protocol.c +++ b/openbsc/src/mgcp/mgcp_protocol.c @@ -942,8 +942,8 @@ static void create_transcoder(struct mgcp_endpoint *endp) if (!endp->is_transcoded) return; - send_msg(endp, in_endp, endp->trans_bts.local_port, "CRCX", "recvonly"); - send_msg(endp, in_endp, endp->trans_bts.local_port, "MDCX", "recvonly"); + send_msg(endp, in_endp, endp->trans_bts.local_port, "CRCX", "sendrecv"); + send_msg(endp, in_endp, endp->trans_bts.local_port, "MDCX", "sendrecv"); send_msg(endp, out_endp, endp->trans_net.local_port, "CRCX", "sendrecv"); send_msg(endp, out_endp, endp->trans_net.local_port, "MDCX", "sendrecv"); -- cgit v1.2.3