AgoraRTC is the entry point for all the methods that can be called in Agora Web SDK.

You can use the AgoraRTC methods to create Client and Stream objects.

Other methods of the AgoraRTC object check for system requirements and set up error logging.

Index

Variables

Const VERSION

VERSION: string

The version of the Agora Web SDK.

example

AgoraRTC.VERSION

Functions

checkSystemRequirements

  • checkSystemRequirements(): boolean
  • Checks the Web Browser Compatibility

    This method checks the compatibility between the Web SDK and the current web browser.

    Use this method before calling createClient to check the compatibility between the system and the web browser.

    Note:

    Agora has yet to conduct comprehensive tests on Chromium kernel browsers, such as QQ and 360. Agora will gradually achieve compatibility on most mainstream browsers in subsequent versions of the Web SDK.

    Returns boolean

    • true: The Web SDK is compatible with the current web browser.
    • false: The Web SDK is not compatible with the current web browser.

createClient

  • Creates a Client Object

    This method creates and returns a client object. You can only call this method once each call session.

    example

    AgoraRTC.createClient(config)

    Parameters

    Returns Client

createStream

  • Creates a Stream Object

    This method creates and returns a stream object.

    example

    AgoraRTC.createStream(spec)

    Parameters

    Returns Stream

getDevices

  • getDevices(callback: function): void
  • Enumerates the Media Devices

    This method enumerates the available media input and output devices, such as microphones, cameras, headsets, and so on.

    If this method succeeds, the SDK returns a list of media devices in an array of MediaDeviceInfo objects.

    Note:

    On Safari 12.1 or later, call this method after calling createStream successfully.

    example

    Sample code

    AgoraRTC.getDevices (function(devices) {
    var devCount = devices.length;
    
    var id = devices[0].deviceId;
    });

    Parameters

    Returns void

getScreenSources

  • getScreenSources(callback: function): void
  • Gets the Sources for Screen-sharing

    To share the screen on Electron, call this method to get the screen sources. See Share the Screen for details.

    If this method succeeds, the SDK returns a list of screen sources in an array of DesktopCapturerSource objects.

    example

    Sample code

    AgoraRTC.getScreenSources(function(err, sources) {
      console.log(sources)
    }

    Parameters

    Returns void

getSupportedCodec

  • getSupportedCodec(supportedCodecOptions?: object): Promise<object>
  • Gets the supported codec of the web browser

    This method returns the codecs supported by both the Agora Web SDK and the web browser. The Agora Web SDK supports VP8 and H.264 for video, and OPUS for audio.

    Note:

    • This method supports all web browsers. For web browsers that do not support WebRTC or are not recognized, the returned codec list is empty.
    • The returned codec list is based on the SDP used by the web browser and for reference only.
    • Some Android phones might claim to support H.264 but have problems in communicating with other platforms using H.264. In this case, we recommend using the VP8 codec.
    example

    Sample code

    // Gets the supported decoding formats as the receiver
    AgoraRTC.getSupportedCodec()
      .then(function(result){
        console.log(`Supported video codec: ${result.video.join(",")}`);
        console.log(`Supported audio codec: ${result.audio.join(",")}`);
      });
    
    // Gets the supported encoding formats as the sender
    navigator.mediaDevices.getUserMedia({video: true, audio: true})
     .then(function(mediaStream){
        return AgoraRTC.getSupportedCodec({stream: mediaStream});
     })
     .then(function(result){
        console.log(`Supported video codec: ${result.video.join(",")}`);
        console.log(`Supported audio codec: ${result.audio.join(",")}`);
     });

    Parameters

    • Optional supportedCodecOptions: object
      • stream: MediaStream

        (Optional) Specifies a MediaStream object.

        If this parameter is empty, this method gets the supported decoding formats of the web browser as the receiver. Otherwise the method gets the supported encoding formats as the sender. In most cases, the supported decoding and encoding formats are the same.

    Returns Promise<object>

    Returns a Promise object. In the .then(function(result){}) callback, result has the following properties:

    • video: array, the supported video codecs. The array might include "H264" and "VP8", or be empty.
    • audio: array, the supported audio codecs. The array might include "OPUS", or be empty.