sipxmedialib  Version 3.3
Public Types | Protected Attributes | Private Member Functions | List of all members
MprDejitter Class Reference

The "Dejitter" utility class. More...

#include <MprDejitter.h>

Collaboration diagram for MprDejitter:
Collaboration graph
[legend]

Public Types

enum  { MAX_RTP_PACKETS = 256 }
 

Public Member Functions

Creators
 MprDejitter (MpConnectionID connId=MP_INVALID_CONNECTION_ID, int streamId=-1)
 Constructor. More...
 
virtual ~MprDejitter ()
 Destructor. More...
 
Manipulators
void reset ()
 Reset dejitter to initial state and prepare for new stream. More...
 
OsStatus pushPacket (MpRtpBufPtr &pRtp)
 Add an incoming RTP packet to the dejitter pool. More...
 
MpRtpBufPtr pullPacket ()
 Get next RTP packet, or NULL if none is available. More...
 
MpRtpBufPtr pullPacket (RtpTimestamp timestamp, UtlBoolean *nextFrameAvailable=NULL, bool lockTimestamp=true)
 Get next RTP packet with given timestamp, or NULL if none is available. More...
 
void setConnectionId (MpConnectionID connId)
 Set connection ID for debug purposes. More...
 
void setStreamId (int streamId)
 Set RTP stream ID for debug purposes. More...
 
void setFlowgrapName (const UtlString &fgName)
 Set flowgraph name for debug purposes. More...
 
Accessors
int getNumPackets () const
 Get number of packets in buffer, arrived in time. More...
 
int getNumLatePackets () const
 Get number of late packets in buffer. More...
 
OsStatus getFirstPacketInfo (RtpSeq &packetSeq, RtpTimestamp &packetTime) const
 Get RTP header info. for first sequentially available packet. More...
 

Protected Attributes

MpRtpBufPtr mpPackets [MAX_RTP_PACKETS]
 Buffer for incoming RTP packets. More...
 
int mNumPackets
 Number of packets in buffer, arrived in time. More...
 
int mNumLatePackets
 Number of packets in buffer, arrived late. More...
 
int mNumDiscarded
 Number of packets overwritten with newly came packets. More...
 
int mLastPushed
 Index of the last inserted packet. More...
 
UtlBoolean mIsFirstPulledPacket
 Have we returned first RTP packet or not? More...
 
RtpSeq mMaxPulledSeqNo
 
MpConnectionID mConnectionId
 Connection ID for debug purposes. More...
 
int mStreamId
 RTP stream ID for debug purposes. More...
 
UtlString mFlowgraphName
 Parent flowgraph for debug purposes. More...
 
UtlString mResourceName
 Resource name for debug purposes. More...
 

Private Member Functions

 MprDejitter (const MprDejitter &rMprDejitter)
 Copy constructor (not implemented for this class) More...
 
MprDejitteroperator= (const MprDejitter &rhs)
 Assignment operator (not implemented for this class) More...
 

Detailed Description

The "Dejitter" utility class.

This class is not thread-safe. For thread-safety it relies on external synchronization mechanisms in MprDecode.

Member Enumeration Documentation

anonymous enum
Enumerator
MAX_RTP_PACKETS 

Could be any value, power of 2 is desired.

Constructor & Destructor Documentation

MprDejitter ( MpConnectionID  connId = MP_INVALID_CONNECTION_ID,
int  streamId = -1 
)

Constructor.

~MprDejitter ( )
virtual

Destructor.

MprDejitter ( const MprDejitter rMprDejitter)
private

Copy constructor (not implemented for this class)

Member Function Documentation

void reset ( )

Reset dejitter to initial state and prepare for new stream.

OsStatus pushPacket ( MpRtpBufPtr pRtp)

Add an incoming RTP packet to the dejitter pool.

This method places the packet to the pool depending the modulo division value.

Warning
This method swaps pRtp with some other packet in the dejitter buffer. So you should dispose pRtp pointer asap after calling this method.
Returns
OS_SUCCESS on success
OS_LIMIT_REACHED if too many codecs used in incoming RTP packets
MpRtpBufPtr pullPacket ( )

Get next RTP packet, or NULL if none is available.

This buffer is the primary dejitter/reorder buffer for the internal codecs. Some codecs may do their own dejitter stuff too. But we can't eliminate this buffer because then out-of-order packets would just be dumped on the ground.

This buffer does NOT substitute silence packets. That is done in MpJitterBuffer called from MprDecode.

If packets arrive out of order, and the newer packet has already been pulled due to the size of the jitter buffer set by the codec, this buffer will NOT discard the out-of-order packet, but send it along anyway it is up to the codec to discard the packets it cannot use. This allows this JB to be a no-op buffer for when the commercial library is used.

If pulled packet belong to signaling codec (e.g. RFC2833 DTMF), then set isSignaling to true. Else packet will be hold for undefined amount of time, possible forever.

MpRtpBufPtr pullPacket ( RtpTimestamp  timestamp,
UtlBoolean *  nextFrameAvailable = NULL,
bool  lockTimestamp = true 
)

Get next RTP packet with given timestamp, or NULL if none is available.

This version of pullPacket() works exactly the same as above version of pullPacket() with one exception: if (lockTimestamp == true) it checks every found packet's timestamp. And return NULL if there are no packets with timestamp less or equal then passed timestamp.

If pulled packet belong to signaling codec (e.g. RFC2833 DTMF), then set isSignaling to true. Else packet will be hold for undefined amount of time, possible forever.

< RTP packet we will return

void setConnectionId ( MpConnectionID  connId)

Set connection ID for debug purposes.

void setStreamId ( int  streamId)

Set RTP stream ID for debug purposes.

void setFlowgrapName ( const UtlString &  fgName)

Set flowgraph name for debug purposes.

int getNumPackets ( ) const
inline

Get number of packets in buffer, arrived in time.

int getNumLatePackets ( ) const
inline

Get number of late packets in buffer.

OsStatus getFirstPacketInfo ( RtpSeq packetSeq,
RtpTimestamp packetTime 
) const

Get RTP header info. for first sequentially available packet.

MprDejitter& operator= ( const MprDejitter rhs)
private

Assignment operator (not implemented for this class)

Member Data Documentation

MpRtpBufPtr mpPackets[MAX_RTP_PACKETS]
protected

Buffer for incoming RTP packets.

int mNumPackets
protected

Number of packets in buffer, arrived in time.

int mNumLatePackets
protected

Number of packets in buffer, arrived late.

int mNumDiscarded
protected

Number of packets overwritten with newly came packets.

int mLastPushed
protected

Index of the last inserted packet.

UtlBoolean mIsFirstPulledPacket
protected

Have we returned first RTP packet or not?

RtpSeq mMaxPulledSeqNo
protected

Keep track of the last sequence number returned, so that we can distinguish out-of-order packets.

MpConnectionID mConnectionId
protected

Connection ID for debug purposes.

int mStreamId
protected

RTP stream ID for debug purposes.

UtlString mFlowgraphName
protected

Parent flowgraph for debug purposes.

UtlString mResourceName
protected

Resource name for debug purposes.