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

Container for device specific input CoreAudio driver. More...

#include <MpidCoreAudio.h>

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

Public Member Functions

Creators
 MpidCoreAudio (const UtlString &name, MpInputDeviceManager &deviceManager)
 Default constructor. More...
 
 ~MpidCoreAudio ()
 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 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...
 

Protected Member Functions

void pushFrame ()
 Push audio frame to InputDeviceManager. More...
 
void skipFrame ()
 Add frame time to mCurrentFrameTime. More...
 
bool setAudioUnitFormat (const AudioStreamBasicDescription &ds)
 
bool initResempler (const AudioStreamBasicDescription &ds)
 
bool setBuffers ()
 

Static Protected Member Functions

static void propertyListener (void *inRefCon, AudioUnit ci, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement)
 
static OSStatus renderProc (void *inRefCon, AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)
 
static OSStatus ACproc (AudioConverterRef inAudioConverter, UInt32 *ioDataPackets, AudioBufferList *ioData, AudioStreamPacketDescription **inUserData, void *inUData)
 

Protected Attributes

AudioUnit mInputUnit
 AudioUnit input handle. More...
 
AudioConverterRef mConverter
 Sample rate converter. More...
 
CoreAudioHardware mDevice
 CoreAudio hardware device handle. More...
 
double mInputSampleRate
 Device smaple rate. More...
 
MpAudioSamplemAudioFrame
 Wave buffer for silence. More...
 
void * mTempBuffer
 Buffer for temporary storage. More...
 
void * mTempBufferHalf
 Pointer to the center of the temp buffer. More...
 
unsigned mTempBufferHalfSize
 Half size of buffer. More...
 
unsigned mInputFrameSize
 Device input frame size. More...
 
- 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...
 

Private Member Functions

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

Additional Inherited Members

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

Detailed Description

Container for device specific input CoreAudio driver.

Constructor & Destructor Documentation

MpidCoreAudio ( const UtlString &  name,
MpInputDeviceManager deviceManager 
)

Default constructor.

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

Destructor.

MpidCoreAudio ( const MpidCoreAudio 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
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.

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.

UtlBoolean isDeviceValid ( )
virtual

Inquire if the device is valid.

Implements MpInputDeviceDriver.

void pushFrame ( )
protected

Push audio frame to InputDeviceManager.

void skipFrame ( )
protected

Add frame time to mCurrentFrameTime.

bool setAudioUnitFormat ( const AudioStreamBasicDescription &  ds)
protected
bool initResempler ( const AudioStreamBasicDescription &  ds)
protected
bool setBuffers ( )
protected
void propertyListener ( void *  inRefCon,
AudioUnit  ci,
AudioUnitPropertyID  inID,
AudioUnitScope  inScope,
AudioUnitElement  inElement 
)
staticprotected
OSStatus renderProc ( void *  inRefCon,
AudioUnitRenderActionFlags *  inActionFlags,
const AudioTimeStamp *  inTimeStamp,
UInt32  inBusNumber,
UInt32  inNumFrames,
AudioBufferList *  ioData 
)
staticprotected
OSStatus ACproc ( AudioConverterRef  inAudioConverter,
UInt32 *  ioDataPackets,
AudioBufferList *  ioData,
AudioStreamPacketDescription **  inUserData,
void *  inUData 
)
staticprotected
MpidCoreAudio& operator= ( const MpidCoreAudio rhs)
private

Assignment operator (not implemented for this class).

Member Data Documentation

AudioUnit mInputUnit
protected

AudioUnit input handle.

AudioConverterRef mConverter
protected

Sample rate converter.

CoreAudioHardware mDevice
protected

CoreAudio hardware device handle.

double mInputSampleRate
protected

Device smaple rate.

MpAudioSample* mAudioFrame
protected

Wave buffer for silence.

void* mTempBuffer
protected

Buffer for temporary storage.

void* mTempBufferHalf
protected

Pointer to the center of the temp buffer.

unsigned mTempBufferHalfSize
protected

Half size of buffer.

unsigned mInputFrameSize
protected

Device input frame size.