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.rtp.RtpPacketProvider Class Referenceabstract
Inheritance diagram for com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider:
com.tritondigital.net.streaming.proxy.dataprovider.DataProvider com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProviderMpeg4Generic

Classes

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 onAudioConfigDecoded (AudioConfig audioConfig)
 Save the AudioConfig and notify / unblock the listeners and threads waiting for it to become ready.
 
void onAudioDataDecoded (byte[] audioData, int audioDataLength, int timestamp)
 
String getSdpConfig (String absControlUrl)
 Returns the SDP string to be sent by the RTSP server in response to a Describe request.
 
void stop ()
 In addition to the default stop, Resets the Sdp Config state to make sure to block the next time that this provider is used, until the SdpConfig is ready again.
 
void stopBlockingUntilAudioConfigReady ()
 Unblock the thread waiting on a call to blockUntilReady.
 
boolean isSdpConfigReady ()
 Tells if the SDP strings can be retrieved without blocking.
 
short getFirstPacketSequenceNumber ()
 Gets the sequence number that the first packet in the queue has (or will have when it is inserted).
 
int getFirstPacketTimestamp ()
 Gets the timestamp that the first packet in the queue has (or will have when it is inserted).
 
void setStateChangedListener (StateChangedListener stateChangedListener)
 Sets the listener to be notified by any state change on this provider.
 
- Public Member Functions inherited from com.tritondigital.net.streaming.proxy.dataprovider.DataProvider
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.
 

Public Attributes

final String TAG = "RtpPacketProvider"
 

Protected Member Functions

Packet createEmptyPacket ()
 
abstract int getPayloadSize (int audioDataLength)
 Gets the minimal size that the bytes array containing the payload should have.
 
abstract void createPayload (byte[] audioData, int audioDataLength, byte[] outPayload, int outPayloadOffset)
 
abstract String getProfileSpecificSdpConfig ()
 Returns the SDP string lines that are related to the profile itself.
 
int getRtpTimestamp (int timestampMS)
 Compute the RTP timestamp, which is the number of samples since the beginning of the stream.
 
void notifyListenerSdpConfigReady ()
 Notifies listener that the SDP Config can now be produced without blocking.
 
void notifyListenerError (ErrorDetail errorDetail)
 Notifies listener that an unrecoverable error has been encountered.
 
- Protected Member Functions inherited from com.tritondigital.net.streaming.proxy.dataprovider.DataProvider
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.
 

Protected Attributes

AudioConfig mAudioConfig
 
short mNextPacketSequenceNumber = 0
 Increments by one for each new packet that is pushed in the queue.
 
- Protected Attributes inherited from com.tritondigital.net.streaming.proxy.dataprovider.DataProvider
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)
 

Static Protected Attributes

static final String LOCALHOST = "127.0.0.1"
 
static final String CRLF = "\r\n"
 

Detailed Description

Base class for different kind of Rtp packets provider. The structure of the Rtp packet is almost identical between each type of provider and follows the RFC 3550 (http://www.ietf.org/rfc/rfc3550.txt), but the payload differs.

This class provides Rtp packets, adds functionality that are specific to Rtp streaming such as the SDP Configuration for the RTSP DESCRIBE response.

Typically, the subclass only overrides getProfileSpecificSdpConfig to tell the Sdp lines for the particular payload type, getPayloadSize and createPayload to create this payload with the good type and optionally onAudioConfigDecoded if it needs to make checks on the config or convert the config to a specific format.

Member Function Documentation

◆ createEmptyPacket()

Packet com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider.createEmptyPacket ( )
protected

◆ createPayload()

abstract void com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider.createPayload ( byte[]  audioData,
int  audioDataLength,
byte[]  outPayload,
int  outPayloadOffset 
)
abstractprotected

Create the payload for RTP Packet with the appropriate profile.

Puts the content of the payload in the given preallocated output buffer and the given offset. This helps preventing new buffer copy by reusing the same bytes array for the output.

Parameters
audioDataThe data to put in the payload
audioDataLengthThe part of the AudioData buffer to use (buffer might be bigger if is is reused)
outPayloadReference to a byte array preallocated with enough memory (at least the size returned by getPayloadSize)
outPayloadOffsetOffset at which the payload will be written in outPayload, allowing to create a header before the payload.

Reimplemented in com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProviderMpeg4Generic.

◆ getFirstPacketSequenceNumber()

short com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider.getFirstPacketSequenceNumber ( )

Gets the sequence number that the first packet in the queue has (or will have when it is inserted).

This is typically used for the RTP server to fill the RTP-INFO line of the PLAY response.

◆ getFirstPacketTimestamp()

int com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider.getFirstPacketTimestamp ( )

Gets the timestamp that the first packet in the queue has (or will have when it is inserted).

This is typically used for the RTP server to fill the RTP-INFO line of the PLAY response.

◆ getProfileSpecificSdpConfig()

abstract String com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider.getProfileSpecificSdpConfig ( )
abstractprotected

Returns the SDP string lines that are related to the profile itself.

This is guaranteed to be only called after the AudioConfig has been received, the calling thread will be blocked until it is received.

◆ getRtpTimestamp()

int com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider.getRtpTimestamp ( int  timestampMS)
protected

Compute the RTP timestamp, which is the number of samples since the beginning of the stream.

Multiply timestamp by the sampling rate to have a good approximation.

Parameters
timestampMSThe timestamp in ms of the first sample in the packet.
Returns
The number of samples played before the first sample of the packet, based on the time and the sampling rate.

◆ getSdpConfig()

String com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider.getSdpConfig ( String  absControlUrl)

Returns the SDP string to be sent by the RTSP server in response to a Describe request.

It includes common configurations from the RFC 2327 (http://www.ietf.org/rfc/rfc2327.txt) added to those specific to the profile used to form the RTP Packets payload. The returned string is ready to be sent to the RTSP client (correctly formatted, contains CR + LF for end of line characters, etc.)

◆ isSdpConfigReady()

boolean com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider.isSdpConfigReady ( )

Tells if the SDP strings can be retrieved without blocking.

It is assumed that once the AudioConfig has been received, all mandatory information are available. Thus, this method returns false until the AudioConfig has been received from the protocol container decoder.

◆ notifyListenerError()

void com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider.notifyListenerError ( ErrorDetail  errorDetail)
protected

Notifies listener that an unrecoverable error has been encountered.

Called by the subclasses to indicate that the provider has encountered an error that forces it to interrupt its processing.

◆ notifyListenerSdpConfigReady()

void com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider.notifyListenerSdpConfigReady ( )
protected

Notifies listener that the SDP Config can now be produced without blocking.

Called by the subclasses to indicate that the provider has received enough data and is ready to be used as the source for streaming.

◆ onAudioConfigDecoded()

void com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider.onAudioConfigDecoded ( AudioConfig  audioConfig)

Save the AudioConfig and notify / unblock the listeners and threads waiting for it to become ready.

Subclasses should always call this method on their super class if they override it. It is recommended to call the 'super' version at the end of the overriden method, as it notifies the listeners and unblock threads waiting for the SDPConfig to become available.

◆ stop()

void com.tritondigital.net.streaming.proxy.dataprovider.rtp.RtpPacketProvider.stop ( )

In addition to the default stop, Resets the Sdp Config state to make sure to block the next time that this provider is used, until the SdpConfig is ready again.

Reimplemented from com.tritondigital.net.streaming.proxy.dataprovider.DataProvider.


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