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 | |
| 43 | /* SDP as last received from the remote call leg. */ |
| 44 | struct sdp_msg remote; |
| 45 | |
| 46 | /* After a channel was assigned, this reflects the chosen codec. */ |
| 47 | struct sdp_audio_codec assignment; |
| 48 | |
| 49 | /* Resulting choice of supported codecs, usually the intersection of the above, |
| 50 | * and the local RTP address to be sent to the remote call leg. |
| 51 | * The RTP address:port in result.rtp is not modified by codec_filter_run() -- set it once. */ |
| 52 | struct sdp_msg result; |
| 53 | }; |
| 54 | |
| 55 | void codec_filter_init(struct codec_filter *codec_filter); |
| 56 | 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] | 57 | void codec_filter_set_bss(struct codec_filter *codec_filter, |
| 58 | const struct gsm0808_speech_codec_list *codec_list_bss_supported); |
| 59 | int codec_filter_set_remote(struct codec_filter *codec_filter, const char *remote_sdp); |
| 60 | void codec_filter_set_local_rtp(struct codec_filter *codec_filter, const struct osmo_sockaddr_str *rtp); |
| 61 | int codec_filter_run(struct codec_filter *codec_filter); |
| 62 | |
| 63 | int codec_filter_to_str_buf(char *buf, size_t buflen, const struct codec_filter *codec_filter); |
| 64 | char *codec_filter_to_str_c(void *ctx, const struct codec_filter *codec_filter); |
| 65 | const char *codec_filter_to_str(const struct codec_filter *codec_filter); |