Audio
You can control user audio for an ongoing session using IZoomVideoSDKAudioHelper. Session hosts can manage their own audio as well the audio of other users in the session.
Check if the user is connected to audio
Before you can use audio controls, you must first check if the user is connected to audio. Use the ZoomVideoSDKAudioStatus and ZoomVideoSDKAudioType methods to do this.
// Get the user's audioStatus.
ZoomVideoSDKAudioStatus audioStatus = pUserInfo->getAudioStatus();
// Get the user's audioType.
ZoomVideoSDKAudioType audioType = audioStatus.audioType;
Connect to audio
If the user is not already connected, you can connect to the audio through the IZoomVideoSDKAudioHelper.
if (audioType == ZoomVideoSDKAudioType_None) {
// User's audio is not connected.
// Get the IZoomVideoSDKAudioHelper to perform audio actions.
IZoomVideoSDKAudioHelper* pAudioHelper = m_pVideoSDK->getAudioHelper();
if (pAudioHelper) {
// Connect User's audio.
pAudioHelper->startAudio();
}
}
else
{
// User is already connected to audio.
}
Mute audio
Once connected, to mute a user's audio, call muteAudio.
// Get the IZoomVideoSDKAudioHelper to perform audio actions.
IZoomVideoSDKAudioHelper* pAudioHelper = m_pVideoSDK->getAudioHelper();
if (pAudioHelper) {
// Mute user.
pAudioHelper->muteAudio(pUser);
}
Unmute audio
To unmute a user's audio, call unmuteAudio.
// Get the IZoomVideoSDKAudioHelper to perform audio actions.
IZoomVideoSDKAudioHelper* pAudioHelper = m_pVideoSDK->getAudioHelper();
if (pAudioHelper) {
// Unmute user.
pAudioHelper->unMuteAudio(pUser);
}
Disconnect audio
To completely disconnect from audio, call stopAudio.
// Get the IZoomVideoSDKAudioHelper to perform audio actions.
IZoomVideoSDKAudioHelper* pAudioHelper = m_pVideoSDK->getAudioHelper();
if (pAudioHelper) {
// Disconnect User's audio.
pAudioHelper->stopAudio();
}
Sound options
By default, Zoom uses noise suppression and echo cancellation to improve the quality of the audio received by your microphone, but these audio filters can interfere with situations that require capturing the full range of audio. See Configuring professional audio settings for Zoom Meetings for details.
Video SDK uses the same technology to improve audio quality, but also supports the ability to turn off these filters to capture the original sound of the microphone, for example, to support the use of a high-quality microphone with built-in audio filters or to capture the full audio range without noise suppression. Capturing the microphone's original sound disables the background noise suppression feature.
Original sound
To enable original sound, set enableMicOriginalInput to true in the IZoomVideoSDKAudioSettingHelper class. The default setting is false.
IZoomVideoSDKAudioSettingHelper* audio_setting_helper = video_sdk_obj_->getAudioSettingHelper();
audio_setting_helper->enableMicOriginalInput(true);
To disable, set enableMicOriginalInput to false.
audio_setting_helper->enableMicOriginalInput(false);
Background noise suppression
By default, Zoom Video SDK's standard optimized audio is used for processing your microphone audio. This includes some background noise suppression and is best for most situations, but the level of background noise suppression can be adjusted to suit your needs.
Set the noise suppression level using setSuppressBackgroundNoiseLevel in the IZoomVideoSDKAudioSettingHelper class.
IZoomVideoSDKAudioSettingHelper* audio_setting_helper = video_sdk_obj_->getAudioSettingHelper();
audio_setting_helper->setSuppressBackgroundNoiseLevel(ZoomVideoSDKSuppressBackgroundNoiseLevel_High);
You can choose from the following levels:
ZoomVideoSDKSuppressBackgroundNoiseLevel_Auto(the default setting)ZoomVideoSDKSuppressBackgroundNoiseLevel_LowZoomVideoSDKSuppressBackgroundNoiseLevel_MediumZoomVideoSDKSuppressBackgroundNoiseLevel_High
Callbacks
Be sure that you have set up a delegate for callback events to receive audio callbacks.
The onUserAudioStatusChanged callback is different from onUserActiveAudioChanged.
- The SDK calls
onUserAudioStatusChangedwhen the user's audio status changes. - The SDK calls
onUserActiveAudioChangedwhen a given user's active audio changes. For example, if the user is unmuted and is using their device's microphone, the SDK triggers this callback whenever their microphone detects a noise.
See the following examples for details.
Audio status changed
Get notified when a user's audio status has changed (for example, when a user goes unmutes).
void CExampleListener::onUserAudioStatusChanged(IZoomVideoSDKAudioHelper* pAudioHelper, IVideoSDKVector<IZoomVideoSDKUser*>* userList)
{
CString strInfo;
IZoomVideoSDKUser* pUser;
int count = userList->GetCount();
for (int i = 0; i < count; i++)
{
pUser = userList->GetItem(i);
strInfo.Format(_T("A user's audio status changed: name=%s, status=%s"), pUser->getUserName(), pUser->getAudioStatus());
}
}
Active audio changed
Get notified when a user's active audio changes (for example, when an unmuted user's microphone detects a noise).
// onUserActiveAudioChanged triggered when an unmuted user's microphone detects a noise.
void CExampleListener::onUserActiveAudioChanged(IZoomVideoSDKAudioHelper* pAudioHelper, IVideoSDKVector<IZoomVideoSDKUser*>* list)
{
CString strInfo;
IZoomVideoSDKUser* pUser;
int count = list->GetCount();
for (int i = 0; i < count; i++)
{
pUser = list->GetItem(i);
strInfo.Format(_T("User's audio activity changed: name=%s"), pUser->getUserName());
}
}