sipxmedialib  Version 3.3
MpInputDeviceDriver.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2007 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // $$
10 
11 // Author: Dan Petrie <dpetrie AT SIPez DOT com>
12 
13 #ifndef _MpInputDeviceDriver_h_
14 #define _MpInputDeviceDriver_h_
15 
16 // SYSTEM INCLUDES
17 #include <utl/UtlDefs.h>
18 #include <os/OsStatus.h>
19 #include <utl/UtlString.h>
20 
21 // APPLICATION INCLUDES
22 #include "mp/MpTypes.h"
23 
24 // DEFINES
25 // MACROS
26 // EXTERNAL FUNCTIONS
27 // EXTERNAL VARIABLES
28 // CONSTANTS
29 // STRUCTS
30 // TYPEDEFS
31 // FORWARD DECLARATIONS
33 
58 class MpInputDeviceDriver : public UtlString
59 {
60 /* //////////////////////////// PUBLIC //////////////////////////////////// */
61 public:
62 
63 /* ============================ CREATORS ================================== */
65 
66 
68  MpInputDeviceDriver(const UtlString& name,
69  MpInputDeviceManager& deviceManager);
77  virtual
80 
82 
83 /* ============================ MANIPULATORS ============================== */
85 
86  virtual OsStatus enableDevice(unsigned samplesPerFrame,
88  unsigned samplesPerSec,
89  MpFrameTime currentFrameTime=0
90  ) = 0;
103  virtual OsStatus disableDevice() = 0;
113  virtual OsStatus setDeviceId(MpInputDeviceHandle deviceId);
115 
117  virtual OsStatus clearDeviceId();
118 
120 
121 /* ============================ ACCESSORS ================================= */
123 
124 
126  virtual MpInputDeviceHandle getDeviceId() const;
127 
129  inline uint32_t getSamplesPerSec() const;
130 
132  inline uint32_t getSamplesPerFrame() const;
133 
135  inline MpFrameTime getFramePeriod();
136 
138  static inline MpFrameTime getFramePeriod(unsigned samplesPerFrame,
139  unsigned samplesPerSec);
140 
142  inline MpFrameTime getCurrentFrameTime() const;
143 
145  inline const UtlString &getDeviceName() const;
146 
148 
149 /* ============================ INQUIRY =================================== */
151 
152 
154  virtual UtlBoolean isEnabled();
155 
157  virtual UtlBoolean isDeviceValid() = 0;
158 
160 
161 /* //////////////////////////// PROTECTED ///////////////////////////////// */
162 protected:
163 
165  UtlBoolean mIsEnabled;
168  unsigned mSamplesPerFrame;
170  unsigned mSamplesPerSec;
174 
176 
177 /* //////////////////////////// PRIVATE /////////////////////////////////// */
178 private:
179 
181  MpInputDeviceDriver(const MpInputDeviceDriver& rMpInputDeviceDriver);
182 
185 };
186 
187 /* ============================ INLINE METHODS ============================ */
188 
190 {
191  return mSamplesPerSec;
192 }
193 
195 {
196  return mSamplesPerFrame;
197 }
198 
200 {
202 }
203 
205  unsigned int samplesPerSec)
206 {
207  return (1000*samplesPerFrame)/samplesPerSec;
208 }
209 
211 {
212  return mCurrentFrameTime;
213 }
214 
215 const UtlString &MpInputDeviceDriver::getDeviceName() const
216 {
217  return *this;
218 }
219 
220 #endif // _MpInputDeviceDriver_h_
MpInputDeviceHandle mDeviceId
this device, as supplied by the InputDeviceManager.
Definition: MpInputDeviceDriver.h:167
int samplesPerFrame
uint32_t MpFrameTime
Definition: MpTypes.h:53
const UtlString & getDeviceName() const
Get device name.
Definition: MpInputDeviceDriver.h:215
virtual UtlBoolean isEnabled()
Inquire if this driver is enabled.
Definition: MpInputDeviceDriver.cpp:91
virtual MpInputDeviceHandle getDeviceId() const
Get device ID associated with this device in parent input device manager.
Definition: MpInputDeviceDriver.cpp:84
Container of input devices for input drivers and resources.
Definition: MpInputDeviceManager.h:79
MpFrameTime getFramePeriod()
Calculate the number of milliseconds that a frame occupies in time.
Definition: MpInputDeviceDriver.h:199
virtual OsStatus enableDevice(unsigned samplesPerFrame, unsigned samplesPerSec, MpFrameTime currentFrameTime=0)=0
Initialize device driver and state.
virtual ~MpInputDeviceDriver()
Destructor.
Definition: MpInputDeviceDriver.cpp:40
MpFrameTime mCurrentFrameTime
pushed to input device manager.
Definition: MpInputDeviceDriver.h:173
uint32_t getSamplesPerFrame() const
Get the samples per frame of this device driver, if enabled.
Definition: MpInputDeviceDriver.h:194
MpInputDeviceManager * mpInputDeviceManager
this device driver.
Definition: MpInputDeviceDriver.h:164
virtual OsStatus setDeviceId(MpInputDeviceHandle deviceId)
Set device ID associated with this device in parent input device manager.
Definition: MpInputDeviceDriver.cpp:58
unsigned mSamplesPerSec
of samples per second.
Definition: MpInputDeviceDriver.h:171
Container for device specific input driver.
Definition: MpInputDeviceDriver.h:58
virtual OsStatus disableDevice()=0
Uninitialize device driver.
Definition: MpInputDeviceDriver.cpp:53
int MpInputDeviceHandle
Definition: MpTypes.h:48
UtlBoolean mIsEnabled
Whether this device driver is enabled or not.
Definition: MpInputDeviceDriver.h:166
MpInputDeviceDriver(const UtlString &name, MpInputDeviceManager &deviceManager)
Default constructor.
Definition: MpInputDeviceDriver.cpp:28
MpFrameTime getCurrentFrameTime() const
Get timestamp for the next frame to be pushed to input device manager.
Definition: MpInputDeviceDriver.h:210
unsigned mSamplesPerFrame
number of samples.
Definition: MpInputDeviceDriver.h:169
virtual UtlBoolean isDeviceValid()=0
Inquire if the device is valid.
virtual OsStatus clearDeviceId()
Clear the device ID associated with this device.
Definition: MpInputDeviceDriver.cpp:71
uint32_t getSamplesPerSec() const
Get the sample rate of this device driver, if enabled.
Definition: MpInputDeviceDriver.h:189
MpInputDeviceDriver & operator=(const MpInputDeviceDriver &rhs)
Assignment operator (not implemented for this class)