[PATCH] libosmocore[master]: gsm0808: add function to translate perm speech to speech co...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Fri Jun 2 15:20:47 UTC 2017


Review at  https://gerrit.osmocom.org/2830

gsm0808: add function to  translate perm speech to speech codec type

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
---
M include/osmocom/gsm/gsm0808_utils.h
M src/gsm/gsm0808_utils.c
M src/gsm/libosmogsm.map
3 files changed, 50 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/30/2830/1

diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h
index c11bf8d..59f64ca 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -71,3 +71,8 @@
 /* Decode Cell Identifier List element */
 int gsm0808_dec_cell_id_list(struct gsm0808_cell_id_list *cil,
 			     const uint8_t *elem, uint8_t len);
+
+/* 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 */
+int gsm0808_convert_to_speech_codec_type(uint8_t perm_spch);
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index c0c2cc2..edd6317 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -653,3 +653,47 @@
 	cil->id_list_len = item_count;
 	return (int)(elem - old_elem);
 }
+
+/* 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 */
+int gsm0808_convert_to_speech_codec_type(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;
+		break;
+	case GSM0808_PERM_FR2:
+		return GSM0808_SCT_FR2;
+		break;
+	case GSM0808_PERM_FR3:
+		return GSM0808_SCT_FR3;
+		break;
+	case GSM0808_PERM_FR4:
+		return GSM0808_SCT_FR4;
+		break;
+	case GSM0808_PERM_FR5:
+		return GSM0808_SCT_FR5;
+		break;
+	case GSM0808_PERM_HR1:
+		return GSM0808_SCT_HR1;
+		break;
+	case GSM0808_PERM_HR3:
+		return GSM0808_SCT_HR3;
+		break;
+	case GSM0808_PERM_HR4:
+		return GSM0808_SCT_HR4;
+		break;
+	case GSM0808_PERM_HR6:
+		return GSM0808_SCT_HR6;
+		break;
+	}
+
+	/* Invalid input */
+	return -EINVAL;
+}
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 8fb9878..c48b0fc 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -162,6 +162,7 @@
 gsm0808_dec_encrypt_info;
 gsm0808_enc_cell_id_list;
 gsm0808_dec_cell_id_list;
+gsm0808_convert_to_speech_codec_type;
 
 gsm0858_rsl_ul_meas_enc;
 

-- 
To view, visit https://gerrit.osmocom.org/2830
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib26a9c20864459b2baaa04f49b6e7902ba44b7cb
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list