aboutsummaryrefslogtreecommitdiffstats
path: root/src/gsm/gsm0808_utils.c
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-06-02 13:22:34 +0200
committerHarald Welte <laforge@gnumonks.org>2017-06-22 17:08:15 +0000
commit3149b0d076477303a38df735fe579b1b06ee17b2 (patch)
treeb4d6d5c5db72eeff2acf722c4329e596cdefe0d1 /src/gsm/gsm0808_utils.c
parenta9b92769482585b17467008fa0d78085d7b10820 (diff)
gsm0808: add function gsm0808_chan_type_to_speech_code()
The permitted speech field used in channel type element (struct gsm0808_channel_type) uses a different representation as the type field in the speech codec element (struct gsm0808_speech_codec) This patch adds a function to convert from permitted speech to speech codec type. Change-Id: Ib26a9c20864459b2baaa04f49b6e7902ba44b7cb
Diffstat (limited to 'src/gsm/gsm0808_utils.c')
-rw-r--r--src/gsm/gsm0808_utils.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 60fb91cd..64ffec4e 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -645,4 +645,41 @@ int gsm0808_dec_cell_id_list(struct gsm0808_cell_id_list *cil,
return (int)(elem - old_elem);
}
+/*! \brief Convert the representation of the permitted speech codec identifier
+ * that is used in struct gsm0808_channel_type to the speech codec
+ * representation we use in struct gsm0808_speech_codec.
+ * \param[in] perm_spch to be converted (see also gsm0808_permitted_speech)
+ * \returns GSM speech codec type; negative on error */
+int gsm0808_chan_type_to_speech_codec(uint8_t perm_spch)
+{
+ /*! The speech codec type, which is used in the channel type field to
+ * signal the permitted speech versions (codecs) has a different
+ * encoding than the type field in the speech codec type element
+ * (See also 3GPP TS 48.008, 3.2.2.11 and 3.2.2.103) */
+
+ switch (perm_spch) {
+ case GSM0808_PERM_FR1:
+ return GSM0808_SCT_FR1;
+ case GSM0808_PERM_FR2:
+ return GSM0808_SCT_FR2;
+ case GSM0808_PERM_FR3:
+ return GSM0808_SCT_FR3;
+ case GSM0808_PERM_FR4:
+ return GSM0808_SCT_FR4;
+ case GSM0808_PERM_FR5:
+ return GSM0808_SCT_FR5;
+ case GSM0808_PERM_HR1:
+ return GSM0808_SCT_HR1;
+ case GSM0808_PERM_HR3:
+ return GSM0808_SCT_HR3;
+ case GSM0808_PERM_HR4:
+ return GSM0808_SCT_HR4;
+ case GSM0808_PERM_HR6:
+ return GSM0808_SCT_HR6;
+ }
+
+ /* Invalid input */
+ return -EINVAL;
+}
+
/*! @} */