Adds a streaming task in a room.
After you call the method, the current user can receive the notification about the status of live streaming by calling Client.on("rtmp-state")
.
Deletes a push task.
Specifies the ID of a streaming task.
Destroys the Client object.
Gets current call information.
Obtains the status of network connection.
The method can be used in the following scenarios:
The connection between the SDK and the server has the following states:
-DISCONNECTED
: The client is disconnected. This state indicates that the SDK:
Client.join
before the client joins the room.Client.leave
.CONNECTING
: The network connection is being established. This state indicates that the SDK:Client.join
.CONNECTED
: The client is connected. This state indicates that the user has successfully joined the room and can publish or subscribe to media streams in the room.DISCONNECTING
: The client is disconnecting.Client.leave
to leave the room.Gets the audio stats of the local publishing stream.
Gets the video stats of the local publishing stream.
The media stream type.
Gets the audio stats of the subscribed remote stream.
Gets the video stats of the subscribed remote stream.
The media stream type.
Gets the stats of the connection to the sessions.
Gets the information about system power.
Gets the stats of the connection to the gateways.
Gets the local user ID.
If uid is specified in the join method, the specified ID is returned. If uid is not specified, the ID will automatically be assigned by YunXin server.
Joins the room.
If the specified room does not exist when you join the room, a room with the specified name is automatically created in the server provided by YunXin.
When you call this method to join a room, the Client.on("connection-state-change") callback will be triggered on the local client. After the user in the communication and the host in the live streaming join the room, the Client.on(" peer-online") callback will be triggered on the remote client.
Room settings.
Error codes:
Error code | Reason | Description |
---|---|---|
403 | netcall.g2 unsafe mode is closed, please contact business! | Token is not set in safe mode. You can get the NERTC Token by calling getToken, and use the token when you join the room. If your app is still in testing, you can switch the application to debug mode in the console. Token is not required when you join a room in debug mode. |
414 | check checksum error | Authentication fails. In most cases, the error occurs because an invalid token is used. |
Leaves a room.
When you call this method to leave a room, the Client.on("connection-state-change") callback will be triggered on the local client. After the user in the communication and the host in the live streaming leave the room, the Client.on(" peer-leave") callback will be triggered on the remote client.
Occurs when the role of the local user changes.
In live streaming, this callback will be triggered when the user role is switched, from host to audience, or from audience to host.
The role after the change.
A remote user publishes audio and video streams.
Occurs when the app has received remote audio and video streams.
This callback will be triggered after an audio and video stream published by a remote user is subscribed.
Occurs when the app has deleted the remote audio and video stream.
After the remote user calls the Client.unpublish method, this callback will be triggered.
This event will return the uid of the user with the highest volume in the current room.
The uid of the user with the highest volume.
This event returns the current user and volume in the room.
The user volume.
User ID.
This event indicates that a remote user or host has joined the room.
The callback will be triggered in the following scenarios:
The user ID of the remote user or the host.
This event indicates that the remote user or the host leaves the room.
The callback will be triggered in the following scenarios:
The user ID of the remote user or the host.
This event indicates that the remote user mutes the audio.
The remote user ID.
This event indicates that the remote user unmutes the audio.
The remote user ID.
This event indicates that the remote user has turned off the video during a video call.
The remote user ID.
This event indicates that the remote user turns on the video during a video call.
The remote user ID.
This event indicates that the remote user has paused screen sharing.
The remote user ID.
This event indicates that the remote user resumes screen sharing.
The remote user ID.
This event indicates that the local user is removed from the room.
The remote user ID.
This event indicates that the room is closed.
This event indicates that the local user stops screen sharing.
This event indicates the connection between the SDK and server changes"
The status after the change.
The status before the change.
An error occurs on the client. Error types include:
A warning is delivered on the client. Warnings:
Warning code.
Reasons.
The audio stream ends. The possible reason is that the device is unplugged.
The video stream ends. The possible reason is that the device is unplugged.
This event indicates that the streaming status has changed.
This event shows the uplink and downlink network quality of all members in the room.
This event shows the current exception events in the room.
Exception events are not errors. However, the events may cause quality problems for calls.
Fails to join the room because the specified media stream encryption key is inconsistent with the key specified by one or more members who join the room.
Reset the encryption key by calling Client.setEncryptionSecret.
Publishes local audio and video streams.
After you publish the audio and video stream, the Client.on("stream-added") callback is triggered on the remote client.
The stream that you want to publish.
Sets a room scene.
You can set a room scene for a call or live event. Different QoS policies are applied to different scenes.
Sets a room scene.
Valid values:
rtc
(default) communications: In this scenario, all users in the room can publish and receive audio and video streams. The setting is suitable for scenarios such as audio calls and group video calls.live
: Live streaming. This scenario has two user roles: host and audience, which can be set using setClientRole. The host can publish and receive audio and video streams, and the audience can receive the streams. The setting is suitable for scenarios such as chat rooms, live streaming, and interactive remote learning for large classes.Sets the user role. By default, a user joins a room as a host.
Before a user joins a room, the user can call this method to change the client role to audience. After a user joins a room, the user can call this method to switch the client role.
You can set the role to host or audience. The permissions of a host and an audience are different.
The user role. Valid values:
host
: The host in live streaming can publish and receive audio and video streams. If the user has published audio or video as before, the audio or video stream will be automatically resumed when the role is switched to host.audience
: The audience in live streaming can only receive audio and video streams. If the user role changes from host to audience, the client will automatically stop publishing audio and video streams.Sets Media stream encryption mode.
In scenarios with high security requirements such as finance, you can use this method to set the media stream encryption mode before you join the room.
-This method is used together with Client.setEncryptionSecret. Before you join the room, you must call Client.setEncryptionMode to set the media stream encryption scheme, and then call Client.setEncryptionSecret to set the secret. If the key is not specified, the media stream encryption cannot be enabled.
Sets media stream encryption key.
-This method is used together with Client.setEncryptionMode. Before you join the room, you must call Client.setEncryptionMode to set the media stream encryption scheme, and then call Client.setEncryptionSecret to set the secret. If the key is not specified, the media stream encryption cannot be enabled.
The encryption key of media streams. The key must be of STRING type and must be 1 to 128 characters in length. We recommend that you set the key to a string that contains only letters.
Sets the priority of media streams from a local user.
If a user has a high priority, the media stream from the user also has a high priority. In unreliable network connections, the SDK guarantees the quality of the media stream from users with a high priority.
Priority settings.
Sets to low streams or high streams.
If the publishing client enables the dual-stream mode, the client subscribes to the high-resolution video stream by default. You can also choose the high-resolution stream or low-resolution stream at the client that subscribes to the streams.
The specified audio and video stream to which you want to subscribe.
The stream type. A value of 0 indicates the low-resolution stream. A value of 1 indicates the high-resolution stream.
Subscribes to remote audio and video streams.
After you subscribe to the remote audio and video stream, the Client.on("stream-subscribed") callback will be triggered on the local client.
The source audio and video stream to which you want to subscribe.
Stops publishing local audio and video streams to the room.
After you stop publishing the audio and video stream, the Client.on("stream-removed") callback is triggered on the remote client.
Stream that you want to stop publishing.
The stream type.
Unsubscribe from remote audio and video streams.
After you unsubscribe from remote audio and video streams, the SDK will not receive remote audio and video streams.
The audio and video stream from which you want to unsubscribe.
The Client interface provides the core functions of audio and video calls, such as joining a room, publishing, and subscribing to audio and video streams.
You can use NERTC.createClient to create a Client object. The Client object points to a local or remote user during a call, and provides the core functions of YunXin NERTC SDK.