aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2022-01-13 18:34:52 +0100
committerneels <nhofmeyr@sysmocom.de>2023-03-14 22:41:52 +0000
commit63881a37355e532bd01aced3d42bcce330b82029 (patch)
tree8b4107e7ccf6eaa14c7504a31aa8239fa9044e53 /include
parenta001a70048291a55e5f80f74096fbba3c4517fdd (diff)
[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
Diffstat (limited to 'include')
-rw-r--r--include/osmocom/msc/Makefile.am1
-rw-r--r--include/osmocom/msc/codec_filter.h66
2 files changed, 67 insertions, 0 deletions
diff --git a/include/osmocom/msc/Makefile.am b/include/osmocom/msc/Makefile.am
index 80f897270..34b4902ce 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 000000000..16315c791
--- /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@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);