Inherits IRtcEngineNative.
Static Public Member Functions | |
static AgoraChannel | CreateChannel (IRtcEngine rtcEngine, string channelId) |
The AgoraChannel class.
agora_gaming_rtc.AgoraChannel.AgoraChannel | ( | IRtcEngine | rtcEngine, |
string | channelId | ||
) |
The AgoraChannel class.
|
static |
Creates and gets an AgoraChannel
object.
To join more than one channel, call this method multiple times to create as many AgoraChannel
objects as needed, and call the JoinChannel method of each created AgoraChannel
object.
After joining multiple channels, you can simultaneously subscribe to streams of all the channels, but publish a stream in only one channel at one time.
rtcEngine | IRtcEngine. |
channelId | The unique channel name for an Agora RTC session. It must be in the string format and not exceed 64 bytes in length. Supported character scopes are:
|
ERR_REFUSED(5)
.AgoraChannel
object, if the method call succeeds.NULL
, if the method call fails.ERR_REFUSED(5)
, if you set channelId
as the empty string "". int agora_gaming_rtc.AgoraChannel.ReleaseChannel | ( | ) |
Releases all AgoraChannel resources.
ERR_NOT_INITIALIZED(7)
: The SDK is not initialized before calling this method. int agora_gaming_rtc.AgoraChannel.JoinChannel | ( | string | token, |
string | info, | ||
uint | uid, | ||
ChannelMediaOptions | channelMediaOptions | ||
) |
Joins the channel with a user ID.
This method differs from the JoinChannel
method in the IRtcEngine
class in the following aspects:
AgoraChannel::JoinChannel | IRtcEngine::JoinChannel |
---|---|
Does not contain the channelName parameter, because the channel name is specified when creating the AgoraChannel object. | Contains the channelName parameter, which specifies the channel to join. |
Contains the channelMediaOptions parameter, which decide whether to subscribe to audio or video streams before joining the channel. | Does not contain the channelMediaOptions parameter. By default, users subscribe to all streams when joining the channel. |
Users can join multiple channels simultaneously by creating multiple AgoraChannel objects and calling the JoinChannel method of each object. | Users can join only one channel. |
By default, the SDK does not publish any stream after the user joins the channel. You need to call the Publish method to do that. | By default, the SDK publishes streams once the user joins the channel. |
Once the user joins the channel, the user subscribes to the audio and video streams of all the other users in the channel by default, giving rise to usage and billing calculation. If you do not want to subscribe to a specified stream or all remote streams, call the mute
methods accordingly.
uid
.IRtcEngine
object.token | The token for authentication:
|
info | (Optional) Additional information about the channel. This parameter can be set as null. Other users in the channel do not receive this information. |
uid | The user ID. A 32-bit unsigned integer with a value ranging from 1 to (232-1). This parameter must be unique. If uid is not assigned (or set as 0 ), the SDK assigns a uid and reports it in the OnJoinChannelSuccessHandler callback. The app must maintain this user ID. |
channelMediaOptions | The channel media options: ChannelMediaOptions. |
AgoraChannel
object with the same channel name.AgoraChannel
object. int agora_gaming_rtc.AgoraChannel.JoinChannelWithUserAccount | ( | string | token, |
string | userAccount, | ||
ChannelMediaOptions | channelMediaOptions | ||
) |
Joins the channel with a user account.
This method differs from the JoinChannelWithUserAccount
method in the IRtcEngine
class in the following aspects:
AgoraChannel::JoinChannelWithUserAccount | IRtcEngine::JoinChannelWithUserAccount |
---|---|
Does not contain the channelId parameter, because the channel name is specified when creating the AgoraChannel object. | Contains the channelId parameter, which specifies the channel to join. |
Contains the autoSubscribeAudio and autoSubscribeVideo parameters, which decide whether to subscribe to audio or video streams before joining the channel. | Does not contain the autoSubscribeAudio or autoSubscribeVideo parameter. By default, users subscribe to all streams when joining the channel. |
Users can join multiple channels simultaneously by creating multiple AgoraChannel objects and calling the JoinChannelWithUserAccount method of each object. | Users can join only one channel. |
By default, the SDK does not publish any stream after the user joins the channel. You need to call the Publish method to do that. | By default, the SDK publishes streams once the user joins the channel. |
Once the user joins the channel, the user subscribes to the audio and video streams of all the other users in the channel by default, giving rise to usage and billing calculation. If you do not want to subscribe to a specified stream or all remote streams, call the mute
methods accordingly.
uid
.IRtcEngine
object.token | The token for authentication:
|
userAccount | The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are:
|
channelMediaOptions | The channel media options: ChannelMediaOptions. |
ERR_INVALID_ARGUMENT(-2)
ERR_NOT_READY(-3)
ERR_REFUSED(-5)
int agora_gaming_rtc.AgoraChannel.LeaveChannel | ( | ) |
Allows a user to leave a channel, such as hanging up or exiting a call.
After joining a channel, the user must call the LeaveChannel
method to end the call before joining another channel.
This method returns 0
if the user leaves the channel and releases all resources related to the call.
This method call is asynchronous, and the user has not left the channel when the method call returns. Once the user leaves the channel, the SDK triggers the ChannelOnLeaveChannelHandler callback.
A successful LeaveChannel
method call triggers the following callbacks:
ChannelOnLeaveChannelHandler
LeaveChannel
method, the LeaveChannel
process interrupts, and the ChannelOnLeaveChannelHandler
callback is not triggered.LeaveChannel
method during a CDN live streaming, the SDK triggers the RemovePublishStreamUrl method.int agora_gaming_rtc.AgoraChannel.Publish | ( | ) |
Publishes the local stream to the channel.
You must keep the following restrictions in mind when calling this method. Otherwise, the SDK returns the ERR_REFUSED(-5)
:
AgoraChannel
object.AgoraChannel
object.ERR_REFUSED(-5)
: The method call is refused. int agora_gaming_rtc.AgoraChannel.Unpublish | ( | ) |
Stops publishing a stream to the channel.
If you call this method in a channel where you are not publishing streams, the SDK returns ERR_REFUSED(5)
.
ERR_REFUSED(5)
: The method call is refused. string agora_gaming_rtc.AgoraChannel.ChannelId | ( | ) |
Gets the channel ID of the current AgoraChannel
object.
AgoraChannel
object, if the method call succeeds.string agora_gaming_rtc.AgoraChannel.GetCallId | ( | ) |
Retrieves the current call ID.
When a user joins a channel on a client, a call ID is generated to identify the call from the client. Feedback methods, such as Rate and Complain, must be called after the call ends to submit feedback to the SDK.
The Rate
and Complain
methods require the call ID retrieved from the GetCallId
method during a call. The call ID is passed as an argument into the Rate
and Complain
methods after the call ends.
int agora_gaming_rtc.AgoraChannel.RenewToken | ( | string | token | ) |
Gets a new token when the current token expires after a period of time.
The token
expires after a period of time once the token schema is enabled when:
CONNECTION_CHANGED_TOKEN_EXPIRED(9)
.The application should call this method to get the new token
. Failure to do so will result in the SDK disconnecting from the server.
token | Pointer to the new token. |
int agora_gaming_rtc.AgoraChannel.SetEncryptionSecret | ( | string | secret | ) |
Enables built-in encryption with an encryption password before users join a channel.
All users in a channel must use the same encryption password. The encryption password is automatically cleared once a user leaves the channel.
If an encryption password is not specified, the encryption functionality will be disabled.
secret | The encryption password. |
int agora_gaming_rtc.AgoraChannel.SetEncryptionMode | ( | string | encryptionMode | ) |
Sets the built-in encryption mode.
The Agora Unity SDK supports built-in encryption, which is set to the aes-128-xts
mode by default. Call this method to use other encryption modes.
All users in the same channel must use the same encryption mode and password.
Refer to the information related to the AES encryption algorithm on the differences between the encryption modes.
encryptionMode | The set encryption mode:
|
int agora_gaming_rtc.AgoraChannel.SetClientRole | ( | CLIENT_ROLE_TYPE | role | ) |
Sets the role of the user, such as a host or an audience (default), before joining a channel in an interactive live streaming.
This method can be used to switch the user role in the interactive live streaming after the user joins a channel.
In the Live Broadcast profile, when a user switches user roles after joining a channel, a successful SetClientRole
method call triggers the following callbacks:
role | Sets the role of the user. See CLIENT_ROLE_TYPE. |
int agora_gaming_rtc.AgoraChannel.SetRemoteUserPriority | ( | uint | uid, |
PRIORITY_TYPE | userPriority | ||
) |
Prioritizes a remote user's stream.
Use this method with the SetRemoteSubscribeFallbackOption method. If the fallback function is enabled for a subscribed stream, the SDK ensures the high-priority user gets the best possible stream quality.
userPriority
as high for one user only.uid | The ID of the remote user. |
userPriority | Sets the priority of the remote user. See PRIORITY_TYPE. |
int agora_gaming_rtc.AgoraChannel.SetRemoteVoicePosition | ( | uint | uid, |
double | pan, | ||
double | gain | ||
) |
Sets the sound position and gain of a remote user.
When the local user calls this method to set the sound position of a remote user, the sound difference between the left and right channels allows the local user to track the real-time position of the remote user, creating a real sense of space. This method applies to massively multiplayer online games, such as Battle Royale games.
uid | The ID of the remote user. |
pan | The sound position of the remote user. The value ranges from -1.0 to 1.0:
|
gain | Gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain. |
int agora_gaming_rtc.AgoraChannel.SetDefaultMuteAllRemoteAudioStreams | ( | bool | mute | ) |
Sets whether to receive all remote audio streams by default. You can call this method either before or after joining a channel. If you call SetDefaultMuteAllRemoteAudioStreams (true)
after joining a channel, the remote audio streams of all subsequent users are not received.
MuteRemoteAudioStream (false)
as many times. Calling SetDefaultMuteAllRemoteAudioStreams (false)
resumes receiving the audio streams of subsequent users only.mute | Sets whether to receive or stop receiving all remote users' audio streams by default:
|
int agora_gaming_rtc.AgoraChannel.SetDefaultMuteAllRemoteVideoStreams | ( | bool | mute | ) |
Sets whether to receive all remote video streams by default. You can call this method either before or after joining a channel. If you call SetDefaultMuteAllRemoteVideoStreams (true)
after joining a channel, the remote video streams of all subsequent users are not received.
MuteRemoteVideoStream (false)
as many times. Calling SetDefaultMuteAllRemoteVideoStreams (false)
resumes receiving the video streams of subsequent users only.mute | Sets whether to receive/stop receiving all remote users' video streams by default:
|
int agora_gaming_rtc.AgoraChannel.MuteAllRemoteAudioStreams | ( | bool | mute | ) |
Stops/Resumes receiving all remote users' audio streams.
mute | Sets whether to receive or stop receiving all remote users' audio streams.
|
int agora_gaming_rtc.AgoraChannel.AdjustUserPlaybackSignalVolume | ( | uint | userId, |
int | volume | ||
) |
Adjusts the playback signal volume of a specified remote user.
You can call this method as many times as necessary to adjust the playback signal volume of different remote users, or to repeatedly adjust the playback signal volume of the same remote user.
userId | The ID of the remote user. |
volume | The playback signal volume of the specified remote user. The value ranges from 0 to 100:
|
int agora_gaming_rtc.AgoraChannel.MuteRemoteAudioStream | ( | uint | userId, |
bool | mute | ||
) |
Stops/Resumes receiving a specified remote user's audio stream.
mute
as true
to stop receiving all remote users' audio streams, call the MuteAllRemoteAudioStreams
method and set mute
as false
before calling this method.MuteAllRemoteAudioStreams
method sets all remote audio streams, while the MuteRemoteAudioStream
method sets a specified remote audio stream.userId | User ID of the specified remote user sending the audio. |
mute | Sets whether to receive/stop receiving a specified remote user's audio stream:
|
int agora_gaming_rtc.AgoraChannel.MuteAllRemoteVideoStreams | ( | bool | mute | ) |
Stops/Resumes receiving all remote video streams.
mute | Sets whether to receive or stop receiving all remote users' video streams:
|
int agora_gaming_rtc.AgoraChannel.MuteRemoteVideoStream | ( | uint | userId, |
bool | mute | ||
) |
Stops/Resumes receiving the video stream from a specified remote user.
mute
as true
to stop receiving all remote video streams, call the MuteAllRemoteVideoStreams
method and set mute
as false
before calling this method.userId | User ID of the specified remote user. |
mute | Sets whether to stop or resume receiving the video stream from a specified remote user:
|
int agora_gaming_rtc.AgoraChannel.SetRemoteVideoStreamType | ( | uint | userId, |
REMOTE_VIDEO_STREAM_TYPE | streamType | ||
) |
Sets the stream type of the remote video.
Under limited network conditions, if the publisher has not disabled the dual-stream mode using EnableDualStreamMode(false), the receiver can choose to receive either the high-quality video stream (the high resolution, and high bitrate video stream) or the low-video stream (the low resolution, and low bitrate video stream).
By default, users receive the high-quality video stream. Call this method if you want to switch to the low-video stream. This method allows the app to adjust the corresponding video stream type based on the size of the video window to reduce the bandwidth and resources.
The aspect ratio of the low-video stream is the same as the high-quality video stream. Once the resolution of the high-quality video stream is set, the system automatically sets the resolution, frame rate, and bitrate of the low-video stream.
The method result returns in the OnApiExecutedHandler callback.
SetRemoteVideoStreamType
and SetRemoteDefaultVideoStreamType, the SDK applies the settings in the SetRemoteVideoStreamType
.userId | ID of the remote user sending the video stream. |
streamType | Sets the video-stream type. See REMOTE_VIDEO_STREAM_TYPE. |
int agora_gaming_rtc.AgoraChannel.SetRemoteDefaultVideoStreamType | ( | REMOTE_VIDEO_STREAM_TYPE | streamType | ) |
Sets the default video-stream type for the video received by the local user when the remote user sends dual streams.
SetRemoteDefaultVideoStreamType
method allows the application to adjust the corresponding video-stream type according to the size of the video window, reducing the bandwidth and resources.The result after calling this method is returned in the OnApiExecutedHandler callback. The Agora RTC SDK receives the high-stream video by default to reduce the bandwidth. If needed, users can switch to the low-stream video through this method.
SetRemoteDefaultVideoStreamType
and SetRemoteVideoStreamType, the SDK applies the settings in the SetRemoteVideoStreamType
.streamType | Sets the default video stream type. See REMOTE_VIDEO_STREAM_TYPE. |
int agora_gaming_rtc.AgoraChannel.CreateDataStream | ( | bool | reliable, |
bool | ordered | ||
) |
Creates a data stream.
Each user can create up to five data streams during the lifecycle of the AgoraChannel.
reliable
and ordered
parameters to true
or false
. Do not set one as true
and the other as false
.reliable | Sets whether or not the recipients are guaranteed to receive the data stream from the sender within five seconds:
|
ordered | Sets whether or not the recipients receive the data stream in the sent order:
|
int agora_gaming_rtc.AgoraChannel.SendStreamMessage | ( | int | streamId, |
string | data, | ||
Int64 | length | ||
) |
Sends data stream messages to all users in a channel.
The SDK has the following restrictions on this method:
A successful SendStreamMessage
method call triggers the ChannelOnStreamMessageHandler callback on the remote client, from which the remote user gets the stream message.
A failed SendStreamMessage
method call triggers the ChannelOnStreamMessageHandler
callback on the remote client.
streamId | The ID of the sent data stream, returned in the CreateDataStream method. |
data | The sent data. |
length | The data length. |
int agora_gaming_rtc.AgoraChannel.AddPublishStreamUrl | ( | string | url, |
bool | transcodingEnabled | ||
) |
Publishes the local stream to a specified CDN streaming URL. (CDN live only.)
The SDK returns the result of this method call in the OnStreamPublishedHandler callback.
The AddPublishStreamUrl
method call triggers the ChannelOnRtmpStreamingStateChangedHandler callback on the local client to report the state of adding a local stream to the CDN.
url | The CDN streaming URL in the RTMP or RTMPS format. The maximum length of this parameter is 1024 bytes. The CDN streaming URL must not contain special characters, such as Chinese language characters. |
transcodingEnabled | Sets whether transcoding is enabled or disabled:
|
ERR_INVALID_ARGUMENT(-2)
: The CDN streaming URL is null
or has a string length of 0.ERR_NOT_INITIALIZED(-7)
: You have not initialized the RTC engine when publishing the stream. int agora_gaming_rtc.AgoraChannel.RemovePublishStreamUrl | ( | string | url | ) |
Removes an RTMP or RTMPS stream from the CDN. (CDN live only.)
This method removes the CDN streaming URL (added by the AddPublishStreamUrl method) from a CDN live stream. The SDK returns the result of this method call in the OnStreamUnpublishedHandler callback.
The RemovePublishStreamUrl
method call triggers the ChannelOnRtmpStreamingStateChangedHandler callback on the local client to report the state of removing an RTMP or RTMPS stream from the CDN.
url | The CDN streaming URL to be removed. The maximum length of this parameter is 1024 bytes. |
int agora_gaming_rtc.AgoraChannel.SetLiveTranscoding | ( | LiveTranscoding | liveTranscoding | ) |
Sets the video layout and audio settings for CDN live. (CDN live only.)
The SDK triggers the ChannelOnTranscodingUpdatedHandler callback when you call the SetLiveTranscoding
method to update the transcoding setting.
SetLiveTranscoding
method to update the transcoding setting for the first time, the SDK does not trigger the ChannelOnTranscodingUpdatedHandler
callback.liveTranscoding | Sets the CDN live audio or video transcoding settings. See LiveTranscoding. |
int agora_gaming_rtc.AgoraChannel.AddInjectStreamUrl | ( | string | url, |
InjectStreamConfig | config | ||
) |
Adds a voice or video stream URL address to the interactive live streaming.
The OnStreamPublishedHandler callback returns the inject status. If this method call is successful, the server pulls the voice or video stream and injects it into a live channel. This is applicable to scenarios where all audience members in the channel can watch a live show and interact with each other.
The AddInjectStreamUrl
method call triggers the following callbacks:
ChannelOnUserJoinedHandler
(uid: 666), if the method call is successful and the online media stream is injected into the channel.url | The URL address which is added to the ongoing interactive live streaming. Valid protocols are RTMP, HLS, and FLV.
|
config | The InjectStreamConfig object that contains the configuration of the added voice or video stream. |
ERR_INVALID_ARGUMENT(-2)
: The injected URL does not exist. Call this method again to inject the stream and ensure that the URL is valid. -ERR_NOT_READY(-3)
: The user is not in the channel. -ERR_NOT_SUPPORTED(-4)
: The channel profile is not interactive live streaming. Call the SetChannelProfile method and set the channel profile to interactive live streaming before calling this method. -ERR_NOT_INITIALIZED(-7)
: The SDK is not initialized. Ensure that the IRtcEngine object is initialized before calling this method. int agora_gaming_rtc.AgoraChannel.RemoveInjectStreamUrl | ( | string | url | ) |
Removes the voice or video stream URL address from the interactive live streaming.
This method removes the URL address (added by the AddInjectStreamUrl method) from the interactive live streaming.
url | The URL address of the added stream to be removed. |
int agora_gaming_rtc.AgoraChannel.StartChannelMediaRelay | ( | ChannelMediaRelayConfiguration | channelMediaRelayConfiguration | ) |
Starts to relay media streams across channels.
After a successful method call, the SDK triggers the ChannelOnMediaRelayStateChangedHandler and ChannelOnMediaRelayEventHandler callbacks, and these callbacks return the state and events of the media stream relay.
ChannelOnMediaRelayStateChangedHandler
callback returns RELAY_STATE_RUNNING(2) and RELAY_OK(0), and the ChannelOnMediaRelayEventHandler
callback returns RELAY_EVENT_PACKET_SENT_TO_DEST_CHANNEL(4), the host starts sending data to the destination channel.ChannelOnMediaRelayStateChangedHandler
callback returns RELAY_STATE_FAILURE(3), an exception occurs during the media stream relay.channelMediaRelayConfiguration | The configuration of the media stream relay: ChannelMediaRelayConfiguration. |
int agora_gaming_rtc.AgoraChannel.UpdateChannelMediaRelay | ( | ChannelMediaRelayConfiguration | channelMediaRelayConfiguration | ) |
Updates the channels for media stream relay. After a successful StartChannelMediaRelay method call, if you want to relay the media stream to more channels, or leave the current relay channel, you can call the UpdateChannelMediaRelay
method.
After a successful method call, the SDK triggers the ChannelOnMediaRelayEventHandler callback with the RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL(7) state code.
StartChannelMediaRelay
method to update the destination channel.channelMediaRelayConfiguration | The media stream relay configuration: ChannelMediaRelayConfiguration. |
int agora_gaming_rtc.AgoraChannel.StopChannelMediaRelay | ( | ) |
Stops the media stream relay.
Once the relay stops, the host quits all the destination channels.
After a successful method call, the SDK triggers the ChannelOnMediaRelayStateChangedHandler callback. If the callback returns RELAY_STATE_IDLE(0) and RELAY_OK(0), the host successfully stops the relay.
ChannelOnMediaRelayStateChangedHandler
callback with the RELAY_ERROR_SERVER_NO_RESPONSE(2) or RELAY_ERROR_SERVER_CONNECTION_LOST(8) state code. You can leave the channel by calling the LeaveChannel method, and the media stream relay automatically stops.CONNECTION_STATE_TYPE agora_gaming_rtc.AgoraChannel.GetConnectionState | ( | ) |
Retrieves the connection state of the SDK.
int agora_gaming_rtc.AgoraChannel.SetClientRole | ( | CLIENT_ROLE_TYPE | role, |
ClientRoleOptions | audienceLatencyLevel | ||
) |
Sets the role of a user in interactive live streaming.
You can call this method either before or after joining the channel to set the user role as audience or host. If you call this method to switch the user role after joining the channel, the SDK triggers the following callbacks:
LIVE_BROADCASTING
profile only.role | The role of a user in interactive live streaming. See CLIENT_ROLE_TYPE. |
audienceLatencyLevel | The detailed options of a user, including user level. See ClientRoleOptions. |
int agora_gaming_rtc.AgoraChannel.EnableEncryption | ( | bool | enabled, |
EncryptionConfig | encryptionConfig | ||
) |
Enables/Disables the built-in encryption.
In scenarios requiring high security, Agora recommends calling this method to enable the built-in encryption before joining a channel.
All users in the same channel must use the same encryption mode and encryption key. Once all users leave the channel, the encryption key of this channel is automatically cleared.
SM4_128_ECB
mode), you need to add an external encryption library.enabled | Whether to enable the built-in encryption:
|
encryptionConfig | Configurations of built-in encryption schemas. See EncryptionConfig. |
AgoraChannel
instance before calling this method.