BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJSIP Reference

pj::AudDevManager Class Reference

#include <media.hpp>

Public Member Functions

int getCaptureDev () const PJSUA2_THROW(Error)
 
AudioMediagetCaptureDevMedia () PJSUA2_THROW(Error)
 
int getPlaybackDev () const PJSUA2_THROW(Error)
 
AudioMediagetPlaybackDevMedia () PJSUA2_THROW(Error)
 
void setCaptureDev (int capture_dev) const PJSUA2_THROW(Error)
 
void setPlaybackDev (int playback_dev) const PJSUA2_THROW(Error)
 
const AudioDevInfoVectorenumDev () PJSUA2_THROW(Error)
 
AudioDevInfoVector2 enumDev2 () const PJSUA2_THROW(Error)
 
void setNullDev () PJSUA2_THROW(Error)
 
MediaPortsetNoDev ()
 
void setSndDevMode (unsigned mode) const PJSUA2_THROW(Error)
 
void setEcOptions (unsigned tail_msec, unsigned options) PJSUA2_THROW(Error)
 
unsigned getEcTail () const PJSUA2_THROW(Error)
 
bool sndIsActive () const
 
void refreshDevs () PJSUA2_THROW(Error)
 
unsigned getDevCount () const
 
AudioDevInfo getDevInfo (int id) const PJSUA2_THROW(Error)
 
int lookupDev (const string &drv_name, const string &dev_name) const PJSUA2_THROW(Error)
 
string capName (pjmedia_aud_dev_cap cap) const
 
void setExtFormat (const MediaFormatAudio &format, bool keep=true) PJSUA2_THROW(Error)
 
MediaFormatAudio getExtFormat () const PJSUA2_THROW(Error)
 
void setInputLatency (unsigned latency_msec, bool keep=true) PJSUA2_THROW(Error)
 
unsigned getInputLatency () const PJSUA2_THROW(Error)
 
void setOutputLatency (unsigned latency_msec, bool keep=true) PJSUA2_THROW(Error)
 
unsigned getOutputLatency () const PJSUA2_THROW(Error)
 
void setInputVolume (unsigned volume, bool keep=true) PJSUA2_THROW(Error)
 
unsigned getInputVolume () const PJSUA2_THROW(Error)
 
void setOutputVolume (unsigned volume, bool keep=true) PJSUA2_THROW(Error)
 
unsigned getOutputVolume () const PJSUA2_THROW(Error)
 
unsigned getInputSignal () const PJSUA2_THROW(Error)
 
unsigned getOutputSignal () const PJSUA2_THROW(Error)
 
void setInputRoute (pjmedia_aud_dev_route route, bool keep=true) PJSUA2_THROW(Error)
 
pjmedia_aud_dev_route getInputRoute () const PJSUA2_THROW(Error)
 
void setOutputRoute (pjmedia_aud_dev_route route, bool keep=true) PJSUA2_THROW(Error)
 
pjmedia_aud_dev_route getOutputRoute () const PJSUA2_THROW(Error)
 
void setVad (bool enable, bool keep=true) PJSUA2_THROW(Error)
 
bool getVad () const PJSUA2_THROW(Error)
 
void setCng (bool enable, bool keep=true) PJSUA2_THROW(Error)
 
bool getCng () const PJSUA2_THROW(Error)
 
void setPlc (bool enable, bool keep=true) PJSUA2_THROW(Error)
 
bool getPlc () const PJSUA2_THROW(Error)
 

Friends

class Endpoint
 

Detailed Description

Audio device manager.

Member Function Documentation

◆ getCaptureDev()

int pj::AudDevManager::getCaptureDev ( ) const

Get currently active capture sound devices. If sound devices has not been created, it is possible that the function returns -1 as device IDs.

Returns
Device ID of the capture device.

◆ getCaptureDevMedia()

AudioMedia& pj::AudDevManager::getCaptureDevMedia ( )

Get the AudioMedia of the capture audio device.

Returns
Audio media for the capture device.

◆ getPlaybackDev()

int pj::AudDevManager::getPlaybackDev ( ) const

Get currently active playback sound devices. If sound devices has not been created, it is possible that the function returns -1 as device IDs.

Returns
Device ID of the playback device.

◆ getPlaybackDevMedia()

AudioMedia& pj::AudDevManager::getPlaybackDevMedia ( )

Get the AudioMedia of the speaker/playback audio device.

Returns
Audio media for the speaker/playback device.

◆ setCaptureDev()

void pj::AudDevManager::setCaptureDev ( int  capture_dev) const

Select or change capture sound device. Application may call this function at any time to replace current sound device. Calling this method will not change the state of the sound device (opened/closed). Note that this method will override the mode set by setSndDevMode().

Parameters
capture_devDevice ID of the capture device.

◆ setPlaybackDev()

void pj::AudDevManager::setPlaybackDev ( int  playback_dev) const

Select or change playback sound device. Application may call this function at any time to replace current sound device. Calling this method will not change the state of the sound device (opened/closed). Note that this method will override the mode set by setSndDevMode().

Parameters
playback_devDevice ID of the playback device.

◆ enumDev()

const AudioDevInfoVector& pj::AudDevManager::enumDev ( )

Warning: deprecated, use enumDev2 instead. This function is not safe in multithreaded environment.

Enum all audio devices installed in the system. This function is not safe in multithreaded environment.

Returns
The list of audio device info.

◆ enumDev2()

AudioDevInfoVector2 pj::AudDevManager::enumDev2 ( ) const

Enum all audio devices installed in the system.

Returns
The list of audio device info.

◆ setNullDev()

void pj::AudDevManager::setNullDev ( )

Set pjsua to use null sound device. The null sound device only provides the timing needed by the conference bridge, and will not interract with any hardware.

◆ setNoDev()

MediaPort* pj::AudDevManager::setNoDev ( )

Disconnect the main conference bridge from any sound devices, and let application connect the bridge to it's own sound device/master port.

Returns
The port interface of the conference bridge, so that application can connect this to it's own sound device or master port.

◆ setSndDevMode()

void pj::AudDevManager::setSndDevMode ( unsigned  mode) const

Set sound device mode.

Parameters
modeThe sound device mode, as bitmask combination of pjsua_snd_dev_mode

◆ setEcOptions()

void pj::AudDevManager::setEcOptions ( unsigned  tail_msec,
unsigned  options 
)

Change the echo cancellation settings.

The behavior of this function depends on whether the sound device is currently active, and if it is, whether device or software AEC is being used.

If the sound device is currently active, and if the device supports AEC, this function will forward the change request to the device and it will be up to the device on whether support the request. If software AEC is being used (the software EC will be used if the device does not support AEC), this function will change the software EC settings. In all cases, the setting will be saved for future opening of the sound device.

If the sound device is not currently active, this will only change the default AEC settings and the setting will be applied next time the sound device is opened.

Parameters
tail_msecThe tail length, in miliseconds. Set to zero to disable AEC.
optionsOptions to be passed to pjmedia_echo_create(). Normally the value should be zero.

◆ getEcTail()

unsigned pj::AudDevManager::getEcTail ( ) const

Get current echo canceller tail length.

Returns
The EC tail length in milliseconds, If AEC is disabled, the value will be zero.

◆ sndIsActive()

bool pj::AudDevManager::sndIsActive ( ) const

Check whether the sound device is currently active. The sound device may be inactive if the application has set the auto close feature to non-zero (the sndAutoCloseTime setting in MediaConfig), or if null sound device or no sound device has been configured via the setNoDev() function.

◆ refreshDevs()

void pj::AudDevManager::refreshDevs ( )

Refresh the list of sound devices installed in the system. This method will only refresh the list of audio device so all active audio streams will be unaffected. After refreshing the device list, application MUST make sure to update all index references to audio devices before calling any method that accepts audio device index as its parameter.

◆ getDevCount()

unsigned pj::AudDevManager::getDevCount ( ) const

Get the number of sound devices installed in the system.

Returns
The number of sound devices installed in the system.

◆ getDevInfo()

AudioDevInfo pj::AudDevManager::getDevInfo ( int  id) const

Get device information.

Parameters
idThe audio device ID.
Returns
The device information which will be filled in by this method once it returns successfully.

◆ lookupDev()

int pj::AudDevManager::lookupDev ( const string &  drv_name,
const string &  dev_name 
) const

Lookup device index based on the driver and device name.

Parameters
drv_nameThe driver name.
dev_nameThe device name.
Returns
The device ID. If the device is not found, Error will be thrown.

◆ capName()

string pj::AudDevManager::capName ( pjmedia_aud_dev_cap  cap) const

Get string info for the specified capability.

Parameters
capThe capability ID.
Returns
Capability name.

◆ setExtFormat()

void pj::AudDevManager::setExtFormat ( const MediaFormatAudio format,
bool  keep = true 
)

This will configure audio format capability (other than PCM) to the sound device being used. If sound device is currently active, the method will forward the setting to the sound device instance to be applied immediately, if it supports it.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_EXT_FORMAT capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Note that in case the setting is kept for future use, it will be applied to any devices, even when application has changed the sound device to be used.

Parameters
formatThe audio format.
keepSpecify whether the setting is to be kept for future use.

◆ getExtFormat()

MediaFormatAudio pj::AudDevManager::getExtFormat ( ) const

Get the audio format capability (other than PCM) of the sound device being used. If sound device is currently active, the method will forward the request to the sound device. If sound device is currently inactive, and if application had previously set the setting and mark the setting as kept, then that setting will be returned. Otherwise, this method will raise error.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_EXT_FORMAT capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Returns
The audio format.

◆ setInputLatency()

void pj::AudDevManager::setInputLatency ( unsigned  latency_msec,
bool  keep = true 
)

This will configure audio input latency control or query capability to the sound device being used. If sound device is currently active, the method will forward the setting to the sound device instance to be applied immediately, if it supports it.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Note that in case the setting is kept for future use, it will be applied to any devices, even when application has changed the sound device to be used.

Parameters
latency_msecThe input latency.
keepSpecify whether the setting is to be kept for future use.

◆ getInputLatency()

unsigned pj::AudDevManager::getInputLatency ( ) const

Get the audio input latency control or query capability of the sound device being used. If sound device is currently active, the method will forward the request to the sound device. If sound device is currently inactive, and if application had previously set the setting and mark the setting as kept, then that setting will be returned. Otherwise, this method will raise error.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Returns
The audio input latency.

◆ setOutputLatency()

void pj::AudDevManager::setOutputLatency ( unsigned  latency_msec,
bool  keep = true 
)

This will configure audio output latency control or query capability to the sound device being used. If sound device is currently active, the method will forward the setting to the sound device instance to be applied immediately, if it supports it.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Note that in case the setting is kept for future use, it will be applied to any devices, even when application has changed the sound device to be used.

Parameters
latency_msecThe output latency.
keepSpecify whether the setting is to be kept for future use.

◆ getOutputLatency()

unsigned pj::AudDevManager::getOutputLatency ( ) const

Get the audio output latency control or query capability of the sound device being used. If sound device is currently active, the method will forward the request to the sound device. If sound device is currently inactive, and if application had previously set the setting and mark the setting as kept, then that setting will be returned. Otherwise, this method will raise error.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Returns
The audio output latency.

◆ setInputVolume()

void pj::AudDevManager::setInputVolume ( unsigned  volume,
bool  keep = true 
)

This will configure audio input volume level capability to the sound device being used. If sound device is currently active, the method will forward the setting to the sound device instance to be applied immediately, if it supports it.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Note that in case the setting is kept for future use, it will be applied to any devices, even when application has changed the sound device to be used.

Parameters
volumeThe input volume level, in percent.
keepSpecify whether the setting is to be kept for future use.

◆ getInputVolume()

unsigned pj::AudDevManager::getInputVolume ( ) const

Get the audio input volume level capability of the sound device being used. If sound device is currently active, the method will forward the request to the sound device. If sound device is currently inactive, and if application had previously set the setting and mark the setting as kept, then that setting will be returned. Otherwise, this method will raise error.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING capability in AudioDevInfo.caps flags, otherwise Error will be thrown. *

Returns
The audio input volume level, in percent.

◆ setOutputVolume()

void pj::AudDevManager::setOutputVolume ( unsigned  volume,
bool  keep = true 
)

This will configure audio output volume level capability to the sound device being used. If sound device is currently active, the method will forward the setting to the sound device instance to be applied immediately, if it supports it.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Note that in case the setting is kept for future use, it will be applied to any devices, even when application has changed the sound device to be used.

Parameters
volumeThe output volume level, in percent.
keepSpecify whether the setting is to be kept for future use.

◆ getOutputVolume()

unsigned pj::AudDevManager::getOutputVolume ( ) const

Get the audio output volume level capability of the sound device being used. If sound device is currently active, the method will forward the request to the sound device. If sound device is currently inactive, and if application had previously set the setting and mark the setting as kept, then that setting will be returned. Otherwise, this method will raise error.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Returns
The audio output volume level, in percent.

◆ getInputSignal()

unsigned pj::AudDevManager::getInputSignal ( ) const

Get the audio input signal level capability of the sound device being used. If sound device is currently active, the method will forward the request to the sound device. If sound device is currently inactive, and if application had previously set the setting and mark the setting as kept, then that setting will be returned. Otherwise, this method will raise error.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_INPUT_SIGNAL_METER capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Returns
The audio input signal level, in percent.

◆ getOutputSignal()

unsigned pj::AudDevManager::getOutputSignal ( ) const

Get the audio output signal level capability of the sound device being used. If sound device is currently active, the method will forward the request to the sound device. If sound device is currently inactive, and if application had previously set the setting and mark the setting as kept, then that setting will be returned. Otherwise, this method will raise error.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_OUTPUT_SIGNAL_METER capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Returns
The audio output signal level, in percent.

◆ setInputRoute()

void pj::AudDevManager::setInputRoute ( pjmedia_aud_dev_route  route,
bool  keep = true 
)

This will configure audio input route capability to the sound device being used. If sound device is currently active, the method will forward the setting to the sound device instance to be applied immediately, if it supports it.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Note that in case the setting is kept for future use, it will be applied to any devices, even when application has changed the sound device to be used.

Parameters
routeThe audio input route.
keepSpecify whether the setting is to be kept for future use.

◆ getInputRoute()

pjmedia_aud_dev_route pj::AudDevManager::getInputRoute ( ) const

Get the audio input route capability of the sound device being used. If sound device is currently active, the method will forward the request to the sound device. If sound device is currently inactive, and if application had previously set the setting and mark the setting as kept, then that setting will be returned. Otherwise, this method will raise error.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Returns
The audio input route.

◆ setOutputRoute()

void pj::AudDevManager::setOutputRoute ( pjmedia_aud_dev_route  route,
bool  keep = true 
)

This will configure audio output route capability to the sound device being used. If sound device is currently active, the method will forward the setting to the sound device instance to be applied immediately, if it supports it.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Note that in case the setting is kept for future use, it will be applied to any devices, even when application has changed the sound device to be used.

Parameters
routeThe audio output route.
keepSpecify whether the setting is to be kept for future use.

◆ getOutputRoute()

pjmedia_aud_dev_route pj::AudDevManager::getOutputRoute ( ) const

Get the audio output route capability of the sound device being used. If sound device is currently active, the method will forward the request to the sound device. If sound device is currently inactive, and if application had previously set the setting and mark the setting as kept, then that setting will be returned. Otherwise, this method will raise error.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Returns
The audio output route.

◆ setVad()

void pj::AudDevManager::setVad ( bool  enable,
bool  keep = true 
)

This will configure audio voice activity detection capability to the sound device being used. If sound device is currently active, the method will forward the setting to the sound device instance to be applied immediately, if it supports it.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_VAD capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Note that in case the setting is kept for future use, it will be applied to any devices, even when application has changed the sound device to be used.

Parameters
enableEnable/disable voice activity detection feature. Set true to enable.
keepSpecify whether the setting is to be kept for future use.

◆ getVad()

bool pj::AudDevManager::getVad ( ) const

Get the audio voice activity detection capability of the sound device being used. If sound device is currently active, the method will forward the request to the sound device. If sound device is currently inactive, and if application had previously set the setting and mark the setting as kept, then that setting will be returned. Otherwise, this method will raise error.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_VAD capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Returns
The audio voice activity detection feature.

◆ setCng()

void pj::AudDevManager::setCng ( bool  enable,
bool  keep = true 
)

This will configure audio comfort noise generation capability to the sound device being used. If sound device is currently active, the method will forward the setting to the sound device instance to be applied immediately, if it supports it.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_CNG capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Note that in case the setting is kept for future use, it will be applied to any devices, even when application has changed the sound device to be used.

Parameters
enableEnable/disable comfort noise generation feature. Set true to enable.
keepSpecify whether the setting is to be kept for future use.

◆ getCng()

bool pj::AudDevManager::getCng ( ) const

Get the audio comfort noise generation capability of the sound device being used. If sound device is currently active, the method will forward the request to the sound device. If sound device is currently inactive, and if application had previously set the setting and mark the setting as kept, then that setting will be returned. Otherwise, this method will raise error.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_CNG capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Returns
The audio comfort noise generation feature.

◆ setPlc()

void pj::AudDevManager::setPlc ( bool  enable,
bool  keep = true 
)

This will configure audio packet loss concealment capability to the sound device being used. If sound device is currently active, the method will forward the setting to the sound device instance to be applied immediately, if it supports it.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_PLC capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Note that in case the setting is kept for future use, it will be applied to any devices, even when application has changed the sound device to be used.

Parameters
enableEnable/disable packet loss concealment feature. Set true to enable.
keepSpecify whether the setting is to be kept for future use.

◆ getPlc()

bool pj::AudDevManager::getPlc ( ) const

Get the audio packet loss concealment capability of the sound device being used. If sound device is currently active, the method will forward the request to the sound device. If sound device is currently inactive, and if application had previously set the setting and mark the setting as kept, then that setting will be returned. Otherwise, this method will raise error.

This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_PLC capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

Returns
The audio packet loss concealment feature.

The documentation for this class was generated from the following file:

 


PJSIP Open Source, high performance, small footprint, and very very portable SIP stack
Copyright (C) 2006-2008 Teluu Inc.