\doxysection{com.\+tritondigital.\+net.\+streaming.\+proxy.\+dataprovider.\+Data\+Provider Class Reference}
\hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider}{}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider}\index{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider@{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider}}


Base class for different kind of Data packets provider.  


Inheritance diagram for com.\+tritondigital.\+net.\+streaming.\+proxy.\+dataprovider.\+Data\+Provider\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.191781cm]{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider}
\end{center}
\end{figure}
\doxysubsubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_a38bde7abcfd2ce40055bb65f9d3f96c7}{stop}} ()
\begin{DoxyCompactList}\small\item\em Interrupts any operation and clear the packets queue. \end{DoxyCompactList}\item 
\mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1Packet}{Packet}} \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_a5502fc0145f47788790d36ee91bc771a}{get\+Packet}} ()
\begin{DoxyCompactList}\small\item\em Returns the next Packet in the stream. \end{DoxyCompactList}\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_a068dba82d9db5b2b843aba2c9713e1a0}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_a068dba82d9db5b2b843aba2c9713e1a0} 
void {\bfseries add\+Free\+Packet\+To\+Pool} (\mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1Packet}{Packet}} packet)
\begin{DoxyCompactList}\small\item\em Puts the given packet back in the free pool packets. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_aa22416b278bb1f2409a06cba131847fd}{clear\+Internal\+Buffer}} ()
\begin{DoxyCompactList}\small\item\em If the provider keeps a buffer of already available packets, clear it immediately. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1Packet}{Packet}} \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_ac82fea6799dac8348e21b68c5e675661}{get\+Free\+Packet}} ()
\begin{DoxyCompactList}\small\item\em Returns a free packet to use for the creation of a new packet. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_aa29588d8cea9453d3051c3316c55dbe2}{enqueue\+Packet}} (\mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1Packet}{Packet}} packet)
\begin{DoxyCompactList}\small\item\em Enqueue a Packet to be sent to the server. \end{DoxyCompactList}\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_a16935bef95edb1c63f05199845cc6712}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_a16935bef95edb1c63f05199845cc6712} 
abstract \mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1Packet}{Packet}} {\bfseries create\+Empty\+Packet} ()
\begin{DoxyCompactList}\small\item\em Create an empty packet of the expected type by the subclass. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
final Array\+Blocking\+Queue$<$ \mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1Packet}{Packet}} $>$ \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_a4620a04632fe2b469f99d19f51f065f9}{m\+Packets\+Queue}} = new Array\+Blocking\+Queue$<$$>$(QUEUE\+\_\+\+SIZE)
\begin{DoxyCompactList}\small\item\em List of all packets that were received from the client and not sent to the server yet. \end{DoxyCompactList}\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_ad8f9a5e1be43a5f192fb2cdb1a1b8955}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_ad8f9a5e1be43a5f192fb2cdb1a1b8955} 
final Array\+Blocking\+Queue$<$ \mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1Packet}{Packet}} $>$ {\bfseries m\+Free\+Packets\+Pool} = new Array\+Blocking\+Queue$<$$>$(QUEUE\+\_\+\+SIZE)
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Base class for different kind of Data packets provider. 

This class implements the Stream\+Container\+Deccoder.\+Audio\+Data\+Decoded\+Listener interface, it is notified as soon as new data is ready to be packetized, then is creates a new packet from this data and enqueues it. It maintains an internal queue of packets to be able to create multiple packets and keep them until the server transmits them. This queue is thread-\/safe and has a fixed size. Trying to add new packets when it is full will block the thread, which might cause some packets to drop on the Stream\+Container\+Deccoder side. Trying to get a packet when queue is empty will also block the calling thread until a new packet is available.

Ideally, the server will consume / transmit the packets at the same rate as they are reveived from the Stream\+Container\+Deccoder, to avoid buffer underrun (queue is empty) or overrun (queue is full), which is both case will block a thread.

A subclass that wants to be efficient should never create Packets directly. Instead, it should request a free packet using get\+Free\+Packet, which will take a packet from the free packets pool or create a new one if necessary. Similarily, the class that takes the packets using get\+Packet should put back the packet in the free packets pool for reuse when it is done with it by calling add\+Free\+Packet\+To\+Pool. 

\doxysubsection{Member Function Documentation}
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_aa22416b278bb1f2409a06cba131847fd}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_aa22416b278bb1f2409a06cba131847fd} 
\index{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider@{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider}!clearInternalBuffer@{clearInternalBuffer}}
\index{clearInternalBuffer@{clearInternalBuffer}!com.tritondigital.net.streaming.proxy.dataprovider.DataProvider@{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider}}
\doxysubsubsection{\texorpdfstring{clearInternalBuffer()}{clearInternalBuffer()}}
{\footnotesize\ttfamily void com.\+tritondigital.\+net.\+streaming.\+proxy.\+dataprovider.\+Data\+Provider.\+clear\+Internal\+Buffer (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



If the provider keeps a buffer of already available packets, clear it immediately. 

Typically invoked before the proxy starts the client, to remove the old data that could have been still present in the buffer. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_aa29588d8cea9453d3051c3316c55dbe2}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_aa29588d8cea9453d3051c3316c55dbe2} 
\index{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider@{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider}!enqueuePacket@{enqueuePacket}}
\index{enqueuePacket@{enqueuePacket}!com.tritondigital.net.streaming.proxy.dataprovider.DataProvider@{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider}}
\doxysubsubsection{\texorpdfstring{enqueuePacket()}{enqueuePacket()}}
{\footnotesize\ttfamily void com.\+tritondigital.\+net.\+streaming.\+proxy.\+dataprovider.\+Data\+Provider.\+enqueue\+Packet (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1Packet}{Packet}}}]{packet }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [protected]}}



Enqueue a Packet to be sent to the server. 

Blocks if the queue is full. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_ac82fea6799dac8348e21b68c5e675661}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_ac82fea6799dac8348e21b68c5e675661} 
\index{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider@{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider}!getFreePacket@{getFreePacket}}
\index{getFreePacket@{getFreePacket}!com.tritondigital.net.streaming.proxy.dataprovider.DataProvider@{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider}}
\doxysubsubsection{\texorpdfstring{getFreePacket()}{getFreePacket()}}
{\footnotesize\ttfamily \mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1Packet}{Packet}} com.\+tritondigital.\+net.\+streaming.\+proxy.\+dataprovider.\+Data\+Provider.\+get\+Free\+Packet (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [protected]}}



Returns a free packet to use for the creation of a new packet. 

Creates a new one if none are available. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_a5502fc0145f47788790d36ee91bc771a}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_a5502fc0145f47788790d36ee91bc771a} 
\index{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider@{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider}!getPacket@{getPacket}}
\index{getPacket@{getPacket}!com.tritondigital.net.streaming.proxy.dataprovider.DataProvider@{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider}}
\doxysubsubsection{\texorpdfstring{getPacket()}{getPacket()}}
{\footnotesize\ttfamily \mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1Packet}{Packet}} com.\+tritondigital.\+net.\+streaming.\+proxy.\+dataprovider.\+Data\+Provider.\+get\+Packet (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Returns the next Packet in the stream. 

If none are available, blocks until new data arrives and is properly wrapped in the appropriate packet format (e.\+g. RTP). Returns null if no packets after a given timeout. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_a38bde7abcfd2ce40055bb65f9d3f96c7}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_a38bde7abcfd2ce40055bb65f9d3f96c7} 
\index{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider@{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider}!stop@{stop}}
\index{stop@{stop}!com.tritondigital.net.streaming.proxy.dataprovider.DataProvider@{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider}}
\doxysubsubsection{\texorpdfstring{stop()}{stop()}}
{\footnotesize\ttfamily void com.\+tritondigital.\+net.\+streaming.\+proxy.\+dataprovider.\+Data\+Provider.\+stop (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Interrupts any operation and clear the packets queue. 

Clears the internal buffer at the same time. 

Reimplemented in \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1raw_1_1RawPacketProvider_aae82d5e26558d41e0aca9b1c0243e9c8}{com.\+tritondigital.\+net.\+streaming.\+proxy.\+dataprovider.\+raw.\+Raw\+Packet\+Provider}}, and \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1rtp_1_1RtpPacketProvider_ada9e74c7980a52681168a8f41976acc5}{com.\+tritondigital.\+net.\+streaming.\+proxy.\+dataprovider.\+rtp.\+Rtp\+Packet\+Provider}}.



\doxysubsection{Member Data Documentation}
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_a4620a04632fe2b469f99d19f51f065f9}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1DataProvider_a4620a04632fe2b469f99d19f51f065f9} 
\index{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider@{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider}!mPacketsQueue@{mPacketsQueue}}
\index{mPacketsQueue@{mPacketsQueue}!com.tritondigital.net.streaming.proxy.dataprovider.DataProvider@{com.tritondigital.net.streaming.proxy.dataprovider.DataProvider}}
\doxysubsubsection{\texorpdfstring{mPacketsQueue}{mPacketsQueue}}
{\footnotesize\ttfamily final Array\+Blocking\+Queue$<$\mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1dataprovider_1_1Packet}{Packet}}$>$ com.\+tritondigital.\+net.\+streaming.\+proxy.\+dataprovider.\+Data\+Provider.\+m\+Packets\+Queue = new Array\+Blocking\+Queue$<$$>$(QUEUE\+\_\+\+SIZE)\hspace{0.3cm}{\ttfamily [protected]}}



List of all packets that were received from the client and not sent to the server yet. 

This list gets bigger when a burst is received and when the client is connected but not the server. On the contrary, it gets smaller if the client disconnects or if the conversion of the data received to destination packet format (e.\+g. RTP) takes more than the server\textquotesingle{}s expected bitrate. 

The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
streamingproxy/src/main/java/com/tritondigital/net/streaming/proxy/dataprovider/Data\+Provider.\+java\end{DoxyCompactItemize}
