Public Member Functions | |
void | setRtcChannelEventHandler (IRtcChannelEventHandler eventHandler) |
IRtcChannelEventHandler | getEventHandler () |
abstract int | destroy () |
abstract String | channelId () |
abstract String | getCallId () |
abstract int | getConnectionState () |
abstract int | joinChannel (String token, String optionalInfo, int optionalUid, ChannelMediaOptions options) |
abstract int | joinChannelWithUserAccount (String token, String userAccount, ChannelMediaOptions options) |
abstract int | leaveChannel () |
abstract int | publish () |
abstract int | unpublish () |
abstract int | renewToken (String token) |
abstract int | setEncryptionSecret (String secret) |
abstract int | setEncryptionMode (String encryptionMode) |
abstract int | registerMediaMetadataObserver (IMetadataObserver observer, int type) |
abstract int | setClientRole (int role) |
abstract int | setRemoteUserPriority (int uid, int userPriority) |
abstract int | setRemoteVoicePosition (int uid, double pan, double gain) |
abstract int | setRemoteRenderMode (int uid, int renderMode, int mirrorMode) |
abstract int | setDefaultMuteAllRemoteAudioStreams (boolean muted) |
abstract int | setDefaultMuteAllRemoteVideoStreams (boolean muted) |
abstract int | muteAllRemoteAudioStreams (boolean muted) |
abstract int | adjustUserPlaybackSignalVolume (int uid, int volume) |
abstract int | muteRemoteAudioStream (int uid, boolean muted) |
abstract int | muteAllRemoteVideoStreams (boolean muted) |
abstract int | muteRemoteVideoStream (int uid, boolean muted) |
abstract int | setRemoteVideoStreamType (int uid, int streamType) |
abstract int | setRemoteDefaultVideoStreamType (int streamType) |
abstract int | createDataStream (boolean reliable, boolean ordered) |
abstract int | sendStreamMessage (int streamId, byte[] message) |
abstract int | addPublishStreamUrl (String url, boolean transcodingEnabled) |
abstract int | removePublishStreamUrl (String url) |
abstract int | setLiveTranscoding (LiveTranscoding transcoding) |
abstract int | addInjectStreamUrl (String url, LiveInjectStreamConfig config) |
abstract int | removeInjectStreamUrl (String url) |
abstract int | startChannelMediaRelay (ChannelMediaRelayConfiguration channelMediaRelayConfiguration) |
abstract int | stopChannelMediaRelay () |
abstract int | updateChannelMediaRelay (ChannelMediaRelayConfiguration channelMediaRelayConfiguration) |
abstract int | setRemoteVideoRenderer (int uid, IVideoSink render) |
The RtcChannel class.
void io.agora.rtc.RtcChannel.setRtcChannelEventHandler | ( | IRtcChannelEventHandler | eventHandler | ) |
Sets the channel event handler.
After setting the channel event handler, you can listen for channel events and receive the statistics of the corresponding RtcChannel instance.
eventHandler | The event handler of the RtcChannel instance: IRtcChannelEventHandler. |
IRtcChannelEventHandler io.agora.rtc.RtcChannel.getEventHandler | ( | ) |
Gets the channel event handler.
|
abstract |
Destroys the RtcChannel instance.
|
abstract |
Gets the channel ID of the current RtcChannel instance.
|
abstract |
Gets the current call ID.
|
abstract |
Gets the connection state of the SDK.
|
abstract |
Joins the channel with a user ID.
This method differs from the joinChannel method in the RtcEngine class in the following aspects:
RtcChannel::joinChannel | RtcEngine::joinChannel |
Does not contain the channelId parameter, because channelId is specified when creating the RtcChannel instance. | 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 RtcChannel instances and calling the joinChannel method of each instance. | 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. |
token | The token generated at your server:
|
optionalInfo | Additional information about the channel. This parameter can be set as null. Other users in the channel do not receive this information. |
optionalUid | 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. |
|
abstract |
Joins a channel with the user account.
This method differs from the joinChannelWithUserAccount method in the RtcEngine class in the following aspects:
RtcChannel::joinChannelWithUserAccount | RtcEngine::joinChannelWithUserAccount |
Does not contain the channelId parameter, because channelId is specified when creating the RtcChannel instance. | 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 RtcChannel instances and calling the joinChannelWithUserAccount method of each instance. | 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. |
token | The token generated at your server:
|
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.
|
options | The channel media options: ChannelMediaOptions. |
|
abstract |
Leaves the current channel.
A successful leaveChannel method call triggers the following callbacks:
|
abstract |
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):
|
abstract |
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).
|
abstract |
Renews the token when the current token expires.
In the following situations, the SDK decides that the current token has expired:
You should get a new token from your server and call this method to renew it. Failure to do so results in the SDK disconnecting from the Agora server.
token | The new token. |
|
abstract |
Enables built-in encryption with an encryption password before joining a channel.
All users in a channel must set the same encryption password. The encryption password is automatically cleared once a user leaves the channel. If the encryption password is not specified or set to empty, the encryption functionality is disabled.
secret | The encryption password. |
|
abstract |
Sets the built-in encryption mode.
The Agora SDK supports built-in encryption, which is set to aes-128-xts mode by default. Call this method to set the encryption mode 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.
setEncryptionSecret
to enable encryption.encryptionMode | Sets the encryption mode:
|
|
abstract |
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 live broadcast interactions, such as sending shopping links, digital coupons, and online quizzes.
observer | The IMetadataObserver class. |
type | The metadata type. Currently, the SDK supports VIDEO_METADATA(0) only.
|
|
abstract |
Sets the role of a user.
This method sets the role of a user, such as a host or an audience. In a Live-Broadcast channel, only a broadcaster can call the publish method in the RtcChannel class.
A successful call of this method triggers the following callbacks:
role | The role of the user:
|
|
abstract |
Sets the priority of a remote user's media stream.
Use this method with the setRemoteSubscribeFallbackOption method. If a remote video stream experiences the fallback, the SDK ensures the high-priority user gets the best possible stream quality.
uid | The ID of the remote user. |
userPriority | The priority of the remote user:
|
|
abstract |
Sets the sound position 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. |
|
abstract |
Updates the remote video display mode.
This method can be called multiple times during a call to change the display mode.
uid | ID of the remote user. |
renderMode | The remote video render mode:
|
mirrorMode | The remote video render mode:
|
|
abstract |
Sets whether to receive all remote audio streams by default.
muted | Determines whether to receive/stop receiving all remote audio streams by default:
|
|
abstract |
Sets whether to receive all remote video streams by default.
muted | Determines whether to receive/stop receiving all remote video streams by default:
|
|
abstract |
Stops/Resumes receiving all remote audio streams.
muted | Determines whether to receive/stop receiving all remote audio streams:
|
|
abstract |
Adjusts the playback volume of a specified remote user.
You can call this method as many times as necessary to adjust the playback volume of different remote users, or to repeatedly adjust the playback volume of the same remote user.
uid | ID of the remote user. |
volume | The playback volume of the specified remote user. The value ranges from 0 to 100:
|
|
abstract |
Stops/Resumes receiving the audio stream of the specified user.
uid | ID of the remote user whose audio stream you want to mute. |
muted | Determines whether to receive/stop receiving the audio stream of the specified user:
|
|
abstract |
Stops/Resumes receiving all remote video streams.
muted | Determines whether to receive/stop receiving all remote video streams:
|
|
abstract |
Stops/Resumes receiving the video stream of the specified user.
uid | ID of the remote user whose video stream you want to mute. |
muted | Determines whether to receive/stop receiving the video stream of the specified user:
|
|
abstract |
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-quality 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 the remote stream type to reduce the bandwidth and resources.
The aspect ratio of the low-quality 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-quality video stream.
The SDK reports the result of calling this method in the onApiCallExecuted callback.
uid | ID of the remote user sending the video stream. |
streamType | Sets the video stream type:
|
|
abstract |
Sets the default video-stream type of the remote video stream when the remote user sends dual streams.
streamType | Sets the video stream type:
|
|
abstract |
Creates a data stream.
Each user can create up to five data streams during the life cycle of the RtcChannel instance.
reliable | Sets whether or not the recipients are guaranteed to receive the data stream from the sender within five seconds:
|
ordered | Determines whether or not the recipients receive the data stream in the sent order:
|
reliable
and ordered
parameters to true
or false
. Do not set one as true
and the other as false
.
|
abstract |
Sends the data stream message.
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 onStreamMessageError callback on the remote client.
streamId | ID of the sent data stream returned by the createDataStream method. |
message | The message data in byte[]. |
|
abstract |
Publishes the local stream to the CDN.
This method call 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 format. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters. |
transcodingEnabled | Sets whether transcoding is enabled/disabled. If you set this parameter as true , ensure that you call the setLiveTranscoding method before this method.
|
|
abstract |
Removes an RTMP stream from the CDN.
This method removes the RTMP URL address (added by addPublishStreamUrl) from a CDN live stream. The SDK reports the result of this method call in the onRtmpStreamingStateChanged callback.
url | The RTMP URL address to be removed. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters. |
|
abstract |
Sets the video layout and audio settings for CDN live.
The SDK triggers the onTranscodingUpdated callback when you call this method to update the LiveTranscoding
class. If you call this method to set the LiveTranscoding
class for the first time, the SDK does not trigger the onTranscodingUpdated
callback.
transcoding | Sets the CDN live audio/video transcoding settings: LiveTranscoding. |
|
abstract |
Injects an online media stream to a Live-Broadcast channel.
If this method call succeeds, the server pulls the voice or video stream and injects it into a live channel. This applies to scenarios where all audience members in the channel can watch a live show and interact with each other.
Calling this method triggers the following callbacks:
url | The URL address to be added to the ongoing live broadcast. Valid protocols are RTMP, HLS, and FLV.
|
config | The LiveInjectStreamConfig object, which contains the configuration information for the added voice or video stream. |
|
abstract |
Removes the injected online media stream from a Live-Broadcast channel.
This method removes the URL address added by addInjectStreamUrl.
If you successfully remove the URL address from the Live-Broadcast, the SDK triggers the onUserJoined callback, with the stream uid of 666.
url | The URL address to be removed. |
|
abstract |
Starts to relay media streams across channels.
After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged and onChannelMediaRelayEvent callbacks, and these callbacks report the state and events of the media stream relay.
onChannelMediaRelayStateChanged
callback reports RELAY_STATE_RUNNING(2) and RELAY_OK(0), and the onChannelMediaRelayEvent
callback reports RELAY_EVENT_PACKET_SENT_TO_DEST_CHANNEL(4), the SDK starts relaying media streams between the original and the destination channel.onChannelMediaRelayStateChanged
callback returns RELAY_STATE_FAILURE(3), an exception occurs during the media stream relay.channelMediaRelayConfiguration | The configuration of the media stream relay: ChannelMediaRelayConfiguration. |
|
abstract |
Stops the media stream relay.
Once the relay stops, the broadcaster quits all the destination channels.
After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged callback. If the callback reports RELAY_STATE_IDLE(0) and RELAY_OK(0), the broadcaster successfully stops the relay.
onChannelMediaRelayStateChanged
callback with the RELAY_ERROR_SERVER_NO_RESPONSE(2) or RELAY_ERROR_SERVER_CONNECTION_LOST(8) state code. You can leave the channel using leaveChannel, and the media stream relay automatically stops.
|
abstract |
Updates the channels for media relay.
After the channel media relay starts, 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, the SDK triggers the onChannelMediaRelayEvent callback with the RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL(7) state code.
startChannelMediaRelay
method to update the destination channel.ChannelMediaRelayConfiguration
before calling this method. channelMediaRelayConfiguration | The media stream relay configuration: ChannelMediaRelayConfiguration. |
|
abstract |
Customizes the remote video renderer for the RtcChannel
object.
During real-time engagements, the Agora SDK enables the default video sink to render the video. In the multi-channel scenario, if you want to customize the video renderer, you can create a customized video sink using the IVideoSink class, and call setRemoteVideoRenderer
to add the customized sink into the RtcChannel
object.
uid | The ID of the remote user. |
render | The customized remote video renderer: IVideoSink. |