|
Triton Mobile SDK for Android 3.5.1
This is a custom android player made by Triton Digital
|
Base class for different kind of Data packets provider. More...
Public Member Functions | |
| void | stop () |
| Interrupts any operation and clear the packets queue. | |
| Packet | getPacket () |
| Returns the next Packet in the stream. | |
| void | addFreePacketToPool (Packet packet) |
| Puts the given packet back in the free pool packets. | |
| void | clearInternalBuffer () |
| If the provider keeps a buffer of already available packets, clear it immediately. | |
Protected Member Functions | |
| Packet | getFreePacket () |
| Returns a free packet to use for the creation of a new packet. | |
| void | enqueuePacket (Packet packet) |
| Enqueue a Packet to be sent to the server. | |
| abstract Packet | createEmptyPacket () |
| Create an empty packet of the expected type by the subclass. | |
Protected Attributes | |
| final ArrayBlockingQueue< Packet > | mPacketsQueue = new ArrayBlockingQueue<>(QUEUE_SIZE) |
| List of all packets that were received from the client and not sent to the server yet. | |
| final ArrayBlockingQueue< Packet > | mFreePacketsPool = new ArrayBlockingQueue<>(QUEUE_SIZE) |
Base class for different kind of Data packets provider.
This class implements the StreamContainerDeccoder.AudioDataDecodedListener interface, it is notified as soon as new data is ready to be packetized, then is creates a new packet from this data and enqueues it. It maintains an internal queue of packets to be able to create multiple packets and keep them until the server transmits them. This queue is thread-safe and has a fixed size. Trying to add new packets when it is full will block the thread, which might cause some packets to drop on the StreamContainerDeccoder side. Trying to get a packet when queue is empty will also block the calling thread until a new packet is available.
Ideally, the server will consume / transmit the packets at the same rate as they are reveived from the StreamContainerDeccoder, to avoid buffer underrun (queue is empty) or overrun (queue is full), which is both case will block a thread.
A subclass that wants to be efficient should never create Packets directly. Instead, it should request a free packet using getFreePacket, which will take a packet from the free packets pool or create a new one if necessary. Similarily, the class that takes the packets using getPacket should put back the packet in the free packets pool for reuse when it is done with it by calling addFreePacketToPool.
| void com.tritondigital.net.streaming.proxy.dataprovider.DataProvider.clearInternalBuffer | ( | ) |
If the provider keeps a buffer of already available packets, clear it immediately.
Typically invoked before the proxy starts the client, to remove the old data that could have been still present in the buffer.
|
protected |
Enqueue a Packet to be sent to the server.
Blocks if the queue is full.
|
protected |
Returns a free packet to use for the creation of a new packet.
Creates a new one if none are available.
| Packet com.tritondigital.net.streaming.proxy.dataprovider.DataProvider.getPacket | ( | ) |
Returns the next Packet in the stream.
If none are available, blocks until new data arrives and is properly wrapped in the appropriate packet format (e.g. RTP). Returns null if no packets after a given timeout.
| void com.tritondigital.net.streaming.proxy.dataprovider.DataProvider.stop | ( | ) |
Interrupts any operation and clear the packets queue.
Clears the internal buffer at the same time.
Reimplemented in com.tritondigital.net.streaming.proxy.dataprovider.raw.RawPacketProvider, and com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider.
|
protected |
List of all packets that were received from the client and not sent to the server yet.
This list gets bigger when a burst is received and when the client is connected but not the server. On the contrary, it gets smaller if the client disconnects or if the conversion of the data received to destination packet format (e.g. RTP) takes more than the server's expected bitrate.