Change in ...osmo-msc[master]: mncc: send payload type matching chosen codec

neels gerrit-no-reply at lists.osmocom.org
Mon Aug 5 21:25:34 UTC 2019


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/15060


Change subject: mncc: send payload type matching chosen codec
......................................................................

mncc: send payload type matching chosen codec

Change-Id: Id32f32d77d24b753adb96b5393c0363439e312c2
---
M include/osmocom/msc/mncc_call.h
M src/libmsc/gsm_04_08_cc.c
2 files changed, 29 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/60/15060/1

diff --git a/include/osmocom/msc/mncc_call.h b/include/osmocom/msc/mncc_call.h
index ad0f0f8..e887cbe 100644
--- a/include/osmocom/msc/mncc_call.h
+++ b/include/osmocom/msc/mncc_call.h
@@ -22,6 +22,7 @@
  */
 #pragma once
 
+#include <osmocom/mgcp_client/mgcp_client.h>
 #include <osmocom/msc/mncc.h>
 #include <osmocom/msc/mncc_call.h>
 
@@ -138,3 +139,5 @@
 struct mncc_call *mncc_call_find_by_callref(uint32_t callref);
 
 void mncc_call_release(struct mncc_call *mncc_call);
+
+uint32_t mgcp_codec_to_mncc_payload_msg_type(enum mgcp_codecs codec);
diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c
index 03830de..444d860 100644
--- a/src/libmsc/gsm_04_08_cc.c
+++ b/src/libmsc/gsm_04_08_cc.c
@@ -30,6 +30,8 @@
 #include <regex.h>
 #include <sys/types.h>
 
+#include <osmocom/mgcp_client/mgcp_client_endpoint_fsm.h>
+
 #include <osmocom/msc/db.h>
 #include <osmocom/msc/debug.h>
 #include <osmocom/msc/gsm_data.h>
@@ -1667,18 +1669,34 @@
 	struct gsm_network *net = msc_a_net(msc_a);
 	struct call_leg *cl = msc_a->cc.call_leg;
 	struct osmo_sockaddr_str *rtp_cn_local;
+	struct rtp_stream *rtp_cn = cl ? cl->rtp[RTP_TO_CN] : NULL;
 	/* FIXME: This has to be set to some meaningful value,
 	 * before the MSC-Split, this value was pulled from
 	 * lchan->abis_ip.rtp_payload */
 	uint32_t payload_type = 0;
-	int msg_type;
+	int payload_msg_type;
+	const struct mgcp_conn_peer *mgcp_info;
 
-	/* FIXME This has to be set to some meaningful value.
-	 * Possible options are:
-	 * GSM_TCHF_FRAME, GSM_TCHF_FRAME_EFR,
-	 * GSM_TCHH_FRAME, GSM_TCH_FRAME_AMR
-	 * (0 if unknown) */
-	msg_type = GSM_TCHF_FRAME;
+	if (!rtp_cn) {
+		LOG_TRANS_CAT(trans, DMNCC, LOGL_ERROR, "Cannot RTP CREATE to MNCC, no RTP set up for the CN side\n");
+		return -EINVAL;
+	}
+
+	if (!rtp_cn->codec_known) {
+		LOG_TRANS_CAT(trans, DMNCC, LOGL_ERROR,
+			      "Cannot RTP CREATE to MNCC, no codec set up for the RTP CN side\n");
+		return -EINVAL;
+	}
+
+	/* Codec */
+	payload_msg_type = mgcp_codec_to_mncc_payload_msg_type(rtp_cn->codec);
+
+	/* Payload Type number */
+	/* FIXME: since several codecs could be enabled, the proper solution is to forward SDP to MNCC as a
+	 * whole. For now, let's just send the first codec, knowing that currently most of our code actually
+	 * only sets a single codec to begin with. */
+	mgcp_info = osmo_mgcpc_ep_ci_get_rtp_info(rtp_cn->ci);
+	payload_type = map_codec_to_pt(mgcp_info->ptmap, mgcp_info->ptmap_len, rtp_cn->codec);
 
 	rtp_cn_local = call_leg_local_ip(cl, RTP_TO_CN);
 	if (!rtp_cn_local) {
@@ -1686,7 +1704,7 @@
 		return -EINVAL;
 	}
 
-	return mncc_recv_rtp(net, trans, trans->callref, MNCC_RTP_CREATE, rtp_cn_local, payload_type, msg_type);
+	return mncc_recv_rtp(net, trans, trans->callref, MNCC_RTP_CREATE, rtp_cn_local, payload_type, payload_msg_type);
 }
 
 static int tch_rtp_connect(struct gsm_network *net, const struct gsm_mncc_rtp *rtp)

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/15060
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: Id32f32d77d24b753adb96b5393c0363439e312c2
Gerrit-Change-Number: 15060
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190805/b8dfff84/attachment.html>


More information about the gerrit-log mailing list