dexter has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-bts/+/30523 )
Change subject: l1sap: Accept RFC5993 and TS 101.318 HR GSM payload
......................................................................
l1sap: Accept RFC5993 and TS 101.318 HR GSM payload
Unfotunately there are two different RTP formats for HR GSM specified
and it is unclear which should be used with GSM networks. Also esch BTS
model may have a preference for either one or the other format.
Lets set internal flags to determine the preference for each BTS model
and then lets use this information to convert incoming RTP packets into
the prefered format. Doing so we will make sure that always both formats
are accepted.
Related: OS#5688
Change-Id: I17f0b546042fa333780fd2f5c315898ab0df574c
---
M include/osmo-bts/bts.h
M src/common/l1sap.c
M src/osmo-bts-lc15/main.c
M src/osmo-bts-oc2g/main.c
M src/osmo-bts-sysmo/main.c
M src/osmo-bts-trx/main.c
6 files changed, 64 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/23/30523/1
diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h
index b1a594c..99c5da1 100644
--- a/include/osmo-bts/bts.h
+++ b/include/osmo-bts/bts.h
@@ -65,6 +65,11 @@
#define BTS_INTERNAL_FLAG_NM_RCHANNEL_DEPENDS_RCARRIER (1 << 2)
/* Whether the BTS model reports interference measurements to L1SAP. */
#define BTS_INTERNAL_FLAG_INTERF_MEAS (1 << 3)
+/* Whether the BTS model prefers HR GSM RTP payload in
+ * GSM ETSI TS.101.138 (TIPHON) format */
+#define BTS_INTERNAL_FLAG_HR_GSM_TS101318 (1 << 4)
+/* Whether the BTS model prefers HR GSM RTP payload in RFC 5883 format */
+#define BTS_INTERNAL_FLAG_SPEECH_H_V1_RFC5993 (1 << 5)
/* BTS implementation flags (internal use, not exposed via OML) */
#define bts_internal_flag_get(bts, flag) \
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 22b5e8c..f8bb23f 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -1253,6 +1253,28 @@
osmo_hexdump(resp_msg->data, resp_msg->len));
return false;
}
+
+ /* Avoid sending an incompatible HR GSM RTP format to lower layers. Two
+ * formats exist: ETSI TS 101.318 and RFC 5993. This check is only
+ * carried out when the BTS model explicitly states a preference. */
+ if (lchan->tch_mode == GSM48_CMODE_SPEECH_V1 && lchan->type ==
GSM_LCHAN_TCH_H) {
+ if (bts_internal_flag_get(lchan->ts->trx->bts,
BTS_INTERNAL_FLAG_SPEECH_H_V1_RFC5993)) {
+ if (resp_msg->len != GSM_HR_BYTES + 1) {
+ LOGPLCHAN(lchan, DL1P, LOGL_NOTICE,
+ "RTP->L1: Dropping unexpected HR GSM encoding (expected RFC 5993, got TS
101.318?) %s\n",
+ osmo_hexdump(resp_msg->data, resp_msg->len));
+ return false;
+ }
+ } else if (bts_internal_flag_get(lchan->ts->trx->bts,
BTS_INTERNAL_FLAG_HR_GSM_TS101318)) {
+ if (resp_msg->len != GSM_HR_BYTES) {
+ LOGPLCHAN(lchan, DL1P, LOGL_NOTICE,
+ "RTP->L1: Dropping unexpected HR GSM encoding (expected TS 101.318, got
RFC 5993?) %s\n",
+ osmo_hexdump(resp_msg->data, resp_msg->len));
+ return false;
+ }
+ }
+ }
+
return true;
}
@@ -1888,10 +1910,39 @@
if (lchan->loopback)
return;
- msg = l1sap_msgb_alloc(rtp_pl_len);
- if (!msg)
- return;
- memcpy(msgb_put(msg, rtp_pl_len), rtp_pl, rtp_pl_len);
+ /* There are two different specifications that describe how HR GSM
+ * audio should be encapsulated in RTP frames: RFC 5993 and
+ * ETSI TS 101.318 (TIPHON). In order to be able to accept both formats
+ * we convert them on reception depending on what the particular BTS
+ * model prefers. In case no preference is set, it will be assumed that
+ * the BTS model is fine with both formats. */
+ if (lchan->tch_mode == GSM48_CMODE_SPEECH_V1 && lchan->type ==
GSM_LCHAN_TCH_H) {
+ if (bts_internal_flag_get(lchan->ts->trx->bts,
BTS_INTERNAL_FLAG_SPEECH_H_V1_RFC5993)
+ && rtp_pl_len == GSM_HR_BYTES) {
+ msg = l1sap_msgb_alloc(rtp_pl_len + 1);
+ if (!msg)
+ return;
+ memcpy(msgb_put(msg, 1), "\x00", 1);
+ memcpy(msgb_put(msg, rtp_pl_len), rtp_pl, rtp_pl_len);
+ } else if (bts_internal_flag_get(lchan->ts->trx->bts,
BTS_INTERNAL_FLAG_HR_GSM_TS101318)
+ && rtp_pl_len == GSM_HR_BYTES + 1) {
+ msg = l1sap_msgb_alloc(rtp_pl_len - 1);
+ if (!msg)
+ return;
+ memcpy(msgb_put(msg, rtp_pl_len - 1), rtp_pl + 1, rtp_pl_len - 1);
+ } else {
+ msg = l1sap_msgb_alloc(rtp_pl_len);
+ if (!msg)
+ return;
+ memcpy(msgb_put(msg, rtp_pl_len), rtp_pl, rtp_pl_len);
+ }
+ } else {
+ msg = l1sap_msgb_alloc(rtp_pl_len);
+ if (!msg)
+ return;
+ memcpy(msgb_put(msg, rtp_pl_len), rtp_pl, rtp_pl_len);
+ }
+
msgb_pull(msg, sizeof(struct osmo_phsap_prim));
/* Store RTP header Marker bit in control buffer */
diff --git a/src/osmo-bts-lc15/main.c b/src/osmo-bts-lc15/main.c
index cb2a9ac..dd82f5e 100644
--- a/src/osmo-bts-lc15/main.c
+++ b/src/osmo-bts-lc15/main.c
@@ -113,6 +113,7 @@
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_MS_PWR_CTRL_DSP);
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_NM_RCHANNEL_DEPENDS_RCARRIER);
+ bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_SPEECH_H_V1_TS101318);
return 0;
}
diff --git a/src/osmo-bts-oc2g/main.c b/src/osmo-bts-oc2g/main.c
index 4484d58..560c6c3 100644
--- a/src/osmo-bts-oc2g/main.c
+++ b/src/osmo-bts-oc2g/main.c
@@ -114,6 +114,7 @@
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_MS_PWR_CTRL_DSP);
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_NM_RCHANNEL_DEPENDS_RCARRIER);
+ bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_SPEECH_H_V1_TS101318);
return 0;
}
diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c
index 95492eb..02a2551 100644
--- a/src/osmo-bts-sysmo/main.c
+++ b/src/osmo-bts-sysmo/main.c
@@ -81,6 +81,7 @@
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_MEAS_PAYLOAD_COMB);
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_MS_PWR_CTRL_DSP);
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_NM_RCHANNEL_DEPENDS_RCARRIER);
+ bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_HR_GSM_TS101318);
return 0;
}
diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c
index 4bd7f0f..19aaa8c 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -157,6 +157,7 @@
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_MEAS_PAYLOAD_COMB);
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_INTERF_MEAS);
+ bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_SPEECH_H_V1_RFC5993);
return 0;
}
--
To view, visit
https://gerrit.osmocom.org/c/osmo-bts/+/30523
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I17f0b546042fa333780fd2f5c315898ab0df574c
Gerrit-Change-Number: 30523
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newchange