Triton Mobile SDK for Android 3.5.1
This is a custom android player made by Triton Digital
Loading...
Searching...
No Matches
com.tritondigital.net.streaming.proxy.server.http.HttpServer Class Reference
Inheritance diagram for com.tritondigital.net.streaming.proxy.server.http.HttpServer:
com.tritondigital.net.streaming.proxy.server.Server

Public Member Functions

 HttpServer ()
 Constructs a HTTP Server that streams the data from the given provider.
 
void bindAndListen (final int port)
 
void cleanUpConnectedSocket ()
 
void cleanUpListeningSocket ()
 
URI getUri ()
 
void setDataProvider (DataProvider rawPacketProvider)
 Sets the HTTP 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 HTTP 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"
 

Detailed Description

Implementation of a Server that responds to Http requests. The Server uses a socket to listen and negotiate the connection. It then streams using the already established TCP connection in response to an HTTP GET request.

The server listens and accepts a connection, the uses non-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, which a blocking socket does not.

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 Http Request Reception (reads from the QueueInputStream, process the received request and blocks when no more data to read) and one for the Audio packets transfer (blocks when no packets available).

Constructor & Destructor Documentation

◆ HttpServer()

com.tritondigital.net.streaming.proxy.server.http.HttpServer.HttpServer ( )

Constructs a HTTP 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.

Member Function Documentation

◆ bindAndListen()

void com.tritondigital.net.streaming.proxy.server.http.HttpServer.bindAndListen ( final int  port)

◆ disconnectAndUnbind()

void com.tritondigital.net.streaming.proxy.server.http.HttpServer.disconnectAndUnbind ( )
protected

◆ getUri()

URI com.tritondigital.net.streaming.proxy.server.http.HttpServer.getUri ( )

◆ onProcessMessage()

void com.tritondigital.net.streaming.proxy.server.http.HttpServer.onProcessMessage ( Object  userInfo)
protected

◆ setDataProvider()

void com.tritondigital.net.streaming.proxy.server.http.HttpServer.setDataProvider ( DataProvider  rawPacketProvider)

Sets the HTTP 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.

Parameters
rawPacketProviderSource of the packets to transmit.

Reimplemented from com.tritondigital.net.streaming.proxy.server.Server.


The documentation for this class was generated from the following file: