From 9c72d193d8f5e98e38f6fc495afc5392dab1c09c Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 31 Oct 2022 17:57:30 +0100 Subject: [PATCH] MNCC: use codec_mapping, drop mgcp_codec_to_mncc_payload_msg_type() Change-Id: I8995ef43b9f79bc1db5672362c6433e4d96dd9e0 --- src/libmsc/gsm_04_08_cc.c | 11 +++++++++- src/libmsc/mncc_call.c | 31 ++++++++++------------------- tests/msc_vlr/msc_vlr_test_call.err | 20 +++++++++---------- 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c index 771ddbc1b..41066d74e 100644 --- a/src/libmsc/gsm_04_08_cc.c +++ b/src/libmsc/gsm_04_08_cc.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -1714,6 +1715,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"); @@ -1727,7 +1729,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); diff --git a/src/libmsc/mncc_call.c b/src/libmsc/mncc_call.c index c9a6d56a4..fbf96f387 100644 --- a/src/libmsc/mncc_call.c +++ b/src/libmsc/mncc_call.c @@ -35,6 +35,7 @@ #include #include #include +#include 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)) diff --git a/tests/msc_vlr/msc_vlr_test_call.err b/tests/msc_vlr/msc_vlr_test_call.err index 5ee71767b..c25c08389 100644 --- a/tests/msc_vlr/msc_vlr_test_call.err +++ b/tests/msc_vlr/msc_vlr_test_call.err @@ -314,8 +314,8 @@ DMSC dummy_msc_i(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_S - Assignment succeeds, triggering CRCX to CN DIUCS msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ){MSC_A_ST_COMMUNICATING}: RAN decode: ASSIGNMENT_COMPLETE DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483649:RTP_TO_RAN:no-CI){UNINITIALIZED}: setting codec to AMR/8000/1 -DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483649:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: setting remote addr to :0 -DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483649:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: Not committing: no MGW endpoint CI set up +DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483649:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: remote addr already :0, no change +DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483649:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: Not committing: no remote RTP address known MGW <--CRCX to RTP_TO_CN-- MSC: callref=0x80000001 DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ){UNINITIALIZED}: Allocated DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ){UNINITIALIZED}: is child of call_leg(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ) @@ -802,8 +802,8 @@ DMSC dummy_msc_i(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGI - Assignment completes, triggering CRCX to CN DIUCS msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){MSC_A_ST_COMMUNICATING}: RAN decode: ASSIGNMENT_COMPLETE DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP:trans-0:call-1059:RTP_TO_RAN:no-CI){UNINITIALIZED}: setting codec to AMR/8000/1 -DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP:trans-0:call-1059:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: setting remote addr to :0 -DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP:trans-0:call-1059:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: Not committing: no MGW endpoint CI set up +DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP:trans-0:call-1059:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: remote addr already :0, no change +DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP:trans-0:call-1059:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: Not committing: no remote RTP address known MGW <--CRCX to RTP_TO_CN-- MSC: callref=0x423 DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){UNINITIALIZED}: Allocated DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){UNINITIALIZED}: is child of call_leg(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP) @@ -1272,8 +1272,8 @@ DMSC dummy_msc_i(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGI - Assignment completes, triggering CRCX to CN DIUCS msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){MSC_A_ST_COMMUNICATING}: RAN decode: ASSIGNMENT_COMPLETE DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP:trans-0:call-1059:RTP_TO_RAN:no-CI){UNINITIALIZED}: setting codec to AMR/8000/1 -DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP:trans-0:call-1059:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: setting remote addr to :0 -DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP:trans-0:call-1059:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: Not committing: no MGW endpoint CI set up +DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP:trans-0:call-1059:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: remote addr already :0, no change +DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP:trans-0:call-1059:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: Not committing: no remote RTP address known MGW <--CRCX to RTP_TO_CN-- MSC: callref=0x423 DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){UNINITIALIZED}: Allocated DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){UNINITIALIZED}: is child of call_leg(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP) @@ -1681,8 +1681,8 @@ DMSC dummy_msc_i(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_S - Assignment succeeds, triggering CRCX to CN DIUCS msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ){MSC_A_ST_COMMUNICATING}: RAN decode: ASSIGNMENT_COMPLETE DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483650:RTP_TO_RAN:no-CI){UNINITIALIZED}: setting codec to AMR/8000/1 -DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483650:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: setting remote addr to :0 -DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483650:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: Not committing: no MGW endpoint CI set up +DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483650:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: remote addr already :0, no change +DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483650:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: Not committing: no remote RTP address known MGW <--CRCX to RTP_TO_CN-- MSC: callref=0x80000002 DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ){UNINITIALIZED}: Allocated DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ){UNINITIALIZED}: is child of call_leg(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ) @@ -2109,8 +2109,8 @@ DMSC dummy_msc_i(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_S - Assignment succeeds, triggering CRCX to CN DIUCS msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ){MSC_A_ST_COMMUNICATING}: RAN decode: ASSIGNMENT_COMPLETE DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483651:RTP_TO_RAN:no-CI){UNINITIALIZED}: setting codec to AMR/8000/1 -DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483651:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: setting remote addr to :0 -DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483651:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: Not committing: no MGW endpoint CI set up +DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483651:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: remote addr already :0, no change +DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ:trans-8:call-2147483651:RTP_TO_RAN:no-CI:local-10-23-23-1-23){UNINITIALIZED}: Not committing: no remote RTP address known MGW <--CRCX to RTP_TO_CN-- MSC: callref=0x80000003 DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ){UNINITIALIZED}: Allocated DCC rtp_stream(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ){UNINITIALIZED}: is child of call_leg(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ)