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
This commit is contained in:
Pau Espin 2022-09-19 18:30:57 +02:00
parent 79701ebd25
commit 0944a4ce91
2 changed files with 27 additions and 5 deletions

View File

@ -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 @@ bool lchan_rtp_established(struct gsm_lchan *lchan);
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);

View File

@ -166,8 +166,7 @@ static void lchan_rtp_fsm_wait_mgw_endpoint_available_onenter(struct osmo_fsm_in
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 @@ static void lchan_rtp_fsm_wait_mgw_endpoint_available_onenter(struct osmo_fsm_in
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 @@ void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *l
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;
}