#include <IAgoraRtcChannel.h>
The IChannel class.
|
inlinevirtual |
|
pure virtual |
Releases all IChannel resources.
ERR_NOT_INITIALIZED (7)
: The SDK is not initialized before calling this method.
|
pure virtual |
Sets the channel event handler.
After setting the channel event handler, you can listen for channel events and receive the statistics of the corresponding IChannel
object.
channelEh | The event handler of the IChannel object. For details, see IChannelEventHandler. |
|
pure virtual |
Joins the channel with a user ID.
Compared with the joinChannel
method in the IRtcEngine class, this method supports joining multiple channels at a time by creating multiple IChannel objects and then calling joinChannel
in each IChannel object.
Once the user joins the channel, the user publishes the local audio and video streams and automatically subscribes to the audio and video streams of all the other users in the channel by default. Subscribing incurs all associated usage costs. To unsubscribe, set the options
parameter or call the mute
methods accordingly.
uid
.IRtcEngine
object.token | The token generated at your server. See Authenticate Your Users with Tokens. |
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 onJoinChannelSuccess callback. The app must maintain this user ID. |
options | The channel media options: ChannelMediaOptions |
ERR_JOIN_CHANNEL_REJECTED(-17)
: The request to join the channel is rejected. The SDK does not support joining the same IChannel channel repeatedly. Therefore, the SDK returns this error code when a user who has already joined an IChannel channel calls the joining channel method of this IChannel object.
|
pure virtual |
Joins the channel with a user account.
Compared with the joinChannelWithUserAccount
method in the IRtcEngine class, this method supports joining multiple channels at a time by creating multiple IChannel objects and then calling joinChannelWithUserAccount
in each IChannel object.
After the user successfully joins the channel, the SDK triggers the following callbacks:
COMMUNICATION
profile, or is a host in the LIVE_BROADCASTING
profile.Once the user joins the channel, the user publishes the local audio and video streams and automatically subscribes to the audio and video streams of all the other users in the channel by default. Subscribing incurs all associated usage costs. To unsubscribe, set the options
parameters or call the mute
methods accordingly.
token | The token generated at your server. See Authenticate Your Users with Tokens. |
userAccount | The user account. The maximum length of this parameter is 255 bytes. Ensure that the user account is unique and do not set it as null. Supported character scopes are:
|
options | The channel media options: agora::rtc::ChannelMediaOptions::ChannelMediaOptions “ChannelMediaOptions”. |
ERR_JOIN_CHANNEL_REJECTED(-17)
: The request to join the channel is rejected. The SDK does not support joining the same IChannel channel repeatedly. Therefore, the SDK returns this error code when a user who has already joined an IChannel channel calls the joining channel method of this IChannel object.
|
pure virtual |
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 onLeaveChannel callback.
A successful leaveChannel method call triggers the following callbacks:
LIVE_BROADCASTING
profile.
|
pure virtual |
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):
|
pure virtual |
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).
|
pure virtual |
|
pure virtual |
Gets the current call ID.
When a user joins a channel on a client, a callId
is generated to identify the call from the client. Feedback methods, such as rate and complain, must be called after the call ends to submit feedback to the SDK.
The rate
and complain
methods require the callId
parameter retrieved from the getCallId
method during a call. callId
is passed as an argument into the rate
and complain
methods after the call ends.
callId | The current call ID. |
|
pure virtual |
Gets a new token when the current token expires after a period of time.
The token
expires after a period of time once the token schema is enabled when:
The application should call this method to get the new token
. Failure to do so will result in the SDK disconnecting from the server.
token | The new token. |
|
pure virtual |
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 | Pointer to the encryption password. |
|
pure virtual |
Sets the built-in encryption mode.
The Agora 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:
|
|
pure virtual |
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.
After a user leaves the channel, the SDK automatically disables the built-in encryption. To re-enable the built-in encryption, call this method before the user joins the channel again.
As of v3.4.5, Agora recommends using either the AES_128_GCM2
or AES_256_GCM2
encryption mode, both of which support adding a salt and are more secure. For details, see Media Stream Encryption.
enabled | Whether to enable the built-in encryption:
|
config | Configurations of built-in encryption schemas. See EncryptionConfig. |
IRtcEngine
instance before calling this method.
|
pure virtual |
Registers a packet observer.
The Agora SDK allows your application to register a packet observer to receive callbacks for voice or video packet transmission.
observer | The registered packet observer. See IPacketObserver. |
|
pure virtual |
Registers the metadata observer.
Registers the metadata observer. You need to implement the IMetadataObserver class and specify the metadata type in this method. A successful call of this method triggers the getMaxMetadataSize callback. This method enables you to add synchronized metadata in the video stream for more diversified interactive live streaming, such as sending shopping links, digital coupons, and online quizzes.
observer | The IMetadataObserver class. See the definition of IMetadataObserver for details. |
type | See METADATA_TYPE. The SDK supports VIDEO_METADATA (0) only for now. |
|
pure virtual |
Sets the role of the user in interactive live streaming.
In the LIVE_BROADCASTING
channel profile, the SDK sets the user role as audience by default. You can call setClientRole
to set the user role as host.
You can call this method either before or after joining a channel. If you call this method to switch the user role after joining a channel, the SDK automatically does the following:
LIVE_BROADCASTING
profile only.role | The role of a user in interactive live streaming. See CLIENT_ROLE_TYPE. |
joinChannel
with the options
parameter and use the default settings publishLocalAudio = true
or publishLocalVideo = true
.setClientRole
to set the user role as host.muteLocalAudioStream(false)
or muteLocalVideoStream(false)
.
|
pure virtual |
Sets the role of the user in interactive live streaming.
In the LIVE_BROADCASTING
channel profile, the SDK sets the user role as audience by default. You can call setClientRole
to set the user role as host.
You can call this method either before or after joining a channel. If you call this method to switch the user role after joining a channel, the SDK automatically does the following:
LIVE_BROADCASTING
profile only.role | The role of a user in interactive live streaming. See CLIENT_ROLE_TYPE. |
options | The detailed options of a user, including user level. See ClientRoleOptions. |
joinChannel
with the options
parameter and use the default settings publishLocalAudio = true
or publishLocalVideo = true
.setClientRole
to set the user role as host.muteLocalAudioStream(false)
or muteLocalVideoStream(false)
.
|
pure virtual |
Prioritizes a remote user's stream.
The SDK ensures the high-priority user gets the best possible stream quality.
serPriority
as high for one user only.uid | The ID of the remote user. |
userPriority | Sets the priority of the remote user. See PRIORITY_TYPE. |
|
pure virtual |
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. |
|
pure virtual |
Updates the display mode of the video view of a remote user.
After initializing the video view of a remote user, you can call this method to update its rendering and mirror modes. This method affects only the video view that the local user sees.
userId | The ID of the remote user. |
renderMode | The rendering mode of the remote video view. See RENDER_MODE_TYPE. |
mirrorMode |
|
|
pure virtual |
Stops or resumes subscribing to the audio streams of all remote users by default.
Call this method after joining a channel. After successfully calling this method, the local user stops or resumes subscribing to the audio streams of all subsequent users.
mute | Sets whether to stop subscribing to the audio streams of all remote users by default.
|
|
pure virtual |
Stops or resumes subscribing to the video streams of all remote users by default.
Call this method after joining a channel. After successfully calling this method, the local user stops or resumes subscribing to the video streams of all subsequent users.
mute | Sets whether to stop subscribing to the video streams of all remote users by default.
|
|
pure virtual |
Stops or resumes publishing the local audio stream.
This method only sets the publishing state of the audio stream in the channel of IChannel.
A successful method call triggers the onRemoteAudioStateChanged callback on the remote client.
You can only publish the local stream in one channel at a time. If you create multiple channels, ensure that you only call muteLocalAudioStream (false) in one channel; otherwise, the method call fails, and the SDK returns -5 (ERR_REFUSED)
.
mute | Sets whether to stop publishing the local audio stream.
|
-5 (ERR_REFUSED)
: The request is rejected.
|
pure virtual |
Stops or resumes publishing the local video stream.
This method only sets the publishing state of the video stream in the channel of IChannel.
A successful method call triggers the onRemoteVideoStateChanged callback on the remote client.
You can only publish the local stream in one channel at a time. If you create multiple channels, ensure that you only call muteLocalVideoStream (false) in one channel; otherwise, the method call fails, and the SDK returns -5 (ERR_REFUSED)
.
mute | Sets whether to stop publishing the local video stream.
|
-5 (ERR_REFUSED)
: The request is rejected.
|
pure virtual |
Stops or resumes subscribing to the audio streams of all remote users.
After successfully calling this method, the local user stops or resumes subscribing to the audio streams of all remote users, including all subsequent users.
muteAllRemoteAudioStreams
and setDefaultMuteAllRemoteAudioStreams
together; otherwise, the settings may not take effect. See Set the Subscribing State.mute | Sets whether to stop subscribing to the audio streams of all remote users.
|
|
pure virtual |
Adjust the playback signal volume of the specified remote user.
After joining a channel, call adjustPlaybackSignalVolume to adjust the playback volume of different remote users, or adjust multiple times for one remote user.
userId | The user ID, which should be the same as the uid of joinChannel |
volume | The playback volume of the voice. The value ranges between 0 and 100, including the following:
|
|
pure virtual |
Stops or resumes subscribing to the audio stream of a specified user.
userId | The user ID of the specified remote user. |
mute | Sets whether to stop subscribing to the audio stream of a specified user.
|
|
pure virtual |
Stops or resumes subscribing to the video streams of all remote users.
After successfully calling this method, the local user stops or resumes subscribing to the video streams of all remote users, including all subsequent users.
mute | Sets whether to stop subscribing to the video streams of all remote users.
|
|
pure virtual |
Stops or resumes subscribing to the video stream of a specified user.
userId | The user ID of the specified remote user. |
mute | Sets whether to stop subscribing to the video stream of a specified user.
|
|
pure virtual |
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 onApiCallExecuted callback.
userId | The ID of the remote user sending the video stream. |
streamType | Sets the video-stream type. See REMOTE_VIDEO_STREAM_TYPE. |
|
pure virtual |
Sets the default stream type of remote videos.
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 onApiCallExecuted callback.
setRemoteVideoStreamType
, the SDK applies the settings in the setRemoteVideoStreamType
method.streamType | Sets the default video-stream type. See REMOTE_VIDEO_STREAM_TYPE. |
|
pure virtual |
Creates a data stream.
Each user can create up to five data streams during the lifecycle of the IChannel.
reliable
as true
while setting ordered
as false
.[out] | streamId | The ID of the created data stream. |
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:
|
|
pure virtual |
Creates a data stream.
Each user can create up to five data streams in a single channel.
This method does not support data reliability. If the receiver receives a data packet five seconds or more after it was sent, the SDK directly discards the data.
[out] | streamId | The ID of the created data stream. |
config | The configurations for the data stream: DataStreamConfig. |
|
pure virtual |
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 onStreamMessage callback on the remote client, from which the remote user gets the stream message.
A failed sendStreamMessage method call triggers the onStreamMessage callback on the remote client.
COMMUNICATION
profile or to the hosts in the LIVE_BROADCASTING
profile. If an audience in the LIVE_BROADCASTING
profile calls this method, the audience may be switched to a host.streamId | The ID of the sent data stream, returned in the createDataStream method. |
data | The sent data. |
length | The length of the sent data. |
|
pure virtual |
Publishes the local stream to a specified CDN streaming URL. (CDN live only.)
The SDK returns the result of this method call in the onStreamPublished callback.
After calling this method, you can push media streams in RTMP or RTMPS protocol to the CDN. The SDK triggers the onRtmpStreamingStateChanged 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/disabled:
|
IChannel
when publishing the stream.
|
pure virtual |
Removes an RTMP or RTMPS stream from the CDN.
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 onStreamUnpublished callback.
The removePublishStreamUrl method call triggers the onRtmpStreamingStateChanged 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. |
|
pure virtual |
Sets the video layout and audio settings for CDN live. (CDN live only.)
The SDK triggers the onTranscodingUpdated callback when you call the setLiveTranscoding
method to update the transcoding setting.
setLiveTranscoding
method to set the transcoding setting for the first time, the SDK does not trigger the onTranscodingUpdated
callback.transcoding | Sets the CDN live audio/video transcoding settings. See LiveTranscoding. |
|
pure virtual |
Starts pushing media streams to a CDN without transcoding.
You can call this method to push a live audio-and-video stream to the specified CDN address. This method can push media streams to only one CDN address at a time, so if you need to push streams to multiple addresses, call this method multiple times.
After you call this method, the SDK triggers the onRtmpStreamingStateChanged callback on the local client to report the state of the streaming.
LIVE_BROADCASTING
profile can call this method.url | The address of the CDN live streaming. The format is RTMP or RTMPS. The character length cannot exceed 1024 bytes. Special characters such as Chinese characters are not supported. |
ERR_INVALID_ARGUMENT(-2)
: url is null or the string length is 0.ERR_NOT_INITIALIZED(-7)
: The SDK is not initialized before calling this method.
|
pure virtual |
Starts pushing media streams to a CDN and sets the transcoding configuration.
You can call this method to push a live audio-and-video stream to the specified CDN address and set the transcoding configuration. This method can push media streams to only one CDN address at a time, so if you need to push streams to multiple addresses, call this method multiple times.
After you call this method, the SDK triggers the onRtmpStreamingStateChanged callback on the local client to report the state of the streaming.
LIVE_BROADCASTING
profile can call this method.url | The address of the CDN live streaming. The format is RTMP or RTMPS. The character length cannot exceed 1024 bytes. Special characters such as Chinese characters are not supported. |
transcoding | The transcoding configuration for CDN live streaming. See LiveTranscoding. |
ERR_INVALID_ARGUMENT(-2)
: url is null or the string length is 0.ERR_NOT_INITIALIZED(-7)
: The SDK is not initialized before calling this method.
|
pure virtual |
Updates the transcoding configuration.
After you start pushing media streams to CDN with transcoding, you can dynamically update the transcoding configuration according to the scenario. The SDK triggers the onTranscodingUpdated callback after the transcoding configuration is updated.
transcoding | The transcoding configuration for CDN live streaming. See LiveTranscoding. |
|
pure virtual |
Stops pushing media streams to a CDN.
You can call this method to stop the live stream on the specified CDN address. This method can stop pushing media streams to only one CDN address at a time, so if you need to stop pushing streams to multiple addresses, call this method multiple times.
After you call this method, the SDK triggers the onRtmpStreamingStateChanged callback on the local client to report the state of the streaming.
url | The address of the CDN live streaming. The format is RTMP or RTMPS. The character length cannot exceed 1024 bytes. Special characters such as Chinese characters are not supported. |
|
pure virtual |
Starts to relay media streams across channels.
After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged and onChannelMediaRelayEvent callbacks, and these callbacks return the state and events of the media stream relay.
LIVE_BROADCASTING
channel.configuration | The configuration of the media stream relay: ChannelMediaRelayConfiguration. |
|
pure virtual |
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 onChannelMediaRelayEvent callback with the RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL (7) state code.
configuration | The media stream relay configuration: ChannelMediaRelayConfiguration. |
|
pure virtual |
Pauses the media stream relay to all destination channels.
After the cross-channel media stream relay starts, you can call this method to pause relaying media streams to all destination channels; after the pause, if you want to resume the relay, call resumeAllChannelMediaRelay.
After a successful method call, the SDK triggers the onChannelMediaRelayEvent callback to report whether the media stream relay is successfully paused.
|
pure virtual |
Resumes the media stream relay to all destination channels.
After calling the pauseAllChannelMediaRelay method, you can call this method to resume relaying media streams to all destination channels.
After a successful method call, the SDK triggers the onChannelMediaRelayEvent callback to report whether the media stream relay is successfully resumed.
|
pure virtual |
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 onChannelMediaRelayStateChanged callback. If the callback returns RELAY_STATE_IDLE (0) and RELAY_OK (0), the host successfully stops the relay.
|
pure virtual |
Gets the current connection state of the SDK.
|
pure virtual |
Enables/Disables the super resolution feature for a remote user's video. (beta feature)
This feature effectively boosts the resolution of a remote user's video seen by the local user. If the original resolution of a remote user's video is a × b, the local user's device can render the remote video at a resolution of 2a × 2b after you enable this feature.
After calling this method, the SDK triggers the onUserSuperResolutionEnabled callback to report whether you have successfully enabled super resolution.
libagora_super_resolution_extension.so
AgoraSuperResolutionExtension.xcframework
userId | The user ID of the remote user. |
enable | Determines whether to enable super resolution for the remote user's video:
|
-157 (ERR_MODULE_NOT_FOUND)
: The dynamic library for super resolution is not integrated.
|
pure virtual |
Enables/Disables the super-resolution feature for a remote user's video stream. This is a beta feature.
This feature effectively boosts the resolution of a remote user's video seen by the local user. If the original resolution of a remote user's video is a × b, the local user's device can render the remote video at a resolution of 2a × 2b after you enable this feature.
After calling this method, the SDK triggers the onUserSuperResolutionEnabled callback to report whether you have successfully enabled super resolution.
libagora_super_resolution_extension.so
AgoraSuperResolutionExtension.xcframework
libagora_super_resolution_extension.dll
enabled | Determines whether to enable super resolution for the remote user's video:
|
mode | The mode of super resolution. See SR_MODE. |
userId | The user ID of the remote user. This parameter only applies when mode is set as SR_MODE_MANUAL(0) . |
-157 (ERR_MODULE_NOT_FOUND)
: The dynamic library for super resolution is not integrated.