Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AgoraRtcChannel

since

v3.0.0

The AgoraRtcChannel class.

Hierarchy

  • EventEmitter
    • AgoraRtcChannel

Index

Constructors

constructor

Properties

rtcChannel

rtcChannel: NodeRtcChannel

Methods

addInjectStreamUrl

  • Injects the online media stream to a live streaming.

    If this method call is successful, the server pulls the voice or video stream and injects it into a live channel. And all audience members in the channel can watch a live show and interact with each other.

    This method call triggers the following callbacks:

    • The local client:
      • streamInjectedStatus, reports the injecting status.
      • userJoined(uid:666), reports the stream is injected successfully and the UID of this stream is 666.
    • The remote client:
      • userJoined(uid:666), reports the stream is injected successfully and the UID of this stream is 666.
    warning

    Agora will soon stop the service for injecting online media streams on the client. If you have not implemented this service, Agora recommends that you do not use it.

    note
    • Only the host in the 1 (live streaming) profile can call this method.
    • Ensure that you enable the Media Push service before using this function. See Prerequisites in the Media Push guide.
    • This method applies to the 1 (live streaming) profile only.
    • You can inject only one media stream into the channel at the same time.

    Parameters

    • url: string

      The URL address to be added to the ongoing live streaming. Valid protocols are RTMP, HLS, and HTTP-FLV.

      • Supported audio codec type: AAC.
      • Supported video codec type: H264 (AVC).
    • config: InjectStreamConfig

      The configuration of the injected stream. See InjectStreamConfig

    Returns number

    • 0: Success
    • < 0: Failure
      • ERR_INVALID_ARGUMENT (2): The injected URL does not exist. Call this method again to inject the stream and ensure that the URL is valid.
      • ERR_NOT_READY (3): The user is not in the channel.
      • ERR_NOT_SUPPORTED (4): The channel profile is not live streaming. Call the setChannelProfile method and set the channel profile to live streaming before calling this method.
      • ERR_NOT_INITIALIZED (7): The SDK is not initialized. Ensure that the AgoraRtcChannel object is initialized before calling this method.

addPublishStreamUrl

  • addPublishStreamUrl(url: string, transcodingEnabled: boolean): number
  • Publishes the local stream to a specified CDN URL address.

    In the 1 (live streaming) profile, the host can call this method to publish the local stream to a specified CDN URL address, which is called "Media Push."

    During Media Push, the SDK triggers the rtmpStreamingStateChanged callback is any streaming state changes.

    note
    • Only the host in the 1 (live streaming) profile can call this method.
    • Call this method after the host joins the channel.
    • Ensure that you enable the Media Push service before using this function. See Prerequisites in the Media Push guide.
    • This method adds only one stream RTMP URL address each time it is called.

    Parameters

    • url: string

      The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes. The RTMP URL address must not contain special characters, such as Chinese language characters.

    • transcodingEnabled: boolean

      Sets whether transcoding is enabled/disabled:

      • true: Enable transcoding. To transcode the audio or video streams when publishing them to CDN live, often used for combining the audio and video streams of multiple hosts in CDN live. When you set this parameter as true, ensure that you call the setLiveTranscoding method before this method.
      • false: Disable transcoding.

    Returns number

    • 0: Success
    • < 0: Failure
      • ERR_INVALID_ARGUMENT (2): The RTMP URL address is NULL or has a string length of 0.
      • ERR_NOT_INITIALIZED (7): You have not initialized AgoraRtcChannel when publishing the stream.

adjustUserPlaybackSignalVolume

  • adjustUserPlaybackSignalVolume(uid: number, volume: number): number
  • Adjusts the playback volume of a specified remote user.

    You can call this method as many times as necessary to adjust the playback volume of different remote users, or to repeatedly adjust the playback volume of the same remote user.

    note
    • Call this method after joining a channel.
    • The playback volume here refers to the mixed volume of a specified remote user.
    • This method can only adjust the playback volume of one specified remote user at a time. To adjust the playback volume of different remote users, call the method as many times, once for each remote user.

    Parameters

    • uid: number

      The ID of the remote user.

    • volume: number

      The playback volume of the specified remote user. The value ranges from 0 to 100:

      • 0: Mute.
      • 100: Original volume.

    Returns number

    • 0: Success.
    • < 0: Failure.

channelId

  • channelId(): string
  • Gets the channel ID of the current AgoraRtcChannel object.

    Returns string

    • The channel ID of the current AgoraRtcChannel object, if the method call succeeds.
    • The empty string "", if the method call fails.

createDataStream

  • createDataStream(reliable: boolean, ordered: boolean): number
  • Creates a data stream.

    Each user can create up to five data streams during the lifecycle of the AgoraRtcChannel.

    deprecated

    This method is deprecated from v3.3.1. Use the createDataStreamWithConfig method instead.

    note

    Set both the reliable and ordered parameters to true or false. Do not set one as true and the other as false.

    Parameters

    • reliable: boolean

      Sets whether or not the recipients are guaranteed to receive the data stream from the sender within five seconds:

      • true: The recipients receive the data stream from the sender within five seconds. If the recipient does not receive the data stream within five seconds, an error is reported to the application.
      • false: There is no guarantee that the recipients receive the data stream within five seconds and no error message is reported for any delay or missing data stream.
    • ordered: boolean

      Sets whether or not the recipients receive the data stream in the sent order:

      • true: The recipients receive the data stream in the sent order.
      • false: The recipients do not receive the data stream in the sent order.

    Returns number

    • 0: Success
    • < 0: Failure

createDataStreamWithConfig

  • Creates a data stream.

    since

    v3.3.1

    Each user can create up to five data streams in a single channel.

    This method does not support data reliability. If the receiver receives a data packet five seconds or more after it was sent, the SDK directly discards the data.

    Parameters

    Returns number

    • Returns the ID of the created data stream, if this method call succeeds.
    • < 0: Fails to create the data stream.

enableEncryption

  • Enables/Disables the built-in encryption.

    since

    v3.2.0

    In scenarios requiring high security, Agora recommends calling this method to enable the built-in encryption before joining a channel.

    All users in the same channel must use the same encryption mode and encryption key. Once all users leave the channel, the encryption key of this channel is automatically cleared.

    note

    If you enable the built-in encryption, you cannot use the RTMP or RTMPS streaming function.

    Parameters

    • enabled: boolean

      Whether to enable the built-in encryption:

      • true: Enable the built-in encryption.
      • false: Disable the built-in encryption.
    • config: EncryptionConfig

      Configurations of built-in encryption schemas. See EncryptionConfig.

    Returns number

    • 0: Success.
    • < 0: Failure.

getCallId

  • getCallId(): string
  • Retrieves the current call ID.

    When a user joins a channel on a client, a callId is generated to identify the call from the client. Feedback methods, such as {@link AgoraRtcChannel.rate rate} and {@link AgoraRtcChannel.complain complain}, must be called after the call ends to submit feedback to the SDK.

    The rate and complain methods require the callId parameter retrieved from the getCallId method during a call.

    Returns string

    • The call ID, if the method call succeeds.
    • The empty string "", if the method call fails.

getConnectionState

  • Gets the connection state of the SDK.

    Returns CONNECTION_STATE_TYPE

    Connect states. See {@link ConnectionState}.

joinChannel

  • Joins a channel with the user ID, and configures whether to automatically subscribe to the audio or video streams.

    Users in the same channel can talk to each other, and multiple users in the same channel can start a group chat. Users with different App IDs cannot call each other.

    You must call the leaveChannel method to exit the current call before entering another channel.

    A successful joinChannel method call triggers the following callbacks:

    • The local client: joinChannelSuccess.
    • The remote client: userJoined, if the user joining the channel is in the 0 (communication) profile, or is a host in the 1 (live stream ing) profile.

    When the connection between the client and the Agora server is interrupted due to poor network conditions, the SDK tries reconnecting to the server.

    When the local client successfully rejoins the channel, the SDK triggers the rejoinChannelSuccess callback on the local client.

    note

    Ensure that the App ID used for generating the token is the same App ID used in the initialize method for creating an AgoraRtcEngine object.

    Parameters

    • token: string

      The token generated at your server. For details, see Generate a token.

    • info: string

      (Optional) Reserved for future use.

    • uid: number

      (Optional) User ID. A 32-bit unsigned integer with a value ranging from 1 to 232-1. The @p uid must be unique. If a @p uid is not assigned (or set to 0), the SDK assigns and returns a @p uid in the joinChannelSuccess callback. Your application must record and maintain the returned uid, because the SDK does not do so. Note: The ID of each user in the channel should be unique. If you want to join the same channel from different devices, ensure that the user IDs in all devices are different.

    • options: ChannelMediaOptions

      The channel media options. See ChannelMediaOptions.

    Returns number

    • 0: Success.
    • < 0: Failure.
      • -2: The parameter is invalid.
      • -3: The SDK fails to be initialized. You can try re-initializing the SDK.
      • `-5: The request is rejected. This may be caused by the following:
        • You have created an AgoraRtcChannel object with the same channel name.
        • You have joined and published a stream in a channel created by the AgoraRtcChannel object. When you join a channel created by the AgoraRtcEngine object, the SDK publishes the local audio and video streams to that channel by default. Because the SDK does not support publishing a local stream to more than one channel simultaneously, an error occurs in this occasion.
      • -7: The SDK is not initialized before calling this method.

joinChannelWithUserAccount

  • joinChannelWithUserAccount(token: string, userAccount: string, options: ChannelMediaOptions): number
  • Joins the channel with a user account.

    After the user successfully joins the channel, the SDK triggers the following callbacks:

    • The local client: localUserRegistered and joinChannelSuccess.
    • The remote client: userJoined and userInfoUpdated, if the user joining the channel is in the communication(0) profile, or is a host in the 1 (live streaming) profile.
    note

    To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type.

    Parameters

    • token: string

      The token generated at your server. For details, see Generate a token.

    • userAccount: string

      The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are:

      • All lowercase English letters: a to z.
      • All uppercase English letters: A to Z.
      • All numeric characters: 0 to 9.
      • The space character.
      • Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
    • options: ChannelMediaOptions

      The channel media options. See ChannelMediaOptions.

    Returns number

    • 0: Success.
    • < 0: Failure.
      • -2
      • -3
      • -5
      • -7

leaveChannel

  • leaveChannel(): number
  • Allows a user to leave a channel.

    Allows a user to leave a channel, such as hanging up or exiting a call. The user must call the method to end the call before joining another channel after call the joinChannel method. This method returns 0 if the user leaves the channel and releases all resources related to the call. This method call is asynchronous, and the user has not left the channel when the method call returns.

    Once the user leaves the channel, the SDK triggers the leavechannel callback.

    A successful leavechannel method call triggers the removeStream callback for the remote client when the user leaving the channel is in the Communication channel, or is a host in the Live streaming profile.

    Returns number

    • 0: Success.
    • < 0: Failure.

muteAllRemoteAudioStreams

  • muteAllRemoteAudioStreams(mute: boolean): number
  • Stops or resumes subscribing to the audio streams of all remote users.

    As of v3.3.1, after successfully calling this method, the local user stops or resumes subscribing to the audio streams of all remote users, including all subsequent users.

    note
    • Call this method after joining a channel.
    • See recommended settings in Set the Subscribing State.

    Parameters

    • mute: boolean

      Sets whether to stop subscribing to the audio streams of all remote users.

      • true: Stop subscribing to the audio streams of all remote users.
      • false: (Default) Resume subscribing to the audio streams of all remote users.

    Returns number

    • 0: Success.
    • < 0: Failure.

muteAllRemoteVideoStreams

  • muteAllRemoteVideoStreams(mute: boolean): number
  • Stops or resumes subscribing to the video streams of all remote users.

    As of v3.3.1, after successfully calling this method, the local user stops or resumes subscribing to the video streams of all remote users, including all subsequent users.

    note
    • Call this method after joining a channel.
    • See recommended settings in Set the Subscribing State.

    Parameters

    • mute: boolean

      Sets whether to stop subscribing to the video streams of all remote users.

      • true: Stop subscribing to the video streams of all remote users.
      • false: (Default) Resume subscribing to the video streams of all remote users.

    Returns number

    • 0: Success.
    • < 0: Failure.

muteLocalAudioStream

  • muteLocalAudioStream(mute: boolean): number
  • Stops or resumes publishing the local audio stream.

    since

    v3.4.5

    This method only sets the publishing state of the audio stream in the channel of IChannel.

    A successful method call triggers the remoteAudioStateChanged callback on the remote client.

    You can only publish the local stream in one channel at a time. If you create multiple channels, ensure that you only call rtcChannel.muteLocalAudioStream(false) in one channel; otherwise, the method call fails, and the SDK returns -5 (ERR_REFUSED).

    note
    • This method does not change the usage state of the audio-capturing device.
    • Whether this method call takes effect is affected by the joinChannel and setClientRole methods. For details, see Set the Publishing State.

    Parameters

    • mute: boolean

      Sets whether to stop publishing the local audio stream.

      • true: Stop publishing the local audio stream.
      • false: Resume publishing the local audio stream.

    Returns number

    • 0: Success.
    • < 0: Failure.
      • -5 (ERR_REFUSED): The request is rejected.

muteLocalVideoStream

  • muteLocalVideoStream(mute: boolean): number
  • Stops or resumes publishing the local video stream.

    since

    v3.4.5

    This method only sets the publishing state of the video stream in the channel of IChannel.

    A successful method call triggers the remoteVideoStateChanged callback on the remote client.

    You can only publish the local stream in one channel at a time. If you create multiple channels, ensure that you only call rtcChannel.muteLocalVideoStream(false) in one channel; otherwise, the method call fails, and the SDK returns -5 (ERR_REFUSED).

    note
    • This method does not change the usage state of the video-capturing device.
    • Whether this method call takes effect is affected by the joinChannel and setClientRole methods. For details, see Set the Publishing State.

    Parameters

    • mute: boolean

      Sets whether to stop publishing the local video stream.

      • true: Stop publishing the local video stream.
      • false: Resume publishing the local video stream.

    Returns number

    • 0: Success.
    • < 0: Failure.
      • -5 (ERR_REFUSED): The request is rejected.

muteRemoteAudioStream

  • muteRemoteAudioStream(uid: number, mute: boolean): number
  • Stops or resumes subscribing to the audio stream of a specified user.

    note
    • Call this method after joining a channel.
    • See recommended settings in Set the Subscribing State.

    Parameters

    • uid: number
    • mute: boolean

      Sets whether to stop subscribing to the audio stream of a specified user.

      • true: Stop subscribing to the audio stream of a specified user.
      • false: (Default) Resume subscribing to the audio stream of a specified user.

    Returns number

    • 0: Success.
    • < 0: Failure.

muteRemoteVideoStream

  • muteRemoteVideoStream(uid: number, mute: boolean): number
  • Stops or resumes subscribing to the video stream of a specified user.

    note
    • Call this method after joining a channel.
    • See recommended settings in Set the Subscribing State.

    Parameters

    • uid: number
    • mute: boolean

      Sets whether to stop subscribing to the video stream of a specified user.

      • true: Stop subscribing to the video stream of a specified user.
      • false: (Default) Resume subscribing to the video stream of a specified user.

    Returns number

    • 0: Success.
    • < 0: Failure.

off

  • off(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: function): this
  • on(evt: "joinChannelSuccess", cb: function): this
  • on(evt: "channelWarning", cb: function): this
  • on(evt: "channelError", cb: function): this
  • on(evt: "rejoinChannelSuccess", cb: function): this
  • on(evt: "leaveChannel", cb: function): this
  • on(evt: "clientRoleChanged", cb: function): this
  • on(evt: "userJoined", cb: function): this
  • on(evt: "userOffline", cb: function): this
  • on(evt: "connectionLost", cb: function): this
  • on(evt: "requestToken", cb: function): this
  • on(evt: "tokenPrivilegeWillExpire", cb: function): this
  • on(evt: "rtcStats", cb: function): this
  • on(evt: "networkQuality", cb: function): this
  • on(evt: "remoteVideoStats", cb: function): this
  • on(evt: "remoteAudioStats", cb: function): this
  • on(evt: "remoteAudioStateChanged", cb: function): this
  • on(evt: "activeSpeaker", cb: function): this
  • on(evt: "firstRemoteAudioDecoded", cb: function): this
  • on(evt: "videoSizeChanged", cb: function): this
  • on(evt: "remoteVideoStateChanged", cb: function): this
  • on(evt: "streamMessage", cb: function): this
  • on(evt: "snapshotTaken", cb: function): this
  • on(evt: "audioDeviceTestVolumeIndication", cb: function): this
  • on(evt: "streamMessageError", cb: function): this
  • on(evt: "channelMediaRelayState", cb: function): this
  • on(evt: "channelMediaRelayEvent", cb: function): this
  • on(evt: "firstRemoteAudioFrame", cb: function): this
  • on(evt: string, listener: Function): this
  • on(evt: "rtmpStreamingStateChanged", cb: function): this
  • on(evt: "transcodingUpdated", cb: function): this
  • on(evt: "streamInjectedStatus", cb: function): this
  • on(evt: "remoteSubscribeFallbackToAudioOnly", cb: function): this
  • on(evt: "connectionStateChanged", cb: function): this
  • on(evt: "audioPublishStateChanged", cb: function): this
  • on(evt: "videoPublishStateChanged", cb: function): this
  • on(evt: "audioSubscribeStateChanged", cb: function): this
  • on(evt: "videoSubscribeStateChanged", cb: function): this
  • on(evt: "firstRemoteVideoFrame", cb: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Occurs when a user joins a specified channel.

    Parameters

    • evt: "joinChannelSuccess"
    • cb: function
        • (uid: number, elapsed: number): void
        • Parameters

          • uid: number

            The User ID.

          • elapsed: number

            Time elapsed (ms) from the user calling the joinChannel method until the SDK triggers this callback.

          Returns void

    Returns this

  • Reports a warning during SDK runtime.

    Parameters

    • evt: "channelWarning"
    • cb: function
        • (warn: number, msg: string): void
        • Parameters

          • warn: number

            Warning code.

          • msg: string

            The warning message.

          Returns void

    Returns this

  • Reports an error during SDK runtime.

    Parameters

    • evt: "channelError"
    • cb: function
        • (err: number, msg: string): void
        • Parameters

          • err: number

            Error code.

          • msg: string

            The error message.

          Returns void

    Returns this

  • Occurs when a user rejoins the channel after disconnection due to network problems. When a user loses connection with the server because of network problems, the SDK automatically tries to reconnect and triggers this callback upon reconnection.

    Parameters

    • evt: "rejoinChannelSuccess"
    • cb: function
        • (uid: number, elapsed: number): void
        • Parameters

          • uid: number

            User ID of the user joining the channel.

          • elapsed: number

            Time elapsed (ms) from the user calling the joinChannel method until the SDK triggers this callback.

          Returns void

    Returns this

  • Occurs when the user leaves the channel.

    When the app calls the leaveChannel method, the SDK uses this callback to notify the app when the user leaves the channel.

    Parameters

    • evt: "leaveChannel"
    • cb: function

    Returns this

  • Occurs when the user role switches in a live streaming.

    For example, from a host to an audience or vice versa.

    This callback notifies the application of a user role switch when the application calls the setClientRole method.

    Parameters

    Returns this

  • Occurs when a user or host joins the channel.

    The SDK triggers this callback under one of the following circumstances:

    • A remote user/host joins the channel by calling the joinChannel method.
    • A remote user switches the user role to the host by calling the setClientRole method after joining the channel.
    • A remote user/host rejoins the channel after a network interruption.
    • The host injects an online media stream into the channel by calling the addInjectStreamUrl method.
    note

    In the 1 (live streaming) profile:

    • The host receives this callback when another host joins the channel.
    • The audience in the channel receives this callback when a new host joins the channel.
    • When a web application joins the channel, the SDK triggers this callback as long as the web application publishes streams.

    Parameters

    • evt: "userJoined"
    • cb: function
        • (uid: number, elapsed: number): void
        • Parameters

          • uid: number

            User ID of the user or host joining the channel.

          • elapsed: number

            Time delay (ms) from the local user calling the joinChannel method until the SDK triggers this callback.

          Returns void

    Returns this

  • Occurs when a remote user (Communication)/host (Live streaming) leaves the channel.

    There are two reasons for users to become offline:

    • Leave the channel: When the user/host leaves the channel, the user/host sends a goodbye message. When this message is received, the SDK determines that the user/host leaves the channel.
    • Drop offline: When no data packet of the user or host is received for a certain period of time, the SDK assumes that the user/host drops offline. A poor network connection may lead to false detections, so we recommend using the signaling system for reliable offline detection.

    Parameters

    • evt: "userOffline"
    • cb: function
        • (uid: number, reason: number): void
        • Parameters

          • uid: number

            ID of the user or host who leaves the channel or goes offline.

          • reason: number

            Reason why the user goes offline:

            • The user left the current channel.
            • The SDK timed out and the user dropped offline because no data packet was received within a certain period of time. If a user quits the call and the message is not passed to the SDK (due to an unreliable channel), the SDK assumes the user dropped offline.
            • (Live streaming only.) The client role switched from the host to the audience.

          Returns void

    Returns this

  • Occurs when the SDK cannot reconnect to Agora's edge server 10 seconds after its connection to the server is interrupted.

    The SDK triggers this callback when it cannot connect to the server 10 seconds after calling the joinChannel method, whether or not it is in the channel.

    Parameters

    • evt: "connectionLost"
    • cb: function
        • (): void
        • Returns void

    Returns this

  • Occurs when the token expires.

    After a token(channel key) is specified by calling the joinChannel method, if the SDK losses connection with the Agora server due to network issues, the token may expire after a certain period of time and a new token may be required to reconnect to the server.

    This callback notifies the application to generate a new token and call joinChannel to rejoin the channel with the new token.

    Parameters

    • evt: "requestToken"
    • cb: function
        • (): void
        • Returns void

    Returns this

  • Occurs when the token expires in 30 seconds.

    The user becomes offline if the token used in the joinChannel method expires. The SDK triggers this callback 30 seconds before the token expires to remind the application to get a new token. Upon receiving this callback, generate a new token on the server and call the renewToken method to pass the new token to the SDK.

    Parameters

    • evt: "tokenPrivilegeWillExpire"
    • cb: function
        • (token: string): void
        • Parameters

          • token: string

            The token that expires in 30 seconds.

          Returns void

    Returns this

  • Reports the statistics of the AgoraRtcChannel once every two seconds.

    Parameters

    • evt: "rtcStats"
    • cb: function

    Returns this

  • Reports the last mile network quality of each user in the channel once every two seconds.

    Last mile refers to the connection between the local device and Agora's edge server.

    Parameters

    • evt: "networkQuality"
    • cb: function
        • Parameters

          • uid: number

            User ID. The network quality of the user with this uid is reported. If uid is 0, the local network quality is reported.

          • txquality: AgoraNetworkQuality

            Uplink transmission quality rating of the user in terms of the transmission bitrate, packet loss rate, average RTT (Round-Trip Time), and jitter of the uplink network. See AgoraNetworkQuality.

          • rxquality: AgoraNetworkQuality

            Downlink network quality rating of the user in terms of the packet loss rate, average RTT, and jitter of the downlink network. See AgoraNetworkQuality.

          Returns void

    Returns this

  • Reports the statistics of the video stream from each remote user/host.

    Parameters

    Returns this

  • Reports the statistics of the audio stream from each remote user/host.

    Parameters

    Returns this

  • Occurs when the remote audio state changes.

    This callback indicates the state change of the remote audio stream.

    Parameters

    Returns this

  • Reports which user is the loudest speaker.

    This callback returns the user ID of the user with the highest voice volume during a period of time, instead of at the moment.

    note

    To receive this callback, you need to call the enableAudioVolumeIndication method.

    Parameters

    • evt: "activeSpeaker"
    • cb: function
        • (uid: number): void
        • Parameters

          • uid: number

            User ID of the active speaker. A uid of 0 represents the local user. If the user enables the audio volume indication by calling the enableAudioVolumeIndication method, this callback returns the uid of the active speaker detected by the audio volume detection module of the SDK.

          Returns void

    Returns this

  • deprecated

    This callback is deprecated, please use remoteAudioStateChanged instead.

    Occurs when the engine receives the first audio frame from a specified remote user.

    Parameters

    • evt: "firstRemoteAudioDecoded"
    • cb: function
        • (uid: number, elapsed: number): void
        • Parameters

          • uid: number

            User ID of the remote user sending the audio stream.

          • elapsed: number

            The time elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback.

          Returns void

    Returns this

  • Occurs when the video size or rotation of a specified user changes.

    Parameters

    • evt: "videoSizeChanged"
    • cb: function
        • (uid: number, width: number, height: number, rotation: number): void
        • Parameters

          • uid: number

            User ID of the remote user or local user (0) whose video size or rotation changes.

          • width: number

            New width (pixels) of the video.

          • height: number

            New height (pixels) of the video.

          • rotation: number

          Returns void

    Returns this

  • Occurs when the remote video state changes.

    Parameters

    Returns this

  • Occurs when the local user receives the data stream from the remote user within five seconds.

    The SDK triggers this callback when the local user receives the stream message that the remote user sends by calling the sendStreamMessage method.

    Parameters

    • evt: "streamMessage"
    • cb: function
        • (uid: number, streamId: number, data: string): void
        • Parameters

          • uid: number

            User ID of the remote user sending the message.

          • streamId: number

            Stream ID.

          • data: string

            The data received bt the local user.

          Returns void

    Returns this

  • Parameters

    • evt: "snapshotTaken"
    • cb: function
        • (channel: string, uid: number, filePath: number, width: number, height: number, errCode: number): void
        • Parameters

          • channel: string
          • uid: number
          • filePath: number
          • width: number
          • height: number
          • errCode: number

          Returns void

    Returns this

  • Reports the result of an audio device test.

    since

    v3.7.0

    After successfully calling startAudioDeviceLoopbackTest to start an audio device test, the SDK triggers the audioDeviceTestVolumeIndication callback at the set time interval to report the volume information of the audio device tested.

    Parameters

    Returns this

  • Occurs when the local user does not receive the data stream from the remote user within five seconds.

    The SDK triggers this callback when the local user fails to receive the stream message that the remote user sends by calling the sendStreamMessage method.

    Parameters

    • evt: "streamMessageError"
    • cb: function
        • (uid: number, streamId: number, code: number, missed: number, cached: number): void
        • Parameters

          • uid: number

            User ID of the remote user sending the message.

          • streamId: number

            Stream ID.

          • code: number
          • missed: number

            Number of the lost messages.

          • cached: number

            Number of incoming cached messages when the data stream is interrupted.

          Returns void

    Returns this

  • Occurs when the state of the media stream relay changes.

    The SDK reports the state of the current media relay and possible error messages in this callback.

    Parameters

    Returns this

  • Reports events during the media stream relay.

    Parameters

    Returns this

  • deprecated

    This callback is deprecated. Please use remoteAudioStateChanged instead.

    Occurs when the engine receives the first audio frame from a specific remote user.

    Parameters

    • evt: "firstRemoteAudioFrame"
    • cb: function
        • (uid: number, elapsed: number): void
        • Parameters

          • uid: number

            User ID of the remote user.

          • elapsed: number

            Time elapsed (ms) from the local user calling joinChannel until the SDK triggers this callback.

          Returns void

    Returns this

  • Parameters

    • evt: string
    • listener: Function

    Returns this

  • Occurs when the state of the RTMP or RTMPS streaming changes.

    The SDK triggers this callback to report the result of the local user calling the addPublishStreamUrl and removePublishStreamUrl method.

    This callback indicates the state of Media Push. When exceptions occur, you can troubleshoot issues by referring to the detailed error descriptions in the code parameter.

    Parameters

    • evt: "rtmpStreamingStateChanged"
    • cb: function
        • (url: string, state: number, code: number): void
        • Parameters

          • url: string

            The RTMP URL address.

          • state: number

            Media Push state:

            • 0: Media Push has not started or has ended. This state is also triggered after you remove an RTMP address from the CDN by calling removePublishStreamUrl.
            • 1: The SDK is connecting to Agora's streaming server and the RTMP server. This state is triggered after you call the addPublishStreamUrl method.
            • 2: Media Push publishes. The SDK successfully publishes the Media Push stream and returns this state.
            • 3: Media Push is recovering. When exceptions occur to the CDN, or the streaming is interrupted, the SDK tries to resume Media Push and returns this state.
              • If the SDK successfully resumes the streaming, 2 returns.
              • If the streaming does not resume within 60 seconds or server errors occur, 4 returns. You can also reconnect to the server by calling the removePublishStreamUrl and then addPublishStreamUrl method.
            • 4: Media Push fails. See the code parameter for the detailed error information. You can also call the addPublishStreamUrl method to publish Media Push again.
          • code: number

            The detailed error information:

            • 0: Media Push publishes successfully.
            • 1: Invalid argument used.
            • 2: The RTMP streams is encrypted and cannot be published.
            • 3: Timeout for Media Push. Call the addPublishStreamUrl to publish the stream again.
            • 4: An error occurs in Agora's streaming server. Call the addPublishStreamUrl to publish the stream again.
            • 5: An error occurs in the RTMP server.
            • 6: Media Push publishes too frequently.
            • 7: The host publishes more than 10 URLs. Delete the unnecessary URLs before adding new ones.
            • 8: The host manipulates other hosts' URLs. Check your app logic.
            • 9: Agora's server fails to find the RTMP stream.
            • 10: The format of the stream's URL address is not supported. Check whether the URL format is correct.
            • 100: The streaming has been stopped normally. After you call removePublishStreamUrl to stop streaming, the SDK returns this value.

          Returns void

    Returns this

  • Occurs when the publisher's transcoding is updated.

    Parameters

    • evt: "transcodingUpdated"
    • cb: function
        • (): void
        • Returns void

    Returns this

  • Occurs when a voice or video stream URL address is added to a live broadcast.

    warning

    Agora will soon stop the service for injecting online media streams on the client. If you have not implemented this service, Agora recommends that you do not use it.

    Parameters

    • evt: "streamInjectedStatus"
    • cb: function
        • (url: string, uid: number, status: number): void
        • Parameters

          • url: string

            The URL address of the externally injected stream.

          • uid: number

            User ID.

          • status: number

            State of the externally injected stream:

            • 0: The external video stream imported successfully.
            • 1: The external video stream already exists.
            • 2: The external video stream to be imported is unauthorized.
            • 3: Import external video stream timeout.
            • 4: Import external video stream failed.
            • 5: The external video stream stopped importing successfully.
            • 6: No external video stream is found.
            • 7: No external video stream is found.
            • 8: Stop importing external video stream timeout.
            • 9: Stop importing external video stream failed.
            • 10: The external video stream is corrupted.

          Returns void

    Returns this

  • Occurs when the remote media stream falls back to audio-only stream due to poor network conditions or switches back to the video stream after the network conditions improve.

    If you call setRemoteSubscribeFallbackOption and set option as AUDIO_ONLY(2), the SDK triggers this callback when the remotely subscribed media stream falls back to audio-only mode due to poor uplink conditions, or when the remotely subscribed media stream switches back to the video after the uplink network condition improves.

    Parameters

    • evt: "remoteSubscribeFallbackToAudioOnly"
    • cb: function
        • (uid: number, isFallbackOrRecover: boolean): void
        • Parameters

          • uid: number

            ID of the remote user sending the stream.

          • isFallbackOrRecover: boolean

            Whether the remote media stream falls back to audio-only or switches back to the video:

            • true: The remote media stream falls back to audio-only due to poor network conditions.
            • false: The remote media stream switches back to the video stream after the network conditions improved.

          Returns void

    Returns this

  • Occurs when the connection state between the SDK and the server changes.

    Parameters

    Returns this

  • Occurs when the audio publishing state changes.

    since

    v3.2.0

    This callback indicates the publishing state change of the local audio stream.

    Parameters

    Returns this

  • Occurs when the video publishing state changes.

    since

    v3.2.0

    This callback indicates the publishing state change of the local video stream.

    Parameters

    Returns this

  • Occurs when the audio subscribing state changes.

    since

    v3.2.0

    This callback indicates the subscribing state change of a remote audio stream.

    Parameters

    • evt: "audioSubscribeStateChanged"
    • cb: function

    Returns this

  • Occurs when the video subscribing state changes.

    since

    v3.2.0

    This callback indicates the subscribing state change of a remote video stream.

    Parameters

    • evt: "videoSubscribeStateChanged"
    • cb: function

    Returns this

  • Occurs when the first remote video frame is rendered.

    since

    v3.7.0

    The SDK triggers this callback when the first frame of the remote video is displayed in the user's video window. The application can get the time elapsed from a user joining the channel until the first video frame is displayed.

    Parameters

    • evt: "firstRemoteVideoFrame"
    • cb: function
        • (uid: number, width: number, height: number, elapsed: number): void
        • Parameters

          • uid: number

            User ID of the remote user sending the video stream.

          • width: number

            Width (px) of the video frame.

          • height: number

            Height (px) of the video stream.

          • elapsed: number

            Time elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback.

          Returns void

    Returns this

publish

  • publish(): number
  • Publishes the local stream to the channel.

    deprecated

    This method is deprecated as of v3.4.5. Use muteLocalAudioStream(false) or muteLocalVideoStream(false) instead.

    You must keep the following restrictions in mind when calling this method. Otherwise, the SDK returns the ERR_REFUSED (5):

    • This method publishes one stream only to the channel corresponding to the current AgoraRtcChannel object.
    • In a live streaming channel, only a host can call this method. To switch the client role, call setClientRole of the current AgoraRtcChannel object.
    • You can publish a stream to only one channel at a time. For details on joining multiple channels, see the advanced guide Join Multiple Channels

    Returns number

    • 0: Success
    • < 0: Failure
      • ERR_REFUSED (5): The method call is refused.

registerMediaMetadataObserver

  • registerMediaMetadataObserver(): number
  • Registers a media metadata observer.

    Returns number

    • 0: Success.
    • < 0: Failure.

release

  • release(): number
  • Releases all AgoraRtcChannel resource

    Returns number

    • 0: Success.
    • < 0: Failure.
      • ERR_NOT_INITIALIZED (7): The SDK is not initialized before calling this method.

removeInjectStreamUrl

  • removeInjectStreamUrl(url: string): number
  • Removes the injected the online media stream in a live streaming.

    This method removes the URL address (added by the addInjectStreamUrl method) in a live streaming.

    If this method call is successful, the SDK triggers the userOffline (uid:666) callback and report the UID of the removed stream is 666.

    warning

    Agora will soon stop the service for injecting online media streams on the client. If you have not implemented this service, Agora recommends that you do not use it.

    Parameters

    • url: string

      The URL address of the injected stream to be removed.

    Returns number

    • 0: Success
    • < 0: Failure

removePublishStreamUrl

  • removePublishStreamUrl(url: string): number
  • Removes the RTMP stream from the CDN.

    This method removes the RTMP URL address (added by addPublishStreamUrl) and stops Media Push.

    This method call triggers the rtmpStreamingStateChanged callback to report the state of removing the URL address.

    note
    • Only the host in the 1 (live streaming) profile can call this method.
    • This method removes only one RTMP URL address each time it is called.
    • This method applies to the 1 (live streaming) profile only.
    • Call this method after addPublishStreamUrl.

    Parameters

    • url: string

      The RTMP URL address to be removed. The maximum length of this parameter is 1024 bytes. The RTMP URL address must not contain special characters, such as Chinese language characters.

    Returns number

    • 0: Success
    • < 0: Failure

renewToken

  • renewToken(newtoken: string): number
  • Gets a new token when the current token expires after a period of time.

    The token expires after a period of time once the token schema is enabled when the SDK triggers the onTokenPrivilegeWillExpire callback or CONNECTION_CHANGED_TOKEN_EXPIRED(9) of onConnectionStateChanged callback.

    You should call this method to renew token, or the SDK disconnects from Agora' server.

    Parameters

    • newtoken: string

      The new Token.

    Returns number

    • 0: Success
    • < 0: Failure

sendMetadata

  • sendMetadata(metadata: Metadata): number
  • Sends the media metadata.

    After calling the registerMediaMetadataObserver method, you can call the setMetadata method to send the media metadata.

    If it is a successful sending, the sender receives the sendMetadataSuccess callback, and the receiver receives the receiveMetadata callback.

    Parameters

    • metadata: Metadata

      The media metadata.

    Returns number

    • 0: Success.
    • < 0: Failure.

sendStreamMessage

  • sendStreamMessage(streamId: number, msg: string): number
  • Sends data stream messages to all users in the channel.

    The SDK has the following restrictions on this method:

    • Up to 30 packets can be sent per second in a channel with each packet having a maximum size of 1 kB.
    • Each client can send up to 6 kB of data per second.
    • Each user can have up to five data streams simultaneously.

    Ensure that you have created the data stream using createDataStream before calling this method.

    If the method call succeeds, the remote user receives the streamMessage callback; If the method call fails, the remote user receives the streamMessageError callback.

    note

    This method applies to the users in the communication(0) profile or the hosts in the 1 (live streaming) profile. If an audience in the 1 (live streaming) profile calls this method, the role of the audience may be switched to the host.

    Parameters

    • streamId: number

      he ID of the sent data stream, returned in the createDataStream method.

    • msg: string

      The data stream messages.

    Returns number

    • 0: Success
    • < 0: Failure

setClientRole

  • Sets the role of the user.

    • This method can be used to set the user's role before the user joins a channel in a live streaming.
    • This method can be used to switch the user role in a live streaming after the user joins a channel.

    In the 1 (live streaming) profile, when a user calls this method to switch user roles after joining a channel, SDK triggers the follwoing callbacks:

    • The local client: clientRoleChanged in the AgoraRtcChannel interface.
    • The remote clinet: userjoined or userOffline.
    note

    This method applies only to the 1 (live streaming) profile.

    Parameters

    • role: CLIENT_ROLE_TYPE

      Sets the role of the user. See {@link AgoraRtcChannel.role role}

    Returns number

    • 0: Success
    • < 0: Failure

setClientRoleWithOptions

  • Sets the role of a user in interactive live streaming.

    since

    v3.2.0

    You can call this method either before or after joining the channel to set the user role as audience or host. If you call this method to switch the user role after joining the channel, the SDK triggers the following callbacks:

    • The local client: clientRoleChanged.
    • The remote client: userJoined or userOffline.
    note
    • This method applies to the LIVE_BROADCASTING profile only.
    • The difference between this method and setClientRole is that this method can set the user level in addition to the user role.
      • The user role determines the permissions that the SDK grants to a user, such as permission to send local streams, receive remote streams, and push streams to a CDN address.
      • The user level determines the level of services that a user can enjoy within the permissions of the user's role. For example, an audience can choose to receive remote streams with low latency or ultra low latency. Levels affect prices.

    Parameters

    Returns number

    • 0: Success.
    • < 0: Failure.

setDefaultMuteAllRemoteAudioStreams

  • setDefaultMuteAllRemoteAudioStreams(mute: boolean): number
  • Stops or resumes subscribing to the audio streams of all remote users by default.

    deprecated

    This method is deprecated from v3.3.1.

    Call this method after joining a channel. After successfully calling this method, the local user stops or resumes subscribing to the audio streams of all subsequent users.

    note

    If you need to resume subscribing to the audio streams of remote users in the channel after calling setDefaultMuteAllRemoteAudioStreams(true), do the following:

    • If you need to resume subscribing to the audio stream of a specified user, call muteRemoteAudioStream(false), and specify the user ID.
    • If you need to resume subscribing to the audio streams of multiple remote users, call muteRemoteAudioStream(false) multiple times.

    Parameters

    • mute: boolean

      Sets whether to stop subscribing to the audio streams of all remote users by default.

      • true: Stop subscribing to the audio streams of all remote users by default.
      • false: (Default) Resume subscribing to the audio streams of all remote users by default.

    Returns number

    • 0: Success.
    • < 0: Failure.

setDefaultMuteAllRemoteVideoStreams

  • setDefaultMuteAllRemoteVideoStreams(mute: boolean): number
  • Stops or resumes subscribing to the video streams of all remote users by default.

    deprecated

    This method is deprecated from v3.3.1.

    Call this method after joining a channel. After successfully calling this method, the local user stops or resumes subscribing to the video streams of all subsequent users.

    note

    If you need to resume subscribing to the video streams of remote users in the channel after calling setDefaultMuteAllRemoteVideoStreams(true), do the following:

    • If you need to resume subscribing to the video stream of a specified user, call muteRemoteVideoStream(false), and specify the user ID.
    • If you need to resume subscribing to the video streams of multiple remote users, call muteRemoteVideoStream(false) multiple times.

    Parameters

    • mute: boolean

      Sets whether to stop subscribing to the video streams of all remote users by default.

      • true: Stop subscribing to the video streams of all remote users by default.
      • false: (Default) Resume subscribing to the video streams of all remote users by default.

    Returns number

    • 0: Success.
    • < 0: Failure.

setEncryptionMode

  • setEncryptionMode(mode: string): number
  • Sets the built-in encryption mode.

    depercated

    This method is deprecated from v3.2.0. Use the enableEncryption method instead.

    The Agora SDK supports built-in encryption, which is set to the aes-128-xts mode by default. To use other encryption modes, call this method.

    All users in the same channel must use the same encryption mode and password.

    Refer to the information related to the AES encryption algorithm on the differences between the encryption modes.

    note

    Call the setEncryptionSecret method before calling this method.

    Parameters

    • mode: string

      The set encryption mode:

      • "aes-128-xts": (Default) 128-bit AES encryption, XTS mode.
      • "aes-128-ecb": 128-bit AES encryption, ECB mode.
      • "aes-256-xts": 256-bit AES encryption, XTS mode.
      • "": When encryptionMode is set as NULL, the encryption mode is set as "aes-128-xts" by default.

    Returns number

    • 0: Success
    • < 0: Failure

setEncryptionSecret

  • setEncryptionSecret(secret: string): number
  • deprecated

    This method is deprecated from v3.2.0. Use the enableEncryption method instead.

    Enables built-in encryption with an encryption password before users join a channel.

    All users in a channel must use the same encryption password. The encryption password is automatically cleared once a user leaves the channel. If an encryption password is not specified, the encryption functionality will be disabled.

    note
    • Do not use this method for the Media Push function.
    • For optimal transmission, ensure that the encrypted data size does not exceed the original data size + 16 bytes. 16 bytes is the maximum padding size for AES encryption.

    Parameters

    • secret: string

      The encryption password.

    Returns number

    • 0: Success
    • < 0: Failure

setLiveTranscoding

  • Sets the video layout and audio settings for CDN live.

    The SDK triggers the transcodingUpdated callback when you call this method to update the transcoding setting. If you call this method for the first time to set the transcoding setting, the SDK does not trigger the transcodingUpdated callback.

    note
    • Only the host in the Live-broadcast porfile can call this method.
    • Ensure that you enable the Media Push service before using this function. See Prerequisites in the Media Push guide.
    • If you call the setLiveTranscoding method to set the LiveTranscoding class for the first time, the SDK does not trigger the transcodingUpdated callback.

    Parameters

    • transcoding: TranscodingConfig

      The transcoding setting for the audio and video streams during Media Push. See {@link LiveTranscoding}

    Returns number

    • 0: Success
    • < 0: Failure

setMaxMetadataSize

  • setMaxMetadataSize(size: number): number
  • Sets the maximum size of the media metadata.

    After calling the registerMediaMetadataObserver method, you can call the setMaxMetadataSize method to set the maximum size.

    Parameters

    • size: number

      The maximum size of your metadata.

    Returns number

    • 0: Success.
    • < 0: Failure.

setRemoteDefaultVideoStreamType

  • setRemoteDefaultVideoStreamType(streamType: StreamType): number
  • Sets the default type of receiving video stream.

    Under limited network conditions, if the publisher has not disabled the dual-stream mode using enableDualStreamMode(false), the receiver can choose to receive either the high-video stream (the high resolution, and high bitrate video stream) or the low-video stream (the low resolution, and low bitrate video stream) by default.

    By default, users receive the high-video stream. Call this method if you want to switch to the low-video stream. This method allows the app to adjust the corresponding video stream type based on the size of the video window to reduce the bandwidth and resources.

    The aspect ratio of the low-video stream is the same as the high-video stream. Once the resolution of the high-video stream is set, the system automatically sets the resolution, frame rate, and bitrate of the low-video stream.

    Parameters

    Returns number

    • 0: Success
    • < 0: Failure

setRemoteUserPriority

  • setRemoteUserPriority(uid: number, priority: Priority): number
  • Prioritizes a remote user's stream.

    Use this method with the setRemoteSubscribeFallbackOption method.

    If the fallback function is enabled for a subscribed stream, the SDK ensures the high-priority user gets the best possible stream quality.

    note

    The Agora SDK supports setting serPriority as high for one user only.

    Parameters

    • uid: number

      The ID of the remote user.

    • priority: Priority

      The priority of the remote user. See Priority.

    Returns number

    • 0: Success
    • < 0: Failure

setRemoteVideoStreamType

  • setRemoteVideoStreamType(uid: number, streamType: StreamType): number
  • Sets the stream type of the remote video.

    Under limited network conditions, if the publisher has not disabled the dual-stream mode using enableDualStreamMode(false), the receiver can choose to receive either the high-video stream (the high resolution, and high bitrate video stream) or the low-video stream (the low resolution, and low bitrate video stream).

    By default, users receive the high-video stream. Call this method if you want to switch to the low-video stream. This method allows the app to adjust the corresponding video stream type based on the size of the video window to reduce the bandwidth and resources.

    The aspect ratio of the low-video stream is the same as the high-video stream. Once the resolution of the high-video stream is set, the system automatically sets the resolution, frame rate, and bitrate of the low-video stream. The SDK reports the result of calling this method in the apiCallExecuted callback.

    Parameters

    • uid: number

      The ID of the remote user sending the video stream.

    • streamType: StreamType

      The video-stream type. See StreamType

    Returns number

    • 0: Success
    • < 0: Failure

setRemoteVoicePosition

  • setRemoteVoicePosition(uid: number, pan: number, gain: number): number
  • Sets the sound position and gain of a remote user.

    When the local user calls this method to set the sound position of a remote user, the sound difference between the left and right channels allows the local user to track the real-time position of the remote user, creating a real sense of space. This method applies to massively multiplayer online games, such as Battle Royale games.

    note
    • For this method to work, enable stereo panning for remote users by calling the enableSoundPositionIndication method before joining a channel.
    • This method requires hardware support. For the best sound positioning, we recommend using a stereo speaker.

    Parameters

    • uid: number

      The ID of the remote user.

    • pan: number

      The sound position of the remote user. The value ranges from -1.0 to 1.0:

      • 0.0: The remote sound comes from the front.
      • -1.0: The remote sound comes from the left.
      • 1.0: The remote sound comes from the right.
    • gain: number

      Gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain.

    Returns number

    • 0: Success
    • < 0: Failure

startChannelMediaRelay

  • Starts to relay media streams across channels.

    After a successful method call, the SDK triggers the channelMediaRelayState and channelMediaRelayEvent callbacks, which returns the state and event of the media stream relay.

    • If channelMediaRelayState returns the state code 2 and the error code0, and channelMediaRelayEvent returns the event code 4, the host starts sending data to the destination channel.
    • If the channelMediaRelayState returns the state code 3, an exception occurs during the media stream relay.
    note
    • Contact sales-us@agora.io before implementing this function.
    • Call this method after joining the channel.
    • This method takes effect only when you are a host in a live-broadcast channel.
    • After a successful method call, if you want to call this method again, ensure that you call the stopChannelMediaRelay method to quit the current relay.
    • We do not support string user accounts in this API.

    Parameters

    Returns number

    • 0: Success
    • < 0: Failure

stopChannelMediaRelay

  • stopChannelMediaRelay(): number
  • Stops the media stream relay.

    Once the relay stops, the host quits all the destination channels.

    After a successful method call, the SDK triggers the channelMediaRelayState callback. If the callback returns the state code 0 and the error code 1, the host successfully stops the relay.

    note

    If the method call fails, the SDK triggers the channelMediaRelayState callback with the error code 2 and 8 in ChannelMediaRelayError. You can leave the channel by calling the leaveChannel method, and the media stream relay automatically stops.

    Returns number

    • 0: Success
    • < 0: Failure

unRegisterMediaMetadataObserver

  • unRegisterMediaMetadataObserver(): number
  • Unregisters a media metadata observer.

    Returns number

    • 0: Success.
    • < 0: Failure.

unpublish

  • unpublish(): number
  • Stops publishing a stream to the channel.

    deprecated

    This method is deprecated as of v3.4.5. Use muteLocalAudioStream(true) or muteLocalVideoStream(true) instead.

    If you call this method in a channel where you are not publishing streams, the SDK returns #ERR_REFUSED (5).

    Returns number

    • 0: Success
    • < 0: Failure
      • ERR_REFUSED (5): The method call is refused.

updateChannelMediaRelay

  • Updates the channels for media stream relay.

    After a successful startChannelMediaRelay method call, if you want to relay the media stream to more channels, or leave the current relay channel, you can call the updateChannelMediaRelay method.

    After a successful method call, the SDK triggers the channelMediaRelayEvent callback with the event code 7.

    note

    Call this method after the startChannelMediaRelay method to update the destination channel.

    Parameters

    Returns number

    • 0: Success
    • < 0: Failure