falconia has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32670 )
Change subject: codec: add osmo_{fr,efr}_is_any_sid() inline functions ......................................................................
codec: add osmo_{fr,efr}_is_any_sid() inline functions
Recently added osmo_{fr,efr}_sid_classify() functions classify FR (EFR) codec frames according to the rules of GSM 06.31 (06.81) section 6.1.1. Both of these specs also define the term "accepted SID frame", encompassing both valid and invalid SID frames, but not regular speech frames. A boolean check for this wider category of "accepted SID frame" is a useful function - many existing calls to legacy osmo_{fr,efr}_check_sid() functions should be converted to this "accepted SID frame" check for full correctness. Add wrapper functions for convenience, and to allow this transition to be made without adding bloat to every use instance.
Change-Id: I5e6e91baf18440af01dccc6ac0171476a8a5c71c --- M include/osmocom/codec/codec.h 1 file changed, 47 insertions(+), 0 deletions(-)
Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve dexter: Looks good to me, but someone else must approve falconia: Looks good to me, approved
diff --git a/include/osmocom/codec/codec.h b/include/osmocom/codec/codec.h index a656bcf..7f82432 100644 --- a/include/osmocom/codec/codec.h +++ b/include/osmocom/codec/codec.h @@ -98,6 +98,33 @@
enum osmo_gsm631_sid_class osmo_fr_sid_classify(const uint8_t *rtp_payload); enum osmo_gsm631_sid_class osmo_efr_sid_classify(const uint8_t *rtp_payload); + +/*! Check if given FR codec frame is any kind of SID, valid or invalid + * \param[in] rtp_payload Buffer with RTP payload + * \returns true if the frame is an "accepted SID frame" in GSM 06.31 + * definition, false otherwise. + */ +static inline bool osmo_fr_is_any_sid(const uint8_t *rtp_payload) +{ + enum osmo_gsm631_sid_class sidc; + + sidc = osmo_fr_sid_classify(rtp_payload); + return sidc != OSMO_GSM631_SID_CLASS_SPEECH; +} + +/*! Check if given EFR codec frame is any kind of SID, valid or invalid + * \param[in] rtp_payload Buffer with RTP payload + * \returns true if the frame is an "accepted SID frame" in GSM 06.81 + * definition, false otherwise. + */ +static inline bool osmo_efr_is_any_sid(const uint8_t *rtp_payload) +{ + enum osmo_gsm631_sid_class sidc; + + sidc = osmo_efr_sid_classify(rtp_payload); + return sidc != OSMO_GSM631_SID_CLASS_SPEECH; +} + bool osmo_fr_sid_preen(uint8_t *rtp_payload); bool osmo_efr_sid_preen(uint8_t *rtp_payload);