falconia has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-abis/+/37250?usp=email )

Change subject: rtp2trau_hr16: use osmo_hr_check_sid()
......................................................................

rtp2trau_hr16: use osmo_hr_check_sid()

The code in libosmotrau previously used its own local function
to check incoming 112-bit HRv1 frames against the possibility of
perfect SID (all 79 bits of SID field set to 1).  However, there is
a public API function in libosmocodec that does the exact same job
- use the common library function.

Until recently, the implementation of osmo_hr_check_sid() in
libosmocodec was quite inefficient (the local version in libosmotrau
was faster) and contained a logic error in the handling of zero-length
input in the place of a received frame.  However, both of these
defects in osmo_hr_check_sid() have now been fixed in libosmocore,
clearing the way for this common library function to be used.

Depends: Ib14204102c03c14d6c5aab42b0ffbef2c3dda3fd (libosmocore)
Change-Id: Ia8fe7e9ea65fadf7f5c136355ca8c24c89f09ef2
---
M TODO-RELEASE
M src/trau/trau_rtp_conv.c
2 files changed, 26 insertions(+), 19 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, but someone else must approve
  falconia: Looks good to me, approved




diff --git a/TODO-RELEASE b/TODO-RELEASE
index e3ad20a..515adef 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -9,3 +9,4 @@
 #library       what            description / commit summary line
 libosmotrau    struct osmo_trau2rtp_state extended (ABI break)
 libosmogsm     >1.9.0          rtp_extensions.h new header
+libosmocodec   >1.9.0          bugfix in osmo_hr_check_sid() in case length=0
diff --git a/src/trau/trau_rtp_conv.c b/src/trau/trau_rtp_conv.c
index 15d5a08..f347cca 100644
--- a/src/trau/trau_rtp_conv.c
+++ b/src/trau/trau_rtp_conv.c
@@ -162,8 +162,6 @@
        FT_NO_DATA              = 7,
 };

-static const uint8_t rtp_hr_sid[14] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-
 static void twtw002_hr16_set_extra_flags(uint8_t *out, const struct 
osmo_trau_frame *tf)
 {
        if (tf->c_bits[16])     /* DTXd */
@@ -446,21 +444,6 @@
        return 0;
 }

-/* does the RTP HR payload resemble a SID frame or not */
-static bool is_rtp_hr_sid(const uint8_t *data, const uint8_t data_len)
-{
-       int i;
-
-       if (data_len < GSM_HR_BYTES)
-               return false;
-
-       for (i = 0; i < GSM_HR_BYTES; i++) {
-               if ((data[i] & rtp_hr_sid[i]) != rtp_hr_sid[i])
-                       return false;
-       }
-       return true;
-}
-
 static int rtp2trau_hr16(struct osmo_trau_frame *tf, const uint8_t *data, 
size_t data_len)
 {
        /* accept both TS 101 318 and RFC 5993 payloads */
@@ -503,7 +486,7 @@
                        tf->c_bits[11] = 1;
                else
                        tf->c_bits[11] = 0;
-               if (is_rtp_hr_sid(data, data_len)) {
+               if (osmo_hr_check_sid(data, data_len)) {
                        /* SID=2 is a valid SID frame */
                        tf->c_bits[12] = 1;
                        tf->c_bits[13] = 0;
@@ -519,7 +502,7 @@
                tf->c_bits[12] = 1; /* C13: spare */
                tf->c_bits[13] = 1; /* C14: spare */
                tf->c_bits[14] = 1; /* C15: spare */
-               if (is_rtp_hr_sid(data, data_len))
+               if (osmo_hr_check_sid(data, data_len))
                        tf->c_bits[15] = 0; /* C16: SP */
                else
                        tf->c_bits[15] = 1; /* C16: SP */

--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/37250?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: Ia8fe7e9ea65fadf7f5c136355ca8c24c89f09ef2
Gerrit-Change-Number: 37250
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <fal...@freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: falconia <fal...@freecalypso.org>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to