sipxmedialib
Version 3.3
|
Sine wave generator Input Device Driver. More...
#include <MpSineWaveGeneratorDeviceDriver.h>
Public Member Functions | |
Creators | |
MpSineWaveGeneratorDeviceDriver (const UtlString &name, MpInputDeviceManager &deviceManager, unsigned int magnitude, unsigned int periodInMicroseconds, int relativeSpeed) | |
Default constructor. More... | |
virtual | ~MpSineWaveGeneratorDeviceDriver () |
Destructor. More... | |
Manipulators | |
virtual OsStatus | enableDevice (unsigned samplesPerFrame, unsigned samplesPerSec, MpFrameTime currentFrameTime) |
Initialize device driver and state. More... | |
virtual OsStatus | disableDevice () |
Uninitialize device driver. More... | |
virtual OsStatus | setTone (unsigned int periodInMicroseconds) |
Set a new tone to be played. More... | |
virtual OsStatus | setMagnitude (unsigned int magnitude) |
Set a new magnitude to be played. More... | |
Inquiry | |
UtlBoolean | isDeviceValid () |
Inquire if the device is valid. More... | |
Public Member Functions inherited from MpInputDeviceDriver | |
MpInputDeviceDriver (const UtlString &name, MpInputDeviceManager &deviceManager) | |
Default constructor. More... | |
virtual | ~MpInputDeviceDriver () |
Destructor. More... | |
virtual OsStatus | setDeviceId (MpInputDeviceHandle deviceId) |
Set device ID associated with this device in parent input device manager. More... | |
virtual OsStatus | clearDeviceId () |
Clear the device ID associated with this device. More... | |
virtual MpInputDeviceHandle | getDeviceId () const |
Get device ID associated with this device in parent input device manager. More... | |
uint32_t | getSamplesPerSec () const |
Get the sample rate of this device driver, if enabled. More... | |
uint32_t | getSamplesPerFrame () const |
Get the samples per frame of this device driver, if enabled. More... | |
MpFrameTime | getFramePeriod () |
Calculate the number of milliseconds that a frame occupies in time. More... | |
MpFrameTime | getCurrentFrameTime () const |
Get timestamp for the next frame to be pushed to input device manager. More... | |
const UtlString & | getDeviceName () const |
Get device name. More... | |
virtual UtlBoolean | isEnabled () |
Inquire if this driver is enabled. More... | |
Static Public Member Functions | |
Accessors | |
static MpAudioSample | calculateSample (MpFrameTime frameStartTime, unsigned int magnitude, unsigned int periodInMicroseconds, unsigned int frameSampleIndex, unsigned int samplesPerFrame, unsigned int samplesPerSecond) |
Calculate a sample value for the specified sample in a frame. More... | |
Static Public Member Functions inherited from MpInputDeviceDriver | |
static MpFrameTime | getFramePeriod (unsigned samplesPerFrame, unsigned samplesPerSec) |
Calculate the number of milliseconds that a frame occupies in time. More... | |
Private Member Functions | |
MpSineWaveGeneratorDeviceDriver (const MpSineWaveGeneratorDeviceDriver &rMpSineWaveGeneratorDeviceDriver) | |
Copy constructor (not implemented for this class) More... | |
MpSineWaveGeneratorDeviceDriver & | operator= (const MpSineWaveGeneratorDeviceDriver &rhs) |
Assignment operator (not implemented for this class) More... | |
Private Attributes | |
unsigned int | mMagnitude |
unsigned int | mPeriodInMicroseconds |
int | mRelativeSpeed |
OsServerTask * | mpReaderTask |
Additional Inherited Members | |
Protected Attributes inherited from MpInputDeviceDriver | |
MpInputDeviceManager * | mpInputDeviceManager |
this device driver. More... | |
UtlBoolean | mIsEnabled |
Whether this device driver is enabled or not. More... | |
MpInputDeviceHandle | mDeviceId |
this device, as supplied by the InputDeviceManager. More... | |
unsigned | mSamplesPerFrame |
number of samples. More... | |
unsigned | mSamplesPerSec |
of samples per second. More... | |
MpFrameTime | mCurrentFrameTime |
pushed to input device manager. More... | |
Sine wave generator Input Device Driver.
Implements a MpSineWaveGeneratorDeviceDriver that generates a sine wave of the given magnitude and period (in samples). This device is primarily intended for testing the input device framework as it produces a predictable signal that can be calculated and predetermined, a useful characteristic for unit testing.
MpSineWaveGeneratorDeviceDriver | ( | const UtlString & | name, |
MpInputDeviceManager & | deviceManager, | ||
unsigned int | magnitude, | ||
unsigned int | periodInMicroseconds, | ||
int | relativeSpeed | ||
) |
Default constructor.
name | - unique for this device driver |
deviceManager | - MpInputDeviceManager this device is to push frames to via pushFrame method |
magnitude | - maximum value of sine wave |
periodInMicroseconds | - the length of a complete 360 degree sine wave cycle in micro-seconds. T=zero as determined by the device manager. |
relativeSpeed | - produce frames faster or slower than CPU clock by the given number of microseconds. This is the amount of time sooner (negative) or later (positive) that a frame of samples is produced. The mRelativeSpeed is effectively zero if its magnitude is not greater than the OsTimer granularity or accuracy. |
|
virtual |
Destructor.
|
private |
Copy constructor (not implemented for this class)
|
virtual |
Initialize device driver and state.
This method enables the device driver.
this SHOULD NOT be used to mute/unmute a device. Disabling and enabling a device results in state and buffer queues being cleared.
samplesPerFrame | - the number of samples in a frame of media |
samplesPerSec | - sample rate for media frame in samples per second |
currentFrameTime | - time in milliseconds for beginning of frame relative to the MpInputDeviceManager reference time |
Implements MpInputDeviceDriver.
|
virtual |
Uninitialize device driver.
This method disables the device driver and should release any platform device resources so that the device might be used else where.
this SHOULD NOT be used to mute/unmute a device. Disabling and enabling a device results in state and buffer queues being cleared.
Implements MpInputDeviceDriver.
|
virtual |
Set a new tone to be played.
|
virtual |
Set a new magnitude to be played.
|
static |
Calculate a sample value for the specified sample in a frame.
frameStartTime | - time in milliseconds for the first sample in the frame from the device manager reference time. |
magnitude | - value of sine amplitude. |
periodInMicroseconds | - sine period in micro-seconds. |
frameSampleIndex | - index to the requested sample of the given frame. |
samplesPerFrame | - number of samples in a frame |
samplesPerSecond | - sample rate in samples per second |
|
inlinevirtual |
Inquire if the device is valid.
Implements MpInputDeviceDriver.
|
private |
Assignment operator (not implemented for this class)
|
private |
|
private |
|
private |
|
private |