libosmocodec  1.4.0
Osmocom codec library
ecu_fr.c File Reference
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <osmocom/core/bitvec.h>
#include <osmocom/codec/gsm610_bits.h>
#include <osmocom/codec/codec.h>
#include <osmocom/codec/ecu.h>

Macros

#define GSM610_XMAXC_REDUCE   4
 
#define GSM610_XMAXC_LEN   6
 

Functions

static bool reduce_xmaxcr (struct bitvec *frame_bitvec, const unsigned int index)
 Reduce the XMAXC field. More...
 
static bool reduce_xmaxcr_all (struct bitvec *frame_bitvec)
 Reduce all XMAXC fields in the frame. More...
 
static int conceal_frame (uint8_t *frame)
 
void osmo_ecu_fr_reset (struct osmo_ecu_fr_state *state, const uint8_t *frame)
 To be called when a good frame is received. More...
 
int osmo_ecu_fr_conceal (struct osmo_ecu_fr_state *state, uint8_t *frame)
 To be called when a bad frame is received. More...
 
static struct osmo_ecu_stateecu_fr_init (void *ctx, enum osmo_ecu_codec codec)
 
static int ecu_fr_frame_in (struct osmo_ecu_state *st, bool bfi, const uint8_t *frame, unsigned int frame_bytes)
 
static int ecu_fr_frame_out (struct osmo_ecu_state *st, uint8_t *frame_out)
 
static __attribute__ ((constructor))
 

Variables

static const struct osmo_ecu_ops osmo_ecu_ops_fr
 

Macro Definition Documentation

◆ GSM610_XMAXC_LEN

#define GSM610_XMAXC_LEN   6

◆ GSM610_XMAXC_REDUCE

#define GSM610_XMAXC_REDUCE   4

Function Documentation

◆ __attribute__()

static __attribute__ ( (constructor)  )
static

◆ conceal_frame()

static int conceal_frame ( uint8_t *  frame)
static

◆ 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 
)
static

◆ ecu_fr_frame_out()

static int ecu_fr_frame_out ( struct osmo_ecu_state st,
uint8_t *  frame_out 
)
static

◆ ecu_fr_init()

static struct osmo_ecu_state* ecu_fr_init ( void *  ctx,
enum osmo_ecu_codec  codec 
)
static

◆ 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.

This function will then generate a replacement frame that can be used to conceal the dropout.

Parameters
[in]stateThe state object for the ECU
[out]frameThe buffer to fill with GSM_FR_BYTES of replacement frame
Returns
0 if the frame was sucessfully filled

References conceal_frame(), osmo_ecu_fr_state::frame_backup, GSM_FR_BYTES, and osmo_ecu_fr_state::subsequent_lost_frame.

◆ 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.

This function will then create a backup of the frame and reset the internal state.

Parameters
[in]stateThe state object for the ECU
[out]frameThe valid frame (GSM_FR_BYTES bytes in RTP payload format)

References osmo_ecu_fr_state::frame_backup, GSM_FR_BYTES, and osmo_ecu_fr_state::subsequent_lost_frame.

Referenced by ecu_fr_frame_in().

◆ reduce_xmaxcr()

static bool reduce_xmaxcr ( struct bitvec frame_bitvec,
const unsigned int  index 
)
static

Reduce the XMAXC field.

When the XMAXC field reaches zero the function will return true.

References bitvec_read_field(), bitvec_write_field(), GSM610_XMAXC_LEN, and GSM610_XMAXC_REDUCE.

Referenced by reduce_xmaxcr_all().

◆ reduce_xmaxcr_all()

static bool reduce_xmaxcr_all ( struct bitvec frame_bitvec)
static

Reduce all XMAXC fields in the frame.

When all XMAXC fields reach zero, then the function will return true.

References GSM610_RTP_XMAXC00, GSM610_RTP_XMAXC10, GSM610_RTP_XMAXC20, GSM610_RTP_XMAXC30, and reduce_xmaxcr().

Referenced by conceal_frame().

Variable Documentation

◆ osmo_ecu_ops_fr

const struct osmo_ecu_ops osmo_ecu_ops_fr
static
Initial value:
= {
.init = ecu_fr_init,
.frame_in = ecu_fr_frame_in,
.frame_out = ecu_fr_frame_out,
}

Referenced by __attribute__().

ecu_fr_init
static struct osmo_ecu_state * ecu_fr_init(void *ctx, enum osmo_ecu_codec codec)
Definition: ecu_fr.c:172
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:187
ecu_fr_frame_out
static int ecu_fr_frame_out(struct osmo_ecu_state *st, uint8_t *frame_out)
Definition: ecu_fr.c:198