falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/41050?usp=email )
Change subject: HRv1 codec: add support for TW-TS-002 ...................................................................... HRv1 codec: add support for TW-TS-002 OsmoBTS supports TW-TS-001 enhanced RTP format for FR and EFR codecs since 2024, providing functional equivalent of GSM 08.60 TRAU-UL output over IP physical transport. Now do the same with TW-TS-002, IP equivalent of GSM 08.61 for HRv1 codec. Only TCH UL path is affected; no changes are needed to TCH DL path because existing RTP Rx handling for RFC 5993 also covers TW-TS-002. Related: OS#6036 Change-Id: Icf11e43d4ce9df990d0e0a856d62d9ea11cb837c --- M src/common/bts.c M src/common/l1sap.c 2 files changed, 74 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/50/41050/1 diff --git a/src/common/bts.c b/src/common/bts.c index 282d730..73cb8a6 100644 --- a/src/common/bts.c +++ b/src/common/bts.c @@ -394,6 +394,7 @@ osmo_bts_set_feature(bts->features, BTS_FEAT_IPV6_NSVC); osmo_bts_set_feature(bts->features, BTS_FEAT_PAGING_COORDINATION); osmo_bts_set_feature(bts->features, BTS_FEAT_TWTS001); + osmo_bts_set_feature(bts->features, BTS_FEAT_TWTS002); /* Maximum TA supported by the PHY (can be overridden by PHY specific code) */ bts->support.max_ta = MAX_TA_DEF; diff --git a/src/common/l1sap.c b/src/common/l1sap.c index e8453b8..d8754f6 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -2227,12 +2227,66 @@ } } +/* See Section 5.2 of RFC5993 and TW-TS-002 */ +enum super5993_ft { + FT_GOOD_SPEECH = 0, + FT_INVALID_SID = 1, + FT_GOOD_SID = 2, + FT_BFI_WITH_DATA = 6, + FT_NO_DATA = 7, +}; + +/* a helper function for emitting GSM-HR UL in TW-TS-002 format */ +static void send_rtp_twts002(struct gsm_lchan *lchan, uint32_t fn, + struct msgb *msg) +{ + enum super5993_ft ft; + uint8_t toc; + bool send_frame; + + if (msg->len == GSM_HR_BYTES) { + switch (tch_ul_msg_sid(msg)) { + case OSMO_GSM631_SID_CLASS_SPEECH: + ft = tch_ul_msg_bfi(msg) ? FT_BFI_WITH_DATA + : FT_GOOD_SPEECH; + break; + case OSMO_GSM631_SID_CLASS_INVALID: + ft = FT_INVALID_SID; + break; + case OSMO_GSM631_SID_CLASS_VALID: + ft = tch_ul_msg_bfi(msg) ? FT_INVALID_SID : FT_GOOD_SID; + break; + default: + OSMO_ASSERT(0); + } + send_frame = true; + } else { + ft = FT_NO_DATA; + send_frame = false; + } + /* ToC octet of TW-TS-002 is an extension of RFC 5993 */ + toc = ft << 4; + if (ft == FT_INVALID_SID) + toc |= 0x04; /* TW-TS-002 version 1.2.0 */ + /* always set DTXd and TAF bits */ + if (lchan->ts->trx->bts->dtxd) + toc |= 0x08; + if (fr_hr_efr_sid_position(lchan, fn)) + toc |= 0x01; + if (send_frame) { + msgb_push_u8(msg, toc); + send_ul_rtp_packet(lchan, fn, msg->data, msg->len); + } else { + send_ul_rtp_packet(lchan, fn, &toc, 1); + } +} + /* A helper function for l1sap_tch_ind(): handling BFI * * Please note that the msgb passed to this function is used only when - * the CN asked the BSS to emit extended RTP formats (currently TW-TS-001, - * later TW-TS-002 as well) that can indicate BFI along with deemed-bad - * frame data bits, just like GSM 08.60 and 08.61 TRAU-UL frames. + * the CN asked the BSS to emit extended RTP formats of TW-TS-001 or + * TW-TS-002 that can indicate BFI along with deemed-bad frame data bits, + * just like GSM 08.60 and 08.61 TRAU-UL frames. */ static void tch_ul_bfi_handler(struct gsm_lchan *lchan, const struct gsm_time *g_time, struct msgb *msg) @@ -2255,6 +2309,14 @@ return; } + /* Ditto for TCH/HS and TW-TS-002. */ + if ((lchan->abis_ip.rtp_extensions & OSMO_RTP_EXT_TWTS002) && + lchan->type == GSM_LCHAN_TCH_H && + lchan->tch_mode == GSM48_CMODE_SPEECH_V1) { + send_rtp_twts002(lchan, fn, msg); + return; + } + /* Are we applying an ECU to this uplink, and are we in a state * (not DTX pause) where we emit ECU output? */ if (lchan->ecu_state && !osmo_ecu_is_dtx_pause(lchan->ecu_state)) { @@ -2526,10 +2588,14 @@ send_ul_rtp_packet(lchan, fn, msg->data, msg->len); } else if (lchan->type == GSM_LCHAN_TCH_H && lchan->tch_mode == GSM48_CMODE_SPEECH_V1) { - /* HR codec: TS 101 318 or RFC 5993, - * will also support TW-TS-002 in the future. */ - send_gsmhr_std_rtp(lchan, &g_time, msg, - bts->emit_hr_rfc5993); + /* HR codec: TW-TS-002 in ThemWi environment, + * or TS 101 318 or RFC 5993 in traditional + * 3GPP or Osmocom environments. */ + if (lchan->abis_ip.rtp_extensions & OSMO_RTP_EXT_TWTS002) + send_rtp_twts002(lchan, fn, msg); + else + send_gsmhr_std_rtp(lchan, &g_time, msg, + bts->emit_hr_rfc5993); } else { /* generic case, no RTP alterations */ send_ul_rtp_packet(lchan, fn, msg->data, msg->len); -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/41050?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: Icf11e43d4ce9df990d0e0a856d62d9ea11cb837c Gerrit-Change-Number: 41050 Gerrit-PatchSet: 1 Gerrit-Owner: falconia <fal...@freecalypso.org>