aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2022-10-31 18:13:47 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2023-03-18 03:05:34 +0100
commit7934e0d974b4f18c3bf415c9faddef90c3e7fccf (patch)
treea1d0ad12940c6c44ea131677f396437a9fcdec2f
parentcec51b340ea424e429e8a266d3a7137c0a8ad552 (diff)
in ran_msg, return gsm0808_speech_codec (inter-MSC)
Get rid of enum mgcp_codecs in inter-MSC handover related code. Change-Id: I9c649f98738a55b8637ae600d5cdf81099fd08e5
-rw-r--r--include/osmocom/msc/msc_ho.h2
-rw-r--r--include/osmocom/msc/ran_msg.h3
-rw-r--r--src/libmsc/msc_ho.c17
-rw-r--r--src/libmsc/msc_t.c20
-rw-r--r--src/libmsc/ran_msg_a.c17
5 files changed, 34 insertions, 25 deletions
diff --git a/include/osmocom/msc/msc_ho.h b/include/osmocom/msc/msc_ho.h
index a3f60c7f2..ca5618ebd 100644
--- a/include/osmocom/msc/msc_ho.h
+++ b/include/osmocom/msc/msc_ho.h
@@ -81,7 +81,7 @@ struct msc_ho_state {
struct osmo_sockaddr_str ran_remote_rtp;
/* The codec from Handover Request Acknowledge. */
bool codec_present;
- enum mgcp_codecs codec;
+ struct gsm0808_speech_codec codec;
/* Inter-MSC voice forwarding via MNCC, to the remote MSC. The Prepare Handover Response sent us the
* Handover Number the remote MSC assigned. This is a call to that Handover Number, via PBX.
diff --git a/include/osmocom/msc/ran_msg.h b/include/osmocom/msc/ran_msg.h
index d6b1e75ac..3e0ac6071 100644
--- a/include/osmocom/msc/ran_msg.h
+++ b/include/osmocom/msc/ran_msg.h
@@ -162,7 +162,8 @@ struct ran_handover_request_ack {
struct osmo_sockaddr_str remote_rtp;
bool codec_present;
- enum mgcp_codecs codec;
+ struct gsm0808_speech_codec codec;
+ bool codec_with_iuup;
};
struct ran_handover_command {
diff --git a/src/libmsc/msc_ho.c b/src/libmsc/msc_ho.c
index d53bb9e4d..e11abcf97 100644
--- a/src/libmsc/msc_ho.c
+++ b/src/libmsc/msc_ho.c
@@ -681,7 +681,7 @@ static void msc_ho_rx_request_ack(struct msc_a *msc_a, struct msc_a_ran_dec_data
msc_a->ho.new_cell.codec = hra->ran_dec->handover_request_ack.codec;
if (hra->ran_dec->handover_request_ack.codec_present) {
LOG_HO(msc_a, LOGL_DEBUG, "Request Ack contains codec %s\n",
- osmo_mgcpc_codec_name(msc_a->ho.new_cell.codec));
+ gsm0808_speech_codec_type_name(msc_a->ho.new_cell.codec.type));
}
}
@@ -728,13 +728,14 @@ static void msc_ho_rtp_switch_to_new_cell(struct msc_a *msc_a)
/* Switch over to the new peer */
rtp_stream_set_remote_addr(rtp_to_ran, &msc_a->ho.new_cell.ran_remote_rtp);
if (msc_a->ho.new_cell.codec_present) {
- struct sdp_audio_codecs codecs = {};
- if (!sdp_audio_codecs_add_mgcp_codec(&codecs, msc_a->ho.new_cell.codec)) {
- LOG_HO(msc_a, LOGL_ERROR,
- "Cannot resolve codec: %s\n", osmo_mgcpc_codec_name(msc_a->ho.new_cell.codec));
- } else {
- rtp_stream_set_codecs(rtp_to_ran, &codecs);
- }
+ const struct codec_mapping *m;
+ m = codec_mapping_by_gsm0808_speech_codec_type(msc_a->ho.new_cell.codec.type);
+ /* TODO: use codec_mapping_by_gsm0808_speech_codec() to also match on codec.cfg */
+ if (!m)
+ LOG_HO(msc_a, LOGL_ERROR, "Cannot resolve codec: %s\n",
+ gsm0808_speech_codec_type_name(msc_a->ho.new_cell.codec.type));
+ else
+ rtp_stream_set_one_codec(rtp_to_ran, &m->sdp);
} else {
LOG_HO(msc_a, LOGL_ERROR, "No codec is set\n");
}
diff --git a/src/libmsc/msc_t.c b/src/libmsc/msc_t.c
index 787d7362f..7f316a7ec 100644
--- a/src/libmsc/msc_t.c
+++ b/src/libmsc/msc_t.c
@@ -38,6 +38,7 @@
#include <osmocom/msc/vlr.h>
#include <osmocom/msc/msc_i.h>
#include <osmocom/msc/gsm_data.h>
+#include <osmocom/msc/codec_mapping.h>
static struct osmo_fsm msc_t_fsm;
@@ -448,11 +449,20 @@ static int msc_t_patch_and_send_ho_request_ack(struct msc_t *msc_t, const struct
LOG_MSC_T(msc_t, LOGL_DEBUG, "No RTP IP:port in Handover Request Ack\n");
}
if (r->codec_present) {
- LOG_MSC_T(msc_t, LOGL_DEBUG, "From Handover Request Ack, got %s\n",
- osmo_mgcpc_codec_name(r->codec));
- rtp_stream_set_codecs_from_mgcp_codec(rtp_ran, r->codec);
- if (rtp_cn)
- rtp_stream_set_codecs_from_mgcp_codec(rtp_cn, r->codec);
+ const struct codec_mapping *m = codec_mapping_by_gsm0808_speech_codec_type(r->codec.type);
+ /* TODO: use codec_mapping_by_gsm0808_speech_codec() to also match on codec.cfg */
+ if (!m) {
+ LOG_MSC_T(msc_t, LOGL_ERROR, "Cannot resolve codec in Handover Request Ack: %s / %s\n",
+ gsm0808_speech_codec_type_name(r->codec.type),
+ m ? sdp_audio_codec_to_str(&m->sdp) : "(unknown)");
+ } else {
+ LOG_MSC_T(msc_t, LOGL_DEBUG, "From Handover Request Ack, got codec %s / %s\n",
+ gsm0808_speech_codec_type_name(r->codec.type),
+ sdp_audio_codec_to_str(&m->sdp));
+ rtp_stream_set_one_codec(rtp_ran, &m->sdp);
+ if (rtp_cn)
+ rtp_stream_set_one_codec(rtp_cn, &m->sdp);
+ }
} else {
LOG_MSC_T(msc_t, LOGL_DEBUG, "No codec in Handover Request Ack\n");
}
diff --git a/src/libmsc/ran_msg_a.c b/src/libmsc/ran_msg_a.c
index 56252f1d0..19402bc11 100644
--- a/src/libmsc/ran_msg_a.c
+++ b/src/libmsc/ran_msg_a.c
@@ -671,13 +671,12 @@ static int ran_a_decode_handover_request_ack(struct ran_dec *ran_dec, const stru
}
if (ie_chosen_speech_version) {
- struct gsm0808_speech_codec sc;
ran_dec_msg.handover_request_ack.chosen_speech_version = ie_chosen_speech_version->val[0];
/* the codec may be extrapolated from this Speech Version or below from Speech Codec */
- gsm0808_speech_codec_from_chan_type(&sc, ran_dec_msg.handover_request_ack.chosen_speech_version);
- ran_dec_msg.handover_request_ack.codec_present = true;
- ran_dec_msg.handover_request_ack.codec = ran_a_mgcp_codec_from_sc(&sc);
+ if (gsm0808_speech_codec_from_chan_type(&ran_dec_msg.handover_request_ack.codec,
+ ran_dec_msg.handover_request_ack.chosen_speech_version) == 0)
+ ran_dec_msg.handover_request_ack.codec_present = true;
}
if (ie_aoip_transp_addr) {
@@ -692,14 +691,12 @@ static int ran_a_decode_handover_request_ack(struct ran_dec *ran_dec, const stru
}
if (ie_speech_codec) {
- struct gsm0808_speech_codec sc;
- if (gsm0808_dec_speech_codec(&sc, ie_speech_codec->val, ie_speech_codec->len) < 0)
+ /* the codec may be extrapolated from above Speech Version or from this Speech Codec */
+ if (gsm0808_dec_speech_codec(&ran_dec_msg.handover_request_ack.codec,
+ ie_speech_codec->val, ie_speech_codec->len) < 0)
LOG_RAN_A_DEC_MSG(LOGL_ERROR, "unable to decode IE Speech Codec (Chosen)\n");
- else {
- /* the codec may be extrapolated from above Speech Version or from this Speech Codec */
+ else
ran_dec_msg.handover_request_ack.codec_present = true;
- ran_dec_msg.handover_request_ack.codec = ran_a_mgcp_codec_from_sc(&sc);
- }
}
return ran_decoded(ran_dec, &ran_dec_msg);