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
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