libosmocodec
UNKNOWN
Osmocom codec library
Toggle main menu visibility
Loading...
Searching...
No Matches
ecu.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <stdint.h>
4
#include <stdbool.h>
5
6
#include <
osmocom/core/defs.h
>
7
#include <
osmocom/codec/codec.h
>
8
9
/* ECU state for GSM-FR - deprecated version only! */
10
struct
osmo_ecu_fr_state
{
11
bool
subsequent_lost_frame
;
12
uint8_t
frame_backup
[
GSM_FR_BYTES
];
13
};
14
15
void
osmo_ecu_fr_reset
(
struct
osmo_ecu_fr_state
*state,
const
uint8_t *frame)
16
OSMO_DEPRECATED_OUTSIDE
(
"Use generic ECU abstraction layer instead"
);
17
int
osmo_ecu_fr_conceal
(
struct
osmo_ecu_fr_state
*state, uint8_t *frame)
18
OSMO_DEPRECATED_OUTSIDE
(
"Use generic ECU abstraction layer instead"
);
19
20
enum
osmo_ecu_codec
{
21
OSMO_ECU_CODEC_HR
,
22
OSMO_ECU_CODEC_FR
,
23
OSMO_ECU_CODEC_EFR
,
24
OSMO_ECU_CODEC_AMR
,
25
_NUM_OSMO_ECU_CODECS
26
};
27
28
/***********************************************************************
29
* Generic ECU abstraction layer below
30
***********************************************************************/
31
32
/* As the developer and copyright holder of the related code, I hereby
33
* state that any ECU implementation using 'struct osmo_ecu_ops' and
34
* registering with the 'osmo_ecu_register()' function shall not be
35
* considered as a derivative work under any applicable copyright law;
36
* the copyleft terms of GPLv2 shall hence not apply to any such ECU
37
* implementation.
38
*
39
* The intent of the above exception is to allow anyone to combine third
40
* party Error Concealment Unit implementations with libosmocodec.
41
* including but not limited to such published by ETSI.
42
*
43
* -- Harald Welte <laforge@gnumonks.org> on August 1, 2019.
44
*/
45
46
/* Codec independent ECU state */
47
struct
osmo_ecu_state
{
48
enum
osmo_ecu_codec
codec
;
49
uint8_t
data
[0];
50
};
51
52
/* initialize an ECU instance */
53
struct
osmo_ecu_state
*
osmo_ecu_init
(
void
*ctx,
enum
osmo_ecu_codec
codec
);
54
55
/* destroy an ECU instance */
56
void
osmo_ecu_destroy
(
struct
osmo_ecu_state
*st);
57
58
/* process a received frame a substitute/erroneous frame */
59
int
osmo_ecu_frame_in
(
struct
osmo_ecu_state
*st,
bool
bfi,
60
const
uint8_t *frame,
unsigned
int
frame_bytes);
61
62
/* generate output data for a substitute/erroneous frame */
63
int
osmo_ecu_frame_out
(
struct
osmo_ecu_state
*st, uint8_t *frame_out);
64
65
/* is the stream handled by this ECU currently in a DTX pause? */
66
bool
osmo_ecu_is_dtx_pause
(
struct
osmo_ecu_state
*st);
67
68
struct
osmo_ecu_ops
{
69
struct
osmo_ecu_state
* (*init)(
void
*ctx,
enum
osmo_ecu_codec
codec);
70
void (*
destroy
)(
struct
osmo_ecu_state
*);
71
int (*
frame_in
)(
struct
osmo_ecu_state
*st,
bool
bfi,
72
const
uint8_t *frame,
unsigned
int
frame_bytes);
73
int (*
frame_out
)(
struct
osmo_ecu_state
*st, uint8_t *
frame_out
);
74
bool (*
is_dtx_pause
)(
struct
osmo_ecu_state
*st);
75
};
76
77
int
osmo_ecu_register
(
const
struct
osmo_ecu_ops
*ops,
enum
osmo_ecu_codec
codec
);
codec.h
GSM_FR_BYTES
#define GSM_FR_BYTES
Definition
codec.h:12
defs.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_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
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_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_fr_reset
void osmo_ecu_fr_reset(struct osmo_ecu_fr_state *state, const uint8_t *frame) OSMO_DEPRECATED_OUTSIDE("Use generic ECU override ion layer instead")
To be called when a good frame is received.
Definition
ecu_fr_old.c:133
osmo_ecu_codec
osmo_ecu_codec
Definition
ecu.h:20
OSMO_ECU_CODEC_FR
@ OSMO_ECU_CODEC_FR
Definition
ecu.h:22
OSMO_ECU_CODEC_HR
@ OSMO_ECU_CODEC_HR
Definition
ecu.h:21
_NUM_OSMO_ECU_CODECS
@ _NUM_OSMO_ECU_CODECS
Definition
ecu.h:25
OSMO_ECU_CODEC_EFR
@ OSMO_ECU_CODEC_EFR
Definition
ecu.h:23
OSMO_ECU_CODEC_AMR
@ OSMO_ECU_CODEC_AMR
Definition
ecu.h:24
osmo_ecu_fr_conceal
int osmo_ecu_fr_conceal(struct osmo_ecu_fr_state *state, uint8_t *frame) OSMO_DEPRECATED_OUTSIDE("Use generic ECU override ion layer instead")
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
osmo_ecu_destroy
void osmo_ecu_destroy(struct osmo_ecu_state *st)
destroy an ECU instance
Definition
ecu.c:58
OSMO_DEPRECATED_OUTSIDE
#define OSMO_DEPRECATED_OUTSIDE(text)
osmo_ecu_fr_state
Definition
ecu.h:10
osmo_ecu_fr_state::frame_backup
uint8_t frame_backup[GSM_FR_BYTES]
Definition
ecu.h:12
osmo_ecu_fr_state::subsequent_lost_frame
bool subsequent_lost_frame
Definition
ecu.h:11
osmo_ecu_ops
Definition
ecu.h:68
osmo_ecu_ops::frame_out
int(* frame_out)(struct osmo_ecu_state *st, uint8_t *frame_out)
Definition
ecu.h:73
osmo_ecu_ops::destroy
void(* destroy)(struct osmo_ecu_state *)
Definition
ecu.h:70
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
osmo_ecu_ops::is_dtx_pause
bool(* is_dtx_pause)(struct osmo_ecu_state *st)
Definition
ecu.h:74
osmo_ecu_state
Definition
ecu.h:47
osmo_ecu_state::codec
enum osmo_ecu_codec codec
Definition
ecu.h:48
osmo_ecu_state::data
uint8_t data[0]
Definition
ecu.h:49
include
osmocom
codec
ecu.h
Generated by
1.17.0