From 1160cabefb2326aaf7f17573ef36859c9bce0d38 Mon Sep 17 00:00:00 2001 From: "Mychaela N. Falconia" Date: Thu, 25 May 2023 19:05:58 +0000 Subject: all models, HR1 codec: accept both TS101318 and RFC5993 formats There exist two different RTP encoding formats for HR1 codec: one "simple" format defined in ETSI TS 101 318, and an extended format (adding a ToC octet) defined in IETF RFC 5993. Following the liberal-accept clause of Postel's law, we would like to accept both formats. Implement this feature by first converting all HR1 RTP inputs to the more basic TS 101 318 format at the point of input preening, and then consistently using this basic format internally. Related: OS#5688 Depends: I13eaad366f9f68615b9e9e4a5f87396a0e9dea0f (libosmocore) Change-Id: I702e26c3ad5b9d8347e73c6cd23efa38a3a3407e --- src/common/rtp_input_preen.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/rtp_input_preen.c b/src/common/rtp_input_preen.c index 90ff6da8..e5cef6ff 100644 --- a/src/common/rtp_input_preen.c +++ b/src/common/rtp_input_preen.c @@ -81,6 +81,22 @@ input_preen_efr(const uint8_t *rtp_pl, unsigned rtp_pl_len) return PL_DECISION_ACCEPT; } +static enum pl_input_decision +input_preen_hr(const uint8_t *rtp_pl, unsigned rtp_pl_len) +{ + switch (rtp_pl_len) { + case GSM_HR_BYTES: + /* RTP input matches our internal format - we are good */ + return PL_DECISION_ACCEPT; + case GSM_HR_BYTES_RTP_RFC5993: + /* Strip ToC octet, leaving only "pure" TS 101 318 payload. */ + return PL_DECISION_STRIP_HDR_OCTET; + default: + /* invalid payload */ + return PL_DECISION_DROP; + } +} + enum pl_input_decision rtp_payload_input_preen(struct gsm_lchan *lchan, const uint8_t *rtp_pl, unsigned rtp_pl_len) @@ -102,7 +118,7 @@ rtp_payload_input_preen(struct gsm_lchan *lchan, const uint8_t *rtp_pl, if (lchan->type == GSM_LCHAN_TCH_F) return input_preen_fr(rtp_pl, rtp_pl_len); else - return PL_DECISION_ACCEPT; /* FIXME: next patch in the series */ + return input_preen_hr(rtp_pl, rtp_pl_len); case GSM48_CMODE_SPEECH_EFR: return input_preen_efr(rtp_pl, rtp_pl_len); case GSM48_CMODE_SPEECH_AMR: -- cgit v1.2.3