The Agora Web SDK (WebRTC) is a JavaScript library loaded by an HTML web page.
The Agora Web SDK library uses APIs in the web browser to establish connections and control the communication and live broadcast services.
AgoraRTC is the entry point for all the methods that can be called in Agora Web SDK.
AgoraRTC includes the following classes.
Class | Description |
---|---|
Client | Represents a user in a call session. Provides much of the core AgoraRTC functionality. |
ClientConfig | Defines the properties of the Client object created by createClient. |
Stream | Represents a published audio or video stream. |
StreamSpec | Defines the properties of the Stream object created by createStream. |
LocalStreamStats | Provides connection statistics of a local stream. |
RemoteStreamStats | Provides connection statistics of a remote stream. |
LiveTranscoding | Defines user-specific CDN live audio/video transcoding settings. |
MediaDeviceInfo | Provides information of a single media input or output device. |
Use the createClient method to create a Client object and get started.
A Client object is a representation of a local or remote user in a call session, and provides access to much of the core AgoraRTC functionality, see the table below.
Method | Description |
---|---|
init | Initializes a client object. |
join | Joins an AgoraRTC channel. |
leave | Leaves an AgoraRTC channel. |
publish | Publishes a local stream. |
unpublish | Unpublishes the local stream. |
subscribe | Subscribes to a remote stream. |
unsubscribe | Unsubscribes from the remote stream. |
enableDualStream | Enables the dual-stream mode on the publisher side. The term dual streams refers to a hybrid of a high-bitrate, high-resolution video stream and a low-bitrate, a low-resolution video stream. |
setLowStreamParameter | Sets the low-video stream profile if the dual-stream mode is enabled. |
setRemoteVideoStreamType | When a remote user sends dual streams, this method decides on which stream to receive on the subscriber side. |
setStreamFallbackOption | Use this method to set stream fallback option on the subscriber. Under poor network conditions, the SDK can choose to subscribe to the low-video stream or only the audio stream. |
disableDualStream | Disables the dual-stream mode. |
enableAudioVolumeIndicator | Enables the SDK to report the active speaker and his/her volume regularly. |
startLiveStreaming | Sends a stream to a URL address and starts a CDN live streaming. |
setLiveTranscoding | Sets the video layout and audio for CDN live. (CDN live only) |
stopLiveStreaming | Removes the voice or video stream URL from a live broadcast and stops live streaming. |
setProxyServer | Deploys the Nginx server. |
setTurnServer | Deploys the TURN server. |
setEncryptionSecret | Enables the built-in encryption. |
setEncryptionMode | Sets the encryption mode. |
renewToken | Renews the token. If you have used Token when joining the channel, call this method to renew your Token when it expires. |
renewChannelKey | Renews the channel key. If you have used channel key when joining the channel, call this method to renew your channel key when it expires. |
getNetworkStats | Retrieves the statistics of the system network. |
getSystemStats | Retrieves the statistics of the system. |
getRecordingDevices | Enumerates the audio input devices such as microphones. |
getPlayoutDevices | Enumerates the audio output devices such as speakers. |
getCameras | Enumerates the video input devices such as cameras. |
getRemoteAudioStats | Retrieves the audio statistics of the remote streams. |
getLocalAudioStats | Retrieves the audio statistics of the published local streams. |
getRemoteVideoStats | Retrieves the video statistics of the remote streams. |
getLocalVideoStats | Retrieves the video statistics of the published local streams. |
getTransportStats | Retrieves the transmission statistics between the App and the Agora service. |
Call the createStream method to create a Stream object.
A Stream object represents a published local or remote media stream object in a call session, and provides methods for stream settings, listed in the table below.
Method | Description |
---|---|
init | Initializes the stream object. |
play | Plays the audio or video stream. |
stop | Stops playing the stream. |
close | Closes the media input device, for example a camera. |
enableAudio | Enables the audio track in the stream. |
disableAudio | Disables the audio track in the stream. |
enableVideo | Enables the video track in the stream. |
disableVideo | Disables the video track in the stream. |
hasAudio | Retrieves the audio flag. |
hasVideo | Retrieves the video flag. |
getAudioLevel | Retrieves the current audio level. |
getAudioTrack | Retrieves the audio track in the stream. |
getVideoTrack | Retrieves the video track in the stream. |
replaceTrack | Replaces the audio or video track in the local stream. |
addTrack | Adds audio or video tracks to the stream. |
removeTrack | Removes the audio or video tracks from the stream. |
setAudioProfile | Sets the audio profile of the stream. |
setAudioVolume | Sets the volume of the remote stream. |
setAudioOutput | Sets the audio output device of the remote stream. You can use it to switch between the microphone and the speakerphone. |
switchDevice | Switches the media input devices, for example microphones, speakers, and cameras. |
setVideoProfile | Sets the video profile of the stream. |
setScreenProfile | Sets the screen profile in screen-sharing. |
startAudioMixing | Starts audio mixing. |
stopAudioMixing | Stops audio mixing. |
pauseAudioMixing | Pauses audio mixing. |
resumeAudioMixing | Resumes audio mixing. |
adjustAudioMixingVolume | Adjusts the volume while audio mixing. |
getAudioMixingDuration | Retrieves the duration (ms) of the audio mixing. |
getAudioMixingCurrentPosition | Retrieves the playback position (ms) of the audio mixing. |
setAudioMixingPosition | Sets the playback position of the audio mixing file to a different start position (by default played from the beginning). |
getId | Retrieves the stream ID. |
getStats | Retrieves the connection statistics of the stream. |
Use the Client.on and Stream.on methods to add event listeners for events dispatched by the Client and Stream methods.
See Error Codes and Warning Codes for details.