falconia submitted this change.
MGCP extension: add parameters for TW-TS-001 & TW-TS-002
TW-TS-001 and TW-TS-002 are enhanced RTP transport formats for
GSM FR/HR/EFR codecs that restore the lost semantics of GSM 08.60
and 08.61 TRAU-UL frames.
TW-TS-003 BSSMAP extension provides a way for a core network to
ask the BSS to use these TRAU-like enhanced RTP formats instead of
those specified in 3GPP TS 48.103; OsmoBSC already supports this
mechanism when the BSS is comprised of IP-native OsmoBTS.
However, in order to achieve the same effect when using E1-based
legacy BTS hardware, the task of generating TW-TS-001/002 RTP
packets for UL and accepting them for DL moves from OsmoBTS to
the E1-Abis-interfacing MGW. osmo_trau2rtp() is already capable
of generating these extended RTP formats on request, but until now
there was no mechanism to signal from OsmoBSC to its associated
E1 Abis MGW whether and when these extensions should be used.
Considering that MGCP as it is used in Osmocom is essentially a
private interface between OsmoBSC or OsmoMSC masters and OsmoMGW
slaves, while the externally defined and generally interoperable
interface is 3GPP TS 48.008, possibly extended with TW-TS-003,
the sensible solution is to make a private extension to the way
FR, EFR and HR codecs are described in SDP in the context of
Osmocom-MGCP.
The SDP extension birthed in the present patch consists of an fmtp
parameter for GSM, GSM-EFR and GSM-HR-08 codecs that is structured
just like the already implemented octet-align parameter for AMR.
TW-TS-001 for FR and EFR shall be described as follows:
m=audio 1234 RTP/AVP 3 110
a=rtpmap:3 GSM/8000/1
a=fmtp:3 tw-ts-001=1
a=rtpmap:110 GSM-EFR/8000/1
a=fmtp:110 tw-ts-001=1
TW-TS-002 for HR codec shall be described as follows:
m=audio 1234 RTP/AVP 111
a=rtpmap:111 GSM-HR-08/8000/1
a=fmtp:111 tw-ts-002=1
The present patch affects two areas:
* Experimental support for the newly defined extension is added to
OsmoMGW-E1. This support is deemed experimental (not for
production use) because even with this extension added, OsmoMGW-E1
is still unable to satisfy ThemWi requirements: neither ThemWi
RTP endpoint library nor the TFO transform of TS 28.062 section
C.3.2.1.1 are currently available in the repertoire of libraries
whose use is allowed in mainline OsmoCNI components, yet both are
required.
* Support is added to libosmo-mgcp-client whereby OsmoBSC will be
able to issue CRCX and MDCX commands to E1 Abis MGW endpoints
with TW-TS-001 and/or TW-TS-002 enabled. Adding the necessary
support to OsmoBSC will allow a complete working system to be
deployed using OsmoBSC plus tw-e1abis-mgw, a replacement for
OsmoMGW-E1 that works by using both Osmocom and ThemWi libraries.
Related: OS#6614
Change-Id: I0d58e6d84418f50670c8ab7cf8490af3bc2f5c26
---
M doc/manuals/chapters/mgcp_extensions.adoc
M include/osmocom/mgcp/mgcp_common.h
M include/osmocom/mgcp/mgcp_endp.h
M src/libosmo-mgcp-client/mgcp_client.c
M src/libosmo-mgcp/mgcp_e1.c
M src/libosmo-mgcp/mgcp_sdp.c
6 files changed, 160 insertions(+), 13 deletions(-)
diff --git a/doc/manuals/chapters/mgcp_extensions.adoc b/doc/manuals/chapters/mgcp_extensions.adoc
index df314bc..ebc0696 100644
--- a/doc/manuals/chapters/mgcp_extensions.adoc
+++ b/doc/manuals/chapters/mgcp_extensions.adoc
@@ -70,3 +70,85 @@
=== `X-Osmux`
See <<mgcp-extension-osmux>>
+
+=== Non-standard SDP codec parameters
+
+CRCX command message normally includes an SDP block that specifies the RTP
+address of the connecting peer and the list of codecs accepted by that entity.
+Codec specifications may include optional parameters given via `a=fmtp` lines;
+one well-known parameter is `octet-align`, defined for AMR and AMR-WB codecs.
+
+In addition to standard (RFC-defined) codec parameters (of which the
+just-mentioned `octet-align` parameter is the only one implemented so far),
+OsmoMGW also understands some non-standard (Osmocom-private) codec parameters
+as listed below.
+These Osmocom-private codec parameters are meaningful only in the context
+of OsmoBSC driving an E1 Abis MGW, which may be either OsmoMGW or a specialized
+third-party replacement.
+
+The MGCP extension described in this section is meaningful only for E1
+endpoints - it has absolutely no effect on `rtpbridge` endpoints!
+
+==== `tw-ts-001` parameter for FR and EFR codecs
+
+GSM Full Rate codec is known in SDP as `GSM`; GSM Enhanced Full Rate codec
+is known in SDP as `GSM-EFR`.
+When either codec is to be transported in RTP, there is a choice between
+two different payload formats: RFC 3551 or TW-TS-001.
+RFC 3551 is the standard in non-GSM Internet applications, and it is the
+format specified in later 3GPP releases for IP-based transport of
+compressed speech - however, it exhibits functional regressions compared
+to the original TRAU-UL frame format of GSM 08.60.
+TW-TS-001 is an enhanced alternative payload format for the same codecs
+that restores the original functionality and semantics of TRAU-UL frames.
+
+In the context of CRCX or MDCX command messages from OsmoBSC to an E1 Abis MGW,
+`tw-ts-001` codec parameter (attached to either `GSM` or `GSM-EFR` codec)
+instructs the MGW whether or not it should emit the extended payload format
+of TW-TS-001 for GSM uplink traffic converted to RTP.
+In the absence of this parameter, IETF-standard and 3GPP-standard RFC 3551
+format is emitted; if TW-TS-001 output is desired, please specify
+`tw-ts-001=1` on the appropriate `a=fmtp` line.
+
+.Example: `CRCX` message requesting EFR codec with TW-TS-001 extensions
+----
+CRCX 2 ds/e1-0/s-2/su16-2@mgw MGCP 1.0
+M: recvonly
+C: 2
+L: p:20
+
+v=0
+c=IN IP4 123.12.12.123
+m=audio 1234 RTP/AVP 110
+a=rtpmap:110 GSM-EFR/8000/1
+a=fmtp:110 tw-ts-001=1
+----
+
+==== `tw-ts-002` parameter for HR codec
+
+GSM Half Rate codec is known in SDP as `GSM-HR-08`.
+The same dichotomy that exists between RFC 3551 and TW-TS-001 RTP payload
+formats for FR and EFR codecs also exists for HR codec, except that
+the two opposing alternatives are now RFC 5993 and TW-TS-002.
+
+In the context of CRCX or MDCX command messages from OsmoBSC to an E1 Abis MGW,
+`tw-ts-002` codec parameter (attached to `GSM-HR-08` codec)
+instructs the MGW whether or not it should emit the extended payload format
+of TW-TS-002 for GSM uplink traffic converted to RTP.
+In the absence of this parameter, IETF-standard and 3GPP-standard RFC 5993
+format is emitted; if TW-TS-002 output is desired, please specify
+`tw-ts-002=1` on the appropriate `a=fmtp` line.
+
+.Example: `CRCX` message requesting HR codec with TW-TS-002 extensions
+----
+CRCX 2 ds/e1-0/s-2/su8-2@mgw MGCP 1.0
+M: recvonly
+C: 2
+L: p:20
+
+v=0
+c=IN IP4 123.12.12.123
+m=audio 1234 RTP/AVP 111
+a=rtpmap:111 GSM-HR-08/8000/1
+a=fmtp:111 tw-ts-002=1
+----
diff --git a/include/osmocom/mgcp/mgcp_common.h b/include/osmocom/mgcp/mgcp_common.h
index 05ae95f..14b226f 100644
--- a/include/osmocom/mgcp/mgcp_common.h
+++ b/include/osmocom/mgcp/mgcp_common.h
@@ -63,6 +63,10 @@
struct mgcp_codec_param {
bool amr_octet_aligned_present;
bool amr_octet_aligned;
+ bool fr_efr_twts001_present;
+ bool fr_efr_twts001;
+ bool hr_twts002_present;
+ bool hr_twts002;
};
/* Ensure that the msg->l2h is NUL terminated. */
diff --git a/include/osmocom/mgcp/mgcp_endp.h b/include/osmocom/mgcp/mgcp_endp.h
index fbe0850..3366674 100644
--- a/include/osmocom/mgcp/mgcp_endp.h
+++ b/include/osmocom/mgcp/mgcp_endp.h
@@ -124,6 +124,7 @@
struct osmo_fsm_inst *trau_sync_fi;
struct osmo_trau2rtp_state *trau_rtp_st;
uint8_t last_amr_ft;
+ uint8_t rtp_extensions;
struct mgcp_rtp_codec *last_codec;
} e1;
diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c
index ab8ba9f..63d03f9 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -1426,15 +1426,32 @@
/* Add optional codec parameters (fmtp) */
if (mgcp_msg->param_present) {
for (i = 0; i < mgcp_msg->ptmap_len; i++) {
- /* The following is only applicable for AMR */
- if (mgcp_msg->ptmap[i].codec != CODEC_AMR_8000_1
- && mgcp_msg->ptmap[i].codec != CODEC_AMRWB_16000_1)
- continue;
pt = mgcp_msg->ptmap[i].pt;
- if (mgcp_msg->param.amr_octet_aligned_present && mgcp_msg->param.amr_octet_aligned)
- MSGB_PRINTF_OR_RET("a=fmtp:%u octet-align=1\r\n", pt);
- else if (mgcp_msg->param.amr_octet_aligned_present && !mgcp_msg->param.amr_octet_aligned)
- MSGB_PRINTF_OR_RET("a=fmtp:%u octet-align=0\r\n", pt);
+ switch (mgcp_msg->ptmap[i].codec) {
+ case CODEC_AMR_8000_1:
+ case CODEC_AMRWB_16000_1:
+ if (!mgcp_msg->param.amr_octet_aligned_present)
+ break;
+ MSGB_PRINTF_OR_RET("a=fmtp:%u octet-align=%d\r\n",
+ pt, (int)mgcp_msg->param.amr_octet_aligned);
+ break;
+ case CODEC_GSM_8000_1:
+ case CODEC_GSMEFR_8000_1:
+ if (!mgcp_msg->param.fr_efr_twts001_present)
+ break;
+ MSGB_PRINTF_OR_RET("a=fmtp:%u tw-ts-001=%d\r\n",
+ pt, (int)mgcp_msg->param.fr_efr_twts001);
+ break;
+ case CODEC_GSMHR_8000_1:
+ if (!mgcp_msg->param.hr_twts002_present)
+ break;
+ MSGB_PRINTF_OR_RET("a=fmtp:%u tw-ts-002=%d\r\n",
+ pt, (int)mgcp_msg->param.hr_twts002);
+ break;
+ default:
+ /* no parameters for the remaining codecs */
+ break;
+ }
}
}
diff --git a/src/libosmo-mgcp/mgcp_e1.c b/src/libosmo-mgcp/mgcp_e1.c
index 3a7a450..f056d75 100644
--- a/src/libosmo-mgcp/mgcp_e1.c
+++ b/src/libosmo-mgcp/mgcp_e1.c
@@ -40,6 +40,7 @@
#include <osmocom/mgcp/debug.h>
#include <osmocom/mgcp/mgcp_e1.h>
#include <osmocom/codec/codec.h>
+#include <osmocom/gsm/rtp_extensions.h>
#define DEBUG_BITS_MAX 80
#define DEBUG_BYTES_MAX 40
@@ -294,6 +295,7 @@
/* Convert decoded trau frame to RTP frame */
struct osmo_trau2rtp_state t2rs = {
.type = fr.type,
+ .rtp_extensions = endp->e1.rtp_extensions,
};
rc = osmo_trau2rtp(msgb_data(msg) + rtp_hdr_len, msg->data_len - rtp_hdr_len, &fr, &t2rs);
if (rc <= 0) {
@@ -682,6 +684,13 @@
determine_trau_fr_type(codec->subtype_name, endp->e1.scd.rate, endp->e1.last_amr_ft, endp);
endp->e1.last_codec = codec;
+ /* possible RTP extensions, codec-associated */
+ endp->e1.rtp_extensions = 0;
+ if (codec->param_present && codec->param.fr_efr_twts001)
+ endp->e1.rtp_extensions |= OSMO_RTP_EXT_TWTS001;
+ if (codec->param_present && codec->param.hr_twts002)
+ endp->e1.rtp_extensions |= OSMO_RTP_EXT_TWTS002;
+
/* Update sync pattern */
sync_pat_id = determine_trau_sync_pat(codec->subtype_name, endp->e1.scd.rate, endp->e1.last_amr_ft, endp);
osmo_trau_sync_set_pat(endp->e1.trau_sync_fi, sync_pat_id);
diff --git a/src/libosmo-mgcp/mgcp_sdp.c b/src/libosmo-mgcp/mgcp_sdp.c
index 1d76ddb..2f21678 100644
--- a/src/libosmo-mgcp/mgcp_sdp.c
+++ b/src/libosmo-mgcp/mgcp_sdp.c
@@ -199,7 +199,7 @@
unsigned int pt;
unsigned int count = 0;
char delimiter;
- unsigned int amr_octet_aligned;
+ unsigned int param_val;
memset(fmtp_param, 0, sizeof(*fmtp_param));
@@ -239,12 +239,30 @@
if (delimiter == ';' || delimiter == ',')
str_ptr[strlen(str_ptr) - 1] = '\0';
- /* AMR octet aligned parameter (see also RFC 3267, section 8.3) */
- if (sscanf(param_str, "octet-align=%d", &amr_octet_aligned) == 1) {
+ /* We support the following codec parameters:
+ *
+ * AMR: octet-align parameter of RFC 4867 section 8.3;
+ * FR & EFR: tw-ts-001 parameter, Osmocom private;
+ * HR: tw-ts-002 parameter, Osmocom private.
+ *
+ * tw-ts-001 and tw-ts-002 Osmocom-private parameters are used
+ * only in the context of OsmoBSC driving an E1 MGW endpoint.
+ */
+ if (sscanf(param_str, "octet-align=%d", ¶m_val) == 1) {
fmtp_param->param.amr_octet_aligned_present = true;
fmtp_param->param.amr_octet_aligned = false;
- if (amr_octet_aligned == 1)
+ if (param_val == 1)
fmtp_param->param.amr_octet_aligned = true;
+ } else if (sscanf(param_str, "tw-ts-001=%d", ¶m_val) == 1) {
+ fmtp_param->param.fr_efr_twts001_present = true;
+ fmtp_param->param.fr_efr_twts001 = false;
+ if (param_val == 1)
+ fmtp_param->param.fr_efr_twts001 = true;
+ } else if (sscanf(param_str, "tw-ts-002=%d", ¶m_val) == 1) {
+ fmtp_param->param.hr_twts002_present = true;
+ fmtp_param->param.hr_twts002 = false;
+ if (param_val == 1)
+ fmtp_param->param.hr_twts002 = true;
}
param_str = strtok(NULL, " ");
@@ -559,7 +577,23 @@
goto buffer_too_small;
}
- if (codec->param_present) {
+ /* Include a=fmtp line in MGCP response only for AMR
+ * octet-align parameter, not for tw-ts-* parameters.
+ * Rationale:
+ *
+ * - tw-ts-* parameters exist meaningfully only for E1
+ * endpoints driven by OsmoBSC, not in any other
+ * context. libosmo-mgcp-client used by OsmoBSC
+ * completely ignores all fmtp lines, has no code
+ * to parse them at all.
+ *
+ * - The SDP we return is supposed to indicate what
+ * _we_ accept, conceptually independent from what
+ * the remote accepts. And we always accept TW-TS-001
+ * and TW-TS-002 RTP formats going to E1 DL, whether
+ * or not we send them in UL per client request.
+ */
+ if (codec->param_present && codec->param.amr_octet_aligned_present) {
fmtp_param.payload_type = payload_type;
fmtp_param.param = codec->param;
fmtp_params[0] = fmtp_param;
To view, visit change 39730. To unsubscribe, or for help writing mail filters, visit settings.