\doxysection{com.\+tritondigital.\+net.\+streaming.\+proxy.\+decoder.\+Stream\+Container\+Decoder Class Reference}
\hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder}{}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder}\index{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}}
Inheritance diagram for com.\+tritondigital.\+net.\+streaming.\+proxy.\+decoder.\+Stream\+Container\+Decoder\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=3.000000cm]{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder}
\end{center}
\end{figure}
\doxysubsubsection*{Classes}
\begin{DoxyCompactItemize}
\item 
interface \mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_1_1AudioDataDecodedListener}{Audio\+Data\+Decoded\+Listener}}
\begin{DoxyCompactList}\small\item\em Interface definition for a callback to be invoked when new metadata is decoded from the stream. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_1_1MetaDataDecodedListener}{Meta\+Data\+Decoded\+Listener}}
\begin{DoxyCompactList}\small\item\em Interface definition for a callback to be invoked when new metadata is decoded from the stream. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_ab9b962948672dcfaa8888380e5969fd0}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_ab9b962948672dcfaa8888380e5969fd0} 
boolean {\bfseries on\+Data\+Received} (byte\mbox{[}$\,$\mbox{]} data, int data\+Length)
\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a5d963c9cc719a756f7268860888804fc}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a5d963c9cc719a756f7268860888804fc} 
void {\bfseries set\+Meta\+Data\+Decoded\+Listener} (\mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_1_1MetaDataDecodedListener}{Meta\+Data\+Decoded\+Listener}} meta\+Data\+Decoded\+Listener)
\begin{DoxyCompactList}\small\item\em Sets the listener to be notified when new meta data is decoded. \end{DoxyCompactList}\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_ab87b03d86419f3825ea832bd0b4bb18f}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_ab87b03d86419f3825ea832bd0b4bb18f} 
void {\bfseries set\+Audio\+Data\+Decoded\+Listener} (\mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_1_1AudioDataDecodedListener}{Audio\+Data\+Decoded\+Listener}} audio\+Data\+Decoded\+Listener)
\begin{DoxyCompactList}\small\item\em Sets the listener to be notified when new audio data is decoded. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a8778c756198501ce60d7ecb911c07e97}{start\+Decoding\+In\+Background}} ()
\begin{DoxyCompactList}\small\item\em Creates and Input\+Stream and starts a thread that decodes it and does the actual job of extracting the audio data and parameters and the meta data. \end{DoxyCompactList}\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a34c8445ac392a9e30bc9fb211fde5959}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a34c8445ac392a9e30bc9fb211fde5959} 
void {\bfseries stop} ()
\begin{DoxyCompactList}\small\item\em Stops the decoding thread and close the streams. \end{DoxyCompactList}\item 
abstract void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a30d5c6be38005fbaab1911e6b9c547cf}{stop\+Decoding\+Thread}} ()
\begin{DoxyCompactList}\small\item\em Stops decoding the input stream passed in start\+Decoding\+In\+Background. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a8d642a4d19be02bc950aede47990e81a}{set\+Reference\+Timestamp\+To\+Now}} ()
\end{DoxyCompactItemize}
\doxysubsubsection*{Public Attributes}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a7cd21c5d9c4301ade90c6cdc3f64645f}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a7cd21c5d9c4301ade90c6cdc3f64645f} 
final String {\bfseries TAG} = "{}Stream\+Container\+Decoder"{}
\end{DoxyCompactItemize}
\doxysubsubsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a7d0a35bbc359b4c98773b549e24c0353}{Stream\+Container\+Decoder}} ()
\begin{DoxyCompactList}\small\item\em Creates the internal streams used to transfer the new data received from the socket to a stream that can be used in blocking reading. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a0436ed49cd43082703dd56adc5eea3d0}{notify\+Meta\+Data\+Decoded}} (final Map$<$ String, Object $>$ meta\+Data, int timestamp)
\begin{DoxyCompactList}\small\item\em Notifies the Meta\+Data\+Listener that a Meta\+Data was decoded. \end{DoxyCompactList}\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a732ea0e2e98054816dd3510f82d0c8d6}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a732ea0e2e98054816dd3510f82d0c8d6} 
void {\bfseries notify\+Audio\+Config\+Decoded} (\mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1AudioConfig}{Audio\+Config}} audio\+Config)
\begin{DoxyCompactList}\small\item\em Notifies the Audio\+Data\+Listener that the Audio\+Config was decoded. \end{DoxyCompactList}\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_af1fe3ff343d0331bfa2869c83108d20b}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_af1fe3ff343d0331bfa2869c83108d20b} 
void {\bfseries notify\+Audio\+Data\+Decoded} (byte\mbox{[}$\,$\mbox{]} audio\+Data, int audio\+Data\+Length, int timestamp)
\begin{DoxyCompactList}\small\item\em Notifies the Audio\+Data\+Listener that an Audio\+Data was decoded. \end{DoxyCompactList}\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a39ea34fcbed56f417138b95ec65e3ea0}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a39ea34fcbed56f417138b95ec65e3ea0} 
abstract void {\bfseries start\+Decoding\+Thread} ()
\begin{DoxyCompactList}\small\item\em Starts the thread that does the decoding. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
volatile Queue\+Input\+Stream \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_acc34f49f2a8bc98ac62b8ca9dd56606e}{m\+Input\+Stream\+For\+Decoding\+Thread}}
\begin{DoxyCompactList}\small\item\em Stream where new received bytes are enqueued, read by the decoder. \end{DoxyCompactList}\item 
long \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a3da04a865fadc6e002e7b134dc87b1b8}{m\+Reference\+Timestamp}}
\begin{DoxyCompactList}\small\item\em The timestamp of the machine at the moment when the decoding starts. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Base class for the class that decoded a stream transport protocol such as Flv or Shout\+Cast. The purpose of this class is to take the input data from a connection (through the Client.\+Data\+Received\+Listener interface), extracts the Metadata and Audio\+Data and send it to a listener.

The listener receives the audio data itself, ummodified, and the parameters required to use this data such as the media type or sample rate, which is extracted from the stream container. It can also receive the Meta\+Data contained in the stream, if any.

The decoding is done in a background thread. Whenever new data is received, the on\+Data\+Received is invoked on the Stream\+Container\+Deccoder instance, the data is sent to the decoding thread, where is is parsed (the thread might block if the received data is not a complete chunk / tag). The decoding thread starts when the Stream\+Container\+Deccoder instance is created, but is blocked until data arrives (on\+Data\+Received is called)

The audio chunks are sent along with their timestamp when they are decoded, to allow the player to buffet them. The player is responsible for player the audio samples at the good time. On the other hand, Metadata listener is notified only when the metadata should be interpreted. This means that if some metadata are received but they reference a date in the future, the metadata listener will only be notified when this future date is reached.

If Meta\+Data need to be delayed, in order to make sure that they are processes synchronously with the Audio that is played, a scheduler thread is created. Therefore, this module uses 2 threads, one for scheduling the Metadata processing and one to do the actual decoding. 

\doxysubsection{Constructor \& Destructor Documentation}
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a7d0a35bbc359b4c98773b549e24c0353}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a7d0a35bbc359b4c98773b549e24c0353} 
\index{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}!StreamContainerDecoder@{StreamContainerDecoder}}
\index{StreamContainerDecoder@{StreamContainerDecoder}!com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}}
\doxysubsubsection{\texorpdfstring{StreamContainerDecoder()}{StreamContainerDecoder()}}
{\footnotesize\ttfamily com.\+tritondigital.\+net.\+streaming.\+proxy.\+decoder.\+Stream\+Container\+Decoder.\+Stream\+Container\+Decoder (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [protected]}}



Creates the internal streams used to transfer the new data received from the socket to a stream that can be used in blocking reading. 

This allows the decoder to read and block until the correct number of bytes is available. Blocking is passive to allow other threads to run. 

\doxysubsection{Member Function Documentation}
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a0436ed49cd43082703dd56adc5eea3d0}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a0436ed49cd43082703dd56adc5eea3d0} 
\index{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}!notifyMetaDataDecoded@{notifyMetaDataDecoded}}
\index{notifyMetaDataDecoded@{notifyMetaDataDecoded}!com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}}
\doxysubsubsection{\texorpdfstring{notifyMetaDataDecoded()}{notifyMetaDataDecoded()}}
{\footnotesize\ttfamily void com.\+tritondigital.\+net.\+streaming.\+proxy.\+decoder.\+Stream\+Container\+Decoder.\+notify\+Meta\+Data\+Decoded (\begin{DoxyParamCaption}\item[{final Map$<$ String, Object $>$}]{meta\+Data,  }\item[{int}]{timestamp }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [protected]}}



Notifies the Meta\+Data\+Listener that a Meta\+Data was decoded. 

Note that this does not directly notify the listener. Instead, it waits for the timestamp to be reached before notifying. Timestamps here are is the same unit and have the same start than the audio data. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a8d642a4d19be02bc950aede47990e81a}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a8d642a4d19be02bc950aede47990e81a} 
\index{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}!setReferenceTimestampToNow@{setReferenceTimestampToNow}}
\index{setReferenceTimestampToNow@{setReferenceTimestampToNow}!com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}}
\doxysubsubsection{\texorpdfstring{setReferenceTimestampToNow()}{setReferenceTimestampToNow()}}
{\footnotesize\ttfamily void com.\+tritondigital.\+net.\+streaming.\+proxy.\+decoder.\+Stream\+Container\+Decoder.\+set\+Reference\+Timestamp\+To\+Now (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}

Affects the reference timestamp used to delay the sending of the Metadata until the metadata timestamp has been reached.

The stream is often sent by burst instead of in real time. This means that when the Metadata is received, it may reference a time in the future. To make sure that the Metadata is only treated when it is supposed to, its timestamp is used (each Metadata has a timestamp associated to, sent by the server when it sends the Metadata) to create a timer that will notify the listener after the good amount of time. Concretely, this means that the metadata is treated approximately when the audio data tag next to it it played, since Metadata and Audio share the same timestamps reference.

For this technique to work, it is important to consider that time 0 is when the audio data actually starts. The set\+Reference\+Timestamp\+To\+Now method needs to be called when when the audio actually starts playing. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a8778c756198501ce60d7ecb911c07e97}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a8778c756198501ce60d7ecb911c07e97} 
\index{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}!startDecodingInBackground@{startDecodingInBackground}}
\index{startDecodingInBackground@{startDecodingInBackground}!com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}}
\doxysubsubsection{\texorpdfstring{startDecodingInBackground()}{startDecodingInBackground()}}
{\footnotesize\ttfamily void com.\+tritondigital.\+net.\+streaming.\+proxy.\+decoder.\+Stream\+Container\+Decoder.\+start\+Decoding\+In\+Background (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Creates and Input\+Stream and starts a thread that decodes it and does the actual job of extracting the audio data and parameters and the meta data. 

Typically, this thread loops until the streaming stops, it reads chunk by chunk from the stream using Data\+Input\+Stream.\+read\+Fully to block until a chunk can be read entirely, and notifies its listener about each decoded chunk. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a30d5c6be38005fbaab1911e6b9c547cf}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a30d5c6be38005fbaab1911e6b9c547cf} 
\index{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}!stopDecodingThread@{stopDecodingThread}}
\index{stopDecodingThread@{stopDecodingThread}!com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}}
\doxysubsubsection{\texorpdfstring{stopDecodingThread()}{stopDecodingThread()}}
{\footnotesize\ttfamily abstract void com.\+tritondigital.\+net.\+streaming.\+proxy.\+decoder.\+Stream\+Container\+Decoder.\+stop\+Decoding\+Thread (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [abstract]}}



Stops decoding the input stream passed in start\+Decoding\+In\+Background. 

Interrupts the background thread that does the decoding itself and free resources that are no longer needed. 

\doxysubsection{Member Data Documentation}
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_acc34f49f2a8bc98ac62b8ca9dd56606e}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_acc34f49f2a8bc98ac62b8ca9dd56606e} 
\index{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}!mInputStreamForDecodingThread@{mInputStreamForDecodingThread}}
\index{mInputStreamForDecodingThread@{mInputStreamForDecodingThread}!com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}}
\doxysubsubsection{\texorpdfstring{mInputStreamForDecodingThread}{mInputStreamForDecodingThread}}
{\footnotesize\ttfamily volatile Queue\+Input\+Stream com.\+tritondigital.\+net.\+streaming.\+proxy.\+decoder.\+Stream\+Container\+Decoder.\+m\+Input\+Stream\+For\+Decoding\+Thread\hspace{0.3cm}{\ttfamily [protected]}}



Stream where new received bytes are enqueued, read by the decoder. 

Blocks when full and trying to add new data and when trying to read if empty. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a3da04a865fadc6e002e7b134dc87b1b8}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1decoder_1_1StreamContainerDecoder_a3da04a865fadc6e002e7b134dc87b1b8} 
\index{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}!mReferenceTimestamp@{mReferenceTimestamp}}
\index{mReferenceTimestamp@{mReferenceTimestamp}!com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder@{com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder}}
\doxysubsubsection{\texorpdfstring{mReferenceTimestamp}{mReferenceTimestamp}}
{\footnotesize\ttfamily long com.\+tritondigital.\+net.\+streaming.\+proxy.\+decoder.\+Stream\+Container\+Decoder.\+m\+Reference\+Timestamp\hspace{0.3cm}{\ttfamily [protected]}}



The timestamp of the machine at the moment when the decoding starts. 

Used to know exactly when to send the Metadata to the listener. 

The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
sdk/src/main/java/com/tritondigital/net/streaming/proxy/decoder/Stream\+Container\+Decoder.\+java\end{DoxyCompactItemize}
