The ID of RtcChannel
Injects an online media stream to live interactive streaming.
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:
StreamInjectedStatus
, with the state of injecting the media stream.UserJoined
(uid: 666), if the method call succeeds and the online
media stream is injected into the channel.UserJoined
(uid: 666), if the method call succeeds and the online
media stream is injected into the channel.Warning
Agora will soon stop the service for injecting online media streams on the client. If you have not implemented this service, Agora recommends that you do not use it.
Note
LiveBroadcasting
channel.The URL address to be added to the ongoing live interactive streaming. Valid protocols are RTMP, HLS, and FLV.
The LiveInjectStreamConfig
object, which contains the configuration information for the added voice or video stream.
LiveBroadcasting
. Call the setChannelProfile
method and set the channel profile to LiveBroadcasting
before calling this method.RtcEngine
instance before calling this method.Adds the RtcChannelEvents
handler.
After setting the RtcChannelEvents
handler, you can listen for channel events and receive the statistics of the corresponding RtcChannel
instance.
The event type.
The RtcChannelEvents
handler.
Publishes the local stream to a specified CDN streaming URL.
After calling this method, you can push media streams in RTMP or RTMPS protocol to the CDN.
This method call triggers the RtmpStreamingStateChanged
callback on the local client to report the state of adding a local stream to the CDN.
Note
LiveBroadcasting
channel.The CDN streaming URL in the RTMP or RTMPS format. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters.
Whether to enable transcoding. If you set this parameter as true,
ensure that you call the setLiveTranscoding
method before this method.
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.false
: Disable transcoding.RtcEngine
when publishing the stream.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.
Note
ID of the remote user.
The playback volume of the specified remote user. The value ranges from 0 to 100:
Creates a data stream.
Each user can create up to five data streams during the life cycle of the RtcChannel
instance.
Note
Set both the reliable
and ordered
parameters to true
or false
. Do not set one as true
and the other as false
.
Sets whether the recipients are guaranteed to receive the data stream from the sender within five seconds.
true
: The recipients receive the data from the sender within five seconds. If the recipient does
not receive the data within five seconds, the SDK triggers the StreamMessageError
callback and returns an error code.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.Determines whether the recipients receive the data stream in the sent order.
true
: The recipients receive the data in the sent order.false
: The recipients do not receive the data in the sent order.Destroys the RtcChannel
instance.
RtcChannel
instance is not initialized before calling this method.Enables/Disables the built-in encryption.
Whether to enable the built-in encryption.
true
: Enable the built-in encryption.false
: Disable the built-in encryption.Configurations of built-in encryption schemas. See EncryptionConfig
.
RtcEngine
instance before calling this method.Gets the current call ID.
Gets the network connection state of the SDK.
Joins the channel with a user ID.
Note
RtcEngine
instance.Once the user joins the channel (switches to another 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.
The token generated at your server.
Additional information about the channel. This parameter can be set as null. Other users in the channel do not receive this information.
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 JoinChannelSuccess
callback. The app must maintain this user ID.
The channel media options.
RtcChannel
object with the same channel name.RtcChannel
object.Joins a channel with the user account.
Note
RtcEngine
instance.Once the user joins the channel (switches to another 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.
The token generated at your server.
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.
The channel media options.
Leaves the current channel.
A successful call of this method triggers the following callbacks:
LeaveChannel
.UserOffline
, if the user leaving the channel is in a Communication
channel, or is a host in a LiveBroadcasting
channel.Stops/Resumes receiving all remote audio streams.
Determines whether to receive/stop receiving all remote audio streams:
true
: Stop receiving all remote audio streams.false
: (Default) Receive all remote audio streams.Stops/Resumes receiving all remote video streams.
Determines whether to receive/stop receiving all remote video streams:
true
: Stop receiving all remote video streams.false
: (Default) Receive all remote video streams.Stops/Resumes receiving the audio stream of the specified user.
ID of the remote user whose audio stream you want to mute.
Determines whether to receive/stop receiving the audio stream of the specified user:
true
: Stop receiving the audio stream of the user.false
: (Default) Receive the audio stream of the user.Stops/Resumes receiving the video stream of the specified user.
ID of the remote user whose video stream you want to mute.
Determines whether to receive/stop receiving the video stream of the specified user:
true
: Stop receiving the video stream of the user.false
: (Default) Receive the video stream of the user.Publishes the local stream to the channel.
You must keep the following restrictions in mind when calling this method.
Otherwise, the SDK returns the Refused(-5)
:
RtcChannel
instance.LiveBroadcasting
channel, only a host can call this method. To switch the client role, call setClientRole
of the current RtcChannel
instance.Registers the metadata observer.
A successful call of this method triggers the setMaxMetadataSize
method.
This method enables you to add synchronized metadata in the video stream for more diversified live streaming interactions, such as sending shopping links, digital coupons, and online quizzes.
Note
joinChannel
method.LiveBroadcasting
profile only.Removes all the RtcChannelEvents
handlers.
The event type.
Removes the injected online media stream from a LiveBroadcasting
channel.
This method removes the URL address added by addInjectStreamUrl
.
If you successfully remove the URL address from the live interactive streaming, the SDK triggers the
UserJoined
callback, with the stream uid of 666.
Warning
Agora will soon stop the service for injecting online media streams on the client. If you have not implemented this service, Agora recommends that you do not use it.
The URL address to be removed.
Removes the RtcChannelEvents
handler.
For callback events that you only want to listen for once, call this method to remove the specific RtcEngineEvents
objects after you have received them.
The event type.
The RtcChannelEvents
handler.
Removes an RTMP or RTMPS stream from the CDN.
This method removes the CDN streaming URL (added by addPublishStreamUrl
) from a CDN live stream.
The SDK reports the result of this method call in the RtmpStreamingStateChanged
callback.
Note
LiveBroadcasting
channel.The CDN streaming URL 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.
Renews the token when the current token expires.
In the following situations, the SDK decides that the current token has expired:
TokenPrivilegeWillExpire
callback, orConnectionStateChanged
callback reports the TokenExpired(9)
error.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.
The new token.
Sends the metadata.
The metadata to be sent.
Sends the data stream message.
The SDK has the following restrictions on this method:
A successful call of this method triggers the StreamMessage
callback on the remote client, from which the remote user gets the stream message.
A failed call of this method triggers the StreamMessageError
callback on the remote client.
ID of the sent data stream returned by the createDataStream
method.
The message data.
Sets the role of a user in live interactive 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:
ClientRoleChanged
.UserJoined
or UserOffline(BecomeAudience)
.Note
LiveBroadcasting
profile only (when the profile
parameter in setChannelProfile
is set as LiveBroadcasting
).The role of a user in interactive live streaming. See ClientRole.
The detailed options of a user, including user level. See ClientRoleOptions.
Sets whether to receive all remote audio streams by default.
Determines whether to receive/stop receiving all remote audio streams by default:
true
: Stop receiving all remote audio streams by default.false
: (Default) Receive all remote audio streams by default.Sets whether to receive all remote video streams by default.
Determines whether to receive/stop receiving all remote video streams by default:
true
: Stop receiving all remote video streams by default.false
: (Default) Receive all remote video streams by default.Sets the built-in encryption mode.
Sets the encryption mode.
Enables built-in encryption with an encryption password before joining a channel.
The encryption password.
Sets the video layout and audio settings for CDN live.
The SDK triggers the TranscodingUpdated
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 TranscodingUpdated
callback.
Note
LiveBroadcasting
channel.addPublishStreamUrl
method.Sets the CDN live audio/video transcoding settings.
Sets the maximum size of the metadata.
Buffer size of the sent or received metadata.
Sets the default video-stream type of the remote video stream when the remote user sends dual streams.
Sets the default video-stream type.
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.
Note The Agora SDK supports setting userPriority as high for one user only.
The ID of the remote user.
The priority of the remote user.
Sets the video stream type of the remote video stream when the remote user sends dual streams. 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.
enableDualStreamMode
method,
the SDK receives the high-video stream by default. You can use this method to switch to the low-video stream.ID of the remote user sending the video stream.
Sets the video-stream type.
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.
Note
enableSoundPositionIndication
method before joining a channel.The ID of the remote user.
The sound position of the remote user. The value ranges from -1.0 to 1.0:
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.
Starts to relay media streams across channels.
After a successful method call, the SDK triggers the ChannelMediaRelayStateChanged
and ChannelMediaRelayEvent
callbacks,
and these callbacks report the state and events of the media stream relay.
If the ChannelMediaRelayStateChanged
callback reports Running(2)
and None(0)
, and
the ChannelMediaRelayEvent
callback
reports SentToDestinationChannel(4)
, the SDK starts relaying media streams between the original and the destination channel.
If the ChannelMediaRelayStateChanged
callback returns Failure(3)
, an exception occurs during the media stream relay.
Note
LiveBroadcasting
channel.stopChannelMediaRelay
method to quit the current relay.The configuration of the media stream relay.
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 ChannelMediaRelayStateChanged
callback. If the callback reports Idle(0)
and
None(0)
, the host successfully stops the relay.
Note
ChannelMediaRelayStateChanged
callback with
the ServerNoResponse(2)
or ServerConnectionLost(8)
state code.
You can leave the channel using leaveChannel
, and the media stream relay automatically stops.Stops publishing a stream to the channel.
If you call this method in a channel where you are not publishing streams, the SDK returns Refused(-5)
.
Unregisters the metadata observer.
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 this method.
After a successful method call, the SDK triggers the ChannelMediaRelayEvent
callback with
the UpdateDestinationChannel(7)
state code.
Note
startChannelMediaRelay
method to update the destination channel.The media stream relay configuration.
Creates and gets an RtcChannel
instance.
To join more than one channel, call this method multiple times to create as many RtcChannel
instances as needed,
and call the joinChannel
method of each created RtcChannel
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.
The unique channel name for the Agora RTC session in the string format. The string length must be less than 64 bytes. Supported character scopes are:
Note
Refused(-5)
.RtcChannel
instance, if the method call succeeds.Refused(-5)
, if you set channelId as the empty string "".Destroys all RtcChannel
instances.
The RtcChannel class.