diff options
author | Oliver Smith <osmith@sysmocom.de> | 2023-02-09 15:09:55 +0100 |
---|---|---|
committer | osmith <osmith@sysmocom.de> | 2023-03-01 08:11:15 +0000 |
commit | 4e54e16b9fc36b4a7144122c26389a1096e48a21 (patch) | |
tree | 0bfc35892b100e64142ca7f415dc781f3cdf4473 | |
parent | f597a035fa2cfad4725f4886aab78b2eb39c879b (diff) |
codec_pref: split test_codec_support_bts_rate
Move the check for the rate into an extra function, so it can be used
for CSD without checking a speech codec at the same time.
Related: OS#4393
Change-Id: Iea8a23ef3c66ed556110038fe9f3bc7f6eef3e96
-rw-r--r-- | src/osmo-bsc/codec_pref.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/src/osmo-bsc/codec_pref.c b/src/osmo-bsc/codec_pref.c index a64425abc..581872ae0 100644 --- a/src/osmo-bsc/codec_pref.c +++ b/src/osmo-bsc/codec_pref.c @@ -174,37 +174,43 @@ static bool test_codec_pref(const struct gsm0808_speech_codec **sc_match, return false; } -/* Check if the given permitted speech value is supported by the BTS - * (vty option bts->codec-support). */ -static bool test_codec_support_bts(const struct gsm_bts *bts, uint8_t perm_spch) +static bool test_codec_support_bts_rate(const struct gsm_bts *bts, const bool full_rate) { - struct gsm_bts_trx *trx; - const struct bts_codec_conf *bts_codec = &bts->codec; unsigned int i; - bool full_rate; - int rc; + struct gsm_bts_trx *trx; enum gsm_phys_chan_config pchan; - bool rate_match = false; - /* Check if the BTS provides a physical channel that matches the - * bandwidth of the desired codec. */ - rc = full_rate_from_perm_spch(&full_rate, perm_spch); - if (rc < 0) - return false; llist_for_each_entry(trx, &bts->trx_list, list) { for (i = 0; i < TRX_NR_TS; i++) { pchan = trx->ts[i].pchan_from_config; if (pchan == GSM_PCHAN_OSMO_DYN) - rate_match = true; + return true; else if (full_rate && pchan == GSM_PCHAN_TCH_F) - rate_match = true; + return true; else if (full_rate && pchan == GSM_PCHAN_TCH_F_PDCH) - rate_match = true; + return true; else if (!full_rate && pchan == GSM_PCHAN_TCH_H) - rate_match = true; + return true; } } - if (!rate_match) + + return false; +} + +/* Check if the given permitted speech value is supported by the BTS + * (vty option bts->codec-support). */ +static bool test_codec_support_bts(const struct gsm_bts *bts, uint8_t perm_spch) +{ + const struct bts_codec_conf *bts_codec = &bts->codec; + bool full_rate; + int rc; + + /* Check if the BTS provides a physical channel that matches the + * bandwidth of the desired codec. */ + rc = full_rate_from_perm_spch(&full_rate, perm_spch); + if (rc < 0) + return false; + if (!test_codec_support_bts_rate(bts, full_rate)) return false; /* Check codec support */ |