OPAL
Version 3.14.3
|
#include <opalmixer.h>
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_DataFrame * | ReadMixed () |
virtual bool | ReadMixed (RTP_DataFrame &mixed) |
virtual bool | OnMixed (RTP_DataFrame *&mixed) |
void | StartPushThread () |
void | StopPushThread (bool lock=true) |
unsigned | GetPeriodTS () const |
Protected Types | |
typedef std::map< Key_T, Stream * > | StreamMap_T |
Protected Member Functions | |
virtual Stream * | CreateStream ()=0 |
virtual bool | MixStreams (RTP_DataFrame &frame)=0 |
virtual size_t | GetOutputSize () const =0 |
virtual bool | OnPush () |
void | PushThreadMain () |
Protected Attributes | |
bool | m_pushThread |
unsigned | m_periodMS |
unsigned | m_periodTS |
StreamMap_T | m_inputStreams |
unsigned | m_outputTimestamp |
RTP_DataFrame * | m_pushFrame |
PThread * | m_workerThread |
bool | m_threadRunning |
PMutex | m_mutex |
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.
typedef PString OpalBaseMixer::Key_T |
|
protected |
OpalBaseMixer::OpalBaseMixer | ( | bool | pushThread, |
unsigned | periodMS, | ||
unsigned | periodTS | ||
) |
pushThread | Indicate if the push thread should be started |
periodMS | The output buffer time in milliseconds |
periodTS | The output buffer time in RTP timestamp units |
|
virtual |
|
virtual |
Add a stream to mixer using the specified key.
key | key for mixer stream |
|
protectedpure virtual |
Implemented in OpalVideoMixer, and OpalAudioMixer.
|
protectedpure virtual |
Implemented in OpalVideoMixer, and OpalAudioMixer.
|
inline |
Get the period for mixing in RTP timestamp units.
References m_periodTS.
|
protectedpure virtual |
Implemented in OpalVideoMixer, and OpalAudioMixer.
|
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.
mixed | Pointer to mixed media. |
Reimplemented in OpalVideoStreamMixer.
|
protectedvirtual |
Reimplemented in OpalAudioStreamMixer.
|
protected |
|
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 |
|
virtual |
Remove all input streams from mixer.
Reimplemented in OpalAudioMixer.
|
virtual |
Remove an input stream from mixer.
key | key for mixer stream |
Reimplemented in OpalAudioMixer.
void OpalBaseMixer::StartPushThread | ( | ) |
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 |
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.
key | key for mixer stream |
input | Input RTP data for media |
|
protected |
|
protected |
|
protected |
|
protected |
Referenced by OpalVideoMixer::GetFrameRate().
|
protected |
Referenced by GetPeriodTS().
|
protected |
|
protected |
|
protected |
|
protected |