aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/msc/codec_sdp_cc_t9n.h
blob: 09345613353e8d365d0750d8c70fa599c84d9705 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* Routines for translation ("t9n") between SDP codec names and CC/BSSMAP codec constants */
#pragma once

#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/gsm/protocol/gsm_08_08.h>
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/msc/sdp_msg.h>
#include <osmocom/gsm/mncc.h>

#define NO_MGCP_CODEC 0xffffffff

extern const struct gsm_mncc_bearer_cap bearer_cap_empty;

enum codec_frhr {
	CODEC_FRHR_NONE = 0,
	CODEC_FRHR_FR,
	CODEC_FRHR_HR,
};

struct codec_mapping {
	/* The sdp.payload_type number in a mapping is not necessarily imperative, but may just reflect the usual
	 * payload type number for a given codec. */
	struct sdp_audio_codec sdp;
	/* The id that mgcp_client.h uses for this codec. Must be set in each mapping, because 0 means PCMU. */
	enum mgcp_codecs mgcp;
	/* Nr of used entries in speech_ver[] below. */
	unsigned int speech_ver_count;
	/* Entries to add to Speech Version lists when this codec is present, if any. */
	enum gsm48_bcap_speech_ver speech_ver[8];
	/* If applicable, one of GSM_TCHF_FRAME, GSM_TCHF_FRAME_EFR, GSM_TCHH_FRAME, GSM_TCH_FRAME_AMR; or zero. */
	uint32_t mncc_payload_msg_type;
	/* Set to true if gsm0808_speech_codec_type below reflects a meaningful value. */
	bool has_gsm0808_speech_codec_type;
	/* gsm0808_speech_codec_type corresponds to gsm0808_speech_codec[_list]->type */
	enum gsm0808_speech_codec_type gsm0808_speech_codec_type;
	/* If applicable, entries to add to Permitted Speech lists when this codec is present; or zero. */
	enum gsm0808_permitted_speech perm_speech;
	/* If applicable, indicator whether this codec can work on a GERAN half-rate lchan, or whether full-rate is
	 * required. Leave zero when this codec does not apply to GERAN. */
	enum codec_frhr frhr;
};

extern const struct codec_mapping codec_map[];
#define foreach_codec_mapping(CODEC_MAPPING) \
	for ((CODEC_MAPPING) = codec_map; (CODEC_MAPPING) < codec_map + ARRAY_SIZE(codec_map); (CODEC_MAPPING)++)

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,
								       uint16_t cfg);
const struct codec_mapping *codec_mapping_by_perm_speech(enum gsm0808_permitted_speech perm_speech);
const struct codec_mapping *codec_mapping_by_subtype_name(const char *subtype_name);
const struct codec_mapping *codec_mapping_by_mgcp_codec(enum mgcp_codecs mgcp);

int bearer_cap_add_speech_ver(struct gsm_mncc_bearer_cap *bearer_cap, enum gsm48_bcap_speech_ver speech_ver);
int sdp_audio_codec_add_to_bearer_cap(struct gsm_mncc_bearer_cap *bearer_cap, const struct sdp_audio_codec *codec);
int sdp_audio_codecs_to_bearer_cap(struct gsm_mncc_bearer_cap *bearer_cap, const struct sdp_audio_codecs *ac);
int bearer_cap_set_radio(struct gsm_mncc_bearer_cap *bearer_cap);

struct sdp_audio_codec *sdp_audio_codecs_add_speech_ver(struct sdp_audio_codecs *ac,
							enum gsm48_bcap_speech_ver speech_ver);
struct sdp_audio_codec *sdp_audio_codecs_add_mgcp_codec(struct sdp_audio_codecs *ac, enum mgcp_codecs mgcp_codec);
void sdp_audio_codecs_from_bearer_cap(struct sdp_audio_codecs *ac, const struct gsm_mncc_bearer_cap *bc);

void sdp_audio_codecs_from_speech_codec_list(struct sdp_audio_codecs *ac, const struct gsm0808_speech_codec_list *cl);

int sdp_audio_codecs_to_gsm0808_channel_type(struct gsm0808_channel_type *ct, const struct sdp_audio_codecs *ac);

enum mgcp_codecs sdp_audio_codec_to_mgcp_codec(const struct sdp_audio_codec *codec);