From ef6bb25aa5b7dcb4a10469c6a39ace3534c08376 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 26 Feb 2010 13:41:22 +0100 Subject: [PATCH] [mgcp] Keep track of the local and remote RTP payload type Keep track of which RTP payload type to use for which direction. --- openbsc/include/openbsc/mgcp_internal.h | 3 +++ openbsc/src/mgcp/mgcp_protocol.c | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h index 2848d5bd0..3df986946 100644 --- a/openbsc/include/openbsc/mgcp_internal.h +++ b/openbsc/include/openbsc/mgcp_internal.h @@ -34,6 +34,9 @@ struct mgcp_endpoint { char *local_options; int conn_mode; + int bts_payload_type; + int net_payload_type; + /* the local rtp port we are binding to */ int rtp_port; diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c index bd47f8c42..e97f1f411 100644 --- a/openbsc/src/mgcp/mgcp_protocol.c +++ b/openbsc/src/mgcp/mgcp_protocol.c @@ -189,7 +189,7 @@ 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", endp->ci, addr, endp->rtp_port, - endp->cfg->audio_payload, endp->cfg->audio_payload, + endp->bts_payload_type, endp->bts_payload_type, endp->cfg->audio_name); return mgcp_create_response_with_data(200, msg, trans_id, sdp_record); } @@ -455,6 +455,8 @@ static struct msgb *handle_create_con(struct mgcp_config *cfg, struct msgb *msg) if (endp->ci == CI_UNUSED) goto error2; + endp->bts_payload_type = cfg->audio_payload; + /* policy CB */ if (cfg->policy_cb) { switch (cfg->policy_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_CRCX, trans_id)) { @@ -542,11 +544,13 @@ static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg) break; case 'm': { int port; + int payload; const char *param = (const char *)&msg->l3h[line_start]; - if (sscanf(param, "m=audio %d RTP/AVP %*d", &port) == 1) { + if (sscanf(param, "m=audio %d RTP/AVP %d", &port, &payload) == 2) { endp->net_rtp = htons(port); endp->net_rtcp = htons(port + 1); + endp->net_payload_type = payload; } break; } @@ -709,6 +713,8 @@ int mgcp_endpoints_allocate(struct mgcp_config *cfg) cfg->endpoints[i].local_rtcp.fd = -1; cfg->endpoints[i].ci = CI_UNUSED; cfg->endpoints[i].cfg = cfg; + cfg->endpoints[i].net_payload_type = -1; + cfg->endpoints[i].bts_payload_type = -1; } return 0;