diff options
author | Harald Welte <laforge@gnumonks.org> | 2019-08-01 20:05:05 +0200 |
---|---|---|
committer | laforge <laforge@gnumonks.org> | 2019-09-02 09:13:50 +0000 |
commit | 750d8311f5c0455f2caaa2ae9dba2cc99300c9dd (patch) | |
tree | aebab66fccee63d0b6da29e23ca3944d0d80c2e9 /include | |
parent | 766f77c3d9b479b49e6e2bc2b105ceb4889304d3 (diff) |
codec/ecu: Introduce new generic Error Concealment Unit abstraction
We don't want to expose the details of a given ECU implementation to
the user (e.g. osmo-bts), but have a generic abstraction layer where
an ECU implementation can simply register a few call-back functions
with the generic core.
As the developer and copyright holder of the related code, I hereby
state that any ECU implementation using 'struct osmo_ecu_ops' and
registering with the 'osmo_ecu_register()' function shall not be
considered as a derivative work under any applicable copyright law;
the copyleft terms of GPLv2 shall hence not apply to any such ECU
implementation.
The intent of the above exception is to allow anyone to combine
third party Error Concealment Unit implementations with libosmocore,
including but not limited to such published by ETSI.
Change-Id: I4d33c9c7c2d4c7462ff38a49c178b65accae1915
Diffstat (limited to 'include')
-rw-r--r-- | include/osmocom/codec/ecu.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/include/osmocom/codec/ecu.h b/include/osmocom/codec/ecu.h index ec0a2f8d..ec946702 100644 --- a/include/osmocom/codec/ecu.h +++ b/include/osmocom/codec/ecu.h @@ -13,3 +13,57 @@ struct osmo_ecu_fr_state { void osmo_ecu_fr_reset(struct osmo_ecu_fr_state *state, const uint8_t *frame); int osmo_ecu_fr_conceal(struct osmo_ecu_fr_state *state, uint8_t *frame); + +enum osmo_ecu_codec { + OSMO_ECU_CODEC_HR, + OSMO_ECU_CODEC_FR, + OSMO_ECU_CODEC_EFR, + OSMO_ECU_CODEC_AMR, + _NUM_OSMO_ECU_CODECS +}; + +/*********************************************************************** + * Generic ECU abstraction layer below + ***********************************************************************/ + +/* As the developer and copyright holder of the related code, I hereby + * state that any ECU implementation using 'struct osmo_ecu_ops' and + * registering with the 'osmo_ecu_register()' function shall not be + * considered as a derivative work under any applicable copyright law; + * the copyleft terms of GPLv2 shall hence not apply to any such ECU + * implementation. + * + * The intent of the above exception is to allow anyone to combine third + * party Error Concealment Unit implementations with libosmocodec. + * including but not limited to such published by ETSI. + * + * -- Harald Welte <laforge@gnumonks.org> on August 1, 2019. + */ + +struct osmo_ecu_state { + enum osmo_ecu_codec codec; + uint8_t data[0]; +}; + +/* initialize an ECU instance */ +struct osmo_ecu_state *osmo_ecu_init(void *ctx, enum osmo_ecu_codec codec); + +/* destroy an ECU instance */ +void osmo_ecu_destroy(struct osmo_ecu_state *st); + +/* process a received frame a substitute/erroneous frame */ +int osmo_ecu_frame_in(struct osmo_ecu_state *st, bool bfi, + const uint8_t *frame, unsigned int frame_bytes); + +/* generate output data for a substitute/erroneous frame */ +int osmo_ecu_frame_out(struct osmo_ecu_state *st, uint8_t *frame_out); + +struct osmo_ecu_ops { + struct osmo_ecu_state * (*init)(void *ctx, enum osmo_ecu_codec codec); + void (*destroy)(struct osmo_ecu_state *); + int (*frame_in)(struct osmo_ecu_state *st, bool bfi, + const uint8_t *frame, unsigned int frame_bytes); + int (*frame_out)(struct osmo_ecu_state *st, uint8_t *frame_out); +}; + +int osmo_ecu_register(const struct osmo_ecu_ops *ops, enum osmo_ecu_codec codec); |