Preview

Before joining a session, you can give users a preview of their video and audio by starting the camera and microphone locally. The local video and audio can be accessed through IZoomVideoSDKVideoHelper and IZoomVideoSDKTestAudioDeviceHelper respectively.

Preview camera

To preview a camera on Windows, you will need a video UI control (such as QT, GTK, SDL, OpenCV, or another) and stream YUV420 raw data frames into the UI control as a video.

//Get list of all cameras
IVideoSDKVector<IZoomVideoSDKCameraDevice*> *cameras = ZoomVideoSDKMgr::GetInst().getVideoHelper()->getCameraList();
//Get ID of selected camera
const zchar_t* deviceID = cameras->GetItem(0)->getDeviceId();
//Start Preview, and handle the callback in a ZoomVideoSDKRawDataPipeDelegate instance
ZoomVideoSDKRawDataPipeDelegate* dataDelegate = new ZoomVideoSDKRawDataPipeDelegate();
	ZoomVideoSDKMgr::GetInst().getVideoHelper()->startVideoPreview(dataDelegate, deviceID);
//Handle callback
void ZoomVideoSDKRawDataPipeDelegate::onRawDataFrameReceived(YUVRawDataI420* data)
{
	const int width = data->GetStreamWidth();
	const int height = data->GetStreamHeight();
	const int bufLen = data->GetBufferLen();
	const int rotation = data->GetRotation();
	const int sourceID = data->GetSourceID();
}

Preview audio

See the following restrictions and prerequisites for testing the microphone and speakers.

Restriction

Users can only test their audio after joining a session with the SDK, for example, if they're in a waiting room.

Prerequisites

  • Video SDK Account
  • Microphone, such as the built in microphone, a USB microphone (if supported), or an inline microphone on headphones
  • Speaker or headphones

Preview microphone

  1. Override the following two callbacks in IZoomVideoSDKDelegate. For example, when the volume changes (available levels are from 0 to 10).

    void SampleClass::onMicSpeakerVolumeChanged(unsigned int micVolume, unsigned int speakerVolume)
    {
    	//TODO
    }
    void SampleClass::onTestMicStatusChanged(ZoomVideoSDK_TESTMIC_STATUS status)
    {
    	//TODO
    }
    
  2. Start a microphone testing session.

    // Use IZoomVideoSDKAudioHelper to get the microphone list for testing
    IZoomVideoSDKAudioHelper* audio_helper = pVideoSdkObj->getAudioHelper();
    IVideoSDKVector<IZoomVideoSDKMicDevice*>* pMicList = audio_helper->getMicList();
    // Use the first one as an example
    IZoomVideoSDKMicDevice* pMicDevice = pMicList->GetItem(0);
    const zchar_t* pDeviceID = pMicList->getDeviceId();
    // Use IZoomVideoSDKTestAudioDeviceHelper start the microphone test.
    IZoomVideoSDK* pVideoSdkObj = CreateZoomVideoSDKObj();
    IZoomVideoSDKTestAudioDeviceHelper* pAudioDeviceTest = pVideoSdkObj->GetAudioDeviceTestHelper();
    ZoomVideoSDKErrors error = pAudioDeviceTest->startMicTestRecording(pDeviceID);
    
  3. Stop the microphone testing session

    ZoomVideoSDKErrors error = pAudioDeviceTest->stopMicTestRecording();
    

Preview speakers

Zoom Video SDK currently only supports MP3 files for speaker tests. The size of the file cannot exceed 1 MB. You must add your own MP3 file and make it accessible from the user's device when they run the test. Follow these steps to configure and run the test.

  1. Add the MP3 file to your project.

  2. Ensure that the user's device can access the MP3 file to use for the test. Define the speaker test audio file path in ZoomVideoSDKInitParams and add the MP3 file path under its extendParam.speakerTestFilePath variable. Be sure that the path is valid and not null.

    ZoomVideoSDKInitParams initParams;
    ZoomVideoSDKExtendParams extendParams;
    extendParam.speakerTestFilePath = <speakerFilePath>;
    
  3. Under the same ZoomVideoSDKInitParams, which is used to set the domain and enable the log, add the ZoomVideoSDKExtendParams variable under its extendParam. Then get the helper to test the speaker.

    initParams.extendParam = extendParams;
    
  4. Start the speaker test. If it's successful, you'll receive the callback onMicSpeakerVolumeChanged with the speaker volume.

    IZoomVideoSDKAudioHelper* audio_helper = pVideoSdkObj->getAudioHelper();
    IVideoSDKVector<IZoomVideoSDKSpeakerDevice*>* pSpeakerList = audio_helper->getSpeakerList();
    // Use the first one as an example
    IZoomVideoSDKSpeakerDevice* pSpeakerDevice = pSpeakerList->GetItem(0);
    const zchar_t* pDeviceID = pSpeakerDevice->getDeviceId();
    ZoomVideoSDKErrors error = pAudioDeviceTest->startSpeakerTest(pDeviceID);
    
  5. Stop the speaker test.

    ZoomVideoSDKErrors error = pAudioDeviceTest->stopSpeakerTest();