OPAL  Version 3.18.8
OpalBaseMixer Class Referenceabstract

#include <opalmixer.h>

Inheritance diagram for OpalBaseMixer:
Collaboration diagram for OpalBaseMixer:

Data Structures

struct  Stream
 

Public Types

typedef PString Key_T
 

Public Member Functions

 OpalBaseMixer (bool pushThread, unsigned periodMS, unsigned periodTS)
 
virtual ~OpalBaseMixer ()
 
virtual bool AddStream (const Key_T &key)
 
virtual void RemoveStream (const Key_T &key)
 
virtual void RemoveAllStreams ()
 
virtual bool WriteStream (const Key_T &key, const RTP_DataFrame &input)
 
virtual RTP_DataFrameReadMixed ()
 
virtual bool ReadMixed (RTP_DataFrame &mixed)
 
virtual bool OnMixed (RTP_DataFrame *&mixed)
 
virtual void StartPushThread ()
 
virtual bool OnPush ()
 
void StopPushThread (bool lock=true)
 
unsigned GetPeriodMS () const
 
unsigned GetPeriodTS () const
 

Protected Types

typedef std::map< Key_T, Stream * > StreamMap_T
 

Protected Member Functions

virtual StreamCreateStream ()=0
 
virtual bool MixStreams (RTP_DataFrame &frame)=0
 
virtual size_t GetOutputSize () const =0
 
void PushThreadMain ()
 
 PDECLARE_MUTEX (m_mutex)
 

Protected Attributes

bool m_pushThread
 
unsigned m_periodMS
 
unsigned m_periodTS
 
StreamMap_T m_inputStreams
 
unsigned m_outputTimestamp
 
RTP_DataFramem_pushFrame
 
PThread * m_workerThread
 
bool m_threadRunning
 

Detailed Description

Class base for a media mixer.

The mixer operates by re-buffering the input media into chunks each with an associated timestamp. A main mixer thread then reads from each stream at regular intervals, mixes the media and creates the output buffer.

Note the timestamps of the input media are extremely important as they are used so that breaks or too fast data in the input media is dealt with correctly.

Member Typedef Documentation

typedef PString OpalBaseMixer::Key_T
typedef std::map<Key_T, Stream *> OpalBaseMixer::StreamMap_T
protected

Constructor & Destructor Documentation

OpalBaseMixer::OpalBaseMixer ( bool  pushThread,
unsigned  periodMS,
unsigned  periodTS 
)
Parameters
pushThreadIndicate if the push thread should be started
periodMSThe output buffer time in milliseconds
periodTSThe output buffer time in RTP timestamp units
virtual OpalBaseMixer::~OpalBaseMixer ( )
virtual

Member Function Documentation

virtual bool OpalBaseMixer::AddStream ( const Key_T key)
virtual

Add a stream to mixer using the specified key.

Parameters
keykey for mixer stream
virtual Stream* OpalBaseMixer::CreateStream ( )
protectedpure virtual

Implemented in OpalVideoMixer, and OpalAudioMixer.

virtual size_t OpalBaseMixer::GetOutputSize ( ) const
protectedpure virtual

Implemented in OpalVideoMixer, and OpalAudioMixer.

unsigned OpalBaseMixer::GetPeriodMS ( ) const
inline

Get the period for mixing in milliseconds.

References m_periodMS.

unsigned OpalBaseMixer::GetPeriodTS ( ) const
inline

Get the period for mixing in RTP timestamp units.

References m_periodTS.

virtual bool OpalBaseMixer::MixStreams ( RTP_DataFrame frame)
protectedpure virtual

Implemented in OpalVideoMixer, and OpalAudioMixer.

virtual bool OpalBaseMixer::OnMixed ( RTP_DataFrame *&  mixed)
virtual

Mixed data is now available. For a push model system, this is called with mixed data as returned by ReadMixed().

The "mixed" parameter is a reference to a pointer, so if the consumer wishes to take responsibility for deleting the pointer to an RTP data frame, then they can set it to NULL.

If false is returned then the push thread is exited.

Parameters
mixedPointer to mixed media.

Reimplemented in OpalVideoStreamMixer.

virtual bool OpalBaseMixer::OnPush ( )
virtual

Push collected input through the mixer to output. This would normally be called from a thread, on a metronomic basis, from a thread started via StartPushThread(), however if m_pushThread is false, that thread is suppressed and it is expected the application would call this function as required.

Reimplemented in OpalAudioStreamMixer.

OpalBaseMixer::PDECLARE_MUTEX ( m_mutex  )
protected
void OpalBaseMixer::PushThreadMain ( )
protected
virtual RTP_DataFrame* OpalBaseMixer::ReadMixed ( )
virtual

Read media from mixer. A pull model system would call this function to get the mixed media from the mixer. Note the stream indicated by the streamToIgnore key is not included in the mixing operation, allowing for example, the member of a conference to not hear themselves.

Note this function is the function that does all the "heavy lifting" for the mixer.

virtual bool OpalBaseMixer::ReadMixed ( RTP_DataFrame mixed)
virtual
virtual void OpalBaseMixer::RemoveAllStreams ( )
virtual

Remove all input streams from mixer.

Reimplemented in OpalAudioMixer.

virtual void OpalBaseMixer::RemoveStream ( const Key_T key)
virtual

Remove an input stream from mixer.

Parameters
keykey for mixer stream

Reimplemented in OpalAudioMixer.

virtual void OpalBaseMixer::StartPushThread ( )
virtual

Start the push thread. Normally called internally.

void OpalBaseMixer::StopPushThread ( bool  lock = true)

Stop the push thread. This will wait for th epush thread to terminate, so care must be taken to avoid deadlocks when calling.

Referenced by OpalAudioMixer::~OpalAudioMixer(), and OpalVideoMixer::~OpalVideoMixer().

virtual bool OpalBaseMixer::WriteStream ( const Key_T key,
const RTP_DataFrame input 
)
virtual

Write an RTP data frame to mixer. A copy of the RTP data frame is created. This function is generally quite fast as the actual mixing is done in a different thread so minimal interference with the normal media stream processing occurs.

Parameters
keykey for mixer stream
inputInput RTP data for media

Field Documentation

StreamMap_T OpalBaseMixer::m_inputStreams
protected
unsigned OpalBaseMixer::m_outputTimestamp
protected
unsigned OpalBaseMixer::m_periodMS
protected
unsigned OpalBaseMixer::m_periodTS
protected

Referenced by GetPeriodTS().

RTP_DataFrame* OpalBaseMixer::m_pushFrame
protected
bool OpalBaseMixer::m_pushThread
protected
bool OpalBaseMixer::m_threadRunning
protected
PThread* OpalBaseMixer::m_workerThread
protected

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