[MERGED] osmo-bts[master]: DTXu: move copy-pasted code to common part

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Jun 23 20:01:02 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: DTXu: move copy-pasted code to common part
......................................................................


DTXu: move copy-pasted code to common part

Abstract code for checking/setting lchan's UL SID flag and RTP Marker
into generic function and use it for LC15 and sysmoBTS.

Change-Id: Ica5392e92bab29164711163e7b01adb174272883
Related: OS#1750
---
M include/osmo-bts/msg_utils.h
M src/common/msg_utils.c
M src/osmo-bts-litecell15/tch.c
M src/osmo-bts-sysmo/tch.c
4 files changed, 20 insertions(+), 36 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmo-bts/msg_utils.h b/include/osmo-bts/msg_utils.h
index 73f8c96..591d194 100644
--- a/include/osmo-bts/msg_utils.h
+++ b/include/osmo-bts/msg_utils.h
@@ -20,6 +20,7 @@
 	OML_MSG_TYPE_OSMO,
 };
 
+void lchan_set_marker(bool t, struct gsm_lchan *lchan);
 void save_last_sid(struct gsm_lchan *lchan, uint8_t *l1_payload, size_t length,
 		   uint32_t fn, bool update);
 bool dtx_sched_optional(struct gsm_lchan *lchan, uint32_t fn);
diff --git a/src/common/msg_utils.c b/src/common/msg_utils.c
index 6f42f73..4c0a2cc 100644
--- a/src/common/msg_utils.c
+++ b/src/common/msg_utils.c
@@ -86,6 +86,17 @@
 	return type;
 }
 
+/* update lchan SID status */
+void lchan_set_marker(bool t, struct gsm_lchan *lchan)
+{
+	if (t)
+		lchan->tch.ul_sid = true;
+	else if (lchan->tch.ul_sid) {
+		lchan->tch.ul_sid = false;
+		lchan->rtp_tx_marker = true;
+	}
+}
+
 /* store the last SID frame in lchan context */
 void save_last_sid(struct gsm_lchan *lchan, uint8_t *l1_payload, size_t length,
 		   uint32_t fn, bool update)
diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c
index ec43c10..b061fe9 100644
--- a/src/osmo-bts-litecell15/tch.c
+++ b/src/osmo-bts-litecell15/tch.c
@@ -108,12 +108,7 @@
 	cur = msgb_put(msg, GSM_FR_BYTES);
 	memcpy(cur, l1_payload, GSM_FR_BYTES);
 
-	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;
-	}
+	lchan_set_marker(osmo_fr_check_sid(l1_payload, payload_len), lchan);
 
 	return msg;
 }
@@ -151,12 +146,8 @@
 	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;
-	}
+	lchan_set_marker(ft == AMR_GSM_EFR_SID, lchan);
+
 	return msg;
 }
 
@@ -187,12 +178,7 @@
 	cur = msgb_put(msg, GSM_HR_BYTES);
 	memcpy(cur, l1_payload, GSM_HR_BYTES);
 
-	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;
-	}
+	lchan_set_marker(osmo_hr_check_sid(l1_payload, payload_len), lchan);
 
 	return msg;
 }
diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c
index 17469f0..527f9e1 100644
--- a/src/osmo-bts-sysmo/tch.c
+++ b/src/osmo-bts-sysmo/tch.c
@@ -118,12 +118,7 @@
 	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;
-	}
+	lchan_set_marker(osmo_fr_check_sid(l1_payload, payload_len), lchan);
 
 	return msg;
 }
@@ -182,12 +177,8 @@
 	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;
-	}
+	lchan_set_marker(ft == AMR_GSM_EFR_SID, lchan);
+
 	return msg;
 }
 
@@ -230,12 +221,7 @@
 	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;
-	}
+	lchan_set_marker(osmo_hr_check_sid(l1_payload, payload_len), lchan);
 
 	return msg;
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ica5392e92bab29164711163e7b01adb174272883
Gerrit-PatchSet: 2
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