in ran_msg, return gsm0808_speech_codec (inter-MSC)

Get rid of enum mgcp_codecs in inter-MSC handover related code.

Change-Id: I9c649f98738a55b8637ae600d5cdf81099fd08e5
This commit is contained in:
Neels Hofmeyr 2022-10-31 18:13:47 +01:00
parent cec51b340e
commit 7934e0d974
5 changed files with 34 additions and 25 deletions

View File

@ -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.

View File

@ -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 {

View File

@ -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");
}

View File

@ -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");
}

View File

@ -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);