IRtcEngineEx
Interface class that provides multi-channel methods.
Inherits from IRtcEngine.
addVideoWatermarkEx
Adds a local video watermark.
abstract addVideoWatermarkEx(
watermarkUrl: string,
options: WatermarkOptions,
connection: RtcConnection
): number;
- Deprecated
- Deprecated: This method is deprecated. Use addVideoWatermarkWithConfigEx instead.
- If the video orientation (OrientationMode) is fixed to landscape or adaptive landscape, landscape coordinates are used for the watermark.
- If the video orientation (OrientationMode) is fixed to portrait or adaptive portrait, portrait coordinates are used for the watermark.
- When setting the watermark coordinates, the image area of the watermark must not exceed the video dimensions set in the setVideoEncoderConfigurationEx method; otherwise, the excess part will be cropped.
- You must call this method after calling enableVideo.
- The image to be added must be in PNG format. This method supports all pixel formats of PNG images: RGBA, RGB, Palette, Gray, and Alpha_gray.
- If the size of the PNG image differs from the size you set in this method, the SDK will scale or crop the image to match the settings.
- If you have started the local video preview using startPreview, you can use the
visibleInPreviewparameter to set whether the watermark is visible during preview. - If local video mirroring is enabled, the local watermark will also be mirrored. To prevent the watermark from being mirrored when viewed locally, we recommend not using both mirroring and watermark features simultaneously. Implement local watermarking at the application level.
Parameters
- watermarkUrl
- The local path of the watermark image to be added. This method supports adding watermark images from absolute or relative local paths.
- options
- Settings for the watermark image to be added. See WatermarkOptions.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
addVideoWatermarkWithConfigEx
Adds a watermark image to the local video.
abstract addVideoWatermarkWithConfigEx(
config: WatermarkConfig,
connection: RtcConnection
): number;
- Since
- Available since v4.6.2.
Scenario
This method applies to multi-channel scenarios.
Parameters
- config
- Watermark configuration. See WatermarkConfig.
- connection
- RtcConnection object. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure.
adjustUserPlaybackSignalVolumeEx
Adjusts the playback volume of a specified remote user.
abstract adjustUserPlaybackSignalVolumeEx(
uid: number,
volume: number,
connection: RtcConnection
): number;
You can call this method during a call to adjust the playback volume of a specified remote user. To adjust the playback volume of multiple users, call this method multiple times.
Timing
You need to call this method after joinChannelEx.
Parameters
- uid
- The ID of the remote user.
- volume
- The volume, with a range of [0,400].
- 0: Mute.
- 100: (Default) Original volume.
- 400: Four times the original volume, with overflow protection.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
clearVideoWatermarkEx
Removes added video watermarks.
abstract clearVideoWatermarkEx(connection: RtcConnection): number;
Parameters
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
createDataStreamEx
Creates a data stream.
abstract createDataStreamEx(
config: DataStreamConfig,
connection: RtcConnection
): number;
Timing
This method must be called after joinChannelEx.
Parameters
- config
- Data stream configuration. See DataStreamConfig.
- connection
- Connection information. See RtcConnection.
Return Values
- ID of the created data stream: if the method call succeeds.
- < 0: Failure. See Error Codes for details and resolution suggestions.
enableAudioVolumeIndicationEx
Enables audio volume indication.
abstract enableAudioVolumeIndicationEx(
interval: number,
smooth: number,
reportVad: boolean,
connection: RtcConnection
): number;
This method allows the SDK to periodically report to the app the volume information of the local user who is sending streams and the remote users (up to 3) with the highest instantaneous volume.
Timing
You need to call this method after joinChannelEx.
Parameters
- interval
- The time interval for the volume indication:
- ≤ 0: Disables the volume indication feature.
- > 0: Returns the interval for volume indication, in milliseconds. It is recommended to set it above 100 ms. Must not be less than 10 ms, otherwise the onAudioVolumeIndication callback will not be received.
- smooth
- The smoothing factor that specifies the sensitivity of the volume indication. The range is [0,10], and the recommended value is 3. The larger the value, the more sensitive the fluctuation; the smaller the value, the smoother the fluctuation.
- reportVad
-
- true: Enables the local voice detection feature. When enabled, the
vadparameter in the onAudioVolumeIndication callback reports whether a human voice is detected locally. - false: (Default) Disables the local voice detection feature. Except in scenarios where the engine automatically performs local voice detection, the
vadparameter in the onAudioVolumeIndication callback does not report whether a human voice is detected locally.
- true: Enables the local voice detection feature. When enabled, the
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
enableContentInspectEx
Enables/disables local snapshot upload.
abstract enableContentInspectEx(
enabled: boolean,
config: ContentInspectConfig,
connection: RtcConnection
): number;
This method allows capturing and uploading snapshots for multiple video streams. After enabling local snapshot upload, the SDK captures and uploads snapshots of the video sent by the local user based on the module type and frequency you set in ContentInspectConfig. After capturing, the Agora server sends a callback notification to your server via HTTPS request and uploads all snapshots to the third-party cloud storage you specify.
Timing
You can call this method either before or after joining a channel.
Parameters
- enabled
- Whether to enable local snapshot upload:
- true: Enable local snapshot upload.
- false: Disable local snapshot upload.
- config
- Local snapshot upload configuration. See ContentInspectConfig.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
enableDualStreamModeEx
Enables or disables dual-stream mode on the sender.
abstract enableDualStreamModeEx(
enabled: boolean,
streamConfig: SimulcastStreamConfig,
connection: RtcConnection
): number;
- Deprecated
- Deprecated: Deprecated since v4.2.0. Use setDualStreamModeEx instead.
- High-quality stream: High resolution and high frame rate video stream.
- Low-quality stream: Low resolution and low frame rate video stream.
Parameters
- enabled
- Whether to enable dual-stream mode:
- true: Enable dual-stream mode.
- false: (Default) Disable dual-stream mode.
- streamConfig
- Configuration of the low-quality video stream. See SimulcastStreamConfig.
Note: If
modeis set toDisableSimulcastStream, thenstreamConfigwill not take effect. - connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
enableEncryptionEx
Enables or disables built-in encryption.
abstract enableEncryptionEx(
connection: RtcConnection,
enabled: boolean,
config: EncryptionConfig
): number;
The SDK automatically disables encryption after the user leaves the channel. To re-enable encryption, you must call this method before the user joins the channel again.
- All users in the same channel must use the same encryption mode and key when calling this method.
- If built-in encryption is enabled, the RTMP streaming feature cannot be used.
Scenario
Scenarios with high security requirements.
Timing
This method must be called before joining a channel.
Parameters
- enabled
- Whether to enable built-in encryption:
true: Enable built-in encryption.false: (Default) Disable built-in encryption.
- config
- Configure the built-in encryption mode and key. See EncryptionConfig.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
enableLoopbackRecordingEx
Enables loopback recording.
abstract enableLoopbackRecordingEx(
connection: RtcConnection,
enabled: boolean,
deviceName?: string
): number;
After enabling loopback recording, the sound played by the sound card will be mixed into the local audio stream and can be sent to the remote side.
- The default sound card on macOS does not support recording. If you need to use this feature, please enable a virtual sound card and set
deviceNameto the name of that virtual sound card. Agora recommends using its self-developed virtual sound card AgoraALD for recording. - This method currently supports only one loopback recording stream.
Parameters
- connection
- Connection information. See RtcConnection.
- enabled
- Whether to enable loopback recording:
- true: Enable loopback recording.
- false: (Default) Disable loopback recording.
- deviceName
-
Note: Electron for UnionTech OS SDK does not support this parameter.
- macOS: The device name of the virtual sound card. Default is empty, which means using the AgoraALD virtual sound card for recording.
- Windows: The device name of the sound card. Default is empty, which means using the built-in sound card of the device.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
getCallIdEx
Gets the call ID using the connection ID.
abstract getCallIdEx(connection: RtcConnection): string;
Each time the client joins a channel, a corresponding callId is generated to identify the call session. You can call this method to get the callId and then pass it to methods such as rate and complain.
Timing
This method must be called after joining a channel.
Parameters
- connection
- Connection information. See RtcConnection.
getConnectionStateEx
Gets the current network connection state.
abstract getConnectionStateEx(connection: RtcConnection): ConnectionStateType;
Timing
Can be called before or after joining a channel.
Parameters
- connection
- Connection information. See RtcConnection.
Return Values
The current network connection state. See ConnectionStateType.
joinChannelEx
Joins a channel.
abstract joinChannelEx(
token: string,
connection: RtcConnection,
options: ChannelMediaOptions
): number;
Call this method to join multiple channels simultaneously. If you want to join the same channel on different devices, make sure the user IDs used on different devices are different.
Scenario
This method is suitable for multi-channel scenarios.
Timing
Call this method after initialize.
In multi-camera capture scenarios, call startPreview after this method and set sourceType to VideoSourceCameraSecondary to ensure the second camera captures properly.
Parameters
- token
- A dynamic key generated on the server for authentication. See Token Authentication.
Note:
- (Recommended) If your project enables security mode (i.e., using APP ID + Token for authentication), this parameter is required.
- If your project only enables debug mode (i.e., using APP ID for authentication), you can join a channel without providing a Token. You will automatically leave the channel 24 hours after joining.
- If you need to join multiple channels simultaneously or switch channels frequently, Agora recommends using a wildcard Token to avoid requesting a new Token from the server each time. See Using Wildcard Token.
- connection
- Connection information. See RtcConnection.
- options
- Channel media options. See ChannelMediaOptions.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and troubleshooting.
- -2: Invalid parameters. For example, invalid Token,
uidis not an integer, or ChannelMediaOptions contains invalid values. Provide valid parameters and rejoin the channel. - -3: IRtcEngine initialization failed. Reinitialize the IRtcEngine object.
- -7: IRtcEngine is not initialized. Initialize the IRtcEngine object before calling this method.
- -8: Internal state error in IRtcEngine. Possible cause: startEchoTest was called to start echo test but stopEchoTest was not called before joining the channel. Call stopEchoTest before this method.
- -17: Join channel rejected. Possible cause: the user is already in the channel. Use onConnectionStateChanged to check the connection state. Do not call this method again unless you receive
ConnectionStateDisconnected(1). - -102: Invalid channel name. Provide a valid
channelIdand rejoin the channel. - -121: Invalid user ID. Provide a valid
uidand rejoin the channel.
- -2: Invalid parameters. For example, invalid Token,
leaveChannelEx
Sets channel options and leaves the channel.
abstract leaveChannelEx(
connection: RtcConnection,
options?: LeaveChannelOptions
): number;
After calling this method, the SDK stops all audio and video interactions, leaves the current channel, and releases all session-related resources. After successfully joining a channel using joinChannelEx, you must call this method to end the call, otherwise you cannot start a new one.
- This method is asynchronous. When the call returns, it does not mean the user has actually left the channel.
- If you call leaveChannel, it will leave both channels joined via joinChannel and joinChannelEx.
Scenario
This method applies to multi-channel scenarios.
Timing
This method must be called after joinChannelEx.
Parameters
- connection
- Connection information. See RtcConnection.
- options
- Options for leaving the channel. See LeaveChannelOptions.
Note: This parameter only supports setting the
stopMicrophoneRecordingmember in LeaveChannelOptions. Other members are not effective.
Return Values
- 0: The method call succeeds.
- < 0: The method call fails. See Error Codes for details and resolution suggestions.
muteAllRemoteAudioStreamsEx
Stops or resumes subscribing to all remote users' audio streams.
abstract muteAllRemoteAudioStreamsEx(
mute: boolean,
connection: RtcConnection
): number;
After this method is successfully called, the local user stops or resumes subscribing to remote users' audio streams, including the streams of users who join the channel after this method is called.
- This method must be called after joining a channel.
- To disable subscribing to remote users' audio streams before joining a channel, set
autoSubscribeAudioto false when calling joinChannel.
Parameters
- mute
- Whether to stop subscribing to all remote users' audio streams:
- true: Stop subscribing to all remote users' audio streams.
- false: (Default) Subscribe to all remote users' audio streams.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
muteAllRemoteVideoStreamsEx
Stops or resumes subscribing to all remote users' video streams.
abstract muteAllRemoteVideoStreamsEx(
mute: boolean,
connection: RtcConnection
): number;
After this method is successfully called, the local user stops or resumes subscribing to all remote users' video streams, including the streams of users who join the channel after this method is called.
Parameters
- mute
- Whether to stop subscribing to all remote users' video streams.
- true: Stop subscribing to all users' video streams.
- false: (Default) Subscribe to all users' video streams.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
muteLocalAudioStreamEx
Stops or resumes publishing the local audio stream.
abstract muteLocalAudioStreamEx(
mute: boolean,
connection: RtcConnection
): number;
After this method is successfully called, the remote client triggers the onUserMuteAudio and onRemoteAudioStateChanged callbacks.
Parameters
- mute
- Whether to stop publishing the local audio stream.
- true: Stop publishing.
- false: (Default) Publish.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
muteLocalVideoStreamEx
Stops or resumes publishing the local video stream.
abstract muteLocalVideoStreamEx(
mute: boolean,
connection: RtcConnection
): number;
After this method is successfully called, the remote user receives the onUserMuteVideo callback.
- This method does not affect the video capture state and does not disable the camera.
Parameters
- mute
- Whether to stop sending the local video stream.
- true: Stop sending the local video stream.
- false: (Default) Send the local video stream.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and troubleshooting.
muteRemoteAudioStreamEx
Stops or resumes receiving the specified audio stream.
abstract muteRemoteAudioStreamEx(
uid: number,
mute: boolean,
connection: RtcConnection
): number;
This method stops or resumes receiving the audio stream from a specified remote user. You can call this method before or after joining a channel. The setting is reset after leaving the channel.
Parameters
- uid
- The ID of the specified user.
- mute
- Whether to stop receiving the specified audio stream:
- true: Stop receiving the specified audio stream.
- false: (Default) Continue receiving the specified audio stream.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and troubleshooting.
muteRemoteVideoStreamEx
Stops or resumes receiving the specified video stream.
abstract muteRemoteVideoStreamEx(
uid: number,
mute: boolean,
connection: RtcConnection
): number;
This method stops or resumes receiving the video stream from a specified remote user. You can call this method before or after joining a channel. The setting is reset after leaving the channel.
Parameters
- uid
- The ID of the remote user.
- mute
- Whether to stop receiving the video stream from a remote user:
- true: Stop receiving.
- false: (Default) Resume receiving.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and troubleshooting.
pauseAllChannelMediaRelayEx
Pauses media stream forwarding to all destination channels.
abstract pauseAllChannelMediaRelayEx(connection: RtcConnection): number;
After starting media stream forwarding across channels, if you need to pause forwarding to all channels, you can call this method. To resume forwarding, call the resumeAllChannelMediaRelay method.
Parameters
- connection
- Connection information. See RtcConnection.
Return Values
- 0: The method call was successful.
- < 0: The method call failed. See Error Codes for details and resolution suggestions.
- -5: This method call was rejected. There is no ongoing cross-channel media stream forwarding.
playEffectEx
Plays the specified sound effect in the channel.
abstract playEffectEx(
connection: RtcConnection,
soundId: number,
filePath: string,
loopCount: number,
pitch: number,
pan: number,
gain: number,
publish?: boolean,
startPos?: number
): number;
- Since
- Available since v4.6.2.
You can call this method to play a specified sound effect to all users in the channel. Each call to this method can only play one sound effect. To play multiple sound effects simultaneously, use different soundId and filePath values and call this method multiple times. You can also set whether to publish the sound effect in the channel.
- Agora recommends not playing more than three sound effects simultaneously.
- The sound effect ID and file path in this method must match those in the preloadEffectEx method.
- If you call preloadEffectEx before calling playEffectEx, the file resource will not be closed after playEffectEx is executed. The next call to playEffectEx will start playback from the beginning.
- If you do not call preloadEffectEx before calling playEffectEx, the file resource will be destroyed after playEffectEx is executed. The next call to playEffectEx will attempt to reopen the file and play from the beginning.
Scenario
This method applies to multi-channel scenarios.
Parameters
- connection
- RtcConnection object. See RtcConnection.
- soundId
- Sound effect ID.
- filePath
- Absolute path of the local file or URL of the online file. Supported audio formats include mp3, mp4, m4a, aac, 3gp, mkv, and wav.
- loopCount
- Number of times the sound effect is played:
-1: Loops indefinitely until stopEffect or stopAllEffects is called.0: Plays once.1: Plays twice.
- pitch
- Pitch of the sound effect. The range is 0.5 to 2.0. The default value is 1.0 (original pitch). The smaller the value, the lower the pitch.
- pan
- Spatial position of the sound effect. The range is -1.0 to 1.0:
-1.0: The sound effect comes from the user's left.0.0: The sound effect comes from the front.1.0: The sound effect comes from the user's right.
- gain
- Volume of the sound effect. The range is 0 to 100. The default value is 100 (original volume). The smaller the value, the lower the volume.
- publish
- Whether to publish the sound effect in the channel:
- true: Publishes the sound effect in the channel.
- false: (Default) Does not publish the sound effect in the channel.
- startPos
- Start position (in milliseconds) for playing the sound effect file.
Return Values
- 0: Success.
- < 0: Failure.
preloadEffectEx
Preloads the specified sound effect into the channel.
abstract preloadEffectEx(
connection: RtcConnection,
soundId: number,
filePath: string,
startPos?: number
): number;
- Since
- Available since v4.6.2.
Each time you call this method, only one sound effect file can be preloaded into memory. To preload multiple sound effects, call this method multiple times. After preloading, you can call playEffect to play the preloaded sound effect, or playAllEffects to play all preloaded sound effects.
- To ensure smooth user experience, the size of the sound effect file should not exceed the limit.
- Agora recommends calling this method before joining a channel.
- If you call preloadEffectEx before playEffectEx, the file resource will not be closed after playEffectEx is executed. The next call to playEffectEx will start playback from the beginning.
- If you do not call preloadEffectEx before playEffectEx, the file resource will be destroyed after playEffectEx is executed. The next call to playEffectEx will attempt to reopen the file and play from the beginning.
Scenario
This method applies to multi-channel scenarios.
Parameters
- connection
- Connection information. See RtcConnection.
- soundId
- Sound effect ID.
- filePath
- Absolute path of the local file or URL of the online file. Supported audio formats include: mp3, mp4, m4a, aac, 3gp, mkv, and wav.
- startPos
- Start position (in milliseconds) for playing the sound effect file.
Return Values
- 0: Success.
- < 0: Failure.
removeVideoWatermarkEx
Removes the specified watermark image from the local or remote video stream.
abstract removeVideoWatermarkEx(
id: string,
connection: RtcConnection
): number;
- Since
- Available since v4.6.2.
Scenario
This method applies to multi-channel scenarios.
Parameters
- id
- Watermark ID.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure.
resumeAllChannelMediaRelayEx
Resumes media stream forwarding to all destination channels.
abstract resumeAllChannelMediaRelayEx(connection: RtcConnection): number;
After calling the pauseAllChannelMediaRelayEx method, if you need to resume forwarding media streams to all destination channels, you can call this method.
Parameters
- connection
- Connection information. See RtcConnection.
Return Values
- 0: The method call was successful.
- < 0: The method call failed. See Error Codes for details and resolution suggestions.
- -5: This method call was rejected. There is no paused cross-channel media stream forwarding.
sendCustomReportMessageEx
Custom data reporting and analysis service.
abstract sendCustomReportMessageEx(
id: string,
category: string,
event: string,
label: string,
value: number,
connection: RtcConnection
): number;
Agora provides custom data reporting and analysis services. This service is currently in a free beta phase. During the beta, you can report up to 10 data entries within 6 seconds. Each custom data entry must not exceed 256 bytes, and each string must not exceed 100 bytes. To try this service, [contact sales](mailto:support@agora.io) to enable it and agree on the custom data format.
sendStreamMessageEx
Sends a data stream.
abstract sendStreamMessageEx(streamId: number, data: Uint8Array, length: number, connection: RtcConnection): number;
- Each client in the channel can have up to 5 data channels simultaneously, and the total sending bitrate shared by all data channels is limited to 30 KB/s.
- Each data channel can send up to 60 packets per second, with each packet up to 1 KB in size.
- This method must be called after joinChannelEx.
- Make sure to call createDataStreamEx to create the data channel before calling this method.
Parameters
- streamId
- Data stream ID. You can get it via createDataStreamEx.
- data
- The data to be sent.
- length
- Length of the data.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
setDualStreamModeEx
Sets the dual-stream mode on the sender side.
abstract setDualStreamModeEx(
mode: SimulcastStreamMode,
streamConfig: SimulcastStreamConfig,
connection: RtcConnection
): number;
AutoSimulcastStream) on the sender side. That is, the sender does not proactively send the low stream. A receiver with host role can call setRemoteVideoStreamTypeEx to request the low stream. Once the sender receives the request, it starts sending the low stream automatically.
- If you want to change this behavior, you can call this method and set
modetoDisableSimulcastStream(never send low stream) orEnableSimulcastStream(always send low stream). - If you want to revert to the default behavior after making changes, call this method again and set
modetoAutoSimulcastStream.
- Calling this method and setting
modetoDisableSimulcastStreamhas the same effect asenableDualStreamModeEx(false). - Calling this method and setting
modetoEnableSimulcastStreamhas the same effect asenableDualStreamModeEx(true). - Both methods can be called before or after joining a channel. If both are used, the settings of the method called later take precedence.
Parameters
- mode
- Mode for sending video streams. See SimulcastStreamMode.
- streamConfig
- Configuration for the low video stream. See SimulcastStreamConfig.
Note: When
modeis set toDisableSimulcastStream, settingstreamConfighas no effect. - connection
- Connection information. See RtcConnection.
Return Values
- 0: The method call succeeds.
- < 0: The method call fails. See Error Codes for details and resolution suggestions.
setRemoteRenderModeEx
Sets the display mode of the remote view.
abstract setRemoteRenderModeEx(
uid: number,
renderMode: RenderModeType,
mirrorMode: VideoMirrorModeType,
connection: RtcConnection
): number;
After initializing the remote user view, you can call this method to update the rendering and mirror mode of the remote user view as displayed locally. This method only affects the video seen by the local user.
Parameters
- uid
- Remote user ID.
- renderMode
- Display mode of the remote view. See RenderModeType.
- mirrorMode
- The mirror mode of the remote user view. See VideoMirrorModeType.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
setRemoteVideoStreamTypeEx
Sets the video stream type to subscribe to.
abstract setRemoteVideoStreamTypeEx(
uid: number,
streamType: VideoStreamType,
connection: RtcConnection
): number;
- By default, the SDK enables the adaptive low stream mode (
AutoSimulcastStream) on the sender side. That is, the sender only sends the high stream. Only receivers with host role can call this method to request the low stream. Once the sender receives the request, it starts sending the low stream automatically. At this point, all users in the channel can call this method to switch to low stream subscription mode. - If the sender calls setDualStreamMode and sets
modetoDisableSimulcastStream(never send low stream), then this method has no effect. - If the sender calls setDualStreamMode and sets
modetoEnableSimulcastStream(always send low stream), then both host and audience receivers can call this method to switch to low stream subscription mode.
mode to DisableSimulcastStream (never send low stream), then this method has no effect. You need to call setDualStreamModeEx again on the sender side to change the setting.Parameters
- uid
- User ID.
- streamType
- Video stream type: VideoStreamType.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: The method call succeeds.
- < 0: The method call fails. See Error Codes for details and resolution suggestions.
setRemoteVideoSubscriptionOptionsEx
Sets the subscription options for the remote video stream.
abstract setRemoteVideoSubscriptionOptionsEx(
uid: number,
options: VideoSubscriptionOptions,
connection: RtcConnection
): number;
When the remote user sends dual streams, you can call this method to set the subscription options for the remote video stream.
Parameters
- uid
- Remote user ID.
- options
- Subscription settings for the video stream. See VideoSubscriptionOptions.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
setRemoteVoicePositionEx
Sets the 2D position of a remote user's voice, that is, the horizontal position.
abstract setRemoteVoicePositionEx(
uid: number,
pan: number,
gain: number,
connection: RtcConnection
): number;
Sets the spatial position and volume of a remote user's voice to help the local user determine the direction of the sound. By calling this method to set the position where the remote user's voice appears, the difference in sound between the left and right channels creates a sense of direction, allowing the user to determine the remote user's real-time position. In multiplayer online games, such as battle royale games, this method can effectively enhance the directional perception of game characters and simulate realistic scenarios.
- For the best listening experience, it is recommended that users wear wired headphones.
- This method must be called after joining the channel.
Parameters
- uid
- The ID of the remote user.
- pan
- Sets the spatial position of the remote user's voice. The range is [-1.0, 1.0]:
- -1.0: The sound appears on the left.
- (Default) 0.0: The sound appears in the center.
- 1.0: The sound appears on the right.
- gain
- Sets the volume of the remote user's voice. The range is [0.0, 100.0], and the default is 100.0, which represents the user's original volume. The smaller the value, the lower the volume.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
setSubscribeAudioAllowlistEx
Sets the audio subscription allowlist.
abstract setSubscribeAudioAllowlistEx(
uidList: number[],
uidNumber: number,
connection: RtcConnection
): number;
You can call this method to specify the audio streams you want to subscribe to.
- This method can be called before or after joining a channel.
- The audio subscription allowlist is not affected by muteRemoteAudioStream, muteAllRemoteAudioStreams, or
autoSubscribeAudioin ChannelMediaOptions. - After setting the allowlist, if you leave and rejoin the channel, the allowlist remains effective.
- If a user is in both the audio subscription blocklist and allowlist, only the blocklist takes effect.
Parameters
- uidList
- List of user IDs in the audio subscription allowlist.
If you want to subscribe to the audio stream of a specific user, add that user's ID to this list. If you want to remove a user from the allowlist, call setSubscribeAudioAllowlist again with an updated list that excludes the user's
uid. - uidNumber
- Number of users in the allowlist.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
setSubscribeAudioBlocklistEx
Sets the audio subscription blocklist.
abstract setSubscribeAudioBlocklistEx(
uidList: number[],
uidNumber: number,
connection: RtcConnection
): number;
You can call this method to specify the audio streams you do not want to subscribe to.
- This method can be called before or after joining a channel.
- The audio subscription blocklist is not affected by muteRemoteAudioStream, muteAllRemoteAudioStreams, or
autoSubscribeAudioin ChannelMediaOptions. - After setting the blocklist, if you leave and rejoin the channel, the blocklist remains effective.
- If a user is in both the audio subscription blocklist and allowlist, only the blocklist takes effect.
Parameters
- uidList
- List of user IDs in the audio subscription blocklist.
If you want to block the audio stream of a specific user, add that user's ID to this list. If you want to remove a user from the blocklist, call setSubscribeAudioBlocklist again with an updated list that excludes the user's
uid. - uidNumber
- Number of users in the blocklist.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
setSubscribeVideoAllowlistEx
Sets the video subscription allowlist.
abstract setSubscribeVideoAllowlistEx(
uidList: number[],
uidNumber: number,
connection: RtcConnection
): number;
You can call this method to specify the video streams you want to subscribe to.
- You can call this method either before or after joining a channel.
- The video subscription allowlist is not affected by muteRemoteVideoStream, muteAllRemoteVideoStreams, or
autoSubscribeVideoin ChannelMediaOptions. - After setting the allowlist, it remains effective even if you leave and rejoin the channel.
- If a user is in both the audio subscription allowlist and blocklist, only the blocklist takes effect.
Parameters
- uidList
- The user ID list for the video subscription allowlist.
If you want to subscribe to the video stream of a specific user, add that user's ID to this list. If you want to remove a user from the allowlist, you need to call the setSubscribeVideoAllowlist method again to update the list so that it no longer includes the
uidof the user you want to remove. - uidNumber
- The number of users in the allowlist.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
setSubscribeVideoBlocklistEx
Sets the video subscription blocklist.
abstract setSubscribeVideoBlocklistEx(
uidList: number[],
uidNumber: number,
connection: RtcConnection
): number;
You can call this method to specify the video streams you do not want to subscribe to.
- You can call this method either before or after joining a channel.
- The video subscription blocklist is not affected by muteRemoteVideoStream, muteAllRemoteVideoStreams, or
autoSubscribeVideoin ChannelMediaOptions. - After setting the blocklist, it remains effective even if you leave and rejoin the channel.
- If a user is in both the audio subscription allowlist and blocklist, only the blocklist takes effect.
Parameters
- uidList
- The user ID list for the video subscription blocklist.
If you want to block the video stream from a specific user, add that user's ID to this list. If you want to remove a user from the blocklist, you need to call the setSubscribeVideoBlocklist method again to update the list so that it no longer includes the
uidof the user you want to remove. - uidNumber
- The number of users in the blocklist.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
setVideoEncoderConfigurationEx
Sets the video encoding configuration.
abstract setVideoEncoderConfigurationEx(
config: VideoEncoderConfiguration,
connection: RtcConnection
): number;
Sets the encoding configuration for the local video. Each video encoding configuration corresponds to a set of video parameters, including resolution, frame rate, and bitrate.
config parameter of this method specifies the maximum values achievable under ideal network conditions. If the network condition is poor, the video engine may not use this config to render the local video and will automatically downgrade to a suitable video parameter configuration.Timing
This method must be called after joinChannelEx.
Parameters
- config
- Video encoding configuration. See VideoEncoderConfiguration.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: The method call succeeds.
- < 0: The method call fails. See Error Codes for details and troubleshooting tips.
setupRemoteVideoEx
Initializes the remote user view.
abstract setupRemoteVideoEx(
canvas: VideoCanvas,
connection: RtcConnection
): number;
This method binds a remote user to a display view and sets the rendering and mirror mode for the remote user's view as seen locally. It only affects the video display seen by the local user.
You need to specify the remote user's ID in VideoCanvas when calling this method. It is generally recommended to set this before joining the channel.
If the remote user's uid is not available before joining the channel, you can call this method upon receiving the onUserJoined callback. If video recording is enabled, the recording service joins the channel as a dummy client. Other clients will also receive its onUserJoined event, but the app should not bind a view to it (as it does not send video streams).
To unbind a view from a remote user, call this method and set view to null.
After leaving the channel, the SDK clears the binding between the remote user and the view.
- You must call this method after joinChannelEx.
- In Flutter, you do not need to call this method manually. Use
AgoraVideoViewto render local and remote views. - If you want to update the rendering or mirror mode of the remote user's view during a call, use the setRemoteRenderModeEx method.
Parameters
- canvas
- Video canvas information. See VideoCanvas.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
startMediaRenderingTracingEx
Starts video frame rendering tracing.
abstract startMediaRenderingTracingEx(connection: RtcConnection): number;
After this method is successfully called, the SDK uses the time of this call as the starting point and reports video frame rendering information via the onVideoRenderingTracingResult callback.
- If you do not call this method, the SDK starts tracing video rendering events automatically using the time of the joinChannel call as the starting point. You can call this method at an appropriate time based on your business scenario to customize the tracing.
- After leaving the current channel, the SDK automatically resets the time to the next joinChannel call.
Scenario
Agora recommends using this method together with UI elements in your app (such as buttons or sliders) to measure the time to first frame rendering from the user's perspective. For example, call this method when the user clicks the Join Channel button, and then use the onVideoRenderingTracingResult callback to obtain the duration of each stage in the video rendering process, allowing you to optimize each stage accordingly.
Parameters
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
startOrUpdateChannelMediaRelayEx
Starts or updates the media stream relay across channels.
abstract startOrUpdateChannelMediaRelayEx(
configuration: ChannelMediaRelayConfiguration,
connection: RtcConnection
): number;
- If the onChannelMediaRelayStateChanged callback reports
RelayStateRunning(2) andRelayOk(0), it means the SDK has started relaying media streams between the source and destination channels. - If the callback reports
RelayStateFailure(3), it indicates an error occurred during the media stream relay.
- Call this method after successfully joining a channel.
- In a live streaming scenario, only users with the broadcaster role can call this method.
- To enable the media stream relay across channels, contact technical support.
- This feature does not support string-type UIDs.
Parameters
- configuration
- Configuration for media stream relay across channels. See ChannelMediaRelayConfiguration.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and troubleshooting.
- -1: General error (not categorized).
- -2: Invalid parameter.
- -8: Internal state error, possibly due to the user not being a broadcaster.
startRtmpStreamWithTranscodingEx
Starts pushing streams to a CDN and sets the transcoding configuration.
abstract startRtmpStreamWithTranscodingEx(
url: string,
transcoding: LiveTranscoding,
connection: RtcConnection
): number;
Agora recommends using the more comprehensive server-side streaming feature. See Implement server-side CDN streaming. Call this method to push live audio and video streams to the specified CDN streaming URL and set the transcoding configuration. This method can only push media streams to one URL at a time. To push to multiple URLs, call this method multiple times. After calling this method, the SDK triggers the onRtmpStreamingStateChanged callback locally to report the streaming status.
- Make sure the CDN streaming service is enabled.
- Call this method after joining a channel.
- Only hosts in a live streaming scenario can call this method.
- If the stream push fails and you want to retry, you must call stopRtmpStreamEx before calling this method again. Otherwise, the SDK returns the same error code as the previous failure.
Parameters
- url
- The CDN streaming URL. Must be in RTMP or RTMPS format. The character length must not exceed 1024 bytes. Special characters such as Chinese characters are not supported.
- transcoding
- The transcoding configuration for the CDN stream. See LiveTranscoding.
- connection
- The connection information. See RtcConnection.
Return Values
- 0: The method call succeeds.
- < 0: The method call fails. See Error Codes for details and resolution suggestions.
- -2: The URL or transcoding parameter is invalid. Check your URL or parameter settings.
- -7: The SDK is not initialized before calling this method.
- -19: The CDN streaming URL is already in use. Use a different URL.
startRtmpStreamWithoutTranscodingEx
Starts pushing media streams without transcoding.
abstract startRtmpStreamWithoutTranscodingEx(
url: string,
connection: RtcConnection
): number;
Agora recommends using the more advanced server-side streaming feature. See Implement Server-side Streaming. Call this method to push live audio and video streams to a specified streaming URL. This method supports pushing to only one URL at a time. To push to multiple URLs, call this method multiple times. After calling this method, the SDK triggers the onRtmpStreamingStateChanged callback locally to report the streaming status.
- Call this method after joining a channel.
- Only broadcasters in a live streaming scenario can call this method.
- If the streaming fails and you want to retry, you must call stopRtmpStream before calling this method again. Otherwise, the SDK will return the same error code as the previous failure.
Parameters
- url
- The streaming URL. Must be in RTMP or RTMPS format. The maximum length is 1024 bytes. Special characters such as Chinese characters are not supported.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and troubleshooting.
- -2: The URL or transcoding parameter is incorrect. Check your URL or parameter settings.
- -7: The SDK is not initialized before calling this method.
- -19: The streaming URL is already in use. Use a different streaming URL.
stopChannelMediaRelayEx
Stops the media stream relay across channels. Once stopped, the broadcaster leaves all destination channels.
abstract stopChannelMediaRelayEx(connection: RtcConnection): number;
After a successful call, the SDK triggers the onChannelMediaRelayStateChanged callback. If it reports RelayStateIdle (0) and RelayOk (0), it indicates that the media stream relay has stopped.
RelayErrorServerNoResponse (2) or RelayErrorServerConnectionLost (8). You can call the leaveChannel method to leave the channel, and the media stream relay will stop automatically.Parameters
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and troubleshooting.
- -5: The method call is rejected. There is no ongoing media stream relay.
stopRtmpStreamEx
Stops pushing streams to a CDN.
abstract stopRtmpStreamEx(url: string, connection: RtcConnection): number;
Agora recommends using the more comprehensive server-side streaming feature. See Implement server-side CDN streaming. Call this method to stop the live stream on the specified CDN streaming URL. This method can only stop one URL at a time. To stop multiple URLs, call this method multiple times. After calling this method, the SDK triggers the onRtmpStreamingStateChanged callback locally to report the streaming status.
Parameters
- url
- The CDN streaming URL. Must be in RTMP or RTMPS format. The character length must not exceed 1024 bytes. Special characters such as Chinese characters are not supported.
- connection
- The connection information. See RtcConnection.
Return Values
- 0: The method call succeeds.
- < 0: The method call fails. See Error Codes for details and resolution suggestions.
takeSnapshotEx
Takes a video snapshot using the connection ID.
abstract takeSnapshotEx(
connection: RtcConnection,
uid: number,
filePath: string
): number;
This method captures a snapshot of the specified user's video stream, generates a JPG image, and saves it to the specified path.
- This method is asynchronous. When the call returns, the SDK has not actually taken the snapshot.
- When used to capture a local video snapshot, it captures the video stream specified in ChannelMediaOptions.
- If the video has been pre-processed, such as with watermarking or beautification, the snapshot will include the effects of the pre-processing.
Timing
This method must be called after joinChannelEx.
Parameters
- connection
- Connection information. See RtcConnection.
- uid
- User ID. Set to 0 to capture a snapshot of the local user's video.
- filePath
-
Note: Make sure the directory exists and is writable.The local path to save the snapshot, including file name and format. For example:
- Windows:
C:\Users\<user_name>\AppData\Local\Agora\<process_name>\example.jpg - macOS:
~/Library/Logs/example.jpg
- Windows:
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and troubleshooting.
takeSnapshotWithConfigEx
Takes a video snapshot at a specified observation point using the connection ID.
abstract takeSnapshotWithConfigEx(
connection: RtcConnection,
uid: number,
config: SnapshotConfig
): number;
This method captures a snapshot of the specified user's video stream, generates a JPG image, and saves it to the specified path.
- This method is asynchronous. When the call returns, the SDK has not actually taken the snapshot.
- When used to capture a local video snapshot, it captures the video stream specified in ChannelMediaOptions.
- If the video has been pre-processed, such as with watermarking or beautification, the snapshot will include the effects of the pre-processing.
Timing
This method must be called after joinChannelEx.
Parameters
- connection
- Connection information. See RtcConnection.
- uid
- User ID. Set to 0 to capture a snapshot of the local user's video.
- config
- Snapshot settings. See SnapshotConfig.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and troubleshooting.
updateChannelMediaOptionsEx
Updates channel media options after joining the channel.
abstract updateChannelMediaOptionsEx(
options: ChannelMediaOptions,
connection: RtcConnection
): number;
Parameters
- options
- Channel media options. See ChannelMediaOptions.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: The method call succeeds.
- < 0: The method call fails. See Error Codes for details and troubleshooting.
- -2: Invalid ChannelMediaOptions values. For example, using an invalid token or setting an invalid user role. You must provide valid parameters.
- -7: The IRtcEngine object is not initialized. You must initialize the IRtcEngine object before calling this method.
- -8: The internal state of the IRtcEngine object is incorrect. This may happen if the user is not in a channel. Use the onConnectionStateChanged callback to determine whether the user is in a channel. If you receive
ConnectionStateDisconnected(1) orConnectionStateFailed(5), the user is not in a channel. You must call joinChannel before using this method.
updateRtmpTranscodingEx
Updates the CDN transcoding configuration.
abstract updateRtmpTranscodingEx(
transcoding: LiveTranscoding,
connection: RtcConnection
): number;
Agora recommends using the more comprehensive server-side streaming feature. See Implement server-side CDN streaming. After enabling transcoding streaming, you can dynamically update the transcoding configuration based on your scenario. After the configuration is updated, the SDK triggers the onTranscodingUpdated callback.
Parameters
- transcoding
- The transcoding configuration for the CDN stream. See LiveTranscoding.
- connection
- The connection information. See RtcConnection.
Return Values
- 0: The method call succeeds.
- < 0: The method call fails. See Error Codes for details and resolution suggestions.