Neels Hofmeyr | b2ce748 | 2022-01-13 18:17:56 +0100 | [diff] [blame^] | 1 | /* Routines for translation between codec representations: SDP, CC/BSSMAP variants, MGCP, MNCC */ |
| 2 | #pragma once |
| 3 | |
| 4 | #include <osmocom/gsm/protocol/gsm_04_08.h> |
| 5 | #include <osmocom/gsm/protocol/gsm_08_08.h> |
| 6 | #include <osmocom/mgcp_client/mgcp_client.h> |
| 7 | #include <osmocom/msc/sdp_msg.h> |
| 8 | #include <osmocom/gsm/mncc.h> |
| 9 | |
| 10 | #define NO_MGCP_CODEC 0xffffffff |
| 11 | |
| 12 | extern const struct gsm_mncc_bearer_cap bearer_cap_empty; |
| 13 | |
| 14 | enum codec_frhr { |
| 15 | CODEC_FRHR_NONE = 0, |
| 16 | CODEC_FRHR_FR, |
| 17 | CODEC_FRHR_HR, |
| 18 | }; |
| 19 | |
| 20 | struct codec_mapping { |
| 21 | /* The sdp.payload_type number in a mapping is not necessarily imperative, but may just reflect the usual |
| 22 | * payload type number for a given codec. */ |
| 23 | struct sdp_audio_codec sdp; |
| 24 | /* The id that mgcp_client.h uses for this codec. Must be set in each mapping, because 0 means PCMU. */ |
| 25 | enum mgcp_codecs mgcp; |
| 26 | /* Nr of used entries in speech_ver[] below. */ |
| 27 | unsigned int speech_ver_count; |
| 28 | /* Entries to add to Speech Version lists when this codec is present, if any. */ |
| 29 | enum gsm48_bcap_speech_ver speech_ver[8]; |
| 30 | /* If applicable, one of GSM_TCHF_FRAME, GSM_TCHF_FRAME_EFR, GSM_TCHH_FRAME, GSM_TCH_FRAME_AMR; or zero. */ |
| 31 | uint32_t mncc_payload_msg_type; |
| 32 | /* Set to true if gsm0808_speech_codec below reflects a meaningful value. */ |
| 33 | bool has_gsm0808_speech_codec; |
| 34 | struct gsm0808_speech_codec gsm0808_speech_codec; |
| 35 | /* If applicable, entries to add to Permitted Speech lists when this codec is present; or zero. */ |
| 36 | enum gsm0808_permitted_speech perm_speech; |
| 37 | /* If applicable, indicator whether this codec can work on a GERAN half-rate lchan, or whether full-rate is |
| 38 | * required. Leave zero when this codec does not apply to GERAN. */ |
| 39 | enum codec_frhr frhr; |
| 40 | }; |
| 41 | |
| 42 | const struct codec_mapping *codec_mapping_by_speech_ver(enum gsm48_bcap_speech_ver speech_ver); |
| 43 | const struct codec_mapping *codec_mapping_by_gsm0808_speech_codec_type(enum gsm0808_speech_codec_type sct); |
| 44 | const struct codec_mapping *codec_mapping_by_gsm0808_speech_codec(const struct gsm0808_speech_codec *sc); |
| 45 | const struct codec_mapping *codec_mapping_by_perm_speech(enum gsm0808_permitted_speech perm_speech); |
| 46 | const struct codec_mapping *codec_mapping_by_subtype_name(const char *subtype_name); |
| 47 | const struct codec_mapping *codec_mapping_by_mgcp_codec(enum mgcp_codecs mgcp); |
| 48 | |
| 49 | int bearer_cap_add_speech_ver(struct gsm_mncc_bearer_cap *bearer_cap, enum gsm48_bcap_speech_ver speech_ver); |
| 50 | int sdp_audio_codec_add_to_bearer_cap(struct gsm_mncc_bearer_cap *bearer_cap, const struct sdp_audio_codec *codec); |
| 51 | int sdp_audio_codecs_to_bearer_cap(struct gsm_mncc_bearer_cap *bearer_cap, const struct sdp_audio_codecs *ac); |
| 52 | int bearer_cap_set_radio(struct gsm_mncc_bearer_cap *bearer_cap); |
| 53 | |
| 54 | struct sdp_audio_codec *sdp_audio_codecs_add_speech_ver(struct sdp_audio_codecs *ac, |
| 55 | enum gsm48_bcap_speech_ver speech_ver); |
| 56 | struct sdp_audio_codec *sdp_audio_codecs_add_mgcp_codec(struct sdp_audio_codecs *ac, enum mgcp_codecs mgcp_codec); |
| 57 | void sdp_audio_codecs_from_bearer_cap(struct sdp_audio_codecs *ac, const struct gsm_mncc_bearer_cap *bc); |
| 58 | |
| 59 | void sdp_audio_codecs_to_speech_codec_list(struct gsm0808_speech_codec_list *cl, const struct sdp_audio_codecs *ac); |
| 60 | void sdp_audio_codecs_from_speech_codec_list(struct sdp_audio_codecs *ac, const struct gsm0808_speech_codec_list *cl); |
| 61 | |
| 62 | int sdp_audio_codecs_to_gsm0808_channel_type(struct gsm0808_channel_type *ct, const struct sdp_audio_codecs *ac); |
| 63 | |
| 64 | enum mgcp_codecs sdp_audio_codec_to_mgcp_codec(const struct sdp_audio_codec *codec); |