|
Triton Mobile SDK for Android 3.5.1
This is a custom android player made by Triton Digital
|
Public Member Functions | |
| RtspServer () | |
| Constructs a RTSP Server that streams the data from the given provider. | |
| void | bindAndListen (final int port) |
| URI | getUri () |
| void | setDataProvider (DataProvider rtpPacketProvider) |
| Sets the RTSP Server to streams the data from the given provider. | |
Public Member Functions inherited from com.tritondigital.net.streaming.proxy.server.Server | |
| void | listen (int port) |
| Starts listening and accepting connections on the given port. | |
| void | stop () |
| Stops the server. | |
| boolean | blockUntilReady () |
| void | stopBlockingUntilReady () |
| Unblock the thread waiting on a call to blockUntilReady. | |
| 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. | |
Static Public Attributes | |
| static final String | SERVER_NAME = "Triton Digital RTSP Proxy" |
Protected Member Functions | |
| void | disconnectAndUnbind () |
| void | onProcessMessage (Object userInfo) |
Protected Member Functions inherited from com.tritondigital.net.streaming.proxy.server.Server | |
| 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. | |
Additional Inherited Members | |
Public Attributes inherited from com.tritondigital.net.streaming.proxy.server.Server | |
| final String | TAG = "Server" |
Static Protected Attributes inherited from com.tritondigital.net.streaming.proxy.server.Server | |
| static final String | LOCALHOST = "127.0.0.1" |
Implementation of a Server that responds to Rtsp requests. The Server uses a socket to listen and negotiate the connection. It then streams using the already established TCP connection, or by sending UDP datagrams.
The RTSP contains the minimum to simply start streaming, based on the RFC 2326 (http://www.ietf.org/rfc/rfc2326.txt). It responds to OPTIONS, DESCRIBE with the minimal SDP information, SETUP and PLAY. RTCP messages are ignored when received, and never generated. They are not needed for the type of work that the proxy does. If needed, they would be added later on.
It supports streaming RTP Packets through UDP or through TCP using interleaved mode. It is also possible to force the use of TCP by returning an UNSUPPORTED_TRANSPORT message to a SETUP request with UDP ports. This works only if the client supports it. A client typically tries to SETUP using UDP, then TCP if UDP is not supported.
In the case of this server, used in a proxy, there are no chances of packets loss or misorder, so UDP is more efficient. However, for debugging purposes, it might be easier to monitor all the data (RTSP negociation + RTP Packets Stream) in a single connection. For this reason, it is supported to force RTP over TCP. This should typically used only for debugging.
The server listens and accepts a connection, the uses blocking sockets to read the requests. To be able to use a BufferedReader, the data that is read from the non-blocking socket is pushed in the QueueInputStream, on which the BufferedReader reads. The read blocks until new data is read from the socket and pushed in the QueueInputStream. This adds a new thread, but it simplifies the code and allows interrupting the reads.
Streaming works by having a background thread that continuously loops and get a packet from the packet provider and send this packet using the appropriate transport. If there are no packet ready, the thread blocks due to the provider blocking until a packet is available.
Therefore, this server uses 3 threads. One for the server (accept the connection, read from the non-blocking socket and push the new data in the QueueInputStream), one for the Rtsp Request Reception (reads from the QueueInputStream, process the received request and blocks when no more data to read) and one for the Rtp packets transfer (blocks when no packets available).
| com.tritondigital.net.streaming.proxy.server.rtsp.RtspServer.RtspServer | ( | ) |
Constructs a RTSP Server that streams the data from the given provider.
The new instance needs to have a source set (setDataProvider) before it starts listening. Use blockUntilReady before starting to listen to avoid delays in responses.
| void com.tritondigital.net.streaming.proxy.server.rtsp.RtspServer.bindAndListen | ( | final int | port | ) |
Reimplemented from com.tritondigital.net.streaming.proxy.server.Server.
|
protected |
Reimplemented from com.tritondigital.net.streaming.proxy.server.Server.
| URI com.tritondigital.net.streaming.proxy.server.rtsp.RtspServer.getUri | ( | ) |
Reimplemented from com.tritondigital.net.streaming.proxy.server.Server.
|
protected |
Reimplemented from com.tritondigital.net.streaming.proxy.server.Server.
| void com.tritondigital.net.streaming.proxy.server.rtsp.RtspServer.setDataProvider | ( | DataProvider | rtpPacketProvider | ) |
Sets the RTSP Server to streams the data from the given provider.
Ignored if the server is already listening or connected. Use blockUntilReady or wait for the onServerReady notification after the provider changes and before starting to listen to avoid delays in responses.
| rtpPacketProvider | Source of the packets to transmit. |
Reimplemented from com.tritondigital.net.streaming.proxy.server.Server.