Public Member Functions

virtual ~IChannel ()
 
virtual int release ()=0
 
virtual int setChannelEventHandler (IChannelEventHandler *channelEh)=0
 
virtual int joinChannel (const char *token, const char *info, uid_t uid, const ChannelMediaOptions &options)=0
 
virtual int joinChannelWithUserAccount (const char *token, const char *userAccount, const ChannelMediaOptions &options)=0
 
virtual int leaveChannel ()=0
 
virtual int publish ()=0
 
virtual int unpublish ()=0
 
virtual const char * channelId ()=0
 
virtual int getCallId (agora::util::AString &callId)=0
 
virtual int renewToken (const char *token)=0
 
virtual int setEncryptionSecret (const char *secret)=0
 
virtual int setEncryptionMode (const char *encryptionMode)=0
 
virtual int enableEncryption (bool enabled, const EncryptionConfig &config)=0
 
virtual int registerPacketObserver (IPacketObserver *observer)=0
 
virtual int registerMediaMetadataObserver (IMetadataObserver *observer, IMetadataObserver::METADATA_TYPE type)=0
 
virtual int setClientRole (CLIENT_ROLE_TYPE role)=0
 
virtual int setRemoteUserPriority (uid_t uid, PRIORITY_TYPE userPriority)=0
 
virtual int setRemoteVoicePosition (uid_t uid, double pan, double gain)=0
 
virtual int setRemoteRenderMode (uid_t userId, RENDER_MODE_TYPE renderMode, VIDEO_MIRROR_MODE_TYPE mirrorMode)=0
 
virtual int setDefaultMuteAllRemoteAudioStreams (bool mute)=0
 
virtual int setDefaultMuteAllRemoteVideoStreams (bool mute)=0
 
virtual int muteAllRemoteAudioStreams (bool mute)=0
 
virtual int adjustUserPlaybackSignalVolume (uid_t userId, int volume)=0
 
virtual int muteRemoteAudioStream (uid_t userId, bool mute)=0
 
virtual int muteAllRemoteVideoStreams (bool mute)=0
 
virtual int muteRemoteVideoStream (uid_t userId, bool mute)=0
 
virtual int setRemoteVideoStreamType (uid_t userId, REMOTE_VIDEO_STREAM_TYPE streamType)=0
 
virtual int setRemoteDefaultVideoStreamType (REMOTE_VIDEO_STREAM_TYPE streamType)=0
 
virtual int createDataStream (int *streamId, bool reliable, bool ordered)=0
 
virtual int sendStreamMessage (int streamId, const char *data, size_t length)=0
 
virtual int addPublishStreamUrl (const char *url, bool transcodingEnabled)=0
 
virtual int removePublishStreamUrl (const char *url)=0
 
virtual int setLiveTranscoding (const LiveTranscoding &transcoding)=0
 
virtual int addInjectStreamUrl (const char *url, const InjectStreamConfig &config)=0
 
virtual int removeInjectStreamUrl (const char *url)=0
 
virtual int startChannelMediaRelay (const ChannelMediaRelayConfiguration &configuration)=0
 
virtual int updateChannelMediaRelay (const ChannelMediaRelayConfiguration &configuration)=0
 
virtual int stopChannelMediaRelay ()=0
 
virtual CONNECTION_STATE_TYPE getConnectionState ()=0
 

Detailed Description

The IChannel class.

Constructor & Destructor Documentation

◆ ~IChannel()

virtual agora::rtc::IChannel::~IChannel ( )
inlinevirtual

Member Function Documentation

◆ release()

virtual int agora::rtc::IChannel::release ( )
pure virtual

Releases all IChannel resources.

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

◆ setChannelEventHandler()

virtual int agora::rtc::IChannel::setChannelEventHandler ( IChannelEventHandler channelEh)
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.

Parameters
channelEhThe event handler of the IChannel object. For details, see IChannelEventHandler.
Returns
  • 0: Success.
  • < 0: Failure.

◆ joinChannel()

virtual int agora::rtc::IChannel::joinChannel ( const char *  token,
const char *  info,
uid_t  uid,
const ChannelMediaOptions options 
)
pure virtual

Joins the channel with a user ID.

This method differs from the joinChannel method in the IRtcEngine class in the following aspects:

IChannel::joinChannel IRtcEngine::joinChannel
Does not contain the channelId parameter, because channelId is specified when creating the IChannel object. Contains the channelId parameter, which specifies the channel to join.
Contains the options parameter, which decides whether to subscribe to all streams before joining the channel. Does not contain the options parameter. By default, users subscribe to all streams when joining the channel.
Users can join multiple channels simultaneously by creating multiple IChannel 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.
Note
  • If you are already in a channel, you cannot rejoin it with the same uid.
  • We recommend using different UIDs for different channels.
  • If you want to join the same channel from different devices, ensure that the UIDs in all devices are different.
  • Ensure that the app ID you use to generate the token is the same with the app ID used when creating the IRtcEngine object.
Parameters
tokenThe token for authentication:
  • In situations not requiring high security: You can use the temporary token generated at Console. For details, see Get a temporary token.
  • In situations requiring high security: Set it as the token generated at your server. For details, see Generate a token.
info(Optional) Additional information about the channel. This parameter can be set as null. Other users in the channel do not receive this information.
uidThe 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.
optionsThe channel media options: ChannelMediaOptions
Returns
  • 0(ERR_OK): Success.
  • < 0: Failure.
    • -2(ERR_INALID_ARGUMENT): The parameter is invalid.
    • -3(ERR_NOT_READY): The SDK fails to be initialized. You can try re-initializing the SDK.
    • -5(ERR_REFUSED): The request is rejected. This may be caused by the following:
      • You have created an IChannel object with the same channel name.
      • You have joined and published a stream in a channel created by the IChannel object.

◆ joinChannelWithUserAccount()

virtual int agora::rtc::IChannel::joinChannelWithUserAccount ( const char *  token,
const char *  userAccount,
const ChannelMediaOptions options 
)
pure virtual

Joins the channel with a user account.

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

Note
To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type.
Parameters
tokenThe token generated at your server:
  • For low-security requirements: You can use the temporary token generated at Console. For details, see Get a temporary toke.
  • For high-security requirements: Set it as the token generated at your server. For details, see Get a token.
userAccountThe user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are:
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • The space character.
  • Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
optionsThe channel media options: agora::rtc::ChannelMediaOptions::ChannelMediaOptions “ChannelMediaOptions”.
Returns

◆ leaveChannel()

virtual int agora::rtc::IChannel::leaveChannel ( )
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:

  • The local client: onLeaveChannel
  • The remote client: onUserOffline , if the user leaving the channel is in the Communication channel, or is a host in the LIVE_BROADCASTING profile.
Note
  • If you call the release method immediately after the leaveChannel method, the leaveChannel process interrupts, and the onLeaveChannel callback is not triggered.
  • If you call the leaveChannel method during a CDN live streaming, the SDK triggers the removePublishStreamUrl method.
Returns
  • 0(ERR_OK): Success.
  • < 0: Failure.
    • -1(ERR_FAILED): A general error occurs (no specified reason).
    • -2(ERR_INALID_ARGUMENT): The parameter is invalid.
    • -7(ERR_NOT_INITIALIZED): The SDK is not initialized.

◆ publish()

virtual int agora::rtc::IChannel::publish ( )
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):

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

◆ unpublish()

virtual int agora::rtc::IChannel::unpublish ( )
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).

Returns
  • 0: Success.
  • < 0: Failure.

◆ channelId()

virtual const char* agora::rtc::IChannel::channelId ( )
pure virtual

Gets the channel ID of the current IChannel object.

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

◆ getCallId()

virtual int agora::rtc::IChannel::getCallId ( agora::util::AString callId)
pure virtual

Retrieves the current call ID.

When a user joins a channel on a client, a callId is generated to identify the call from the client. Feedback methods, such as 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.

Parameters
callIdThe current call ID.
Returns
  • 0: Success.
  • < 0: Failure.

◆ renewToken()

virtual int agora::rtc::IChannel::renewToken ( const char *  token)
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.

Parameters
tokenPointer to the new token.
Returns
  • 0(ERR_OK): Success.
  • < 0: Failure.
    • -1(ERR_FAILED): A general error occurs (no specified reason).
    • -2(ERR_INALID_ARGUMENT): The parameter is invalid.
    • -7(ERR_NOT_INITIALIZED): The SDK is not initialized.

◆ setEncryptionSecret()

virtual int agora::rtc::IChannel::setEncryptionSecret ( const char *  secret)
pure virtual

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

Deprecated:
Deprecated as of v3.1.0. Use the enableEncryption instead.

All users in a channel must use the same encryption password. The encryption password is automatically cleared once a user leaves the channel.

If an encryption password is not specified, the encryption functionality will be disabled.

Note
  • Do not use this method for CDN live streaming.
  • For optimal transmission, ensure that the encrypted data size does not exceed the original data size + 16 bytes. 16 bytes is the maximum padding size for AES encryption.
Parameters
secretPointer to the encryption password.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setEncryptionMode()

virtual int agora::rtc::IChannel::setEncryptionMode ( const char *  encryptionMode)
pure virtual

Sets the built-in encryption mode.

Deprecated:
Deprecated as of v3.1.0. Use the enableEncryption instead.

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.

Note
Call the setEncryptionSecret method to enable the built-in encryption function before calling this method.
Parameters
encryptionModeThe set encryption mode:
  • "aes-128-xts": (Default) 128-bit AES encryption, XTS mode.
  • "aes-128-ecb": 128-bit AES encryption, ECB mode.
  • "aes-256-xts": 256-bit AES encryption, XTS mode.
  • "": When encryptionMode is set as NULL, the encryption mode is set as "aes-128-xts" by default.
Returns
  • 0: Success.
  • < 0: Failure.

◆ enableEncryption()

virtual int agora::rtc::IChannel::enableEncryption ( bool  enabled,
const EncryptionConfig config 
)
pure virtual

Enables/Disables the built-in encryption.

Since
v3.1.0

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

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

Note
  • If you enable the built-in encryption, you cannot use the RTMP streaming function.
  • Agora supports four encryption modes. If you choose an encryption mode (excepting SM4_128_ECB mode), you need to add an external encryption library when integrating the SDK. See the advanced guide Channel Encryption.
Parameters
enabledWhether to enable the built-in encryption:
  • true: Enable the built-in encryption.
  • false: Disable the built-in encryption.
configConfigurations of built-in encryption schemas. See EncryptionConfig.
Returns
  • 0: Success.
  • < 0: Failure.
    • -2(ERR_INVALID_ARGUMENT): An invalid parameter is used. Set the parameter with a valid value.
    • -4(ERR_NOT_SUPPORTED): The encryption mode is incorrect or the SDK fails to load the external encryption library. Check the enumeration or reload the external encryption library.
    • -7(ERR_NOT_INITIALIZED): The SDK is not initialized. Initialize the IRtcEngine instance before calling this method.

◆ registerPacketObserver()

virtual int agora::rtc::IChannel::registerPacketObserver ( IPacketObserver observer)
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.

Note
  • The size of the packet sent to the network after processing should not exceed 1200 bytes, otherwise, the packet may fail to be sent.
  • Ensure that both receivers and senders call this method, otherwise, you may meet undefined behaviors such as no voice and black screen.
  • When you use CDN live streaming, recording or storage functions, Agora doesn't recommend calling this method.
Parameters
observerThe registered packet observer. See IPacketObserver.
Returns
  • 0: Success.
  • < 0: Failure.

◆ registerMediaMetadataObserver()

virtual int agora::rtc::IChannel::registerMediaMetadataObserver ( IMetadataObserver observer,
IMetadataObserver::METADATA_TYPE  type 
)
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.

Note
  • Call this method before the joinChannel method.
  • This method applies to the LIVE_BROADCASTING channel profile.
Parameters
observerThe IMetadataObserver class. See the definition of IMetadataObserver for details.
typeSee METADATA_TYPE. The SDK supports VIDEO_METADATA (0) only for now.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setClientRole()

virtual int agora::rtc::IChannel::setClientRole ( CLIENT_ROLE_TYPE  role)
pure virtual

Sets the role of the user, such as a host or an audience (default), before joining a channel in the 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_BROADCASTING profile, when a user switches user roles after joining a channel, a successful setClientRole method call triggers the following callbacks:

Note
This method applies only to the LIVE_BROADCASTING profile.
Parameters
roleSets the role of the user. See CLIENT_ROLE_TYPE.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setRemoteUserPriority()

virtual int agora::rtc::IChannel::setRemoteUserPriority ( uid_t  uid,
PRIORITY_TYPE  userPriority 
)
pure virtual

Prioritizes a remote user's stream.

The SDK ensures the high-priority user gets the best possible stream quality.

Note
The Agora SDK supports setting serPriority as high for one user only.
Parameters
uidThe ID of the remote user.
userPrioritySets the priority of the remote user. See PRIORITY_TYPE.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setRemoteVoicePosition()

virtual int agora::rtc::IChannel::setRemoteVoicePosition ( uid_t  uid,
double  pan,
double  gain 
)
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.

Note
  • For this method to work, enable stereo panning for remote users by calling the enableSoundPositionIndication method before joining a channel.
  • This method requires hardware support. For the best sound positioning, we recommend using a stereo speaker.
Parameters
uidThe ID of the remote user.
panThe sound position of the remote user. The value ranges from -1.0 to 1.0:
  • 0.0: the remote sound comes from the front.
  • -1.0: the remote sound comes from the left.
  • 1.0: the remote sound comes from the right.
gainGain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setRemoteRenderMode()

virtual int agora::rtc::IChannel::setRemoteRenderMode ( uid_t  userId,
RENDER_MODE_TYPE  renderMode,
VIDEO_MIRROR_MODE_TYPE  mirrorMode 
)
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.

Note
  • Call this method after calling the setupRemoteVideo method to initialize the remote video view.
  • During a call, you can call this method as many times as necessary to update the display mode of the video view of a remote user.
Parameters
userIdThe ID of the remote user.
renderModeThe rendering mode of the remote video view. See RENDER_MODE_TYPE.
mirrorMode
  • The mirror mode of the remote video view. See VIDEO_MIRROR_MODE_TYPE.
  • Note: The SDK disables the mirror mode by default.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setDefaultMuteAllRemoteAudioStreams()

virtual int agora::rtc::IChannel::setDefaultMuteAllRemoteAudioStreams ( bool  mute)
pure virtual

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.

Note
If you want to resume receiving the audio stream, call muteRemoteAudioStream (false), and specify the ID of the remote user whose audio stream you want to receive. To receive the audio streams of multiple remote users, call muteRemoteAudioStream (false) as many times. Calling setDefaultMuteAllRemoteAudioStreams (false) resumes receiving the audio streams of subsequent users only.
Parameters
muteSets whether to receive/stop receiving all remote users' audio streams by default:
  • true: Stops receiving all remote users' audio streams by default.
  • false: (Default) Receives all remote users' audio streams by default.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setDefaultMuteAllRemoteVideoStreams()

virtual int agora::rtc::IChannel::setDefaultMuteAllRemoteVideoStreams ( bool  mute)
pure virtual

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.

Note
If you want to resume receiving the video stream, call muteRemoteVideoStream (false), and specify the ID of the remote user whose video stream you want to receive. To receive the video streams of multiple remote users, call muteRemoteVideoStream (false) as many times. Calling setDefaultMuteAllRemoteVideoStreams (false) resumes receiving the video streams of subsequent users only.
Parameters
muteSets whether to receive/stop receiving all remote users' video streams by default:
  • true: Stop receiving all remote users' video streams by default.
  • false: (Default) Receive all remote users' video streams by default.
Returns
  • 0: Success.
  • < 0: Failure.

◆ muteAllRemoteAudioStreams()

virtual int agora::rtc::IChannel::muteAllRemoteAudioStreams ( bool  mute)
pure virtual

Stops/Resumes receiving all remote users' audio streams.

Parameters
muteSets whether to receive/stop receiving all remote users' audio streams.
  • true: Stops receiving all remote users' audio streams.
  • false: (Default) Receives all remote users' audio streams.
Returns
  • 0: Success.
  • < 0: Failure.

◆ adjustUserPlaybackSignalVolume()

virtual int agora::rtc::IChannel::adjustUserPlaybackSignalVolume ( uid_t  userId,
int  volume 
)
pure virtual

Adjust the playback 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.

Note
  • Call this method after joining a channel.
  • This method adjusts the playback volume, which is the mixed volume for the specified remote user.
  • This method can only adjust the playback volume of one specified remote user at a time. If you want to adjust the playback volume of several remote users, call the method multiple times, once for each remote user.
Parameters
userIdThe user ID, which should be the same as the uid of joinChannel
volumeThe playback volume of the voice. The value ranges from 0 to 100:
  • 0: Mute.
  • 100: Original volume.
Returns
  • 0: Success.
  • < 0: Failure.

◆ muteRemoteAudioStream()

virtual int agora::rtc::IChannel::muteRemoteAudioStream ( uid_t  userId,
bool  mute 
)
pure virtual

Stops/Resumes receiving a specified remote user's audio stream.

Note
If you called the muteAllRemoteAudioStreams method and set mute as true to stop receiving all remote users' audio streams, call the muteAllRemoteAudioStreams method and set mute as false before calling this method. The muteAllRemoteAudioStreams method sets all remote audio streams, while the muteRemoteAudioStream method sets a specified remote audio stream.
Parameters
userIdThe user ID of the specified remote user sending the audio.
muteSets whether to receive/stop receiving a specified remote user's audio stream:
  • true: Stops receiving the specified remote user's audio stream.
  • false: (Default) Receives the specified remote user's audio stream.
Returns
  • 0: Success.
  • < 0: Failure.

◆ muteAllRemoteVideoStreams()

virtual int agora::rtc::IChannel::muteAllRemoteVideoStreams ( bool  mute)
pure virtual

Stops/Resumes receiving all video stream from a specified remote user.

Parameters
muteSets whether to receive/stop receiving all remote users' video streams:
  • true: Stop receiving all remote users' video streams.
  • false: (Default) Receive all remote users' video streams.
Returns
  • 0: Success.
  • < 0: Failure.

◆ muteRemoteVideoStream()

virtual int agora::rtc::IChannel::muteRemoteVideoStream ( uid_t  userId,
bool  mute 
)
pure virtual

Stops/Resumes receiving the video stream from a specified remote user.

Note
If you called the muteAllRemoteVideoStreams method and set mute as true to stop receiving all remote video streams, call the muteAllRemoteVideoStreams method and set mute as false before calling this method.
Parameters
userIdThe user ID of the specified remote user.
muteSets whether to stop/resume receiving the video stream from a specified remote user:
  • true: Stop receiving the specified remote user's video stream.
  • false: (Default) Receive the specified remote user's video stream.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setRemoteVideoStreamType()

virtual int agora::rtc::IChannel::setRemoteVideoStreamType ( uid_t  userId,
REMOTE_VIDEO_STREAM_TYPE  streamType 
)
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.

Parameters
userIdThe ID of the remote user sending the video stream.
streamTypeSets the video-stream type. See REMOTE_VIDEO_STREAM_TYPE.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setRemoteDefaultVideoStreamType()

virtual int agora::rtc::IChannel::setRemoteDefaultVideoStreamType ( REMOTE_VIDEO_STREAM_TYPE  streamType)
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.

Parameters
streamTypeSets the default video-stream type. See REMOTE_VIDEO_STREAM_TYPE.
Returns
  • 0: Success.
  • < 0: Failure.

◆ createDataStream()

virtual int agora::rtc::IChannel::createDataStream ( int *  streamId,
bool  reliable,
bool  ordered 
)
pure virtual

Creates a data stream.

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

Note
Set both the reliable and ordered parameters to true or false. Do not set one as true and the other as false.
Parameters
streamIdThe ID of the created data stream.
reliableSets whether or not the recipients are guaranteed to receive the data stream from the sender within five seconds:
  • true: The recipients receive the data stream from the sender within five seconds. If the recipient does not receive the data stream within five seconds, an error is reported to the application.
  • false: There is no guarantee that the recipients receive the data stream within five seconds and no error message is reported for any delay or missing data stream.
orderedSets whether or not the recipients receive the data stream in the sent order:
  • true: The recipients receive the data stream in the sent order.
  • false: The recipients do not receive the data stream in the sent order.
Returns
  • Returns 0: Success.
  • < 0: Failure.

◆ sendStreamMessage()

virtual int agora::rtc::IChannel::sendStreamMessage ( int  streamId,
const char *  data,
size_t  length 
)
pure virtual

Sends data stream messages to all users in a channel.

The SDK has the following restrictions on this method:

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

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.

Note
  • This method applies only to the 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.
  • Ensure that you have created the data stream using createDataStream before calling this method.
Parameters
streamIdThe ID of the sent data stream, returned in the createDataStream method.
dataThe sent data.
lengthThe length of the sent data.
Returns
  • 0: Success.
  • < 0: Failure.

◆ addPublishStreamUrl()

virtual int agora::rtc::IChannel::addPublishStreamUrl ( const char *  url,
bool  transcodingEnabled 
)
pure virtual

Publishes the local stream to a specified CDN live RTMP address. (CDN live only.)

The SDK returns the result of this method call in the onStreamPublished callback.

The addPublishStreamUrl method call triggers the onRtmpStreamingStateChanged callback on the local client to report the state of adding a local stream to the CDN.

Note
  • Ensure that the user joins the channel before calling this method.
  • Ensure that you enable the RTMP Converter service before using this function. See Prerequisites in the advanced guide Push Streams to CDN.
  • This method adds only one stream RTMP URL address each time it is called.
Parameters
urlThe CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes. The RTMP URL address must not contain special characters, such as Chinese language characters.
transcodingEnabledSets whether transcoding is enabled/disabled:
  • true: Enable transcoding. To transcode the audio or video streams when publishing them to CDN live, often used for combining the audio and video streams of multiple hosts in CDN live. If you set this parameter as true, ensure that you call the setLiveTranscoding method before this method.
  • false: Disable transcoding.
Returns

◆ removePublishStreamUrl()

virtual int agora::rtc::IChannel::removePublishStreamUrl ( const char *  url)
pure virtual

Removes an RTMP stream from the CDN.

This method removes the RTMP URL address (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 stream from the CDN.

Note
  • This method removes only one RTMP URL address each time it is called.
  • The RTMP URL address must not contain special characters, such as Chinese language characters.
Parameters
urlThe RTMP URL address to be removed. The maximum length of this parameter is 1024 bytes.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setLiveTranscoding()

virtual int agora::rtc::IChannel::setLiveTranscoding ( const LiveTranscoding transcoding)
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.

Note
  • Ensure that you enable the RTMP Converter service before using this function. See Prerequisites in the advanced guide Push Streams to CDN..
  • If you call the setLiveTranscoding method to set the transcoding setting for the first time, the SDK does not trigger the onTranscodingUpdated callback.
Parameters
transcodingSets the CDN live audio/video transcoding settings. See LiveTranscoding.
Returns
  • 0: Success.
  • < 0: Failure.

◆ addInjectStreamUrl()

virtual int agora::rtc::IChannel::addInjectStreamUrl ( const char *  url,
const InjectStreamConfig config 
)
pure virtual

Adds a voice or video stream URL address to the interactive live streaming.

The onStreamPublished 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:

  • The local client:
    • onStreamInjectedStatus , with the state of the injecting the online stream.
    • onUserJoined (uid: 666), if the method call is successful and the online media stream is injected into the channel.
  • The remote client:

    • onUserJoined (uid: 666), if the method call is successful and the online media stream is injected into the channel.
    Note
    • Ensure that you enable the RTMP Converter service before using this function. See Prerequisites in the advanced guide Push Streams to CDN.
    • This method applies to the Native SDK v2.4.1 and later.
    • This method applies to the LIVE_BROADCASTING profile only.
    • You can inject only one media stream into the channel at the same time.
    Parameters
    urlThe URL address to be added to the ongoing live streaming. Valid protocols are RTMP, HLS, and HTTP-FLV.
    • Supported audio codec type: AAC.
    • Supported video codec type: H264 (AVC).
    configThe InjectStreamConfig object that contains the configuration of the added voice or video stream.
    Returns
    • 0: Success.
    • < 0: Failure.
      • ERR_INVALID_ARGUMENT (2): The injected URL does not exist. Call this method again to inject the stream and ensure that the URL is valid.
      • ERR_NOT_READY (3): The user is not in the channel.
      • ERR_NOT_SUPPORTED (4): The channel profile is not LIVE_BROADCASTING. Call the setChannelProfile method and set the channel profile to LIVE_BROADCASTING before calling this method.
      • ERR_NOT_INITIALIZED (7): The SDK is not initialized. Ensure that the IChannel object is initialized before calling this method.

◆ removeInjectStreamUrl()

virtual int agora::rtc::IChannel::removeInjectStreamUrl ( const char *  url)
pure virtual

Removes the voice or video stream URL address from a live streaming.

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

Note
If this method is called successfully, the SDK triggers the onUserOffline callback and returns a stream uid of 666.
Parameters
urlPointer to the URL address of the added stream to be removed.
Returns
  • 0: Success.
  • < 0: Failure.

◆ startChannelMediaRelay()

virtual int agora::rtc::IChannel::startChannelMediaRelay ( const ChannelMediaRelayConfiguration configuration)
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.

Note
  • Call this method after the joinChannel method.
  • This method takes effect only when you are a host in a LIVE_BROADCASTING channel.
  • After a successful method call, if you want to call this method again, ensure that you call the stopChannelMediaRelay method to quit the current relay.
  • Contact sales.nosp@m.-us@.nosp@m.agora.nosp@m..io before implementing this function.
  • We do not support string user accounts in this API.
Parameters
configurationThe configuration of the media stream relay: ChannelMediaRelayConfiguration.
Returns
  • 0: Success.
  • < 0: Failure.

◆ updateChannelMediaRelay()

virtual int agora::rtc::IChannel::updateChannelMediaRelay ( const ChannelMediaRelayConfiguration configuration)
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.

Note
Call this method after the startChannelMediaRelay method to update the destination channel.
Parameters
configurationThe media stream relay configuration: ChannelMediaRelayConfiguration.
Returns
  • 0: Success.
  • < 0: Failure.

◆ stopChannelMediaRelay()

virtual int agora::rtc::IChannel::stopChannelMediaRelay ( )
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.

Note
If the method call fails, the SDK triggers the onChannelMediaRelayStateChanged 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.
Returns
  • 0: Success.
  • < 0: Failure.

◆ getConnectionState()

virtual CONNECTION_STATE_TYPE agora::rtc::IChannel::getConnectionState ( )
pure virtual

Gets the current connection state of the SDK.

Returns
CONNECTION_STATE_TYPE.