laforge submitted this change.

View Change


Approvals: laforge: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified
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
---
M include/osmocom/msc/rtp_stream.h
M src/libmsc/call_leg.c
M src/libmsc/rtp_stream.c
3 files changed, 45 insertions(+), 9 deletions(-)

diff --git a/include/osmocom/msc/rtp_stream.h b/include/osmocom/msc/rtp_stream.h
index d9a85c2..c42657a 100644
--- a/include/osmocom/msc/rtp_stream.h
+++ b/include/osmocom/msc/rtp_stream.h
@@ -45,6 +45,7 @@
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 @@
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 2c75d96..b078c77 100644
--- a/src/libmsc/call_leg.c
+++ b/src/libmsc/call_leg.c
@@ -336,7 +336,7 @@
{
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 6c408af..dcb4ef0 100644
--- a/src/libmsc/rtp_stream.c
+++ b/src/libmsc/rtp_stream.c
@@ -83,6 +83,8 @@
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 @@
.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 @@
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 @@
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 @@
.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 @@
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 @@
}

/* 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 @@
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 @@
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 @@
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 @@
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;

To view, visit change 33499. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: I7a5637d0a7f1df13133e522fc78ba75eeeb2873e
Gerrit-Change-Number: 33499
Gerrit-PatchSet: 9
Gerrit-Owner: jolly <andreas@eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-CC: neels <nhofmeyr@sysmocom.de>
Gerrit-MessageType: merged