libosmocodec  1.9.2
Osmocom codec library
codec.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/bits.h>

Go to the source code of this file.

Macros

#define GSM_FR_BYTES   33
 
#define GSM_HR_BYTES   14
 
#define GSM_EFR_BYTES   31
 
#define GSM_HR_BYTES_RTP_RFC5993   (GSM_HR_BYTES + 1)
 
#define GSM_HR_BYTES_RTP_TS101318   (GSM_HR_BYTES)
 

Enumerations

enum  osmo_amr_type {
  AMR_4_75 = 0,
  AMR_5_15 = 1,
  AMR_5_90 = 2,
  AMR_6_70 = 3,
  AMR_7_40 = 4,
  AMR_7_95 = 5,
  AMR_10_2 = 6,
  AMR_12_2 = 7,
  AMR_SID = 8,
  AMR_GSM_EFR_SID = 9,
  AMR_TDMA_EFR_SID = 10,
  AMR_PDC_EFR_SID = 11,
  AMR_NO_DATA = 15
}
 
enum  osmo_amr_quality {
  AMR_BAD = 0,
  AMR_GOOD = 1
}
 
enum  osmo_gsm631_sid_class {
  OSMO_GSM631_SID_CLASS_SPEECH = 0,
  OSMO_GSM631_SID_CLASS_INVALID = 1,
  OSMO_GSM631_SID_CLASS_VALID = 2
}
 

Functions

static const char * osmo_amr_type_name (enum osmo_amr_type type)
 
int osmo_amr_s_to_d (ubit_t *out, const ubit_t *in, uint16_t n_bits, enum osmo_amr_type amr_mode)
 Convert from S-bits (codec output) to d-bits. More...
 
int osmo_amr_d_to_s (ubit_t *out, const ubit_t *in, uint16_t n_bits, enum osmo_amr_type amr_mode)
 Convert from d-bits to s-bits (codec input). More...
 
static bool osmo_amr_is_speech (enum osmo_amr_type ft)
 Check if given AMR Frame Type is a speech frame. More...
 
bool osmo_fr_check_sid (const uint8_t *rtp_payload, size_t payload_len)
 Check whether RTP frame contains FR SID code word according to TS 101 318 §5.1.2. More...
 
bool osmo_hr_check_sid (const uint8_t *rtp_payload, size_t payload_len)
 Check whether RTP frame contains HR SID code word according to TS 101 318 §5.2.2. More...
 
bool osmo_efr_check_sid (const uint8_t *rtp_payload, size_t payload_len)
 Check whether RTP frame contains EFR SID code word according to TS 101 318 §5.3.2. More...
 
enum osmo_gsm631_sid_class osmo_fr_sid_classify (const uint8_t *rtp_payload)
 Classify potentially-SID FR codec frame in RTP format according to the rules of GSM 06.31 §6.1.1. More...
 
enum osmo_gsm631_sid_class osmo_efr_sid_classify (const uint8_t *rtp_payload)
 Classify potentially-SID EFR codec frame in RTP format according to the rules of GSM 06.81 §6.1.1. More...
 
static bool osmo_fr_is_any_sid (const uint8_t *rtp_payload)
 Check if given FR codec frame is any kind of SID, valid or invalid. More...
 
static bool osmo_efr_is_any_sid (const uint8_t *rtp_payload)
 Check if given EFR codec frame is any kind of SID, valid or invalid. More...
 
bool osmo_fr_sid_preen (uint8_t *rtp_payload)
 Preen potentially-SID FR codec frame in RTP format, ensuring that it is either a speech frame or a valid SID, and if the latter, making it a perfect, error-free SID frame. More...
 
bool osmo_efr_sid_preen (uint8_t *rtp_payload)
 Preen potentially-SID EFR codec frame in RTP format, ensuring that it is either a speech frame or a valid SID, and if the latter, making it a perfect, error-free SID frame. More...
 
void osmo_fr_sid_reset (uint8_t *rtp_payload)
 Reset the SID field and the unused bits of a potentially corrupted, but still valid GSM-FR SID frame in RTP encoding to their pristine state. More...
 
void osmo_hr_sid_reset (uint8_t *rtp_payload)
 Reset the SID field of a potentially corrupted, but still valid GSM-HR SID frame in TS 101 318 format to its pristine state (full SID codeword). More...
 
void osmo_efr_sid_reset (uint8_t *rtp_payload)
 Reset the SID field of a potentially corrupted, but still valid GSM-EFR SID frame in RTP encoding to its pristine state (full SID code word). More...
 
int osmo_amr_rtp_enc (uint8_t *payload, uint8_t cmr, enum osmo_amr_type ft, enum osmo_amr_quality bfi)
 Encode various AMR parameters from RTP payload (RFC 4867) More...
 
int osmo_amr_rtp_dec (const uint8_t *payload, int payload_len, uint8_t *cmr, int8_t *cmi, enum osmo_amr_type *ft, enum osmo_amr_quality *bfi, int8_t *sti)
 Decode various AMR parameters from RTP payload (RFC 4867) acording to 3GPP TS 26.101. More...
 

Variables

const uint16_t gsm610_bitorder []
 
const uint16_t gsm620_unvoiced_bitorder []
 
const uint16_t gsm620_voiced_bitorder []
 
const uint16_t gsm660_bitorder []
 
const uint16_t gsm690_12_2_bitorder []
 
const uint16_t gsm690_10_2_bitorder []
 
const uint16_t gsm690_7_95_bitorder []
 
const uint16_t gsm690_7_4_bitorder []
 
const uint16_t gsm690_6_7_bitorder []
 
const uint16_t gsm690_5_9_bitorder []
 
const uint16_t gsm690_5_15_bitorder []
 
const uint16_t gsm690_4_75_bitorder []
 
const uint8_t osmo_gsm611_silence_frame [GSM_FR_BYTES]
 
const struct value_string osmo_amr_type_names []
 
const uint8_t gsm690_bitlength [AMR_NO_DATA+1]
 These constants refer to the length of one "AMR core frame" as per TS 26.101 Section 4.2.2 / Table 2. More...
 

Macro Definition Documentation

◆ GSM_EFR_BYTES

#define GSM_EFR_BYTES   31

◆ GSM_FR_BYTES

#define GSM_FR_BYTES   33

◆ GSM_HR_BYTES

#define GSM_HR_BYTES   14

◆ GSM_HR_BYTES_RTP_RFC5993

#define GSM_HR_BYTES_RTP_RFC5993   (GSM_HR_BYTES + 1)

◆ GSM_HR_BYTES_RTP_TS101318

#define GSM_HR_BYTES_RTP_TS101318   (GSM_HR_BYTES)

Enumeration Type Documentation

◆ osmo_amr_quality

Enumerator
AMR_BAD 
AMR_GOOD 

◆ osmo_amr_type

Enumerator
AMR_4_75 
AMR_5_15 
AMR_5_90 
AMR_6_70 
AMR_7_40 
AMR_7_95 
AMR_10_2 
AMR_12_2 
AMR_SID 
AMR_GSM_EFR_SID 
AMR_TDMA_EFR_SID 
AMR_PDC_EFR_SID 
AMR_NO_DATA 

◆ osmo_gsm631_sid_class

Enumerator
OSMO_GSM631_SID_CLASS_SPEECH 
OSMO_GSM631_SID_CLASS_INVALID 
OSMO_GSM631_SID_CLASS_VALID 

Function Documentation

◆ osmo_amr_d_to_s()

int osmo_amr_d_to_s ( ubit_t out,
const ubit_t in,
uint16_t  n_bits,
enum osmo_amr_type  amr_mode 
)

Convert from d-bits to s-bits (codec input).

Parameters
[out]outuser-provided output buffer for generated unpacked s-bits
[in]ininput buffer for unpacked d-bits
[in]n_bitsnumber of bits (in both in and out)
[in]AMRmode (0..7)

References ARRAY_SIZE, ts26101_reorder_table::len, n, ts26101_reorder_table::s_to_d, and ts26101_reorder_tables.

◆ osmo_amr_is_speech()

static bool osmo_amr_is_speech ( enum osmo_amr_type  ft)
inlinestatic

Check if given AMR Frame Type is a speech frame.

Parameters
[in]ftAMR Frame Type
Returns
true if AMR with given Frame Type contains voice, false otherwise

References AMR_10_2, AMR_12_2, AMR_4_75, AMR_5_15, AMR_5_90, AMR_6_70, AMR_7_40, and AMR_7_95.

◆ osmo_amr_rtp_dec()

int osmo_amr_rtp_dec ( const uint8_t *  rtppayload,
int  payload_len,
uint8_t *  cmr,
int8_t *  cmi,
enum osmo_amr_type ft,
enum osmo_amr_quality bfi,
int8_t *  sti 
)

Decode various AMR parameters from RTP payload (RFC 4867) acording to 3GPP TS 26.101.

Parameters
[in]rtppayloadPayload from RTP packet
[in]payload_lenlength of rtppayload
[out]cmrAMR Codec Mode Request, not filled if NULL
[out]cmiAMR Codec Mode Indicator, -1 if not applicable for this type, not filled if NULL
[out]ftAMR Frame Type, not filled if NULL
[out]bfiAMR Bad Frame Indicator, not filled if NULL
[out]stiAMR SID Type Indicator, -1 if not applicable for this type, not filled if NULL
Returns
length of AMR data or negative value on error

References amr_len_by_ft, AMR_SID, ENOTSUP, and type.

◆ osmo_amr_rtp_enc()

int osmo_amr_rtp_enc ( uint8_t *  payload,
uint8_t  cmr,
enum osmo_amr_type  ft,
enum osmo_amr_quality  bfi 
)

Encode various AMR parameters from RTP payload (RFC 4867)

Parameters
[out]payloadPayload for RTP packet, contains speech data (if any) except for have 2 first bytes where header will be built
[in]cmrAMR codec Mode Request
[in]ftAMR Frame Type
[in]bfiAMR Bad Frame Indicator
Returns
length of AMR data (header + ToC + speech data) or negative value on error

Note: only octet-aligned mode is supported so the header occupies 2 full bytes. Optional interleaving header is not supported.

References amr_len_by_ft, and ENOTSUP.

◆ osmo_amr_s_to_d()

int osmo_amr_s_to_d ( ubit_t out,
const ubit_t in,
uint16_t  n_bits,
enum osmo_amr_type  amr_mode 
)

Convert from S-bits (codec output) to d-bits.

Parameters
[out]outuser-provided output buffer for generated unpacked d-bits
[in]ininput buffer for unpacked s-bits
[in]n_bitsnumber of bits (in both in and out)
[in]AMRmode (0..7)

References ARRAY_SIZE, ts26101_reorder_table::len, n, ts26101_reorder_table::s_to_d, and ts26101_reorder_tables.

◆ osmo_amr_type_name()

static const char* osmo_amr_type_name ( enum osmo_amr_type  type)
inlinestatic

◆ osmo_efr_check_sid()

bool osmo_efr_check_sid ( const uint8_t *  rtp_payload,
size_t  payload_len 
)

Check whether RTP frame contains EFR SID code word according to TS 101 318 §5.3.2.

Parameters
[in]rtp_payloadBuffer with RTP payload
[in]payload_lenLength of payload
Returns
true if code word is found, false otherwise

References ARRAY_SIZE, bitvec_get_bit_pos(), bitvec::data, bitvec::data_len, ONE, and sid_code_word_bits.

◆ osmo_efr_is_any_sid()

static bool osmo_efr_is_any_sid ( const uint8_t *  rtp_payload)
inlinestatic

Check if given EFR codec frame is any kind of SID, valid or invalid.

Parameters
[in]rtp_payloadBuffer with RTP payload
Returns
true if the frame is an "accepted SID frame" in GSM 06.81 definition, false otherwise.

References osmo_efr_sid_classify(), and OSMO_GSM631_SID_CLASS_SPEECH.

◆ osmo_efr_sid_classify()

enum osmo_gsm631_sid_class osmo_efr_sid_classify ( const uint8_t *  rtp_payload)

Classify potentially-SID EFR codec frame in RTP format according to the rules of GSM 06.81 §6.1.1.

Parameters
[in]rtp_payloadBuffer with RTP payload
Returns
enum osmo_gsm631_sid_class, with symbolic values OSMO_GSM631_SID_CLASS_SPEECH, OSMO_GSM631_SID_CLASS_INVALID or OSMO_GSM631_SID_CLASS_VALID corresponding to the 3 possible bit-counting classifications prescribed by the spec.

Differences between the more familiar osmo_efr_check_sid() and the present function are:

  1. osmo_efr_check_sid() returns true only if the SID frame is absolutely perfect, with all 95 bits of the SID code word set. However, the rules of GSM 06.81 §6.1.1 allow up to one bit to be in error, and the frame is still accepted as valid SID.
  2. The third possible state of invalid SID is not handled at all by the simpler osmo_efr_check_sid() function.
  3. osmo_efr_check_sid() includes a check for 0xC RTP signature, and returns false if that signature nibble is wrong. That check is not included in the present version because there is no place for it in the ETSI-prescribed classification, it is neither speech nor SID. The assumption is that this function is used to classify the bit content of received codec frames, not their RTP encoding - the latter needs to be validated beforehand.

Which function should one use? The answer depends on the specific circumstances, and needs to be addressed on a case-by-case basis.

References ARRAY_SIZE, bitvec_get_bit_pos(), bitvec::data, bitvec::data_len, GSM_EFR_BYTES, n, ONE, OSMO_GSM631_SID_CLASS_INVALID, OSMO_GSM631_SID_CLASS_SPEECH, OSMO_GSM631_SID_CLASS_VALID, and sid_code_word_bits.

Referenced by osmo_efr_is_any_sid(), and osmo_efr_sid_preen().

◆ osmo_efr_sid_preen()

bool osmo_efr_sid_preen ( uint8_t *  rtp_payload)

Preen potentially-SID EFR codec frame in RTP format, ensuring that it is either a speech frame or a valid SID, and if the latter, making it a perfect, error-free SID frame.

Parameters
[in]rtp_payloadBuffer with RTP payload - must be writable!
Returns
true if the frame is good, false otherwise

References OSMO_ASSERT, osmo_efr_sid_classify(), osmo_efr_sid_reset(), OSMO_GSM631_SID_CLASS_INVALID, OSMO_GSM631_SID_CLASS_SPEECH, and OSMO_GSM631_SID_CLASS_VALID.

◆ osmo_efr_sid_reset()

void osmo_efr_sid_reset ( uint8_t *  rtp_payload)

Reset the SID field of a potentially corrupted, but still valid GSM-EFR SID frame in RTP encoding to its pristine state (full SID code word).

Parameters
[in]rtp_payloadBuffer with RTP payload - must be writable!

Per GSM 06.62 section 5.3, a freshly minted SID frame consists of 58 bits of comfort noise parameters (LSF and 4 times fixed codebook gain), 95 bits of SID code word (all 1s) and 91 unused bits (all 0s). Network elements that receive SID frames from call leg A uplink and need to retransmit them on leg B downlink should "rejuvenate" received SID frames prior to retransmission by resetting the SID field to its pristine state of all 1s; this function does the job.

Potential TODO: it would be nice to also zero out the remaining 91 bits which the spec leaves as reserved, clearing out leg A radio bit errors - but do we really need to?

Referenced by osmo_efr_sid_preen().

◆ osmo_fr_check_sid()

bool osmo_fr_check_sid ( const uint8_t *  rtp_payload,
size_t  payload_len 
)

Check whether RTP frame contains FR SID code word according to TS 101 318 §5.1.2.

Parameters
[in]rtp_payloadBuffer with RTP payload
[in]payload_lenLength of payload
Returns
true if code word is found, false otherwise

References ARRAY_SIZE, bitvec_get_bit_pos(), bitvec::data, bitvec::data_len, sid_code_word_bits, and ZERO.

Referenced by conceal_frame().

◆ osmo_fr_is_any_sid()

static bool osmo_fr_is_any_sid ( const uint8_t *  rtp_payload)
inlinestatic

Check if given FR codec frame is any kind of SID, valid or invalid.

Parameters
[in]rtp_payloadBuffer with RTP payload
Returns
true if the frame is an "accepted SID frame" in GSM 06.31 definition, false otherwise.

References osmo_fr_sid_classify(), and OSMO_GSM631_SID_CLASS_SPEECH.

◆ osmo_fr_sid_classify()

enum osmo_gsm631_sid_class osmo_fr_sid_classify ( const uint8_t *  rtp_payload)

Classify potentially-SID FR codec frame in RTP format according to the rules of GSM 06.31 §6.1.1.

Parameters
[in]rtp_payloadBuffer with RTP payload
Returns
enum osmo_gsm631_sid_class, with symbolic values OSMO_GSM631_SID_CLASS_SPEECH, OSMO_GSM631_SID_CLASS_INVALID or OSMO_GSM631_SID_CLASS_VALID corresponding to the 3 possible bit-counting classifications prescribed by the spec.

Differences between the more familiar osmo_fr_check_sid() and the present function are:

  1. osmo_fr_check_sid() returns true only if the SID frame is absolutely perfect, with all 95 bits of the SID code word zeroed. However, the rules of GSM 06.31 §6.1.1 allow up to one bit to be in error, and the frame is still accepted as valid SID.
  2. The third possible state of invalid SID is not handled at all by the simpler osmo_fr_check_sid() function.
  3. osmo_fr_check_sid() includes a check for 0xD RTP signature, and returns false if that signature nibble is wrong. That check is not included in the present version because there is no place for it in the ETSI-prescribed classification, it is neither speech nor SID. The assumption is that this function is used to classify the bit content of received codec frames, not their RTP encoding - the latter needs to be validated beforehand.

Which function should one use? The answer depends on the specific circumstances, and needs to be addressed on a case-by-case basis.

References ARRAY_SIZE, bitvec_get_bit_pos(), bitvec::data, bitvec::data_len, GSM_FR_BYTES, n, OSMO_GSM631_SID_CLASS_INVALID, OSMO_GSM631_SID_CLASS_SPEECH, OSMO_GSM631_SID_CLASS_VALID, sid_code_word_bits, and ZERO.

Referenced by fr_ecu_input(), osmo_fr_is_any_sid(), and osmo_fr_sid_preen().

◆ osmo_fr_sid_preen()

bool osmo_fr_sid_preen ( uint8_t *  rtp_payload)

Preen potentially-SID FR codec frame in RTP format, ensuring that it is either a speech frame or a valid SID, and if the latter, making it a perfect, error-free SID frame.

Parameters
[in]rtp_payloadBuffer with RTP payload - must be writable!
Returns
true if the frame is good, false otherwise

References OSMO_ASSERT, osmo_fr_sid_classify(), osmo_fr_sid_reset(), OSMO_GSM631_SID_CLASS_INVALID, OSMO_GSM631_SID_CLASS_SPEECH, and OSMO_GSM631_SID_CLASS_VALID.

◆ osmo_fr_sid_reset()

void osmo_fr_sid_reset ( uint8_t *  rtp_payload)

Reset the SID field and the unused bits of a potentially corrupted, but still valid GSM-FR SID frame in RTP encoding to their pristine state.

Parameters
[in]rtp_payloadBuffer with RTP payload - must be writable!

Per GSM 06.12 section 5.2, a freshly minted SID frame carries 60 bits of comfort noise parameters (LARc and 4 times Xmaxc), while the remaining 200 bits are all zeros; the latter 200 all-0 bits further break down into 95 bits of SID field (checked by receivers to detect SID) and 105 unused bits which receivers are told to ignore. Network elements that receive SID frames from call leg A uplink and need to retransmit them on leg B downlink should "rejuvenate" received SID frames prior to retransmission; this function does the job.

Referenced by osmo_fr_sid_preen().

◆ osmo_hr_check_sid()

bool osmo_hr_check_sid ( const uint8_t *  rtp_payload,
size_t  payload_len 
)

Check whether RTP frame contains HR SID code word according to TS 101 318 §5.2.2.

Parameters
[in]rtp_payloadBuffer with RTP payload
[in]payload_lenLength of payload
Returns
true if code word is found, false otherwise

References bitvec_get_bit_pos(), bitvec::cur_bit, bitvec::data, bitvec::data_len, and ONE.

◆ osmo_hr_sid_reset()

void osmo_hr_sid_reset ( uint8_t *  rtp_payload)

Reset the SID field of a potentially corrupted, but still valid GSM-HR SID frame in TS 101 318 format to its pristine state (full SID codeword).

Parameters
[in]rtp_payloadBuffer with RTP payload - must be writable!

Per GSM 06.22 section 5.3, a freshly minted SID frame consists of 33 bits of comfort noise parameters and 79 bits of SID codeword (all 1s). Network elements that receive SID frames from call leg A uplink and need to retransmit them on leg B downlink should "rejuvenate" received SID frames prior to retransmission by resetting the SID field to its pristine state of all 1s; this function does the job.

Important note: because of HR-specific quirks (lack of exact bit counting rules in GSM 06.41 spec compared to 06.31 & 06.81, plus the fact that such bit counting can only be done efficiently in the GSM 05.03 channel decoder prior to bit reordering based on voiced or unvoiced mode), a generic (usable from any network element) SID classification function similar to osmo_{fr,efr}_sid_classify() unfortunately cannot exist for HR. Therefore, the triggering condition for invoking this SID rejuvenation/reset function can only be an out-of-band SID indication, as in GSM 08.61 TRAU frames or RFC 5993 ToC octet.

Variable Documentation

◆ gsm610_bitorder

const uint16_t gsm610_bitorder[]

◆ gsm620_unvoiced_bitorder

const uint16_t gsm620_unvoiced_bitorder[]

◆ gsm620_voiced_bitorder

const uint16_t gsm620_voiced_bitorder[]

◆ gsm660_bitorder

const uint16_t gsm660_bitorder[]

◆ gsm690_10_2_bitorder

const uint16_t gsm690_10_2_bitorder[]

◆ gsm690_12_2_bitorder

const uint16_t gsm690_12_2_bitorder[]

◆ gsm690_4_75_bitorder

const uint16_t gsm690_4_75_bitorder[]

◆ gsm690_5_15_bitorder

const uint16_t gsm690_5_15_bitorder[]

◆ gsm690_5_9_bitorder

const uint16_t gsm690_5_9_bitorder[]

◆ gsm690_6_7_bitorder

const uint16_t gsm690_6_7_bitorder[]

◆ gsm690_7_4_bitorder

const uint16_t gsm690_7_4_bitorder[]

◆ gsm690_7_95_bitorder

const uint16_t gsm690_7_95_bitorder[]

◆ gsm690_bitlength

const uint8_t gsm690_bitlength[AMR_NO_DATA+1]

These constants refer to the length of one "AMR core frame" as per TS 26.101 Section 4.2.2 / Table 2.

◆ osmo_amr_type_names

const struct value_string osmo_amr_type_names[]

Referenced by osmo_amr_type_name().

◆ osmo_gsm611_silence_frame

const uint8_t osmo_gsm611_silence_frame[GSM_FR_BYTES]

Referenced by fr_ecu_output().

AMR_12_2
@ AMR_12_2
Definition: codec.h:48
bitvec_read_field
uint64_t bitvec_read_field(struct bitvec *bv, unsigned int *read_index, unsigned int len)
gsm690_5_15_bitorder
const uint16_t gsm690_5_15_bitorder[103]
Definition: gsm690.c:186
osmo_ecu_fr_state::subsequent_lost_frame
bool subsequent_lost_frame
Definition: ecu.h:11
AMR_SID
@ AMR_SID
Definition: codec.h:49
bitvec::data
uint8_t * data
GSM_FR_BYTES
#define GSM_FR_BYTES
Definition: codec.h:12
osmo_ecu_frame_out
int osmo_ecu_frame_out(struct osmo_ecu_state *st, uint8_t *frame_out)
generate output data for a substitute/erroneous frame.
Definition: ecu.c:90
gsm690_7_4_bitorder
const uint16_t gsm690_7_4_bitorder[148]
Definition: gsm690.c:124
osmo_amr_s_to_d
int osmo_amr_s_to_d(ubit_t *out, const ubit_t *in, uint16_t n_bits, enum osmo_amr_type amr_mode)
Convert from S-bits (codec output) to d-bits.
Definition: gsm690.c:278
gsm690_7_95_bitorder
const uint16_t gsm690_7_95_bitorder[159]
Definition: gsm690.c:101
gsm620_voiced_bitorder
const uint16_t gsm620_voiced_bitorder[112]
Definition: gsm620.c:153
osmo_prbs_state_init
void osmo_prbs_state_init(struct osmo_prbs_state *st, const struct osmo_prbs *prbs)
osmo_hr_check_sid
bool osmo_hr_check_sid(const uint8_t *rtp_payload, size_t payload_len)
Check whether RTP frame contains HR SID code word according to TS 101 318 §5.2.2.
Definition: gsm620.c:274
osmo_ecu_state::codec
enum osmo_ecu_codec codec
Definition: ecu.h:50
osmo_amr_type_names
const struct value_string osmo_amr_type_names[]
Definition: gsm690.c:330
osmo_fr_check_sid
bool osmo_fr_check_sid(const uint8_t *rtp_payload, size_t payload_len)
Check whether RTP frame contains FR SID code word according to TS 101 318 §5.1.2.
Definition: gsm610.c:334
fr_ecu_state::sid_prefix
uint8_t sid_prefix[SID_PREFIX_LEN]
Definition: ecu_fr.c:94
osmo_amr_rtp_dec
int osmo_amr_rtp_dec(const uint8_t *rtppayload, int payload_len, uint8_t *cmr, int8_t *cmi, enum osmo_amr_type *ft, enum osmo_amr_quality *bfi, int8_t *sti)
Decode various AMR parameters from RTP payload (RFC 4867) acording to 3GPP TS 26.101.
Definition: gsm690.c:360
ecu_fr_init
static struct osmo_ecu_state * ecu_fr_init(void *ctx, enum osmo_ecu_codec codec)
Definition: ecu_fr.c:284
bitvec_get_bit_pos
enum bit_value bitvec_get_bit_pos(const struct bitvec *bv, unsigned int bitnr)
osmo_amr_type
osmo_amr_type
Definition: codec.h:40
len
static size_t len(const char *str)
fr_ecu_state::prng
struct osmo_prbs_state prng
Definition: ecu_fr.c:97
bitvec_pack
unsigned int bitvec_pack(const struct bitvec *bv, uint8_t *buffer)
ZERO
ZERO
n
write Write running configuration to or terminal n Write configuration to the copy running config startup Copy configuration n Copy running config to n Copy running config to startup write Write running configuration to or terminal n Write to terminal n
fr_ecu_state::pr_state
enum ecu_principal_state pr_state
Definition: ecu_fr.c:92
osmo_ecu_is_dtx_pause
bool osmo_ecu_is_dtx_pause(struct osmo_ecu_state *st)
check if the current state of this ECU is a DTX pause.
Definition: ecu.c:102
OSMO_ASSERT
#define OSMO_ASSERT(exp)
GSM611_XMAXC_REDUCE
#define GSM611_XMAXC_REDUCE
Definition: ecu_fr.c:76
gsm690_bitlength
const uint8_t gsm690_bitlength[AMR_NO_DATA+1]
These constants refer to the length of one "AMR core frame" as per TS 26.101 Section 4....
Definition: gsm690.c:219
fr_ecu_input
static void fr_ecu_input(struct fr_ecu_state *fr, const uint8_t *frame)
Definition: ecu_fr.c:105
utils.h
ts26101_reorder_table
Definition: gsm690.c:231
bitvec_free
void bitvec_free(struct bitvec *bv)
SID_PREFIX_LEN
#define SID_PREFIX_LEN
Definition: ecu_fr.c:81
bitvec::data_len
unsigned int data_len
osmo_ecu_destroy
void osmo_ecu_destroy(struct osmo_ecu_state *st)
destroy an ECU instance
Definition: ecu.c:58
GSM610_XMAXC_REDUCE
#define GSM610_XMAXC_REDUCE
Definition: ecu_fr_old.c:35
GSM610_XMAXC_LEN
#define GSM610_XMAXC_LEN
Definition: ecu_fr_old.c:36
osmo_ecu_fr_state::frame_backup
uint8_t frame_backup[GSM_FR_BYTES]
Definition: ecu.h:12
osmo_gsm631_sid_class
osmo_gsm631_sid_class
Definition: codec.h:91
gsm690_6_7_bitorder
const uint16_t gsm690_6_7_bitorder[134]
Definition: gsm690.c:146
ecu_fr_is_dtx_pause
static bool ecu_fr_is_dtx_pause(struct osmo_ecu_state *st)
Definition: ecu_fr.c:327
osmo_ecu_state::data
uint8_t data[0]
Definition: ecu.h:51
reduce_xmaxcr
static bool reduce_xmaxcr(struct bitvec *frame_bitvec, const unsigned int index)
Reduce the XMAXC field.
Definition: ecu_fr_old.c:42
OSMO_GSM631_SID_CLASS_SPEECH
@ OSMO_GSM631_SID_CLASS_SPEECH
Definition: codec.h:92
ecu_principal_state
ecu_principal_state
Definition: ecu_fr.c:83
osmo_prbs_get_ubit
ubit_t osmo_prbs_get_ubit(struct osmo_prbs_state *state)
STATE_SID_MUTING
@ STATE_SID_MUTING
Definition: ecu_fr.c:88
gsm690_10_2_bitorder
const uint16_t gsm690_10_2_bitorder[204]
Definition: gsm690.c:73
prbs.h
random_grid_pos
static void random_grid_pos(struct fr_ecu_state *fr, uint8_t *frame)
Definition: ecu_fr.c:189
GSM610_RTP_XMAXC00
@ GSM610_RTP_XMAXC00
Definition: gsm610_bits.h:59
osmo_fr_check_sid
bool osmo_fr_check_sid(const uint8_t *rtp_payload, size_t payload_len)
Check whether RTP frame contains FR SID code word according to TS 101 318 §5.1.2.
Definition: gsm610.c:334
codec.h
osmo_ecu_frame_in
int osmo_ecu_frame_in(struct osmo_ecu_state *st, bool bfi, const uint8_t *frame, unsigned int frame_bytes)
process a received frame a substitute/erroneous frame.
Definition: ecu.c:76
osmo_ecu_fr_conceal
int osmo_ecu_fr_conceal(struct osmo_ecu_fr_state *state, uint8_t *frame)
To be called when a bad frame is received.
Definition: ecu_fr_old.c:147
osmo_ecu_register
int osmo_ecu_register(const struct osmo_ecu_ops *ops, enum osmo_ecu_codec codec)
register an ECU implementation for a given codec
Definition: ecu.c:118
AMR_7_95
@ AMR_7_95
Definition: codec.h:46
g_ecu_ops
static const struct osmo_ecu_ops * g_ecu_ops[_NUM_OSMO_ECU_CODECS]
Definition: ecu.c:39
AMR_NO_DATA
@ AMR_NO_DATA
Definition: codec.h:53
osmo_ecu_ops::is_dtx_pause
bool(* is_dtx_pause)(struct osmo_ecu_state *st)
Definition: ecu.h:74
AMR_4_75
@ AMR_4_75
Definition: codec.h:41
AMR_PDC_EFR_SID
@ AMR_PDC_EFR_SID
Definition: codec.h:52
GSM610_RTP_XMAXC30
@ GSM610_RTP_XMAXC30
Definition: gsm610_bits.h:227
STATE_SP_MUTING
@ STATE_SP_MUTING
Definition: ecu_fr.c:86
osmo_amr_rtp_enc
int osmo_amr_rtp_enc(uint8_t *payload, uint8_t cmr, enum osmo_amr_type ft, enum osmo_amr_quality bfi)
Encode various AMR parameters from RTP payload (RFC 4867)
Definition: gsm690.c:408
gsm620_unvoiced_bitorder
const uint16_t gsm620_unvoiced_bitorder[112]
Definition: gsm620.c:34
osmo_efr_check_sid
bool osmo_efr_check_sid(const uint8_t *rtp_payload, size_t payload_len)
Check whether RTP frame contains EFR SID code word according to TS 101 318 §5.3.2.
Definition: gsm660.c:282
fr_ecu_state::speech_frame
uint8_t speech_frame[GSM_FR_BYTES]
Definition: ecu_fr.c:93
AMR_5_15
@ AMR_5_15
Definition: codec.h:42
fr_ecu_output
static void fr_ecu_output(struct fr_ecu_state *fr, uint8_t *frame)
Definition: ecu_fr.c:237
gsm690_5_9_bitorder
const uint16_t gsm690_5_9_bitorder[118]
Definition: gsm690.c:167
gsm690_4_75_bitorder
const uint16_t gsm690_4_75_bitorder[95]
Definition: gsm690.c:204
osmo_ecu_fr_state
Definition: ecu.h:10
bitvec.h
osmo_ecu_fr_reset
void osmo_ecu_fr_reset(struct osmo_ecu_fr_state *state, const uint8_t *frame)
To be called when a good frame is received.
Definition: ecu_fr_old.c:133
AMR_6_70
@ AMR_6_70
Definition: codec.h:44
STATE_SPEECH
@ STATE_SPEECH
Definition: ecu_fr.c:85
__attribute__
static __attribute__((constructor))
Definition: ecu_fr.c:341
osmo_fr_sid_preen
bool osmo_fr_sid_preen(uint8_t *rtp_payload)
Preen potentially-SID FR codec frame in RTP format, ensuring that it is either a speech frame or a va...
Definition: gsm610.c:442
reemit_sid
static void reemit_sid(struct fr_ecu_state *fr, uint8_t *frame)
Definition: ecu_fr.c:216
talloc.h
osmo_fr_sid_classify
enum osmo_gsm631_sid_class osmo_fr_sid_classify(const uint8_t *rtp_payload)
Classify potentially-SID FR codec frame in RTP format according to the rules of GSM 06....
Definition: gsm610.c:385
if
if(vty->type==VTY_SHELL_SERV)
osmo_ecu_state
Definition: ecu.h:47
bitvec_write_field
int bitvec_write_field(struct bitvec *bv, unsigned int *write_index, uint64_t val, unsigned int len)
OSMO_GSM631_SID_CLASS_INVALID
@ OSMO_GSM631_SID_CLASS_INVALID
Definition: codec.h:93
osmo_fr_sid_reset
void osmo_fr_sid_reset(uint8_t *rtp_payload)
Reset the SID field and the unused bits of a potentially corrupted, but still valid GSM-FR SID frame ...
Definition: gsm610.c:420
osmo_ecu_ops::destroy
void(* destroy)(struct osmo_ecu_state *)
Definition: ecu.h:70
osmo_ecu_ops::init
struct osmo_ecu_state *(* init)(void *ctx, enum osmo_ecu_codec codec)
Definition: ecu.h:69
AMR_7_40
@ AMR_7_40
Definition: codec.h:45
bitvec
gsm690_12_2_bitorder
const uint16_t gsm690_12_2_bitorder[244]
Definition: gsm690.c:41
OSMO_GSM631_SID_CLASS_VALID
@ OSMO_GSM631_SID_CLASS_VALID
Definition: codec.h:94
ts26101_reorder_table::len
uint8_t len
size of table
Definition: gsm690.c:235
fr_ecu_state::sid_reemit_count
uint8_t sid_reemit_count
Definition: ecu_fr.c:96
AMR_5_90
@ AMR_5_90
Definition: codec.h:43
fr_ecu_state::last_input_was_sid
bool last_input_was_sid
Definition: ecu_fr.c:98
ONE
ONE
value_string
ts26101_reorder_table::s_to_d
const uint16_t * s_to_d
Table as per TS 26.101 Annex B to compute d-bits from s-bits.
Definition: gsm690.c:233
gsm660_bitorder
const uint16_t gsm660_bitorder[260]
Definition: gsm660.c:38
STATE_NO_DATA
@ STATE_NO_DATA
Definition: ecu_fr.c:84
reduce_xmaxc_sid
static bool reduce_xmaxc_sid(struct fr_ecu_state *fr)
Definition: ecu_fr.c:201
gsm610_bits.h
osmo_hr_sid_reset
void osmo_hr_sid_reset(uint8_t *rtp_payload)
Reset the SID field of a potentially corrupted, but still valid GSM-HR SID frame in TS 101 318 format...
Definition: gsm620.c:311
sid_code_word_bits
static const uint8_t sid_code_word_bits[95]
Definition: gsm660.c:261
osmo_ecu_codec
osmo_ecu_codec
Definition: ecu.h:20
ubit_t
uint8_t ubit_t
ARRAY_SIZE
#define ARRAY_SIZE(x)
sid_code_word_bits
static const uint16_t sid_code_word_bits[95]
Definition: gsm610.c:313
bitvec_alloc
struct bitvec * bitvec_alloc(unsigned int size, void *ctx)
GSM610_RTP_XMAXC20
@ GSM610_RTP_XMAXC20
Definition: gsm610_bits.h:171
osmo_gsm611_silence_frame
const uint8_t osmo_gsm611_silence_frame[GSM_FR_BYTES]
Definition: gsm610.c:305
osmo_prbs15
const struct osmo_prbs osmo_prbs15
reduce_xmaxc
static bool reduce_xmaxc(uint8_t *frame)
Definition: ecu_fr.c:163
osmo_efr_sid_classify
enum osmo_gsm631_sid_class osmo_efr_sid_classify(const uint8_t *rtp_payload)
Classify potentially-SID EFR codec frame in RTP format according to the rules of GSM 06....
Definition: gsm660.c:333
amr_len_by_ft
static const uint8_t amr_len_by_ft[16]
Definition: gsm690.c:326
ecu.h
AMR_TDMA_EFR_SID
@ AMR_TDMA_EFR_SID
Definition: codec.h:51
osmo_ecu_ops::frame_in
int(* frame_in)(struct osmo_ecu_state *st, bool bfi, const uint8_t *frame, unsigned int frame_bytes)
Definition: ecu.h:71
GSM610_RTP_XMAXC10
@ GSM610_RTP_XMAXC10
Definition: gsm610_bits.h:115
fr_ecu_state::sid_xmaxc
uint8_t sid_xmaxc
Definition: ecu_fr.c:95
reduce_xmaxcr_all
static bool reduce_xmaxcr_all(struct bitvec *frame_bitvec)
Reduce all XMAXC fields in the frame.
Definition: ecu_fr_old.c:65
ts26101_reorder_tables
static const struct ts26101_reorder_table ts26101_reorder_tables[8]
Definition: gsm690.c:238
osmo_ecu_init
struct osmo_ecu_state * osmo_ecu_init(void *ctx, enum osmo_ecu_codec codec)
initialize an ECU instance for given codec.
Definition: ecu.c:48
osmo_ecu_register
int osmo_ecu_register(const struct osmo_ecu_ops *ops, enum osmo_ecu_codec codec)
register an ECU implementation for a given codec
Definition: ecu.c:118
ecu_fr_frame_in
static int ecu_fr_frame_in(struct osmo_ecu_state *st, bool bfi, const uint8_t *frame, unsigned int frame_bytes)
Definition: ecu_fr.c:303
ecu_fr_frame_out
static int ecu_fr_frame_out(struct osmo_ecu_state *st, uint8_t *frame_out)
Definition: ecu_fr.c:319
fr_ecu_state
Definition: ecu_fr.c:91
bitvec::cur_bit
unsigned int cur_bit
type
enum osmo_sub_auth_type type
osmo_efr_sid_reset
void osmo_efr_sid_reset(uint8_t *rtp_payload)
Reset the SID field of a potentially corrupted, but still valid GSM-EFR SID frame in RTP encoding to ...
Definition: gsm660.c:371
bits.h
osmo_ecu_ops::frame_out
int(* frame_out)(struct osmo_ecu_state *st, uint8_t *frame_out)
Definition: ecu.h:73
osmo_efr_sid_preen
bool osmo_efr_sid_preen(uint8_t *rtp_payload)
Preen potentially-SID EFR codec frame in RTP format, ensuring that it is either a speech frame or a v...
Definition: gsm660.c:397
AMR_10_2
@ AMR_10_2
Definition: codec.h:47
osmo_amr_quality
osmo_amr_quality
Definition: codec.h:59
osmo_ecu_ops_fr
static const struct osmo_ecu_ops osmo_ecu_ops_fr
Definition: ecu_fr.c:334
osmo_amr_d_to_s
int osmo_amr_d_to_s(ubit_t *out, const ubit_t *in, uint16_t n_bits, enum osmo_amr_type amr_mode)
Convert from d-bits to s-bits (codec input).
Definition: gsm690.c:304
OSMO_ECU_CODEC_FR
@ OSMO_ECU_CODEC_FR
Definition: ecu.h:22
osmo_prbs_state
GSM_EFR_BYTES
#define GSM_EFR_BYTES
Definition: codec.h:16
gsm610_bitorder
const uint16_t gsm610_bitorder[260]
Definition: gsm610.c:36
AMR_GSM_EFR_SID
@ AMR_GSM_EFR_SID
Definition: codec.h:50
osmo_gsm611_silence_frame
const uint8_t osmo_gsm611_silence_frame[GSM_FR_BYTES]
Definition: gsm610.c:305
osmo_ecu_ops
Definition: ecu.h:68
ENOTSUP
#define ENOTSUP
conceal_frame
static int conceal_frame(uint8_t *frame)
Definition: ecu_fr_old.c:78
_NUM_OSMO_ECU_CODECS
@ _NUM_OSMO_ECU_CODECS
Definition: ecu.h:25
bitvec_unpack
unsigned int bitvec_unpack(struct bitvec *bv, const uint8_t *buffer)
STATE_SID
@ STATE_SID
Definition: ecu_fr.c:87
osmo_fr_sid_classify
enum osmo_gsm631_sid_class osmo_fr_sid_classify(const uint8_t *rtp_payload)
Classify potentially-SID FR codec frame in RTP format according to the rules of GSM 06....
Definition: gsm610.c:385