[PATCH] osmo-bts[master]: DTX: send AMR voice alongside with ONSET

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
Thu Sep 29 09:33:33 UTC 2016


Hello Harald Welte, Jenkins Builder,

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

    https://gerrit.osmocom.org/961

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

DTX: send AMR voice alongside with ONSET

When ONSET event happens (either via Marker bit or due to unmarked
talkspurt) we should first send Onset event to L1 and than send voice
data in response to the same PH-RTS.ind.

Change-Id: I2a7b89430ca49eee4a350c5f980bd6bcbc386347
---
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
6 files changed, 64 insertions(+), 24 deletions(-)


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

diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c
index 0779dac..9075258 100644
--- a/src/osmo-bts-litecell15/l1_if.c
+++ b/src/osmo-bts-litecell15/l1_if.c
@@ -443,6 +443,7 @@
 	uint8_t chan_nr;
 	GsmL1_Prim_t *l1p;
 	struct msgb *nmsg = NULL;
+	int rc = -1;
 
 	chan_nr = l1sap->u.tch.chan_nr;
 	u32Fn = l1sap->u.tch.fn;
@@ -466,17 +467,20 @@
 		if (!nmsg)
 			return -ENOMEM;
 		l1p = msgb_l1prim(nmsg);
-		if (!l1if_tch_encode(lchan,
+		rc = l1if_tch_encode(lchan,
 				     l1p->u.phDataReq.msgUnitParam.u8Buffer,
 				     &l1p->u.phDataReq.msgUnitParam.u8Size,
 				     msg->data, msg->len, u32Fn,
-				     l1sap->u.tch.marker)) {
+				     l1sap->u.tch.marker);
+		if (rc < 0) {
+		/* no data encoded for L1: smth will be generated below */
 			msgb_free(nmsg);
 			nmsg = NULL;
 		}
 	}
 
-	/* no message/data, we generate an empty traffic msg */
+	/* no message/data, we might generate an empty traffic msg or re-send
+	   cached SID in case of DTX */
 	if (!nmsg)
 		nmsg = gen_empty_tch_msg(lchan, u32Fn);
 
@@ -504,9 +508,23 @@
 	/* 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);
+	if (rc > 0) { /* DTX: Send voice after ONSET was sent */
+		rc = l1if_tch_encode(lchan,
+				     l1p->u.phDataReq.msgUnitParam.u8Buffer,
+				     &l1p->u.phDataReq.msgUnitParam.u8Size,
+				     msg->data, msg->len, u32Fn,
+				     false);
+		if (rc < 0) {
+		/* error while generating voice frame for L1 */
+			msgb_free(nmsg);
+			return -BADMSG;
+		}
+		/* data request */
+		data_req_from_l1sap(l1p, fl1, u8Tn, u32Fn, sapi, subCh,
+				    u8BlockNbr,
+				    l1p->u.phDataReq.msgUnitParam.u8Size);
+		/* send message to DSP's queue */
+		osmo_wqueue_enqueue(&fl1->write_q[MQ_L1_WRITE], nmsg);
 	}
 
 	if (msg)
diff --git a/src/osmo-bts-litecell15/l1_if.h b/src/osmo-bts-litecell15/l1_if.h
index 88d71bf..adb197d 100644
--- a/src/osmo-bts-litecell15/l1_if.h
+++ b/src/osmo-bts-litecell15/l1_if.h
@@ -89,7 +89,7 @@
 struct gsm_lchan *l1if_hLayer_to_lchan(struct gsm_bts_trx *trx, uint32_t hLayer);
 
 /* tch.c */
-bool l1if_tch_encode(struct gsm_lchan *lchan, uint8_t *data, uint8_t *len,
+int 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);
 int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg);
diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c
index 08c64ab..4677b1a 100644
--- a/src/osmo-bts-litecell15/tch.c
+++ b/src/osmo-bts-litecell15/tch.c
@@ -211,7 +211,9 @@
  *  \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)
- *  \returns true if encoding result can be sent further to L1, false otherwise
+ *  \returns 0 if encoding result can be sent further to L1 without extra actions
+ *           positive value if data is ready AND extra actions are required
+ *           negative value otherwise
  *
  * This function prepares a msgb with a L1 PH-DATA.req primitive and
  * queues it into lchan->dl_tch_queue.
@@ -220,7 +222,7 @@
  * yet, as things like the frame number, etc. are unknown at the time we
  * pre-fill the primtive.
  */
-bool l1if_tch_encode(struct gsm_lchan *lchan, uint8_t *data, uint8_t *len,
+int 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;
@@ -269,7 +271,7 @@
 				LOGP(DRTP, LOGL_NOTICE, "%s SPEECH frame without"
 				     " Marker: ONSET forced\n",
 				     get_value_string(osmo_amr_type_names, ft));
-				return true;
+				return rc;
 			}
 			LOGP(DRTP, LOGL_DEBUG, "%s SPEECH frame with Marker\n",
 			     get_value_string(osmo_amr_type_names, ft));
@@ -289,14 +291,14 @@
 	if (rc < 0) {
 		LOGP(DRTP, LOGL_ERROR, "%s unable to parse RTP payload\n",
 		     gsm_lchan_name(lchan));
-		return false;
+		return -EBADMSG;
 	}
 
 	*len = rc + 1;
 
 	DEBUGP(DRTP, "%s RTP->L1: %s\n", gsm_lchan_name(lchan),
 		osmo_hexdump(data, *len));
-	return true;
+	return 0;
 }
 
 static int is_recv_only(uint8_t speech_mode)
diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c
index 3c6db43..e6dc8c1 100644
--- a/src/osmo-bts-sysmo/l1_if.c
+++ b/src/osmo-bts-sysmo/l1_if.c
@@ -436,6 +436,7 @@
 	uint8_t chan_nr;
 	GsmL1_Prim_t *l1p;
 	struct msgb *nmsg = NULL;
+	int rc = -1;
 
 	chan_nr = l1sap->u.tch.chan_nr;
 	u32Fn = l1sap->u.tch.fn;
@@ -459,17 +460,20 @@
 		if (!nmsg)
 			return -ENOMEM;
 		l1p = msgb_l1prim(nmsg);
-		if (!l1if_tch_encode(lchan,
+		rc = l1if_tch_encode(lchan,
 				     l1p->u.phDataReq.msgUnitParam.u8Buffer,
 				     &l1p->u.phDataReq.msgUnitParam.u8Size,
 				     msg->data, msg->len, u32Fn,
-				     l1sap->u.tch.marker)) {
+				     l1sap->u.tch.marker);
+		if (rc < 0) {
+		/* no data encoded for L1: smth will be generated below */
 			msgb_free(nmsg);
 			nmsg = NULL;
 		}
 	}
 
-	/* no message/data, we generate an empty traffic msg */
+	/* no message/data, we might generate an empty traffic msg or re-send
+	   cached SID in case of DTX */
 	if (!nmsg)
 		nmsg = gen_empty_tch_msg(lchan, u32Fn);
 
@@ -497,9 +501,23 @@
 	/* 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);
+	if (rc > 0) { /* DTX: Send voice after ONSET was sent */
+		rc = l1if_tch_encode(lchan,
+				     l1p->u.phDataReq.msgUnitParam.u8Buffer,
+				     &l1p->u.phDataReq.msgUnitParam.u8Size,
+				     msg->data, msg->len, u32Fn,
+				     false);
+		if (rc < 0) {
+		/* error while generating voice frame for L1 */
+			msgb_free(nmsg);
+			return -BADMSG;
+		}
+		/* data request */
+		data_req_from_l1sap(l1p, fl1, u8Tn, u32Fn, sapi, subCh,
+				    u8BlockNbr,
+				    l1p->u.phDataReq.msgUnitParam.u8Size);
+		/* send message to DSP's queue */
+		osmo_wqueue_enqueue(&fl1->write_q[MQ_L1_WRITE], nmsg);
 	}
 
 	return 0;
diff --git a/src/osmo-bts-sysmo/l1_if.h b/src/osmo-bts-sysmo/l1_if.h
index a90c39b..ece7a01 100644
--- a/src/osmo-bts-sysmo/l1_if.h
+++ b/src/osmo-bts-sysmo/l1_if.h
@@ -109,7 +109,7 @@
 struct gsm_lchan *l1if_hLayer_to_lchan(struct gsm_bts_trx *trx, uint32_t hLayer);
 
 /* tch.c */
-bool l1if_tch_encode(struct gsm_lchan *lchan, uint8_t *data, uint8_t *len,
+int 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);
 int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg);
diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c
index 3eb9bfd..f7522ba 100644
--- a/src/osmo-bts-sysmo/tch.c
+++ b/src/osmo-bts-sysmo/tch.c
@@ -307,7 +307,9 @@
  *  \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)
- *  \returns true if encoding result can be sent further to L1, false otherwise
+ *  \returns 0 if encoding result can be sent further to L1 without extra actions
+ *           positive value if data is ready AND extra actions are required
+ *           negative value otherwise
  *
  * This function prepares a msgb with a L1 PH-DATA.req primitive and
  * queues it into lchan->dl_tch_queue.
@@ -316,7 +318,7 @@
  * yet, as things like the frame number, etc. are unknown at the time we
  * pre-fill the primtive.
  */
-bool l1if_tch_encode(struct gsm_lchan *lchan, uint8_t *data, uint8_t *len,
+int 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;
@@ -367,7 +369,7 @@
 				LOGP(DRTP, LOGL_NOTICE, "%s SPEECH frame without"
 				     " Marker: ONSET forced\n",
 				     get_value_string(osmo_amr_type_names, ft));
-				return true;
+				return rc;
 			}
 			LOGP(DRTP, LOGL_DEBUG, "%s SPEECH frame with Marker\n",
 			     get_value_string(osmo_amr_type_names, ft));
@@ -387,14 +389,14 @@
 	if (rc < 0) {
 		LOGP(DRTP, LOGL_ERROR, "%s unable to parse RTP payload\n",
 		     gsm_lchan_name(lchan));
-		return false;
+		return -EBADMSG;
 	}
 
 	*len = rc + 1;
 
 	DEBUGP(DRTP, "%s RTP->L1: %s\n", gsm_lchan_name(lchan),
 		osmo_hexdump(data, *len));
-	return true;
+	return 0;
 }
 
 static int is_recv_only(uint8_t speech_mode)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I2a7b89430ca49eee4a350c5f980bd6bcbc386347
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