OPAL
Version 3.18.8
|
#include <silencedetect.h>
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 ¶ms, const int clockRate=0) |
void | GetParameters (Params ¶ms) |
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) | |
Implement silence detection of audio. This is the complement of Voice Activity Detection (VAD) and can be used for that purpose.
typedef Modes OpalSilenceDetector::Mode |
OpalSilenceDetector::OpalSilenceDetector | ( | const Params & | newParam | ) |
Create a new detector. Default clock rate is 8000.
newParam | New parameters for silence detector |
Result OpalSilenceDetector::Detect | ( | const BYTE * | audioPtr, |
PINDEX | audioLen, | ||
unsigned | timestamp | ||
) |
Detemine (in context) if audio stream is currently silent.
|
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.
buffer | RTP payload being detected |
size | Size of payload buffer |
Implemented in OpalLineSilenceDetector, and OpalPCM16SilenceDetector.
|
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.
buffer | RTP payload being detected |
size | Size of payload buffer |
asPercentage | Return as percentage on logarithmic scale |
|
inline |
Get the current sampling clock rate.
References m_clockRate.
void OpalSilenceDetector::GetParameters | ( | Params & | params | ) |
Get the current parameters in use.
|
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 | |||
) |
|
protected |
|
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.
clockRate | Sampling 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.
params | New parameters for silence detector |
clockRate | Sampling clock rate for the preprocessor |
|
protected |
|
protected |
Referenced by GetClockRate().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Referenced by GetReceiveHandler().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |