Commit Graph

7 Commits

Author SHA1 Message Date
Neels Hofmeyr f5a7003d86 wip
Change-Id: I974a02ecf8f280177c0ad616a05bb2aabf0d54ff
2024-02-25 03:49:31 +01:00
Neels Hofmeyr 64475fc6d8 codec_mapping: add amr flags
These flags are redundant, the aim is to speed up comparisons of AMR
fmtp when traversing a long list of codec variants. It can skip a lot of
repetitive strcmp and fmtp string parsing when used by a loop.

Change-Id: Ic2c9b4983b5374621e02389900e3622faa29cad9
2024-02-25 03:43:12 +01:00
Neels Hofmeyr c2e4bfc585 codec_mapping_matches_gsm0808_speech_codec
Change-Id: I852c1647a1b14017bd4f0ae79d22d84de28187f8
2024-02-25 03:43:12 +01:00
Neels Hofmeyr d1039bb8a5 codec_mapping_matches_speech_ver
Change-Id: Iccd1f137674ef23dfa37a7e21086e046514ce39b
2024-02-25 03:43:12 +01:00
Neels Hofmeyr 21f1bfb4a8 add codec_mapping_next() and codec_mapping_foreach()
So far, querying the codec mapping returns one match.
For example:

 const struct codec_mapping *m;
 m = codec_mapping_by_speech_ver(GSM48_BCAP_SV_FR);
 if (!m)
         return -ENOENT;

But when supporting various AMR rates, we need to find multiple matches
in some code paths.

Also to support AMR OA vs BE modes, we need to combine multiple criteria
in some places.

With this patch, and as soon as an upcoming patch implements
codec_mapping_matches_speech_ver(), above code example becomes:

 const struct codec_mapping *m;
 codec_mapping_foreach (m) {
         if (codec_mapping_matches_speech_ver(m, GSM48_BCAP_SV_FR))
	         break;
 }
 if (!m)
         return -ENOENT;

This pattern supports collecting multiple matches in a list:

 const struct codec_mapping *m;
 codec_mapping_foreach (m) {
         if (codec_mapping_matches_speech_ver(m, GSM48_BCAP_SV_FR))
	         sdp_audio_codecs_add_copy(my_list, m);
 }

And this pattern also supports combining criteria:

 const struct codec_mapping *m;
 codec_mapping_foreach (m) {
	 // only allow AMR in OA mode
 	 if (!osmo_sdp_fmtp_amr_is_octet_aligned(m->sdp.fmtp))
	         continue;
         if (codec_mapping_matches_speech_ver(m, GSM48_BCAP_SV_AMR_F)
	     || codec_mapping_matches_speech_ver(m, GSM48_BCAP_SV_AMR_H))
	         sdp_audio_codecs_add_copy(my_list, m);
 }

Change-Id: Iaaa59d4bf5a6126a1bfe4ae282b82f6cb3ec6f99
2024-02-25 03:43:12 +01:00
Neels Hofmeyr cefe594c72 add sdp_audio_codec_to_speech_codec_list()
Used by I8760feaa8598047369ef8c3ab2673013bac8ac8a to add just a single
codec to a speech codec list, instead of a list.

Change-Id: I6ac23c54bc26939e048ff2df06eb987421cfb1c5
2023-12-13 01:52:22 +00:00
Neels Hofmeyr b2ce74829a add codec_mapping.h,c
Converting between different codec representations is confusing. This
codec mapping provides a consolidated overview of all our codec
representations, and how they match up.

In particular, it adds the SDP codec representation repertoire,
preparing the use of full SDP on the MNCC interface.

Related: SYS#5066
Change-Id: Iaa307be6a8487aa8d4ba7cd59d5c5ef04818a744
2023-03-14 22:41:52 +00:00