Overview

最終更新日:2021-04-14 19:00:19

    Supported Platforms

    Proposed by Google, the WebRTC technology is well supported by Chrome (desktop), Edge (desktop), Firefox (desktop), and Safari (desktop and mobile), but poorly or not supported by other platforms such as browsers on Android.

    • If your application scenario is mainly in the education sector, consider using TRTC SDK for Electron, which supports two-channel big/small video images, with more flexible screen sharing schemes and better recovery capabilities on poor network connections.
    OS BrowserMinimum Browser
    Version Requirement
    Receive (Playback)Send (Broadcast)Screen SharingSDK Version Requirement
    macOS Safari (desktop) 11+ Supported Supported Supported (on Safari 13+) -
    Chrome (desktop) 56+ Supported Supported Supported (on Chrome 72+) -
    Firefox (desktop) 56+ Supported Supported Supported (on Firefox 66+) 4.7.0+
    Edge (desktop) 80+ Supported Supported Supported 4.7.0+
    Windows Chrome (desktop) 56+ Supported Supported Supported (on Chrome 72+) -
    QQ browser (desktop, WebKit core) 10.4+ Supported Supported Not supported -
    Firefox (desktop) 56+ Supported Supported Supported (on Firefox 66+) 4.7.0+
    Edge (desktop) 80+ Supported Supported Supported 4.7.0+
    iOS 11.1.2+ Safari (mobile) 11+ Supported Supported Not supported -
    iOS 12.1.4+ WeChat embedded browser - Supported Not supported Not supported -
    iOS 14.3+ WeChat embedded browser WeChat 6.5+ Supported Supported Not supported -
    Android QQ browser (mobile) - Not supported Not supported Not supported -
    UC browser (mobile) - Not supported Not supported Not supported -
    WeChat embedded browser (TBS core) - Supported Supported Not supported -
    WeChat embedded browser (XWEB core) - Supported Supported Not supported -

    API Guide

    The tutorials below offer detailed instructions on how to use different APIs.

    Feature Sample Code
    Basic audio/video call Tutorial
    Interactive live streaming Tutorial
    Switching cameras/mics Tutorial
    Setting local video attributes Tutorial
    Dynamically enabling/disabling local audio/video Tutorial
    Sharing screen Tutorial
    Detecting volume Tutorial
    Custom capturing and playback rendering Tutorial
    Specifying the maximum number of upstream users in a room Tutorial
    Adding music and audio effects Tutorial

    TRTC

    Note:

    This document applies to 4.x.x versions of TRTC SDK for desktop browsers.

    TRTC is the main entry to TRTC SDK for desktop browsers. You can use TRTC methods to create a client object (Client) and local audio/video stream object (Stream) for real-time communication, check a browser's compatibility and whether it supports screen sharing, as well as set log levels and upload logs.

    API Description
    VERSION Gets the version number of TRTC SDK for desktop browsers.
    checkSystemRequirements Checks whether a browser supports TRTC SDK for desktop browsers; if not, ask users to download the latest version of Chrome.
    isScreenShareSupported Checks whether the browser supports screen sharing. Call this method before creating a screen sharing stream.
    getDevices Returns the list of media input/output devices.
    getCameras Returns the list of cameras.
    getMicrophones Returns the list of mics.
    getSpeakers Returns the list of speakers.
    createClient Creates a client object for real-time audio/video calls. This method needs to be called only once for each call.
    createStream Creates a local Stream object, which uses the publish() method to publish local audio/video stream.

    TRTC.Logger

    TRTC.Logger provides methods for log settings such as log output level setting and log upload enabling/disabling.

    API Description
    setLogLevel Sets the log output level.
    enableUploadLog Enables log upload.
    disableUploadLog Disables log upload.

    Client

    The audio/video call client object Client is created through createClient() and represents an audio/video call.

    API Description
    setProxyServer Sets proxy servers. This method is suitable where you deploy proxy servers, e.g., Nginx + Coturn, by yourself.
    setTurnServer Sets TURN servers. This method is used along with setProxyServer() and is suitable where you deploy proxy and TURN servers by yourself.
    join Enters a room, which starts an audio/video call. If the room does not exist, the system will create one.
    leave Exits the current room, which ends the current audio/video call.
    publish Publishes local audio/video stream. This method can be called only after room entry using the join() method. Only one local stream can be published in one audio/video call.
    unpublish Unpublishes local stream.
    subscribe Subscribes to a remote stream.
    unsubscribe Unsubscribes from a remote stream.
    switchRole Switches user roles. This method works only in the interactive live streaming mode (live).
    on Listens for client object events.
    getRemoteMutedState Gets the list of the audio/video mute status of remote users in the current room.
    getLocalAudioStats Gets audio statistics of published local streams. This method can be used only after publish() is called.
    getLocalVideoStats Gets video statistics of published local streams. This method can be used only after publish() is called.
    getRemoteAudioStats Gets audio statistics of all current remote streams.
    getRemoteVideoStats Gets video statistics of all current remote streams.

    LocalStream

    LocalStream (local audio/video stream) is created through createStream and is a subclass of Stream.

    API Description
    initialize Initializes local audio/video stream objects.
    setAudioProfile Sets audio profiles. This method can be used only before initialize() is called.
    setVideoProfile Sets video profiles. This method can be used only before initialize() is called.
    setScreenProfile Sets screen sharing profiles. This method can be used only before initialize() is called.
    setVideoContentHint Sets video content hints, mainly in order to improve the video encoding quality in different scenarios. This method can be used only after initialize() is called.
    switchDevice Switches media input devices.
    addTrack Adds an audio or video track.
    removeTrack Removes the video track.
    replaceTrack Replaces audio or video track.
    play Starts playing audio/video stream.
    stop Stops playing audio/video stream.
    resume Resumes playing audio/video stream.
    close Closes audio/video stream.
    muteAudio Disables the audio track.
    muteVideo Disables the video track.
    unmuteAudio Enables the audio track.
    unmuteVideo Enables the video track.
    getId Gets the unique stream ID.
    getUserId Gets the ID of the user to whom the stream belongs.
    setAudioOutput Sets the audio output device.
    getAudioLevel Gets the current audio level. This method works only if there is audio data in local or remote stream.
    hasAudio Specifies whether there is an audio track.
    hasVideo Specifies whether there is a video track.
    getAudioTrack Gets the audio track.
    getVideoTrack Gets the video track.
    getVideoFrame Gets the current video frame.
    on Listens for stream events.

    RemoteStream

    Remote audio/video stream, which is obtained by listening for the Client.on('stream-added') event and is a subclass of [Stream]().

    API Description
    getType Gets the remote stream type. This method is mainly used to determine whether a remote stream is a primary audio/video stream or secondary video stream (which is usually a screen sharing stream).
    play Starts playing audio/video stream.
    stop Stops playing audio/video stream.
    resume Resumes playing audio/video stream.
    close Closes audio/video stream.
    muteAudio Disables the audio track.
    muteVideo Disables the video track.
    unmuteAudio Enables the audio track.
    unmuteVideo Enables the video track.
    getId Gets the unique stream ID.
    getUserId Gets the ID of the user to whom the stream belongs.
    setAudioOutput Sets the audio output device.
    setAudioVolume Sets the audio level.
    getAudioLevel Gets the current audio level. This method works only if there is audio data in local or remote stream.
    hasAudio Specifies whether there is an audio track.
    hasVideo Specifies whether there is a video track.
    getAudioTrack Gets the audio track.
    getVideoTrack Gets the video track.
    getVideoFrame Gets the current video frame.
    on Listens for stream events.

    RtcError

    RtcError object.

    API Description
    getCode Gets the error code.