sipxmedialib  Version 3.3
MprDelay.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: Sergey Kostanbaev <Sergey DOT Kostanbaev AT sipez DOT com>
12 
13 #ifndef _MprDelay_h_
14 #define _MprDelay_h_
15 
16 // SYSTEM INCLUDES
17 // APPLICATION INCLUDES
18 #include "mp/MpAudioResource.h"
19 #include "mp/MpAudioBuf.h"
20 #include "mp/MpResourceMsg.h"
21 
22 
23 // DEFINES
24 // MACROS
25 // EXTERNAL FUNCTIONS
26 // EXTERNAL VARIABLES
27 // STRUCTS
28 // TYPEDEFS
29 // FORWARD DECLARATIONS
30 
31 
163 class MprDelay : public MpAudioResource
164 {
165 /* //////////////////////////////// PUBLIC //////////////////////////////// */
166 public:
167  enum
168  {
170  };
171 /* =============================== CREATORS =============================== */
173 
174  MprDelay(const UtlString& rName, int capacity = DEFAULT_FIFO_CAPACITY);
176 
178  ~MprDelay();
179 
181 
182 /* ============================= MANIPULATORS ============================= */
184 
185 
187  static UtlBoolean startPlay(const UtlString& namedResource,
188  OsMsgQ& fgQ);
189 
191  static UtlBoolean stopPlay(const UtlString& namedResource,
192  OsMsgQ& fgQ);
193 
195 
196 /* ============================== ACCESSORS =============================== */
198 
199 
200 
202 
203 /* =============================== INQUIRY ================================ */
205 
206 
208  int getDelayMs();
209 
211  int getDelaySamples();
212 
214  int getDelayFrames();
215 
217 
218 /* ////////////////////////////// PROTECTED /////////////////////////////// */
219 protected:
220 
221  UtlBoolean doDelay(MpBufPtr& inBuf,
222  MpBufPtr& outBuf,
223  int samplesPerFrame,
224  int samplesPerSecond);
225 
227  UtlBoolean handleMessage(MpResourceMsg& rMsg);
228 
230  UtlBoolean doProcessFrame(MpBufPtr inBufs[],
231  MpBufPtr outBufs[],
232  int inBufsSize,
233  int outBufsSize,
234  UtlBoolean isEnabled,
235  int samplesPerFrame,
236  int samplesPerSecond);
237 
238 
239 /* /////////////////////////////// PRIVATE //////////////////////////////// */
240 private:
242  {
247  };
248 
249  typedef enum
250  {
253  } AddlMsgTypes;
254 
261  {
262  /* ///////////////////////////// PUBLIC //////////////////////////////// */
263  public:
264 
265  /* ============================ CREATORS =============================== */
267 
268  MprDelayFifo(int capacity);
270 
272  ~MprDelayFifo();
273 
275 
276  /* ========================== MANIPULATORS ============================= */
278 
279  void reset();
281 
283  void pushData(MpAudioBufPtr& databuff);
284 
286  void popData(MpAudioBufPtr& databuff);
293 
294  /* =========================== ACCESSORS =============================== */
296 
297 
299  int getFifoLength() const;
300 
301 
303 
304  /* ============================ INQUIRY ================================ */
306 
307 
309  UtlBoolean isQuiescent() const;
310 
312  UtlBoolean isEmpty() const;
313 
315 
316  /* /////////////////////////// PROTECTED /////////////////////////////// */
317  protected:
318 
319  /* //////////////////////////// PRIVATE //////////////////////////////// */
320  private:
326  };
327 
331 };
332 
333 /* ============================ INLINE METHODS ============================ */
334 
335 #endif // _MprDelay_h_
MprDelayFifo(int capacity)
Constructor.
Definition: MprDelay.cpp:203
Message object used to communicate with the media processing task.
Definition: MpResourceMsg.h:30
UtlBoolean doDelay(MpBufPtr &inBuf, MpBufPtr &outBuf, int samplesPerFrame, int samplesPerSecond)
Definition: MprDelay.cpp:96
int mBuffSize
Definition: MprDelay.h:322
static UtlBoolean stopPlay(const UtlString &namedResource, OsMsgQ &fgQ)
Send message to stop play.
Definition: MprDelay.cpp:58
int samplesPerFrame
UtlBoolean isEmpty() const
Is FIFIO empty.
Definition: MprDelay.cpp:290
Definition: MprDelay.h:169
Definition: MprDelay.h:251
Definition: MpResourceMsg.h:56
MprDelayFifo mFifo
FIFO for the stored data.
Definition: MprDelay.h:330
UtlBoolean mIsQuiescenceNotified
Have FIFO quiescent state been notified?
Definition: MprDelay.h:329
Fifo for Delay resource.
Definition: MprDelay.h:260
int mStartPosition
Definition: MprDelay.h:324
int samplesPerSecond
Definition: MprDelay.h:252
MprDelayState mState
State of delay resource.
Definition: MprDelay.h:328
int getDelayFrames()
Get delay in frames.
Definition: MprDelay.cpp:86
Smart pointer to MpAudioBuf.
Definition: MpAudioBuf.h:168
Abstract base class for all audio processing objects.
Definition: MpAudioResource.h:38
void reset()
Reset FIFO.
Definition: MprDelay.cpp:218
int getDelayMs()
Get delay in milliseconds.
Definition: MprDelay.cpp:70
int getFifoLength() const
Get number of buffers in queue.
Definition: MprDelay.cpp:277
Definition: MprDelay.h:244
Definition: MprDelay.h:246
UtlBoolean handleMessage(MpResourceMsg &rMsg)
Handles an incoming flowgraph message for this media processing object.
Definition: MprDelay.cpp:159
~MprDelay()
Destructor.
Definition: MprDelay.cpp:43
Definition: MprDelay.h:245
static UtlBoolean startPlay(const UtlString &namedResource, OsMsgQ &fgQ)
Send message to start play.
Definition: MprDelay.cpp:51
MpAudioBufPtr * mBuff
Definition: MprDelay.h:321
Delay Resource.
Definition: MprDelay.h:163
Smart pointer to MpBuf.
Definition: MpBuf.h:160
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: MprDelay.cpp:178
MprDelay(const UtlString &rName, int capacity=DEFAULT_FIFO_CAPACITY)
Constructor.
Definition: MprDelay.cpp:33
void popData(MpAudioBufPtr &databuff)
Pop audio buffer from FIFO.
Definition: MprDelay.cpp:261
~MprDelayFifo()
Destructor.
Definition: MprDelay.cpp:213
int mNumActiveFrames
Definition: MprDelay.h:325
AddlMsgTypes
Definition: MprDelay.h:249
void pushData(MpAudioBufPtr &databuff)
Push audio buffer to FIFO.
Definition: MprDelay.cpp:227
MprDelayState
Definition: MprDelay.h:241
int mEndPosition
Definition: MprDelay.h:323
UtlBoolean isQuiescent() const
Does FIFO contain only silent frames?
Definition: MprDelay.cpp:285
int getDelaySamples()
Get delay in samples.
Definition: MprDelay.cpp:78
Definition: MprDelay.h:243
UtlBoolean isEnabled() const
Returns TRUE is this resource is currently enabled, FALSE otherwise.
Definition: MpResource.cpp:440