\doxysection{twjit.\+h}
\label{twjit_8h_source}\index{include/osmocom/netif/twjit.h@{include/osmocom/netif/twjit.h}}

\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{comment}{/*}}
\DoxyCodeLine{2 \textcolor{comment}{ * Themyscira Wireless RTP jitter buffer implementation:}}
\DoxyCodeLine{3 \textcolor{comment}{ * public API definition for Osmocom-\/integrated version.}}
\DoxyCodeLine{4 \textcolor{comment}{ *}}
\DoxyCodeLine{5 \textcolor{comment}{ * This code was contributed to Osmocom Cellular Network Infrastructure}}
\DoxyCodeLine{6 \textcolor{comment}{ * project by Mother Mychaela N. Falconia of Themyscira Wireless.}}
\DoxyCodeLine{7 \textcolor{comment}{ * Mother Mychaela's contributions are NOT subject to copyright:}}
\DoxyCodeLine{8 \textcolor{comment}{ * no rights reserved, all rights relinquished.}}
\DoxyCodeLine{9 \textcolor{comment}{ */}}
\DoxyCodeLine{10 }
\DoxyCodeLine{11 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{12 }
\DoxyCodeLine{13 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{14 \textcolor{preprocessor}{\#include <stdbool.h>}}
\DoxyCodeLine{15 }
\DoxyCodeLine{16 \textcolor{preprocessor}{\#include <osmocom/core/msgb.h>}}
\DoxyCodeLine{17 }
\DoxyCodeLine{35 \textcolor{keyword}{struct }osmo\_twjit;}
\DoxyCodeLine{36 }
\DoxyCodeLine{48 \textcolor{keyword}{struct }osmo\_twjit\_config;}
\DoxyCodeLine{49 }
\DoxyCodeLine{59 \textcolor{keyword}{struct }osmo\_twjit\_stats \{}
\DoxyCodeLine{60         \textcolor{comment}{/* For ABI reasons, none of the following fields may be deleted}}
\DoxyCodeLine{61 \textcolor{comment}{         * or reordered! */}}
\DoxyCodeLine{62 }
\DoxyCodeLine{63         \textcolor{comment}{/* normal operation */}}
\DoxyCodeLine{64         uint32\_t rx\_packets;}
\DoxyCodeLine{65         uint32\_t delivered\_pkt;}
\DoxyCodeLine{66         uint32\_t handovers\_in;}
\DoxyCodeLine{67         uint32\_t handovers\_out;}
\DoxyCodeLine{68         uint32\_t marker\_resets;}
\DoxyCodeLine{69         \textcolor{comment}{/* undesirable, but not totally unexpected */}}
\DoxyCodeLine{70         uint32\_t too\_old;}
\DoxyCodeLine{71         uint32\_t underruns;}
\DoxyCodeLine{72         uint32\_t ho\_underruns;}
\DoxyCodeLine{73         uint32\_t output\_gaps;}
\DoxyCodeLine{74         uint32\_t thinning\_drops;}
\DoxyCodeLine{75         \textcolor{comment}{/* unusual error events */}}
\DoxyCodeLine{76         uint32\_t bad\_packets;}
\DoxyCodeLine{77         uint32\_t duplicate\_ts;}
\DoxyCodeLine{78         \textcolor{comment}{/* independent analysis of Rx packet stream */}}
\DoxyCodeLine{79         uint32\_t ssrc\_changes;}
\DoxyCodeLine{80         uint32\_t seq\_skips;}
\DoxyCodeLine{81         uint32\_t seq\_backwards;}
\DoxyCodeLine{82         uint32\_t seq\_repeats;}
\DoxyCodeLine{83         uint32\_t intentional\_gaps;}
\DoxyCodeLine{84         uint32\_t ts\_resets;}
\DoxyCodeLine{85         uint32\_t jitter\_max;}
\DoxyCodeLine{86         \textcolor{comment}{/* new counters added after first osmo\_twjit ABI freeze */}}
\DoxyCodeLine{87         uint32\_t soft\_underruns;}
\DoxyCodeLine{88 }
\DoxyCodeLine{89         \textcolor{comment}{/* New fields may be added here at the end; once added, they become}}
\DoxyCodeLine{90 \textcolor{comment}{         * permanent like the initially defined ones. */}}
\DoxyCodeLine{91 \};}
\DoxyCodeLine{92 }
\DoxyCodeLine{103 \textcolor{keyword}{struct }osmo\_twjit\_rr\_info \{}
\DoxyCodeLine{104         \textcolor{comment}{/* For ABI reasons, none of the following fields may be deleted}}
\DoxyCodeLine{105 \textcolor{comment}{         * or reordered! */}}
\DoxyCodeLine{106 }
\DoxyCodeLine{108         uint32\_t ssrc;}
\DoxyCodeLine{110         uint32\_t rx\_packets;}
\DoxyCodeLine{112         uint32\_t base\_seq;}
\DoxyCodeLine{114         uint32\_t max\_seq\_ext;}
\DoxyCodeLine{116         uint32\_t expected\_pkt;}
\DoxyCodeLine{120         uint32\_t jitter\_accum;}
\DoxyCodeLine{121         \textcolor{comment}{/* New fields may be added here at the end; once added, they become}}
\DoxyCodeLine{122 \textcolor{comment}{         * permanent like the initially defined ones. */}}
\DoxyCodeLine{123 \};}
\DoxyCodeLine{124 }
\DoxyCodeLine{125 \textcolor{comment}{/* twjit API: managing configuration structures */}}
\DoxyCodeLine{126 }
\DoxyCodeLine{127 \textcolor{keyword}{struct }osmo\_twjit\_config *osmo\_twjit\_config\_alloc(\textcolor{keywordtype}{void} *ctx);}
\DoxyCodeLine{128 \textcolor{keywordtype}{void} osmo\_twjit\_config\_free(\textcolor{keyword}{struct} osmo\_twjit\_config *conf);}
\DoxyCodeLine{129 }
\DoxyCodeLine{130 \textcolor{keywordtype}{int} osmo\_twjit\_config\_set\_buffer\_depth(\textcolor{keyword}{struct} osmo\_twjit\_config *conf,}
\DoxyCodeLine{131                                         uint16\_t bd\_start, uint16\_t bd\_hiwat);}
\DoxyCodeLine{132 \textcolor{keywordtype}{int} osmo\_twjit\_config\_set\_thinning\_int(\textcolor{keyword}{struct} osmo\_twjit\_config *conf,}
\DoxyCodeLine{133                                         uint16\_t thinning\_int);}
\DoxyCodeLine{134 \textcolor{keywordtype}{int} osmo\_twjit\_config\_set\_max\_future\_sec(\textcolor{keyword}{struct} osmo\_twjit\_config *conf,}
\DoxyCodeLine{135                                          uint16\_t max\_future\_sec);}
\DoxyCodeLine{136 \textcolor{keywordtype}{int} osmo\_twjit\_config\_set\_start\_min\_delta(\textcolor{keyword}{struct} osmo\_twjit\_config *conf,}
\DoxyCodeLine{137                                           uint16\_t delta\_ms);}
\DoxyCodeLine{138 \textcolor{keywordtype}{int} osmo\_twjit\_config\_set\_start\_max\_delta(\textcolor{keyword}{struct} osmo\_twjit\_config *conf,}
\DoxyCodeLine{139                                           uint16\_t delta\_ms);}
\DoxyCodeLine{140 \textcolor{keywordtype}{int} osmo\_twjit\_config\_set\_underrun\_ext(\textcolor{keyword}{struct} osmo\_twjit\_config *conf,}
\DoxyCodeLine{141                                         uint16\_t underrun\_ext);}
\DoxyCodeLine{142 \textcolor{keywordtype}{int} osmo\_twjit\_config\_set\_handover\_on\_marker(\textcolor{keyword}{struct} osmo\_twjit\_config *conf,}
\DoxyCodeLine{143                                              \textcolor{keywordtype}{bool} hom);}
\DoxyCodeLine{144 }
\DoxyCodeLine{145 \textcolor{comment}{/* twjit API: actual twjit instances */}}
\DoxyCodeLine{146 }
\DoxyCodeLine{147 \textcolor{keyword}{struct }osmo\_twjit *osmo\_twjit\_create(\textcolor{keywordtype}{void} *ctx, uint16\_t clock\_khz,}
\DoxyCodeLine{148                                      uint16\_t quantum\_ms,}
\DoxyCodeLine{149                                      \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_twjit\_config *config);}
\DoxyCodeLine{150 \textcolor{keywordtype}{void} osmo\_twjit\_destroy(\textcolor{keyword}{struct} osmo\_twjit *twjit);}
\DoxyCodeLine{151 }
\DoxyCodeLine{152 \textcolor{keywordtype}{int} osmo\_twjit\_set\_config(\textcolor{keyword}{struct} osmo\_twjit *twjit,}
\DoxyCodeLine{153                           \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_twjit\_config *config);}
\DoxyCodeLine{154 \textcolor{keywordtype}{void} osmo\_twjit\_reset(\textcolor{keyword}{struct} osmo\_twjit *twjit);}
\DoxyCodeLine{155 }
\DoxyCodeLine{156 \textcolor{comment}{/* RTP input, takes ownership of msgb */}}
\DoxyCodeLine{157 \textcolor{keywordtype}{void} osmo\_twjit\_input(\textcolor{keyword}{struct} osmo\_twjit *twjit, \textcolor{keyword}{struct} msgb *msg);}
\DoxyCodeLine{158 }
\DoxyCodeLine{159 \textcolor{comment}{/* output function, to be called by TDM/GSM/etc fixed-\/timing side */}}
\DoxyCodeLine{160 \textcolor{keyword}{struct }msgb *osmo\_twjit\_output(\textcolor{keyword}{struct} osmo\_twjit *twjit);}
\DoxyCodeLine{161 }
\DoxyCodeLine{162 \textcolor{comment}{/* Stats and RR info structures are contained inside opaque struct osmo\_twjit.}}
\DoxyCodeLine{163 \textcolor{comment}{ * We need to provide access to these stats and RR info structures to API}}
\DoxyCodeLine{164 \textcolor{comment}{ * users, but we don't want to make the whole twjit instance struct public.}}
\DoxyCodeLine{165 \textcolor{comment}{ * Also we would like to have fast external access to these stats, hence an API}}
\DoxyCodeLine{166 \textcolor{comment}{ * that copies our stats to caller-\/provided storage would be very inefficient.}}
\DoxyCodeLine{167 \textcolor{comment}{ * Compromise: we allow direct external access to just these selected parts}}
\DoxyCodeLine{168 \textcolor{comment}{ * of the full internal state structure by providing API functions that}}
\DoxyCodeLine{169 \textcolor{comment}{ * return pointers to these selected parts.}}
\DoxyCodeLine{170 \textcolor{comment}{ */}}
\DoxyCodeLine{171 \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_twjit\_stats *}
\DoxyCodeLine{172 osmo\_twjit\_get\_stats(\textcolor{keyword}{struct} osmo\_twjit *twjit);}
\DoxyCodeLine{173 }
\DoxyCodeLine{174 \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_twjit\_rr\_info *}
\DoxyCodeLine{175 osmo\_twjit\_get\_rr\_info(\textcolor{keyword}{struct} osmo\_twjit *twjit);}
\DoxyCodeLine{176 }
\DoxyCodeLine{177 \textcolor{comment}{/* When we compose outgoing RTCP packets in the upper layer of twrtp,}}
\DoxyCodeLine{178 \textcolor{comment}{ * we need to know whether or not we have received at least one valid}}
\DoxyCodeLine{179 \textcolor{comment}{ * RTP data packet so far.  If we haven't received any RTP yet, then}}
\DoxyCodeLine{180 \textcolor{comment}{ * we have no Rx SSRC, all data in struct osmo\_twjit\_rr\_info are invalid,}}
\DoxyCodeLine{181 \textcolor{comment}{ * and we cannot send RTCP reception reports.}}
\DoxyCodeLine{182 \textcolor{comment}{ */}}
\DoxyCodeLine{183 \textcolor{keywordtype}{bool} osmo\_twjit\_rr\_info\_valid(\textcolor{keyword}{struct} osmo\_twjit *twjit);}
\DoxyCodeLine{184 }
\DoxyCodeLine{185 \textcolor{comment}{/* vty configuration functions */}}
\DoxyCodeLine{186 }
\DoxyCodeLine{187 \textcolor{keywordtype}{void} osmo\_twjit\_vty\_init(\textcolor{keywordtype}{int} twjit\_node);}
\DoxyCodeLine{188 }
\DoxyCodeLine{189 \textcolor{keyword}{struct }vty;}
\DoxyCodeLine{190 }
\DoxyCodeLine{191 \textcolor{keywordtype}{int} osmo\_twjit\_config\_write(\textcolor{keyword}{struct} vty *vty,}
\DoxyCodeLine{192                             \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_twjit\_config *conf,}
\DoxyCodeLine{193                             \textcolor{keyword}{const} \textcolor{keywordtype}{char} *prefix);}
\DoxyCodeLine{194 }

\end{DoxyCode}
