sipxmedialib  Version 3.3
MpVadBase.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2008-2014 SIPez LLC. All rights reserved.
3 //
4 // Copyright (C) 2008 SIPfoundry Inc.
5 // Licensed by SIPfoundry under the LGPL license.
6 //
7 // $$
9 
10 // Author: Sergey Kostanbaev <Sergey DOT Kostanbaev AT sipez DOT com>
11 
12 #ifndef _MpVadBase_h_
13 #define _MpVadBase_h_
14 
15 // SYSTEM INCLUDES
16 // APPLICATION INCLUDES
17 #include <utl/UtlDefs.h>
18 #include <os/OsStatus.h>
19 #include <utl/UtlString.h>
20 #include "mp/MpTypes.h"
21 
22 // DEFINES
23 // MACROS
24 // EXTERNAL FUNCTIONS
25 // EXTERNAL VARIABLES
26 // CONSTANTS
27 // STRUCTS
28 // TYPEDEFS
29 // FORWARD DECLARATIONS
30 
40 class MpVadBase
41 {
42 /* //////////////////////////// PUBLIC //////////////////////////////////// */
43 public:
44 
45 /* ============================ CREATORS ================================== */
47 
48  virtual OsStatus init(int samplesPerSec) = 0;
54  static MpVadBase *createVad(const UtlString &name = "");
64  virtual ~MpVadBase() {};
66 
68 
69 /* ============================ MANIPULATORS ============================== */
71 
72 
74  virtual MpSpeechType processFrame(uint32_t packetTimeStamp,
75  const MpAudioSample* pBuf,
76  unsigned inSamplesNum,
77  const MpSpeechParams &speechParams,
78  UtlBoolean calcEnergyOnly = FALSE) = 0;
91  virtual OsStatus setParam(const char* paramName, void* value) = 0;
100  static void setDefaultAlgorithm(const UtlString& name);
111  virtual void reset() = 0;
120 
121 /* ============================ ACCESSORS ================================= */
123 
124  virtual int getEnergy() const = 0;
126 
128  void setName(const UtlString& name);
129 
131 
132 /* ============================ INQUIRY =================================== */
134 
135 
137 
138 /* //////////////////////////// PROTECTED ///////////////////////////////// */
139 protected:
140 
141  static UtlString smDefaultAlgorithm;
142 
143  UtlString mName;
144 
145 /* //////////////////////////// PRIVATE /////////////////////////////////// */
146 private:
147 
148 };
149 
150 #endif // _MpVadBase_h_
Definition: MpVadBase.h:40
Definition: MpTypes.h:74
virtual MpSpeechType processFrame(uint32_t packetTimeStamp, const MpAudioSample *pBuf, unsigned inSamplesNum, const MpSpeechParams &speechParams, UtlBoolean calcEnergyOnly=FALSE)=0
Detect speech presence.
virtual int getEnergy() const =0
Return weighted energy of current frame.
int16_t MpAudioSample
Definition: MpTypes.h:44
static void setDefaultAlgorithm(const UtlString &name)
Set algorithm to be used by default.
Definition: MpVadBase.cpp:60
MpSpeechType
Type of audio data.
Definition: MpTypes.h:65
UtlString mName
Name useful for debugging to distiguish multiple instances.
Definition: MpVadBase.h:143
void setName(const UtlString &name)
Set name.
Definition: MpVadBase.cpp:67
virtual ~MpVadBase()
Destructor.
Definition: MpVadBase.h:65
virtual OsStatus init(int samplesPerSec)=0
Initialize VAD with given sample rate.
static UtlString smDefaultAlgorithm
Name of algorithm to be used by default.
Definition: MpVadBase.h:141
static MpVadBase * createVad(const UtlString &name="")
Factory method for VAD algorithms creation.
Definition: MpVadBase.cpp:31
virtual void reset()=0
Prepare to process other unrelated audio stream.
#define FALSE
Definition: PlgDefsV1.h:37
virtual OsStatus setParam(const char *paramName, void *value)=0
Set algorithm parameter.