libosmocodec
1.4.0
Osmocom codec library
|
#include <stdint.h>
#include <stdbool.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/bits.h>
Go to the source code of this file.
|
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
} |
|
|
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...
|
|
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...
|
|
◆ GSM_EFR_BYTES
◆ GSM_FR_BYTES
◆ GSM_HR_BYTES
◆ 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_amr_d_to_s()
◆ osmo_amr_is_speech()
◆ 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, AMR_SID, ENOTSUP, and type.
◆ osmo_amr_rtp_enc()
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, and ENOTSUP.
◆ osmo_amr_s_to_d()
◆ osmo_fr_check_sid()
bool osmo_fr_check_sid |
( |
const uint8_t * |
rtp_payload, |
|
|
size_t |
payload_len |
|
) |
| |
◆ osmo_hr_check_sid()
bool osmo_hr_check_sid |
( |
const uint8_t * |
rtp_payload, |
|
|
size_t |
payload_len |
|
) |
| |
◆ gsm610_bitorder
const uint16_t gsm610_bitorder[] |
|
extern |
◆ gsm620_unvoiced_bitorder
const uint16_t gsm620_unvoiced_bitorder[] |
|
extern |
◆ gsm620_voiced_bitorder
const uint16_t gsm620_voiced_bitorder[] |
|
extern |
◆ gsm660_bitorder
const uint16_t gsm660_bitorder[] |
|
extern |
◆ gsm690_10_2_bitorder
const uint16_t gsm690_10_2_bitorder[] |
|
extern |
◆ gsm690_12_2_bitorder
const uint16_t gsm690_12_2_bitorder[] |
|
extern |
◆ gsm690_4_75_bitorder
const uint16_t gsm690_4_75_bitorder[] |
|
extern |
◆ gsm690_5_15_bitorder
const uint16_t gsm690_5_15_bitorder[] |
|
extern |
◆ gsm690_5_9_bitorder
const uint16_t gsm690_5_9_bitorder[] |
|
extern |
◆ gsm690_6_7_bitorder
const uint16_t gsm690_6_7_bitorder[] |
|
extern |
◆ gsm690_7_4_bitorder
const uint16_t gsm690_7_4_bitorder[] |
|
extern |
◆ gsm690_7_95_bitorder
const uint16_t gsm690_7_95_bitorder[] |
|
extern |
◆ gsm690_bitlength
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
@ AMR_12_2
Definition: codec.h:42
uint64_t bitvec_read_field(struct bitvec *bv, unsigned int *read_index, unsigned int len)
const uint16_t gsm690_5_15_bitorder[103]
Definition: gsm690.c:190
bool subsequent_lost_frame
Definition: ecu.h:11
static bool reduce_xmaxcr_all(struct bitvec *frame_bitvec)
Reduce all XMAXC fields in the frame.
Definition: ecu_fr.c:65
@ AMR_SID
Definition: codec.h:43
#define GSM_FR_BYTES
Definition: codec.h:12
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:94
const uint16_t gsm690_7_4_bitorder[148]
Definition: gsm690.c:128
static uint16_t mask(const uint8_t msb)
Definition: gsm620.c:271
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:282
const uint16_t gsm690_7_95_bitorder[159]
Definition: gsm690.c:105
const uint16_t gsm620_voiced_bitorder[112]
Definition: gsm620.c:156
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
enum osmo_ecu_codec codec
Definition: ecu.h:48
const struct value_string osmo_amr_type_names[]
Definition: gsm690.c:334
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
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:364
static struct osmo_ecu_state * ecu_fr_init(void *ctx, enum osmo_ecu_codec codec)
Definition: ecu_fr.c:172
enum bit_value bitvec_get_bit_pos(const struct bitvec *bv, unsigned int bitnr)
osmo_amr_type
Definition: codec.h:34
static size_t len(const char *str)
unsigned int bitvec_pack(const struct bitvec *bv, uint8_t *buffer)
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
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:223
void bitvec_free(struct bitvec *bv)
void osmo_ecu_destroy(struct osmo_ecu_state *st)
destroy an ECU instance
Definition: ecu.c:62
uint8_t frame_backup[GSM_FR_BYTES]
Definition: ecu.h:12
const uint16_t gsm690_6_7_bitorder[134]
Definition: gsm690.c:150
uint8_t data[0]
Definition: ecu.h:49
static bool reduce_xmaxcr(struct bitvec *frame_bitvec, const unsigned int index)
Reduce the XMAXC field.
Definition: ecu_fr.c:42
const uint16_t gsm690_10_2_bitorder[204]
Definition: gsm690.c:77
@ GSM610_RTP_XMAXC00
Definition: gsm610_bits.h:59
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
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:80
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:108
@ AMR_7_95
Definition: codec.h:40
static const struct osmo_ecu_ops * g_ecu_ops[_NUM_OSMO_ECU_CODECS]
Definition: ecu.c:43
static int conceal_frame(uint8_t *frame)
Definition: ecu_fr.c:78
@ AMR_NO_DATA
Definition: codec.h:47
@ AMR_4_75
Definition: codec.h:35
@ AMR_PDC_EFR_SID
Definition: codec.h:46
@ GSM610_RTP_XMAXC30
Definition: gsm610_bits.h:227
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:412
const uint16_t gsm620_unvoiced_bitorder[112]
Definition: gsm620.c:37
@ AMR_5_15
Definition: codec.h:36
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.c:133
const uint16_t gsm690_5_9_bitorder[118]
Definition: gsm690.c:171
const uint16_t gsm690_4_75_bitorder[95]
Definition: gsm690.c:208
#define GSM610_XMAXC_REDUCE
Definition: ecu_fr.c:35
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:147
@ AMR_6_70
Definition: codec.h:38
static __attribute__((constructor))
Definition: ecu_fr.c:214
if(vty->type==VTY_SHELL_SERV)
int bitvec_write_field(struct bitvec *bv, unsigned int *write_index, uint64_t val, unsigned int len)
struct bitvec * bitvec_alloc(unsigned int size, TALLOC_CTX *ctx)
void(* destroy)(struct osmo_ecu_state *)
Definition: ecu.h:67
struct osmo_ecu_state *(* init)(void *ctx, enum osmo_ecu_codec codec)
Definition: ecu.h:66
@ AMR_7_40
Definition: codec.h:39
const uint16_t gsm690_12_2_bitorder[244]
Definition: gsm690.c:45
uint8_t len
size of table
Definition: gsm690.c:239
@ AMR_5_90
Definition: codec.h:37
const uint16_t * s_to_d
Table as per TS 26.101 Annex B to compute d-bits from s-bits.
Definition: gsm690.c:237
const uint16_t gsm660_bitorder[260]
Definition: gsm660.c:38
osmo_ecu_codec
Definition: ecu.h:20
enum osmo_sub_auth_type type
@ GSM610_RTP_XMAXC20
Definition: gsm610_bits.h:171
static const uint8_t amr_len_by_ft[16]
Definition: gsm690.c:330
@ AMR_TDMA_EFR_SID
Definition: codec.h:45
int(* frame_in)(struct osmo_ecu_state *st, bool bfi, const uint8_t *frame, unsigned int frame_bytes)
Definition: ecu.h:68
@ GSM610_RTP_XMAXC10
Definition: gsm610_bits.h:115
static const struct ts26101_reorder_table ts26101_reorder_tables[8]
Definition: gsm690.c:242
struct osmo_ecu_state * osmo_ecu_init(void *ctx, enum osmo_ecu_codec codec)
initialize an ECU instance for given codec.
Definition: ecu.c:52
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:108
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:187
static int ecu_fr_frame_out(struct osmo_ecu_state *st, uint8_t *frame_out)
Definition: ecu_fr.c:198
int(* frame_out)(struct osmo_ecu_state *st, uint8_t *frame_out)
Definition: ecu.h:70
int bitvec_get_uint(struct bitvec *bv, unsigned int num_bits)
@ AMR_10_2
Definition: codec.h:41
osmo_amr_quality
Definition: codec.h:50
static const struct osmo_ecu_ops osmo_ecu_ops_fr
Definition: ecu_fr.c:208
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:308
@ OSMO_ECU_CODEC_FR
Definition: ecu.h:22
const uint16_t gsm610_bitorder[260]
Definition: gsm610.c:40
@ AMR_GSM_EFR_SID
Definition: codec.h:44
#define GSM610_XMAXC_LEN
Definition: ecu_fr.c:36
@ _NUM_OSMO_ECU_CODECS
Definition: ecu.h:25
unsigned int bitvec_unpack(struct bitvec *bv, const uint8_t *buffer)