React Api Reference
    Preparing search index...

    Function runPreCallTest

      • Runs a pre-call test to evaluate the user's network quality and media devices before joining a meeting.
      • Returns a Promise that resolves with the test results or rejects with a PreCallTestError if the test fails.
      • The options parameter can be used to configure the test duration, provide custom media tracks, and receive live stats updates via the onStatsChange callback.
      • The returned Promise also includes a .stop() method, which allows the test to be cancelled before completion.

      Parameters

      • options: {
            audioConfig?: {
                encoderConfig?:
                    | "speech_low_quality"
                    | "speech_standard"
                    | "music_standard"
                    | "standard_stereo"
                    | "high_quality"
                    | "high_quality_stereo";
                microphoneId?: string;
                noiseConfig?: {
                    autoGainControl: boolean;
                    echoCancellation: boolean;
                    noiseSuppression: boolean;
                };
            };
            audioOnly?: boolean;
            audioTrack?: MediaStream;
            onStatsChange?: (stats: object) => void;
            samplingDuration?: number;
            token: string;
            videoConfig?: {
                bitrateMode?: "high_quality" | "balanced" | "bandwidth_optimized";
                cameraId?: string;
                encoderConfig?:
                    | "h90p_w160p"
                    | "h180p_w320p"
                    | "h216p_w384p"
                    | "h360p_w640p"
                    | "h540p_w960p"
                    | "h720p_w1280p"
                    | "h1080p_w1920p"
                    | "h1440p_w2560p"
                    | "h2160p_w3840p"
                    | "h120p_w160p"
                    | "h180p_w240p"
                    | "h240p_w320p"
                    | "h360p_w480p"
                    | "h480p_w640p"
                    | "h540p_w720p"
                    | "h720p_w960p"
                    | "h1080p_w1440p"
                    | "h1440p_w1920p";
                facingMode?: "user"
                | "environment";
                maxLayer?: 2 | 3;
                multiStream?: boolean;
                optimizationMode?: "text" | "motion" | "detail";
            };
            videoTrack?: MediaStream;
        }
        • OptionalaudioConfig?: {
              encoderConfig?:
                  | "speech_low_quality"
                  | "speech_standard"
                  | "music_standard"
                  | "standard_stereo"
                  | "high_quality"
                  | "high_quality_stereo";
              microphoneId?: string;
              noiseConfig?: {
                  autoGainControl: boolean;
                  echoCancellation: boolean;
                  noiseSuppression: boolean;
              };
          }
          • OptionalencoderConfig?:
                | "speech_low_quality"
                | "speech_standard"
                | "music_standard"
                | "standard_stereo"
                | "high_quality"
                | "high_quality_stereo"
            • It will be the encoder configuration you want to use for Audio Track.
            • You can choose from the below mentioned list of values for the encoder config.
            Encoder Config Bitrate Auto Gain Echo Cancellation Noise Suppression
            speech_low_quality 16 kbps TRUE TRUE TRUE
            speech_standard 24 kbps TRUE TRUE TRUE
            music_standard 32 kbps FALSE FALSE FALSE
            standard_stereo 64 kbps FALSE FALSE FALSE
            high_quality 128 kbps FALSE FALSE FALSE
            high_quality_stereo 192 kbps FALSE FALSE FALSE
            "speech_standard"
            
          • OptionalmicrophoneId?: string

            It will be the id of the mic from which the audio should be captured.

          • OptionalnoiseConfig?: {
                autoGainControl: boolean;
                echoCancellation: boolean;
                noiseSuppression: boolean;
            }

            Configuration for audio noise processing.

            • autoGainControl: boolean

              If true auto gain will turned on else it would be turned off.

            • echoCancellation: boolean

              If true echo cancellation will turned on else it would be turned off.

            • noiseSuppression: boolean

              If true noise suppression will turned on else it would be turned off.

        • OptionalaudioOnly?: boolean

          Skips the camera test and runs the pre-call test using audio only.

          false
          
        • OptionalaudioTrack?: MediaStream

          Your own microphone track that is created by createMicrophoneAudioTrack.

        • OptionalonStatsChange?: (stats: object) => void

          Receives the latest network stats while the test is running.

        • OptionalsamplingDuration?: number

          Duration for sampling stats during the test, in milliseconds. Minimum: 10000, Maximum: 120000.

          15000
          
        • token: string

          Authentication token used to authorize SDK operations. You can generate a token in the following ways:

          1. Temporary Token – Generate it from the Dashboard API Keys.
          2. Server-generated Token – Generate a JWT on your backend and fetch it securely.
        • OptionalvideoConfig?: {
              bitrateMode?: "high_quality" | "balanced" | "bandwidth_optimized";
              cameraId?: string;
              encoderConfig?:
                  | "h90p_w160p"
                  | "h180p_w320p"
                  | "h216p_w384p"
                  | "h360p_w640p"
                  | "h540p_w960p"
                  | "h720p_w1280p"
                  | "h1080p_w1920p"
                  | "h1440p_w2560p"
                  | "h2160p_w3840p"
                  | "h120p_w160p"
                  | "h180p_w240p"
                  | "h240p_w320p"
                  | "h360p_w480p"
                  | "h480p_w640p"
                  | "h540p_w720p"
                  | "h720p_w960p"
                  | "h1080p_w1440p"
                  | "h1440p_w1920p";
              facingMode?: "user"
              | "environment";
              maxLayer?: 2 | 3;
              multiStream?: boolean;
              optimizationMode?: "text" | "motion" | "detail";
          }
          • OptionalbitrateMode?: "high_quality" | "balanced" | "bandwidth_optimized"

            Controls the video quality and bandwidth consumption. You can choose between high_quality for the best picture, bandwidth_optimized to save data, or balanced for a mix of both. Defaults to balanced.

            Allowed Value: BitrateMode

            BitrateMode.BALANCED
            
          • OptionalcameraId?: string

            It will be the id of the camera from which the video should be captured.

          • OptionalencoderConfig?:
                | "h90p_w160p"
                | "h180p_w320p"
                | "h216p_w384p"
                | "h360p_w640p"
                | "h540p_w960p"
                | "h720p_w1280p"
                | "h1080p_w1920p"
                | "h1440p_w2560p"
                | "h2160p_w3840p"
                | "h120p_w160p"
                | "h180p_w240p"
                | "h240p_w320p"
                | "h360p_w480p"
                | "h480p_w640p"
                | "h540p_w720p"
                | "h720p_w960p"
                | "h1080p_w1440p"
                | "h1440p_w1920p"

            You can choose from the below mentioned list of values for the encoder config.

            Supported values include:

            Encoder Config Resolution Frame Rate Optimized (kbps) Balanced (kbps) High Quality (kbps)
            h90p_w160p 160x90 15 fps 60 100 150
            h180p_w320p 320x180 15 fps 100 150 250
            h216p_w384p 384x216 15 fps 120 200 350
            h360p_w640p 640x360 20 fps 200 400 600
            h540p_w960p 960x540 25 fps 350 550 800
            h720p_w1280p 1280x720 30 fps 1000 1500 2000
            h1080p_w1920p 1920x1080 30 fps 1600 2200 2700
            h1440p_w2560p 2560x1440 30 fps 5000 5500 6000
            h2160p_w3840p 3840x2160 30 fps 8000 8500 9000
            h120p_w160p 160x120 15 fps 60 100 150
            h180p_w240p 240x180 15 fps 100 150 250
            h240p_w320p 320x240 15 fps 120 200 350
            h360p_w480p 480x360 20 fps 200 400 600
            h480p_w640p 640×480 25 fps 300 500 700
            h540p_w720p 720×540 30 fps 350 550 800
            h720p_w960p 960×720 30 fps 900 1300 1600
            h1080p_w1440p 1440×1080 30 fps 1600 2200 2700
            h1440p_w1920p 1920×1440 30 fps 3500 4000 4500

            Note

            Above mentioned encoder configurations are valid for both, landscape as well as portrait mode.

            "h720p_w1280p"
            
          • OptionalfacingMode?: "user" | "environment"

            Specifies whether to use the front or back camera for the video track.

          • OptionalmaxLayer?: 2 | 3

            Specifies the maximum number of simulcast layers to publish. Only effective when multiStream is true.

          • OptionalmultiStream?: boolean

            It will specify if the stream should send multiple resolution layers or single resolution layer.

            Info

            For meetings with fewer than or equal to four participants, setting multiStream:false is regarded as best practice.

            true
            
          • OptionaloptimizationMode?: "text" | "motion" | "detail"

            It will specify the optimization mode for the video track being generated.

        • OptionalvideoTrack?: MediaStream

          Your own camera track that is created by createCameraVideoTrack.

      Returns Promise<
          {
              aborted: boolean;
              camera: object;
              microphone: object;
              network: object;
              testDuration: number;
          },
      > & { stop(): Promise<void> }

      • stop: function
        • Idempotent method to stop the ongoing pre-call test. Cleans up all allocated resources and resolves once teardown is complete.

          Returns Promise<void>

      import { runPreCallTest } from "@videosdk.live/react-sdk";

      runPreCallTest({
      token: TOKEN,
      samplingDuration: 120000,
      audioOnly: true,
      videoTrack: customVideoTrack,
      audioTrack: customAudioTrack,
      onStatsChange: (stats) => {
      console.log("stats", stats);
      },
      })
      .then((result) => {
      console.log("Pre-call test result:", result);
      })
      .catch((err) => {
      console.log("code : " + err.code);
      console.log("message : " + err.message);
      });