|
Triton Mobile SDK for Android 3.5.1
This is a custom android player made by Triton Digital
|
Classes | |
| enum | State |
| All different states in which the server can be. More... | |
| interface | StateChangedListener |
| Interface to be implemented in order to be notified about the important changes of state of the server. More... | |
Public Member Functions | |
| void | listen (int port) |
| Starts listening and accepting connections on the given port. | |
| void | stop () |
| Stops the server. | |
| abstract URI | getUri () |
| Returns the Uri that should be used to connect to this server, typically localhost on the port specified in the call to listen. | |
| boolean | blockUntilReady () |
| void | stopBlockingUntilReady () |
| Unblock the thread waiting on a call to blockUntilReady. | |
| abstract void | setDataProvider (DataProvider rtpPacketProvider) |
| Sets the instance that provides the data to stream to the server. | |
| void | setStateChangedListener (StateChangedListener stateChangedListener) |
| Sets the listener to be notified about the various state change on the server. | |
| State | getState () |
| Gets the current state of the server. | |
Public Attributes | |
| final String | TAG = "Server" |
Protected Member Functions | |
| abstract void | bindAndListen (int port) |
| Does the job of binding a socket and start accepting incoming connections. | |
| abstract void | onProcessMessage (Object userInfo) |
| Let the child class do whatever it needs with the message. | |
| abstract void | disconnectAndUnbind () |
| Does the job of disconnecting, unbinding the socket and stop accepting incoming connections. | |
| void | onConnected () |
| Called when the child class accepts a connection. | |
| void | onDisconnected () |
| Called when the child class disconnected. | |
| void | onError (ErrorDetail errorDetail) |
| Called when the child class encounters an error. | |
| void | onMessageReceived (Object userInfo) |
| Called when the child class receives data. | |
| void | setStateNotReady () |
| Sets the internal state to not ready state and notify listener about it. | |
| void | setStateReady () |
| Sets the internal state to ready state and notify listener about it. | |
| void | setStateListening () |
| Sets the internal state to listening state and notify listener about it. | |
| void | setStateConnected () |
| Sets the internal state to connected state and notify listener about it. | |
| void | setStateStopping () |
| Sets the internal state to stopping state and notify listener about it. | |
| void | setStateError (ErrorDetail errorDetail) |
| Sets the internal state to error state and notify listener about it. | |
Static Protected Attributes | |
| static final String | LOCALHOST = "127.0.0.1" |
Base class for any network server allowing sending a stream. Any child of this class should provide functionality to take packets from a source (provider) and send it to the client.
Typically, child classes will call onConnected, onDisconnected, onMessageReceived and onError when those events are received. The superclass will synchronise the calls, ensure that the states are consistent and call the onCompleteConnection, onCompleteDisconnection, onProcessRequest and onProcessError methods on the child class.
If they choose to manipulate the state directly, child classes should make sure to match the desired behaviour, especially setting the READY state when the server is ready to listen, as this will unblock any thread that called blockUntilReady.
| boolean com.tritondigital.net.streaming.proxy.server.Server.blockUntilReady | ( | ) |
Some servers might require a certain amount of data to be already available (either to fill a buffer or to extract configuration information needed in the stream negotiation) before being ready to listen. This method blocks the calling thread until the server has all required information and is ready to start listening.
This is typically between the data provider and the call to listen. There is also a notification sent when the server becomes ready, to avoid blocking the thread and allow it to do some UI animation while waiting. If the server is not ready, it may block when generating a response, causing the client to consider it as a timeout and disconnect.
This method blocks until either the server is ready, the server is stopped / encountered an error or until stopBlockingUntilReady is invoked. The return code will differ if the server is unlocked and the server is not ready.
true If the server is ready, false if not (there was an error or the server was stopped).
|
abstract |
Returns the Uri that should be used to connect to this server, typically localhost on the port specified in the call to listen.
Returns null if the server is not listening.
| void com.tritondigital.net.streaming.proxy.server.Server.listen | ( | int | port | ) |
Starts listening and accepting connections on the given port.
| port | The port to listen on, -1 for any available port. When using any available port, make sure to use getUri in order to know the address of the server. If the port is specified (not -1), and is not available for bind, the server enters the error state. |
|
protected |
Called when the child class accepts a connection.
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 child is notified via onProcessMessage and receives the user info that it passed.
|
abstractprotected |
Let the child class do whatever it needs with the message.
Only called if the server is in the correct state, and protected for thread safety.
|
abstract |
Sets the instance that provides the data to stream to the server.
Ignored if the server is already listening or connected.
The servers often require a specific class of providers, make sure to read the specific server documentation for this method.
Reimplemented in com.tritondigital.net.streaming.proxy.server.http.HttpServer, and com.tritondigital.net.streaming.proxy.server.rtsp.RtspServer.
|
protected |
Sets the internal state to connected state and notify listener about it.
Called by subclasses when they accept an incoming connection.
|
protected |
Sets the internal state to error state and notify listener about it.
Called by subclasses when they encounter an unrecoverable error.
|
protected |
Sets the internal state to listening state and notify listener about it.
Called by subclasses when they start listening.
|
protected |
Sets the internal state to not ready state and notify listener about it.
Called by subclasses when the DataProvider changes and is not ready to be used for streaming.
|
protected |
Sets the internal state to ready state and notify listener about it.
Called by subclasses when they are ready to listen (all needed data have been received from the provider).
|
protected |
Sets the internal state to stopping state and notify listener about it.
Called by subclasses when they start to stop. Stays in this state until the stop is complete.
| void com.tritondigital.net.streaming.proxy.server.Server.stop | ( | ) |
Stops the server.
Stops listening and disconnects the connected client if there is one. The server loses the ready state of its data provider when disconnected. It therefore has to wait for its Data Provider to send the ready notification before it can be used to listen again.