aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-sysmo/tch.c
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-06-13 11:33:43 +0200
committerHarald Welte <laforge@gnumonks.org>2016-06-14 10:19:13 +0000
commita10ac248c6b6efe3f1fa1fd85331b32e7941c981 (patch)
treef32afe75d05b50725fe01429cb73cf94532517c1 /src/osmo-bts-sysmo/tch.c
parent60970056c87180c88539fcc6e3b0ba72e0f3d674 (diff)
DTXu: mark beginning of speech burst in RTP
Set Marker bit in RTP header to mark the beginning of talkspurt. Change-Id: I3dd70ad8ff94356e3c3cc5458255f6c23534783e Related: OS#1562
Diffstat (limited to 'src/osmo-bts-sysmo/tch.c')
-rw-r--r--src/osmo-bts-sysmo/tch.c50
1 files changed, 44 insertions, 6 deletions
diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c
index 07a0efb2..a391fcca 100644
--- a/src/osmo-bts-sysmo/tch.c
+++ b/src/osmo-bts-sysmo/tch.c
@@ -91,7 +91,8 @@ void osmo_nibble_shift_left_unal(uint8_t *out, const uint8_t *in,
}
-static struct msgb *l1_to_rtppayload_fr(uint8_t *l1_payload, uint8_t payload_len)
+static struct msgb *l1_to_rtppayload_fr(uint8_t *l1_payload, uint8_t payload_len,
+ struct gsm_lchan *lchan)
{
struct msgb *msg;
uint8_t *cur;
@@ -116,6 +117,13 @@ static struct msgb *l1_to_rtppayload_fr(uint8_t *l1_payload, uint8_t payload_len
cur[0] |= 0xD0;
#endif /* USE_L1_RTP_MODE */
+ if (osmo_fr_check_sid(l1_payload, payload_len))
+ lchan->tch.ul_sid = true;
+ else if (lchan->tch.ul_sid) {
+ lchan->tch.ul_sid = false;
+ lchan->rtp_tx_marker = true;
+ }
+
return msg;
}
@@ -142,7 +150,9 @@ static int rtppayload_to_l1_fr(uint8_t *l1_payload, const uint8_t *rtp_payload,
}
#if defined(L1_HAS_EFR) && defined(USE_L1_RTP_MODE)
-static struct msgb *l1_to_rtppayload_efr(uint8_t *l1_payload, uint8_t payload_len)
+static struct msgb *l1_to_rtppayload_efr(uint8_t *l1_payload,
+ uint8_t payload_len,
+ struct gsm_lchan *lchan)
{
struct msgb *msg;
uint8_t *cur;
@@ -166,6 +176,17 @@ static struct msgb *l1_to_rtppayload_efr(uint8_t *l1_payload, uint8_t payload_le
cur[0] |= 0xC0;
#endif /* USE_L1_RTP_MODE */
+ enum osmo_amr_type ft;
+ enum osmo_amr_quality bfi;
+ uint8_t cmr;
+ int8_t sti, cmi;
+ osmo_amr_rtp_dec(l1_payload, payload_len, &cmr, &cmi, &ft, &bfi, &sti);
+ if (ft == AMR_GSM_EFR_SID)
+ lchan->tch.ul_sid = true;
+ else if (lchan->tch.ul_sid) {
+ lchan->tch.ul_sid = false;
+ lchan->rtp_tx_marker = true;
+ }
return msg;
}
@@ -184,7 +205,8 @@ static int rtppayload_to_l1_efr(uint8_t *l1_payload, const uint8_t *rtp_payload,
#warning No EFR support in L1
#endif /* L1_HAS_EFR */
-static struct msgb *l1_to_rtppayload_hr(uint8_t *l1_payload, uint8_t payload_len)
+static struct msgb *l1_to_rtppayload_hr(uint8_t *l1_payload, uint8_t payload_len,
+ struct gsm_lchan *lchan)
{
struct msgb *msg;
uint8_t *cur;
@@ -207,6 +229,13 @@ static struct msgb *l1_to_rtppayload_hr(uint8_t *l1_payload, uint8_t payload_len
osmo_revbytebits_buf(cur, GSM_HR_BYTES);
#endif /* USE_L1_RTP_MODE */
+ if (osmo_hr_check_sid(l1_payload, payload_len))
+ lchan->tch.ul_sid = true;
+ else if (lchan->tch.ul_sid) {
+ lchan->tch.ul_sid = false;
+ lchan->rtp_tx_marker = true;
+ }
+
return msg;
}
@@ -525,6 +554,15 @@ int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg)
lchan->type != GSM_LCHAN_TCH_F)
goto err_payload_match;
break;
+ case GsmL1_TchPlType_Amr_Onset:
+ if (lchan->type != GSM_LCHAN_TCH_H &&
+ lchan->type != GSM_LCHAN_TCH_F)
+ goto err_payload_match;
+ /* according to 3GPP TS 26.093 ONSET frames precede the first
+ speech frame of a speech burst - set the marker for next RTP
+ frame and drop last SID */
+ lchan->rtp_tx_marker = true;
+ break;
default:
LOGP(DL1C, LOGL_NOTICE, "%s Rx Payload Type %s is unsupported\n",
gsm_lchan_name(lchan),
@@ -535,14 +573,14 @@ int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg)
switch (payload_type) {
case GsmL1_TchPlType_Fr:
- rmsg = l1_to_rtppayload_fr(payload, payload_len);
+ rmsg = l1_to_rtppayload_fr(payload, payload_len, lchan);
break;
case GsmL1_TchPlType_Hr:
- rmsg = l1_to_rtppayload_hr(payload, payload_len);
+ rmsg = l1_to_rtppayload_hr(payload, payload_len, lchan);
break;
#if defined(L1_HAS_EFR) && defined(USE_L1_RTP_MODE)
case GsmL1_TchPlType_Efr:
- rmsg = l1_to_rtppayload_efr(payload, payload_len);
+ rmsg = l1_to_rtppayload_efr(payload, payload_len, lchan);
break;
#endif
case GsmL1_TchPlType_Amr: