codec.h File Reference
`#include <stdint.h>`
`#include <stdbool.h>`
`#include <osmocom/core/utils.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

## 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 }

## Functions

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...
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 struct value_string | osmo_amr_type_names []

## 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

## Enumeration Type Documentation

## osmo_amr_quality

enum osmo_amr_quality

Enumerator
AMR_BAD |
AMR_GOOD |

## osmo_amr_type

enum 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 |

## Function Documentation

## osmo_amr_is_speech()

static bool osmo_amr_is_speech | ( | enum osmo_amr_type | ft | ) |

inline static

Check if given AMR Frame Type is a speech frame.

Parameters

  [in] | ft | AMR 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] | rtppayload | Payload from RTP packet
  [in] | payload_len | length of rtppayload
  [out] | cmr | AMR Codec Mode Request, not filled if NULL
  [out] | cmi | AMR Codec Mode Indicator, -1 if not applicable for this type, not filled if NULL
  [out] | ft | AMR Frame Type, not filled if NULL
  [out] | bfi | AMR Bad Frame Indicator, not filled if NULL
  [out] | sti | AMR 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, and AMR_SID.

## 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] | payload | Payload for RTP packet, contains speech data (if any) except for have 2 first bytes where header will be built
  [in] | cmr | AMR codec Mode Request
  [in] | ft | AMR Frame Type
  [in] | bfi | AMR 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.

## 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_payload | Buffer with RTP payload
  [in] | payload_len | Length of payload

Returns
  true if code word is found, false otherwise

Referenced by conceal_frame().

## 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_payload | Buffer with RTP payload
  [in] | payload_len | Length of payload

Returns
  true if code word is found, false otherwise

References mask().

## 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[]

## osmo_amr_type_names

const struct value_string osmo_amr_type_names[]

AMR_12_2
@ AMR_12_2
Definition: codec.h:41
gsm690_5_15_bitorder
const uint16_t gsm690_5_15_bitorder[103]
Definition: gsm690.c:188
osmo_ecu_fr_state::subsequent_lost_frame
bool subsequent_lost_frame
Definition: ecu.h:10
reduce_xmaxcr_all
static bool reduce_xmaxcr_all(struct bitvec *frame_bitvec)
Reduce all XMAXC fields in the frame.
Definition: ecu_fr.c:65
AMR_SID
@ AMR_SID
Definition: codec.h:42
GSM_FR_BYTES
#define GSM_FR_BYTES
Definition: codec.h:11
gsm690_7_4_bitorder
const uint16_t gsm690_7_4_bitorder[148]
Definition: gsm690.c:126
mask
static uint16_t mask(const uint8_t msb)
Definition: gsm620.c:271
gsm690_7_95_bitorder
const uint16_t gsm690_7_95_bitorder[159]
Definition: gsm690.c:103
gsm620_voiced_bitorder
const uint16_t gsm620_voiced_bitorder[112]
Definition: gsm620.c:156
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:283
osmo_amr_type_names
const struct value_string osmo_amr_type_names[]
Definition: gsm690.c:223
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:309
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:253
osmo_amr_type
osmo_amr_type
Definition: codec.h:33
osmo_ecu_fr_state::frame_backup
uint8_t frame_backup[GSM_FR_BYTES]
Definition: ecu.h:11
gsm690_6_7_bitorder
const uint16_t gsm690_6_7_bitorder[134]
Definition: gsm690.c:148
reduce_xmaxcr
static bool reduce_xmaxcr(struct bitvec *frame_bitvec, const unsigned int index)
Reduce the XMAXC field.
Definition: ecu_fr.c:42
gsm690_10_2_bitorder
const uint16_t gsm690_10_2_bitorder[204]
Definition: gsm690.c:75
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:309
codec.h
AMR_7_95
@ AMR_7_95
Definition: codec.h:39
conceal_frame
static int conceal_frame(uint8_t *frame)
Definition: ecu_fr.c:78
AMR_NO_DATA
@ AMR_NO_DATA
Definition: codec.h:46
AMR_4_75
@ AMR_4_75
Definition: codec.h:34
AMR_PDC_EFR_SID
@ AMR_PDC_EFR_SID
Definition: codec.h:45
GSM610_RTP_XMAXC30
@ GSM610_RTP_XMAXC30
Definition: gsm610_bits.h:227
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:301
gsm620_unvoiced_bitorder
const uint16_t gsm620_unvoiced_bitorder[112]
Definition: gsm620.c:37
AMR_5_15
@ AMR_5_15
Definition: codec.h:35
osmo_ecu_fr_reset
void osmo_ecu_fr_reset(struct osmo_ecu_fr_state *state, uint8_t *frame)
To be called when a good frame is received.
Definition: ecu_fr.c:131
gsm690_5_9_bitorder
const uint16_t gsm690_5_9_bitorder[118]
Definition: gsm690.c:169
gsm690_4_75_bitorder
const uint16_t gsm690_4_75_bitorder[95]
Definition: gsm690.c:206
osmo_ecu_fr_state
Definition: ecu.h:9
GSM610_XMAXC_REDUCE
#define GSM610_XMAXC_REDUCE
Definition: ecu_fr.c:35
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.c:142
AMR_6_70
@ AMR_6_70
Definition: codec.h:37
AMR_7_40
@ AMR_7_40
Definition: codec.h:38
gsm690_12_2_bitorder
const uint16_t gsm690_12_2_bitorder[244]
Definition: gsm690.c:43
AMR_5_90
@ AMR_5_90
Definition: codec.h:36
gsm660_bitorder
const uint16_t gsm660_bitorder[260]
Definition: gsm660.c:38
gsm610_bits.h
GSM610_RTP_XMAXC20
@ GSM610_RTP_XMAXC20
Definition: gsm610_bits.h:171
amr_len_by_ft
static const uint8_t amr_len_by_ft[16]
Definition: gsm690.c:219
ecu.h
AMR_TDMA_EFR_SID
@ AMR_TDMA_EFR_SID
Definition: codec.h:44
GSM610_RTP_XMAXC10
@ GSM610_RTP_XMAXC10
Definition: gsm610_bits.h:115
AMR_10_2
@ AMR_10_2
Definition: codec.h:40
osmo_amr_quality
osmo_amr_quality
Definition: codec.h:49
gsm610_bitorder
const uint16_t gsm610_bitorder[260]
Definition: gsm610.c:40
AMR_GSM_EFR_SID
@ AMR_GSM_EFR_SID
Definition: codec.h:43
GSM610_XMAXC_LEN
#define GSM610_XMAXC_LEN
Definition: ecu_fr.c:36