BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJSIP Reference

pj::AudDevManager Class Reference

#include <media.hpp>

Public Member Functions

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

Friends

class Endpoint
 

Detailed Description

Audio device manager.

Member Function Documentation

◆ getCaptureDev()

int pj::AudDevManager::getCaptureDev ( ) const
throw (Error
)

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 ( )
throw (Error
)

Get the AudioMedia of the capture audio device.

Returns
Audio media for the capture device.

◆ getPlaybackDev()

int pj::AudDevManager::getPlaybackDev ( ) const
throw (Error
)

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 ( )
throw (Error
)

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
throw (Error
)

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

Parameters
capture_devDevice ID of the capture device.

◆ setPlaybackDev()

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

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

Parameters
playback_devDevice ID of the playback device.

◆ enumDev()

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

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
throw (Error
)

Enum all audio devices installed in the system.

Returns
The list of audio device info.

◆ setNullDev()

void pj::AudDevManager::setNullDev ( )
throw (Error
)

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
throw (Error
)

Set sound device mode.

Note that this method will open the sound device, using current active IDs set via setCaptureDev() or setPlaybackDev(), if the flag PJSUA_SND_DEV_NO_IMMEDIATE_OPEN is not specified.

Parameters
modeThe sound device mode, as bitmask combination of pjsua_snd_dev_mode

◆ setEcOptions()

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

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
throw (Error
)

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 ( )
throw (Error
)

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
throw (Error
)

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
throw (Error
)

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 
)
throw (Error
)

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
throw (Error
)

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 
)
throw (Error
)

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
throw (Error
)

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 
)
throw (Error
)

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
throw (Error
)

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 
)
throw (Error
)

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
throw (Error
)

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 
)
throw (Error
)

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
throw (Error
)

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
throw (Error
)

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
throw (Error
)

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 
)
throw (Error
)

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
throw (Error
)

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 
)
throw (Error
)

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
throw (Error
)

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 
)
throw (Error
)

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
throw (Error
)

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 
)
throw (Error
)

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
throw (Error
)

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 
)
throw (Error
)

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
throw (Error
)

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.