sipxmedialib  Version 3.3
Classes | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
MpidWinMM Class Reference

Container for the Microsoft Windows Multimedia specific input driver. More...

#include <MpidWinMM.h>

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

Classes

class  MpWinInputAudioDeviceNotifier
 

Public Member Functions

Creators
 MpidWinMM (const UtlString &name, MpInputDeviceManager &deviceManager, unsigned nInputBuffers=DEFAULT_N_INPUT_BUFS)
 Default constructor. More...
 
virtual ~MpidWinMM ()
 Destructor. More...
 
Manipulators
OsStatus enableDevice (unsigned samplesPerFrame, unsigned samplesPerSec, MpFrameTime currentFrameTime)
 Initialize device driver and state. More...
 
OsStatus disableDevice ()
 Uninitialize device driver. More...
 
Inquiry
UtlBoolean isDeviceValid ()
 Inquire if the windows 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 UtlString getDefaultDeviceName ()
 get the windows name of the default wave input device. 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...
 

Protected Member Functions

WAVEHDR * initWaveHeader (int n)
 Zero out a wave header, so it is ready to be filled in by windows. More...
 
void processAudioInput (HWAVEIN hwi, UINT uMsg, void *dwParam1)
 Processes incoming audio data. More...
 

Static Protected Member Functions

static void CALLBACK waveInCallbackStatic (HWAVEIN hwi, UINT uMsg, void *dwInstance, void *dwParam1, void *dwParam2)
 Callback function for receiving data from windows audio. More...
 
static bool nameIsSame (const UtlString &a, const UtlString &b)
 
static IMMDeviceEnumerator * getWinDeviceEnumerator ()
 
static void registerDeviceEnumerator (IMMDeviceEnumerator *deviceEnumeratorPtr, IMMNotificationClient *winAudioDeviceChangeCallback)
 
static void unregisterDeviceEnumerator (IMMDeviceEnumerator *deviceEnumeratorPtr, IMMNotificationClient *winAudioDeviceChangeCallback)
 
static void getWinNameForDevice (IMMDeviceEnumerator *deviceEnumeratorPtr, const LPCWSTR winDeviceId, UtlString &deviceName)
 

Private Member Functions

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

Private Attributes

int mWinMMDeviceId
 
HWAVEIN mDevHandle
 The Microsoft handle for this audio input device. More...
 
unsigned mNumInBuffers
 
unsigned mWaveBufSize
 
WAVEHDR * mpWaveHeaders
 Array of nNumInBuffers wave headers. More...
 
LPSTR * mpWaveBuffers
 Array of nNumInBuffers wave buffers. More...
 
UtlBoolean mIsOpen
 Boolean indicating waveInOpen() completed. More...
 
unsigned mnAddBufferFailures
 within the callback has failed since last enabled. More...
 
IMMNotificationClient * mWinAudioDeviceChangeCallback
 device state changes. More...
 
IMMDeviceEnumerator * mDeviceEnumeratorPtr
 

Friends

class MpodWinMM
 

Additional Inherited Members

- Protected Attributes inherited from MpInputDeviceDriver
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...
 

Detailed Description

Container for the Microsoft Windows Multimedia specific input driver.

The MpidWinMM device driver wrapper is the concrete container containing the implementation of the windows multimedia wave audio input interface. This is currently driven by callbacks.

See also
MpInputDeviceDriver

Constructor & Destructor Documentation

MpidWinMM ( const UtlString &  name,
MpInputDeviceManager deviceManager,
unsigned  nInputBuffers = DEFAULT_N_INPUT_BUFS 
)

Default constructor.

Parameters
[in]name- unique device driver name (e.g. "YAMAHA AC-XG WDM Audio", etc.)
[in]deviceManager- MpInputDeviceManager this device is to push frames to via pushFrame method
[in]nOutputBuffers- The number of frame-sized buffers to register with Windows to fill with frames of audio data, in case we're not fast enough to process them.
~MpidWinMM ( )
virtual

Destructor.

MpidWinMM ( const MpInputDeviceDriver rMpInputDeviceDriver)
private

Copy constructor (not implemented for this class)

Member Function Documentation

OsStatus enableDevice ( unsigned  samplesPerFrame,
unsigned  samplesPerSec,
MpFrameTime  currentFrameTime 
)
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
[in]samplesPerFrame- the number of samples in a frame of media
[in]samplesPerSec- sample rate for media frame in samples per second
[in]currentFrameTime- time in milliseconds for beginning of frame relative to the MpInputDeviceManager reference time
[in]deviceId- device Id used to identify this input device to MpInputDeviceManager for pushFrame calls.

Implements MpInputDeviceDriver.

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

UtlString getDefaultDeviceName ( )
static

get the windows name of the default wave input device.

UtlBoolean isDeviceValid ( )
inlinevirtual

Inquire if the windows device is valid.

Implements MpInputDeviceDriver.

WAVEHDR * initWaveHeader ( int  n)
protected

Zero out a wave header, so it is ready to be filled in by windows.

Initialize all the values in the wave header indicated by n.

Parameters
[in]n- The index into mpWaveHeaders indicating which wave header to initialize.
Returns
a pointer to the wave header that was initialized.
void processAudioInput ( HWAVEIN  hwi,
UINT  uMsg,
void *  dwParam1 
)
protected

Processes incoming audio data.

This method, called by the static callback function waveInCallbackStatic, processes audio input data from the windows waveform audio functions, passing the results to the input manager.

void CALLBACK waveInCallbackStatic ( HWAVEIN  hwi,
UINT  uMsg,
void *  dwInstance,
void *  dwParam1,
void *  dwParam2 
)
staticprotected

Callback function for receiving data from windows audio.

This static method is called by the windows waveform audio functions passing incoming audio data to be processed. This function then passes the results on to processAudioInput()

bool nameIsSame ( const UtlString &  a,
const UtlString &  b 
)
staticprotected
IMMDeviceEnumerator * getWinDeviceEnumerator ( )
staticprotected
void registerDeviceEnumerator ( IMMDeviceEnumerator *  deviceEnumeratorPtr,
IMMNotificationClient *  winAudioDeviceChangeCallback 
)
staticprotected
void unregisterDeviceEnumerator ( IMMDeviceEnumerator *  deviceEnumeratorPtr,
IMMNotificationClient *  winAudioDeviceChangeCallback 
)
staticprotected
void getWinNameForDevice ( IMMDeviceEnumerator *  deviceEnumeratorPtr,
const LPCWSTR  winDeviceId,
UtlString &  deviceName 
)
staticprotected
MpidWinMM& operator= ( const MpInputDeviceDriver rhs)
private

Assignment operator (not implemented for this class)

Friends And Related Function Documentation

friend class MpodWinMM
friend

Member Data Documentation

int mWinMMDeviceId
private

The underlying windows Device ID (not the logical Mp device ID)

HWAVEIN mDevHandle
private

The Microsoft handle for this audio input device.

unsigned mNumInBuffers
private

The number of buffers to supply to windows for audio processing.

unsigned mWaveBufSize
private

The size, in bytes, of mpWaveBuffer after allocation.

WAVEHDR* mpWaveHeaders
private

Array of nNumInBuffers wave headers.

LPSTR* mpWaveBuffers
private

Array of nNumInBuffers wave buffers.

UtlBoolean mIsOpen
private

Boolean indicating waveInOpen() completed.

unsigned mnAddBufferFailures
private

within the callback has failed since last enabled.

The number of times that addBuffer called

IMMNotificationClient* mWinAudioDeviceChangeCallback
private

device state changes.

Callback interface for audio

IMMDeviceEnumerator* mDeviceEnumeratorPtr
private