[PATCH] libosmocore[master]: gsm0808: add function gsm0808_extrapolate_speech_codec()

2017-06-21 Thread dexter
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2831

to look at the new patch set (#8).

gsm0808: add function gsm0808_extrapolate_speech_codec()

The contents of the speech codec element (struct gsm0808_speech_codec),
that is also used in the speech codec list element (struct
gsm0808_speech_codec_list) can be extrapolated directly from the
permitted speech parameter in the channel type field (struct
gsm0808_channel_type) when full AoIP with compressed speech via
RTP/UDP/IP is assumed and when the codec configuration on the air
interface exactly matches the codec configuration on the IP backhaul.

This patch adds a function that can be used as a helper to fill
out spech codec fields by only giving a permitted speech parameter
as input.

Change-Id: I257c972e9fdf0dfe940a8d483447085bd62e50a2
---
M include/osmocom/gsm/gsm0808_utils.h
M src/gsm/gsm0808_utils.c
M src/gsm/libosmogsm.map
3 files changed, 57 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/31/2831/8

diff --git a/include/osmocom/gsm/gsm0808_utils.h 
b/include/osmocom/gsm/gsm0808_utils.h
index 9057273..0c69e31 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -73,3 +73,5 @@
 const uint8_t *elem, uint8_t len);
 
 int gsm0808_convert_to_speech_codec_type(uint8_t perm_spch);
+int gsm0808_extrapolate_speech_codec(struct gsm0808_speech_codec *sc,
+uint8_t perm_spch);
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index f7062a5..efa29a1 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -682,4 +682,58 @@
return -EINVAL;
 }
 
+/*! \brief Extrapolate a speech codec field from a given permitted speech
+ *  parameter (channel type).
+ *  \param[out] sc Caller provided memory to store the resulting speech codec
+ *  \param[in] perm_spch value that is used to derive the speech codec info
+ *  (see also: enum gsm0808_speech_codec_type in gsm0808_utils.h)
+ *  \returns zero when successful; negative on error */
+int gsm0808_extrapolate_speech_codec(struct gsm0808_speech_codec *sc,
+uint8_t perm_spch)
+{
+   int rc;
+
+   memset(sc, 0, sizeof(*sc));
+
+   /* Determine codec type */
+   rc = gsm0808_convert_to_speech_codec_type(perm_spch);
+   if (rc < 0)
+   return -EINVAL;
+   sc->type = (uint8_t) rc;
+
+   /* Depending on the speech codec type, pick a default codec
+* configuration that exactly matches the configuration on the
+* air interface. */
+   switch (sc->type) {
+   case GSM0808_SCT_FR3:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_FR_AMR;
+   break;
+   case GSM0808_SCT_FR4:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_OFR_AMR_WB;
+   break;
+   case GSM0808_SCT_FR5:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_FR_AMR_WB;
+   break;
+   case GSM0808_SCT_HR3:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_HR_AMR;
+   break;
+   case GSM0808_SCT_HR4:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_OHR_AMR_WB;
+   break;
+   case GSM0808_SCT_HR6:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_OHR_AMR;
+   break;
+   default:
+   /* Note: Not all codec types specify a default setting,
+* in this case, we just set the field to zero. */
+   sc->cfg = 0;
+   }
+
+   /* Tag all codecs as "Full IP"
+* (see als 3GPP TS 48.008 3.2.2.103) */
+   sc->fi = true;
+
+   return 0;
+}
+
 /*! @} */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index ccc5b9a..36cba39 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -163,6 +163,7 @@
 gsm0808_enc_cell_id_list;
 gsm0808_dec_cell_id_list;
 gsm0808_convert_to_speech_codec_type;
+gsm0808_extrapolate_speech_codec;
 
 gsm0858_rsl_ul_meas_enc;
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I257c972e9fdf0dfe940a8d483447085bd62e50a2
Gerrit-PatchSet: 8
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


[PATCH] libosmocore[master]: gsm0808: add function gsm0808_extrapolate_speech_codec()

2017-06-19 Thread dexter
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2831

to look at the new patch set (#7).

gsm0808: add function gsm0808_extrapolate_speech_codec()

The contents of the speech codec element (struct gsm0808_speech_codec),
that is also used in the speech codec list element (struct
gsm0808_speech_codec_list) can be extrapolated directly from the
permitted speech parameter in the channel type field (struct
gsm0808_channel_type) when full AoIP with compressed speech via
RTP/UDP/IP is assumed and when the codec configuration on the air
interface exactly matches the codec configuration on the IP backhaul.

This patch adds a function that can be used as a helper to fill
out spech codec fields by only giving a permitted speech parameter
as input.

Change-Id: I257c972e9fdf0dfe940a8d483447085bd62e50a2
---
M include/osmocom/gsm/gsm0808_utils.h
M src/gsm/gsm0808_utils.c
M src/gsm/libosmogsm.map
3 files changed, 53 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/31/2831/7

diff --git a/include/osmocom/gsm/gsm0808_utils.h 
b/include/osmocom/gsm/gsm0808_utils.h
index 9057273..0c69e31 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -73,3 +73,5 @@
 const uint8_t *elem, uint8_t len);
 
 int gsm0808_convert_to_speech_codec_type(uint8_t perm_spch);
+int gsm0808_extrapolate_speech_codec(struct gsm0808_speech_codec *sc,
+uint8_t perm_spch);
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 2d4b15c..d27ca5b 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -682,4 +682,54 @@
return -EINVAL;
 }
 
+/*! \brief Extrapolate a speech codec field from a given permitted speech
+ *  parameter (channel type).
+ *  \param[out] sc Caller provided memory to store the resulting speech codec
+ *  \param[in] perm_spch value from where the speech codec is derived from
+ *  (see also: enum gsm0808_speech_codec_type in gsm0808_utils.h)
+ *  \returns zero when successful; negative on error */
+int gsm0808_extrapolate_speech_codec(struct gsm0808_speech_codec *sc,
+uint8_t perm_spch)
+{
+   int rc;
+
+   memset(sc, 0, sizeof(*sc));
+
+   /* Determine codec type */
+   rc = gsm0808_convert_to_speech_codec_type(perm_spch);
+   if (rc < 0)
+   return -EINVAL;
+   sc->type = (uint8_t) rc;
+
+   /* Depending on the speech codec type, pick a default codc
+* configuration that exactly matches the configuration on the
+* air interface. */
+   switch (sc->type) {
+   case GSM0808_SCT_FR3:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_FR_AMR;
+   break;
+   case GSM0808_SCT_FR4:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_OFR_AMR_WB;
+   break;
+   case GSM0808_SCT_FR5:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_FR_AMR_WB;
+   break;
+   case GSM0808_SCT_HR3:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_HR_AMR;
+   break;
+   case GSM0808_SCT_HR4:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_OHR_AMR_WB;
+   break;
+   case GSM0808_SCT_HR6:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_OHR_AMR;
+   break;
+   }
+
+   /* Tag all codecs as "Full IP"
+* (see als 3GPP TS 48.008 3.2.2.103) */
+   sc->fi = true;
+
+   return 0;
+}
+
 /*! @} */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index ccc5b9a..36cba39 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -163,6 +163,7 @@
 gsm0808_enc_cell_id_list;
 gsm0808_dec_cell_id_list;
 gsm0808_convert_to_speech_codec_type;
+gsm0808_extrapolate_speech_codec;
 
 gsm0858_rsl_ul_meas_enc;
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I257c972e9fdf0dfe940a8d483447085bd62e50a2
Gerrit-PatchSet: 7
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


[PATCH] libosmocore[master]: gsm0808: add function gsm0808_extrapolate_speech_codec()

2017-06-19 Thread dexter
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2831

to look at the new patch set (#6).

gsm0808: add function gsm0808_extrapolate_speech_codec()

The contents of the speech codec element (struct gsm0808_speech_codec),
that is also used in the speech codec list element (struct
gsm0808_speech_codec_list) can be extrapolated directly from the
permitted speech parameter in the channel type field (struct
gsm0808_channel_type) when full AoIP with compressed speech via
RTP/UDP/IP is assumed and when the codec configuration on the air
interface exactly matches the codec configuration on the IP backhaul.

This patch adds a function that can be used as a helper to fill
out spech codec fields by only giving a permitted speech parameter
as input.

Change-Id: I257c972e9fdf0dfe940a8d483447085bd62e50a2
---
M include/osmocom/gsm/gsm0808_utils.h
M src/gsm/gsm0808_utils.c
M src/gsm/libosmogsm.map
3 files changed, 55 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/31/2831/6

diff --git a/include/osmocom/gsm/gsm0808_utils.h 
b/include/osmocom/gsm/gsm0808_utils.h
index 9057273..0c69e31 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -73,3 +73,5 @@
 const uint8_t *elem, uint8_t len);
 
 int gsm0808_convert_to_speech_codec_type(uint8_t perm_spch);
+int gsm0808_extrapolate_speech_codec(struct gsm0808_speech_codec *sc,
+uint8_t perm_spch);
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 2d4b15c..eeb9b42 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -682,4 +682,56 @@
return -EINVAL;
 }
 
+/*! \brief Extrapolate a speech codec field from a given permitted speech
+ *  parameter (channel type).
+ *  \param[out] sc Caller provided memory to store the resulting speech codec
+ *  \param[in] perm_spch value from where the speech codec is derived from
+ *  (see also: enum gsm0808_speech_codec_type in gsm0808_utils.h)
+ *  \returns zero when successful; negative on error */
+int gsm0808_extrapolate_speech_codec(struct gsm0808_speech_codec *sc,
+uint8_t perm_spch)
+{
+   int rc;
+
+   memset(sc, 0, sizeof(*sc));
+
+   /* Determine codec type */
+   rc = gsm0808_convert_to_speech_codec_type(perm_spch);
+   if (rc < 0)
+   return -EINVAL;
+   sc->type = (uint8_t) rc;
+
+   /* Depending on the speech codec type, pick a default codc
+* configuration that exactly matches the configuration on the
+* air interface. */
+   switch (sc->type) {
+   case GSM0808_SCT_FR3:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_FR_AMR;
+   break;
+   case GSM0808_SCT_FR4:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_OFR_AMR_WB;
+   break;
+   case GSM0808_SCT_FR5:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_FR_AMR_WB;
+   break;
+   case GSM0808_SCT_HR3:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_HR_AMR;
+   break;
+   case GSM0808_SCT_HR4:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_OHR_AMR_WB;
+   break;
+   case GSM0808_SCT_HR6:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_OHR_AMR;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   /* Tag all codecs as "Full IP"
+* (see als 3GPP TS 48.008 3.2.2.103) */
+   sc->fi = true;
+
+   return 0;
+}
+
 /*! @} */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index ccc5b9a..36cba39 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -163,6 +163,7 @@
 gsm0808_enc_cell_id_list;
 gsm0808_dec_cell_id_list;
 gsm0808_convert_to_speech_codec_type;
+gsm0808_extrapolate_speech_codec;
 
 gsm0858_rsl_ul_meas_enc;
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I257c972e9fdf0dfe940a8d483447085bd62e50a2
Gerrit-PatchSet: 6
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


[PATCH] libosmocore[master]: gsm0808: add function gsm0808_extrapolate_speech_codec()

2017-06-16 Thread dexter
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2831

to look at the new patch set (#4).

gsm0808: add function gsm0808_extrapolate_speech_codec()

The contents of the speech codec element (struct gsm0808_speech_codec),
that is also used in the speech codec list element (struct
gsm0808_speech_codec_list) can be extrapolated directly from the
permitted speech parameter in the channel type field (struct
gsm0808_channel_type) when full AoIP with compressed speech via
RTP/UDP/IP is assumed and when the codec configuration on the air
interface exactly matches the codec configuration on the IP backhaul.

This patch adds a function that can be used as a helper to fill
out spech codec fields by only giving a permitted speech parameter
as input.

Change-Id: I257c972e9fdf0dfe940a8d483447085bd62e50a2
---
M include/osmocom/gsm/gsm0808_utils.h
M src/gsm/gsm0808_utils.c
M src/gsm/libosmogsm.map
3 files changed, 63 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/31/2831/4

diff --git a/include/osmocom/gsm/gsm0808_utils.h 
b/include/osmocom/gsm/gsm0808_utils.h
index 59f64ca..2a53508 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -76,3 +76,7 @@
  * 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);
+
+/* Extrapolate a speech codec field from a given permitted speech parameter */
+int gsm0808_extrapolate_speech_codec(struct gsm0808_speech_codec *sc,
+uint8_t perm_spch);
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 5ff280a..8282f02 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -684,4 +684,62 @@
return -EINVAL;
 }
 
+/*! \brief Extrapolate a speech codec field from a given permitted
+ *  speech parameter 
+ *  \param[out] sc Caller provided memory to store the resulting speech codec
+ *  \param[in] perm_spch value from where the speech codec is derived from
+ *  \returns zero when successfull; negative on error */
+int gsm0808_extrapolate_speech_codec(struct gsm0808_speech_codec *sc,
+uint8_t perm_spch)
+{
+   /*! Note: This function accepts the permitted speech configuration
+*  from the channel type information and computes an AoIP speech
+*  codec that field that consistently matches the channel type
+*  configuration. This reflects a a non-transcoding-situation.
+*  (In transcoding scenarios, the codec used in the RTP stream
+*  may be differ from the codec used on the air interface) */
+
+   int rc;
+
+   memset(sc, 0, sizeof(*sc));
+
+   /* Determine codec type */
+   rc = gsm0808_convert_to_speech_codec_type(perm_spch);
+   if (rc < 0)
+   return -EINVAL;
+   sc->type = (uint8_t) rc;
+
+   /* Depending on the speech codec type, pick a default codc
+* configuration that exactly matches the configuration on the
+* air interface. */
+   switch (sc->type) {
+   case GSM0808_SCT_FR3:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_FR_AMR;
+   break;
+   case GSM0808_SCT_FR4:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_OFR_AMR_WB;
+   break;
+   case GSM0808_SCT_FR5:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_FR_AMR_WB;
+   break;
+   case GSM0808_SCT_HR3:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_HR_AMR;
+   break;
+   case GSM0808_SCT_HR4:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_OHR_AMR_WB;
+   break;
+   case GSM0808_SCT_HR6:
+   sc->cfg = GSM0808_SC_CFG_DEFAULT_OHR_AMR;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   /* Tag all codecs as "Full IP"
+* (see als 3GPP TS 48.008 3.2.2.103) */
+   sc->fi = true;
+
+   return 0;
+}
+
 /*! @} */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index ccc5b9a..36cba39 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -163,6 +163,7 @@
 gsm0808_enc_cell_id_list;
 gsm0808_dec_cell_id_list;
 gsm0808_convert_to_speech_codec_type;
+gsm0808_extrapolate_speech_codec;
 
 gsm0858_rsl_ul_meas_enc;
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I257c972e9fdf0dfe940a8d483447085bd62e50a2
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr