aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-06-06 12:49:39 +0200
committerMax <msuraev@sysmocom.de>2016-06-10 14:45:11 +0200
commitc00a2d69d3f44e47ffeeb4561174c1f16dfc261c (patch)
tree6fa96fa1176e5a678b3bade7692bbbc57e2246ca
parenta6ee8245923ee907a18a062c8a36a523ddfe36b0 (diff)
Use libosmocodec for AMR RTP
Use libosmocodec function to parse RTP with AMR payload in sysmoBTS and LC15. This replaces "manual" parsing of AMR frame with function covered by test suite and makes adding DTXd support easier. Related: OS#1563 Change-Id: I1464f9a12e3f92926d03d5dd5d18e8f0f7206dd9
-rw-r--r--src/osmo-bts-litecell15/Makefile.am4
-rw-r--r--src/osmo-bts-litecell15/tch.c25
-rw-r--r--src/osmo-bts-sysmo/Makefile.am4
-rw-r--r--src/osmo-bts-sysmo/tch.c26
-rw-r--r--tests/sysmobts/Makefile.am4
5 files changed, 27 insertions, 36 deletions
diff --git a/src/osmo-bts-litecell15/Makefile.am b/src/osmo-bts-litecell15/Makefile.am
index 5b63001..768e29d 100644
--- a/src/osmo-bts-litecell15/Makefile.am
+++ b/src/osmo-bts-litecell15/Makefile.am
@@ -1,8 +1,8 @@
AUTOMAKE_OPTIONS = subdir-objects
AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR) -I$(LITECELL15_INCDIR)
-AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(LIBGPS_CFLAGS)
-COMMON_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) $(LIBOSMOCTRL_LIBS) -lortp
+AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCODEC_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(LIBGPS_CFLAGS) $(ORTP_CFLAGS)
+COMMON_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) $(LIBOSMOCTRL_LIBS) $(ORTP_LIBS)
EXTRA_DIST = misc/lc15bts_mgr.h misc/lc15bts_misc.h misc/lc15bts_par.h \
misc/lc15bts_temp.h misc/lc15bts_power.h misc/lc15bts_clock.h \
diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c
index d09264a..5a76fb9 100644
--- a/src/osmo-bts-litecell15/tch.c
+++ b/src/osmo-bts-litecell15/tch.c
@@ -35,6 +35,7 @@
#include <osmocom/core/select.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/bits.h>
+#include <osmocom/codec/codec.h>
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/trau/osmo_ortp.h>
@@ -268,10 +269,6 @@ static struct msgb *l1_to_rtppayload_amr(uint8_t *l1_payload, uint8_t payload_le
return msg;
}
-enum amr_frame_type {
- AMR_FT_SID_AMR = 8,
-};
-
int get_amr_mode_idx(const struct amr_multirate_conf *amr_mrc, uint8_t cmi)
{
unsigned int i;
@@ -293,13 +290,15 @@ static int rtppayload_to_l1_amr(uint8_t *l1_payload, const uint8_t *rtp_payload,
struct gsm_lchan *lchan)
{
struct amr_multirate_conf *amr_mrc = &lchan->tch.amr_mr;
- uint8_t ft = (rtp_payload[1] >> 3) & 0xf;
- uint8_t cmr = rtp_payload[0] >> 4;
- uint8_t cmi, sti;
+ enum osmo_amr_type ft;
+ enum osmo_amr_quality bfi;
+ uint8_t cmr;
+ int8_t sti, cmi;
uint8_t *l1_cmi_idx = l1_payload;
uint8_t *l1_cmr_idx = l1_payload+1;
int rc;
+ osmo_amr_rtp_dec(rtp_payload, payload_len, &cmr, &cmi, &ft, &bfi, &sti);
memcpy(l1_payload+2, rtp_payload, payload_len);
/* CMI in downlink tells the L1 encoder which encoding function
@@ -310,11 +309,7 @@ static int rtppayload_to_l1_amr(uint8_t *l1_payload, const uint8_t *rtp_payload,
cmi = ft;
LOGP(DRTP, LOGL_DEBUG, "SPEECH frame with CMI %u\n", cmi);
break;
- case AMR_FT_SID_AMR:
- /* extract the mode indiciation from last bits of
- * 39 bit SID frame (Table 6 / 26.101) */
- cmi = (rtp_payload[2+4] >> 1) & 0x7;
- sti = rtp_payload[2+4] & 0x10;
+ case AMR_SID:
LOGP(DRTP, LOGL_DEBUG, "SID %s frame with CMI %u\n",
sti ? "UPDATE" : "FIRST", cmi);
break;
@@ -348,12 +343,12 @@ static int rtppayload_to_l1_amr(uint8_t *l1_payload, const uint8_t *rtp_payload,
}
#if 0
/* check for bad quality indication */
- if (rtp_payload[1] & AMR_TOC_QBIT) {
+ if (bfi == AMR_GOOD) {
/* obtain frame type from AMR FT */
l1_payload[2] = ft;
} else {
/* bad quality, we should indicate that... */
- if (ft == AMR_FT_SID_AMR) {
+ if (ft == AMR_SID) {
/* FIXME: Should we do GsmL1_TchPlType_Amr_SidBad? */
l1_payload[2] = ft;
} else {
@@ -362,7 +357,7 @@ static int rtppayload_to_l1_amr(uint8_t *l1_payload, const uint8_t *rtp_payload,
}
#endif
- if (ft == AMR_FT_SID_AMR) {
+ if (ft == AMR_SID) {
/* store the last SID frame in lchan context */
unsigned int copy_len;
copy_len = OSMO_MIN(payload_len+1,
diff --git a/src/osmo-bts-sysmo/Makefile.am b/src/osmo-bts-sysmo/Makefile.am
index 9ed89dc..34f4bb0 100644
--- a/src/osmo-bts-sysmo/Makefile.am
+++ b/src/osmo-bts-sysmo/Makefile.am
@@ -1,6 +1,6 @@
AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR)
-AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(LIBGPS_CFLAGS) $(ORTP_CFLAGS)
-COMMON_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) $(LIBOSMOCTRL_LIBS) $(ORTP_LIBS)
+AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCODEC_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(LIBGPS_CFLAGS) $(ORTP_CFLAGS)
+COMMON_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) $(LIBOSMOCTRL_LIBS) $(ORTP_LIBS)
EXTRA_DIST = misc/sysmobts_mgr.h misc/sysmobts_misc.h misc/sysmobts_par.h \
misc/sysmobts_eeprom.h misc/sysmobts_nl.h femtobts.h hw_misc.h \
diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c
index 13f9ec6..2436c06 100644
--- a/src/osmo-bts-sysmo/tch.c
+++ b/src/osmo-bts-sysmo/tch.c
@@ -32,6 +32,7 @@
#include <osmocom/core/select.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/bits.h>
+#include <osmocom/codec/codec.h>
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/trau/osmo_ortp.h>
@@ -343,10 +344,6 @@ static struct msgb *l1_to_rtppayload_amr(uint8_t *l1_payload, uint8_t payload_le
return msg;
}
-enum amr_frame_type {
- AMR_FT_SID_AMR = 8,
-};
-
int get_amr_mode_idx(const struct amr_multirate_conf *amr_mrc, uint8_t cmi)
{
unsigned int i;
@@ -368,13 +365,16 @@ static int rtppayload_to_l1_amr(uint8_t *l1_payload, const uint8_t *rtp_payload,
struct gsm_lchan *lchan)
{
struct amr_multirate_conf *amr_mrc = &lchan->tch.amr_mr;
- uint8_t ft = (rtp_payload[1] >> 3) & 0xf;
- uint8_t cmr = rtp_payload[0] >> 4;
- uint8_t cmi, sti;
+ enum osmo_amr_type ft;
+ enum osmo_amr_quality bfi;
+ uint8_t cmr;
+ int8_t sti, cmi;
uint8_t *l1_cmi_idx = l1_payload;
uint8_t *l1_cmr_idx = l1_payload+1;
int rc;
+ osmo_amr_rtp_dec(rtp_payload, payload_len, &cmr, &cmi, &ft, &bfi, &sti);
+
#ifdef USE_L1_RTP_MODE
memcpy(l1_payload+2, rtp_payload, payload_len);
#else
@@ -398,11 +398,7 @@ static int rtppayload_to_l1_amr(uint8_t *l1_payload, const uint8_t *rtp_payload,
cmi = ft;
LOGP(DRTP, LOGL_DEBUG, "SPEECH frame with CMI %u\n", cmi);
break;
- case AMR_FT_SID_AMR:
- /* extract the mode indiciation from last bits of
- * 39 bit SID frame (Table 6 / 26.101) */
- cmi = (rtp_payload[2+4] >> 1) & 0x7;
- sti = rtp_payload[2+4] & 0x10;
+ case AMR_SID:
LOGP(DRTP, LOGL_DEBUG, "SID %s frame with CMI %u\n",
sti ? "UPDATE" : "FIRST", cmi);
break;
@@ -436,12 +432,12 @@ static int rtppayload_to_l1_amr(uint8_t *l1_payload, const uint8_t *rtp_payload,
}
#if 0
/* check for bad quality indication */
- if (rtp_payload[1] & AMR_TOC_QBIT) {
+ if (bfi == AMR_GOOD) {
/* obtain frame type from AMR FT */
l1_payload[2] = ft;
} else {
/* bad quality, we should indicate that... */
- if (ft == AMR_FT_SID_AMR) {
+ if (ft == AMR_SID) {
/* FIXME: Should we do GsmL1_TchPlType_Amr_SidBad? */
l1_payload[2] = ft;
} else {
@@ -450,7 +446,7 @@ static int rtppayload_to_l1_amr(uint8_t *l1_payload, const uint8_t *rtp_payload,
}
#endif
- if (ft == AMR_FT_SID_AMR) {
+ if (ft == AMR_SID) {
/* store the last SID frame in lchan context */
unsigned int copy_len;
copy_len = OSMO_MIN(payload_len+1,
diff --git a/tests/sysmobts/Makefile.am b/tests/sysmobts/Makefile.am
index a00e7c2..2f267f3 100644
--- a/tests/sysmobts/Makefile.am
+++ b/tests/sysmobts/Makefile.am
@@ -1,6 +1,6 @@
AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR) -I$(top_srcdir)/src/osmo-bts-sysmo
-AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(ORTP_CFLAGS)
-LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(ORTP_LIBS)
+AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCODEC_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(ORTP_CFLAGS)
+LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(ORTP_LIBS)
noinst_PROGRAMS = sysmobts_test
EXTRA_DIST = sysmobts_test.ok