Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • default

Index

Constructors

  • Returns default

Properties

_listeners: Map<any, any>
_trtcCloud: undefined | default

Methods

  • callExperimentalAPI(jsonStr: string): Promise<void>
    • Call experimental APIs
    • Note: This API is used to call experimental APIs.

    Parameters

    • jsonStr: string

    Returns Promise<void>

  • connectOtherRoom(param: string): Promise<void>
    • Request cross-room communication (anchor competition)
    • The cross-room communication feature allows the anchors of two rooms to communicate without exiting their own rooms.
    • For example, after anchor A in room 001 uses connectOtherRoom() to successfully call anchor B in room 002, all users in room 001 will receive the onRemoteUserEnterRoom(B) and onUserVideoAvailable(B,true) callbacks, and all users in room 002 will receive the onRemoteUserEnterRoom(A) and onUserVideoAvailable(A,true) callbacks.
    • In essence, cross-room communication is a way to share the audio and video of two anchors in different rooms so that the audiences in both rooms can see both anchors.
    • To ensure the compatibility of extended parameters for the cross-room communication API, the JSON format is used for the parameters, which must contain at least two fields:
    • roomId: If anchor A in room 001 wants to call anchor B in room 002, he or she must set roomId to 002 when calling ConnectOtherRoom().
    • userId: If anchor A in room 001 wants to call anchor B in room 002, he or she must set userId to the user ID of anchor B when calling ConnectOtherRoom().
    • The result of requesting cross-room communication is returned through the onConnectOtherRoom() callback.
    • Sample call:
    • var object = new Map();
    • object['roomId'] = 155;
    • object['userId'] = '57890';
    • trtcCloud.connectOtherRoom(jsonEncode(object));

    Parameters

    • param: string

    Returns Promise<void>

  • disconnectOtherRoom(): Promise<void>
    • Exit a cross-room call
    • The result of exiting a cross-room call is returned through the onDisconnectOtherRoom callback.

    Returns Promise<void>

  • enableAudioVolumeEvaluation(intervalMs: number): Promise<void>
    • Enable the volume reminder
    • After the volume reminder is enabled, the SDK’s measurement of audio volumes will be returned via the onUserVoiceVolume callback. This API works only if it is called before startLocalAudio().

    Parameters

    • intervalMs: number

    Returns Promise<void>

  • enterRoom(params: TRTCParams, scene: number): Promise<void>
    • Enter a room
    • After calling this API, you will receive the onEnterRoom(result) callback in TRTCCloudListener.
    • If room entry succeeded, result would be a positive number (result > 0), indicating the time in milliseconds (ms) room entry took.
    • If room entry failed, result would be a negative number (result < 0), which represents the error code.

    Parameters

    Returns Promise<void>

  • exitRoom(): Promise<void>
    • Exit a room
    • Calling exitRoom() will trigger the execution of room exit-related logic, including releasing resources such as audio/video devices and codecs. After all the resources are released, the SDK will notify you via the onExitRoom() callback.
    • If you need to call enterRoom() again or switch to another RTC SDK, please wait until you receive the onExitRoom() callback. Otherwise, you may encounter problems such as the camera or mic being occupied. The common issue of failure to switch between call volume and media volume on Android is caused by this problem.

    Returns Promise<void>

  • getAudioCaptureVolume(): Promise<number>
  • Get the capturing volume of the SDK

    Returns Promise<number>

    • Get the audio effect management class TXAudioEffectManager

    Returns default

    TXAudioEffectManager

  • getAudioPlayoutVolume(): Promise<number>
  • Get the playback volume of the SDK

    Returns Promise<number>

    • Get the beauty filter management class TXBeautyManager

    Returns default

    TXBeautyManager

    • Get the device management module

    Returns default

    TXDeviceManager

  • getSDKVersion(): Promise<string>
    • Get the SDK version

    Returns Promise<string>

    Version number

  • muteAllRemoteAudio(mute: boolean): Promise<void>
    • Mute/Unmute all users

    Parameters

    • mute: boolean

    Returns Promise<void>

  • muteAllRemoteVideoStreams(mute: boolean): Promise<void>
    • Pause/Resume receiving all remote videos
    • This API pauses receiving all remote users' videos but does not release the resources, so the videos will freeze at the last frame.
    • This API takes effect regardless of whether it is called before or after enterRoom, and mute will be reset to False after exitRoom.

    Parameters

    • mute: boolean

    Returns Promise<void>

  • muteLocalAudio(mute: boolean): Promise<void>
    • Mute/Unmute the local user
    • After the local user is muted, other members in the room will receive the onUserAudioAvailable(userId, false) callback notification. After local audio is unmuted, other members in the room will receive the onUserAudioAvailable(userId, true) callback notification.
    • Different from stopLocalAudio, muteLocalAudio(true) does not stop the publishing of audio or video data. Data packets continue to be sent, although without audio and at extremely low bitrate. As MP4 and other video formats have high requirements on audio continuity, an MP4 recording file may not be played smoothly if stopLocalAudio is used. muteLocalAudio has less impact on the compatibility of MP4 recording files. Therefore, you are advised to use muteLocalAudio in scenarios with high requirements on recording quality.

    Parameters

    • mute: boolean

    Returns Promise<void>

  • muteLocalVideo(mute: boolean): Promise<void>
    • Pause/Resume publishing local video data
    • After you pause publishing local video, other users in the room will receive the onUserVideoAvailable(userId, false) callback. After you resume publishing local video, other users in the room will receive the onUserVideoAvailable(userId, true) callback.

    Parameters

    • mute: boolean

    Returns Promise<void>

  • muteRemoteAudio(userId: string, mute: boolean): Promise<void>
    • Mute/Unmute a remote user

    Parameters

    • userId: string
    • mute: boolean

    Returns Promise<void>

  • muteRemoteVideoStream(userId: string, mute: boolean): Promise<void>
    • Pause/Resume receiving the video of a remote user
    • This API pauses receiving the specified remote user's video but does not release the resources, so the user’s video will freeze at the last frame.
    • This API takes effect regardless of whether it is called before or after enterRoom, and mute will be reset to False after exitRoom.

    Parameters

    • userId: string
    • mute: boolean

    Returns Promise<void>

  • registerListener(listener: (type: TRTCCloudListener, params: any) => void): { remove: () => void }
  • Register an event listener

    Parameters

    Returns { remove: () => void }

    • remove: () => void
        • (): void
        • Returns void

  • setAudioCaptureVolume(volume: number): Promise<void>
    • Set the capturing volume of the SDK

    Parameters

    • volume: number

    Returns Promise<void>

  • setAudioPlayoutVolume(volume: number): Promise<void>
    • Set the playback volume of the SDK
    • This API controls the volume of audio delivered to the system for playback. It affects the volume of local recording files, but not the volume of in-ear monitoring.

    Parameters

    • volume: number

    Returns Promise<void>

  • setConsoleEnabled(enabled: boolean): Promise<void>
    • Enable/Disable console log printing

    Parameters

    • enabled: boolean

    Returns Promise<void>

  • setDefaultStreamRecvMode(autoRecvAudio: boolean, autoRecvVideo: boolean): Promise<void>
    • Set the audio/video receiving mode (must be called before room entry to take effect)
    • To enable instant streaming, the SDK automatically receives audio/video upon successful room entry. This means you will receive the audio and video data of all remote users right after you enter a room. If you do not call startRemoteView, video data will be automatically canceled after the timeout period elapses. If your application scenario involves only audio (e.g., audio chat), you can use this API to disable automatic video data receiving.

    Parameters

    • autoRecvAudio: boolean
    • autoRecvVideo: boolean

    Returns Promise<void>

  • setGSensorMode(mode: number): Promise<void>
    • Set the adaptation mode of the G-sensor

    Parameters

    • mode: number

    Returns Promise<void>

  • setLogCompressEnabled(enabled: boolean): Promise<void>
    • Enable/Disable local log compression
    • If compression is enabled, log size will reduce significantly, but logs can be read only after being decompressed by the Python script provided by Tencent Cloud. If compression is disabled, logs will be stored in plaintext and will take up more storage space, but they can be read directly in Notepad.

    Parameters

    • enabled: boolean

    Returns Promise<void>

  • setLogDirPath(path: string): Promise<void>
    • Modify the log path
    • Log files are stored in /app directory/files/log/tencent/liteav/ by default. To change the path, call this API before calling others. Make sure that the directory exists and your app has read/write access to the directory.

    Parameters

    • path: string

    Returns Promise<void>

  • setLogLevel(level: number): Promise<void>
    • Set the log output level

    Parameters

    • level: number

    Returns Promise<void>

    • Set On-Cloud MixTranscoding parameters
    • If you enable relayed push on the "Function Configuration" page of the TRTC console, each user publishing streams in the room will have a default CDN address.
    • There may be multiple anchors in a room, each sending their own video and audio, but CDN audience needs only one live stream. Therefore, you need to mix multiple audio/video streams into one standard live stream, which requires MixTranscoding.
    • When you call the setMixTranscodingConfig() API, the SDK will send a command to the Tencent Cloud transcoding server to mix multiple audio/video streams in the room into one stream. You can use the mixUsers parameter to set the position of each video and specify whether to mix only audio. You can also set the encoding parameters of the mixed stream, including videoWidth, videoHeight, and videoBitrate.
    • For more information, please see On-Cloud MixTranscoding.
    • @paramconfig: If config is not empty, On-Cloud MixTranscoding will start. If config is empty, On-Cloud MixTranscoding will stop. For more information, see the description of TRTCTranscodingConfig.
    • 注意:
    • 使用 startPublishing() 请参考 TRTCCloudDef.tsx 中关于 TRTCTranscodingConfig 的介绍。如果传入 null 则取消云端混流转码。

    Parameters

    Returns Promise<void>

    • Set QoS parameters
    • The parameters determine the SDK’s QoS policy under different network conditions, for example, whether to prioritize clarity or smoothness under poor network conditions.

    Parameters

    Returns Promise<void>

  • setRemoteAudioVolume(userId: string, volume: number): Promise<void>
    • Set the playback volume of a remote user’s audio

    Parameters

    • userId: string
    • volume: number

    Returns Promise<void>

  • setVideoEncoderMirror(mirror: boolean): Promise<void>
    • Set the mirror mode of encoded videos
    • This API mirrors (flips) the video presented to remote users and recorded by the server, but it does not change the image displayed to the local camera preview.

    Parameters

    • mirror: boolean

    Returns Promise<void>

    • Set video encoder parameters
    • Encoder parameters determine the quality of video watched by remote users and recorded in the cloud.

    Parameters

    Returns Promise<void>

  • setVideoEncoderRotation(rotation: number): Promise<void>
    • Set the orientation of encoded videos, i.e., videos seen by remote users and recorded by the server
    • If you rotate your phone or Android tablet 180 degrees, remote users will see an upside-down video. You can fix this by calling this API to rotate your video 180 degrees before the SDK sends it to remote users.
    • TRTCCloudDef.TRTC_VIDEO_ROTATION_0 (default value): do not rotate
    • TRTCCloudDef.TRTC_VIDEO_ROTATION_180: rotate 180 degrees clockwise

    Parameters

    • rotation: number

    Returns Promise<void>

  • setVideoMuteImage(image: string, fps: number): Promise<void>
    • Set the image that is displayed when local video publishing is paused
    • After local video publishing is paused, the image set will be displayed.
    • Currently, you can only use an image from the internet.
    • @param image: Image to display. If it is empty, no image is displayed.
    • @param fps: Frame rate of the image to display. Value range: 5-20. Default value: 10

    Parameters

    • image: string
    • fps: number

    Returns Promise<void>

  • setWatermark(image: string, streamType: number, x: number, y: number, width: number): Promise<void>
    • Add a watermark
    • The position of the watermark is determined by rect, which is in the format of (x, y, width, height).
    • x: X coordinate of the watermark, which is a floating-point number between 0 and 1
    • y: Y coordinate of the watermark, which is a floating-point number between 0 and 1
    • width: Width of the watermark, which is a floating-point number between 0 and 1
    • height: You don’t need to set this parameter. The SDK will calculate the height according to the watermark image's aspect ratio.
    • Example: If a video is encoded in the resolution of 540 × 960, and you set rect to (0.1, 0.1, 0.2, 0.0), then the coordinates of the top-left corner of the watermark will be (540 × 0.1, 960 × 0.1) or (54, 96), and the width of the watermark will be 540 × 0.2 or 108 px. The height of the watermark will be calculated based on the watermark image’s aspect ratio.
    • @param image: Watermark image, which must be in PNG format with a transparent background
    • @param streamType: The stream the watermark is added to
    • @param rect: Normalized coordinates of the watermark relative to the video’s resolution. The value range of x, y, width, and height is 0-1.
    • Note: If you want to add a watermark to both the primary stream (usually used for the camera video) and the substream (usually used for screen sharing), you need to call this API twice, setting streamType to different values each time.

    Parameters

    • image: string
    • streamType: number
    • x: number
    • y: number
    • width: number

    Returns Promise<void>

    • Start audio recording
    • After this API is called, the SDK will record all audios of a call, including the local audio, remote audios, and background music, into a single file. This API works regardless of whether you are in the room or not. When exitRoom is called, audio recording will stop automatically.

    Parameters

    Returns Promise<number>

    0: Recording successful. -1: Recording has started. -2: Failed to create the file or directory. -3: Unsupported audio format. -1001: Invalid parameter.

  • startLocalAudio(quality: number): Promise<void>
    • Start capturing and publishing audio and set audio quality
    • This API captures audio data from the mic and sends the data to other users in the room. The SDK does not start local audio capturing or publishing automatically. You need to call this API to start it manually so that other users in the room can hear you.
    • Higher audio quality at the anchor side means a better listening experience for the audience, but high audio quality relies on high bandwidth. Video stutter may occur if bandwidth is insufficient.

    Parameters

    • quality: number

    Returns Promise<void>

    • Start relaying to the live streaming CDN of a non-Tencent Cloud vendor
    • This API is similar to startPublishing(), but startPublishCDNStream() supports relaying to the live streaming CDN of a non-Tencent Cloud vendor.
    • @paramCDN: relaying parameters. For more information, please see TRTCPublishCDNParam.
    • Notes:
    • Using startPublishing() to bind Tencent Cloud’s live streaming CDN does not incur fees, but using startPublishCDNStream() to bind the live streaming CDN of a non-Tencent Cloud vendor incurs relaying fees.

    Parameters

    Returns Promise<void>

  • startPublishing(streamId: string, streamType: number): Promise<void>
    • Start publishing stream to Tencent Cloud’s live streaming CDN
    • When calling this API, you need to specify a StreamId for the current user in Tencent Cloud’s CDN, which is used to splice the CDN playback address of the user.
    • For example, if you set the StreamId of the current user's primary stream to user_stream_001, the CDN playback address of the user’s primary stream will be http://yourdomain/live/user_stream_001.flv, where yourdomain is the domain name you use for playback. You can configure your playback domain name in the CSS console. Tencent Cloud doesn't provide a default playback domain name.
    • You can also specify the streamId when setting the TRTCParams parameter of enterRoom. This method is recommended.

    Parameters

    • streamId: string
    • streamType: number

    Returns Promise<void>

  • startSpeedTest(sdkAppId: number, userId: string, userSig: string): Promise<void>
    • Start network speed testing, which should be avoided during video calls to ensure call quality
    • The testing result can be used to optimize the SDK's server selection policy, so you are advised to run the test before the first call, which will help the SDK select the optimal server. If the result is unsatisfactory, you can show a UI message asking users to change to a better network. The result is returned via the TRTCCloudListener.onSpeedTest callback.
    • Note: Speed testing consumes traffic and consequently generates a small traffic fee.

    Parameters

    • sdkAppId: number
    • userId: string
    • userSig: string

    Returns Promise<void>

  • stopAudioRecording(): Promise<void>
    • Stop audio recording
    • When exitRoom is called, audio recording will stop automatically.

    Returns Promise<void>

  • stopLocalAudio(): Promise<void>
    • Stop capturing and publishing audio
    • After local audio capturing and publishing stop, other users in the room will receive the onUserAudioAvailable(false) callback.

    Returns Promise<void>

  • stopPublishCDNStream(): Promise<void>
  • Stop relaying to non-Tencent Cloud address

    Returns Promise<void>

  • stopPublishing(): Promise<void>
  • Stop publishing stream to Tencent Cloud’s live streaming CDN

    Returns Promise<void>

  • stopSpeedTest(): Promise<void>
  • Stop server speed testing

    Returns Promise<void>

  • switchRole(role: number): Promise<void>
    • Switch roles (applicable only to the live streaming scenarios TRTC_APP_SCENE_LIVE and TRTC_APP_SCENE_VOICE_CHATROOM)
    • In live streaming scenarios, a user may need to switch between the anchor role and audience role. You can specify your role during room entry by specifying the role parameter in TRTCParams. You can also call switchRole to switch the role after room entry.

    Parameters

    • role: number

    Returns Promise<void>

    • Switch rooms
    • After calling this API, you will exit the current room and stop publishing local audio/video and playing remote audio/video, but local video preview will continue. After you enter a new room, the publishing of local audio/video will resume automatically.
    • The result of the API call is returned through the onSwitchRoom(errCode, errMsg) callback.

    Parameters

    Returns Promise<void>

  • unRegisterAllListener(): void
  • Unregister all event listeners

    Returns void

  • destroySharedInstance(): void
  • Terminate a TRTCCloud singleton

    Returns void

  • Create a TRTCCloud singleton

    Returns default

Generated using TypeDoc