MNCC: use codec_mapping, drop mgcp_codec_to_mncc_payload_msg_type()

Change-Id: I8995ef43b9f79bc1db5672362c6433e4d96dd9e0
This commit is contained in:
Neels Hofmeyr 2022-10-31 17:57:30 +01:00 committed by neels
parent b2ce74829a
commit a001a70048
2 changed files with 20 additions and 22 deletions

View File

@ -56,6 +56,7 @@
#include <osmocom/msc/mncc_call.h>
#include <osmocom/msc/msc_t.h>
#include <osmocom/msc/sdp_msg.h>
#include <osmocom/msc/codec_mapping.h>
#include <osmocom/gsm/gsm48.h>
#include <osmocom/gsm/gsm0480.h>
@ -1770,6 +1771,7 @@ int gsm48_tch_rtp_create(struct gsm_trans *trans)
uint32_t payload_type;
int payload_msg_type;
const struct mgcp_conn_peer *mgcp_info;
const struct codec_mapping *m;
if (!rtp_cn) {
LOG_TRANS_CAT(trans, DMNCC, LOGL_ERROR, "Cannot RTP CREATE to MNCC, no RTP set up for the CN side\n");
@ -1783,7 +1785,14 @@ int gsm48_tch_rtp_create(struct gsm_trans *trans)
}
/* Codec */
payload_msg_type = mgcp_codec_to_mncc_payload_msg_type(rtp_cn->codec);
m = codec_mapping_by_mgcp_codec(rtp_cn->codec);
if (!m) {
LOG_TRANS_CAT(trans, DMNCC, LOGL_ERROR,
"Cannot RTP CREATE to MNCC, cannot resolve codec '%s'\n",
osmo_mgcpc_codec_name(rtp_cn->codec));
return -EINVAL;
}
payload_msg_type = m->mncc_payload_msg_type;
/* Payload Type number */
mgcp_info = osmo_mgcpc_ep_ci_get_rtp_info(rtp_cn->ci);

View File

@ -35,6 +35,7 @@
#include <osmocom/msc/rtp_stream.h>
#include <osmocom/msc/msub.h>
#include <osmocom/msc/vlr.h>
#include <osmocom/msc/codec_mapping.h>
struct osmo_fsm mncc_call_fsm;
static bool mncc_call_tx_rtp_create(struct mncc_call *mncc_call);
@ -274,25 +275,6 @@ static bool mncc_call_rx_rtp_create(struct mncc_call *mncc_call)
return mncc_call_tx_rtp_create(mncc_call);
}
/* Convert enum mgcp_codecs to an gsm_mncc_rtp->payload_msg_type value. */
uint32_t mgcp_codec_to_mncc_payload_msg_type(enum mgcp_codecs codec)
{
switch (codec) {
default:
/* disclaimer: i have no idea what i'm doing. */
case CODEC_GSM_8000_1:
return GSM_TCHF_FRAME;
case CODEC_GSMEFR_8000_1:
return GSM_TCHF_FRAME_EFR;
case CODEC_GSMHR_8000_1:
return GSM_TCHH_FRAME;
case CODEC_AMR_8000_1:
case CODEC_AMRWB_16000_1:
//return GSM_TCHF_FRAME;
return GSM_TCH_FRAME_AMR;
}
}
static bool mncc_call_tx_rtp_create(struct mncc_call *mncc_call)
{
if (!mncc_call->rtps || !osmo_sockaddr_str_is_nonzero(&mncc_call->rtps->local)) {
@ -314,8 +296,15 @@ static bool mncc_call_tx_rtp_create(struct mncc_call *mncc_call)
}
if (mncc_call->rtps->codec_known) {
mncc_msg.rtp.payload_type = 0; /* ??? */
mncc_msg.rtp.payload_msg_type = mgcp_codec_to_mncc_payload_msg_type(mncc_call->rtps->codec);
const struct codec_mapping *m = codec_mapping_by_mgcp_codec(mncc_call->rtps->codec);
if (!m) {
mncc_call_error(mncc_call, "Failed to resolve audio codec '%s'\n",
osmo_mgcpc_codec_name(mncc_call->rtps->codec));
return false;
}
mncc_msg.rtp.payload_type = m->sdp.payload_type;
mncc_msg.rtp.payload_msg_type = m->mncc_payload_msg_type;
}
if (mncc_call_tx(mncc_call, &mncc_msg))