dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/32740 )
Change subject: gsm630: make osmo_hr_check_sid compatible with RFC 5993 ......................................................................
gsm630: make osmo_hr_check_sid compatible with RFC 5993
RFC 5993 specifies a one byte TOC at the beginning of the RTP payload, while TS 101 318 does not have such a TOC byte. Since both formats are used in the field, let's make sure that osmo_hr_check_sid will work with both formats.
Related: OS#5688 Related: OS#5996 Change-Id: I25728299b757fbc87dd1b3f5adaec9b8b240c5d1 --- M src/codec/gsm620.c 1 file changed, 28 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/40/32740/1
diff --git a/src/codec/gsm620.c b/src/codec/gsm620.c index 4eae514..9b4083c 100644 --- a/src/codec/gsm620.c +++ b/src/codec/gsm620.c @@ -265,16 +265,24 @@ };
/*! Check whether RTP frame contains HR SID code word according to - * TS 101 318 §5.2.2 + * TS 101 318 §5.2.2 (payload may be supplied in TS 101 318 or RFC 5993 formt). * \param[in] rtp_payload Buffer with RTP payload * \param[in] payload_len Length of payload * \returns true if code word is found, false otherwise */ bool osmo_hr_check_sid(const uint8_t *rtp_payload, size_t payload_len) { - struct bitvec bv = { - .data = (uint8_t *)rtp_payload, - .data_len = payload_len, + struct bitvec bv; + size_t offset = 0; + + /* In case the payload is supplied in RFC 5993 format, we need to apply + * an offset to remove the one byte TOC at the beginning */ + if (payload_len == GSM_HR_BYTES_RTP_RFC5993) + offset = 1; + + bv = (struct bitvec) { + .data = (uint8_t *)rtp_payload + offset, + .data_len = payload_len - offset, };
/* A SID frame is identified by a SID codeword consisting of 79 bits which are all 1,