tencent cloud

Feedback

Overview

Last updated: 2022-06-01 11:19:46

    Supported Platforms

    The TRTC web SDK is based on WebRTC and can be used on mainstream desktop and mobile browsers. For details about browser support, see the table below.
    If your browser (for example, WebView) is not in the list, you can run a TRTC Web SDK Support Level Test in the browser to test whether it fully supports WebRTC.

    Operating System Browser Minimum Browser
    Version Requirements
    SDK Version Requirements Receive (Playback) Send (Publish) Share Screen
    Windows Chrome (desktop) 56+ N/A Supported Supported Supported on Chrome 72+
    QQ Browser (desktop, WebKit core) 10.4+ N/A Supported Supported Not supported
    Firefox (desktop) 56+ 4.7.0+ Supported Supported Supported on Firefox 66+
    Edge (desktop) 80+ 4.7.0+ Supported Supported Supported
    Sogou Browser (desktop, WebKit core) 11+ 4.7.0+ Supported Supported Supported
    Sogou Browser (Trident core) N/A N/A Not supported Not supported Not supported
    Opera (desktop) 46+ 4.7.0+ Supported Supported Supported on Opera 60+
    360 Secure Browser (Blink core) 13+ 4.7.0+ Supported Supported Supported
    360 Secure Browser (Trident core) N/A N/A Not supported Not supported Not supported
    WeChat built-in browser (desktop) N/A N/A Supported Not supported Not supported
    WeCom built-in browser (desktop) N/A N/A Supported Not supported Not supported
    macOS Safari (desktop) 11+ N/A Supported Supported Supported on Safari 13+
    Chrome (desktop) 56+ N/A Supported Supported Supported on Chrome 72+
    Firefox (desktop) 56+ 4.7.0+ Supported Supported Supported on Firefox 66+. (Note[3])
    Edge (desktop) 80+ 4.7.0+ Supported Supported Supported
    Opera (desktop) 46+ 4.7.0+ Supported Supported Supported on Opera 60+
    WeChat built-in browser (desktop) N/A N/A Supported Not supported Not supported
    WeCom built-in browser (desktop) N/A N/A Supported Not supported Not supported
    Android WeChat built-in browser (TBS core) N/A N/A Supported Supported Not supported
    WeChat built-in browser (XWEB core) N/A N/A Supported Supported Not supported
    WeCom built-in browser N/A N/A Supported Supported Not supported
    Chrome (mobile) N/A N/A Supported Supported Not supported
    QQ Browser (mobile) N/A N/A Not supported Not supported Not supported
    UC Browser (mobile) N/A N/A Not supported Not supported Not supported
    iOS 12.1.4+ WeChat built-in browser N/A N/A Supported Not supported Not supported
    iOS 14.3+ WeChat built-in browser WeChat 6.5+ N/A Supported Supported Not supported
    iOS WeCom built-in browser N/A N/A Supported Not supported Not supported
    iOS 11.1.2+ Safari (mobile) 11+ N/A Supported Supported Not supported
    iOS 12.1.4+ Chrome (mobile) N/A N/A Supported Not supported Not supported
    iOS 14.3+ Chrome (mobile) N/A N/A Supported Supported Not supported
    Note:

    • Due to H.264 copyright restrictions, H.264 encoding, which is required for stream publishing, is unavailable for Chrome versions earlier than v88 on Huawei devices. If you want to use the TRTC web SDK to publish streams on Chrome or Chrome WebView-based browsers on Huawei devices, please submit a ticket to enable VP8 encoding/decoding.
    • Firefox for macOS performs poorly in terms of screen sharing, and no solution has been found yet. We recommend you use Chrome or Safari instead.
    • If you want to add support for dual-channel encoding on web, please submit a ticket.
    • For service stability and better online support, we recommend you to keep your SDK updated to the latest version. For notes on version updates, see Update Guide.

    URL Protocol Support

    Because of the security policies of browsers, when you use WebRTC, there are requirements on the protocol used for access. For details, see the table below.

    Scenario Protocol Receive (Playback) Send (Publish) Share Screen Remarks
    Production HTTPS Supported Supported Supported Recommended
    Production HTTP Supported Not supported Not supported
    Local development http://localhost Supported Supported Supported Recommended
    Local development http://127.0.0.1 Supported Supported Supported
    Local development http://[local IP address] Supported Not supported Not supported
    Local development file:/// Supported Supported Supported

    API Guide

    For details about the initialization process and the use of APIs, see the tutorials below:

    Feature Sample Code
    Audio/Video call Tutorial
    Interactive live streaming Tutorial
    Switching cameras/mics Tutorial
    Setting local video attributes Tutorial
    Disabling/Enabling local audio/video Tutorial
    Screen sharing Tutorial
    Measuring volume Tutorial
    Custom capturing and rendering Tutorial
    Limit on the number of upstream users in a room Tutorial
    Adding background music and audio effects Tutorial
    Environment and device check before calls Tutorial
    Network quality check before calls Tutorial
    Device change check Tutorial
    Publishing to CDN Tutorial
    Enabling dual-stream mode Tutorial
    Enabling beauty filters Tutorial
    Enabling watermarking Tutorial
    Enabling cross-room communication Tutorial
    Implementing On-Cloud MixTranscoding Tutorial
    Implementing on-cloud recording Tutorial
    Note:

    • Learn more about the features of the TRTC web SDK here.
    • For FAQs, see Web.

    API Details

    TRTC

    Note:

    This document applies to 4.x.x versions of the TRTC web SKD.

    TRTC is the main entry to the TRTC web SDK. You can use TRTC APIs 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 the log output level and enable/disable log upload.

    API Description
    VERSION Version of the TRTC web SDK
    checkSystemRequirements Checks whether a browser is compatible with the TRTC web SDK. If not, ask users to download the latest version of Chrome.
    isScreenShareSupported Checks whether a browser supports screen sharing. Call this API before creating a screen sharing stream.
    isSmallStreamSupported Checks whether a browser supports the dual-stream mode. Call this API before you enable the dual-stream mode.
    getDevices Gets the list of media input/output devices.
    getCameras Gets the list of cameras.
    getMicrophones Gets the list of mics.
    getSpeakers Gets the list of speakers.
    createClient Creates a client object, which can enter a room, publish streams, subscribe to streams, and perform other actions.
    createStream Creates a local Stream object, which uses the publish() API to publish the local audio/video stream.

    TRTC.Logger

    TRTC.Logger provides APIs for log settings, including 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

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

    API Description
    setProxyServer Sets proxy servers. You can use this API if you deploy proxy servers, e.g., Nginx + Coturn, by yourself.
    setTurnServer Sets TURN servers. This API is used together with setProxyServer(). You can use it if you deploy proxy and TURN servers by yourself.
    join Enters a room. This starts an audio/video call. If the room does not exist, the system will create the room automatically.
    leave Exits a room. This ends an audio/video call.
    publish Publishes the local audio/video stream. You should call this API only after you call join() to enter a room. You can publish only one local stream per audio/video call.
    unpublish Stops publishing the local stream.
    subscribe Subscribes to a remote stream.
    unsubscribe Unsubscribes from a remote stream.
    switchRole Switches user roles. This API works only in interactive live streaming scenarios (live).
    on Listens for client object events.
    off Stops listening for client object events.
    getRemoteMutedState Gets the audio/video status of remote users in a room.
    getTransportStats Gets data transfer statistics.
    getLocalAudioStats Gets the audio statistics of the published local stream. This API can be used only after publish() is called.
    getLocalVideoStats Gets the video statistics of the published local stream. This API can be used only after publish() is called.
    getRemoteAudioStats Gets the audio statistics of all remote streams.
    getRemoteVideoStats Gets the video statistics of all remote streams.
    startPublishCDNStream Publishes the stream of the current client to CDN.
    stopPublishCDNStream Stops publishing the stream of the current client to CDN.
    startMixTranscode Starts On-Cloud MixTranscoding. This API works only after stream publishing.
    stopMixTranscode Stops On-Cloud MixTranscoding. This API works only after successful local stream publishing (publish) and stream mixing (startMixTranscode).
    enableAudioVolumeEvaluation Enables/Disables the volume callback.
    enableSmallStream Enables the dual-stream mode for publishing.
    disableSmallStream Disables the dual-stream mode for publishing.
    setSmallStreamProfile Sets parameters for the low-quality stream.
    setRemoteVideoStreamType Switches between the low-quality stream and high-quality stream of a remote user. This API works only if a remote user enables the dual-stream mode.

    LocalStream

    A local audio/video stream is created through createStream. LocalStream is a subclass of Stream.

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

    RemoteStream

    A remote audio/video stream is obtained via the Client.on('stream-added') callback. RemoteStream 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 an audio/video primary stream or a video substream (which is usually a screen sharing stream).
    play Starts playing an audio/video stream.
    stop Stops playing an audio/video stream.
    resume Resumes playing an audio/video stream.
    close Closes an audio/video stream.
    muteAudio Disables the audio track of a stream.
    muteVideo Disables the video track of a stream.
    unmuteAudio Enables the audio track of a stream.
    unmuteVideo Enables the video track of a stream.
    getId Gets the stream ID.
    getUserId Gets the ID of the user to whom a stream belongs.
    setAudioOutput Sets the audio output device.
    setAudioVolume Sets the playback volume.
    getAudioLevel Gets the current volume. This API works only if there is audio data in the local stream or a remote stream.
    hasAudio Queries whether there is an audio track.
    hasVideo Queries whether there is a video track.
    getAudioTrack Gets the audio track of a stream.
    getVideoTrack Gets the video track of a stream.
    getVideoFrame Gets the current video frame.
    on Listens for stream events.
    off Stops listening for stream events.

    RtcError

    RtcError is the error object.

    API Description
    getCode Gets the error code.

    ClientEvent

    A list of client events, which are also the values of eventName in the client.on('eventName') callback.

    API Description
    stream-added There was a new remote stream. This callback is triggered after a remote user starts publishing.
    stream-removed A remote stream was removed. This callback is triggered after a remote user stops publishing.
    stream-updated A remote stream was updated. This callback is triggered after a remote user adds, removes, or replaces an audio or video track.
    stream-subscribed A remote stream was subscribed to. This callback is triggered after the local user calls subscribe() to successfully subscribe to a remote stream.
    connection-state-changed The connection status between the local client and Tencent Cloud changed.
    peer-join A remote user entered the room.
    peer-leave A remote user left the room.
    mute-audio A remote user disabled their audio track. This callback is triggered after a remote user disables their audio track.
    mute-video A remote user disabled their video track. This callback is triggered after a remote user disables their video track.
    unmute-audio A remote user enabled their audio track. This callback is triggered after a remote user enables their audio track.
    unmute-video A remote user enabled their video track. This callback is triggered after a remote user enables their video track.
    client-banned A user was removed from the room for one of the following reasons:
    • A user with the same username entered the room. Note: Avoid repeated room entry with the same username because it will cause an error.
    • The account admin called a server-side API to remove the user from the room.
    network-quality Callback of statistics on the quality of upstream and downstream data transfer. This callback is triggered every two seconds after room entry.
    audio-volume Callback of user volumes.
    After you call the enableAudioVolumeEvaluation API to enable this callback, the SDK will return the volume of each user in the room at a regular interval.
    error Error event. This callback is triggered if an unrecoverable error occurs. For details, see Error Codes.

    StreamEvent

    A list of stream events.

    API Description
    player-state-changed The status of the audio/video player changed.
    screen-sharing-stopped Local screen sharing stopped. This event is valid only for the local stream.
    connection-state-changed The connection status of the stream changed. Listen for this event in stream-added and cancel listening for this event in stream-removed.
    error Error event. This callback is triggered if an unrecoverable error occurs. For details, see Error Codes.

    Contact Us

    If you have any questions, please email us at colleenyu@tencent.com.

    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support