Change in osmo-mgw[mykola/iuup]: iuup_cn_node.c: make it work for AMR 12.2k codec

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Mykola Shchetinin gerrit-no-reply at lists.osmocom.org
Fri Dec 21 18:12:53 UTC 2018


Mykola Shchetinin has uploaded this change for review. ( https://gerrit.osmocom.org/12424


Change subject: iuup_cn_node.c: make it work for AMR 12.2k codec
......................................................................

iuup_cn_node.c: make it work for AMR 12.2k codec

rx_data: prepend hardcoded AMR 12.2 header "0xf03c" to the front of RTP
payload
osmo_iuup_cn_tx_payload: strip AMR header (2 bytes) from the front of RTP
payload

Change-Id: I244c4c4778798912c818812a15709695d3251f87
---
M src/libosmo-mgcp/iuup_cn_node.c
M tests/iuup/iuup_test.c
M tests/iuup/iuup_test.ok
3 files changed, 17 insertions(+), 14 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/24/12424/1

diff --git a/src/libosmo-mgcp/iuup_cn_node.c b/src/libosmo-mgcp/iuup_cn_node.c
index f555e36..fda7a7a 100644
--- a/src/libosmo-mgcp/iuup_cn_node.c
+++ b/src/libosmo-mgcp/iuup_cn_node.c
@@ -85,10 +85,12 @@
 		   struct osmo_iuup_hdr_data *hdr)
 {
 	/* Remove the IuUP bit from the middle of the buffer by writing the RTP header forward. */
+	/* And append AMR 12.2k header "0xf03c". - AD HOC fix */
 	unsigned int pre_hdr_len = ((uint8_t*)hdr) - pdu->data;
-	memmove(pdu->data + sizeof(*hdr), pdu->data, pre_hdr_len);
-
-	msgb_pull(pdu, sizeof(*hdr));
+	memmove(pdu->data + sizeof(*hdr) - 2, pdu->data, pre_hdr_len);
+	((uint8_t*)hdr)[2] = 0xf0;
+	((uint8_t*)hdr)[3] = 0x3c;
+	msgb_pull(pdu, sizeof(*hdr) - 2);
 
 	LOGP(DIUUP, LOGL_DEBUG, "(%s) IuUP stripping IuUP header from RTP data\n", cn->name);
 	cn->cfg.rx_payload(pdu, cn->cfg.node_priv);
@@ -191,7 +193,8 @@
 	rtp_was = (void*)pdu->data;
 
 	/* copy the RTP header part backwards by the size needed for the IuUP header */
-	rtp = (void*)msgb_push(pdu, sizeof(*iuup_hdr));
+	/* also strips 2 bytes from the front of RTP payload - AMR header - AD HOC fix */
+	rtp = (void*)msgb_push(pdu, sizeof(*iuup_hdr) - 2);
 	memmove(rtp, rtp_was, sizeof(*rtp));
 
 	/* Send the same payload type to the peer (erm...) */
diff --git a/tests/iuup/iuup_test.c b/tests/iuup/iuup_test.c
index 8d96f06..e6f2ca5 100644
--- a/tests/iuup/iuup_test.c
+++ b/tests/iuup/iuup_test.c
@@ -111,7 +111,7 @@
 #define RTP_PAYLOAD "6cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0"
 	printf("\nReceive payload encapsulated in IuUP. Expecting rx_payload() of just RTP packet\n");
 	printf("i.e. should strip away " IUUP_HEADER "\n");
-	expect_rx_payload = RTP_HEADER RTP_PAYLOAD;
+	expect_rx_payload = RTP_HEADER "f03c" RTP_PAYLOAD;
 	rx_pdu(cn,
 	       msgb_from_hex("IuUP-Data",
 			     RTP_HEADER IUUP_HEADER RTP_PAYLOAD));
@@ -119,18 +119,18 @@
 	printf("\nTransmit RTP. Expecting tx_msg() with inserted IuUP header\n");
 	expect_tx_msg = RTP_HEADER "000002b3" RTP_PAYLOAD;
 	tx_payload(cn,
-		   msgb_from_hex("RTP data", RTP_HEADER RTP_PAYLOAD));
+		   msgb_from_hex("RTP data", RTP_HEADER "f03c" RTP_PAYLOAD));
 
 	printf("\nMore RTP, each time the Frame Nr advances, causing a new header CRC.\n");
 	expect_tx_msg = RTP_HEADER "0100e2b3" RTP_PAYLOAD;
 	tx_payload(cn,
-		   msgb_from_hex("RTP data", RTP_HEADER RTP_PAYLOAD));
+		   msgb_from_hex("RTP data", RTP_HEADER "f03c" RTP_PAYLOAD));
 	expect_tx_msg = RTP_HEADER "02007eb3" RTP_PAYLOAD;
 	tx_payload(cn,
-		   msgb_from_hex("RTP data", RTP_HEADER RTP_PAYLOAD));
+		   msgb_from_hex("RTP data", RTP_HEADER "f03c" RTP_PAYLOAD));
 	expect_tx_msg = RTP_HEADER "03009eb3" RTP_PAYLOAD;
 	tx_payload(cn,
-		   msgb_from_hex("RTP data", RTP_HEADER RTP_PAYLOAD));
+		   msgb_from_hex("RTP data", RTP_HEADER "f03c" RTP_PAYLOAD));
 
 	printf("All done.\n");
 }
diff --git a/tests/iuup/iuup_test.ok b/tests/iuup/iuup_test.ok
index 2b09c66..8c473d6 100644
--- a/tests/iuup/iuup_test.ok
+++ b/tests/iuup/iuup_test.ok
@@ -15,14 +15,14 @@
 8060944c6256042c000101020100e2b36cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
 rx_payload() invoked by iuup_cn!
         [IuUP] -RTP->
-8060944c6256042c000101026cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
+8060944c6256042c00010102f03c6cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
 node_priv=0x2342
 ok: matches expected msg
 rc=0
 
 Transmit RTP. Expecting tx_msg() with inserted IuUP header
         [IuUP] <-RTP-
-8060944c6256042c000101026cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
+8060944c6256042c00010102f03c6cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
 tx_msg() invoked by iuup_cn!
  <-PDU- [IuUP]
 8060944c6256042c00010102000002b36cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
@@ -32,7 +32,7 @@
 
 More RTP, each time the Frame Nr advances, causing a new header CRC.
         [IuUP] <-RTP-
-8060944c6256042c000101026cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
+8060944c6256042c00010102f03c6cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
 tx_msg() invoked by iuup_cn!
  <-PDU- [IuUP]
 8060944c6256042c000101020100e2b36cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
@@ -40,7 +40,7 @@
 ok: matches expected msg
 rc=0
         [IuUP] <-RTP-
-8060944c6256042c000101026cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
+8060944c6256042c00010102f03c6cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
 tx_msg() invoked by iuup_cn!
  <-PDU- [IuUP]
 8060944c6256042c0001010202007eb36cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
@@ -48,7 +48,7 @@
 ok: matches expected msg
 rc=0
         [IuUP] <-RTP-
-8060944c6256042c000101026cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
+8060944c6256042c00010102f03c6cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0
 tx_msg() invoked by iuup_cn!
  <-PDU- [IuUP]
 8060944c6256042c0001010203009eb36cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0

-- 
To view, visit https://gerrit.osmocom.org/12424
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: mykola/iuup
Gerrit-MessageType: newchange
Gerrit-Change-Id: I244c4c4778798912c818812a15709695d3251f87
Gerrit-Change-Number: 12424
Gerrit-PatchSet: 1
Gerrit-Owner: Mykola Shchetinin <mykola at pentonet.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181221/bd40c4fb/attachment.htm>


More information about the gerrit-log mailing list