Matan Perelman has uploaded this change for review. (
https://gerrit.osmocom.org/c/gapk/+/32094 )
Change subject: fmt_rtp_amr,fmt_rtp_efr: replace damaged packets with silence
......................................................................
fmt_rtp_amr,fmt_rtp_efr: replace damaged packets with silence
Change-Id: I7245aa0bc0955cc8b94d5401a15e694f50498093
---
M src/fmt_rtp_amr.c
M src/fmt_rtp_efr.c
2 files changed, 30 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/gapk refs/changes/94/32094/1
diff --git a/src/fmt_rtp_amr.c b/src/fmt_rtp_amr.c
index a6a3c9f..02d74ca 100644
--- a/src/fmt_rtp_amr.c
+++ b/src/fmt_rtp_amr.c
@@ -27,6 +27,8 @@
#include <osmocom/gapk/formats.h>
#include <osmocom/gapk/utils.h>
+static const uint8_t SILENCE[] = {0x80, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00};
+
/* conversion function: RTP payload -> canonical format */
static int
rtp_amr_from_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len)
@@ -42,6 +44,12 @@
static int
rtp_amr_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len)
{
+ /* Detect severely damaged frames according to RFC4867 4.3.2 */
+ if ((src[1] & 0x04) == 0) {
+ src = SILENCE;
+ src_len = sizeof(SILENCE);
+ }
+
/* skip Payload Header according to RFC4867 4.4.1 */
memcpy(dst, src+1, src_len-1);
diff --git a/src/fmt_rtp_efr.c b/src/fmt_rtp_efr.c
index 7afb1a3..34b8823 100644
--- a/src/fmt_rtp_efr.c
+++ b/src/fmt_rtp_efr.c
@@ -30,6 +30,15 @@
#define EFR_LEN 31
#define EFR_MAGIC 0xc
+static const uint8_t DAMAGED_PACKET[EFR_LEN] = {
+ 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
+};
+static const uint8_t SILENCE[EFR_LEN] = {
+ 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00,
0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
+};
+
/* conversion function: RTP payload -> canonical format */
static int
rtp_efr_from_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len)
@@ -58,6 +67,10 @@
return EFR_CANON_LEN;
}
+ if (!memcmp(DAMAGED_PACKET, src, EFR_LEN)) {
+ src = SILENCE;
+ }
+
for (i=0; i<(EFR_LEN-1); i++)
dst[i] = (src[i] << 4) | (src[i+1] >> 4);
dst[EFR_LEN-1] = src[EFR_LEN-1] << 4;
--
To view, visit
https://gerrit.osmocom.org/c/gapk/+/32094
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: gapk
Gerrit-Branch: master
Gerrit-Change-Id: I7245aa0bc0955cc8b94d5401a15e694f50498093
Gerrit-Change-Number: 32094
Gerrit-PatchSet: 1
Gerrit-Owner: Matan Perelman <matan1008(a)gmail.com>
Gerrit-MessageType: newchange