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.dataprovider.DataProvider Class Referenceabstract

Base class for different kind of Data packets provider. More...

Inheritance diagram for com.tritondigital.net.streaming.proxy.dataprovider.DataProvider:
com.tritondigital.net.streaming.proxy.dataprovider.raw.RawPacketProvider com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProviderMpeg4Generic

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< PacketmPacketsQueue = new ArrayBlockingQueue<>(QUEUE_SIZE)
 List of all packets that were received from the client and not sent to the server yet.
 
final ArrayBlockingQueue< PacketmFreePacketsPool = new ArrayBlockingQueue<>(QUEUE_SIZE)
 

Detailed Description

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.

Member Function Documentation

◆ clearInternalBuffer()

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.

◆ enqueuePacket()

void com.tritondigital.net.streaming.proxy.dataprovider.DataProvider.enqueuePacket ( Packet  packet)
protected

Enqueue a Packet to be sent to the server.

Blocks if the queue is full.

◆ getFreePacket()

Packet com.tritondigital.net.streaming.proxy.dataprovider.DataProvider.getFreePacket ( )
protected

Returns a free packet to use for the creation of a new packet.

Creates a new one if none are available.

◆ getPacket()

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.

◆ stop()

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.

Member Data Documentation

◆ mPacketsQueue

final ArrayBlockingQueue<Packet> com.tritondigital.net.streaming.proxy.dataprovider.DataProvider.mPacketsQueue = new ArrayBlockingQueue<>(QUEUE_SIZE)
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.


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