aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-litecell15/tch.c
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-09-30 19:09:04 +0200
committerMax <msuraev@sysmocom.de>2016-09-30 19:09:04 +0200
commit067ef3f1ce1b7474a553bb8e54ff1543c4012828 (patch)
treedd96bd6d72a529de7fb27956f4d5e38008a25ceb /src/osmo-bts-litecell15/tch.c
parent9959f45d90166331dc8196c603184888bbe7f1e8 (diff)
DTX: move ONSET detection into separate function
Move code from tch.c (lc15, sysmo) into generic function which: - check if talkspurt is happening - cache SID if necessary or invalidate cache - fill in CMR & CMI prefix This also fixes the problem when SID FIRST was cached without sending just like SID UPDATE instead of being sent right away. Change-Id: I6c7016a54749abadeef4fd4f5b6f750b256fb916
Diffstat (limited to 'src/osmo-bts-litecell15/tch.c')
-rw-r--r--src/osmo-bts-litecell15/tch.c55
1 files changed, 19 insertions, 36 deletions
diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c
index 5b5a375d..bcb1edda 100644
--- a/src/osmo-bts-litecell15/tch.c
+++ b/src/osmo-bts-litecell15/tch.c
@@ -199,13 +199,10 @@ static struct msgb *l1_to_rtppayload_amr(uint8_t *l1_payload, uint8_t payload_le
*/
static int rtppayload_to_l1_amr(uint8_t *l1_payload, const uint8_t *rtp_payload,
uint8_t payload_len,
- struct gsm_lchan *lchan, uint8_t cmr, int8_t cmi,
- uint8_t ft)
+ struct gsm_lchan *lchan, uint8_t ft)
{
- memcpy(l1_payload+2, rtp_payload, payload_len);
- amr_set_mode_pref(l1_payload, &lchan->tch.amr_mr, cmi, cmr);
-
- return payload_len + 2;
+ memcpy(l1_payload, rtp_payload, payload_len);
+ return payload_len;
}
#define RTP_MSGB_ALLOC_SIZE 512
@@ -227,11 +224,8 @@ bool l1if_tch_encode(struct gsm_lchan *lchan, uint8_t *data, uint8_t *len,
const uint8_t *rtp_pl, unsigned int rtp_pl_len, uint32_t fn, bool marker)
{
uint8_t *payload_type;
- uint8_t *l1_payload, cmr;
- enum osmo_amr_type ft;
- enum osmo_amr_quality bfi;
- int8_t sti, cmi;
- int rc;
+ uint8_t *l1_payload, ft;
+ int rc = 0;
bool is_sid = false;
DEBUGP(DRTP, "%s RTP IN: %s\n", gsm_lchan_name(lchan),
@@ -265,36 +259,25 @@ bool l1if_tch_encode(struct gsm_lchan *lchan, uint8_t *data, uint8_t *len,
/* FIXME: detect and save EFR SID */
break;
case GSM48_CMODE_SPEECH_AMR:
- osmo_amr_rtp_dec(rtp_pl, rtp_pl_len, &cmr, &cmi, &ft, &bfi,
- &sti);
- if (ft == AMR_SID) {
- save_last_sid(lchan, rtp_pl, rtp_pl_len, fn, sti, cmr,
- cmi);
- return false;
- }
- if (ft != AMR_NO_DATA && !osmo_amr_is_speech(ft)) {
- LOGP(DRTP, LOGL_ERROR, "unsupported AMR FT 0x%02x\n",
- ft);
- return false;
- }
- if (osmo_amr_is_speech(ft)) {
- if (lchan->tch.last_sid.len) { /* FIXME: force ONSET */
- marker = true;
- }
- /* We received AMR SPEECH frame - invalidate saved SID */
- lchan->tch.last_sid.len = 0;
- }
- if (marker) {
+ rc = dtx_amr_check_onset(lchan, rtp_pl, rtp_pl_len, fn,
+ l1_payload, &ft);
+
+ if (marker || rc > 0) {
*payload_type = GsmL1_TchPlType_Amr_Onset;
- rc = 0;
- LOGP(DRTP, LOGL_ERROR, "Marker SPEECH frame AMR %s\n",
+ *len = 1;
+ if (rc != 0) {
+ LOGP(DRTP, LOGL_NOTICE, "%s SPEECH frame without"
+ " Marker: ONSET forced\n",
+ get_value_string(osmo_amr_type_names, ft));
+ return true;
+ }
+ LOGP(DRTP, LOGL_DEBUG, "%s SPEECH frame with Marker\n",
get_value_string(osmo_amr_type_names, ft));
}
else {
*payload_type = GsmL1_TchPlType_Amr;
- rc = rtppayload_to_l1_amr(l1_payload, rtp_pl,
- rtp_pl_len, lchan, cmr, cmi,
- ft);
+ rc = 2 + rtppayload_to_l1_amr(l1_payload + 2, rtp_pl,
+ rtp_pl_len, lchan, ft);
}
break;
default: