Audio
You can control user audio for an ongoing session using methods provided by the Video SDK. Session hosts can manage their own audio and video as well the audio and video of other users in the session.
Check if the user is connected to audio
Before implementing audio controls, you must first check if the user is connected to audio by getting the user's ZoomVideoSDKAudioType.
// 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, you can mute a user's audio by calling muteAudio:
// Get the IZoomVideoSDKAudioHelper to perform audio actions.
IZoomVideoSDKAudioHelper* pAudioHelper = m_pVideoSDK->getAudioHelper();
if (pAudioHelper) {
// Mute user.
pAudioHelper->muteAudio(pUser);
}
Unmute audio
Unmute a user's audio in a similar manner using unmuteAudio:
// Get the IZoomVideoSDKAudioHelper to perform audio actions.
IZoomVideoSDKAudioHelper* pAudioHelper = m_pVideoSDK->getAudioHelper();
if (pAudioHelper) {
// Unmute user.
pAudioHelper->unMuteAudio(pUser);
}
Disconnect from audio
To disconnect completely from audio, use the 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.
Get notified when a user's audio status has changed
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());
}
}
Get notified when a user's active audio changes
// onUserActiveAudioChanged is different from onUserAudioStatusChanged. onUserActiveAudioChanged is called when a given user's audio changes, while onUserAudioStatusChanged is called when the user's audio status changes. For example, if the user is unmuted and is using their device's microphone, this callback will be triggered whenever their 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());
}
}