IRtcEngineEx
Interface class that provides multi-channel methods.
Inherits from IRtcEngine.
AddVideoWatermarkEx [1/2]
Adds a local video watermark.
public abstract int AddVideoWatermarkEx(string watermarkUrl, WatermarkOptions options, RtcConnection connection);
- Deprecated
- Deprecated: This method is deprecated. Use
addVideoWatermarkEx [2/2]instead.
- If the video orientation (ORIENTATION_MODE) is fixed to landscape or adaptive landscape, landscape coordinates are used.
- If the video orientation is fixed to portrait or adaptive portrait, portrait coordinates are used.
- When setting watermark coordinates, the image area must not exceed the video dimensions set in SetVideoEncoderConfigurationEx, otherwise the excess will be cropped.
- You must call this method after calling EnableVideo.
- The watermark image must be in PNG format. This method supports all PNG pixel formats: RGBA, RGB, Palette, Gray, and Alpha_gray.
- If the size of the PNG image differs from the size set in this method, the SDK will scale or crop the image to match the settings.
- If you have already started local video preview using StartPreview [2/2], the
visibleInPreviewparameter in this method can control whether the watermark is visible during preview. - If local video is set to mirror mode, the local watermark will also be mirrored. To avoid mirrored watermark for local users, it is recommended not to use both mirror and watermark features together. Implement watermark at the application layer instead.
Parameters
- watermarkUrl
- The local path of the watermark image to be added. This method supports adding watermark images from absolute/relative local paths.
- options
- Settings for the watermark image. See WatermarkOptions.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
AdjustUserPlaybackSignalVolumeEx
Adjusts the playback volume of a specified remote user locally.
public abstract int AdjustUserPlaybackSignalVolumeEx(uint uid, int volume, RtcConnection connection);
You can call this method during a call to adjust the playback volume of a specified remote user locally. To adjust the volume for multiple users, call this method multiple times.
Timing
Call this method after JoinChannelEx.
Parameters
- uid
- Remote user ID.
- volume
- Volume, ranging from [0,400].
- 0: Mute.
- 100: (Default) Original volume.
- 400: Four times the original volume, with built-in 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.
public abstract int ClearVideoWatermarkEx(RtcConnection connection);
Parameters
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
CreateAgoraRtcEngineEx
Creates an IRtcEngineEx object.
public static IRtcEngineEx CreateAgoraRtcEngineEx()
{
return (IRtcEngineEx)(instance ?? (instance = new RtcEngine(IntPtr.Zero)));
}
Currently, RTC v4.x SDK supports creating only one IRtcEngineEx object per App.
Return Values
IRtcEngineEx object.
CreateDataStreamEx [1/2]
Creates a data stream.
public abstract int CreateDataStreamEx(ref int streamId, bool reliable, bool ordered, RtcConnection connection);
- Deprecated
- Deprecated: This method is deprecated. Use CreateDataStreamEx [2/2] instead.
You can call this method to create a data stream and improve the reliability and ordering of data transmission.
Timing
This method must be called after JoinChannelEx.
Parameters
- streamId
- Output parameter. The ID of the created data stream.
- reliable
-
Note: Make sure to setWhether to guarantee data reliability, i.e., whether the receiver must receive the data within 5 seconds after it is sent:
reliableandorderedboth to true or both to false.- true: The receiver will receive the data sent by the sender within 5 seconds, otherwise the OnStreamMessageError callback is triggered and the corresponding error message is returned.
- false: The receiver is not guaranteed to receive the data, and no error is reported even if the data is lost.
- ordered
- Whether to guarantee data ordering, i.e., whether the receiver must receive the data in the order it was sent:
- true: The receiver receives the data packets in the order they were sent by the sender.
- false: The receiver is not guaranteed to receive the data packets in order.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Data stream created successfully.
- < 0: Method call failed. See Error Codes for details and resolution suggestions.
CreateDataStreamEx [2/2]
Creates a data stream.
public abstract int CreateDataStreamEx(ref int streamId, DataStreamConfig config, RtcConnection connection);
Compared with CreateDataStreamEx [1/2], this method does not guarantee the reliability of data transmission. The receiver discards packets that are received more than 5 seconds after being sent.
Timing
This method must be called after JoinChannelEx.
Parameters
- streamId
- Output parameter. The ID of the created data stream.
- config
- Data stream configuration. See DataStreamConfig.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Data stream created successfully.
- < 0: Method call failed. See Error Codes for details and resolution suggestions.
EnableAudioVolumeIndicationEx
Enables audio volume indication.
public abstract int EnableAudioVolumeIndicationEx(int interval, int smooth, bool reportVad, RtcConnection connection);
This method allows the SDK to periodically report volume information of the local user and up to three remote users with the highest instantaneous volume to the app.
Timing
You must call this method after JoinChannelEx.
Parameters
- interval
- Sets the time interval of the volume indication:
- ≤ 0: Disables the volume indication.
- > 0: The interval (ms) at which the volume indication is returned. We recommend setting it to greater than 100 ms. The minimum value is 10 ms. If the value is less than 10 ms, you may not receive the OnAudioVolumeIndication callback.
- smooth
- The smoothing factor that sets the sensitivity of the volume indication. The value range is [0,10], and the recommended value is 3. The greater the value, the more sensitive the indication; the smaller the value, the smoother the indication.
- reportVad
-
- true: Enables the local voice activity detection (VAD). After it is enabled, the
vadparameter in the OnAudioVolumeIndication callback reports whether voice is detected locally. - false: (Default) Disables the local VAD. Except for scenarios where the engine automatically performs local VAD, the
vadparameter in the OnAudioVolumeIndication callback does not report whether voice is detected locally.
- true: Enables the local voice activity detection (VAD). After it is enabled, the
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and troubleshooting.
EnableContentInspectEx
Enables/disables local snapshot upload.
public abstract int EnableContentInspectEx(bool enabled, ContentInspectConfig config, RtcConnection connection);
This method allows you to capture and upload snapshots from multiple video streams. After enabling local snapshot upload, the SDK captures and uploads snapshots of the local user's video based on the module type and frequency you set in ContentInspectConfig. Once the snapshots are captured, Agora's server sends a callback notification to your server via an HTTPS request and uploads all snapshots to your designated third-party cloud storage.
Timing
You can call this method before or after joining a channel.
Parameters
- enabled
- Sets 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.
public abstract int EnableDualStreamModeEx(bool enabled, SimulcastStreamConfig streamConfig, RtcConnection connection);
- 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: When
modeis set toDISABLE_SIMULCAST_STREAM, 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.
EnableEncryptionEx
Enables or disables built-in encryption.
public abstract int EnableEncryptionEx(RtcConnection connection, bool enabled, EncryptionConfig config);
After a user leaves the channel, the SDK automatically disables encryption. To re-enable encryption, you need to call this method before the user rejoins the channel.
- All users in the same channel must use the same encryption mode and key when calling this method.
- When 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 the 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.
public abstract int EnableLoopbackRecordingEx(RtcConnection connection, bool enabled, string deviceName);
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 end.
- This method is only applicable to macOS and Windows platforms.
- The default sound card on macOS does not support recording. If you need this feature, please enable a virtual sound card and set
deviceNameto the device name of the virtual sound card. Agora recommends using the self-developed virtual sound card AgoraALD for recording. - Currently, only one loopback recording is supported.
Parameters
- connection
- Connection information. See RtcConnection.
- enabled
- Whether to enable loopback recording:
- true: Enable loopback recording.
- false: (Default) Do not enable loopback recording.
- deviceName
-
- 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 for recording.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
GetCallIdEx
Gets the call ID using the connection ID.
public abstract int GetCallIdEx(ref string callId, RtcConnection connection);
Each time the client joins a channel, it generates a corresponding callId to identify the current call. You can call this method to get the callId parameter, and then pass it in when calling methods such as Rate and Complain.
Timing
You need to call this method after joining a channel.
Parameters
- callId
- An output parameter. The current call ID.
- connection
- Connection information. See RtcConnection.
GetConnectionStateEx
Gets the current network connection state.
public abstract CONNECTION_STATE_TYPE GetConnectionStateEx(RtcConnection connection);
Timing
Can be called before or after joining a channel.
Parameters
- connection
- Connection information. See RtcConnection.
Return Values
The current network connection state. See CONNECTION_STATE_TYPE.
JoinChannelEx
Joins a channel.
public abstract int JoinChannelEx(string token, RtcConnection connection, ChannelMediaOptions options);
Call this method to join multiple channels simultaneously. If you want to join the same channel on different devices, make sure each device uses a different user ID.
Scenario
This method is suitable for multi-channel scenarios.
Timing
This method must be called after Initialize.
In multi-camera capture scenarios, you need to call StartPreview [2/2] after this method and set sourceType to VIDEO_SOURCE_CAMERA_SECONDARY to ensure the second camera captures properly.
Parameters
- token
- A dynamic key generated on your server for authentication. See Token Authentication.
Note:
- (Recommended) If your project has enabled secure mode (i.e., using APP ID + Token for authentication), this parameter is required.
- If your project is in debug mode only (i.e., using APP ID for authentication), you can join the channel without providing a Token. The user will automatically leave the channel after 24 hours.
- 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 your server each time you join a new channel. See Using Wildcard Token.
- connection
- Connection information. See RtcConnection.
- options
- Channel media configuration options. See ChannelMediaOptions.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and troubleshooting advice.
- -2: Invalid parameters. For example, using an invalid Token,
uidnot set as an integer, or invalid values in ChannelMediaOptions. You need to provide valid parameters and rejoin the channel. - -3: IRtcEngine initialization failed. You need to reinitialize the IRtcEngine object.
- -7: IRtcEngine is not initialized. You must successfully initialize IRtcEngine before calling this method.
- -8: Internal state error in IRtcEngine. Possible cause: calling this method to join a channel after StartEchoTest without calling StopEchoTest. You need to call StopEchoTest before this method.
- -17: This method call was rejected. Possible cause: the user is already in the channel. Use the OnConnectionStateChanged callback to check the connection state. Do not call this method again unless you receive
CONNECTION_STATE_DISCONNECTED(1). - -102: Invalid channel name. You need to provide a valid
channelIdand rejoin the channel. - -121: Invalid user ID. You need to provide a valid
uidand rejoin the channel.
- -2: Invalid parameters. For example, using an invalid Token,
LeaveChannelEx [1/2]
Leaves the channel.
public abstract int LeaveChannelEx(RtcConnection connection);
After calling this method, the SDK stops 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 or LeaveChannelEx [2/2] to end the call, otherwise you cannot start a new one.
- This method is asynchronous. The return does not mean you have actually left the channel.
- If you call LeaveChannel [1/2] or LeaveChannel [2/2], you will leave both the channels joined by JoinChannel [1/2] or JoinChannel [2/2] and JoinChannelEx.
Scenario
This method applies to multi-channel scenarios.
Timing
Call this method after JoinChannelEx.
Parameters
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and suggestions.
LeaveChannelEx [2/2]
Sets channel options and leaves the channel.
public abstract int LeaveChannelEx(RtcConnection connection, LeaveChannelOptions options);
After calling this method, the SDK stops 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 or LeaveChannelEx [1/2] to end the call, otherwise you cannot start a new one.
- This method is asynchronous. The return does not mean you have actually left the channel.
- If you call LeaveChannel [1/2] or LeaveChannel [2/2], you will leave both the channels joined by JoinChannel [1/2] or JoinChannel [2/2] and JoinChannelEx.
Scenario
This method applies to multi-channel scenarios.
Timing
Call this method 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: Success.
- < 0: Failure. See Error Codes for details and suggestions.
MuteAllRemoteAudioStreamsEx
Stops or resumes subscribing to all remote users' audio streams.
public abstract int MuteAllRemoteAudioStreamsEx(bool mute, RtcConnection connection);
After successfully calling this method, the local user stops or resumes subscribing to remote users' audio streams, including those who join the channel after this method is called.
- This method must be called after joining a channel.
- To set the default behavior to not subscribe to remote users' audio streams before joining a channel, set
autoSubscribeAudioto false when calling JoinChannel [2/2].
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.
public abstract int MuteAllRemoteVideoStreamsEx(bool mute, RtcConnection connection);
After this method is successfully called, the local user stops or resumes subscribing to all remote users' video streams, including those 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.
public abstract int MuteLocalAudioStreamEx(bool mute, RtcConnection connection);
After this method is successfully called, remote users trigger 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.
public abstract int MuteLocalVideoStreamEx(bool mute, RtcConnection connection);
After this method is successfully called, remote users trigger the OnUserMuteVideo callback.
- This method does not affect the video capture status 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 resolution suggestions.
MuteRemoteAudioStreamEx
Stops or resumes receiving the specified audio stream.
public abstract int MuteRemoteAudioStreamEx(uint uid, bool mute, RtcConnection connection);
This method stops or resumes receiving the audio stream of a specified remote user. It can be called before or after joining the channel. The setting becomes invalid 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 resolution suggestions.
MuteRemoteVideoStreamEx
Stops or resumes receiving a specified video stream.
public abstract int MuteRemoteVideoStreamEx(uint uid, bool mute, RtcConnection connection);
This method stops or resumes receiving the video stream of a specified remote user. You can call this method before or after joining a channel. The setting becomes invalid after leaving the channel.
Parameters
- uid
- The ID of the remote user.
- mute
- Whether to stop receiving the video stream of 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 resolution suggestions.
PauseAllChannelMediaRelayEx
Pauses media stream forwarding to all destination channels.
public abstract int PauseAllChannelMediaRelayEx(RtcConnection connection);
After starting to forward media streams 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 succeeds.
- < 0: The method call fails. See Error Codes for details and resolution suggestions.
- -5: This method call was rejected. No cross-channel media stream forwarding is currently in progress.
PlayEffectEx
Plays the specified sound effect in the channel.
public abstract int PlayEffectEx(RtcConnection connection, int soundId, string filePath, int loopCount, double pitch, double pan, int gain, bool publish = false, int startPos = 0);
- Since
- Available since v4.6.2.
You can call this method to play the 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 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 at the same time.
- The sound effect ID and file path in this method must be the same as those in the
preloadEffectExmethod. - If you call
preloadEffectExbefore callingplayEffectEx, thenplayEffectExwill not release the file resource after execution. The next time you callplayEffectEx, it will start playing from the beginning. - If you do not call
preloadEffectExbefore callingplayEffectEx, thenplayEffectExwill destroy the resource after execution. The next time you callplayEffectEx, it will attempt to reopen the file and start playing from the beginning.
Scenario
This method applies to multi-channel scenarios.
Parameters
- connection
- RtcConnection object. See RtcConnection.
- soundId
- Sound effect ID.
- filePath
- The absolute path of the local file or the URL of the online file. Supported audio formats include mp3, mp4, m4a, aac, 3gp, mkv, and wav.
- loopCount
- Number of times the sound effect loops:
-1: Infinite loop untilstopEffectorstopAllEffectsis called.0: Play once.1: Play twice.
- pitch
- Pitch of the sound effect. The range is from 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 from -1.0 to 1.0:
-1.0: The sound effect comes from the left of the user.0.0: The sound effect comes from the front of the user.1.0: The sound effect comes from the right of the user.
- gain
- Volume of the sound effect. The range is from 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: Publish the sound effect in the channel.
- false: (Default) Do not publish the sound effect in the channel.
- startPos
- The start position for playing the sound effect file, in milliseconds.
Return Values
- 0: Success.
- < 0: Failure.
PreloadEffectEx
Preloads the specified sound effect into the channel.
public abstract int PreloadEffectEx(RtcConnection connection, int soundId, string filePath, int startPos = 0);
- 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 effect files, call this method multiple times. After preloading, you can call playEffect to play the preloaded sound effect, or call playAllEffects to play all preloaded sound effects.
- To ensure a smooth 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
preloadEffectExbefore callingplayEffectEx, thenplayEffectExwill not release the file resource after execution. The next time you callplayEffectEx, it will start playing from the beginning. - If you do not call
preloadEffectExbefore callingplayEffectEx, thenplayEffectExwill destroy the resource after execution. The next time you callplayEffectEx, it will attempt to reopen the file and start playing from the beginning.
Scenario
This method applies to multi-channel scenarios.
Parameters
- connection
- Connection information. See RtcConnection.
- soundId
- Sound effect ID.
- filePath
- The absolute path of the local file or the URL of the online file. Supported audio formats include: mp3, mp4, m4a, aac, 3gp, mkv, and wav.
- startPos
- The start position for playing the sound effect file, in milliseconds.
Return Values
- 0: Success.
- < 0: Failure.
RemoveVideoWatermarkEx
Removes the specified watermark image from the local or remote video stream.
public abstract int RemoveVideoWatermarkEx(string id, RtcConnection connection);
- 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.
public abstract int ResumeAllChannelMediaRelayEx(RtcConnection connection);
After calling the PauseAllChannelMediaRelayEx method, if you need to resume forwarding to all destination channels, you can call this method.
Parameters
- 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.
- -5: This method call was rejected. No cross-channel media stream forwarding is currently paused.
SendCustomReportMessageEx
Custom data reporting and analytics service.
public abstract int SendCustomReportMessageEx(string id, string category, string @event, string label, int value, RtcConnection connection);
Agora provides custom data reporting and analytics services. This service is currently in a free beta period. 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, please [contact sales](mailto:support@agora.io) to enable it and agree on the custom data format.
SendStreamMessageEx
Sends a data stream.
public abstract int SendStreamMessageEx(int streamId, byte[] data, uint length, RtcConnection connection);
- 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.
- If you need a more comprehensive, low-latency, high-concurrency, and scalable real-time messaging and state synchronization solution, we recommend using Real-time Messaging.
- You must call this method after JoinChannelEx.
- Make sure you have called CreateDataStreamEx [2/2] to create a data channel before calling this method.
Parameters
- streamId
- The data stream ID. You can get it through CreateDataStreamEx [2/2].
- data
- The data to be sent.
- length
- The 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.
public abstract int SetDualStreamModeEx(SIMULCAST_STREAM_MODE mode, SimulcastStreamConfig streamConfig, RtcConnection connection);
AUTO_SIMULCAST_STREAM) on the sender, meaning the sender does not actively send low-quality streams. Receivers with host identity can call SetRemoteVideoStreamTypeEx to request a low-quality stream, and the sender starts sending it upon receiving the request.
- If you want to change this behavior, call this method and set
modetoDISABLE_SIMULCAST_STREAM(never send low-quality stream) orENABLE_SIMULCAST_STREAM(always send low-quality stream). - If you want to revert to the default behavior after changing it, call this method again and set
modetoAUTO_SIMULCAST_STREAM.
- Calling this method and setting
modetoDISABLE_SIMULCAST_STREAMhas the same effect asEnableDualStreamModeEx(false). - Calling this method and setting
modetoENABLE_SIMULCAST_STREAMhas the same effect asEnableDualStreamModeEx(true). - Both methods can be called before or after joining a channel. If both are used, the settings from the later call take effect.
Parameters
- mode
- The mode for sending video streams. See SIMULCAST_STREAM_MODE.
- streamConfig
- Configuration of the low-quality video stream. See SimulcastStreamConfig.
Note: When
modeis set toDISABLE_SIMULCAST_STREAM, 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.
public abstract int SetRemoteRenderModeEx(uint uid, RENDER_MODE_TYPE renderMode, VIDEO_MIRROR_MODE_TYPE mirrorMode, RtcConnection connection);
After initializing the remote user view, you can call this method to update the rendering and mirror mode of the remote user view when displayed locally. This method only affects the video image seen by the local user.
Parameters
- uid
- Remote user ID.
- renderMode
- Display mode of the remote view. See RENDER_MODE_TYPE.
- mirrorMode
- Mirror mode of the remote user view. See VIDEO_MIRROR_MODE_TYPE.
- 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.
public abstract int SetRemoteVideoStreamTypeEx(uint uid, VIDEO_STREAM_TYPE streamType, RtcConnection connection);
- By default, the SDK enables small stream adaptive mode (
AUTO_SIMULCAST_STREAM) on the sender side, meaning the sender only sends the high-quality stream. Only receivers with host roles can call this method to request the low-quality stream. Once the sender receives the request, it starts sending the low-quality stream automatically. At this point, all users in the channel can call this method to switch to the low-quality stream subscription mode. - If the sender calls SetDualStreamMode [2/2] and sets
modetoDISABLE_SIMULCAST_STREAM(never send low-quality stream), this method has no effect. - If the sender calls SetDualStreamMode [2/2] and sets
modetoENABLE_SIMULCAST_STREAM(always send low-quality stream), both host and audience roles on the receiver side can call this method to switch to low-quality stream subscription mode.
mode to DISABLE_SIMULCAST_STREAM (never send low-quality stream), this method has no effect. You need to call SetDualStreamModeEx again on the sender side to change the configuration.Parameters
- uid
- User ID.
- streamType
- Video stream type: VIDEO_STREAM_TYPE.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
SetRemoteVideoSubscriptionOptionsEx
Sets the subscription options for the remote video stream.
public abstract int SetRemoteVideoSubscriptionOptionsEx(uint uid, VideoSubscriptionOptions options, RtcConnection connection);
When the remote user sends dual streams, you can call this method to set the subscription options for the remote video stream.
Parameters
- uid
- The 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, i.e., horizontal plane position.
public abstract int SetRemoteVoicePositionEx(uint uid, double pan, double gain, RtcConnection connection);
Sets the spatial position and volume of a remote user's voice to help the local user perceive directionality. By calling this API to set the position of a remote user's voice, the difference between the left and right audio channels creates a sense of direction, allowing the user to determine the real-time position of the remote user. In multiplayer online games, such as battle royale games, this method can effectively enhance the spatial awareness of game characters and simulate real scenarios.
- For the best listening experience, it is recommended that users wear wired headphones.
- This method must be called after joining a channel.
Parameters
- uid
- The ID of the remote user.
- pan
- Sets the spatial position of the remote user's voice. Range: [-1.0, 1.0]:
- -1.0: Voice appears on the left.
- (Default) 0.0: Voice appears in front.
- 1.0: Voice appears on the right.
- gain
- Sets the volume of the remote user's voice. Range: [0.0, 100.0], default is 100.0, indicating 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.
public abstract int GetCacheDir(out string path, int length);
You can call this method to specify the audio streams you want to subscribe to.
- You can call this method either before or after joining a channel.
- The audio subscription allowlist is not affected by MuteRemoteAudioStream, MuteAllRemoteAudioStreams, or the
autoSubscribeAudiosetting in 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 list of user IDs in the audio subscription allowlist.
If you want to subscribe to the audio stream of a specific user, add the user's ID to this list. To remove a user from the allowlist, you need to call SetSubscribeAudioAllowlist again with an updated list that does not include 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.
SetSubscribeAudioBlocklistEx
Sets the audio subscription blocklist.
public abstract int SetSubscribeAudioBlocklistEx(uint[] uidList, int uidNumber, RtcConnection connection);
You can call this method to specify the audio streams you do not want to subscribe to.
- You can call this method before or after joining a channel.
- The audio subscription blocklist is not affected by MuteRemoteAudioStream, MuteAllRemoteAudioStreams, or
autoSubscribeAudioin ChannelMediaOptions. - After setting the blocklist, it remains effective even if you leave and rejoin the channel.
- If a user appears in both the audio subscription blocklist and allowlist, only the blocklist takes effect.
Parameters
- uidList
- The list of user IDs in the audio subscription blocklist.
If you want to block the audio stream from a specific user, add the user's ID to this list. To remove a user from the blocklist, you need to call SetSubscribeAudioBlocklist again to update the list so that it no longer includes the user's
uid. - uidNumber
- The number of users in the audio subscription 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.
public abstract int SetSubscribeVideoAllowlistEx(uint[] uidList, int uidNumber, RtcConnection connection);
You can call this method to specify the video streams you want to subscribe to.
- You can call this method 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 appears in both the audio subscription blocklist and allowlist, only the blocklist takes effect.
Parameters
- uidList
- The list of user IDs in the video subscription allowlist.
If you want to subscribe only to the video stream from a specific user, add the user's ID to this list. To remove a user from the allowlist, you need to call SetSubscribeVideoAllowlist again to update the video subscription allowlist so that it no longer includes the user's
uid. - uidNumber
- The number of users in the video subscription 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.
public abstract int SetSubscribeVideoBlocklistEx(uint[] uidList, int uidNumber, RtcConnection connection);
You can call this method to specify the video streams you do not want to subscribe to.
- You can call this method 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 appears in both the audio subscription blocklist and allowlist, only the blocklist takes effect.
Parameters
- uidList
- The list of user IDs in the video subscription blocklist.
If you want to block the video stream from a specific user, add the user's ID to this list. To remove a user from the blocklist, you need to call SetSubscribeVideoBlocklist again to update the list so that it no longer includes the user's
uid. - uidNumber
- The number of users in the video subscription 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 properties.
public abstract int SetVideoEncoderConfigurationEx(VideoEncoderConfiguration config, RtcConnection connection);
Sets the encoding properties for the local video. Each video encoding configuration corresponds to a set of video-related 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 setting.Timing
This method must be called after JoinChannelEx.
Parameters
- config
- Video encoding parameter configuration. See VideoEncoderConfiguration.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Method call succeeded.
- < 0: Method call failed. See Error Codes for details and resolution suggestions.
SetupRemoteVideoEx
Initializes the remote user view.
public abstract int SetupRemoteVideoEx(VideoCanvas canvas, RtcConnection connection);
This method binds the remote user and the display view, and sets the rendering and mirror mode of the remote user view when displayed locally. It only affects the video image seen by the local user.
When calling this method, you need to specify the user ID of the remote video in VideoCanvas. It is generally recommended to set it before joining the channel.
If you cannot obtain the remote user's uid before joining the channel, you can call this method upon receiving the OnUserJoined callback. If video recording is enabled, the recording service will join the channel as a dummy client, and other clients will also receive its onUserJoined event. The app should not bind a view for it (because it does not send video streams).
To unbind a remote user's view, call this method and set view to null.
After leaving the channel, the SDK will clear the binding of the remote user view.
- This method must be called 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 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.
public abstract int StartMediaRenderingTracingEx(RtcConnection connection);
After this method is successfully called, the SDK uses the time of this call as the starting point and reports video frame rendering information through the OnVideoRenderingTracingResult callback.
- If you do not call this method, the SDK uses the time of calling JoinChannel [2/2] to join the channel as the default starting point and automatically begins tracing video rendering events. You can call this method at an appropriate time based on your business scenario to customize the tracing point.
- After leaving the current channel, the SDK automatically resets the tracing point to the time of the next channel join.
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 cross-channel media stream forwarding.
public abstract int StartOrUpdateChannelMediaRelayEx(ChannelMediaRelayConfiguration configuration, RtcConnection connection);
- If the OnChannelMediaRelayStateChanged callback reports
RELAY_STATE_RUNNING(2) andRELAY_OK(0), it means the SDK has started forwarding media streams between the source and destination channels. - If the callback reports
RELAY_STATE_FAILURE(3), it means an error occurred during cross-channel media stream forwarding.
- Call this method after successfully joining a channel.
- In a live streaming scenario, only users with the host role can call this method.
- Cross-channel media stream forwarding requires contacting technical support to enable.
- This feature does not support String-type UIDs.
Parameters
- configuration
- Configuration for cross-channel media stream forwarding. See ChannelMediaRelayConfiguration.
- 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.
- -1: General error (not specifically classified).
- -2: Invalid parameter.
- -8: Internal state error. Possibly because the user role is not host.
StartRtmpStreamWithTranscodingEx
Starts RTMP streaming with transcoding settings.
public abstract int StartRtmpStreamWithTranscodingEx(string url, LiveTranscoding transcoding, RtcConnection connection);
Agora recommends using a more comprehensive server-side streaming feature. See Implement server-side streaming. By calling this method, you can push live audio and video streams to the specified RTMP address and set transcoding parameters. This method can only push to one address at a time. If you need to push to multiple addresses, call this method multiple times. After calling this method, the SDK triggers the OnRtmpStreamingStateChanged callback locally to report the streaming state.
- Make sure the RTMP streaming service is enabled.
- Call this method after joining a channel.
- Only hosts in a live broadcast scenario can call this method.
- If the streaming fails and you want to restart it, make sure to call StopRtmpStreamEx before calling this method again, otherwise the SDK returns the same error code as the last failure.
Parameters
- url
- The RTMP or RTMPS streaming URL. The character length must not exceed 1024 bytes. Chinese characters and other special characters are not supported.
- transcoding
- The transcoding settings for RTMP streaming. See LiveTranscoding.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
- -2: Invalid URL or transcoding parameters. Please check your URL or parameter settings.
- -7: The SDK was not initialized before calling this method.
- -19: The RTMP URL is already in use. Please use another RTMP URL.
StartRtmpStreamWithoutTranscodingEx
Starts RTMP streaming without transcoding.
public abstract int StartRtmpStreamWithoutTranscodingEx(string url, RtcConnection connection);
Agora recommends using a more comprehensive server-side streaming feature. See Implement server-side streaming. By calling this method, you can push live audio and video streams to the specified RTMP address. This method can only push to one address at a time. If you need to push to multiple addresses, call this method multiple times. After calling this method, the SDK triggers the OnRtmpStreamingStateChanged callback locally to report the streaming state.
- Call this method after joining a channel.
- Only hosts in a live broadcast scenario can call this method.
- If the streaming fails and you want to restart it, make sure to call StopRtmpStream before calling this method again, otherwise the SDK returns the same error code as the last failure.
Parameters
- url
- The RTMP or RTMPS streaming URL. The character length must not exceed 1024 bytes. Chinese characters and other special characters are not supported.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
- -2: Invalid URL or transcoding parameters. Please check your URL or parameter settings.
- -7: The SDK was not initialized before calling this method.
- -19: The RTMP URL is already in use. Please use another RTMP URL.
StopChannelMediaRelayEx
Stops channel media stream relay. Once stopped, the host leaves all destination channels.
public abstract int StopChannelMediaRelayEx(RtcConnection connection);
After this method is successfully called, the SDK triggers the OnChannelMediaRelayStateChanged callback. If it reports RELAY_STATE_IDLE (0) and RELAY_OK (0), it indicates that media stream relay has stopped.
RELAY_ERROR_SERVER_NO_RESPONSE (2) or RELAY_ERROR_SERVER_CONNECTION_LOST (8). You can call the LeaveChannel [2/2] 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 resolution suggestions.
- -5: This method call was rejected. There is no ongoing channel media stream relay.
StopRtmpStreamEx
Stops the RTMP stream.
public abstract int StopRtmpStreamEx(string url, RtcConnection connection);
Agora recommends using a more complete server-side streaming service. See Implement Server-Side RTMP Streaming. Call this method to stop the live stream at the specified RTMP streaming URL. This method can only stop one stream at a time. To stop multiple streams, call this method multiple times. After calling this method, the SDK triggers the OnRtmpStreamingStateChanged callback locally to report the streaming status.
Parameters
- url
- The RTMP streaming URL. Must be in RTMP or RTMPS format. The character length cannot exceed 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 resolution suggestions.
TakeSnapshotEx [1/2]
Captures a video snapshot using a connection ID.
public abstract int TakeSnapshotEx(RtcConnection connection, uint uid, string filePath);
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 yet completed the snapshot.
- When used for local video snapshots, it captures the video stream specified in ChannelMediaOptions.
- If the video has been post-processed (e.g., with watermark or beautification), the snapshot will include the effects.
Timing
Call this method 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.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 - iOS:
/App Sandbox/Library/Caches/example.jpg - macOS:
~/Library/Logs/example.jpg - Android:
/storage/emulated/0/Android/data/<package name>/files/example.jpg
- Windows:
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
TakeSnapshotEx [2/2]
Captures a video snapshot at a specified observation point using a connection ID.
public abstract int TakeSnapshotEx(RtcConnection connection, uint uid, SnapshotConfig config);
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 yet completed the snapshot.
- When used for local video snapshots, it captures the video stream specified in ChannelMediaOptions.
- If the video has been post-processed (e.g., with watermark or beautification), the snapshot will include the effects.
Timing
Call this method 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 configuration. See SnapshotConfig.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
UpdateChannelMediaOptionsEx
Updates channel media options after joining the channel.
public abstract int UpdateChannelMediaOptionsEx(ChannelMediaOptions options, RtcConnection connection);
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 resolution suggestions.
- -2: Invalid ChannelMediaOptions member values. For example, using an invalid token or setting an invalid user role. You need to provide valid parameters.
- -7: The IRtcEngine object is not initialized. You must successfully initialize the IRtcEngine object before calling this method.
- -8: Internal state error of the IRtcEngine object. This may be because the user is not in the channel. It is recommended to use the OnConnectionStateChanged callback to determine whether the user is in the channel. If you receive
CONNECTION_STATE_DISCONNECTED(1) orCONNECTION_STATE_FAILED(5), it means the user is not in the channel. You need to call JoinChannel [2/2] before calling this method.
UpdateRtmpTranscodingEx
Updates the RTMP transcoding configuration.
public abstract int UpdateRtmpTranscodingEx(LiveTranscoding transcoding, RtcConnection connection);
Agora recommends using a more complete server-side streaming service. See Implement Server-Side RTMP Streaming. After enabling transcoding streaming, you can dynamically update the transcoding configuration based on your scenario. After the transcoding configuration is updated, the SDK triggers the OnTranscodingUpdated callback.
Parameters
- transcoding
- The RTMP transcoding configuration. See LiveTranscoding.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.