From 58fe2e03c851627ad0a91f2a00e0119636a8d832 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Wed, 21 Jun 2023 12:37:18 +0200 Subject: ASCI: rtp_stream_commit(): Also update MGW on conn mode change So far rtp_stream_commit() triggers an MGCP MDCX message only when codecs or the RTP address changed. Do the same for mode changes. ('sendrecv', 'recvonly', 'sendonly',...) Change-Id: I7a5637d0a7f1df13133e522fc78ba75eeeb2873e Related: OS#4854 --- include/osmocom/msc/rtp_stream.h | 2 ++ src/libmsc/call_leg.c | 2 +- src/libmsc/rtp_stream.c | 36 ++++++++++++++++++++++++++++-------- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/include/osmocom/msc/rtp_stream.h b/include/osmocom/msc/rtp_stream.h index d9a85c2b4..c42657ad8 100644 --- a/include/osmocom/msc/rtp_stream.h +++ b/include/osmocom/msc/rtp_stream.h @@ -45,6 +45,7 @@ struct rtp_stream { struct osmo_mgcpc_ep_ci *ci; enum mgcp_connection_mode crcx_conn_mode; + bool mode_sent_to_mgw; /* configured to use Osmux */ bool use_osmux; @@ -68,6 +69,7 @@ int rtp_stream_do_mdcx(struct rtp_stream *rtps); bool rtp_stream_set_codecs_from_mgcp_codec(struct rtp_stream *rtps, enum mgcp_codecs codec); void rtp_stream_set_one_codec(struct rtp_stream *rtps, const struct sdp_audio_codec *codec); void rtp_stream_set_codecs(struct rtp_stream *rtps, const struct sdp_audio_codecs *codecs); +void rtp_stream_set_mode(struct rtp_stream *rtps, enum mgcp_connection_mode mode); void rtp_stream_set_remote_addr(struct rtp_stream *rtps, const struct osmo_sockaddr_str *r); void rtp_stream_set_remote_addr_and_codecs(struct rtp_stream *rtps, const struct sdp_msg *sdp); void rtp_stream_set_remote_osmux_cid(struct rtp_stream *rtps, uint8_t osmux_cid); diff --git a/src/libmsc/call_leg.c b/src/libmsc/call_leg.c index 2c75d96a9..b078c770c 100644 --- a/src/libmsc/call_leg.c +++ b/src/libmsc/call_leg.c @@ -336,7 +336,7 @@ int call_leg_ensure_ci(struct call_leg *cl, enum rtp_direction dir, uint32_t cal { if (call_leg_ensure_rtp_alloc(cl, dir, call_id, for_trans)) return -EIO; - cl->rtp[dir]->crcx_conn_mode = cl->crcx_conn_mode[dir]; + rtp_stream_set_mode(cl->rtp[dir], cl->crcx_conn_mode[dir]); if (dir == RTP_TO_RAN && cl->ran_peer_supports_osmux) { cl->rtp[dir]->use_osmux = true; cl->rtp[dir]->remote_osmux_cid = -1; /* wildcard */ diff --git a/src/libmsc/rtp_stream.c b/src/libmsc/rtp_stream.c index 6c408affc..dcb4ef08e 100644 --- a/src/libmsc/rtp_stream.c +++ b/src/libmsc/rtp_stream.c @@ -83,6 +83,8 @@ void rtp_stream_update_id(struct rtp_stream *rtps) OSMO_STRBUF_PRINTF(sb, ":no-codecs"); else if (!rtps->codecs_sent_to_mgw) OSMO_STRBUF_PRINTF(sb, ":codecs-not-sent"); + if (!rtps->codecs_sent_to_mgw) + OSMO_STRBUF_PRINTF(sb, ":mode-not-sent"); if (rtps->use_osmux) { if (rtps->remote_osmux_cid < 0) OSMO_STRBUF_PRINTF(sb, ":no-remote-osmux-cid"); @@ -128,6 +130,7 @@ struct rtp_stream *rtp_stream_alloc(struct call_leg *parent_call_leg, enum rtp_d .dir = dir, .local_osmux_cid = -2, .remote_osmux_cid = -2, + .crcx_conn_mode = MGCP_CONN_NONE, /* Use connection's default mode. */ }; rtp_stream_update_id(rtps); @@ -172,14 +175,15 @@ static void rtp_stream_fsm_establishing_established(struct osmo_fsm_inst *fi, ui osmo_fsm_inst_dispatch(fi->proc.parent, CALL_LEG_EV_RTP_STREAM_ADDR_AVAILABLE, rtps); check_established(rtps); - if ((!rtps->remote_sent_to_mgw || !rtps->codecs_sent_to_mgw) + if ((!rtps->remote_sent_to_mgw || !rtps->codecs_sent_to_mgw || !rtps->mode_sent_to_mgw) && osmo_sockaddr_str_is_nonzero(&rtps->remote) && (!rtps->use_osmux || rtps->remote_osmux_cid_sent_to_mgw) && rtps->codecs_known) { LOG_RTPS(rtps, LOGL_DEBUG, - "local ip:port set;%s%s%s triggering MDCX to send the new settings\n", + "local ip:port set;%s%s%s%s triggering MDCX to send the new settings\n", (!rtps->remote_sent_to_mgw) ? " remote ip:port not yet sent," : "", (!rtps->codecs_sent_to_mgw) ? " codecs not yet sent," : "", + (!rtps->mode_sent_to_mgw) ? " mode not yet sent," : "", (rtps->use_osmux && !rtps->remote_osmux_cid_sent_to_mgw) ? "Osmux CID not yet sent,": ""); rtp_stream_do_mdcx(rtps); } @@ -194,6 +198,7 @@ static void rtp_stream_fsm_establishing_established(struct osmo_fsm_inst *fi, ui case RTP_STREAM_EV_MDCX_FAIL: rtps->remote_sent_to_mgw = false; rtps->codecs_sent_to_mgw = false; + rtps->mode_sent_to_mgw = false; rtps->remote_osmux_cid_sent_to_mgw = false; rtp_stream_update_id(rtps); rtp_stream_state_chg(rtps, RTP_STREAM_ST_DISCARDING); @@ -308,8 +313,7 @@ static int rtp_stream_do_mgcp_verb(struct rtp_stream *rtps, enum mgcp_verb verb, .x_osmo_osmux_cid = rtps->remote_osmux_cid, }; - if (verb == MGCP_VERB_CRCX) - verb_info.conn_mode = rtps->crcx_conn_mode; + verb_info.conn_mode = rtps->crcx_conn_mode; if (rtps->codecs_known) { /* Send the list of codecs to the MGW. Ideally we would just feed the SDP directly, but for legacy @@ -343,6 +347,7 @@ static int rtp_stream_do_mgcp_verb(struct rtp_stream *rtps, enum mgcp_verb verb, verb_info.port = rtps->remote.port; rtps->remote_sent_to_mgw = true; } + rtps->mode_sent_to_mgw = true; if (rtps->use_osmux && rtps->remote_osmux_cid >= 0) rtps->remote_osmux_cid_sent_to_mgw = true; rtp_stream_update_id(rtps); @@ -379,7 +384,7 @@ void rtp_stream_release(struct rtp_stream *rtps) } /* After setting up a remote RTP address or a new codec, call this to trigger an MDCX. - * The MDCX will only trigger if all data needed by an endpoint is available (both RTP address and codec) and if at + * The MDCX will only trigger if all data needed by an endpoint is available (RTP address, codecs and mode) and if at * least one of them has not yet been sent to the MGW in a previous CRCX or MDCX. */ int rtp_stream_commit(struct rtp_stream *rtps) { @@ -391,8 +396,9 @@ int rtp_stream_commit(struct rtp_stream *rtps) LOG_RTPS(rtps, LOGL_DEBUG, "Not committing: no codecs known\n"); return -1; } - if (rtps->remote_sent_to_mgw && rtps->codecs_sent_to_mgw) { - LOG_RTPS(rtps, LOGL_DEBUG, "Not committing: both remote RTP address and codecs already set up at MGW\n"); + if (rtps->remote_sent_to_mgw && rtps->codecs_sent_to_mgw && rtps->mode_sent_to_mgw) { + LOG_RTPS(rtps, LOGL_DEBUG, + "Not committing: remote RTP address, codecs and mode are already set up at MGW\n"); return 0; } if (!rtps->ci) { @@ -400,9 +406,10 @@ int rtp_stream_commit(struct rtp_stream *rtps) return -1; } - LOG_RTPS(rtps, LOGL_DEBUG, "Committing: Tx MDCX to update the MGW: updating%s%s%s\n", + LOG_RTPS(rtps, LOGL_DEBUG, "Committing: Tx MDCX to update the MGW: updating%s%s%s%s\n", rtps->remote_sent_to_mgw ? "" : " remote-RTP-IP-port", rtps->codecs_sent_to_mgw ? "" : " codecs", + rtps->mode_sent_to_mgw ? "" : " mode", (!rtps->use_osmux || rtps->remote_osmux_cid_sent_to_mgw) ? "" : " remote-Osmux-CID"); return rtp_stream_do_mdcx(rtps); } @@ -425,6 +432,18 @@ void rtp_stream_set_codecs(struct rtp_stream *rtps, const struct sdp_audio_codec rtp_stream_update_id(rtps); } +void rtp_stream_set_mode(struct rtp_stream *rtps, enum mgcp_connection_mode mode) +{ + if (rtps->crcx_conn_mode == mode) + return; + if (rtps->fi->state == RTP_STREAM_ST_ESTABLISHED) + rtp_stream_state_chg(rtps, RTP_STREAM_ST_ESTABLISHING); + LOG_RTPS(rtps, LOGL_DEBUG, "setting mode to %s\n", mgcp_client_cmode_name(mode)); + rtps->mode_sent_to_mgw = false; + rtps->crcx_conn_mode = mode; + rtp_stream_update_id(rtps); +} + /* Convenience shortcut to call rtp_stream_set_codecs() with a list of only one sdp_audio_codec record. */ void rtp_stream_set_one_codec(struct rtp_stream *rtps, const struct sdp_audio_codec *codec) { @@ -485,6 +504,7 @@ bool rtp_stream_is_established(struct rtp_stream *rtps) return false; if (!rtps->remote_sent_to_mgw || !rtps->codecs_sent_to_mgw + || !rtps->mode_sent_to_mgw || (rtps->use_osmux && !rtps->remote_osmux_cid_sent_to_mgw)) return false; return true; -- cgit v1.2.3