blob: cb1424b6329848fac23a9eabbb53e5ffc62f2e3b [file] [log] [blame]
Oliver Smith5375f782023-05-23 13:38:33 +02001/* Filter/overlay codec and CSD bearer service selections for voice calls/CSD,
2 * across MS, RAN and CN limitations
3 *
4 * (C) 2023 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
5 * All Rights Reserved
6 *
7 * Author: Oliver Smith
8 *
9 * SPDX-License-Identifier: AGPL-3.0+
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Affero General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Affero General Public License for more details.
20 *
21 * You should have received a copy of the GNU Affero General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25#include <osmocom/msc/transaction_cc.h>
Oliver Smithc7c40c92023-05-23 17:43:40 +020026#include <osmocom/msc/codec_filter.h>
Oliver Smith5375f782023-05-23 13:38:33 +020027
Oliver Smitha35abb72023-05-23 17:29:57 +020028void trans_cc_filter_init(struct gsm_trans *trans)
29{
30 trans->cc.codecs = (struct codec_filter){};
31}
32
Oliver Smithc7c40c92023-05-23 17:43:40 +020033void trans_cc_filter_set_ran(struct gsm_trans *trans, enum osmo_rat_type ran_type)
34{
35 codec_filter_set_ran(&trans->cc.codecs, ran_type);
36}
37
Oliver Smith1c7f1782023-05-23 17:58:26 +020038void trans_cc_filter_set_bss(struct gsm_trans *trans, struct msc_a *msc_a)
39{
40 codec_filter_set_bss(&trans->cc.codecs, &msc_a->cc.compl_l3_codec_list_bss_supported);
41}
42
Oliver Smithceca8e62023-05-24 11:15:52 +020043void trans_cc_filter_run(struct gsm_trans *trans)
44{
Oliver Smithc63c3a02023-05-24 10:48:07 +020045 codec_filter_run(&trans->cc.codecs, &trans->cc.local, &trans->cc.remote);
46 LOG_TRANS(trans, LOGL_DEBUG, "codecs: %s\n",
47 codec_filter_to_str(&trans->cc.codecs, &trans->cc.local, &trans->cc.remote));
Oliver Smithceca8e62023-05-24 11:15:52 +020048}
49
Oliver Smith5375f782023-05-23 13:38:33 +020050void trans_cc_filter_set_ms_from_bc(struct gsm_trans *trans, const struct gsm_mncc_bearer_cap *bcap)
51{
52 trans->cc.codecs.ms = (struct sdp_audio_codecs){0};
53
54 if (!bcap)
55 return;
56
57 switch (bcap->transfer) {
58 case GSM48_BCAP_ITCAP_SPEECH:
59 sdp_audio_codecs_from_bearer_cap(&trans->cc.codecs.ms, bcap);
60 break;
61 default:
62 LOG_TRANS(trans, LOGL_ERROR, "Handling of information transfer capability %d not implemented\n",
63 bcap->transfer);
64 break;
65 }
66}
Oliver Smith8a8ce712023-05-31 16:56:52 +020067
68void trans_cc_set_remote_from_bc(struct gsm_trans *trans, const struct gsm_mncc_bearer_cap *bcap)
69{
70 trans->cc.remote.audio_codecs = (struct sdp_audio_codecs){0};
71
72 if (!bcap)
73 return;
74
75 switch (bcap->transfer) {
76 case GSM48_BCAP_ITCAP_SPEECH:
77 sdp_audio_codecs_from_bearer_cap(&trans->cc.remote.audio_codecs, bcap);
78 break;
79 default:
80 LOG_TRANS(trans, LOGL_ERROR, "Handling of information transfer capability %d not implemented\n",
81 bcap->transfer);
82 break;
83 }
84}