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
This commit is contained in:
parent
390df2f954
commit
10d47901fd
|
@ -44,7 +44,7 @@ struct codec_filter {
|
||||||
struct sdp_audio_codec assignment;
|
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,
|
void codec_filter_set_bss(struct codec_filter *codec_filter,
|
||||||
const struct gsm0808_speech_codec_list *codec_list_bss_supported);
|
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);
|
int codec_filter_run(struct codec_filter *codec_filter, struct sdp_msg *result, const struct sdp_msg *remote);
|
||||||
|
|
|
@ -26,6 +26,9 @@ struct ran_infra {
|
||||||
const ran_dec_l2_t ran_dec_l2;
|
const ran_dec_l2_t ran_dec_l2;
|
||||||
const ran_encode_t ran_encode;
|
const ran_encode_t ran_encode;
|
||||||
struct sccp_ran_inst *sri;
|
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
|
/* 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
|
* 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. */
|
* RAN to IUFP, to decapsulate the IuUP headers. */
|
||||||
|
|
|
@ -25,52 +25,16 @@
|
||||||
|
|
||||||
#include <osmocom/msc/codec_filter.h>
|
#include <osmocom/msc/codec_filter.h>
|
||||||
#include <osmocom/msc/codec_mapping.h>
|
#include <osmocom/msc/codec_mapping.h>
|
||||||
|
#include <osmocom/msc/ran_infra.h>
|
||||||
#include <osmocom/msc/debug.h>
|
#include <osmocom/msc/debug.h>
|
||||||
|
|
||||||
/* Add all known payload types encountered in GSM networks */
|
void codec_filter_set_ran(struct codec_filter *codec_filter, const struct sdp_audio_codecs *codecs)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
|
const struct sdp_audio_codec *c;
|
||||||
codec_filter->ran = (struct sdp_audio_codecs){};
|
codec_filter->ran = (struct sdp_audio_codecs){};
|
||||||
|
/* Add codecs one by one, to resolve any payload type number conflicts or duplicates. */
|
||||||
switch (ran_type) {
|
sdp_audio_codecs_foreach (c, codecs)
|
||||||
default:
|
sdp_audio_codecs_add_copy(&codec_filter->ran, c, true, true);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void codec_filter_set_bss(struct codec_filter *codec_filter,
|
void codec_filter_set_bss(struct codec_filter *codec_filter,
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <osmocom/msc/ran_msg_a.h>
|
#include <osmocom/msc/ran_msg_a.h>
|
||||||
#include <osmocom/msc/ran_msg_iu.h>
|
#include <osmocom/msc/ran_msg_iu.h>
|
||||||
#include <osmocom/msc/ran_peer.h>
|
#include <osmocom/msc/ran_peer.h>
|
||||||
|
#include <osmocom/msc/codec_mapping.h>
|
||||||
|
|
||||||
#include <osmocom/msc/ran_infra.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);
|
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]);
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <osmocom/msc/transaction_cc.h>
|
#include <osmocom/msc/transaction_cc.h>
|
||||||
#include <osmocom/msc/codec_filter.h>
|
#include <osmocom/msc/codec_filter.h>
|
||||||
#include <osmocom/msc/csd_filter.h>
|
#include <osmocom/msc/csd_filter.h>
|
||||||
|
#include <osmocom/msc/ran_infra.h>
|
||||||
|
|
||||||
void trans_cc_filter_init(struct gsm_trans *trans)
|
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)
|
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);
|
csd_filter_set_ran(&trans->cc.csd, ran_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue