pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/29418 )
Change subject: mgcp: Set up Osmux only when AMR codec is selected ......................................................................
mgcp: Set up Osmux only when AMR codec is selected
Until now Osmux was selected unconditionally in bss-side CRCX, without checking if the codec was AMR or not. If Osmux use policy is "on", we only want to request Osmux use if AMR codec is selected.
Change-Id: I3f53555dd9608f1337365e4f82b492bdf1da05bb --- M include/osmocom/bsc/lchan_rtp_fsm.h M src/osmo-bsc/lchan_rtp_fsm.c 2 files changed, 27 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/18/29418/1
diff --git a/include/osmocom/bsc/lchan_rtp_fsm.h b/include/osmocom/bsc/lchan_rtp_fsm.h index 5dbdb0a..397b5e1 100644 --- a/include/osmocom/bsc/lchan_rtp_fsm.h +++ b/include/osmocom/bsc/lchan_rtp_fsm.h @@ -13,6 +13,7 @@
struct gsm_lchan; struct mgcp_conn_peer; +enum mgcp_codecs;
enum lchan_rtp_fsm_state { LCHAN_RTP_ST_WAIT_MGW_ENDPOINT_AVAILABLE, @@ -48,3 +49,4 @@ void lchan_forget_mgw_endpoint(struct gsm_lchan *lchan);
void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *lchan, bool bss_side); +bool mgcp_codec_is_picked(const struct mgcp_conn_peer *verb_info, enum mgcp_codecs codec); diff --git a/src/osmo-bsc/lchan_rtp_fsm.c b/src/osmo-bsc/lchan_rtp_fsm.c index 87c235f..916823a 100644 --- a/src/osmo-bsc/lchan_rtp_fsm.c +++ b/src/osmo-bsc/lchan_rtp_fsm.c @@ -166,8 +166,7 @@
crcx_info = (struct mgcp_conn_peer){ .ptime = 20, - .x_osmo_osmux_use = bts->use_osmux != OSMUX_USAGE_OFF, - .x_osmo_osmux_cid = -1, /* -1 is wildcard */ + .x_osmo_osmux_cid = -1, /* -1 is wildcard, .x_osmo_osmux_use set below */ }; if (lchan->conn) { crcx_info.call_id = lchan->conn->sccp.conn_id; @@ -175,9 +174,25 @@ crcx_info.x_osmo_ign = lchan->conn->sccp.msc->x_osmo_ign; } mgcp_pick_codec(&crcx_info, lchan, true); - /* TODO: lchan_rtp_fail() here if crcx_info->codecs[] contains non-AMR and bts->use_osmux=ONLY. - If bts->use_osmux=ON, only set .x_osmo_osmux_use if there's an AMR in crcx_info->codecs[]. - IF osmux=no, always set x_osmo_osmux_use=false*/ + + /* Set up Osmux use in MGW according to configured policy */ + bool amr_picked = mgcp_codec_is_picked(&crcx_info, CODEC_AMR_8000_1); + switch (bts->use_osmux) { + case OSMUX_USAGE_OFF: + crcx_info.x_osmo_osmux_use = false; + break; + case OSMUX_USAGE_ON: + crcx_info.x_osmo_osmux_use = amr_picked; + break; + case OSMUX_USAGE_ONLY: + if (!amr_picked) { + lchan_rtp_fail("Only AMR codec can be used when configured with policy 'osmux only'." + " Check your configuration."); + return; + } + crcx_info.x_osmo_osmux_use = true; + break; + }
osmo_mgcpc_ep_ci_request(lchan->mgw_endpoint_ci_bts, MGCP_VERB_CRCX, &crcx_info, fi, LCHAN_RTP_EV_MGW_ENDPOINT_AVAILABLE, LCHAN_RTP_EV_MGW_ENDPOINT_ERROR, @@ -908,3 +923,8 @@ verb_info->param.amr_octet_aligned = lchan->conn->sccp.msc->amr_octet_aligned; } } + +bool mgcp_codec_is_picked(const struct mgcp_conn_peer *verb_info, enum mgcp_codecs codec) +{ + return verb_info->codecs[0] == codec; +}