codec_mapping_matches_gsm0808_speech_codec

Change-Id: I852c1647a1b14017bd4f0ae79d22d84de28187f8
This commit is contained in:
Neels Hofmeyr 2024-01-19 05:52:37 +01:00
parent d1039bb8a5
commit c2e4bfc585
2 changed files with 21 additions and 0 deletions

View File

@ -59,6 +59,8 @@ const struct codec_mapping *codec_mapping_next(const struct codec_mapping *c);
for ((CODEC_MAPPING) = codec_mapping_next(NULL); (CODEC_MAPPING); (CODEC_MAPPING) = codec_mapping_next(CODEC_MAPPING))
bool codec_mapping_matches_speech_ver(const struct codec_mapping *m, enum gsm48_bcap_speech_ver speech_ver);
bool codec_mapping_matches_gsm0808_speech_codec_type(const struct codec_mapping *m, enum gsm0808_speech_codec_type sct);
bool codec_mapping_matches_gsm0808_speech_codec(const struct codec_mapping *m, const struct gsm0808_speech_codec *sc);
const struct codec_mapping *codec_mapping_by_speech_ver(enum gsm48_bcap_speech_ver speech_ver);
const struct codec_mapping *codec_mapping_by_gsm0808_speech_codec_type(enum gsm0808_speech_codec_type sct);

View File

@ -245,6 +245,15 @@ const struct codec_mapping *codec_mapping_by_speech_ver(enum gsm48_bcap_speech_v
return NULL;
}
bool codec_mapping_matches_gsm0808_speech_codec_type(const struct codec_mapping *m, enum gsm0808_speech_codec_type sct)
{
if (!m->has_gsm0808_speech_codec)
return false;
if (m->gsm0808_speech_codec.type == sct)
return true;
return false;
}
const struct codec_mapping *codec_mapping_by_gsm0808_speech_codec_type(enum gsm0808_speech_codec_type sct)
{
const struct codec_mapping *m;
@ -257,6 +266,16 @@ const struct codec_mapping *codec_mapping_by_gsm0808_speech_codec_type(enum gsm0
return NULL;
}
bool codec_mapping_matches_gsm0808_speech_codec(const struct codec_mapping *m, const struct gsm0808_speech_codec *sc)
{
if (!codec_mapping_matches_gsm0808_speech_codec_type(m, sc->type))
return false;
/* Return all those where m->gsm0808_speech_codec.cfg is a subset of sc->cfg.
* codec_mapping entries all have just a single cfg bit set. An incoming Speech Codec may list multiple cfg bits
* in one mask. */
return (m->gsm0808_speech_codec.cfg & sc->cfg) == m->gsm0808_speech_codec.cfg;
}
const struct codec_mapping *codec_mapping_by_gsm0808_speech_codec(const struct gsm0808_speech_codec *sc)
{
const struct codec_mapping *m;