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 <[email protected]>
Gerrit-MessageType: newchange

Reply via email to