sipxmedialib  Version 3.3
Protected Attributes | Private Member Functions | List of all members
MpInputDeviceDriver Class Referenceabstract

Container for device specific input driver. More...

#include <MpInputDeviceDriver.h>

Inheritance diagram for MpInputDeviceDriver:
Inheritance graph
[legend]
Collaboration diagram for MpInputDeviceDriver:
Collaboration graph
[legend]

Protected Attributes

MpInputDeviceManagermpInputDeviceManager
 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...
 

Private Member Functions

 MpInputDeviceDriver (const MpInputDeviceDriver &rMpInputDeviceDriver)
 Copy constructor (not implemented for this class) More...
 
MpInputDeviceDriveroperator= (const MpInputDeviceDriver &rhs)
 Assignment operator (not implemented for this class) More...
 

Creators

 MpInputDeviceDriver (const UtlString &name, MpInputDeviceManager &deviceManager)
 Default constructor. More...
 
virtual ~MpInputDeviceDriver ()
 Destructor. More...
 

Manipulators

virtual OsStatus enableDevice (unsigned samplesPerFrame, unsigned samplesPerSec, MpFrameTime currentFrameTime=0)=0
 Initialize device driver and state. More...
 
virtual OsStatus disableDevice ()=0
 Uninitialize device driver. 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...
 

Accessors

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...
 
static MpFrameTime getFramePeriod (unsigned samplesPerFrame, unsigned samplesPerSec)
 Calculate the number of milliseconds that a frame occupies in time. More...
 

Inquiry

virtual UtlBoolean isEnabled ()
 Inquire if this driver is enabled. More...
 
virtual UtlBoolean isDeviceValid ()=0
 Inquire if the device is valid. More...
 

Detailed Description

Container for device specific input driver.

The MpInputDeviceDriver is the abstract container for the implementation of input media drivers. An instance of MpInputDeviceDriver is created for every physical and logical input device (e.g. microphone). A driver is instantiated and then added to the MpInputDeviceManager. The driver must be enabled via the MpInputDeviceManager before it yields input frames.

The MpInputDeviceDriver obtains frames of audio from hardware and provides them to the MpInputDeviceManager which makes the frames available to MprFromInputDevice resources in flowgraphs. The MpInputDeviceDriver may be an OsTask which runs and gets frames for the OS and hardware specific device or MpInputDeviceDriver may be driven via callbacks from the OS/hardware input device driver. This is an implementation choice.

MpInputDeviceDriver has a text name which is defined upon construction. This name will typically be the same as the OS defined name for the input device. The name of the MpInputDeviceDriver is accessed via the data() method inherited from UtlString. This allows MpInputDeviceDriver to be contained and accessed by name.

Constructor & Destructor Documentation

MpInputDeviceDriver ( const UtlString &  name,
MpInputDeviceManager deviceManager 
)

Default constructor.

Parameters
name- unique device driver name (e.g. "/dev/dsp", "YAMAHA AC-XG WDM Audio", etc.)
deviceManager- MpInputDeviceManager this device is to push frames to via pushFrame method
~MpInputDeviceDriver ( )
virtual

Destructor.

MpInputDeviceDriver ( const MpInputDeviceDriver rMpInputDeviceDriver)
private

Copy constructor (not implemented for this class)

Member Function Documentation

virtual OsStatus enableDevice ( unsigned  samplesPerFrame,
unsigned  samplesPerSec,
MpFrameTime  currentFrameTime = 0 
)
pure 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.

Parameters
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

Implemented in MpSineWaveGeneratorDeviceDriver, MpidAndroid, MpidWinMM, MpidOss, MpidCoreAudio, and MpidAlsa.

OsStatus disableDevice ( )
pure 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.

Implemented in MpSineWaveGeneratorDeviceDriver, MpidWinMM, MpidAndroid, MpidOss, MpidAlsa, and MpidCoreAudio.

OsStatus setDeviceId ( MpInputDeviceHandle  deviceId)
virtual

Set device ID associated with this device in parent input device manager.

OsStatus clearDeviceId ( )
virtual

Clear the device ID associated with this device.

MpInputDeviceHandle getDeviceId ( ) const
virtual

Get device ID associated with this device in parent input device manager.

uint32_t getSamplesPerSec ( void  ) const
inline

Get the sample rate of this device driver, if enabled.

uint32_t getSamplesPerFrame ( void  ) const
inline

Get the samples per frame of this device driver, if enabled.

MpFrameTime getFramePeriod ( )
inline

Calculate the number of milliseconds that a frame occupies in time.

static MpFrameTime getFramePeriod ( unsigned  samplesPerFrame,
unsigned  samplesPerSec 
)
inlinestatic

Calculate the number of milliseconds that a frame occupies in time.

MpFrameTime getCurrentFrameTime ( ) const
inline

Get timestamp for the next frame to be pushed to input device manager.

const UtlString & getDeviceName ( ) const
inline

Get device name.

UtlBoolean isEnabled ( )
virtual

Inquire if this driver is enabled.

virtual UtlBoolean isDeviceValid ( )
pure virtual

Inquire if the device is valid.

Implemented in MpSineWaveGeneratorDeviceDriver, MpidWinMM, MpidAlsa, MpidOss, MpidAndroid, and MpidCoreAudio.

MpInputDeviceDriver& operator= ( const MpInputDeviceDriver rhs)
private

Assignment operator (not implemented for this class)

Member Data Documentation

MpInputDeviceManager* mpInputDeviceManager
protected

this device driver.

The object that manages

UtlBoolean mIsEnabled
protected

Whether this device driver is enabled or not.

MpInputDeviceHandle mDeviceId
protected

this device, as supplied by the InputDeviceManager.

The logical device ID that identifies

unsigned mSamplesPerFrame
protected

number of samples.

Device produce audio frame with this

unsigned mSamplesPerSec
protected

of samples per second.

Device produce audio with this number

MpFrameTime mCurrentFrameTime
protected

pushed to input device manager.

Timestamp for the next frame to be