OPAL  Version 3.18.8
OpalSilenceDetector Class Referenceabstract

#include <silencedetect.h>

Inheritance diagram for OpalSilenceDetector:

Data Structures

struct  Params
 

Public Types

typedef Modes Mode
 

Public Member Functions

 P_DECLARE_STREAMABLE_ENUM (Modes, NoSilenceDetection, FixedSilenceDetection, AdaptiveSilenceDetection)
 
Construction
 OpalSilenceDetector (const Params &newParam)
 

Basic operations

enum  Result { IsSilent, VoiceActivated, VoiceActive }
 
PNotifier m_receiveHandler
 
Mode m_mode
 
unsigned m_signalDeadband
 
unsigned m_silenceDeadband
 
unsigned m_adaptivePeriod
 
unsigned m_clockRate
 
unsigned m_lastTimestamp
 
unsigned m_receivedTime
 
unsigned m_levelThreshold
 
unsigned m_signalMinimum
 
unsigned m_silenceMaximum
 
unsigned m_signalReceivedTime
 
unsigned m_silenceReceivedTime
 
unsigned m_lastSignalLevel
 
Result m_lastResult
 
const PNotifier & GetReceiveHandler () const
 
void SetParameters (const Params &params, const int clockRate=0)
 
void GetParameters (Params &params)
 
void SetClockRate (unsigned clockRate)
 
unsigned GetClockRate () const
 
Result GetResult (unsigned *currentThreshold=NULL, unsigned *currentLevel=NULL) const
 
Result Detect (const BYTE *audioPtr, PINDEX audioLen, unsigned timestamp)
 
virtual unsigned GetAverageSignalLevel (const BYTE *buffer, PINDEX size)=0
 
static unsigned GetAverageSignalLevelPCM16 (const BYTE *buffer, PINDEX size, bool asPercentage)
 
 PDECLARE_NOTIFIER (RTP_DataFrame, OpalSilenceDetector, ReceivedPacket)
 
 PDECLARE_MUTEX (m_inUse)
 

Detailed Description

Implement silence detection of audio. This is the complement of Voice Activity Detection (VAD) and can be used for that purpose.

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
IsSilent 
VoiceActivated 
VoiceActive 

Constructor & Destructor Documentation

OpalSilenceDetector::OpalSilenceDetector ( const Params newParam)

Create a new detector. Default clock rate is 8000.

Parameters
newParamNew parameters for silence detector

Member Function Documentation

Result OpalSilenceDetector::Detect ( const BYTE *  audioPtr,
PINDEX  audioLen,
unsigned  timestamp 
)

Detemine (in context) if audio stream is currently silent.

virtual unsigned OpalSilenceDetector::GetAverageSignalLevel ( const BYTE *  buffer,
PINDEX  size 
)
pure virtual

Get the average signal level in the stream. This is called from within the silence detection algorithm to calculate the average signal level of the last data frame read from the stream.

The default behaviour returns UINT_MAX which indicates that the average signal has no meaning for the stream.

Parameters
bufferRTP payload being detected
sizeSize of payload buffer

Implemented in OpalLineSilenceDetector, and OpalPCM16SilenceDetector.

static unsigned OpalSilenceDetector::GetAverageSignalLevelPCM16 ( const BYTE *  buffer,
PINDEX  size,
bool  asPercentage 
)
static

Get the average signal level in the stream. This is called from within the silence detection algorithm to calculate the average signal level of the last data frame read from the stream.

The default behaviour returns UINT_MAX which indicates that the average signal has no meaning for the stream.

Parameters
bufferRTP payload being detected
sizeSize of payload buffer
asPercentageReturn as percentage on logarithmic scale
unsigned OpalSilenceDetector::GetClockRate ( ) const
inline

Get the current sampling clock rate.

References m_clockRate.

void OpalSilenceDetector::GetParameters ( Params params)

Get the current parameters in use.

const PNotifier& OpalSilenceDetector::GetReceiveHandler ( ) const
inline

References m_receiveHandler.

Result OpalSilenceDetector::GetResult ( unsigned *  currentThreshold = NULL,
unsigned *  currentLevel = NULL 
) const

Get silence detection status

The currentThreshold value for energy value as logarithmic scale from 0 to 255 (actually a u-Law value) which is used as the threshold value for audio signal.

The currentLevel value is the energy as logarithmic scale from 0 to 255 (actually a u-Law value) for last audio frame.

OpalSilenceDetector::P_DECLARE_STREAMABLE_ENUM ( Modes  ,
NoSilenceDetection  ,
FixedSilenceDetection  ,
AdaptiveSilenceDetection   
)
OpalSilenceDetector::PDECLARE_MUTEX ( m_inUse  )
protected
OpalSilenceDetector::PDECLARE_NOTIFIER ( RTP_DataFrame  ,
OpalSilenceDetector  ,
ReceivedPacket   
)
protected
void OpalSilenceDetector::SetClockRate ( unsigned  clockRate)

Set the sampling clock rate for the preprocessor. Adusts the interpretation of time values. This may be called while audio is being transferred, but if in adaptive mode calling this will reset the filter.

Parameters
clockRateSampling clock rate for the preprocessor
void OpalSilenceDetector::SetParameters ( const Params params,
const int  clockRate = 0 
)

Set the silence detector parameters. This adjusts the silence detector "agression". The deadband and adaptive periods are in ms units to work for any clock rate. The clock rate value is optional: 0 leaves value unchanged. This may be called while audio is being transferred, but if in adaptive mode calling this will reset the filter.

Parameters
paramsNew parameters for silence detector
clockRateSampling clock rate for the preprocessor

Field Documentation

unsigned OpalSilenceDetector::m_adaptivePeriod
protected
unsigned OpalSilenceDetector::m_clockRate
protected

Referenced by GetClockRate().

Result OpalSilenceDetector::m_lastResult
protected
unsigned OpalSilenceDetector::m_lastSignalLevel
protected
unsigned OpalSilenceDetector::m_lastTimestamp
protected
unsigned OpalSilenceDetector::m_levelThreshold
protected
Mode OpalSilenceDetector::m_mode
protected
unsigned OpalSilenceDetector::m_receivedTime
protected
PNotifier OpalSilenceDetector::m_receiveHandler
protected

Referenced by GetReceiveHandler().

unsigned OpalSilenceDetector::m_signalDeadband
protected
unsigned OpalSilenceDetector::m_signalMinimum
protected
unsigned OpalSilenceDetector::m_signalReceivedTime
protected
unsigned OpalSilenceDetector::m_silenceDeadband
protected
unsigned OpalSilenceDetector::m_silenceMaximum
protected
unsigned OpalSilenceDetector::m_silenceReceivedTime
protected

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