# OpalJitterBuffer Class Reference

`#include <jitter.h>`

Inheritance diagram for OpalJitterBuffer:

List of all members.

## Public Member Functions

| OpalJitterBuffer (unsigned minJitterDelay, unsigned maxJitterDelay, unsigned timeUnits=8, PINDEX stackSize=30000)
virtual | ~OpalJitterBuffer ()
void | PrintOn (ostream &strm) const
virtual PBoolean | OnReadPacket (RTP_DataFrame &frame, PBoolean loop)=0
void | SetDelay (unsigned minJitterDelay, unsigned maxJitterDelay)
void | UseImmediateReduction (PBoolean state)
virtual PBoolean | ReadData (RTP_DataFrame &frame)
DWORD | GetJitterTime () const
unsigned | GetTimeUnits () const
DWORD | GetPacketsTooLate () const
DWORD | GetBufferOverruns () const
DWORD | GetMaxConsecutiveMarkerBits () const
void | SetMaxConsecutiveMarkerBits (DWORD max)
virtual void | Resume (PHandleAggregator *aggregator=NULL)
| PDECLARE_NOTIFIER (PThread, OpalJitterBuffer, JitterThreadMain)
PBoolean | WaitForTermination (const PTimeInterval &t)
bool | IsEmpty ()

## Protected Member Functions

void | Start (unsigned _minJitterTime, unsigned _maxJitterTime)
Entry * | GetNewest (bool pop)
Entry * | GetOldest (bool pop)
PBoolean | Init (Entry *&currentReadFrame, PBoolean &markerWarning)
PBoolean | PreRead (Entry *&currentReadFrame, PBoolean &markerWarning)
PBoolean | OnRead (Entry *&currentReadFrame, PBoolean &markerWarning, PBoolean loop)
void | DeInit (Entry *&currentReadFrame, PBoolean &markerWarning)

## Protected Attributes

PINDEX | bufferSize
DWORD | minJitterTime
DWORD | maxJitterTime
DWORD | maxConsecutiveMarkerBits
unsigned | timeUnits
DWORD | currentJitterTime
DWORD | packetsTooLate
unsigned | bufferOverruns
unsigned | consecutiveBufferOverruns
DWORD | consecutiveMarkerBits
PTimeInterval | consecutiveEarlyPacketStartTime
DWORD | lastWriteTimestamp
PTimeInterval | lastWriteTick
DWORD | jitterCalc
DWORD | targetJitterTime
unsigned | jitterCalcPacketCount
bool | doJitterReductionImmediately
FrameQueue | freeFrames
FrameQueue | jitterBuffer
Entry * | currentFrame
PMutex | bufferMutex
bool | shuttingDown
bool | preBuffering
bool | firstReadData
RTP_JitterBufferAnalyser * | analyser
PThread * | jitterThread
PINDEX | jitterStackSize

## Classes

class | Entry
class | FrameQueue

## Detailed Description

This is an Abstract jitter buffer, which can be used simply in any application. The user is required to use a descendant of this class, and provide a "OnReadPacket" method, so that network packets can be placed in this class instance

## Constructor & Destructor Documentation

OpalJitterBuffer::OpalJitterBuffer | ( | unsigned | minJitterDelay,
|  | unsigned | maxJitterDelay,
|  | unsigned | timeUnits = `8`,
|  | PINDEX | stackSize = `30000` |
| ) |  |  |

Constructor for this jitter buffer. The size of this buffer can be altered later with the SetDelay method

Parameters:

  minJitterDelay | Minimum delay in RTP timestamp units
  maxJitterDelay | Maximum delay in RTP timestamp units
  timeUnits | Time units, usually 8 or 16
  stackSize | Stack size for jitter thread

virtual OpalJitterBuffer::~OpalJitterBuffer | ( |  | ) | `[virtual]`

Destructor, which closes this down and deletes the internal list of frames

## Member Function Documentation

void OpalJitterBuffer::PrintOn | ( | ostream & | strm | ) | const

Report the statistics for this jitter instance

virtual PBoolean OpalJitterBuffer::OnReadPacket | ( | RTP_DataFrame & | frame,
|  | PBoolean | loop |
| ) |  |  | `[pure virtual]`

This method is where this OpalJitterBuffer collects data from the outside world. A descendant class of OpalJitterBuffer will override this method

Returns:
  PTrue on successful read, PFalse on faulty read.

Parameters:

  frame | Frame read from the RTP session
  loop | If PTrue, loop as long as data is available, if PFalse, only process once

Implemented in IAX2JitterBuffer, and RTP_JitterBuffer.

void OpalJitterBuffer::SetDelay | ( | unsigned | minJitterDelay,
|  | unsigned | maxJitterDelay |
| ) |  |  |

Set the maximum delay the jitter buffer will operate to.

Parameters:

  minJitterDelay | Minimum delay in RTP timestamp units
  maxJitterDelay | Maximum delay in RTP timestamp units

void OpalJitterBuffer::UseImmediateReduction | ( | PBoolean | state | ) | `[inline]`

virtual PBoolean OpalJitterBuffer::ReadData | ( | RTP_DataFrame & | frame | ) | `[virtual]`

Read a data frame from the RTP channel. Any control frames received are dispatched to callbacks and are not returned by this function. It will block until a data frame is available or an error occurs.

Parameters:

  frame | Frame read from the RTP session

DWORD OpalJitterBuffer::GetJitterTime | ( |  | ) | const`[inline]`

Get current delay for jitter buffer.

unsigned OpalJitterBuffer::GetTimeUnits | ( |  | ) | const`[inline]`

Get time units.

DWORD OpalJitterBuffer::GetPacketsTooLate | ( |  | ) | const`[inline]`

Get total number received packets too late to go into jitter buffer.

DWORD OpalJitterBuffer::GetBufferOverruns | ( |  | ) | const`[inline]`

Get total number received packets that overran the jitter buffer.

DWORD OpalJitterBuffer::GetMaxConsecutiveMarkerBits | ( |  | ) | const`[inline]`

Get maximum consecutive marker bits before buffer starts to ignore them.

void OpalJitterBuffer::SetMaxConsecutiveMarkerBits | ( | DWORD | max | ) | `[inline]`

Set maximum consecutive marker bits before buffer starts to ignore them.

virtual void OpalJitterBuffer::Resume | ( | PHandleAggregator * | aggregator = `NULL` | ) | `[virtual]`

Start jitter thread

OpalJitterBuffer::PDECLARE_NOTIFIER | ( | PThread | ,
|  | OpalJitterBuffer | ,
|  | JitterThreadMain |  |
| ) |  |  |

PBoolean OpalJitterBuffer::WaitForTermination | ( | const PTimeInterval & | t | ) | `[inline]`

bool OpalJitterBuffer::IsEmpty | ( |  | ) | `[inline]`

void OpalJitterBuffer::Start | ( | unsigned | _minJitterTime,
|  | unsigned | _maxJitterTime |
| ) |  |  | `[protected]`

Entry* OpalJitterBuffer::GetNewest | ( | bool | pop | ) | `[inline, protected]`

Entry* OpalJitterBuffer::GetOldest | ( | bool | pop | ) | `[inline, protected]`

PBoolean OpalJitterBuffer::Init | ( | Entry *& | currentReadFrame,
|  | PBoolean & | markerWarning |
| ) |  |  | `[protected]`

PBoolean OpalJitterBuffer::PreRead | ( | Entry *& | currentReadFrame,
|  | PBoolean & | markerWarning |
| ) |  |  | `[protected]`

PBoolean OpalJitterBuffer::OnRead | ( | Entry *& | currentReadFrame,
|  | PBoolean & | markerWarning,
|  | PBoolean | loop |
| ) |  |  | `[protected]`

void OpalJitterBuffer::DeInit | ( | Entry *& | currentReadFrame,
|  | PBoolean & | markerWarning |
| ) |  |  | `[protected]`

## Member Data Documentation

PINDEX OpalJitterBuffer::bufferSize `[protected]`

DWORD OpalJitterBuffer::minJitterTime `[protected]`

DWORD OpalJitterBuffer::maxJitterTime `[protected]`

DWORD OpalJitterBuffer::maxConsecutiveMarkerBits `[protected]`

unsigned OpalJitterBuffer::timeUnits `[protected]`

DWORD OpalJitterBuffer::currentJitterTime `[protected]`

DWORD OpalJitterBuffer::packetsTooLate `[protected]`

unsigned OpalJitterBuffer::bufferOverruns `[protected]`

unsigned OpalJitterBuffer::consecutiveBufferOverruns `[protected]`

DWORD OpalJitterBuffer::consecutiveMarkerBits `[protected]`

PTimeInterval OpalJitterBuffer::consecutiveEarlyPacketStartTime `[protected]`

DWORD OpalJitterBuffer::lastWriteTimestamp `[protected]`

PTimeInterval OpalJitterBuffer::lastWriteTick `[protected]`

DWORD OpalJitterBuffer::jitterCalc `[protected]`

DWORD OpalJitterBuffer::targetJitterTime `[protected]`

unsigned OpalJitterBuffer::jitterCalcPacketCount `[protected]`

bool OpalJitterBuffer::doJitterReductionImmediately `[protected]`

FrameQueue OpalJitterBuffer::freeFrames `[protected]`

FrameQueue OpalJitterBuffer::jitterBuffer `[protected]`

Entry* OpalJitterBuffer::currentFrame `[protected]`

PMutex OpalJitterBuffer::bufferMutex `[protected]`

bool OpalJitterBuffer::shuttingDown `[protected]`

bool OpalJitterBuffer::preBuffering `[protected]`

bool OpalJitterBuffer::firstReadData `[protected]`

RTP_JitterBufferAnalyser* OpalJitterBuffer::analyser `[protected]`

PThread* OpalJitterBuffer::jitterThread `[protected]`

PINDEX OpalJitterBuffer::jitterStackSize `[protected]`

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

- jitter.h