Neels Hofmeyr | 63881a3 | 2022-01-13 18:34:52 +0100 | [diff] [blame] | 1 | /* Filter/overlay codec selections for a voice call, across MS, RAN and CN limitations */ |
| 2 | /* |
Vadim Yanitskiy | 999a593 | 2023-05-18 17:22:26 +0700 | [diff] [blame] | 3 | * (C) 2019-2022 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de> |
Neels Hofmeyr | 63881a3 | 2022-01-13 18:34:52 +0100 | [diff] [blame] | 4 | * All Rights Reserved |
| 5 | * |
| 6 | * Author: Neels Hofmeyr |
| 7 | * |
| 8 | * SPDX-License-Identifier: GPL-2.0+ |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | */ |
| 20 | #pragma once |
| 21 | |
| 22 | #include <osmocom/gsm/gsm_utils.h> |
| 23 | #include <osmocom/gsm/mncc.h> |
| 24 | #include <osmocom/mgcp_client/mgcp_client.h> |
| 25 | |
| 26 | #include <osmocom/msc/sdp_msg.h> |
| 27 | |
| 28 | struct gsm0808_speech_codec_list; |
| 29 | |
| 30 | /* Combine various codec selections to obtain a resulting set of codecs allowed by all of them. |
| 31 | * Members reflect the different entities/stages that select codecs in a voice call. |
| 32 | * Call codec_filter_run() and obtain the resulting set of codecs in codec_filter.result. */ |
| 33 | struct codec_filter { |
| 34 | /* The fixed set of codecs available on the RAN type, per definition. */ |
| 35 | struct sdp_audio_codecs ran; |
| 36 | /* The codecs advertised by the MS Bearer Capabilities */ |
| 37 | struct sdp_audio_codecs ms; |
| 38 | /* If known, the set of codecs the current RAN cell allows / has available. |
| 39 | * This may not be available if the BSC does not issue this information early enough. |
| 40 | * Should be ignored if empty. */ |
| 41 | struct sdp_audio_codecs bss; |
| 42 | |
Neels Hofmeyr | 63881a3 | 2022-01-13 18:34:52 +0100 | [diff] [blame] | 43 | /* After a channel was assigned, this reflects the chosen codec. */ |
| 44 | struct sdp_audio_codec assignment; |
Neels Hofmeyr | 63881a3 | 2022-01-13 18:34:52 +0100 | [diff] [blame] | 45 | }; |
| 46 | |
Neels Hofmeyr | 63881a3 | 2022-01-13 18:34:52 +0100 | [diff] [blame] | 47 | void codec_filter_set_ran(struct codec_filter *codec_filter, enum osmo_rat_type ran_type); |
Neels Hofmeyr | 63881a3 | 2022-01-13 18:34:52 +0100 | [diff] [blame] | 48 | void codec_filter_set_bss(struct codec_filter *codec_filter, |
| 49 | const struct gsm0808_speech_codec_list *codec_list_bss_supported); |
Oliver Smith | c63c3a0 | 2023-05-24 10:48:07 +0200 | [diff] [blame] | 50 | int codec_filter_run(struct codec_filter *codec_filter, struct sdp_msg *result, const struct sdp_msg *remote); |
Neels Hofmeyr | 63881a3 | 2022-01-13 18:34:52 +0100 | [diff] [blame] | 51 | |
Oliver Smith | 593cd88 | 2023-05-24 10:40:19 +0200 | [diff] [blame] | 52 | int codec_filter_to_str_buf(char *buf, size_t buflen, const struct codec_filter *codec_filter, |
Oliver Smith | c63c3a0 | 2023-05-24 10:48:07 +0200 | [diff] [blame] | 53 | const struct sdp_msg *result, const struct sdp_msg *remote); |
| 54 | char *codec_filter_to_str_c(void *ctx, const struct codec_filter *codec_filter, const struct sdp_msg *result, |
Oliver Smith | 593cd88 | 2023-05-24 10:40:19 +0200 | [diff] [blame] | 55 | const struct sdp_msg *remote); |
Oliver Smith | c63c3a0 | 2023-05-24 10:48:07 +0200 | [diff] [blame] | 56 | const char *codec_filter_to_str(const struct codec_filter *codec_filter, const struct sdp_msg *result, |
| 57 | const struct sdp_msg *remote); |