sipxmedialib  Version 3.3
MprVoiceActivityNotifier.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2008 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2008 SIPez LLC.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 // Author: Alexander Chemeris <Alexander DOT Chemeris AT SIPez DOT com>
12 
13 #ifndef _MprVoiceActivityNotifier_h_
14 #define _MprVoiceActivityNotifier_h_
15 
16 // SYSTEM INCLUDES
17 // APPLICATION INCLUDES
18 #include "mp/MpAudioResource.h"
19 #include "mp/MpResourceMsg.h"
20 
21 // DEFINES
22 // MACROS
23 // EXTERNAL FUNCTIONS
24 // EXTERNAL VARIABLES
25 // STRUCTS
26 // TYPEDEFS
27 // FORWARD DECLARATIONS
28 class MpVadBase;
29 
36 {
37 /* //////////////////////////////// PUBLIC //////////////////////////////// */
38 public:
39 
41  static const int smDefaultLevelPeriodMs;
43  static const int smDefaultInactivityTimeoutMs;
44 
45 /* =============================== CREATORS =============================== */
47 
48 
50  MprVoiceActivityNotifier(const UtlString& rName,
51  int notificationPeriodMs = smDefaultLevelPeriodMs,
52  int inactivityTimeoutMs = smDefaultInactivityTimeoutMs);
56 
58 
62 
64 
65 /* ============================= MANIPULATORS ============================= */
67 
68 
70  static
71  OsStatus chageNotificationPeriod(const UtlString& namedResource,
72  OsMsgQ& fgQ,
73  int notificationPeriodMs);
74 
76  static
77  OsStatus changeInactivityTimeout(const UtlString& namedResource,
78  OsMsgQ& fgQ,
79  int inactivityTimeoutMs);
80 
82 
83 /* ============================== ACCESSORS =============================== */
85 
86 
87 
89 
90 /* =============================== INQUIRY ================================ */
92 
93 
94 
96 
97 /* ////////////////////////////// PROTECTED /////////////////////////////// */
98 protected:
99 
100  enum
101  {
104  };
105 
107  {
110  };
111 
120 
122  UtlBoolean doProcessFrame(MpBufPtr inBufs[],
123  MpBufPtr outBufs[],
124  int inBufsSize,
125  int outBufsSize,
126  UtlBoolean isEnabled,
127  int samplesPerFrame,
128  int samplesPerSecond);
129 
131  UtlBoolean handleMessage(MpResourceMsg& rMsg);
132 
134  UtlBoolean handleChangeNotificationPeriod(int periodMs);
135 
137  UtlBoolean handleChangeInactivityTimeout(int timeout);
138 
140  OsStatus setFlowGraph(MpFlowGraphBase* pFlowGraph);
141 
142 /* /////////////////////////////// PRIVATE //////////////////////////////// */
143 private:
144 
145 };
146 
147 /* ============================ INLINE METHODS ============================ */
148 
149 #endif // _MprVoiceActivityNotifier_h_
UtlBoolean handleMessage(MpResourceMsg &rMsg)
Handles an incoming flowgraph message for this media processing object.
Definition: MprVoiceActivityNotifier.cpp:166
Message object used to communicate with the media processing task.
Definition: MpResourceMsg.h:30
int samplesPerFrame
Definition: MpVadBase.h:40
int mEnergyLevelMax
Maximum of the energy level since the last notification.
Definition: MprVoiceActivityNotifier.h:118
Definition: MpResourceMsg.h:56
int mInactivitySamples
Number of samples since last active packet.
Definition: MprVoiceActivityNotifier.h:117
Definition: MprVoiceActivityNotifier.h:103
int mLevelPeriodSmp
Number of samples between level notifications.
Definition: MprVoiceActivityNotifier.h:113
Voice Activity notifier resource.
Definition: MprVoiceActivityNotifier.h:35
Flow graph for coordinating the execution of media processing resources.
Definition: MpFlowGraphBase.h:91
static const int smDefaultLevelPeriodMs
Default period (in ms) to send energy level notifications.
Definition: MprVoiceActivityNotifier.h:41
static OsStatus changeInactivityTimeout(const UtlString &namedResource, OsMsgQ &fgQ, int inactivityTimeoutMs)
Change duration of silence (in ms) before STOPPED notification is sent.
Definition: MprVoiceActivityNotifier.cpp:70
int samplesPerSecond
int mLevelPeriodMs
Number of milliseconds between level notifications.
Definition: MprVoiceActivityNotifier.h:112
UtlBoolean handleChangeInactivityTimeout(int timeout)
Handle MPRM_CHANGE_INACTIVITY_TIMEOUT message.
Definition: MprVoiceActivityNotifier.cpp:199
~MprVoiceActivityNotifier()
Destructor.
Definition: MprVoiceActivityNotifier.cpp:52
int mLevelSamplesPassed
Number of samples since last level notification.
Definition: MprVoiceActivityNotifier.h:114
Abstract base class for all audio processing objects.
Definition: MpAudioResource.h:38
int mInactivityTimeoutMs
Number of milliseconds of silence before STOP notification.
Definition: MprVoiceActivityNotifier.h:115
static const int smDefaultInactivityTimeoutMs
Default duration of silence (in ms) before STOPPED notification is sent.
Definition: MprVoiceActivityNotifier.h:43
Definition: MprVoiceActivityNotifier.h:109
MprVoiceActivityNotifier(const UtlString &rName, int notificationPeriodMs=smDefaultLevelPeriodMs, int inactivityTimeoutMs=smDefaultInactivityTimeoutMs)
Constructor.
Definition: MprVoiceActivityNotifier.cpp:37
StreamState
Definition: MprVoiceActivityNotifier.h:106
Definition: MprVoiceActivityNotifier.h:108
OsStatus setFlowGraph(MpFlowGraphBase *pFlowGraph)
Associates this resource with the indicated flow graph.
Definition: MprVoiceActivityNotifier.cpp:210
Smart pointer to MpBuf.
Definition: MpBuf.h:160
UtlBoolean handleChangeNotificationPeriod(int periodMs)
Handle MPRM_CHANGE_NOTIFICATION_PERIOD message.
Definition: MprVoiceActivityNotifier.cpp:188
static OsStatus chageNotificationPeriod(const UtlString &namedResource, OsMsgQ &fgQ, int notificationPeriodMs)
Change period between energy level notifications.
Definition: MprVoiceActivityNotifier.cpp:60
UtlBoolean doProcessFrame(MpBufPtr inBufs[], MpBufPtr outBufs[], int inBufsSize, int outBufsSize, UtlBoolean isEnabled, int samplesPerFrame, int samplesPerSecond)
This method does the real work for the media processing resource and must be defined in each class de...
Definition: MprVoiceActivityNotifier.cpp:86
int mInactivityTimeoutSmp
Number of samples of silence before STOP notification.
Definition: MprVoiceActivityNotifier.h:116
Definition: MprVoiceActivityNotifier.h:102
UtlBoolean isEnabled() const
Returns TRUE is this resource is currently enabled, FALSE otherwise.
Definition: MpResource.cpp:440
StreamState mStreamState
Stream activity state.
Definition: MprVoiceActivityNotifier.h:119