|
Triton Mobile SDK for Android 3.5.1
This is a custom android player made by Triton Digital
|
Classes | |
| interface | AudioDataDecodedListener |
| Interface definition for a callback to be invoked when new metadata is decoded from the stream. More... | |
| interface | MetaDataDecodedListener |
| Interface definition for a callback to be invoked when new metadata is decoded from the stream. More... | |
Public Member Functions | |
| boolean | onDataReceived (byte[] data, int dataLength) |
| void | setMetaDataDecodedListener (MetaDataDecodedListener metaDataDecodedListener) |
| Sets the listener to be notified when new meta data is decoded. | |
| void | setAudioDataDecodedListener (AudioDataDecodedListener audioDataDecodedListener) |
| Sets the listener to be notified when new audio data is decoded. | |
| void | startDecodingInBackground () |
| Creates and InputStream and starts a thread that decodes it and does the actual job of extracting the audio data and parameters and the meta data. | |
| void | stop () |
| Stops the decoding thread and close the streams. | |
| abstract void | stopDecodingThread () |
| Stops decoding the input stream passed in startDecodingInBackground. | |
| void | setReferenceTimestampToNow () |
Public Attributes | |
| final String | TAG = "StreamContainerDecoder" |
Protected Member Functions | |
| StreamContainerDecoder () | |
| Creates the internal streams used to transfer the new data received from the socket to a stream that can be used in blocking reading. | |
| void | notifyMetaDataDecoded (final Map< String, Object > metaData, int timestamp) |
| Notifies the MetaDataListener that a MetaData was decoded. | |
| void | notifyAudioConfigDecoded (AudioConfig audioConfig) |
| Notifies the AudioDataListener that the AudioConfig was decoded. | |
| void | notifyAudioDataDecoded (byte[] audioData, int audioDataLength, int timestamp) |
| Notifies the AudioDataListener that an AudioData was decoded. | |
| abstract void | startDecodingThread () |
| Starts the thread that does the decoding. | |
Protected Attributes | |
| volatile QueueInputStream | mInputStreamForDecodingThread |
| Stream where new received bytes are enqueued, read by the decoder. | |
| long | mReferenceTimestamp |
| The timestamp of the machine at the moment when the decoding starts. | |
Base class for the class that decoded a stream transport protocol such as Flv or ShoutCast. The purpose of this class is to take the input data from a connection (through the Client.DataReceivedListener interface), extracts the Metadata and AudioData 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 MetaData contained in the stream, if any.
The decoding is done in a background thread. Whenever new data is received, the onDataReceived is invoked on the StreamContainerDeccoder 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 StreamContainerDeccoder instance is created, but is blocked until data arrives (onDataReceived 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 MetaData 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.
|
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.
|
protected |
Notifies the MetaDataListener that a MetaData 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.
| void com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder.setReferenceTimestampToNow | ( | ) |
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 setReferenceTimestampToNow method needs to be called when when the audio actually starts playing.
| void com.tritondigital.net.streaming.proxy.decoder.StreamContainerDecoder.startDecodingInBackground | ( | ) |
Creates and InputStream 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 DataInputStream.readFully to block until a chunk can be read entirely, and notifies its listener about each decoded chunk.
|
abstract |
Stops decoding the input stream passed in startDecodingInBackground.
Interrupts the background thread that does the decoding itself and free resources that are no longer needed.
|
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.
|
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.