aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmgcp/mgcp_protocol.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2014-02-05 18:56:17 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-05-22 14:39:16 +0200
commitcab6e7528c475d6aee687001a6146e5f20d8f53d (patch)
tree5d172538444f1b503ff3d2a7a09da5c139ad815f /openbsc/src/libmgcp/mgcp_protocol.c
parent038f97a69fe58d2bcb6cabcb82b3485f7d622ed2 (diff)
mgcp: add voice muxer support
This patch adds the voice muxer. You can use this to batch RTP traffic to reduce bandwidth comsuption. Basically, osmux transforms RTP flows to a compact batch format, that is later on decompacted to its original form. Port UDP/1984 is used for the muxer traffic between osmo-bsc_nat and osmo-bsc_mgcp (in the BSC side). This feature depends on libosmo-netif, which contains the osmux core support. Osmux is requested on-demand via the MGCP CRCX/MDCX messages (using the vendor-specific extension X-Osmux: on) coming from the BSC-NAT, so you can selectively enable osmux per BSC from one the bsc-nat.cfg file, so we have a centralized point to enable/disable osmux. First thing you need to do is to accept requests to use Osmux, this can be done from VTY interface of osmo-bsc_nat and osmo-bsc_mgcp by adding the following line: mgcp ... osmux on osmux batch-factor 4 This just initializes the osmux engine. You still have to specify what BSC uses osmux from osmo-bsc_nat configuration file: ... bsc 1 osmux on bsc 2 ... bsc 3 osmux on In this case, bsc 1 and 3 should use osmux if possible, bsc 2 does not have osmux enabled. Thus, you can selectively enable osmux depending on the BSC, and we have a centralized point for configuration from the bsc-nat to enable osmux on demand, as suggested by Holger. At this moment, this patch contains heavy debug logging for each RTP packet that can be removed later to save cycles. The RTP ssrc/seqnum/timestamp is randomly allocated for each MDCX that is received to configure an endpoint.
Diffstat (limited to 'openbsc/src/libmgcp/mgcp_protocol.c')
-rw-r--r--openbsc/src/libmgcp/mgcp_protocol.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c
index 5c88c9dd3..1480acca3 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -236,7 +236,7 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp,
addr = endp->cfg->source_addr;
len = snprintf(sdp_record, sizeof(sdp_record) - 1,
- "I: %u\n\n"
+ "I: %u%s\n\n"
"v=0\r\n"
"o=- %u 23 IN IP4 %s\r\n"
"c=IN IP4 %s\r\n"
@@ -244,7 +244,8 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp,
"m=audio %d RTP/AVP %d\r\n"
"a=rtpmap:%d %s\r\n"
"%s%s",
- endp->ci, endp->ci, addr, addr,
+ endp->ci, endp->cfg->osmux && endp->osmux ? "\nX-Osmux: On" : "",
+ endp->ci, addr, addr,
endp->net_end.local_port, endp->bts_end.payload_type,
endp->bts_end.payload_type, endp->tcfg->audio_name,
fmtp_extra ? fmtp_extra : "", fmtp_extra ? "\r\n" : "");
@@ -759,6 +760,14 @@ static struct msgb *handle_create_con(struct mgcp_parse_data *p)
case 'M':
mode = (const char *) line + 3;
break;
+ case 'X':
+ if (strcmp("Osmux: on", line + 2) == 0 &&
+ osmux_enable_endpoint(endp, OSMUX_ROLE_BSC) < 0) {
+ LOGP(DMGCP, LOGL_ERROR,
+ "Could not activate osmux in endpoint %d\n",
+ ENDPOINT_NUMBER(endp));
+ }
+ break;
case '\0':
have_sdp = 1;
goto mgcp_header_done;
@@ -859,8 +868,12 @@ mgcp_header_done:
if (p->cfg->change_cb)
p->cfg->change_cb(tcfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_CRCX);
- if (endp->conn_mode & MGCP_CONN_RECV_ONLY && tcfg->keepalive_interval != 0)
- mgcp_send_dummy(endp);
+ if (endp->conn_mode & MGCP_CONN_RECV_ONLY && tcfg->keepalive_interval != 0) {
+ if (endp->osmux)
+ osmux_send_dummy(endp);
+ else
+ mgcp_send_dummy(endp);
+ }
create_transcoder(endp);
return create_response_with_sdp(endp, "CRCX", p->trans);
@@ -874,7 +887,7 @@ static struct msgb *handle_modify_con(struct mgcp_parse_data *p)
{
struct mgcp_endpoint *endp = p->endp;
int error_code = 500;
- int silent = 0;
+ int silent = 0, osmux = 0;
char *line;
const char *local_options = NULL;
@@ -909,6 +922,10 @@ static struct msgb *handle_modify_con(struct mgcp_parse_data *p)
}
endp->orig_mode = endp->conn_mode;
break;
+ case 'X':
+ if (strcmp("Osmux: on", line + 2) == 0)
+ osmux = 1;
+ break;
case 'Z':
silent = strcmp("noanswer", line + 3) == 0;
break;
@@ -926,6 +943,21 @@ static struct msgb *handle_modify_con(struct mgcp_parse_data *p)
}
}
+ /* Re-enable Osmux if we receive a MDCX, we have to set up a new
+ * RTP flow: this generates a randomly allocated RTP SSRC and sequence
+ * number.
+ */
+ if (osmux) {
+ if (osmux_enable_endpoint(endp, OSMUX_ROLE_BSC) < 0) {
+ LOGP(DMGCP, LOGL_ERROR,
+ "Could not update osmux in endpoint %d\n",
+ ENDPOINT_NUMBER(endp));
+ }
+ LOGP(DMGCP, LOGL_NOTICE,
+ "Re-enabling osmux in endpoint %d, we got updated\n",
+ ENDPOINT_NUMBER(endp));
+ }
+
set_local_cx_options(endp->tcfg->endpoints, &endp->local_options,
local_options);