aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2024-02-02 08:34:29 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2024-02-09 05:17:39 +0100
commit17e39a777754c5d2fe18760711c2443a5004ecc5 (patch)
treee63c015d535173e094cf01166b01544c1bf897f7
parenta2bb6d5c4d4761078aa07796cbb0d9332f0d95ac (diff)
make default RAN codecs configurable in ran_infra
Instead of generating the default codecs list for a RAN for each call, place a pre-composed list in ran_infra.c. (1) The main aim is to allow configuring this list -- subsequent commit Ib5655214ce48c66d095e8f1b7b7106ac3ee43ec0 will add the VTY commands to modify the predefined lists. (2) As a free side effect, this also allows configuring the order of preference for specific codecs. (3) It may also save us some iterations of the codec_map[], which may grow a lot more variants; for example, we could add one entry for each possible AMR mode-set... Change-Id: If46231a53f7512dbd81790fd30462d65fe059aa3
-rw-r--r--include/osmocom/msc/codec_filter.h2
-rw-r--r--include/osmocom/msc/ran_infra.h3
-rw-r--r--src/libmsc/codec_filter.c48
-rw-r--r--src/libmsc/ran_infra.c29
-rw-r--r--src/libmsc/transaction_cc.c3
5 files changed, 41 insertions, 44 deletions
diff --git a/include/osmocom/msc/codec_filter.h b/include/osmocom/msc/codec_filter.h
index da4a67e04..a8be8445e 100644
--- a/include/osmocom/msc/codec_filter.h
+++ b/include/osmocom/msc/codec_filter.h
@@ -44,7 +44,7 @@ struct codec_filter {
struct sdp_audio_codec assignment;
};
-void codec_filter_set_ran(struct codec_filter *codec_filter, enum osmo_rat_type ran_type);
+void codec_filter_set_ran(struct codec_filter *codec_filter, const struct sdp_audio_codecs *codecs);
void codec_filter_set_bss(struct codec_filter *codec_filter,
const struct gsm0808_speech_codec_list *codec_list_bss_supported);
int codec_filter_run(struct codec_filter *codec_filter, struct sdp_msg *result, const struct sdp_msg *remote);
diff --git a/include/osmocom/msc/ran_infra.h b/include/osmocom/msc/ran_infra.h
index 262a9c82e..f96e2cfc9 100644
--- a/include/osmocom/msc/ran_infra.h
+++ b/include/osmocom/msc/ran_infra.h
@@ -26,6 +26,9 @@ struct ran_infra {
const ran_dec_l2_t ran_dec_l2;
const ran_encode_t ran_encode;
struct sccp_ran_inst *sri;
+ /* Codecs available on this RAN type by default, in order of preference. If empty, all known codecs will be
+ * allowed and offered to peers. */
+ struct sdp_audio_codecs codecs;
/* To always set up the MGW endpoint facing the RAN side with specific codecs, list those here. Otherwise leave
* empty (to use the result of codecs filtering). This exists for IuCS, to always set the MGW endpoint facing
* RAN to IUFP, to decapsulate the IuUP headers. */
diff --git a/src/libmsc/codec_filter.c b/src/libmsc/codec_filter.c
index 5485814f6..249df858a 100644
--- a/src/libmsc/codec_filter.c
+++ b/src/libmsc/codec_filter.c
@@ -25,52 +25,16 @@
#include <osmocom/msc/codec_filter.h>
#include <osmocom/msc/codec_mapping.h>
+#include <osmocom/msc/ran_infra.h>
#include <osmocom/msc/debug.h>
-/* Add all known payload types encountered in GSM networks */
-static void sdp_add_all_geran_codecs(struct sdp_audio_codecs *ac)
-{
- /* In order of preference. TODO: make configurable */
- static const enum gsm48_bcap_speech_ver mobile_codecs[] = {
- GSM48_BCAP_SV_AMR_F /*!< 4 GSM FR V3 (FR AMR) */,
- GSM48_BCAP_SV_AMR_H /*!< 5 GSM HR V3 (HR_AMR) */,
- GSM48_BCAP_SV_EFR /*!< 2 GSM FR V2 (GSM EFR) */,
- GSM48_BCAP_SV_FR /*!< 0 GSM FR V1 (GSM FR) */,
- GSM48_BCAP_SV_HR /*!< 1 GSM HR V1 (GSM HR) */,
- };
- int i;
- for (i = 0; i < ARRAY_SIZE(mobile_codecs); i++)
- sdp_audio_codecs_add_speech_ver(ac, mobile_codecs[i]);
-}
-
-/* Add all known AMR payload types encountered in UTRAN networks */
-static void sdp_add_all_utran_codecs(struct sdp_audio_codecs *ac)
-{
- /* In order of preference. TODO: make configurable */
- static const enum gsm48_bcap_speech_ver utran_codecs[] = {
- GSM48_BCAP_SV_AMR_F /*!< 4 GSM FR V3 (FR AMR) */,
- GSM48_BCAP_SV_AMR_H /*!< 5 GSM HR V3 (HR_AMR) */,
- GSM48_BCAP_SV_AMR_FW /*!< 8 GSM FR V5 (FR AMR-WB) */,
- };
- int i;
- for (i = 0; i < ARRAY_SIZE(utran_codecs); i++)
- sdp_audio_codecs_add_speech_ver(ac, utran_codecs[i]);
-}
-
-void codec_filter_set_ran(struct codec_filter *codec_filter, enum osmo_rat_type ran_type)
+void codec_filter_set_ran(struct codec_filter *codec_filter, const struct sdp_audio_codecs *codecs)
{
+ const struct sdp_audio_codec *c;
codec_filter->ran = (struct sdp_audio_codecs){};
-
- switch (ran_type) {
- default:
- case OSMO_RAT_GERAN_A:
- sdp_add_all_geran_codecs(&codec_filter->ran);
- break;
-
- case OSMO_RAT_UTRAN_IU:
- sdp_add_all_utran_codecs(&codec_filter->ran);
- break;
- }
+ /* Add codecs one by one, to resolve any payload type number conflicts or duplicates. */
+ sdp_audio_codecs_foreach (c, codecs)
+ sdp_audio_codecs_add_copy(&codec_filter->ran, c, true, true);
}
void codec_filter_set_bss(struct codec_filter *codec_filter,
diff --git a/src/libmsc/ran_infra.c b/src/libmsc/ran_infra.c
index 6a178403f..07a1cd2da 100644
--- a/src/libmsc/ran_infra.c
+++ b/src/libmsc/ran_infra.c
@@ -28,6 +28,7 @@
#include <osmocom/msc/ran_msg_a.h>
#include <osmocom/msc/ran_msg_iu.h>
#include <osmocom/msc/ran_peer.h>
+#include <osmocom/msc/codec_mapping.h>
#include <osmocom/msc/ran_infra.h>
@@ -128,3 +129,31 @@ struct ran_infra msc_ran_infra[] = {
};
const int msc_ran_infra_len = ARRAY_SIZE(msc_ran_infra);
+
+static __attribute__((constructor)) void on_dso_load_geran(void)
+{
+ /* Initialize GERAN default codecs, in order of preference. By definition, all codec_mapping entries that match
+ * one of the GERAN GMSK Speech Versions are available. */
+ static const enum gsm48_bcap_speech_ver mobile_codecs[] = {
+ GSM48_BCAP_SV_AMR_F /*!< 4 GSM FR V3 (FR AMR) */,
+ GSM48_BCAP_SV_AMR_H /*!< 5 GSM HR V3 (HR_AMR) */,
+ GSM48_BCAP_SV_EFR /*!< 2 GSM FR V2 (GSM EFR) */,
+ GSM48_BCAP_SV_FR /*!< 0 GSM FR V1 (GSM FR) */,
+ GSM48_BCAP_SV_HR /*!< 1 GSM HR V1 (GSM HR) */,
+ };
+ int i;
+ for (i = 0; i < ARRAY_SIZE(mobile_codecs); i++)
+ sdp_audio_codecs_add_speech_ver(&msc_ran_infra[OSMO_RAT_GERAN_A].codecs, mobile_codecs[i]);
+}
+
+static __attribute__((constructor)) void on_dso_load_utran(void)
+{
+ static const enum gsm48_bcap_speech_ver utran_codecs[] = {
+ GSM48_BCAP_SV_AMR_F /*!< 4 GSM FR V3 (FR AMR) */,
+ GSM48_BCAP_SV_AMR_H /*!< 5 GSM HR V3 (HR_AMR) */,
+ GSM48_BCAP_SV_AMR_FW /*!< 8 GSM FR V5 (FR AMR-WB) */,
+ };
+ int i;
+ for (i = 0; i < ARRAY_SIZE(utran_codecs); i++)
+ sdp_audio_codecs_add_speech_ver(&msc_ran_infra[OSMO_RAT_UTRAN_IU].codecs, utran_codecs[i]);
+}
diff --git a/src/libmsc/transaction_cc.c b/src/libmsc/transaction_cc.c
index 2a540bfa5..e88598278 100644
--- a/src/libmsc/transaction_cc.c
+++ b/src/libmsc/transaction_cc.c
@@ -25,6 +25,7 @@
#include <osmocom/msc/transaction_cc.h>
#include <osmocom/msc/codec_filter.h>
#include <osmocom/msc/csd_filter.h>
+#include <osmocom/msc/ran_infra.h>
void trans_cc_filter_init(struct gsm_trans *trans)
{
@@ -34,7 +35,7 @@ void trans_cc_filter_init(struct gsm_trans *trans)
void trans_cc_filter_set_ran(struct gsm_trans *trans, enum osmo_rat_type ran_type)
{
- codec_filter_set_ran(&trans->cc.codecs, ran_type);
+ codec_filter_set_ran(&trans->cc.codecs, &msc_ran_infra[ran_type].codecs);
csd_filter_set_ran(&trans->cc.csd, ran_type);
}