OPAL  Version 3.18.8
OpalAudioMixer Class Reference

#include <opalmixer.h>

Inheritance diagram for OpalAudioMixer:
Collaboration diagram for OpalAudioMixer:

Data Structures

struct  AudioStream
 

Public Member Functions

 OpalAudioMixer (bool stereo=false, unsigned sampleRate=OpalMediaFormat::AudioClockRate, bool pushThread=true, unsigned period=10)
 
 ~OpalAudioMixer ()
 
virtual void RemoveStream (const Key_T &key)
 
virtual void RemoveAllStreams ()
 
bool IsStereo () const
 
unsigned GetSampleRate () const
 
bool SetSampleRate (unsigned rate)
 
bool SetJitterBufferSize (const Key_T &key, const OpalJitterBuffer::Init &init)
 
- Public Member Functions inherited from OpalBaseMixer
 OpalBaseMixer (bool pushThread, unsigned periodMS, unsigned periodTS)
 
virtual ~OpalBaseMixer ()
 
virtual bool AddStream (const Key_T &key)
 
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 Member Functions

virtual StreamCreateStream ()
 
virtual bool MixStreams (RTP_DataFrame &frame)
 
virtual size_t GetOutputSize () const
 
void PreMixStreams ()
 
void MixStereo (RTP_DataFrame &frame)
 
void MixAdditive (RTP_DataFrame &frame, const short *audioToSubtract)
 
- Protected Member Functions inherited from OpalBaseMixer
void PushThreadMain ()
 
 PDECLARE_MUTEX (m_mutex)
 

Protected Attributes

bool m_stereo
 
unsigned m_sampleRate
 
AudioStreamm_left
 
AudioStreamm_right
 
std::vector< int > m_mixedAudio
 
- Protected Attributes inherited from OpalBaseMixer
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
 

Additional Inherited Members

- Public Types inherited from OpalBaseMixer
typedef PString Key_T
 
- Protected Types inherited from OpalBaseMixer
typedef std::map< Key_T, Stream * > StreamMap_T
 

Detailed Description

Class for an audio mixer. This takes raw PCM-16 data and sums all the input data streams to produce a single PCM-16 sample value.

For 2 or less channels, they may be mixed as stereo where 16 bit PCM samples are placed in adjacent pairs in the output, rather than summing them.

Constructor & Destructor Documentation

OpalAudioMixer::OpalAudioMixer ( bool  stereo = false,
unsigned  sampleRate = OpalMediaFormat::AudioClockRate,
bool  pushThread = true,
unsigned  period = 10 
)
Parameters
stereoIndicate stero or mixed mono mode
sampleRateSample rate for audio, default 8kHz
pushThreadIndicate push thread is to be used
periodPeriod for push/pull of audio from mixer in milliseconds
OpalAudioMixer::~OpalAudioMixer ( )
inline

Member Function Documentation

virtual Stream* OpalAudioMixer::CreateStream ( )
protectedvirtual

Implements OpalBaseMixer.

virtual size_t OpalAudioMixer::GetOutputSize ( ) const
protectedvirtual

Implements OpalBaseMixer.

unsigned OpalAudioMixer::GetSampleRate ( ) const
inline

Get sample rate for audio.

References m_sampleRate.

bool OpalAudioMixer::IsStereo ( ) const
inline

Return flag for mixing stereo audio data.

References m_stereo.

void OpalAudioMixer::MixAdditive ( RTP_DataFrame frame,
const short *  audioToSubtract 
)
protected
void OpalAudioMixer::MixStereo ( RTP_DataFrame frame)
protected
virtual bool OpalAudioMixer::MixStreams ( RTP_DataFrame frame)
protectedvirtual

Implements OpalBaseMixer.

void OpalAudioMixer::PreMixStreams ( )
protected
virtual void OpalAudioMixer::RemoveAllStreams ( )
virtual

Remove all input streams from mixer.

Reimplemented from OpalBaseMixer.

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

Remove an input stream from mixer.

Parameters
keykey for mixer stream

Reimplemented from OpalBaseMixer.

bool OpalAudioMixer::SetJitterBufferSize ( const Key_T key,
const OpalJitterBuffer::Init init 
)

Sets the size of the jitter buffer to be used by the specified stream in this mixer. A mixer defaults to not having any jitter buffer enabled.

If either jitter delay parameter is zero, it destroys the jitter buffer attached to this mixer.

Parameters
keykey for mixer stream
initInitialisation information
bool OpalAudioMixer::SetSampleRate ( unsigned  rate)

Set sample rate for audio data. Note that all streams must have the same sample rate.

Returns false if attempts to set sample rate to something different to existing streams.

Parameters
rateNew rate

Field Documentation

AudioStream* OpalAudioMixer::m_left
protected
std::vector<int> OpalAudioMixer::m_mixedAudio
protected
AudioStream* OpalAudioMixer::m_right
protected
unsigned OpalAudioMixer::m_sampleRate
protected

Referenced by GetSampleRate().

bool OpalAudioMixer::m_stereo
protected

Referenced by IsStereo().


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