lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

November 2022

  • 2 participants
  • 2503 discussions
Change in osmo-msc[master]: [codecs filter] apply BSS codecs from Assignment Complete
by neels 13 Nov '22

13 Nov '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/30124 ) Change subject: [codecs filter] apply BSS codecs from Assignment Complete ...................................................................... [codecs filter] apply BSS codecs from Assignment Complete Codec List (BSS Supported) is received once in Complete Layer 3 and again in Assignment Complete messages. Use the most recent one, i.e. the one from Assignment Complete, when it occurs. Related: SYS#5066 Change-Id: I5e66ecc7987fa926f39d8be8eaf5799b931ab20a --- M src/libmsc/msc_a.c 1 file changed, 5 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/24/30124/1 diff --git a/src/libmsc/msc_a.c b/src/libmsc/msc_a.c index 484617e..12ddae3 100644 --- a/src/libmsc/msc_a.c +++ b/src/libmsc/msc_a.c @@ -47,6 +47,7 @@ #include <osmocom/msc/rtp_stream.h> #include <osmocom/msc/msc_ho.h> #include <osmocom/msc/codec_mapping.h> +#include <osmocom/msc/codec_filter.h> #define MSC_A_USE_WAIT_CLEAR_COMPLETE "wait-Clear-Complete" @@ -1353,6 +1354,10 @@ rtp_stream_commit(rtps_to_ran); + /* Remember the Codec List (BSS Supported) */ + if (ac->assignment_complete.codec_list_bss_supported) + codec_filter_set_bss(&cc_trans->cc.codecs, ac->assignment_complete.codec_list_bss_supported); + /* Setup CN side endpoint CI: * Now that * - the first CI has been created and a definitive endpoint name is assigned to the call_leg's MGW -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/30124 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: I5e66ecc7987fa926f39d8be8eaf5799b931ab20a Gerrit-Change-Number: 30124 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-msc[master]: [codecs filter] MT call: apply BSS codec list
by neels 13 Nov '22

13 Nov '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/30120 ) Change subject: [codecs filter] MT call: apply BSS codec list ...................................................................... [codecs filter] MT call: apply BSS codec list For MT call, initialize the codecs filter and apply the Codec List (BSS Supported) from Compl L3. Related: SYS#5066 Change-Id: I530409a64d11da48518a3dc60aa3a4e47c384663 --- M src/libmsc/gsm_04_08_cc.c 1 file changed, 10 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/20/30120/1 diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c index 032d9fe..5c7ff1f 100644 --- a/src/libmsc/gsm_04_08_cc.c +++ b/src/libmsc/gsm_04_08_cc.c @@ -674,6 +674,16 @@ gsm48_start_cc_timer(trans, 0x303, GSM48_T303); + /* MT call leg is starting. Gather all codecs information so far known. + * (Usually) paging has succeeded, and now we're processing the MNCC Setup from the remote MO call leg. + * Initialize the codecs filter with this side's BSS' codec list, received at Complete Layer 3. + * We must not pass bearer_cap to codec_filter_init(), because we haven't received the MT MS's Bearer + * Capabilities yet; the Bearer Capabilities handled here are actually the remote call leg's Bearer + * Capabilities. */ + codec_filter_init(&trans->cc.codecs); + codec_filter_set_ran(&trans->cc.codecs, trans->msc_a->c.ran->type); + codec_filter_set_bss(&trans->cc.codecs, &trans->msc_a->cc.compl_l3_codec_list_bss_supported); + /* bearer capability */ if (setup->fields & MNCC_F_BEARER_CAP) { /* Create a copy of the bearer capability in the transaction struct, so we -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/30120 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: I530409a64d11da48518a3dc60aa3a4e47c384663 Gerrit-Change-Number: 30120 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-msc[master]: [codecs filter] MT call: store MS Bearer Cap from CC Call Conf
by neels 13 Nov '22

13 Nov '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/30122 ) Change subject: [codecs filter] MT call: store MS Bearer Cap from CC Call Conf ...................................................................... [codecs filter] MT call: store MS Bearer Cap from CC Call Conf Related: SYS#5066 Change-Id: Ic3d0f05af57a493d500700c63b121c8114e7fbf4 --- M src/libmsc/gsm_04_08_cc.c 1 file changed, 4 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/22/30122/1 diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c index d12220d..649b533 100644 --- a/src/libmsc/gsm_04_08_cc.c +++ b/src/libmsc/gsm_04_08_cc.c @@ -800,6 +800,10 @@ * this information later */ memcpy(&trans->bearer_cap, &call_conf.bearer_cap, sizeof(trans->bearer_cap)); + + /* This is the MT call leg's Call Conf, containing the MS Bearer Capabilities of the MT MS. + * Store in codecs filter. */ + codec_filter_set_ms_from_bc(&trans->cc.codecs, &call_conf.bearer_cap); } /* cause */ -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/30122 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: Ic3d0f05af57a493d500700c63b121c8114e7fbf4 Gerrit-Change-Number: 30122 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-msc[master]: [codecs filter] MT call: apply remote call leg codecs
by neels 13 Nov '22

13 Nov '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/30121 ) Change subject: [codecs filter] MT call: apply remote call leg codecs ...................................................................... [codecs filter] MT call: apply remote call leg codecs Use either the SDP or the Bearer Capabilites indicated in the incoming MNCC to apply the remote call leg's codecs selection to the codecs filter. Use the codecs filter result for outgoing Bearer Capabilites. So far, we just forwarded the Bearer Capabilities received in MNCC from the remote call leg, and omitted Bearer Cap if the remote call leg did not provide any. Instead, always include Bearer Cap, and compose it from the codecs filter result. Hence the Bearer Cap is now an intersection of MS, BSS and remote call leg, instead of just the remote call leg. Related: SYS#5066 Change-Id: I84d9bbca3e4061da622b1b2fc0bde8868e7e3521 --- M src/libmsc/gsm_04_08_cc.c M tests/msc_vlr/msc_vlr_test_call.c M tests/msc_vlr/msc_vlr_test_call.err 3 files changed, 64 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/21/30121/1 diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c index 5c7ff1f..d12220d 100644 --- a/src/libmsc/gsm_04_08_cc.c +++ b/src/libmsc/gsm_04_08_cc.c @@ -639,6 +639,7 @@ struct gsm48_hdr *gh; struct gsm_mncc *setup = arg; int rc, trans_id; + struct gsm_mncc_bearer_cap bearer_cap; gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh)); @@ -683,14 +684,60 @@ codec_filter_init(&trans->cc.codecs); codec_filter_set_ran(&trans->cc.codecs, trans->msc_a->c.ran->type); codec_filter_set_bss(&trans->cc.codecs, &trans->msc_a->cc.compl_l3_codec_list_bss_supported); - - /* bearer capability */ - if (setup->fields & MNCC_F_BEARER_CAP) { - /* Create a copy of the bearer capability in the transaction struct, so we - * can use this information later */ - memcpy(&trans->bearer_cap, &setup->bearer_cap, sizeof(trans->bearer_cap)); - gsm48_encode_bearer_cap(msg, 0, &setup->bearer_cap); + /* sdp.remote: if SDP is included in the MNCC, take that as definitive list of remote audio codecs. */ + if (setup->sdp[0]) { + rc = sdp_msg_from_sdp_str(&trans->cc.codecs.remote, setup->sdp); + if (rc) + LOG_TRANS(trans, LOGL_ERROR, "Failed to parse remote call leg SDP: %d\n", rc); } + /* sdp.remote: if there is no SDP information or we failed to parse it, try using the Bearer Capability from + * MNCC, if any. */ + if (!trans->cc.codecs.remote.audio_codecs.count && (setup->fields & MNCC_F_BEARER_CAP)) { + trans->cc.codecs.remote = (struct sdp_msg){}; + sdp_audio_codecs_from_bearer_cap(&trans->cc.codecs.remote.audio_codecs, + &setup->bearer_cap); + } + LOG_TRANS(trans, LOGL_DEBUG, "codecs: %s\n", codec_filter_to_str(&trans->cc.codecs)); + if (!trans->cc.codecs.remote.audio_codecs.count) + LOG_TRANS(trans, LOGL_INFO, + "Got no information of remote audio codecs: neither SDP nor Bearer Capability. Trying anyway.\n"); + + codec_filter_run(&trans->cc.codecs); + LOG_TRANS(trans, LOGL_DEBUG, "codecs: %s\n", codec_filter_to_str(&trans->cc.codecs)); + + /* Compose Bearer Capability information that reflects only the codecs (Speech Versions) remaining after + * intersecting MS, BSS and remote call leg restrictions. To store in trans for later use, and to include in + * the outgoing CC Setup message. */ + bearer_cap = (struct gsm_mncc_bearer_cap){ + .speech_ver = { -1 }, + }; + sdp_audio_codecs_to_bearer_cap(&bearer_cap, &trans->cc.codecs.result.audio_codecs); + rc = bearer_cap_set_radio(&bearer_cap); + if (rc) { + LOG_TRANS(trans, LOGL_ERROR, "Error composing Bearer Capability for CC Setup\n"); + trans_free(trans); + msgb_free(msg); + return rc; + } + /* Create a copy of the bearer capability in the transaction struct, so we can use this information later */ + trans->bearer_cap = bearer_cap; + /* If no resulting codecs remain, error out. We cannot find a codec that matches both call legs. If the MGW were + * able to transcode, we could use non-identical codecs on each conn of the MGW endpoint, but we are aiming for + * finding a matching codec. */ + if (bearer_cap.speech_ver[0] == -1) { + LOG_TRANS(trans, LOGL_ERROR, "%s: no codec match possible: %s\n", + get_mncc_name(setup->msg_type), codec_filter_to_str(&trans->cc.codecs)); + + /* incompatible codecs */ + rc = mncc_release_ind(trans->net, trans, trans->callref, + GSM48_CAUSE_LOC_PRN_S_LU, + GSM48_CC_CAUSE_INCOMPAT_DEST /* TODO: correct cause code? */); + trans_free(trans); + msgb_free(msg); + return rc; + } + gsm48_encode_bearer_cap(msg, 0, &bearer_cap); + /* facility */ if (setup->fields & MNCC_F_FACILITY) gsm48_encode_facility(msg, 0, &setup->facility); diff --git a/tests/msc_vlr/msc_vlr_test_call.c b/tests/msc_vlr/msc_vlr_test_call.c index a547935..d169650 100644 --- a/tests/msc_vlr/msc_vlr_test_call.c +++ b/tests/msc_vlr/msc_vlr_test_call.c @@ -316,7 +316,7 @@ VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d"); btw("MS sends SecurityModeControl acceptance, VLR accepts, sends CC Setup"); - dtap_expect_tx("0305" /* CC: Setup */); + dtap_expect_tx("0305" /* CC: Setup */ "04 07 60 04 05 0b 06 08 87" /* Bearer Cap */); ms_sends_security_mode_complete(1); btw("MS confirms call, we create a RAN-side RTP and forward MNCC_CALL_CONF_IND"); @@ -419,7 +419,7 @@ VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d"); btw("MS sends SecurityModeControl acceptance, VLR accepts, sends CC Setup"); - dtap_expect_tx("0305" /* CC: Setup */); + dtap_expect_tx("0305" /* CC: Setup */ "04 07 60 04 05 0b 06 08 87" /* Bearer Cap */); ms_sends_security_mode_complete(1); btw("MS confirms call, we create a RAN-side RTP and forward MNCC_CALL_CONF_IND"); diff --git a/tests/msc_vlr/msc_vlr_test_call.err b/tests/msc_vlr/msc_vlr_test_call.err index 0018d86..1c0799c 100644 --- a/tests/msc_vlr/msc_vlr_test_call.err +++ b/tests/msc_vlr/msc_vlr_test_call.err @@ -761,10 +761,13 @@ DMSC msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){MSC_A_ST_AUTHENTICATED}: Received Event MSC_A_EV_TRANSACTION_ACCEPTED DMSC msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){MSC_A_ST_AUTHENTICATED}: state_chg to MSC_A_ST_COMMUNICATING DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP callref-0x423 tid-0) starting timer T303 with 30 seconds +DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP callref-0x423 tid-0) codecs: :0{(no-codecs)} (from: RAN={AMR:octet-align=1#112,AMR-WB:octet-align=1#113}) +DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP callref-0x423 tid-0) Got no information of remote audio codecs: neither SDP nor Bearer Capability. Trying anyway. +DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP callref-0x423 tid-0) codecs: :0{AMR:octet-align=1#112,AMR-WB:octet-align=1#113} (from: RAN={AMR:octet-align=1#112,AMR-WB:octet-align=1#113}) DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP callref-0x423 tid-0) new state NULL -> CALL_PRESENT DIUCS msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){MSC_A_ST_COMMUNICATING}: Sending DTAP: CC GSM48_MT_CC_SETUP DMSC msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){MSC_A_ST_COMMUNICATING}: RAN encode: DTAP on UTRAN-Iu -- DTAP --UTRAN-Iu--> MS: GSM48_MT_CC_SETUP: 0305 +- DTAP --UTRAN-Iu--> MS: GSM48_MT_CC_SETUP: 030504076004050b060887 - DTAP matches expected message DMSC dummy_msc_i(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){0}: Received Event MSC_I_EV_FROM_A_FORWARD_ACCESS_SIGNALLING_REQUEST DREF VLR subscr IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100 - Paging: now used by 3 (attached,CC,active-conn) @@ -1231,10 +1234,13 @@ DMSC msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){MSC_A_ST_AUTHENTICATED}: Received Event MSC_A_EV_TRANSACTION_ACCEPTED DMSC msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){MSC_A_ST_AUTHENTICATED}: state_chg to MSC_A_ST_COMMUNICATING DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP callref-0x423 tid-0) starting timer T303 with 30 seconds +DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP callref-0x423 tid-0) codecs: :0{(no-codecs)} (from: RAN={AMR:octet-align=1#112,AMR-WB:octet-align=1#113}) +DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP callref-0x423 tid-0) Got no information of remote audio codecs: neither SDP nor Bearer Capability. Trying anyway. +DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP callref-0x423 tid-0) codecs: :0{AMR:octet-align=1#112,AMR-WB:octet-align=1#113} (from: RAN={AMR:octet-align=1#112,AMR-WB:octet-align=1#113}) DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP callref-0x423 tid-0) new state NULL -> CALL_PRESENT DIUCS msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){MSC_A_ST_COMMUNICATING}: Sending DTAP: CC GSM48_MT_CC_SETUP DMSC msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){MSC_A_ST_COMMUNICATING}: RAN encode: DTAP on UTRAN-Iu -- DTAP --UTRAN-Iu--> MS: GSM48_MT_CC_SETUP: 0305 +- DTAP --UTRAN-Iu--> MS: GSM48_MT_CC_SETUP: 030504076004050b060887 - DTAP matches expected message DMSC dummy_msc_i(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:PAGING_RESP){0}: Received Event MSC_I_EV_FROM_A_FORWARD_ACCESS_SIGNALLING_REQUEST DREF VLR subscr IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100 - Paging: now used by 3 (attached,CC,active-conn) -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/30121 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: I84d9bbca3e4061da622b1b2fc0bde8868e7e3521 Gerrit-Change-Number: 30121 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-msc[master]: [codecs filter] add trans.cc.codecs
by neels 13 Nov '22

13 Nov '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/30117 ) Change subject: [codecs filter] add trans.cc.codecs ...................................................................... [codecs filter] add trans.cc.codecs Add the central codecs_filter for Call Control. Subsequent patches will start to populate the individual stages of this codec filter, one by one. Related: SYS#5066 Change-Id: Ib3fdeff8d1e1ea0760168d63ee6e1b1fb993aa5f --- M include/osmocom/msc/transaction.h 1 file changed, 3 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/17/30117/1 diff --git a/include/osmocom/msc/transaction.h b/include/osmocom/msc/transaction.h index 14b89bb..0966627 100644 --- a/include/osmocom/msc/transaction.h +++ b/include/osmocom/msc/transaction.h @@ -8,6 +8,7 @@ #include <osmocom/msc/mncc.h> #include <osmocom/msc/msc_a.h> #include <osmocom/msc/debug.h> +#include <osmocom/msc/codec_filter.h> #include <osmocom/gsm/gsm0411_smc.h> #include <osmocom/gsm/gsm0411_smr.h> @@ -101,6 +102,8 @@ struct gsm_mncc msg; /* stores setup/disconnect/release message */ bool mncc_initiated; /* Whether an MNCC Release is necessary on failure */ struct osmo_lcls *lcls; + /* Track codec choices from BSS and remote call leg */ + struct codec_filter codecs; } cc; struct { struct gsm411_smc_inst smc_inst; -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/30117 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: Ib3fdeff8d1e1ea0760168d63ee6e1b1fb993aa5f Gerrit-Change-Number: 30117 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-msc[master]: [codecs filter] store BSS codec list from Compl L3
by neels 13 Nov '22

13 Nov '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/30118 ) Change subject: [codecs filter] store BSS codec list from Compl L3 ...................................................................... [codecs filter] store BSS codec list from Compl L3 The initial Compl L3 happens long before we establish a CC transaction. Remember the Codec List (BSS Supported), so that we can feed the new codecs filter with it. Subsequent patches implement feeding the filter. Related: SYS#5066 Change-Id: I7cdc348218433141a43d2e42750af02591688240 --- M include/osmocom/msc/msc_a.h M src/libmsc/msc_a.c 2 files changed, 15 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/18/30118/1 diff --git a/include/osmocom/msc/msc_a.h b/include/osmocom/msc/msc_a.h index e56ea52..18eb76c 100644 --- a/include/osmocom/msc/msc_a.h +++ b/include/osmocom/msc/msc_a.h @@ -121,6 +121,9 @@ * \-------RTP--> (ISUP) <--RTP--> <--RTP--> */ struct { + /* Codec List (BSS Supported) as received during Complete Layer 3 Information */ + struct gsm0808_speech_codec_list compl_l3_codec_list_bss_supported; + /* All of the RTP stream handling */ struct call_leg *call_leg; struct mncc_call *mncc_forwarding_to_remote_ran; diff --git a/src/libmsc/msc_a.c b/src/libmsc/msc_a.c index d7e97cd..484617e 100644 --- a/src/libmsc/msc_a.c +++ b/src/libmsc/msc_a.c @@ -46,6 +46,7 @@ #include <osmocom/msc/call_leg.h> #include <osmocom/msc/rtp_stream.h> #include <osmocom/msc/msc_ho.h> +#include <osmocom/msc/codec_mapping.h> #define MSC_A_USE_WAIT_CLEAR_COMPLETE "wait-Clear-Complete" @@ -1442,6 +1443,17 @@ .lai.plmn = msc_a_net(msc_a)->plmn, }; gsm0808_cell_id_to_cgi(&msc_a->via_cell, msg->compl_l3.cell_id); + /* If a codec list was sent along in the RAN_MSG_COMPL_L3, remember it for any upcoming codec + * resolution. */ + if (msg->compl_l3.codec_list_bss_supported) { + msc_a->cc.compl_l3_codec_list_bss_supported = *msg->compl_l3.codec_list_bss_supported; + if (log_check_level(msc_a->c.ran->log_subsys, LOGL_DEBUG)) { + struct sdp_audio_codecs ac = {}; + sdp_audio_codecs_from_speech_codec_list(&ac, &msc_a->cc.compl_l3_codec_list_bss_supported); + LOG_MSC_A(msc_a, LOGL_DEBUG, "Complete Layer 3: Codec List (BSS Supported): %s\n", + sdp_audio_codecs_to_str(&ac)); + } + } rc = msc_a_up_l3(msc_a, msg->compl_l3.msg); if (!rc) { struct ran_conn *conn = msub_ran_conn(msc_a->c.msub); -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/30118 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: I7cdc348218433141a43d2e42750af02591688240 Gerrit-Change-Number: 30118 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-msc[master]: [codecs filter] MO call: apply BSS codec list
by neels 13 Nov '22

13 Nov '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/30119 ) Change subject: [codecs filter] MO call: apply BSS codec list ...................................................................... [codecs filter] MO call: apply BSS codec list Related: SYS#5066 Change-Id: I062268406ae3f3a63a7f413db51c509c9eaf9e8a --- M src/libmsc/gsm_04_08_cc.c M tests/msc_vlr/msc_vlr_test_call.err 2 files changed, 12 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/19/30119/1 diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c index 41066d7..032d9fe 100644 --- a/src/libmsc/gsm_04_08_cc.c +++ b/src/libmsc/gsm_04_08_cc.c @@ -610,8 +610,17 @@ new_cc_state(trans, GSM_CSTATE_INITIATED); + /* MO call leg starting, gather all codec information so far known: */ + codec_filter_init(&trans->cc.codecs); + codec_filter_set_ran(&trans->cc.codecs, trans->msc_a->c.ran->type); + codec_filter_set_bss(&trans->cc.codecs, &trans->msc_a->cc.compl_l3_codec_list_bss_supported); + if (setup.fields & MNCC_F_BEARER_CAP) + codec_filter_set_ms_from_bc(&trans->cc.codecs, &trans->bearer_cap); + codec_filter_run(&trans->cc.codecs); + LOG_TRANS(trans, setup.emergency ? LOGL_NOTICE : LOGL_INFO, "%sSETUP to %s\n", setup.emergency ? "EMERGENCY_" : "", setup.called.number); + LOG_TRANS(trans, LOGL_DEBUG, "codecs: %s\n", codec_filter_to_str(&trans->cc.codecs)); rate_ctr_inc(rate_ctr_group_get_ctr(trans->net->msc_ctrs, MSC_CTR_CALL_MO_SETUP)); diff --git a/tests/msc_vlr/msc_vlr_test_call.err b/tests/msc_vlr/msc_vlr_test_call.err index c25c083..0018d86 100644 --- a/tests/msc_vlr/msc_vlr_test_call.err +++ b/tests/msc_vlr/msc_vlr_test_call.err @@ -290,6 +290,7 @@ DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000001 tid-8) starting guard timer with 180 seconds DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000001 tid-8) new state NULL -> INITIATED DCC trans(CC:INITIATED IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000001 tid-8) SETUP to 123 +DCC trans(CC:INITIATED IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000001 tid-8) codecs: :0{AMR:octet-align=1#112} (from: MS={AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111} RAN={AMR:octet-align=1#112,AMR-WB:octet-align=1#113}) DMNCC trans(CC:INITIATED IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000001 tid-8) tx MNCC_SETUP_IND MSC --> MNCC: callref 0x80000001: MNCC_SETUP_IND DREF msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ){MSC_A_ST_COMMUNICATING}: - rx_from_ms: now used by 1 (cc) @@ -1657,6 +1658,7 @@ DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000002 tid-8) starting guard timer with 180 seconds DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000002 tid-8) new state NULL -> INITIATED DCC trans(CC:INITIATED IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000002 tid-8) SETUP to 123 +DCC trans(CC:INITIATED IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000002 tid-8) codecs: :0{AMR:octet-align=1#112} (from: MS={AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111} RAN={AMR:octet-align=1#112,AMR-WB:octet-align=1#113}) DMNCC trans(CC:INITIATED IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000002 tid-8) tx MNCC_SETUP_IND MSC --> MNCC: callref 0x80000002: MNCC_SETUP_IND DREF msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ){MSC_A_ST_COMMUNICATING}: - rx_from_ms: now used by 1 (cc) @@ -2085,6 +2087,7 @@ DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000003 tid-8) starting guard timer with 180 seconds DCC trans(CC:NULL IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000003 tid-8) new state NULL -> INITIATED DCC trans(CC:INITIATED IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000003 tid-8) SETUP to 123 +DCC trans(CC:INITIATED IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000003 tid-8) codecs: :0{AMR:octet-align=1#112} (from: MS={AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111} RAN={AMR:octet-align=1#112,AMR-WB:octet-align=1#113}) DMNCC trans(CC:INITIATED IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ callref-0x80000003 tid-8) tx MNCC_SETUP_IND MSC --> MNCC: callref 0x80000003: MNCC_SETUP_IND DREF msc_a(IMSI-901700000010650:MSISDN-42342:TMSI-0x03020100:UTRAN-Iu:CM_SERVICE_REQ){MSC_A_ST_COMMUNICATING}: - rx_from_ms: now used by 1 (cc) -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/30119 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: I062268406ae3f3a63a7f413db51c509c9eaf9e8a Gerrit-Change-Number: 30119 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-msc[master]: MNCC: use codec_mapping, drop mgcp_codec_to_mncc_payload_msg_type()
by neels 13 Nov '22

13 Nov '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/30115 ) Change subject: MNCC: use codec_mapping, drop mgcp_codec_to_mncc_payload_msg_type() ...................................................................... MNCC: use codec_mapping, drop mgcp_codec_to_mncc_payload_msg_type() Change-Id: I8995ef43b9f79bc1db5672362c6433e4d96dd9e0 --- M src/libmsc/gsm_04_08_cc.c M src/libmsc/mncc_call.c M tests/msc_vlr/msc_vlr_test_call.err 3 files changed, 30 insertions(+), 32 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/15/30115/1 diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c index 771ddbc..41066d7 100644 --- a/src/libmsc/gsm_04_08_cc.c +++ b/src/libmsc/gsm_04_08_cc.c @@ -55,6 +55,7 @@ #include <osmocom/msc/rtp_stream.h> #include <osmocom/msc/mncc_call.h> #include <osmocom/msc/msc_t.h> +#include <osmocom/msc/codec_mapping.h> #include <osmocom/gsm/gsm48.h> #include <osmocom/gsm/gsm0480.h> @@ -1714,6 +1715,7 @@ 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 @@ } /* 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 c9a6d56..fbf96f3 100644 --- a/src/libmsc/mncc_call.c +++ b/src/libmsc/mncc_call.c @@ -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 @@ 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 @@ } 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 5ee7176..c25c083 100644 --- a/tests/msc_vlr/msc_vlr_test_call.err +++ b/tests/msc_vlr/msc_vlr_test_call.err @@ -314,8 +314,8 @@ - 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 @@ - 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 @@ - 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 @@ - 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 @@ - 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) -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/30115 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: I8995ef43b9f79bc1db5672362c6433e4d96dd9e0 Gerrit-Change-Number: 30115 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-msc[master]: add codec_mapping.h,c
by neels 13 Nov '22

13 Nov '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/30114 ) Change subject: add codec_mapping.h,c ...................................................................... add codec_mapping.h,c Converting between different codec representations is confusing. This codec mapping provides a consolidated overview of all our codec representations, and how they match up. In particular, it adds the SDP codec representation repertoire, preparing the use of full SDP on the MNCC interface. Related: SYS#5066 Change-Id: Iaa307be6a8487aa8d4ba7cd59d5c5ef04818a744 --- M include/osmocom/msc/Makefile.am A include/osmocom/msc/codec_mapping.h M src/libmsc/Makefile.am A src/libmsc/codec_mapping.c 4 files changed, 568 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/14/30114/1 diff --git a/include/osmocom/msc/Makefile.am b/include/osmocom/msc/Makefile.am index adda44c..80f8972 100644 --- a/include/osmocom/msc/Makefile.am +++ b/include/osmocom/msc/Makefile.am @@ -1,6 +1,7 @@ noinst_HEADERS = \ call_leg.h \ cell_id_list.h \ + codec_mapping.h \ db.h \ debug.h \ e_link.h \ diff --git a/include/osmocom/msc/codec_mapping.h b/include/osmocom/msc/codec_mapping.h new file mode 100644 index 0000000..cba086a --- /dev/null +++ b/include/osmocom/msc/codec_mapping.h @@ -0,0 +1,68 @@ +/* Routines for translation between codec representations: SDP, CC/BSSMAP variants, MGCP, MNCC */ +#pragma once + +#include <osmocom/gsm/protocol/gsm_04_08.h> +#include <osmocom/gsm/protocol/gsm_08_08.h> +#include <osmocom/mgcp_client/mgcp_client.h> +#include <osmocom/msc/sdp_msg.h> +#include <osmocom/gsm/mncc.h> + +#define NO_MGCP_CODEC 0xffffffff + +extern const struct gsm_mncc_bearer_cap bearer_cap_empty; + +enum codec_frhr { + CODEC_FRHR_NONE = 0, + CODEC_FRHR_FR, + CODEC_FRHR_HR, +}; + +struct codec_mapping { + /* The sdp.payload_type number in a mapping is not necessarily imperative, but may just reflect the usual + * payload type number for a given codec. */ + struct sdp_audio_codec sdp; + /* The id that mgcp_client.h uses for this codec. Must be set in each mapping, because 0 means PCMU. */ + enum mgcp_codecs mgcp; + /* Nr of used entries in speech_ver[] below. */ + unsigned int speech_ver_count; + /* Entries to add to Speech Version lists when this codec is present, if any. */ + enum gsm48_bcap_speech_ver speech_ver[8]; + /* If applicable, one of GSM_TCHF_FRAME, GSM_TCHF_FRAME_EFR, GSM_TCHH_FRAME, GSM_TCH_FRAME_AMR; or zero. */ + uint32_t mncc_payload_msg_type; + /* Set to true if gsm0808_speech_codec below reflects a meaningful value. */ + bool has_gsm0808_speech_codec; + struct gsm0808_speech_codec gsm0808_speech_codec; + /* If applicable, entries to add to Permitted Speech lists when this codec is present; or zero. */ + enum gsm0808_permitted_speech perm_speech; + /* If applicable, indicator whether this codec can work on a GERAN half-rate lchan, or whether full-rate is + * required. Leave zero when this codec does not apply to GERAN. */ + enum codec_frhr frhr; +}; + +extern const struct codec_mapping codec_map[]; +#define foreach_codec_mapping(CODEC_MAPPING) \ + for ((CODEC_MAPPING) = codec_map; (CODEC_MAPPING) < codec_map + ARRAY_SIZE(codec_map); (CODEC_MAPPING)++) + +const struct codec_mapping *codec_mapping_by_speech_ver(enum gsm48_bcap_speech_ver speech_ver); +const struct codec_mapping *codec_mapping_by_gsm0808_speech_codec_type(enum gsm0808_speech_codec_type sct, + uint16_t cfg); +const struct codec_mapping *codec_mapping_by_perm_speech(enum gsm0808_permitted_speech perm_speech); +const struct codec_mapping *codec_mapping_by_subtype_name(const char *subtype_name); +const struct codec_mapping *codec_mapping_by_mgcp_codec(enum mgcp_codecs mgcp); + +int bearer_cap_add_speech_ver(struct gsm_mncc_bearer_cap *bearer_cap, enum gsm48_bcap_speech_ver speech_ver); +int sdp_audio_codec_add_to_bearer_cap(struct gsm_mncc_bearer_cap *bearer_cap, const struct sdp_audio_codec *codec); +int sdp_audio_codecs_to_bearer_cap(struct gsm_mncc_bearer_cap *bearer_cap, const struct sdp_audio_codecs *ac); +int bearer_cap_set_radio(struct gsm_mncc_bearer_cap *bearer_cap); + +struct sdp_audio_codec *sdp_audio_codecs_add_speech_ver(struct sdp_audio_codecs *ac, + enum gsm48_bcap_speech_ver speech_ver); +struct sdp_audio_codec *sdp_audio_codecs_add_mgcp_codec(struct sdp_audio_codecs *ac, enum mgcp_codecs mgcp_codec); +void sdp_audio_codecs_from_bearer_cap(struct sdp_audio_codecs *ac, const struct gsm_mncc_bearer_cap *bc); + +void sdp_audio_codecs_to_speech_codec_list(struct gsm0808_speech_codec_list *cl, const struct sdp_audio_codecs *ac); +void sdp_audio_codecs_from_speech_codec_list(struct sdp_audio_codecs *ac, const struct gsm0808_speech_codec_list *cl); + +int sdp_audio_codecs_to_gsm0808_channel_type(struct gsm0808_channel_type *ct, const struct sdp_audio_codecs *ac); + +enum mgcp_codecs sdp_audio_codec_to_mgcp_codec(const struct sdp_audio_codec *codec); diff --git a/src/libmsc/Makefile.am b/src/libmsc/Makefile.am index de02a17..c7fe4bb 100644 --- a/src/libmsc/Makefile.am +++ b/src/libmsc/Makefile.am @@ -27,6 +27,7 @@ libmsc_a_SOURCES = \ call_leg.c \ cell_id_list.c \ + codec_mapping.c \ sccp_ran.c \ msc_vty.c \ db.c \ diff --git a/src/libmsc/codec_mapping.c b/src/libmsc/codec_mapping.c new file mode 100644 index 0000000..56574b1 --- /dev/null +++ b/src/libmsc/codec_mapping.c @@ -0,0 +1,498 @@ +/* Routines for translation between codec representations: SDP, CC/BSSMAP variants, MGCP, MNCC */ +/* + * (C) 2019-2022 by sysmocom - s.m.f.c. GmbH <info(a)sysmocom.de> + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include <string.h> + +#include <osmocom/gsm/mncc.h> + +#include <osmocom/msc/sdp_msg.h> +#include <osmocom/msc/codec_mapping.h> +#include <osmocom/msc/mncc.h> + +const struct codec_mapping codec_map[] = { + /* FIXME: I'm not sure about OFR, OHR -- O means octet-aligned?? */ + /* FIXME: sdp.fmtp handling is not done properly yet, proper mode-set and octet-align handling will follow in + * separate patches. */ + { + .sdp = { + .payload_type = 0, + .subtype_name = "PCMU", + .rate = 8000, + }, + .mgcp = CODEC_PCMU_8000_1, + }, + { + .sdp = { + .payload_type = 3, + .subtype_name = "GSM", + .rate = 8000, + }, + .mgcp = CODEC_GSM_8000_1, + .speech_ver_count = 1, + .speech_ver = { GSM48_BCAP_SV_FR }, + .mncc_payload_msg_type = GSM_TCHF_FRAME, + .has_gsm0808_speech_codec = true, + .gsm0808_speech_codec = { + .fi = true, + .type = GSM0808_SCT_FR1, + }, + .perm_speech = GSM0808_PERM_FR1, + .frhr = CODEC_FRHR_FR, + }, + { + .sdp = { + .payload_type = 8, + .subtype_name = "PCMA", + .rate = 8000, + }, + .mgcp = CODEC_PCMA_8000_1, + }, + { + .sdp = { + .payload_type = 18, + .subtype_name = "G729", + .rate = 8000, + }, + .mgcp = CODEC_G729_8000_1, + }, + { + .sdp = { + .payload_type = 110, + .subtype_name = "GSM-EFR", + .rate = 8000, + }, + .mgcp = CODEC_GSMEFR_8000_1, + .speech_ver_count = 1, + .speech_ver = { GSM48_BCAP_SV_EFR }, + .mncc_payload_msg_type = GSM_TCHF_FRAME_EFR, + .has_gsm0808_speech_codec = true, + .gsm0808_speech_codec = { + .fi = true, + .type = GSM0808_SCT_FR2, + }, + .perm_speech = GSM0808_PERM_FR2, + .frhr = CODEC_FRHR_FR, + }, + { + .sdp = { + .payload_type = 111, + .subtype_name = "GSM-HR-08", + .rate = 8000, + }, + .mgcp = CODEC_GSMHR_8000_1, + .speech_ver_count = 1, + .speech_ver = { GSM48_BCAP_SV_HR }, + .mncc_payload_msg_type = GSM_TCHH_FRAME, + .has_gsm0808_speech_codec = true, + .gsm0808_speech_codec = { + .fi = true, + .type = GSM0808_SCT_HR1, + .cfg = GSM0808_SC_CFG_DEFAULT_HR_AMR, + }, + .perm_speech = GSM0808_PERM_HR1, + .frhr = CODEC_FRHR_HR, + }, + { + .sdp = { + .payload_type = 112, + .subtype_name = "AMR", + .rate = 8000, + /* AMR is always octet-aligned in 2G and 3G RAN, so this fmtp is signalled to remote call legs. + * So far, fmtp is ignored in incoming SIP SDP, so an incoming SDP without 'octet-align=1' will + * match with this entry; we will still reply with 'octet-align=1', which often works out. */ + .fmtp = "octet-align=1", + }, + .mgcp = CODEC_AMR_8000_1, + .speech_ver_count = 1, + .speech_ver = { GSM48_BCAP_SV_AMR_F }, + .mncc_payload_msg_type = GSM_TCH_FRAME_AMR, + .has_gsm0808_speech_codec = true, + .gsm0808_speech_codec = { + .fi = true, + .type = GSM0808_SCT_FR3, + .cfg = GSM0808_SC_CFG_DEFAULT_FR_AMR, + }, + .perm_speech = GSM0808_PERM_FR3, + .frhr = CODEC_FRHR_FR, + }, + { + /* Another entry like the above, to map HR3 to AMR, too. */ + .sdp = { + .payload_type = 112, + .subtype_name = "AMR", + .rate = 8000, + .fmtp = "octet-align=1", + }, + .mgcp = CODEC_AMR_8000_1, + .speech_ver_count = 2, + .speech_ver = { GSM48_BCAP_SV_AMR_H, GSM48_BCAP_SV_AMR_OH }, + .mncc_payload_msg_type = GSM_TCH_FRAME_AMR, + .has_gsm0808_speech_codec = true, + .gsm0808_speech_codec = { + .fi = true, + .type = GSM0808_SCT_HR3, + .cfg = GSM0808_SC_CFG_DEFAULT_HR_AMR, + }, + .perm_speech = GSM0808_PERM_HR3, + .frhr = CODEC_FRHR_HR, + }, + { + .sdp = { + .payload_type = 113, + .subtype_name = "AMR-WB", + .rate = 16000, + .fmtp = "octet-align=1", + }, + .mgcp = CODEC_AMRWB_16000_1, + .speech_ver_count = 2, + .speech_ver = { GSM48_BCAP_SV_AMR_OFW, GSM48_BCAP_SV_AMR_FW }, + .mncc_payload_msg_type = GSM_TCH_FRAME_AMR, + .has_gsm0808_speech_codec = true, + .gsm0808_speech_codec = { + .fi = true, + .type = GSM0808_SCT_FR5, + .cfg = GSM0808_SC_CFG_DEFAULT_FR_AMR_WB, + }, + .perm_speech = GSM0808_PERM_FR5, + .frhr = CODEC_FRHR_FR, + }, + { + /* Another entry like the above, to map HR4 to AMR-WB, too. */ + .sdp = { + .payload_type = 113, + .subtype_name = "AMR-WB", + .rate = 16000, + .fmtp = "octet-align=1", + }, + .mgcp = CODEC_AMRWB_16000_1, + .speech_ver_count = 1, + .speech_ver = { GSM48_BCAP_SV_AMR_OHW }, + .mncc_payload_msg_type = GSM_TCH_FRAME_AMR, + .has_gsm0808_speech_codec = true, + .gsm0808_speech_codec = { + .fi = true, + .type = GSM0808_SCT_HR4, + .cfg = GSM0808_SC_CFG_DEFAULT_OHR_AMR_WB, + }, + .perm_speech = GSM0808_PERM_HR4, + .frhr = CODEC_FRHR_HR, + }, + { + .sdp = { + .payload_type = 96, + .subtype_name = "VND.3GPP.IUFP", + .rate = 16000, + }, + .mgcp = CODEC_IUFP, + }, +}; + +const struct gsm_mncc_bearer_cap bearer_cap_empty = { + .speech_ver = { -1 }, + }; + +const struct codec_mapping *codec_mapping_by_speech_ver(enum gsm48_bcap_speech_ver speech_ver) +{ + const struct codec_mapping *m; + foreach_codec_mapping(m) { + int i; + for (i = 0; i < m->speech_ver_count; i++) + if (m->speech_ver[i] == speech_ver) + return m; + } + return NULL; +} + + +const struct codec_mapping *codec_mapping_by_gsm0808_speech_codec_type(enum gsm0808_speech_codec_type sct, uint16_t cfg) +{ + const struct codec_mapping *m; + foreach_codec_mapping(m) { + if (!m->has_gsm0808_speech_codec) + continue; + if (m->gsm0808_speech_codec.type == sct) + return m; + /* TODO: evaluate cfg bits? */ + } + return NULL; +} + +const struct codec_mapping *codec_mapping_by_perm_speech(enum gsm0808_permitted_speech perm_speech) +{ + const struct codec_mapping *m; + foreach_codec_mapping(m) { + if (m->perm_speech == perm_speech) + return m; + } + return NULL; +} + +const struct codec_mapping *codec_mapping_by_subtype_name(const char *subtype_name) +{ + const struct codec_mapping *m; + foreach_codec_mapping(m) { + if (!strcmp(m->sdp.subtype_name, subtype_name)) + return m; + } + return NULL; +} + +const struct codec_mapping *codec_mapping_by_mgcp_codec(enum mgcp_codecs mgcp) +{ + const struct codec_mapping *m; + foreach_codec_mapping(m) { + if (m->mgcp == mgcp) + return m; + } + return NULL; +} + +/* Append given Speech Version to the end of the Bearer Capabilities Speech Version array. Return 1 if added, zero + * otherwise (as in, return the number of items added). */ +int bearer_cap_add_speech_ver(struct gsm_mncc_bearer_cap *bearer_cap, enum gsm48_bcap_speech_ver speech_ver) +{ + int i; + for (i = 0; i < ARRAY_SIZE(bearer_cap->speech_ver) - 1; i++) { + if (bearer_cap->speech_ver[i] == speech_ver) + return 0; + if (bearer_cap->speech_ver[i] == -1) { + bearer_cap->speech_ver[i] = speech_ver; + bearer_cap->speech_ver[i+1] = -1; + return 1; + } + } + return 0; +} + +/* From the current speech_ver list present in the bearer_cap, set the bearer_cap.radio. + * If a HR speech_ver is present, set to GSM48_BCAP_RRQ_DUAL_FR, otherwise set to GSM48_BCAP_RRQ_FR_ONLY. */ +int bearer_cap_set_radio(struct gsm_mncc_bearer_cap *bearer_cap) +{ + bool hr_present; + int i; + for (i = 0; i < ARRAY_SIZE(bearer_cap->speech_ver) - 1; i++) { + const struct codec_mapping *m = codec_mapping_by_speech_ver(bearer_cap->speech_ver[i]); + + if (!m) + continue; + + if (m->frhr == CODEC_FRHR_HR) + hr_present = true; + } + + if (hr_present) + bearer_cap->radio = GSM48_BCAP_RRQ_DUAL_FR; + else + bearer_cap->radio = GSM48_BCAP_RRQ_FR_ONLY; + + return 0; +} + +/* Try to convert the SDP audio codec name to Speech Versions to append to Bearer Capabilities. + * Return the number of Speech Version entries added (some may add more than one, others may be unknown/unapplicable and + * return 0). */ +int sdp_audio_codec_add_to_bearer_cap(struct gsm_mncc_bearer_cap *bearer_cap, const struct sdp_audio_codec *codec) +{ + const struct codec_mapping *m; + int added = 0; + foreach_codec_mapping(m) { + int i; + if (strcmp(m->sdp.subtype_name, codec->subtype_name)) + continue; + /* TODO also match rate and fmtp? */ + for (i = 0; i < m->speech_ver_count; i++) { + added += bearer_cap_add_speech_ver(bearer_cap, m->speech_ver[i]); + } + } + return added; +} + +/* Append all audio codecs found in given sdp_msg to Bearer Capability, by traversing all codec entries with + * sdp_audio_codec_add_to_bearer_cap(). Return the number of Speech Version entries added. + * Note that Speech Version entries are only appended, no previous entries are removed. + * Note that only the Speech Version entries are modified; to make a valid Bearer Capabiliy, at least bearer_cap->radio + * must also be set (before or after this function); see also bearer_cap_set_radio(). */ +int sdp_audio_codecs_to_bearer_cap(struct gsm_mncc_bearer_cap *bearer_cap, const struct sdp_audio_codecs *ac) +{ + const struct sdp_audio_codec *codec; + int added = 0; + + foreach_sdp_audio_codec(codec, ac) { + added += sdp_audio_codec_add_to_bearer_cap(bearer_cap, codec); + } + + return added; +} + +/* Convert Speech Version to SDP audio codec and append to SDP message struct. */ +struct sdp_audio_codec *sdp_audio_codecs_add_speech_ver(struct sdp_audio_codecs *ac, + enum gsm48_bcap_speech_ver speech_ver) +{ + const struct codec_mapping *m; + struct sdp_audio_codec *ret = NULL; + foreach_codec_mapping(m) { + int i; + for (i = 0; i < m->speech_ver_count; i++) { + if (m->speech_ver[i] == speech_ver) { + ret = sdp_audio_codecs_add_copy(ac, &m->sdp); + break; + } + } + } + return ret; +} + +struct sdp_audio_codec *sdp_audio_codecs_add_mgcp_codec(struct sdp_audio_codecs *ac, enum mgcp_codecs mgcp_codec) +{ + const struct codec_mapping *m = codec_mapping_by_mgcp_codec(mgcp_codec); + if (!m) + return NULL; + return sdp_audio_codecs_add_copy(ac, &m->sdp); +} + +void sdp_audio_codecs_from_bearer_cap(struct sdp_audio_codecs *ac, const struct gsm_mncc_bearer_cap *bc) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(bc->speech_ver); i++) { + if (bc->speech_ver[i] == -1) + break; + sdp_audio_codecs_add_speech_ver(ac, bc->speech_ver[i]); + } +} + +void sdp_audio_codecs_to_speech_codec_list(struct gsm0808_speech_codec_list *scl, const struct sdp_audio_codecs *ac) +{ + const struct sdp_audio_codec *codec; + + *scl = (struct gsm0808_speech_codec_list){}; + + foreach_sdp_audio_codec(codec, ac) { + const struct codec_mapping *m = codec_mapping_by_subtype_name(codec->subtype_name); + if (!m) + continue; + if (!m->has_gsm0808_speech_codec) + continue; + if (scl->len >= ARRAY_SIZE(scl->codec)) + break; + scl->codec[scl->len] = m->gsm0808_speech_codec; + /* FIXME: apply AMR configuration according to codec->fmtp */ + scl->len++; + } +} + +void sdp_audio_codecs_from_speech_codec_list(struct sdp_audio_codecs *ac, const struct gsm0808_speech_codec_list *cl) +{ + int i; + for (i = 0; i < cl->len; i++) { + const struct gsm0808_speech_codec *sc = &cl->codec[i]; + const struct codec_mapping *m = codec_mapping_by_gsm0808_speech_codec_type(sc->type, sc->cfg); + if (!m) + continue; + sdp_audio_codecs_add_copy(ac, &m->sdp); + /* FIXME: for AMR, apply sc->cfg to the added codec's fmtp */ + } +} + +int sdp_audio_codecs_to_gsm0808_channel_type(struct gsm0808_channel_type *ct, const struct sdp_audio_codecs *ac) +{ + const struct sdp_audio_codec *codec; + bool fr_present = false; + int first_fr_idx = -1; + bool hr_present = false; + int first_hr_idx = -1; + int idx = -1; + + *ct = (struct gsm0808_channel_type){ + .ch_indctr = GSM0808_CHAN_SPEECH, + }; + + foreach_sdp_audio_codec(codec, ac) { + const struct codec_mapping *m; + int i; + bool dup; + idx++; + foreach_codec_mapping(m) { + if (strcmp(m->sdp.subtype_name, codec->subtype_name)) + continue; + + switch (m->perm_speech) { + default: + continue; + + case GSM0808_PERM_FR1: + case GSM0808_PERM_FR2: + case GSM0808_PERM_FR3: + case GSM0808_PERM_FR4: + case GSM0808_PERM_FR5: + fr_present = true; + if (first_fr_idx < 0) + first_fr_idx = idx; + break; + + case GSM0808_PERM_HR1: + case GSM0808_PERM_HR2: + case GSM0808_PERM_HR3: + case GSM0808_PERM_HR4: + case GSM0808_PERM_HR6: + hr_present = true; + if (first_hr_idx < 0) + first_hr_idx = idx; + break; + } + + /* Avoid duplicates */ + dup = false; + for (i = 0; i < ct->perm_spch_len; i++) { + if (ct->perm_spch[i] == m->perm_speech) { + dup = true; + break; + } + } + if (dup) + continue; + + ct->perm_spch[ct->perm_spch_len] = m->perm_speech; + ct->perm_spch_len++; + } + } + + if (fr_present && hr_present) { + if (first_fr_idx <= first_hr_idx) + ct->ch_rate_type = GSM0808_SPEECH_FULL_PREF; + else + ct->ch_rate_type = GSM0808_SPEECH_HALF_PREF; + } else if (fr_present && !hr_present) + ct->ch_rate_type = GSM0808_SPEECH_FULL_BM; + else if (!fr_present && hr_present) + ct->ch_rate_type = GSM0808_SPEECH_HALF_LM; + else + return -EINVAL; + return 0; +} + +enum mgcp_codecs sdp_audio_codec_to_mgcp_codec(const struct sdp_audio_codec *codec) +{ + const struct codec_mapping *m; + foreach_codec_mapping(m) { + if (!sdp_audio_codec_cmp(&m->sdp, codec, false, false)) + return m->mgcp; + } + return NO_MGCP_CODEC; +} -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/30114 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: Iaa307be6a8487aa8d4ba7cd59d5c5ef04818a744 Gerrit-Change-Number: 30114 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-msc[master]: [codecs filter] add codec_filter.h,c
by neels 13 Nov '22

13 Nov '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/30116 ) Change subject: [codecs filter] add codec_filter.h,c ...................................................................... [codecs filter] add codec_filter.h,c Add the infrastructure to store and filter all codec limitiations from the different stages: MS, BSS, CN and remote call leg. Upcoming patches will properly collect these and find an optimal codec. No functional change, yet. Related: SYS#5066 Change-Id: I4d90f7ca62f2307a7b93dd164aeecbf4bd98ff0a --- M include/osmocom/msc/Makefile.am A include/osmocom/msc/codec_filter.h M src/libmsc/Makefile.am A src/libmsc/codec_filter.c 4 files changed, 279 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/16/30116/1 diff --git a/include/osmocom/msc/Makefile.am b/include/osmocom/msc/Makefile.am index 80f8972..34b4902 100644 --- a/include/osmocom/msc/Makefile.am +++ b/include/osmocom/msc/Makefile.am @@ -1,6 +1,7 @@ noinst_HEADERS = \ call_leg.h \ cell_id_list.h \ + codec_filter.h \ codec_mapping.h \ db.h \ debug.h \ diff --git a/include/osmocom/msc/codec_filter.h b/include/osmocom/msc/codec_filter.h new file mode 100644 index 0000000..16315c7 --- /dev/null +++ b/include/osmocom/msc/codec_filter.h @@ -0,0 +1,66 @@ +/* Filter/overlay codec selections for a voice call, across MS, RAN and CN limitations */ +/* + * (C) 2019-2022 by sysmocom - s.m.f.c. GmbH <info(a)sysmocom.de> + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#pragma once + +#include <osmocom/gsm/gsm_utils.h> +#include <osmocom/gsm/mncc.h> +#include <osmocom/mgcp_client/mgcp_client.h> + +#include <osmocom/msc/sdp_msg.h> + +struct gsm0808_speech_codec_list; + +/* Combine various codec selections to obtain a resulting set of codecs allowed by all of them. + * Members reflect the different entities/stages that select codecs in a voice call. + * Call codec_filter_run() and obtain the resulting set of codecs in codec_filter.result. */ +struct codec_filter { + /* The fixed set of codecs available on the RAN type, per definition. */ + struct sdp_audio_codecs ran; + /* The codecs advertised by the MS Bearer Capabilities */ + struct sdp_audio_codecs ms; + /* If known, the set of codecs the current RAN cell allows / has available. + * This may not be available if the BSC does not issue this information early enough. + * Should be ignored if empty. */ + struct sdp_audio_codecs bss; + + /* SDP as last received from the remote call leg. */ + struct sdp_msg remote; + + /* After a channel was assigned, this reflects the chosen codec. */ + struct sdp_audio_codec assignment; + + /* Resulting choice of supported codecs, usually the intersection of the above, + * and the local RTP address to be sent to the remote call leg. + * The RTP address:port in result.rtp is not modified by codec_filter_run() -- set it once. */ + struct sdp_msg result; +}; + +void codec_filter_init(struct codec_filter *codec_filter); +void codec_filter_set_ran(struct codec_filter *codec_filter, enum osmo_rat_type ran_type); +void codec_filter_set_ms_from_bc(struct codec_filter *codec_filter, const struct gsm_mncc_bearer_cap *ms_bearer_cap); +void codec_filter_set_bss(struct codec_filter *codec_filter, + const struct gsm0808_speech_codec_list *codec_list_bss_supported); +int codec_filter_set_remote(struct codec_filter *codec_filter, const char *remote_sdp); +void codec_filter_set_local_rtp(struct codec_filter *codec_filter, const struct osmo_sockaddr_str *rtp); +int codec_filter_run(struct codec_filter *codec_filter); + +int codec_filter_to_str_buf(char *buf, size_t buflen, const struct codec_filter *codec_filter); +char *codec_filter_to_str_c(void *ctx, const struct codec_filter *codec_filter); +const char *codec_filter_to_str(const struct codec_filter *codec_filter); diff --git a/src/libmsc/Makefile.am b/src/libmsc/Makefile.am index c7fe4bb..bde70c9 100644 --- a/src/libmsc/Makefile.am +++ b/src/libmsc/Makefile.am @@ -27,6 +27,7 @@ libmsc_a_SOURCES = \ call_leg.c \ cell_id_list.c \ + codec_filter.c \ codec_mapping.c \ sccp_ran.c \ msc_vty.c \ diff --git a/src/libmsc/codec_filter.c b/src/libmsc/codec_filter.c new file mode 100644 index 0000000..e3c49c9 --- /dev/null +++ b/src/libmsc/codec_filter.c @@ -0,0 +1,211 @@ +/* Filter/overlay codec selections for a voice call, across MS, RAN and CN limitations */ +/* + * (C) 2019-2022 by sysmocom - s.m.f.c. GmbH <info(a)sysmocom.de> + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <osmocom/gsm/protocol/gsm_08_08.h> + +#include <osmocom/msc/codec_filter.h> +#include <osmocom/msc/codec_mapping.h> +#include <osmocom/msc/debug.h> + +/* Add all known payload types encountered in GSM networks */ +static void sdp_add_all_mobile_codecs(struct sdp_audio_codecs *ac) +{ + /* In order of preference. TODO: make configurable */ + static const enum gsm48_bcap_speech_ver mobile_codecs[] = { + GSM48_BCAP_SV_AMR_F /*!< 4 GSM FR V3 (FR AMR) */, + GSM48_BCAP_SV_AMR_H /*!< 5 GSM HR V3 (HR_AMR) */, + GSM48_BCAP_SV_EFR /*!< 2 GSM FR V2 (GSM EFR) */, + GSM48_BCAP_SV_FR /*!< 0 GSM FR V1 (GSM FR) */, + GSM48_BCAP_SV_HR /*!< 1 GSM HR V1 (GSM HR) */, + }; + int i; + for (i = 0; i < ARRAY_SIZE(mobile_codecs); i++) + sdp_audio_codecs_add_speech_ver(ac, mobile_codecs[i]); +} + +/* Add all known AMR payload types encountered in UTRAN networks */ +static void sdp_add_all_utran_codecs(struct sdp_audio_codecs *ac) +{ + /* In order of preference. TODO: make configurable */ + static const enum gsm48_bcap_speech_ver utran_codecs[] = { + GSM48_BCAP_SV_AMR_F /*!< 4 GSM FR V3 (FR AMR) */, + GSM48_BCAP_SV_AMR_H /*!< 5 GSM HR V3 (HR_AMR) */, + GSM48_BCAP_SV_AMR_OH /*!< 11 GSM HR V6 (OHR AMR) */, + GSM48_BCAP_SV_AMR_FW /*!< 8 GSM FR V5 (FR AMR-WB) */, + GSM48_BCAP_SV_AMR_OFW /*!< 6 GSM FR V4 (OFR AMR-WB) */, + GSM48_BCAP_SV_AMR_OHW /*!< 7 GSM HR V4 (OHR AMR-WB) */, + }; + int i; + for (i = 0; i < ARRAY_SIZE(utran_codecs); i++) + sdp_audio_codecs_add_speech_ver(ac, utran_codecs[i]); +} + +void codec_filter_init(struct codec_filter *codec_filter) +{ + *codec_filter = (struct codec_filter){}; +} + +void codec_filter_set_ran(struct codec_filter *codec_filter, enum osmo_rat_type ran_type) +{ + codec_filter->ran = (struct sdp_audio_codecs){}; + + switch (ran_type) { + default: + case OSMO_RAT_GERAN_A: + sdp_add_all_mobile_codecs(&codec_filter->ran); + break; + + case OSMO_RAT_UTRAN_IU: + sdp_add_all_utran_codecs(&codec_filter->ran); + break; + } +} + +void codec_filter_set_ms_from_bc(struct codec_filter *codec_filter, const struct gsm_mncc_bearer_cap *ms_bearer_cap) +{ + codec_filter->ms = (struct sdp_audio_codecs){0}; + if (ms_bearer_cap) + sdp_audio_codecs_from_bearer_cap(&codec_filter->ms, ms_bearer_cap); +} + +void codec_filter_set_bss(struct codec_filter *codec_filter, + const struct gsm0808_speech_codec_list *codec_list_bss_supported) +{ + codec_filter->bss = (struct sdp_audio_codecs){}; + if (codec_list_bss_supported) + sdp_audio_codecs_from_speech_codec_list(&codec_filter->bss, codec_list_bss_supported); +} + +int codec_filter_set_remote(struct codec_filter *codec_filter, const char *remote_sdp) +{ + return sdp_msg_from_sdp_str(&codec_filter->remote, remote_sdp); +} + +void codec_filter_set_local_rtp(struct codec_filter *codec_filter, const struct osmo_sockaddr_str *rtp) +{ + if (!rtp) + codec_filter->result.rtp = (struct osmo_sockaddr_str){0}; + else + codec_filter->result.rtp = *rtp; +} + +/* Render intersections of all known audio codec constraints to reach a resulting choice of favorite audio codec, plus + * possible set of alternative audio codecs, in codec_filter->result. (The result.rtp address remains unchanged.) */ +int codec_filter_run(struct codec_filter *codec_filter) +{ + struct sdp_audio_codecs *r = &codec_filter->result.audio_codecs; + struct sdp_audio_codec *a = &codec_filter->assignment; + *r = codec_filter->ran; + if (codec_filter->ms.count) + sdp_audio_codecs_intersection(r, &codec_filter->ms, false); + if (codec_filter->bss.count) + sdp_audio_codecs_intersection(r, &codec_filter->bss, false); + if (codec_filter->remote.audio_codecs.count) + sdp_audio_codecs_intersection(r, &codec_filter->remote.audio_codecs, true); + +#if ALLOW_REASSIGNMENT + /* If osmo-msc were able to trigger a re-assignment after the remote side has picked a codec mismatching the + * initial Assignment, then this code here would make sense: keep the other codecs as available to choose from, + * but put the currently assigned codec in the first position. */ + if (sdp_audio_codec_is_set(a)) { + /* Assignment has completed, the chosen codec should be the first of the resulting SDP. + * Make sure this is actually listed in the result SDP and move to first place. */ + struct sdp_audio_codec *select = sdp_audio_codec_by_descr(r, a); + + if (!select) { + /* Not present. Add. */ + if (sdp_audio_codec_by_payload_type(r, a->payload_type, false)) { + /* Oh crunch, that payload type number is already in use. + * Find an unused one. */ + for (a->payload_type = 96; a->payload_type <= 127; a->payload_type++) { + if (!sdp_audio_codec_by_payload_type(r, a->payload_type, false)) + break; + } + + if (a->payload_type > 127) + return -ENOSPC; + } + select = sdp_audio_codec_add_copy(r, a); + } + + sdp_audio_codecs_select(r, select); + } +#else + /* Currently, osmo-msc does not trigger re-assignment if the remote side has picked a codec that the local side + * would also support, but the local side has already assigned a mismatching codec before. Mismatching codecs + * means call failure. So, currently, if locally, Assignment has already happened, it makes sense to send only + * the assigned codec as available choice to the remote side. */ + if (sdp_audio_codec_is_set(a)) { + /* Assignment has completed, the chosen codec should be the the only possible one. */ + struct sdp_audio_codecs assigned_codec = {}; + sdp_audio_codecs_add_copy(&assigned_codec, a); + sdp_audio_codecs_intersection(r, &assigned_codec, false); + } +#endif + return 0; +} + +int codec_filter_to_str_buf(char *buf, size_t buflen, const struct codec_filter *codec_filter) +{ + struct osmo_strbuf sb = { .buf = buf, .len = buflen }; + OSMO_STRBUF_APPEND(sb, sdp_msg_to_str_buf, &codec_filter->result); + OSMO_STRBUF_PRINTF(sb, " (from:"); + + if (sdp_audio_codec_is_set(&codec_filter->assignment)) { + OSMO_STRBUF_PRINTF(sb, " assigned="); + OSMO_STRBUF_APPEND(sb, sdp_audio_codec_to_str_buf, &codec_filter->assignment); + } + + if (codec_filter->remote.audio_codecs.count + || osmo_sockaddr_str_is_nonzero(&codec_filter->remote.rtp)) { + OSMO_STRBUF_PRINTF(sb, " remote="); + OSMO_STRBUF_APPEND(sb, sdp_msg_to_str_buf, &codec_filter->remote); + } + + if (codec_filter->ms.count) { + OSMO_STRBUF_PRINTF(sb, " MS={"); + OSMO_STRBUF_APPEND(sb, sdp_audio_codecs_to_str_buf, &codec_filter->ms); + OSMO_STRBUF_PRINTF(sb, "}"); + } + + if (codec_filter->bss.count) { + OSMO_STRBUF_PRINTF(sb, " bss={"); + OSMO_STRBUF_APPEND(sb, sdp_audio_codecs_to_str_buf, &codec_filter->bss); + OSMO_STRBUF_PRINTF(sb, "}"); + } + + OSMO_STRBUF_PRINTF(sb, " RAN={"); + OSMO_STRBUF_APPEND(sb, sdp_audio_codecs_to_str_buf, &codec_filter->ran); + OSMO_STRBUF_PRINTF(sb, "}"); + + OSMO_STRBUF_PRINTF(sb, ")"); + + return sb.chars_needed; +} + +char *codec_filter_to_str_c(void *ctx, const struct codec_filter *codec_filter) +{ + OSMO_NAME_C_IMPL(ctx, 128, "codec_filter_to_str_c-ERROR", codec_filter_to_str_buf, codec_filter) +} + +const char *codec_filter_to_str(const struct codec_filter *codec_filter) +{ + return codec_filter_to_str_c(OTC_SELECT, codec_filter); +} -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/30116 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: I4d90f7ca62f2307a7b93dd164aeecbf4bd98ff0a Gerrit-Change-Number: 30116 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • ...
  • 251
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.