[PATCH] osmo-bts[master]: DTX: check Marker bit to send ONSET to L1

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Sat Sep 17 11:23:21 UTC 2016


Hello Harald Welte, Jenkins Builder,

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

    https://gerrit.osmocom.org/691

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

DTX: check Marker bit to send ONSET to L1

If Marker bit is set than it's a talkspurt which we have to explicitly
indicate to L1 by first sending ONSET message and than actual voice
data in a separate message.

This change affect sysmobts and LC15 hw.

Change-Id: I88c41568bcb0d82699f617adc4ad192603dd1bb6
Related: OS#1750
---
M include/osmo-bts/l1sap.h
M src/common/l1sap.c
M src/osmo-bts-litecell15/l1_if.c
M src/osmo-bts-litecell15/l1_if.h
M src/osmo-bts-litecell15/tch.c
M src/osmo-bts-sysmo/l1_if.c
M src/osmo-bts-sysmo/l1_if.h
M src/osmo-bts-sysmo/tch.c
8 files changed, 75 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/91/691/5

diff --git a/include/osmo-bts/l1sap.h b/include/osmo-bts/l1sap.h
index 2735574..981cd75 100644
--- a/include/osmo-bts/l1sap.h
+++ b/include/osmo-bts/l1sap.h
@@ -55,7 +55,7 @@
 
 /* call-back function for incoming RTP */
 void l1sap_rtp_rx_cb(struct osmo_rtp_socket *rs, const uint8_t *rtp_pl,
-	unsigned int rtp_pl_len);
+		     unsigned int rtp_pl_len, bool marker);
 
 /* channel control */
 int l1sap_chan_act(struct gsm_bts_trx *trx, uint8_t chan_nr, struct tlv_parsed *tp);
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 7eb0b62..a89d257 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -24,7 +24,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
-
+#include <stdbool.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -659,7 +659,7 @@
 	struct osmo_phsap_prim *resp_l1sap, empty_l1sap;
 	struct gsm_time g_time;
 	struct gsm_lchan *lchan;
-	uint8_t chan_nr;
+	uint8_t chan_nr, marker = 0;
 	uint32_t fn;
 
 	chan_nr = rts_ind->chan_nr;
@@ -691,6 +691,9 @@
 			gsm_lchan_name(lchan));
 		resp_l1sap = &empty_l1sap;
 	} else {
+		/* Obtain RTP header Marker bit from control buffer */
+		marker = resp_msg->cb[0];
+
 		resp_msg->l2h = resp_msg->data;
 		msgb_push(resp_msg, sizeof(*resp_l1sap));
 		resp_msg->l1h = resp_msg->data;
@@ -702,6 +705,7 @@
 		resp_msg);
 	resp_l1sap->u.tch.chan_nr = chan_nr;
 	resp_l1sap->u.tch.fn = fn;
+	resp_l1sap->u.tch.marker = marker;
 
 	DEBUGP(DL1P, "Tx TCH.req %02u/%02u/%02u chan_nr=%d\n",
 		g_time.t1, g_time.t2, g_time.t3, chan_nr);
@@ -1050,7 +1054,7 @@
 
 /*! \brief call-back function for incoming RTP */
 void l1sap_rtp_rx_cb(struct osmo_rtp_socket *rs, const uint8_t *rtp_pl,
-                     unsigned int rtp_pl_len)
+                     unsigned int rtp_pl_len, bool marker)
 {
 	struct gsm_lchan *lchan = rs->priv;
 	struct msgb *msg, *tmp;
@@ -1063,6 +1067,8 @@
 	memcpy(msgb_put(msg, rtp_pl_len), rtp_pl, rtp_pl_len);
 	msgb_pull(msg, sizeof(*l1sap));
 
+	/* Store RTP header Marker bit in control buffer */
+	msg->cb[0] = marker;
 
 	 /* make sure the queue doesn't get too long */
 	llist_for_each_entry(tmp, &lchan->dl_tch_queue, list)
diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c
index 3672b8f..a7f0475 100644
--- a/src/osmo-bts-litecell15/l1_if.c
+++ b/src/osmo-bts-litecell15/l1_if.c
@@ -469,7 +469,7 @@
 		l1if_tch_encode(lchan,
 			l1p->u.phDataReq.msgUnitParam.u8Buffer,
 			&l1p->u.phDataReq.msgUnitParam.u8Size,
-			msg->data, msg->len);
+			msg->data, msg->len, l1sap->u.tch.marker);
 	}
 
 	/* no message/data, we generate an empty traffic msg */
@@ -500,7 +500,13 @@
 	/* send message to DSP's queue */
 	osmo_wqueue_enqueue(&fl1->write_q[MQ_L1_WRITE], nmsg);
 
-	msgb_free(msg);
+	if (l1sap->u.tch.marker) { /* Send voice after ONSET was sent */
+		l1sap->u.tch.marker = 0;
+		return ph_tch_req(trx, l1sap->oph.msg, l1sap);
+	}
+
+	if (msg)
+		msgb_free(msg);
 	return 0;
 }
 
diff --git a/src/osmo-bts-litecell15/l1_if.h b/src/osmo-bts-litecell15/l1_if.h
index 2d136af..7dd4f95 100644
--- a/src/osmo-bts-litecell15/l1_if.h
+++ b/src/osmo-bts-litecell15/l1_if.h
@@ -11,6 +11,8 @@
 
 #include <nrw/litecell15/gsml1prim.h>
 
+#include <stdbool.h>
+
 enum {
 	MQ_SYS_READ,
 	MQ_L1_READ,
@@ -88,7 +90,7 @@
 
 /* tch.c */
 void l1if_tch_encode(struct gsm_lchan *lchan, uint8_t *data, uint8_t *len,
-	const uint8_t *rtp_pl, unsigned int rtp_pl_len);
+	const uint8_t *rtp_pl, unsigned int rtp_pl_len, bool marker);
 int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg);
 int l1if_tch_fill(struct gsm_lchan *lchan, uint8_t *l1_buffer);
 struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan, uint32_t fn);
diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c
index 187f688..bd0b6eb 100644
--- a/src/osmo-bts-litecell15/tch.c
+++ b/src/osmo-bts-litecell15/tch.c
@@ -26,7 +26,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
-
+#include <stdbool.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -222,6 +222,9 @@
 		cmi = ft;
 		LOGP(DRTP, LOGL_DEBUG, "SPEECH frame with CMI %u\n", cmi);
 		break;
+	case AMR_NO_DATA:
+		LOGP(DRTP, LOGL_DEBUG, "SPEECH frame AMR NO_DATA\n");
+		break;
 	case AMR_SID:
 		LOGP(DRTP, LOGL_DEBUG, "SID %s frame with CMI %u\n",
 		     sti ? "UPDATE" : "FIRST", cmi);
@@ -288,6 +291,7 @@
  *  \param rs RTP Socket
  *  \param[in] rtp_pl buffer containing RTP payload
  *  \param[in] rtp_pl_len length of \a rtp_pl
+ *  \param[in] marker RTP header Marker bit (indicates speech onset)
  *
  * This function prepares a msgb with a L1 PH-DATA.req primitive and
  * queues it into lchan->dl_tch_queue.
@@ -297,10 +301,13 @@
  * pre-fill the primtive.
  */
 void l1if_tch_encode(struct gsm_lchan *lchan, uint8_t *data, uint8_t *len,
-	const uint8_t *rtp_pl, unsigned int rtp_pl_len)
+		     const uint8_t *rtp_pl, unsigned int rtp_pl_len, bool marker)
 {
 	uint8_t *payload_type;
-	uint8_t *l1_payload;
+	uint8_t *l1_payload, cmr;
+	enum osmo_amr_type ft;
+	enum osmo_amr_quality bfi;
+	int8_t sti, cmi;
 	int rc;
 
 	DEBUGP(DRTP, "%s RTP IN: %s\n", gsm_lchan_name(lchan),
@@ -327,9 +334,19 @@
 					  rtp_pl_len);
 		break;
 	case GSM48_CMODE_SPEECH_AMR:
-		*payload_type = GsmL1_TchPlType_Amr;
-		rc = rtppayload_to_l1_amr(l1_payload, rtp_pl,
-					  rtp_pl_len, lchan);
+		if (marker) {
+			*payload_type = GsmL1_TchPlType_Amr_Onset;
+			rc = 0;
+			osmo_amr_rtp_dec(rtp_pl, rtp_pl_len, &cmr, &cmi, &ft,
+					 &bfi, &sti);
+			LOGP(DRTP, LOGL_ERROR, "Marker SPEECH frame AMR %s\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);
+		}
 		break;
 	default:
 		/* we don't support CSD modes */
diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c
index 0880ee9..26b1819 100644
--- a/src/osmo-bts-sysmo/l1_if.c
+++ b/src/osmo-bts-sysmo/l1_if.c
@@ -462,7 +462,7 @@
 		l1if_tch_encode(lchan,
 			l1p->u.phDataReq.msgUnitParam.u8Buffer,
 			&l1p->u.phDataReq.msgUnitParam.u8Size,
-			msg->data, msg->len);
+			msg->data, msg->len, l1sap->u.tch.marker);
 	}
 
 	/* no message/data, we generate an empty traffic msg */
@@ -493,6 +493,11 @@
 	/* send message to DSP's queue */
 	osmo_wqueue_enqueue(&fl1->write_q[MQ_L1_WRITE], nmsg);
 
+	if (l1sap->u.tch.marker) { /* Send voice after ONSET was sent */
+		l1sap->u.tch.marker = 0;
+		return ph_tch_req(trx, l1sap->oph.msg, l1sap);
+	}
+
 	return 0;
 }
 
diff --git a/src/osmo-bts-sysmo/l1_if.h b/src/osmo-bts-sysmo/l1_if.h
index 2fc8a29..47720d5 100644
--- a/src/osmo-bts-sysmo/l1_if.h
+++ b/src/osmo-bts-sysmo/l1_if.h
@@ -11,6 +11,8 @@
 
 #include <sysmocom/femtobts/gsml1prim.h>
 
+#include <stdbool.h>
+
 enum {
 	MQ_SYS_READ,
 	MQ_L1_READ,
@@ -108,7 +110,7 @@
 
 /* tch.c */
 void l1if_tch_encode(struct gsm_lchan *lchan, uint8_t *data, uint8_t *len,
-	const uint8_t *rtp_pl, unsigned int rtp_pl_len);
+	const uint8_t *rtp_pl, unsigned int rtp_pl_len, bool marker);
 int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg);
 int l1if_tch_fill(struct gsm_lchan *lchan, uint8_t *l1_buffer);
 struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan, uint32_t fn);
diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c
index 39feae1..4989b52 100644
--- a/src/osmo-bts-sysmo/tch.c
+++ b/src/osmo-bts-sysmo/tch.c
@@ -319,6 +319,9 @@
 		cmi = ft;
 		LOGP(DRTP, LOGL_DEBUG, "SPEECH frame with CMI %u\n", cmi);
 		break;
+	case AMR_NO_DATA:
+		LOGP(DRTP, LOGL_DEBUG, "SPEECH frame AMR NO_DATA\n");
+		break;
 	case AMR_SID:
 		LOGP(DRTP, LOGL_DEBUG, "SID %s frame with CMI %u\n",
 		     sti ? "UPDATE" : "FIRST", cmi);
@@ -385,6 +388,7 @@
  *  \param rs RTP Socket
  *  \param[in] rtp_pl buffer containing RTP payload
  *  \param[in] rtp_pl_len length of \a rtp_pl
+ *  \param[in] marker RTP header Marker bit (indicates speech onset)
  *
  * This function prepares a msgb with a L1 PH-DATA.req primitive and
  * queues it into lchan->dl_tch_queue.
@@ -394,10 +398,13 @@
  * pre-fill the primtive.
  */
 void l1if_tch_encode(struct gsm_lchan *lchan, uint8_t *data, uint8_t *len,
-	const uint8_t *rtp_pl, unsigned int rtp_pl_len)
+		     const uint8_t *rtp_pl, unsigned int rtp_pl_len, bool marker)
 {
 	uint8_t *payload_type;
-	uint8_t *l1_payload;
+	uint8_t *l1_payload, cmr;
+	enum osmo_amr_type ft;
+	enum osmo_amr_quality bfi;
+	int8_t sti, cmi;
 	int rc;
 
 	DEBUGP(DRTP, "%s RTP IN: %s\n", gsm_lchan_name(lchan),
@@ -426,9 +433,19 @@
 		break;
 #endif
 	case GSM48_CMODE_SPEECH_AMR:
-		*payload_type = GsmL1_TchPlType_Amr;
-		rc = rtppayload_to_l1_amr(l1_payload, rtp_pl,
-					  rtp_pl_len, lchan);
+		if (marker) {
+			*payload_type = GsmL1_TchPlType_Amr_Onset;
+			rc = 0;
+			osmo_amr_rtp_dec(rtp_pl, rtp_pl_len, &cmr, &cmi, &ft,
+					 &bfi, &sti);
+			LOGP(DRTP, LOGL_ERROR, "Marker SPEECH frame AMR %s\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);
+		}
 		break;
 	default:
 		/* we don't support CSD modes */

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I88c41568bcb0d82699f617adc4ad192603dd1bb6
Gerrit-PatchSet: 5
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list