dexter has uploaded this change for review.
mgcp_sdp: add fmtp string to define HR GSM RTP format
There are two different RTP HR GSM formats defined (TS 101.318 and
RFC5993). Lets add an fmtp parameter In order to select between the
two formats (and convert if necessary) via MGCP/SDP. Unfortunately there
is no official fmtp string defined, so we have to define an osmocom
specific string.
Change-Id: Idde8da27fd335dc03b8fbd9e0fedc1491b77e9e4
Related: OS#5688
---
M include/osmocom/mgcp/mgcp_common.h
M src/libosmo-mgcp/mgcp_network.c
M src/libosmo-mgcp/mgcp_sdp.c
3 files changed, 29 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/14/31214/1
diff --git a/include/osmocom/mgcp/mgcp_common.h b/include/osmocom/mgcp/mgcp_common.h
index 07d8d37..ac26b6c 100644
--- a/include/osmocom/mgcp/mgcp_common.h
+++ b/include/osmocom/mgcp/mgcp_common.h
@@ -58,10 +58,17 @@
MGCP_X_OSMO_IGN_CALLID = 1,
};
+enum mgcp_gsm_hr_fmt {
+ MGCP_GSM_HR_FMT_TS101318,
+ MGCP_GSM_HR_FMT_RFC5993,
+};
+
/* Codec parameters (communicated via SDP/fmtp) */
struct mgcp_codec_param {
bool amr_octet_aligned_present;
bool amr_octet_aligned;
+ bool gsm_hr_format_present;
+ enum mgcp_gsm_hr_fmt gsm_hr_format;
};
/* Ensure that the msg->l2h is NUL terminated. */
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index d6028a2..79444a2 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -687,7 +687,8 @@
* function is used to convert between RFC 5993 and TS 101318, which we normally
* use.
* Return 0 on sucess, negative on errors like invalid data length. */
-static int rfc5993_hr_convert(struct mgcp_endpoint *endp, struct msgb *msg)
+static int rfc5993_hr_convert(struct mgcp_endpoint *endp, struct msgb *msg,
+ bool target_fmt_present, enum mgcp_gsm_hr_fmt target_fmt)
{
struct rtp_hdr *rtp_hdr;
if (msgb_length(msg) < sizeof(struct rtp_hdr)) {
@@ -700,11 +701,15 @@
if (msgb_length(msg) == GSM_HR_BYTES + sizeof(struct rtp_hdr)) {
/* TS 101318 encoding => RFC 5993 encoding */
+ if (target_fmt_present && target_fmt == MGCP_GSM_HR_FMT_TS101318)
+ return 0;
msgb_put(msg, 1);
memmove(rtp_hdr->data + 1, rtp_hdr->data, GSM_HR_BYTES);
rtp_hdr->data[0] = 0x00;
} else if (msgb_length(msg) == GSM_HR_BYTES + sizeof(struct rtp_hdr) + 1) {
/* RFC 5993 encoding => TS 101318 encoding */
+ if (target_fmt_present && target_fmt == MGCP_GSM_HR_FMT_RFC5993)
+ return 0;
memmove(rtp_hdr->data, rtp_hdr->data + 1, GSM_HR_BYTES);
msgb_trim(msg, msgb_length(msg) - 1);
} else {
@@ -1234,9 +1239,13 @@
conn_dst->end.codec->param.amr_octet_aligned ? "octet-aligned" : "bandwidth-efficient");
break;
}
- } else if (rtp_end->rfc5993_hr_convert &&
- strcmp(conn_src->end.codec->subtype_name, "GSM-HR-08") == 0) {
- rc = rfc5993_hr_convert(endp, msg);
+ } else if ((rtp_end->rfc5993_hr_convert ||
+ (conn_dst->end.codec->param_present
+ && conn_dst->end.codec->param.gsm_hr_format_present))
+ && strcmp(conn_src->end.codec->subtype_name, "GSM-HR-08") == 0) {
+ rc = rfc5993_hr_convert(endp, msg, conn_dst->end.codec->param_present
+ && conn_dst->end.codec->param.gsm_hr_format_present,
+ conn_dst->end.codec->param.gsm_hr_format);
if (rc < 0) {
LOGPENDP(endp, DRTP, LOGL_ERROR, "Error while converting to GSM-HR-08\n");
break;
diff --git a/src/libosmo-mgcp/mgcp_sdp.c b/src/libosmo-mgcp/mgcp_sdp.c
index 10822e5..c552adb 100644
--- a/src/libosmo-mgcp/mgcp_sdp.c
+++ b/src/libosmo-mgcp/mgcp_sdp.c
@@ -247,6 +247,15 @@
fmtp_param->param.amr_octet_aligned = true;
}
+ /* GSM-HR format (osmocom specific) */
+ if (strcmp(param_str, "gsm-hr-format=ts101318") == 0) {
+ fmtp_param->param.gsm_hr_format_present = true;
+ fmtp_param->param.gsm_hr_format = MGCP_GSM_HR_FMT_TS101318;
+ } else if (strcmp(param_str, "gsm-hr-format=rfc5993") == 0) {
+ fmtp_param->param.gsm_hr_format_present = true;
+ fmtp_param->param.gsm_hr_format = MGCP_GSM_HR_FMT_RFC5993;
+ }
+
param_str = strtok(NULL, " ");
if (!param_str)
break;
To view, visit change 31214. To unsubscribe, or for help writing mail filters, visit settings.