From 45822227577cba5c6c4a4d4d61a7a9e8b4992c25 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 6 Jun 2016 12:49:39 +0200 Subject: 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 Reviewed-on: https://gerrit.osmocom.org/204 Tested-by: Jenkins Builder Reviewed-by: Harald Welte --- src/osmo-bts-litecell15/tch.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'src/osmo-bts-litecell15/tch.c') diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c index a11911c8..15ad4566 100644 --- a/src/osmo-bts-litecell15/tch.c +++ b/src/osmo-bts-litecell15/tch.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -222,10 +223,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; @@ -247,13 +244,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 @@ -264,11 +263,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; @@ -302,12 +297,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 { @@ -316,7 +311,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, -- cgit v1.2.3