diff options
Diffstat (limited to 'include/osmocom/codec')
-rw-r--r-- | include/osmocom/codec/Makefile.am | 7 | ||||
-rw-r--r-- | include/osmocom/codec/codec.h | 57 | ||||
-rw-r--r-- | include/osmocom/codec/ecu.h | 6 |
3 files changed, 69 insertions, 1 deletions
diff --git a/include/osmocom/codec/Makefile.am b/include/osmocom/codec/Makefile.am new file mode 100644 index 00000000..63ae4024 --- /dev/null +++ b/include/osmocom/codec/Makefile.am @@ -0,0 +1,7 @@ +osmocodec_HEADERS = \ + ecu.h \ + codec.h \ + gsm610_bits.h \ + $(NULL) + +osmocodecdir = $(includedir)/osmocom/codec diff --git a/include/osmocom/codec/codec.h b/include/osmocom/codec/codec.h index cbdad75e..7a23e7f0 100644 --- a/include/osmocom/codec/codec.h +++ b/include/osmocom/codec/codec.h @@ -15,6 +15,10 @@ /* TS 101318 Chapter 5.3: 244 bits + 4bit sig */ #define GSM_EFR_BYTES 31 +/* Number of bytes of an GSM_HR RTP payload */ +#define GSM_HR_BYTES_RTP_RFC5993 (GSM_HR_BYTES + 1) +#define GSM_HR_BYTES_RTP_TS101318 (GSM_HR_BYTES) + extern const uint16_t gsm610_bitorder[]; /* FR */ extern const uint16_t gsm620_unvoiced_bitorder[]; /* HR unvoiced */ extern const uint16_t gsm620_voiced_bitorder[]; /* HR voiced */ @@ -29,6 +33,8 @@ extern const uint16_t gsm690_5_9_bitorder[]; /* AMR 5.9 kbits */ extern const uint16_t gsm690_5_15_bitorder[]; /* AMR 5.15 kbits */ extern const uint16_t gsm690_4_75_bitorder[]; /* AMR 4.75 kbits */ +extern const uint8_t osmo_gsm611_silence_frame[GSM_FR_BYTES]; + extern const struct value_string osmo_amr_type_names[]; enum osmo_amr_type { @@ -47,6 +53,9 @@ enum osmo_amr_type { AMR_NO_DATA = 15, }; +static inline const char *osmo_amr_type_name(enum osmo_amr_type type) +{ return get_value_string(osmo_amr_type_names, type); } + enum osmo_amr_quality { AMR_BAD = 0, AMR_GOOD = 1 @@ -78,8 +87,56 @@ static inline bool osmo_amr_is_speech(enum osmo_amr_type ft) } } +/* SID ternary classification per GSM 06.31 & 06.81 section 6.1.1 */ +enum osmo_gsm631_sid_class { + OSMO_GSM631_SID_CLASS_SPEECH = 0, + OSMO_GSM631_SID_CLASS_INVALID = 1, + OSMO_GSM631_SID_CLASS_VALID = 2, +}; + bool osmo_fr_check_sid(const uint8_t *rtp_payload, size_t payload_len); bool osmo_hr_check_sid(const uint8_t *rtp_payload, size_t payload_len); +bool osmo_efr_check_sid(const uint8_t *rtp_payload, size_t payload_len); + +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); +enum osmo_gsm631_sid_class osmo_hr_sid_classify(const uint8_t *rtp_payload, + bool bci_flag, + bool *bfi_from_bci); + +/*! 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); + +void osmo_fr_sid_reset(uint8_t *rtp_payload); +void osmo_hr_sid_reset(uint8_t *rtp_payload); +void osmo_efr_sid_reset(uint8_t *rtp_payload); + int osmo_amr_rtp_enc(uint8_t *payload, uint8_t cmr, enum osmo_amr_type ft, enum osmo_amr_quality bfi); int osmo_amr_rtp_dec(const uint8_t *payload, int payload_len, uint8_t *cmr, diff --git a/include/osmocom/codec/ecu.h b/include/osmocom/codec/ecu.h index 668df367..64928609 100644 --- a/include/osmocom/codec/ecu.h +++ b/include/osmocom/codec/ecu.h @@ -6,7 +6,7 @@ #include <osmocom/core/defs.h> #include <osmocom/codec/codec.h> -/* ECU state for GSM-FR */ +/* ECU state for GSM-FR - deprecated version only! */ struct osmo_ecu_fr_state { bool subsequent_lost_frame; uint8_t frame_backup[GSM_FR_BYTES]; @@ -62,12 +62,16 @@ int osmo_ecu_frame_in(struct osmo_ecu_state *st, bool bfi, /* generate output data for a substitute/erroneous frame */ int osmo_ecu_frame_out(struct osmo_ecu_state *st, uint8_t *frame_out); +/* is the stream handled by this ECU currently in a DTX pause? */ +bool osmo_ecu_is_dtx_pause(struct osmo_ecu_state *st); + struct osmo_ecu_ops { struct osmo_ecu_state * (*init)(void *ctx, enum osmo_ecu_codec codec); void (*destroy)(struct osmo_ecu_state *); int (*frame_in)(struct osmo_ecu_state *st, bool bfi, const uint8_t *frame, unsigned int frame_bytes); int (*frame_out)(struct osmo_ecu_state *st, uint8_t *frame_out); + bool (*is_dtx_pause)(struct osmo_ecu_state *st); }; int osmo_ecu_register(const struct osmo_ecu_ops *ops, enum osmo_ecu_codec codec); |