\doxysection{Osmocom Jitter Buffer}
\label{group__jibuf}\index{Osmocom Jitter Buffer@{Osmocom Jitter Buffer}}
\doxysubsection*{Files}
\begin{DoxyCompactItemize}
\item 
file \textbf{ jibuf.\+h}
\begin{DoxyCompactList}\small\item\em Osmocom Jitter Buffer helpers. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+jibuf}
\begin{DoxyCompactList}\small\item\em A structure representing a single instance of a jitter buffer. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{group__jibuf_ga78eb735a1f6c3dd8b6478ded3db60652}} 
typedef void($\ast$ {\bfseries osmo\+\_\+jibuf\+\_\+dequeue\+\_\+cb}) (struct msgb $\ast$msg, void $\ast$data)
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+jibuf} $\ast$ \textbf{ osmo\+\_\+jibuf\+\_\+alloc} (void $\ast$talloc\+\_\+ctx)
\begin{DoxyCompactList}\small\item\em Allocate a new jitter buffer instance. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+jibuf\+\_\+delete} (struct \textbf{ osmo\+\_\+jibuf} $\ast$jb)
\begin{DoxyCompactList}\small\item\em Destroy a previously allocated jitter buffer instance. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+jibuf\+\_\+enqueue} (struct \textbf{ osmo\+\_\+jibuf} $\ast$jb, struct msgb $\ast$msg)
\begin{DoxyCompactList}\small\item\em Try to enqueue a packet into the jitter buffer. \end{DoxyCompactList}\item 
bool \textbf{ osmo\+\_\+jibuf\+\_\+empty} (struct \textbf{ osmo\+\_\+jibuf} $\ast$jb)
\begin{DoxyCompactList}\small\item\em Check whether the jitter buffer instance has packets queued or not. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+jibuf\+\_\+set\+\_\+min\+\_\+delay} (struct \textbf{ osmo\+\_\+jibuf} $\ast$jb, uint32\+\_\+t min\+\_\+delay)
\begin{DoxyCompactList}\small\item\em Set minimum buffer size for the jitter buffer. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+jibuf\+\_\+set\+\_\+max\+\_\+delay} (struct \textbf{ osmo\+\_\+jibuf} $\ast$jb, uint32\+\_\+t max\+\_\+delay)
\begin{DoxyCompactList}\small\item\em Set maximum buffer size for the jitter buffer. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+jibuf\+\_\+enable\+\_\+skew\+\_\+compensation} (struct \textbf{ osmo\+\_\+jibuf} $\ast$jb, bool enable)
\begin{DoxyCompactList}\small\item\em Toggle use of skew detection and compensation mechanism. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+jibuf\+\_\+set\+\_\+dequeue\+\_\+cb} (struct \textbf{ osmo\+\_\+jibuf} $\ast$jb, osmo\+\_\+jibuf\+\_\+dequeue\+\_\+cb dequeue\+\_\+cb, void $\ast$cb\+\_\+data)
\begin{DoxyCompactList}\small\item\em Set dequeue callback for the jitter buffer. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}


\doxysubsection{Function Documentation}
\mbox{\label{group__jibuf_ga20592f230f9d1233752fd318996f2c9d}} 
\index{Osmocom Jitter Buffer@{Osmocom Jitter Buffer}!osmo\_jibuf\_alloc@{osmo\_jibuf\_alloc}}
\index{osmo\_jibuf\_alloc@{osmo\_jibuf\_alloc}!Osmocom Jitter Buffer@{Osmocom Jitter Buffer}}
\doxysubsubsection{osmo\_jibuf\_alloc()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+jibuf} $\ast$ osmo\+\_\+jibuf\+\_\+alloc (\begin{DoxyParamCaption}\item[{void $\ast$}]{talloc\+\_\+ctx }\end{DoxyParamCaption})}



Allocate a new jitter buffer instance. 

\begin{DoxyReturn}{Returns}
the new allocated instance 
\end{DoxyReturn}
\mbox{\label{group__jibuf_gacdac7beaf3d97543718ddfa33123fb7e}} 
\index{Osmocom Jitter Buffer@{Osmocom Jitter Buffer}!osmo\_jibuf\_delete@{osmo\_jibuf\_delete}}
\index{osmo\_jibuf\_delete@{osmo\_jibuf\_delete}!Osmocom Jitter Buffer@{Osmocom Jitter Buffer}}
\doxysubsubsection{osmo\_jibuf\_delete()}
{\footnotesize\ttfamily void osmo\+\_\+jibuf\+\_\+delete (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+jibuf} $\ast$}]{jb }\end{DoxyParamCaption})}



Destroy a previously allocated jitter buffer instance. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em jb} & Previously allocated (non-\/null) jitter buffer instance\\
\hline
\end{DoxyParams}
All the queued packets are dequeued before deleting the instance. \mbox{\label{group__jibuf_gae73a3b805b83f453339adeee9cdfaba4}} 
\index{Osmocom Jitter Buffer@{Osmocom Jitter Buffer}!osmo\_jibuf\_empty@{osmo\_jibuf\_empty}}
\index{osmo\_jibuf\_empty@{osmo\_jibuf\_empty}!Osmocom Jitter Buffer@{Osmocom Jitter Buffer}}
\doxysubsubsection{osmo\_jibuf\_empty()}
{\footnotesize\ttfamily bool osmo\+\_\+jibuf\+\_\+empty (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+jibuf} $\ast$}]{jb }\end{DoxyParamCaption})}



Check whether the jitter buffer instance has packets queued or not. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em jb} & jitter buffer instance \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if the queue is empty, false otherwise. 
\end{DoxyReturn}
\mbox{\label{group__jibuf_ga096e87b2dbdade72c35d51a51fe57839}} 
\index{Osmocom Jitter Buffer@{Osmocom Jitter Buffer}!osmo\_jibuf\_enable\_skew\_compensation@{osmo\_jibuf\_enable\_skew\_compensation}}
\index{osmo\_jibuf\_enable\_skew\_compensation@{osmo\_jibuf\_enable\_skew\_compensation}!Osmocom Jitter Buffer@{Osmocom Jitter Buffer}}
\doxysubsubsection{osmo\_jibuf\_enable\_skew\_compensation()}
{\footnotesize\ttfamily void osmo\+\_\+jibuf\+\_\+enable\+\_\+skew\+\_\+compensation (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+jibuf} $\ast$}]{jb,  }\item[{bool}]{enable }\end{DoxyParamCaption})}



Toggle use of skew detection and compensation mechanism. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em jb} & jitter buffer instance \\
\hline
\mbox{\texttt{ in}}  & {\em enable} & Whether to enable or not (default) the skew estimation and compensation mechanism\\
\hline
\end{DoxyParams}
When this function is called, the estimated skew is reset. \mbox{\label{group__jibuf_ga522165ddc51578436ae2d26691fa7ec0}} 
\index{Osmocom Jitter Buffer@{Osmocom Jitter Buffer}!osmo\_jibuf\_enqueue@{osmo\_jibuf\_enqueue}}
\index{osmo\_jibuf\_enqueue@{osmo\_jibuf\_enqueue}!Osmocom Jitter Buffer@{Osmocom Jitter Buffer}}
\doxysubsubsection{osmo\_jibuf\_enqueue()}
{\footnotesize\ttfamily int osmo\+\_\+jibuf\+\_\+enqueue (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+jibuf} $\ast$}]{jb,  }\item[{struct msgb $\ast$}]{msg }\end{DoxyParamCaption})}



Try to enqueue a packet into the jitter buffer. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em jb} & jitter buffer instance \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & msgb to enqueue, containing an RTP packet \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
$<$0 if the packet was dropped, 0 otherwise
\end{DoxyReturn}
This function calculates the delay for the enqueued packet. If the delay is bigger than the current buffer size, the function returns -\/1 and the caller owns the packet again and can free it if required. If the packet is enqueued, 0 is returned and the exact same packet (ownership transfer, no copy is made) will be available again through the dequeue\+\_\+cb() when the queue timer for this packet expires. \mbox{\label{group__jibuf_ga3a8213fe8bed42d649fcb1c8d13e23d8}} 
\index{Osmocom Jitter Buffer@{Osmocom Jitter Buffer}!osmo\_jibuf\_set\_dequeue\_cb@{osmo\_jibuf\_set\_dequeue\_cb}}
\index{osmo\_jibuf\_set\_dequeue\_cb@{osmo\_jibuf\_set\_dequeue\_cb}!Osmocom Jitter Buffer@{Osmocom Jitter Buffer}}
\doxysubsubsection{osmo\_jibuf\_set\_dequeue\_cb()}
{\footnotesize\ttfamily void osmo\+\_\+jibuf\+\_\+set\+\_\+dequeue\+\_\+cb (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+jibuf} $\ast$}]{jb,  }\item[{osmo\+\_\+jibuf\+\_\+dequeue\+\_\+cb}]{dequeue\+\_\+cb,  }\item[{void $\ast$}]{cb\+\_\+data }\end{DoxyParamCaption})}



Set dequeue callback for the jitter buffer. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em jb} & jitter buffer instance \\
\hline
\mbox{\texttt{ in}}  & {\em dequeue\+\_\+cb} & function pointer to call back when the dequeue timer for a given packet expires \\
\hline
\mbox{\texttt{ in}}  & {\em cb\+\_\+data} & data pointer to be passed to dequeue\+\_\+cb together with the msgb. \\
\hline
\end{DoxyParams}
\mbox{\label{group__jibuf_ga5e84571c3348525b6ad647a22cd2581d}} 
\index{Osmocom Jitter Buffer@{Osmocom Jitter Buffer}!osmo\_jibuf\_set\_max\_delay@{osmo\_jibuf\_set\_max\_delay}}
\index{osmo\_jibuf\_set\_max\_delay@{osmo\_jibuf\_set\_max\_delay}!Osmocom Jitter Buffer@{Osmocom Jitter Buffer}}
\doxysubsubsection{osmo\_jibuf\_set\_max\_delay()}
{\footnotesize\ttfamily void osmo\+\_\+jibuf\+\_\+set\+\_\+max\+\_\+delay (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+jibuf} $\ast$}]{jb,  }\item[{uint32\+\_\+t}]{max\+\_\+delay }\end{DoxyParamCaption})}



Set maximum buffer size for the jitter buffer. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em jb} & jitter buffer instance \\
\hline
\mbox{\texttt{ in}}  & {\em max\+\_\+delay} & Maximum buffer size, as in maximum delay in milliseconds \\
\hline
\end{DoxyParams}
\mbox{\label{group__jibuf_gabcd63f39049bc4d6b3541a674b78963d}} 
\index{Osmocom Jitter Buffer@{Osmocom Jitter Buffer}!osmo\_jibuf\_set\_min\_delay@{osmo\_jibuf\_set\_min\_delay}}
\index{osmo\_jibuf\_set\_min\_delay@{osmo\_jibuf\_set\_min\_delay}!Osmocom Jitter Buffer@{Osmocom Jitter Buffer}}
\doxysubsubsection{osmo\_jibuf\_set\_min\_delay()}
{\footnotesize\ttfamily void osmo\+\_\+jibuf\+\_\+set\+\_\+min\+\_\+delay (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+jibuf} $\ast$}]{jb,  }\item[{uint32\+\_\+t}]{min\+\_\+delay }\end{DoxyParamCaption})}



Set minimum buffer size for the jitter buffer. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em jb} & jitter buffer instance \\
\hline
\mbox{\texttt{ in}}  & {\em min\+\_\+delay} & Minimum buffer size, as in minimum delay in milliseconds \\
\hline
\end{DoxyParams}
