runPreCallTest

suspend fun runPreCallTest(options: PreCallTestOptions, onStatsChange: (PreCallNetworkQuality) -> Unit? = null): PreCallTestResult

Runs a pre-call test: checks the camera and microphone, publishes them to a test server for the sampling window in options, and scores the uplink and downlink. Run it before createRoom: from that call until the room is left, the test fails with ERROR_PRECALL_AFTER_INIT. Joining a room stops a running test.

Suspends until the test finishes and returns its result. Cancelling the coroutine stops the test, as does stopPreCallTest.

Without a videoTrack / audioTrack in options the test opens the devices itself, as createCameraVideoTrack / createMicrophoneAudioTrack do, so an open camera preview on another track ends. After a successful test those tracks stay open and belong to the app (PreCallMediaReport.track); stop them or publish them. Tracks the app passed are never stopped.

The test never asks for CAMERA / RECORD_AUDIO: request them first.

Code Example:

lifecycleScope.launch {
val result = VideoSDK.runPreCallTest(PreCallTestOptions(token = authToken)) { stats ->
showStats(stats)
}
}

Return

the test result.

Parameters

options

what to test and for how long, plus any tracks to reuse.

onStatsChange

called on the main thread with each stats sample; null for none.

See also

Throws

when the test fails (ERROR_PRECALL_INVALID_TOKEN, ERROR_PRECALL_INVALID_CONFIG, ERROR_PRECALL_TEST_ALREADY_RUNNING, ERROR_PRECALL_AFTER_INIT, ERROR_PRECALL_MEDIA_CHECK_FAILED, …).