Classified ads
Classes | Public Slots | Signals | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
AudioMixer Class Reference

Class for mixing together 0-n audio streams. More...

#include <audiomixer.h>

Inheritance diagram for AudioMixer:
Inheritance graph
[legend]
Collaboration diagram for AudioMixer:
Collaboration graph
[legend]

Classes

struct  AudioFrameStruct
 
struct  AudioStreamMetadata
 

Public Slots

void insertCapturedAudioFrame (const QByteArray &aFrame, quint32 aSeqNo)
 
void insertReceivedAudioFrame (quint32 aCallId, quint32 aSeqNo, const QByteArray &aFrame)
 

Signals

void frameReadyForLocalSpeaker (const QByteArray &aFrame)
 
void frameReadyForRemoteSend (quint32 aCallId, quint32 aSeqNo, const QByteArray &aFrame)
 

Public Member Functions

 AudioMixer (Model &aModel)
 
 ~AudioMixer ()
 
void insertStream (quint32 aCallId, quint32 aStartingSeq, bool aIsLocallyCaptured)
 
void removeStream (quint32 aCallId)
 

Private Types

typedef struct AudioMixer::AudioFrameStruct AudioFrame
 
typedef struct AudioMixer::AudioStreamMetadata AudioFrameMetadata
 

Private Member Functions

void tryMixFrames (quint32 aCallId, quint32 aSeqNo)
 
void configureMixedStreams ()
 
void doInsertAudioFrame (const QByteArray &aFrame, bool aIsLocallyCaptured, quint32 aSeqNo, quint32 aCallId)
 
void clip (QByteArray &aBuffer)
 

Private Attributes

QList< QQueue< AudioFrame > > iAudioDataBuffer
 
QList< AudioFrameMetadataiStreams
 
QList< int > iIndexesToMixForLocalSpeaker
 
QList< int > iIndexesToMixForRemoteOutput
 
ModeliModel
 

Detailed Description

Class for mixing together 0-n audio streams.

This class has 2 types of input and 2 types of output. Input type 1: locally captured microphone data Input type 2: 0-n streams sent from remote nodes Output type 1: Audio intended for playback from local loudspeaker Output type 2: Audio intended to be sent to remote nodes Depending on situation this class will mix a bit differently. If there is only type 1 input and 1 type 2 stream then no mixing will occur: input type 2 becomes output type 1 and that's it. If there is more than 1 streams to mix together then mixer will actually mix.

Member Typedef Documentation

Constructor & Destructor Documentation

AudioMixer::AudioMixer ( Model aModel)

Constructor.

AudioMixer::~AudioMixer ( )

Member Function Documentation

void AudioMixer::clip ( QByteArray &  aBuffer)
private

Method that clips away samples that do not fall into [-1,1] range

void AudioMixer::configureMixedStreams ( )
private

method for figuring out which stream to mix into which direction

void AudioMixer::doInsertAudioFrame ( const QByteArray &  aFrame,
bool  aIsLocallyCaptured,
quint32  aSeqNo,
quint32  aCallId 
)
private

workhorse of insertCaptured/ReceivedAudioFrame slots

Parameters
aIsLocallyCapturedis true if audio is from local microphone and false if received from remote node
void AudioMixer::frameReadyForLocalSpeaker ( const QByteArray &  aFrame)
signal

emitted when mixing done for local playback

void AudioMixer::frameReadyForRemoteSend ( quint32  aCallId,
quint32  aSeqNo,
const QByteArray &  aFrame 
)
signal

emitted when mixing done for remote nodes

void AudioMixer::insertCapturedAudioFrame ( const QByteArray &  aFrame,
quint32  aSeqNo 
)
slot

Method for inputting an audio frame from local microphone. Frame is 60 milliseconds raw audio data in floating point format with 8kHz sample rate. That means there are 480 samples, totalling 960*2 bytes. See constants in top of audiomixer.cpp file. Each floating point sample in array needs to be in range [-1,1]

Parameters
aFrameis the audio data. floating point, native-encoding audio/pcm data.
aSeqNoSequence number of frame. This is a incrementing number that begins from 0 at stream start. Note that it is entirely possible to start mixing a stream from middle so when processing starts, this value does not necessarily start from 0
void AudioMixer::insertReceivedAudioFrame ( quint32  aCallId,
quint32  aSeqNo,
const QByteArray &  aFrame 
)
slot

Method for inputting an audio frame that is received from network. See method insertCapturedAudioFrame for more information, same frame data format must be used.

Parameters
aFrameis the audio data. float, native-encoding audio/pcm data.
aSeqNoSequence number of frame. This is a incrementing number that begins from 0 at stream start. Note that it is entirely possible to start mixing a stream from middle so when processing starts, this value does not necessarily start from 0
aCallIdCall id for keeping track which frame belongs to which stream. Typically inside mixer there are both locally captured frames and frames from remote that both have same call id ; if there are multiple calls in progress then one set of frames of local input and several from remote sources. If aIsLocallyCaptured is true, then value of this parameter has no effect
void AudioMixer::insertStream ( quint32  aCallId,
quint32  aStartingSeq,
bool  aIsLocallyCaptured 
)

method for entering stream metadata so that stream with given callid gets included into mixer output

void AudioMixer::removeStream ( quint32  aCallId)

method for removing stream metadata so that stream with given callid no longer gets included into mixer output

void AudioMixer::tryMixFrames ( quint32  aCallId,
quint32  aSeqNo 
)
private

workhorse method. will check for buffers and see if we have frames for all streams to mix and if conditions evaluate true, will output the mixed frame, or several if possible.

Member Data Documentation

QList<QQueue<AudioFrame> > AudioMixer::iAudioDataBuffer
private

Voice data buffer. Must share same indexing with iStreams e.g. if stream metadata for call x is in iStreams[y] then call data for that stream needs to go to queue strictly at iAudioDataBuffer[y]

QList<int> AudioMixer::iIndexesToMixForLocalSpeaker
private

List of indexes to iStreams that are mixed into speaker output

QList<int> AudioMixer::iIndexesToMixForRemoteOutput
private

List of indexes to iStreams that are mixed into remote nodes

Model& AudioMixer::iModel
private

datamodel

QList<AudioFrameMetadata> AudioMixer::iStreams
private

Metadata of streams being served


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