aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2022-08-08 19:11:09 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2022-08-09 02:28:32 +0200
commita0bacd54bcd3adc02f39cf62f2b2f69420403749 (patch)
treebf5a52442e19a253d0d8f41cddef18921a68d7d1
parentad7767c24f5f9f2b2ba7668185b8fc0235c7164e (diff)
codec t9n: include full gsm0808_speech_codec in mapping
-rw-r--r--include/osmocom/msc/codec_sdp_cc_t9n.h8
-rw-r--r--src/libmsc/codec_sdp_cc_t9n.c77
2 files changed, 65 insertions, 20 deletions
diff --git a/include/osmocom/msc/codec_sdp_cc_t9n.h b/include/osmocom/msc/codec_sdp_cc_t9n.h
index 093456133..150fd265b 100644
--- a/include/osmocom/msc/codec_sdp_cc_t9n.h
+++ b/include/osmocom/msc/codec_sdp_cc_t9n.h
@@ -29,10 +29,9 @@ struct codec_mapping {
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;
+ /* Set to true if gsm0808_speech_codec below reflects a meaningful value. */
+ bool has_gsm0808_speech_codec;
+ struct gsm0808_speech_codec gsm0808_speech_codec;
/* 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
@@ -61,6 +60,7 @@ struct sdp_audio_codec *sdp_audio_codecs_add_speech_ver(struct sdp_audio_codecs
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_to_speech_codec_list(struct gsm0808_speech_codec_list *cl, const struct sdp_audio_codecs *ac);
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);
diff --git a/src/libmsc/codec_sdp_cc_t9n.c b/src/libmsc/codec_sdp_cc_t9n.c
index 11345d3e9..251fe66ce 100644
--- a/src/libmsc/codec_sdp_cc_t9n.c
+++ b/src/libmsc/codec_sdp_cc_t9n.c
@@ -48,8 +48,11 @@ const struct codec_mapping codec_map[] = {
.speech_ver_count = 1,
.speech_ver = { GSM48_BCAP_SV_FR },
.mncc_payload_msg_type = GSM_TCHF_FRAME,
- .has_gsm0808_speech_codec_type = true,
- .gsm0808_speech_codec_type = GSM0808_SCT_FR1,
+ .has_gsm0808_speech_codec = true,
+ .gsm0808_speech_codec = {
+ .fi = true,
+ .type = GSM0808_SCT_FR1,
+ },
.perm_speech = GSM0808_PERM_FR1,
.frhr = CODEC_FRHR_FR,
},
@@ -79,8 +82,11 @@ const struct codec_mapping codec_map[] = {
.speech_ver_count = 1,
.speech_ver = { GSM48_BCAP_SV_EFR },
.mncc_payload_msg_type = GSM_TCHF_FRAME_EFR,
- .has_gsm0808_speech_codec_type = true,
- .gsm0808_speech_codec_type = GSM0808_SCT_FR2,
+ .has_gsm0808_speech_codec = true,
+ .gsm0808_speech_codec = {
+ .fi = true,
+ .type = GSM0808_SCT_FR2,
+ },
.perm_speech = GSM0808_PERM_FR2,
.frhr = CODEC_FRHR_FR,
},
@@ -94,8 +100,12 @@ const struct codec_mapping codec_map[] = {
.speech_ver_count = 1,
.speech_ver = { GSM48_BCAP_SV_HR },
.mncc_payload_msg_type = GSM_TCHH_FRAME,
- .has_gsm0808_speech_codec_type = true,
- .gsm0808_speech_codec_type = GSM0808_SCT_HR1,
+ .has_gsm0808_speech_codec = true,
+ .gsm0808_speech_codec = {
+ .fi = true,
+ .type = GSM0808_SCT_HR1,
+ .cfg = GSM0808_SC_CFG_DEFAULT_HR_AMR,
+ },
.perm_speech = GSM0808_PERM_HR1,
.frhr = CODEC_FRHR_HR,
},
@@ -117,8 +127,12 @@ const struct codec_mapping codec_map[] = {
.speech_ver_count = 1,
.speech_ver = { GSM48_BCAP_SV_AMR_F },
.mncc_payload_msg_type = GSM_TCH_FRAME_AMR,
- .has_gsm0808_speech_codec_type = true,
- .gsm0808_speech_codec_type = GSM0808_SCT_FR3,
+ .has_gsm0808_speech_codec = true,
+ .gsm0808_speech_codec = {
+ .fi = true,
+ .type = GSM0808_SCT_FR3,
+ .cfg = GSM0808_SC_CFG_DEFAULT_FR_AMR,
+ },
.perm_speech = GSM0808_PERM_FR3,
.frhr = CODEC_FRHR_FR,
},
@@ -133,8 +147,12 @@ const struct codec_mapping codec_map[] = {
.speech_ver_count = 2,
.speech_ver = { GSM48_BCAP_SV_AMR_H, GSM48_BCAP_SV_AMR_OH },
.mncc_payload_msg_type = GSM_TCH_FRAME_AMR,
- .has_gsm0808_speech_codec_type = true,
- .gsm0808_speech_codec_type = GSM0808_SCT_HR3,
+ .has_gsm0808_speech_codec = true,
+ .gsm0808_speech_codec = {
+ .fi = true,
+ .type = GSM0808_SCT_HR3,
+ .cfg = GSM0808_SC_CFG_DEFAULT_HR_AMR,
+ },
.perm_speech = GSM0808_PERM_HR3,
.frhr = CODEC_FRHR_HR,
},
@@ -149,8 +167,12 @@ const struct codec_mapping codec_map[] = {
.speech_ver_count = 2,
.speech_ver = { GSM48_BCAP_SV_AMR_OFW, GSM48_BCAP_SV_AMR_FW },
.mncc_payload_msg_type = GSM_TCH_FRAME_AMR,
- .has_gsm0808_speech_codec_type = true,
- .gsm0808_speech_codec_type = GSM0808_SCT_FR5,
+ .has_gsm0808_speech_codec = true,
+ .gsm0808_speech_codec = {
+ .fi = true,
+ .type = GSM0808_SCT_FR5,
+ .cfg = GSM0808_SC_CFG_DEFAULT_FR_AMR_WB,
+ },
.perm_speech = GSM0808_PERM_FR5,
.frhr = CODEC_FRHR_FR,
},
@@ -165,8 +187,12 @@ const struct codec_mapping codec_map[] = {
.speech_ver_count = 1,
.speech_ver = { GSM48_BCAP_SV_AMR_OHW },
.mncc_payload_msg_type = GSM_TCH_FRAME_AMR,
- .has_gsm0808_speech_codec_type = true,
- .gsm0808_speech_codec_type = GSM0808_SCT_HR4,
+ .has_gsm0808_speech_codec = true,
+ .gsm0808_speech_codec = {
+ .fi = true,
+ .type = GSM0808_SCT_HR4,
+ .cfg = GSM0808_SC_CFG_DEFAULT_OHR_AMR_WB,
+ },
.perm_speech = GSM0808_PERM_HR4,
.frhr = CODEC_FRHR_HR,
},
@@ -201,9 +227,9 @@ const struct codec_mapping *codec_mapping_by_gsm0808_speech_codec_type(enum gsm0
{
const struct codec_mapping *m;
foreach_codec_mapping(m) {
- if (!m->has_gsm0808_speech_codec_type)
+ if (!m->has_gsm0808_speech_codec)
continue;
- if (m->gsm0808_speech_codec_type == sct)
+ if (m->gsm0808_speech_codec.type == sct)
return m;
/* TODO: evaluate cfg bits? */
}
@@ -354,6 +380,25 @@ void sdp_audio_codecs_from_bearer_cap(struct sdp_audio_codecs *ac, const struct
}
}
+void sdp_audio_codecs_to_speech_codec_list(struct gsm0808_speech_codec_list *scl, const struct sdp_audio_codecs *ac)
+{
+ const struct sdp_audio_codec *codec;
+
+ *scl = (struct gsm0808_speech_codec_list){};
+
+ foreach_sdp_audio_codec(codec, ac) {
+ const struct codec_mapping *m = codec_mapping_by_subtype_name(codec->subtype_name);
+ if (!m)
+ continue;
+ if (!m->has_gsm0808_speech_codec)
+ continue;
+ if (scl->len >= ARRAY_SIZE(scl->codec))
+ break;
+ scl->codec[scl->len] = m->gsm0808_speech_codec;
+ scl->len++;
+ }
+}
+
void sdp_audio_codecs_from_speech_codec_list(struct sdp_audio_codecs *ac, const struct gsm0808_speech_codec_list *cl)
{
int i;