RtcEngine class provides main interface-related methods for applications to call.
IRtcEngineEx is the basic interface of the NERTC SDK. Creates an IRtcEngine object and calls the methods of this object, and you can activate the communication feature the NERTC SDK provides.
virtual int nertc::IRtcEngine::leaveChannel |
( |
| ) |
|
|
pure virtual |
Leaves the room.
Leaves a room for hang up or calls ended.
A user can call the leaveChannel method to end the call before the user makes another call.
After the method is called successfully, the onLeaveChannel callback is locally triggered, and the onUserLeave callback is remotely triggered.
- 注解
- The method is asynchronous call. Users cannot exit the room when the method is called and returned. After users exit the room, the SDK triggers the onLeaveChannel callback.
- If you call leaveChannel method and instantly call release method, the SDK cannot trigger onLeaveChannel callback.
- 返回
- 0: Success.
- Other values: Failure.
virtual void nertc::IRtcEngine::release |
( |
bool |
sync = true | ) |
|
|
pure virtual |
Destroys an NERtc instance to release resources.
This method releases all resources used by the NERTC SDK. In some cases, real-time audio and video communication is only needed upon your demands. If no RTC calls are required, you can call this method to release resources.
After you call the release method, other methods and callbacks supported by the SDK become unavailable. If you want to use RTC calls, you must create a new NERtc instance.
- 注解
- If you need to use IRtcEngine instance again that cannot be initialized after release, you need to createNERtcEngine after destroyNERtcEngine.
- 参数
-
[in] | sync | The value is true by default, which can only be set to true. The default setting indicates synchronization call of the instance. You must return before you release the resources and return the IRtcEngine object resources.
App cannot call the interface in the callbacks returned by the SDK. If not, deadlock occurs and the SDK can only retrieve related object resources before the callback is returned. The SDK automatically detects the deadlock, and changes the deadlock to asynchronous call. However, the asynchronous call consumes extra time. |
virtual int nertc::IRtcEngine::setupLocalVideoCanvas |
( |
NERtcVideoCanvas * |
canvas | ) |
|
|
pure virtual |
Sets local views.
This method is used to set the display information about the local video. The method is applicable for only local users. Remote users are not affected.
Apps can call this API operation to associate with the view that plays local video streams. During application development, in most cases, before joining a room, you must first call this method to set the local video view after the SDK is initialized.
- 注解
- If you use external rendering on the Mac platform, you must set the rendering before the SDK is initialized.
- 参数
-
[in] | canvas | The video canvas information. |
- 返回
- 0: Success.
- Other values: Failure.
virtual int nertc::IRtcEngine::switchChannel |
( |
const char * |
token, |
|
|
const char * |
channel_name |
|
) |
| |
|
pure virtual |
Switches to a room of audio and video call.
In live streaming, the audience can call this method to switch from the current room to another room.
After you switch to another room by calling the method, the local first receive the onLeaveChannel callback that the user leaves the room, and then receives the onJoinChanne callback that the user joins the new room. Remote clients receive the return from onUserLeave and onUserJoined.
- 注解
- The method applies to only the live streaming. The role is the audience in the RTC room. The room scene is set to live streaming by calling the setchannelprofile method, and the role of room members is set to audience by calling the setClientRole method.
- By default, after a room member switches to another room, the room member subscribes to audio streams from other members of the new room. In this case, data usage is charged and billing is updated. If you want to unsubscribe to the previous audio stream, you can call the subscribeRemoteAudio method with a value of false passed in.
- 参数
-
[in] | token | The certification signature used in authentication (NERTC Token). Valid values:
- Null. You can set the value to null in the debugging mode. We recommend you change to the default safe mode before your product is officially launched.
- NERTC Token acquired. In safe mode, the acquired token must be specified. If the specified token is invalid, users are unable to join a channel. We recommend that you use the safe mode.
|
[in] | channel_name | The room name that a user wants to switch to. |
- 返回
- 0: Success.
- Other values: Failure.