Voice SDK for Web v4.22.2

Index

Enumerations

Classes

Interfaces

Type aliases

Events

Variables

Functions

Type aliases

AudioEncoderConfigurationPreset

AudioEncoderConfigurationPreset: keyof typeof AUDIO_ENCODER_CONFIG_SETTINGS

The preset audio encoder configurations.

You can pass the preset video encoder configurations when calling the following methods:

The following table lists all the preset audio profiles. The SDK uses "music_standard" by default.

Audio Profile Configurations
"speech_low_quality" Sample rate 16 kHz, mono, encoding bitrate 24 Kbps
"speech_standard" Sample rate 32 kHz, mono, encoding bitrate 24 Kbps
"music_standard" Sample rate 48 kHz, mono, encoding bitrate 32 Kbps
"standard_stereo" Sample rate 48 kHz, stereo, encoding bitrate 64 Kbps
"high_quality" Sample rate 48 kHz, mono, encoding bitrate 128 Kbps
"high_quality_stereo" Sample rate 48 kHz, stereo, encoding bitrate 192 Kbps

AudioSourceState

AudioSourceState: "stopped" | "playing" | "paused"

Processing state of the audio buffer:

  • "stopped": The SDK stops processing the audio buffer. Reasons may include:
  • The SDK finishes processing the audio buffer.
  • The user manually stops the processing of the audio buffer.
  • "playing": The SDK is processing the audio buffer.
  • "paused": The SDK pauses processing the audio buffer.

You can get the state with BufferSourceAudioTrack.on("source-state-change").

CheckVideoVisibleResult

CheckVideoVisibleResult: CheckVisibleResult

The visibility of the <video> tag.

Get the visibility of the <video> tag through the following methods and events:

This object contains the following parameters:

  • visible: Boolean, whether the <video> tag is visible or not.
  • reason: This parameter is only valid when visible is false, which indicates the reason:
    • "SIZE": The size of <video> is too small to see.
    • "STYLE": The CSS styles of <video> or its ancestor element cause <video> to be invisible.
    • "POSITION": The <video> tag or its ancestor element are positioned outside the viewport.
    • "COVERED": The <video> tag is covered by other elements.

ClientRole

ClientRole: "audience" | "host"

The user role in a live broadcast channel.

  • "host": Host. A host can both publish tracks and subscribe to tracks.
  • "audience": Audience. An audience can only subscribe to tracks.

ConnectionState

ConnectionState: "DISCONNECTED" | "CONNECTING" | "RECONNECTING" | "CONNECTED" | "DISCONNECTING"

Connection state between the SDK and Agora's edge server.

You can get the connection state through connectionState.

The connection between the SDK and the edge server has the following states:

  • "DISCONNECTED": The SDK is disconnected from the server.
  • This is the initial state until you call join.
  • The SDK also enters this state after you call leave, when the user is banned, or when the connection fails.
  • "CONNECTING": The SDK is connecting to the server. The SDK enters this state when you call join.
  • "CONNECTED": The SDK is connected to the server and joins a channel. The user can now publish streams or subscribe to streams in the channel.
  • "RECONNECTING": The SDK is reconnecting to the server. If the connection is lost because the network is down or switched, the SDK enters this state.
  • "DISCONNECTING": The SDK is disconnecting from the server. The SDK enters this state when you call leave.

DeviceState

DeviceState: "ACTIVE" | "INACTIVE"

The state of the media input device.

  • "ACTIVE": The device is plugged in.
  • "INACTIVE": The device is unplugged.

EncryptionMode

EncryptionMode: "aes-128-xts" | "aes-256-xts" | "aes-128-ecb" | "sm4-128-ecb" | "aes-128-gcm" | "aes-256-gcm" | "aes-128-gcm2" | "aes-256-gcm2" | "none"

The encryption mode, which is used in the setEncryptionConfig method call.

  • "aes-128-xts": 128-bit AES encryption, XTS mode.
  • "aes-256-xts": 256-bit AES encryption, XTS mode.
  • "aes-128-gcm": 128-bit AES encryption, GCM mode.
  • "aes-256-gcm": 256-bit AES encryption, GCM mode.
  • "aes-128-gcm2": 128-bit AES encryption, GCM mode, with salt.
  • "aes-256-gcm2": 256-bit AES encryption, GCM mode, with salt.
  • "aes-128-ecb": 128-bit AES encryption, ECB mode.
  • "sm4-128-ecb": 128-bit SM4 encryption, ECB mode.
  • "none": No encryption.

OptimizationMode

OptimizationMode: "motion" | "detail"

The video transmission optimization mode:

  • "detail": Prioritizes video quality.
    • The browser ensures high-quality images by automatically calculating a minimum bitrate based on the capturing resolution and frame rate. No matter how poor the network condition is, the sending bitrate will never be lower than the minimum value.
    • In most cases, the browser does not reduce the sending resolution, but may reduce the frame rate.
  • "motion": Since v4.21.0, the browser prioritizes video smoothness.
    • In poor network conditions, the browser reduces the sending bitrate to minimize video freezes.
    • In most cases, the browser does not reduce the frame rate, but may reduce the sending resolution.

RequiredOnlyOneOf

RequiredOnlyOneOf<T, K>: object[K] extends infer O ? object : never

Type parameters

  • T

  • K: keyof T

SDK_CODEC

SDK_CODEC: keyof typeof VideoCodec

The codec that the Web browser uses for encoding.

  • "vp8": Use VP8 for encoding.
  • "h264": Use H.264 for encoding.
  • "vp9": (Beta) Use VP9 for encoding.
  • "av1": Use AV1 for encoding.

Safari 12.1 or earlier does not support the VP8 codec.

SDK_MODE

SDK_MODE: "live" | "rtc" | "p2p"

The channel profile.

The SDK differentiates channel profiles and applies different optimization algorithms accordingly. For example, it prioritizes smoothness and low latency for a video call, and prioritizes video quality for a video broadcast.

The SDK supports the following channel profiles:

  • "live": Sets the channel profile as live broadcast. You need to go on to call setClientRole to set the client as either a host or an audience. A host can send and receive audio or video, while an audience can only receive audio or video.
  • "rtc": Sets the channel profile as communication. It is used for a one-on-one call or a group call where all users in the channel can converse freely.

ScreenAudioTrackInitConfig

ScreenAudioTrackInitConfig: AudioTrackInitConfig

Configurations for the audio track of screen sharing. Set these configurations when calling AgoraRTC.createScreenVideoTrack to enable audio during screen sharing.

ScreenEncoderConfigurationPreset

ScreenEncoderConfigurationPreset: keyof typeof SUPPORT_SCREEN_ENCODER_CONFIG_LIST

The preset video encoder configurations for screen sharing.

You can pass the preset video encoder configurations when calling AgoraRTC.createScreenVideoTrack.

The following table lists all the preset video profiles for screen sharing.

Video Profile Resolution (Width×Height) Frame Rate (fps)
"480p" 640 × 480 5
"480p_1" 640 × 480 5
"480p_2" 640 × 480 30
"480p_3" 640 × 480 15
"720p" 1280 × 720 5
"720p_1" 1280 × 720 5
"720p_2" 1280 × 720 30
"720p_3" 1280 × 720 15
"720p_auto" 1280 × 720 30
"1080p" 1920 × 1080 5
"1080p_1" 1920 × 1080 5
"1080p_2" 1920 × 1080 30
"1080p_3" 1920 × 1080 15

"720p_auto" is only recommended to be set on Safari to ensure dynamic adjustment of the encoding resolution. For details, see the release notes.

ScreenSourceType

ScreenSourceType: "screen" | "window" | "application"

The type of the source for screen sharing.

  • "screen": Sharing the whole screen.
  • "application": Sharing all windows of an app.
  • "window": Sharing a window of an app.

UID

UID: number | string

The user ID to identify a user in the channel.

Each user in the same channel should have a unique user ID with the same data type (number or string).

To ensure a better end-user experience, Agora recommends using a number as the user ID. See join for details.

VideoEncoderConfigurationPreset

VideoEncoderConfigurationPreset: keyof typeof SUPPORT_VIDEO_ENCODER_CONFIG_LIST

The preset video encoder configurations.

You can pass the preset video encoder configurations when calling AgoraRTC.createCameraVideoTrack or AgoraRTC.createScreenVideoTrack.

The following table lists all the preset video profiles. The SDK uses "480p_1" by default.

Video Profile Resolution (Width×Height) Frame Rate (fps) Chrome Firefox Safari
120p 160 × 120 15
120p_1 160 × 120 15
120p_3 120 × 120 15
180p 320 × 180 15
180p_1 320 × 180 15
180p_3 180 × 180 15
180p_4 240 × 180 15
240p 320 × 240 15
240p_1 320 × 240 15
240p_3 240 × 240 15
240p_4 424 × 240 15
360p 640 × 360 15
360p_1 640 × 360 15
360p_3 360 × 360 15
360p_4 640 × 360 30
360p_6 360 × 360 30
360p_7 480 × 360 15
360p_8 480 × 360 30
360p_9 640 × 360 15
360p_10 640 × 360 24
360p_11 640 × 360 24
480p 640 × 480 15
480p_1 640 × 480 15
480p_2 640 × 480 30
480p_3 480 × 480 15
480p_4 640 × 480 30
480p_6 480 × 480 30
480p_8 848 × 480 15
480p_9 848 × 480 30
480p_10 640 × 480 10
720p 1280 × 720 15
720p_1 1280 × 720 15
720p_2 1280 × 720 30
720p_3 1280 × 720 30
720p_auto 1280 × 720 30
720p_5 960 × 720 15
720p_6 960 × 720 30
1080p 1920 × 1080 15
1080p_1 1920 × 1080 15
1080p_2 1920 × 1080 30
1080p_3 1920 × 1080 30
1080p_5 1920 × 1080 60

"720p_auto" is only recommended to be set on Safari to ensure dynamic adjustment of the encoding resolution. For details, see the release notes.

Events

track-updated

  • track-updated(track: MediaStreamTrack): void
  • Triggers when a media track is updated.

    Parameters

    Returns void

Variables

Const AgoraRTC

AgoraRTC: IAgoraRTC

Functions

content-inspect-connection-state-change

  • content-inspect-connection-state-change(preState: InspectState, newState: InspectState): void
  • Parameters

    • preState: InspectState
    • newState: InspectState

    Returns void

content-inspect-error

  • content-inspect-error(error?: AgoraRTCError): void
  • Parameters

    • Optional error: AgoraRTCError

    Returns void

image-moderation-connection-state-change