sipxmedialib  Version 3.3
MprHook.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2009 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2009 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // $$
10 
11 #ifndef _MprHook_h_
12 #define _MprHook_h_
13 
14 // SYSTEM INCLUDES
15 
16 // APPLICATION INCLUDES
17 #include "mp/MpAudioResource.h"
18 #include "mp/MpResourceMsg.h"
19 
20 // DEFINES
21 // MACROS
22 // EXTERNAL FUNCTIONS
23 // EXTERNAL VARIABLES
24 // CONSTANTS
25 // STRUCTS
26 // TYPEDEFS
27 // FORWARD DECLARATIONS
28 
35 class MprHook : public MpAudioResource
36 {
37 /* //////////////////////////// PUBLIC //////////////////////////////////// */
38 public:
39 
41  typedef void (*HookFunction)(MpBufPtr &pBuf, uint32_t time, void *pUserData);
47 /* ============================ CREATORS ================================== */
49 
50  MprHook(const UtlString& rName);
52 
54  virtual
55  ~MprHook();
56 
58 
59 /* ============================ MANIPULATORS ============================== */
61 
62 
64  static OsStatus setHook(const UtlString& namedResource,
65  OsMsgQ& fgQ,
66  HookFunction func,
67  void *pUserData);
73 
74 /* ============================ ACCESSORS ================================= */
76 
77 
79 
80 /* ============================ INQUIRY =================================== */
82 
83 
85 
86 /* //////////////////////////// PROTECTED ///////////////////////////////// */
87 protected:
88 
89 /* //////////////////////////// PRIVATE /////////////////////////////////// */
90 private:
91 
92  typedef enum
93  {
95  } AddlMsgTypes;
96 
98  void *mpUserData;
99  uint32_t mFrameNum;
100 
101  virtual UtlBoolean doProcessFrame(MpBufPtr inBufs[],
102  MpBufPtr outBufs[],
103  int inBufsSize,
104  int outBufsSize,
105  UtlBoolean isEnabled,
106  int samplesPerFrame,
107  int samplesPerSecond);
108 
110  virtual UtlBoolean handleMessage(MpResourceMsg& rMsg);
111 
113  MprHook(const MprHook& rMprHook);
114 
116  MprHook& operator=(const MprHook& rhs);
117 
118 };
119 
120 /* ============================ INLINE METHODS ============================ */
121 
122 #endif // _MprHook_h_
Message object used to communicate with the media processing task.
Definition: MpResourceMsg.h:30
void * mpUserData
User data to pass to hook function.
Definition: MprHook.h:98
HookFunction mpHook
Hook function to be called.
Definition: MprHook.h:97
int samplesPerFrame
MprHook & operator=(const MprHook &rhs)
Assignment operator (not implemented for this class)
Definition: MpResourceMsg.h:56
MprHook(const UtlString &rName)
Constructor.
Definition: MprHook.cpp:30
virtual 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: MprHook.cpp:71
virtual ~MprHook()
Destructor.
Definition: MprHook.cpp:38
int samplesPerSecond
static OsStatus setHook(const UtlString &namedResource, OsMsgQ &fgQ, HookFunction func, void *pUserData)
Set hook function to be called for every received frame.
Definition: MprHook.cpp:44
Definition: MprHook.h:94
Abstract base class for all audio processing objects.
Definition: MpAudioResource.h:38
virtual UtlBoolean handleMessage(MpResourceMsg &rMsg)
Handles an incoming flowgraph message for this media processing object.
Definition: MprHook.cpp:104
AddlMsgTypes
Definition: MprHook.h:92
Smart pointer to MpBuf.
Definition: MpBuf.h:160
uint32_t mFrameNum
Number of the current frame.
Definition: MprHook.h:99
void(* HookFunction)(MpBufPtr &pBuf, uint32_t time, void *pUserData)
Pointer to a hook function.
Definition: MprHook.h:41
The "Hook" media processing resource.
Definition: MprHook.h:35
UtlBoolean isEnabled() const
Returns TRUE is this resource is currently enabled, FALSE otherwise.
Definition: MpResource.cpp:440