\doxysection{ecu.\+h}
\label{ecu_8h_source}\index{include/osmocom/codec/ecu.h@{include/osmocom/codec/ecu.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{2 }
\DoxyCodeLine{3 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{4 \textcolor{preprocessor}{\#include <stdbool.h>}}
\DoxyCodeLine{5 }
\DoxyCodeLine{6 \textcolor{preprocessor}{\#include <osmocom/core/defs.h>}}
\DoxyCodeLine{7 \textcolor{preprocessor}{\#include <osmocom/codec/codec.h>}}
\DoxyCodeLine{8 }
\DoxyCodeLine{9 \textcolor{comment}{/* ECU state for GSM-\/FR -\/ deprecated version only! */}}
\DoxyCodeLine{10 \textcolor{keyword}{struct }osmo\_ecu\_fr\_state \{}
\DoxyCodeLine{11         \textcolor{keywordtype}{bool} subsequent\_lost\_frame;}
\DoxyCodeLine{12         uint8\_t frame\_backup[GSM\_FR\_BYTES];}
\DoxyCodeLine{13 \};}
\DoxyCodeLine{14 }
\DoxyCodeLine{15 \textcolor{keywordtype}{void} osmo\_ecu\_fr\_reset(\textcolor{keyword}{struct} osmo\_ecu\_fr\_state *state, \textcolor{keyword}{const} uint8\_t *frame)}
\DoxyCodeLine{16         OSMO\_DEPRECATED\_OUTSIDE(\textcolor{stringliteral}{"{}Use generic ECU abstraction layer instead"{}});}
\DoxyCodeLine{17 \textcolor{keywordtype}{int} osmo\_ecu\_fr\_conceal(\textcolor{keyword}{struct} osmo\_ecu\_fr\_state *state, uint8\_t *frame)}
\DoxyCodeLine{18         OSMO\_DEPRECATED\_OUTSIDE(\textcolor{stringliteral}{"{}Use generic ECU abstraction layer instead"{}});}
\DoxyCodeLine{19 }
\DoxyCodeLine{20 \textcolor{keyword}{enum} osmo\_ecu\_codec \{}
\DoxyCodeLine{21         OSMO\_ECU\_CODEC\_HR,}
\DoxyCodeLine{22         OSMO\_ECU\_CODEC\_FR,}
\DoxyCodeLine{23         OSMO\_ECU\_CODEC\_EFR,}
\DoxyCodeLine{24         OSMO\_ECU\_CODEC\_AMR,}
\DoxyCodeLine{25         \_NUM\_OSMO\_ECU\_CODECS}
\DoxyCodeLine{26 \};}
\DoxyCodeLine{27 }
\DoxyCodeLine{28 \textcolor{comment}{/***********************************************************************}}
\DoxyCodeLine{29 \textcolor{comment}{ * Generic ECU abstraction layer below}}
\DoxyCodeLine{30 \textcolor{comment}{ ***********************************************************************/}}
\DoxyCodeLine{31 }
\DoxyCodeLine{32 \textcolor{comment}{/* As the developer and copyright holder of the related code, I hereby}}
\DoxyCodeLine{33 \textcolor{comment}{ * state that any ECU implementation using 'struct osmo\_ecu\_ops' and}}
\DoxyCodeLine{34 \textcolor{comment}{ * registering with the 'osmo\_ecu\_register()' function shall not be}}
\DoxyCodeLine{35 \textcolor{comment}{ * considered as a derivative work under any applicable copyright law;}}
\DoxyCodeLine{36 \textcolor{comment}{ * the copyleft terms of GPLv2 shall hence not apply to any such ECU}}
\DoxyCodeLine{37 \textcolor{comment}{ * implementation.}}
\DoxyCodeLine{38 \textcolor{comment}{ *}}
\DoxyCodeLine{39 \textcolor{comment}{ * The intent of the above exception is to allow anyone to combine third}}
\DoxyCodeLine{40 \textcolor{comment}{ * party Error Concealment Unit implementations with libosmocodec.}}
\DoxyCodeLine{41 \textcolor{comment}{ * including but not limited to such published by ETSI.}}
\DoxyCodeLine{42 \textcolor{comment}{ *}}
\DoxyCodeLine{43 \textcolor{comment}{ *   -\/-\/ Harald Welte <laforge@gnumonks.org> on August 1, 2019.}}
\DoxyCodeLine{44 \textcolor{comment}{ */}}
\DoxyCodeLine{45 }
\DoxyCodeLine{46 \textcolor{comment}{/* Codec independent ECU state */}}
\DoxyCodeLine{47 \textcolor{keyword}{struct }osmo\_ecu\_state \{}
\DoxyCodeLine{48         \textcolor{keyword}{enum} osmo\_ecu\_codec codec;}
\DoxyCodeLine{49         uint8\_t data[0];}
\DoxyCodeLine{50 \};}
\DoxyCodeLine{51 }
\DoxyCodeLine{52 \textcolor{comment}{/* initialize an ECU instance */}}
\DoxyCodeLine{53 \textcolor{keyword}{struct }osmo\_ecu\_state *osmo\_ecu\_init(\textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{enum} osmo\_ecu\_codec codec);}
\DoxyCodeLine{54 }
\DoxyCodeLine{55 \textcolor{comment}{/* destroy an ECU instance */}}
\DoxyCodeLine{56 \textcolor{keywordtype}{void} osmo\_ecu\_destroy(\textcolor{keyword}{struct} osmo\_ecu\_state *st);}
\DoxyCodeLine{57 }
\DoxyCodeLine{58 \textcolor{comment}{/* process a received frame a substitute/erroneous frame */}}
\DoxyCodeLine{59 \textcolor{keywordtype}{int} osmo\_ecu\_frame\_in(\textcolor{keyword}{struct} osmo\_ecu\_state *st, \textcolor{keywordtype}{bool} bfi,}
\DoxyCodeLine{60                       \textcolor{keyword}{const} uint8\_t *frame, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} frame\_bytes);}
\DoxyCodeLine{61 }
\DoxyCodeLine{62 \textcolor{comment}{/* generate output data for a substitute/erroneous frame */}}
\DoxyCodeLine{63 \textcolor{keywordtype}{int} osmo\_ecu\_frame\_out(\textcolor{keyword}{struct} osmo\_ecu\_state *st, uint8\_t *frame\_out);}
\DoxyCodeLine{64 }
\DoxyCodeLine{65 \textcolor{comment}{/* is the stream handled by this ECU currently in a DTX pause? */}}
\DoxyCodeLine{66 \textcolor{keywordtype}{bool} osmo\_ecu\_is\_dtx\_pause(\textcolor{keyword}{struct} osmo\_ecu\_state *st);}
\DoxyCodeLine{67 }
\DoxyCodeLine{68 \textcolor{keyword}{struct }osmo\_ecu\_ops \{}
\DoxyCodeLine{69         \textcolor{keyword}{struct }osmo\_ecu\_state * (*init)(\textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{enum} osmo\_ecu\_codec codec);}
\DoxyCodeLine{70         void (*destroy)(\textcolor{keyword}{struct }osmo\_ecu\_state *);}
\DoxyCodeLine{71         int (*frame\_in)(\textcolor{keyword}{struct }osmo\_ecu\_state *st, \textcolor{keywordtype}{bool} bfi,}
\DoxyCodeLine{72                         \textcolor{keyword}{const} uint8\_t *frame, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} frame\_bytes);}
\DoxyCodeLine{73         int (*frame\_out)(\textcolor{keyword}{struct }osmo\_ecu\_state *st, uint8\_t *frame\_out);}
\DoxyCodeLine{74         bool (*is\_dtx\_pause)(\textcolor{keyword}{struct }osmo\_ecu\_state *st);}
\DoxyCodeLine{75 \};}
\DoxyCodeLine{76 }
\DoxyCodeLine{77 \textcolor{keywordtype}{int} osmo\_ecu\_register(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ecu\_ops *ops, \textcolor{keyword}{enum} osmo\_ecu\_codec codec);}

\end{DoxyCode}
