|
Triton Mobile SDK for Android 3.5.1
This is a custom android player made by Triton Digital
|
Base class for any network client allowing connection to a stream. More...
Classes | |
| interface | DataReceivedListener |
| Interface definition for a callback to be invoked when new data is received from the stream. More... | |
| enum | State |
| All different states in which the client can be. More... | |
| interface | StateChangedListener |
| Interface to be implemented in order to be notified about the important changes of state of the client. More... | |
Public Member Functions | |
| void | setUserAgent (String userAgent) |
| Sets the User Agent used when connecting. | |
| void | connect (URI uri) |
| Connects the client to the given URI and start streaming. | |
| void | stop () |
| Trigger the disconnection if already connected. | |
| void | setDataReceivedListener (DataReceivedListener listener) |
| Sets the listener notified whenever a chunk of data is downloaded. | |
| void | setStateChangedListener (StateChangedListener stateChangedListener) |
| Sets the listener to be notified about the various state change on the client. | |
| State | getState () |
| Gets the current state of the client. | |
| StreamContainerDecoder | getStreamContainerDecoder () |
| void | setStreamContainerDecoder (StreamContainerDecoder streamContainerDecoder) |
Static Public Attributes | |
| static final String | TAG = "Client" |
Protected Member Functions | |
| abstract void | startConnectingInBackground () |
| Connects the client to the given URI and start streaming. | |
| abstract void | disconnect () |
| Does the job of Stops connecting or disconnect. | |
| void | onConnected () |
| Called when the child class connects to a server. | |
| void | onDisconnected () |
| Called when the child class disconnected. | |
| void | onError (ErrorDetail errorDetail) |
| Called when the child class encounters an error. | |
| void | onMessageReceived (byte[] buffer, int bufferLength) |
| Called when the child class receives data. | |
Protected Attributes | |
| DataReceivedListener | mDataReceivedListener |
| StreamContainerDecoder | streamContainerDecoder |
| URI | mUri |
| String | mUserAgent = "TritonDigital Streaming Proxy" |
Base class for any network client allowing connection to a stream.
Any child of this class should provide functionality to stream from a source and notify its listener whenever new data becomes available.
The listener receives the stream data, but not the response header) and is responsible for interpreting and decoding this data. The received data is not modified of buffered. The listener is responsible for determining if the data is complete and should cumulate incomplete chunks in order to use them when enough data was received.
Child classes should correctly set the state to avoid having inconsistent behaviours in the proxy. Each state update method should be called at the appropriate time: onConnected, onDisconnected, onError and onMessageReceived. It should implement the connection mechanism, make sure that the connection runs in a separate thread (method startConnectingInBackground) and that it can be disconnected easily (method disconnect).
The connection and transfer are all done in a background thread.
| void com.tritondigital.net.streaming.proxy.client.Client.connect | ( | URI | uri | ) |
Connects the client to the given URI and start streaming.
This call is asynchronous, it starts the connection process in a secondary thread and return immediately. If the URI is not supported, an error is returned and the listener is notified. If there is an error or a timeout during the connection, the listener is also notified.
|
protected |
Called when the child class connects to a server.
When it is safe (thread synchronisation), the internal state is changed.
|
protected |
Called when the child class disconnected.
When it is safe (thread synchronisation), the internal state is changed.
|
protected |
Called when the child class encounters an error.
When it is safe (thread synchronisation), the internal state is changed.
|
protected |
Called when the child class receives data.
When it is safe (thread synchronisation), the message is posted to the listener.
| void com.tritondigital.net.streaming.proxy.client.Client.setDataReceivedListener | ( | DataReceivedListener | listener | ) |
Sets the listener notified whenever a chunk of data is downloaded.
It is strongly discouraged to change the listener when a connection or a download is in progress as there is no way to know which of the new or the old listener will receive the callback during the transition.
| void com.tritondigital.net.streaming.proxy.client.Client.setUserAgent | ( | String | userAgent | ) |
Sets the User Agent used when connecting.
Does nothing if set after the connect was called.
|
abstractprotected |
Connects the client to the given URI and start streaming.
This call is asynchronous, it starts the connection process in a secondary thread and return immediately. If the URI is not supported, an error is returned and the listener is notified. If there is an error or a timeout during the connection, the listener is also notified.