falconia has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-bts/+/32970 )
Change subject: all models, HR1 codec: select RTP output format via vty option
......................................................................
all models, HR1 codec: select RTP output format via vty option
The new vty option "rtp hr-format (rfc5993|ts101318)" selects the
RTP output format to be used for HR1 codec, consistently across
all models. The default is set to rfc5993 as a forward-looking
measure: once we implement GSM 06.41 section 6.1.1 SID classification
(OS#6036), the extra ToC octet of rfc5993 format (which carries
SID classification status) will allow operation closer to traditional
E1 Abis where this SID classification is done by the UL-receiving BTS
and carried in out-of-band control bits.
Closes: OS#5688
Change-Id: I168191874a062429a57904511a1e89e3f588732e
---
M include/osmo-bts/bts.h
M src/common/bts.c
M src/common/l1sap.c
M src/common/vty.c
M tests/osmo-bts.vty
5 files changed, 59 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/70/32970/1
diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h
index 0fff2a5..7ca3224 100644
--- a/include/osmo-bts/bts.h
+++ b/include/osmo-bts/bts.h
@@ -300,6 +300,7 @@
int rtp_priority;
bool rtp_nogaps_mode; /* emit RTP stream without any gaps */
+ bool emit_hr_rfc5993;
struct {
uint8_t ciphers; /* flags A5/1==0x1, A5/2==0x2, A5/3==0x4 */
diff --git a/src/common/bts.c b/src/common/bts.c
index 242c5dd..802cb00 100644
--- a/src/common/bts.c
+++ b/src/common/bts.c
@@ -330,6 +330,7 @@
bts->rtp_port_range_next = bts->rtp_port_range_start;
bts->rtp_ip_dscp = -1;
bts->rtp_priority = -1;
+ bts->emit_hr_rfc5993 = true;
/* Default (fall-back) MS/BS Power control parameters */
power_ctrl_params_def_reset(&bts->bs_dpc_params, true);
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 75bc795..fb93e49 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -1643,6 +1643,24 @@
lchan->rtp_tx_marker = false;
}
+/* a helper function for emitting HR1 UL in RFC 5993 format */
+static void send_rtp_rfc5993(struct gsm_lchan *lchan, uint32_t fn,
+ const uint8_t *input_pl, uint16_t input_pl_len)
+{
+ uint8_t new_pl[GSM_HR_BYTES_RTP_RFC5993];
+
+ OSMO_ASSERT(input_pl_len == GSM_HR_BYTES);
+ /* FIXME: implement proper SID classification per GSM 06.41 section
+ * 6.1.1; see OS#6036. Until then, detect error-free SID frames
+ * using our existing osmo_hr_check_sid() function. */
+ if (osmo_hr_check_sid(input_pl, input_pl_len))
+ new_pl[0] = 0x20;
+ else
+ new_pl[0] = 0x00;
+ memcpy(new_pl + 1, input_pl, GSM_HR_BYTES);
+ send_ul_rtp_packet(lchan, fn, new_pl, GSM_HR_BYTES_RTP_RFC5993);
+}
+
/* TCH received from bts model */
static int l1sap_tch_ind(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap,
struct ph_tch_param *tch_ind)
@@ -1682,7 +1700,11 @@
* good enough. */
if (msg->len && tch_ind->lqual_cb >= bts->min_qual_norm) {
/* hand msg to RTP code for transmission */
- send_ul_rtp_packet(lchan, fn, msg->data, msg->len);
+ if (bts->emit_hr_rfc5993 && lchan->type == GSM_LCHAN_TCH_H &&
+ lchan->tch_mode == GSM48_CMODE_SPEECH_V1)
+ send_rtp_rfc5993(lchan, fn, msg->data, msg->len);
+ else
+ send_ul_rtp_packet(lchan, fn, msg->data, msg->len);
/* if loopback is enabled, also queue received RTP data */
if (lchan->loopback) {
/* add new frame to queue, make sure the queue doesn't get too long */
diff --git a/src/common/vty.c b/src/common/vty.c
index b17800c..8df5642 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -418,6 +418,8 @@
vty_out(vty, " rtp socket-priority %d%s", bts->rtp_priority,
VTY_NEWLINE);
if (bts->rtp_nogaps_mode)
vty_out(vty, " rtp continuous-streaming%s", VTY_NEWLINE);
+ vty_out(vty, " rtp hr-format %s%s",
+ bts->emit_hr_rfc5993 ? "rfc5993" : "ts101318", VTY_NEWLINE);
vty_out(vty, " paging queue-size %u%s",
paging_get_queue_max(bts->paging_state),
VTY_NEWLINE);
vty_out(vty, " paging lifetime %u%s",
paging_get_lifetime(bts->paging_state),
@@ -797,6 +799,17 @@
return CMD_SUCCESS;
}
+DEFUN(cfg_bts_rtp_hr_format,
+ cfg_bts_rtp_hr_format_cmd,
+ "rtp hr-format (rfc5993|ts101318)",
+ RTP_STR "HRv1 codec output format\n" "RFC 5993\n" "TS 101
318\n")
+{
+ struct gsm_bts *bts = vty->index;
+
+ bts->emit_hr_rfc5993 = !strcmp(argv[0], "rfc5993");
+ return CMD_SUCCESS;
+}
+
#define PAG_STR "Paging related parameters\n"
DEFUN_ATTR(cfg_bts_paging_queue_size,
@@ -2686,6 +2699,7 @@
install_element(BTS_NODE, &cfg_bts_rtp_priority_cmd);
install_element(BTS_NODE, &cfg_bts_rtp_cont_stream_cmd);
install_element(BTS_NODE, &cfg_bts_no_rtp_cont_stream_cmd);
+ install_element(BTS_NODE, &cfg_bts_rtp_hr_format_cmd);
install_element(BTS_NODE, &cfg_bts_band_cmd);
install_element(BTS_NODE, &cfg_description_cmd);
install_element(BTS_NODE, &cfg_no_description_cmd);
diff --git a/tests/osmo-bts.vty b/tests/osmo-bts.vty
index 7f2e78c..356f2aa 100644
--- a/tests/osmo-bts.vty
+++ b/tests/osmo-bts.vty
@@ -235,6 +235,7 @@
rtp socket-priority <0-255>
rtp continuous-streaming
no rtp continuous-streaming
+ rtp hr-format (rfc5993|ts101318)
band
(450|GSM450|480|GSM480|750|GSM750|810|GSM810|850|GSM850|900|GSM900|1800|DCS1800|1900|PCS1900)
description .TEXT
no description
--
To view, visit
https://gerrit.osmocom.org/c/osmo-bts/+/32970
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I168191874a062429a57904511a1e89e3f588732e
Gerrit-Change-Number: 32970
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-MessageType: newchange