From f85337f7dff2645e86cd101779c625c3de426008 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Fri, 21 Aug 2020 15:00:39 +0200 Subject: WIP cc codecs to gsm0808_speech_codec_list Change-Id: I15475b26cdd769add7162f4c2dddeda38174f998 --- include/osmocom/msc/ran_msg.h | 1 + src/libmsc/codec_sdp_cc_t9n.c | 45 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/include/osmocom/msc/ran_msg.h b/include/osmocom/msc/ran_msg.h index 3b08b466c..ae5aef38d 100644 --- a/include/osmocom/msc/ran_msg.h +++ b/include/osmocom/msc/ran_msg.h @@ -83,6 +83,7 @@ struct ran_clear_command { struct ran_assignment_command { const struct osmo_sockaddr_str *cn_rtp; const struct gsm0808_channel_type *channel_type; + const struct gsm0808_speech_codec_list *speech_codec_list_msc_preferred; enum nsap_addr_enc rab_assign_addr_enc; bool osmux_present; uint8_t osmux_cid; diff --git a/src/libmsc/codec_sdp_cc_t9n.c b/src/libmsc/codec_sdp_cc_t9n.c index 75b91abfb..cbb746433 100644 --- a/src/libmsc/codec_sdp_cc_t9n.c +++ b/src/libmsc/codec_sdp_cc_t9n.c @@ -336,6 +336,51 @@ void sdp_audio_codecs_from_speech_codec_list(struct sdp_audio_codecs *ac, const } } +static enum gsm0808_speech_codec_defaults codec_cfg(enum gsm0808_speech_codec_type type) +{ + switch (type) { + case GSM0808_SCT_FR3: + return GSM0808_SC_CFG_DEFAULT_FR_AMR; + case GSM0808_SCT_FR4: + return GSM0808_SC_CFG_DEFAULT_OFR_AMR_WB; + case GSM0808_SCT_FR5: + return GSM0808_SC_CFG_DEFAULT_FR_AMR_WB; + case GSM0808_SCT_HR3: + return GSM0808_SC_CFG_DEFAULT_HR_AMR; + case GSM0808_SCT_HR4: + return GSM0808_SC_CFG_DEFAULT_OHR_AMR_WB; + case GSM0808_SCT_HR6: + return GSM0808_SC_CFG_DEFAULT_OHR_AMR; + default: + return 0; + } +} + +void sdp_audio_codecs_to_speech_codec_list(struct gsm0808_speech_codec_list *cl, const struct sdp_audio_codecs *ac) +{ + const struct sdp_audio_codec *codec; + + *cl = (struct gsm0808_speech_codec_list){}; + + foreach_sdp_audio_codec(codec, ac) { + const struct codec_mapping *m; + foreach_codec_mapping(m) { + if (strcmp(m->sdp.subtype_name, codec->subtype_name)) + continue; + if (!m->has_gsm0808_speech_codec_type) + continue; + if (cl->len >= ARRAY_SIZE(cl->codec)) + break; + cl->codec[cl->len] = (struct gsm0808_speech_codec){ + .fi = true, + .type = m->gsm0808_speech_codec_type, + .cfg = codec_cfg(m->gsm0808_speech_codec_type), + }; + cl->len++; + } + } +} + int sdp_audio_codecs_to_gsm0808_channel_type(struct gsm0808_channel_type *ct, const struct sdp_audio_codecs *ac) { const struct sdp_audio_codec *codec; -- cgit v1.2.3