sipxmedialib  Version 3.3
Protected Attributes | Static Protected Attributes | List of all members
MpVadBase Class Referenceabstract

#include <MpVadBase.h>

Inheritance diagram for MpVadBase:
Inheritance graph
[legend]

Protected Attributes

UtlString mName
 Name useful for debugging to distiguish multiple instances. More...
 

Static Protected Attributes

static UtlString smDefaultAlgorithm
 Name of algorithm to be used by default. More...
 

Creators

virtual OsStatus init (int samplesPerSec)=0
 Initialize VAD with given sample rate. More...
 
virtual ~MpVadBase ()
 Destructor. More...
 
static MpVadBasecreateVad (const UtlString &name="")
 Factory method for VAD algorithms creation. More...
 

Manipulators

virtual MpSpeechType processFrame (uint32_t packetTimeStamp, const MpAudioSample *pBuf, unsigned inSamplesNum, const MpSpeechParams &speechParams, UtlBoolean calcEnergyOnly=FALSE)=0
 Detect speech presence. More...
 
virtual OsStatus setParam (const char *paramName, void *value)=0
 Set algorithm parameter. More...
 
virtual void reset ()=0
 Prepare to process other unrelated audio stream. More...
 
static void setDefaultAlgorithm (const UtlString &name)
 Set algorithm to be used by default. More...
 

Accessors

virtual int getEnergy () const =0
 Return weighted energy of current frame. More...
 
void setName (const UtlString &name)
 Set name. More...
 

Detailed Description

Base class for all VAD algorithms.

To create concrete class you could directly instantiate it or use MpVadBase::createVad() static method for greater flexibility.

Constructor & Destructor Documentation

virtual ~MpVadBase ( )
inlinevirtual

Destructor.

Member Function Documentation

virtual OsStatus init ( int  samplesPerSec)
pure virtual

Initialize VAD with given sample rate.

Should be called before any other class methods.

Implemented in MpVadSimple.

MpVadBase * createVad ( const UtlString &  name = "")
static

Factory method for VAD algorithms creation.

Parameters
[in]name- name of VAD algorithm to use. Use empty string to get default algorithm.
Returns
Method never returns NULL. If appropriate VAD algorithm is not found, default one is returned.
virtual MpSpeechType processFrame ( uint32_t  packetTimeStamp,
const MpAudioSample pBuf,
unsigned  inSamplesNum,
const MpSpeechParams speechParams,
UtlBoolean  calcEnergyOnly = FALSE 
)
pure virtual

Detect speech presence.

Parameters
[in]packetTimeStamp- RTP timestamp of packet.
[in]pBuf- buffer with input data.
[in]inSamplesNum- number of samples of actual data, passed to this function.
[in]speechParams- various parameters of speech.
[in]calcEnergyOnly- if TRUE, VAD should calculate energy only.
Returns
Method returns MP_SPEECH_ACTIVE or MP_SPEECH_SILENT mainly, but if algorithm doesn't handle some situations return value may be MP_SPEECH_UNKNOWN

Implemented in MpVadSimple.

virtual OsStatus setParam ( const char *  paramName,
void *  value 
)
pure virtual

Set algorithm parameter.

Parameters
[in]paramName- name of parameter
[in]value- value, can be any type, before call cast it to void*
Returns
Method returns OS_SUCCESS if parameter has been set, otherwise OS_FAILED

Implemented in MpVadSimple.

void setDefaultAlgorithm ( const UtlString &  name)
static

Set algorithm to be used by default.

Initially default algorithm is defined at compile time. Using this function you can change default algorithm at run-time or switch back to compile-time default.

Parameters
[in]name- name of algorithm to use by default. Reverts to compile-time default if empty.
virtual void reset ( )
pure virtual

Prepare to process other unrelated audio stream.

Only initialized algorithm can be reseted. Calling reset() should bring algorithm to the original state as it was right after init(). So init() should NOT be called after reset().

Implemented in MpVadSimple.

virtual int getEnergy ( ) const
pure virtual

Return weighted energy of current frame.

Implemented in MpVadSimple.

void setName ( const UtlString &  name)

Set name.

Member Data Documentation

UtlString smDefaultAlgorithm
staticprotected

Name of algorithm to be used by default.

UtlString mName
protected

Name useful for debugging to distiguish multiple instances.