NERtc Windows SDK  V4.4.301
Public 成员函数 | 所有成员列表
nertc::IRtcEngine类 参考abstract

#include <nertc_engine.h>

类 nertc::IRtcEngine 继承关系图:
nertc::IRtcEngineEx

Public 成员函数

virtual int initialize (const NERtcEngineContext &context)=0
 
virtual void release (bool sync=true)=0
 
virtual int setClientRole (NERtcClientRole role)=0
 
virtual int setChannelProfile (NERtcChannelProfileType profile)=0
 
virtual int joinChannel (const char *token, const char *channel_name, uid_t uid)=0
 
virtual int switchChannel (const char *token, const char *channel_name)=0
 
virtual int leaveChannel ()=0
 
virtual int queryInterface (NERtcInterfaceIdType iid, void **inter)=0
 
virtual int enableLocalAudio (bool enabled)=0
 
virtual int setupLocalVideoCanvas (NERtcVideoCanvas *canvas)=0
 
virtual int setupRemoteVideoCanvas (uid_t uid, NERtcVideoCanvas *canvas)=0
 
virtual int enableLocalVideo (bool enabled)=0
 
virtual int subscribeRemoteVideoStream (uid_t uid, NERtcRemoteVideoStreamType type, bool subscribe)=0
 

详细描述

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.

成员函数说明

◆ enableLocalAudio()

virtual int nertc::IRtcEngine::enableLocalAudio ( bool  enabled)
pure virtual

Enables or disables local audio capture.

The method can enable the local audio again to start local audio capture and processing.

The method does not affect receiving or playing remote audio and audio streams.

注解
The method is different from muteLocalAudioStream in:.
The method enables the internal engine, which is still valid after you call leaveChannel.
参数
[in]enabled
  • true: Enables local audio feature again. You can enable local audio capture or processing by default.
  • false: Disables local audio feature again. You can stop local audio capture or processing.
返回
  • 0: Success.
  • Other values: Failure.

◆ enableLocalVideo()

virtual int nertc::IRtcEngine::enableLocalVideo ( bool  enabled)
pure virtual

Enables or disables local audio capture and rendering.

The method enables local video capture.

注解
  • You can call this method before or after you join a room.
  • The method enables the internal engine, which is still valid after you call leaveChannel.
  • After local video capture is successfully enabled or disabled, the onUserVideoStop or onUserVideoStart callback is remotely triggered.
参数
[in]enabledspecifies whether to enable local video capture and rendering.
  • true: Enables the local video capture and rendering.
  • false: Disables the local camera device. After local video capture is disabled, remote users cannot receive video streams from local users. However, local users can still receive video streams from remote users. If the setting is false, the local camera is not required to call the method.
返回
  • 0: Success.
  • Other values: Failure.

◆ initialize()

virtual int nertc::IRtcEngine::initialize ( const NERtcEngineContext context)
pure virtual

Initializes the NERTC SDK service.

After calling the createNERtcEngine to create IRtcEngine object, you must call the method to initialize before calling other methods. After successfully initializing, the audio and video call mode is enabled by default.

警告
  • Callers must use the same AppKey to make audio or video calls.
  • One IRtcEngine instance object must share the same App Key. If you need to change the AppKey, you must first call release to destroy the current instance, and then call the method to create a new instance.
参数
[in]contextindicates the passed RTC engine context object. NERtcEngineContext.
返回
  • 0: Success.
  • Other values: Failure.

◆ joinChannel()

virtual int nertc::IRtcEngine::joinChannel ( const char *  token,
const char *  channel_name,
uid_t  uid 
)
pure virtual

Joins a channel of audio and video call.

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.

  • After you join a room by calling the relevant method supported by the SDK, users in the same room can make audio or video calls. Users that join the same room can start a group chat. Apps that use different AppKeys cannot communicate with each other.
  • After the method is called successfully, the onJoinChannel callback is locally triggered, and the onUserJoined callback is remotely triggered.
  • If you join a room, you subscribe to the audio streams from other users in the same room by default. In this case, the data usage is billed. To unsubscribe, you can call the setParameters method.
  • In live streaming, audiences can switch channels by calling switchChannel.
注解
The ID of each user must be unique.
参数
[in]tokenThe certification signature used in authentication (NERTC Token). Valid values:
  • Null. You can set the value to null in the debugging mode. This poses a security risk. We recommend that you contact your business manager to 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 room. We recommend that you use the safe mode.
[in]channel_nameThe name of the room. Users that use the same name can join the same room. The name must be of STRING type and must be 1 to 64 characters in length. The following 89 characters are supported: a-z, A-Z, 0-9, space, !#$%&()+-:;≤.,>? @[]^_{|}~”.
[in]uidThe unique identifier of a user. The uid of each user in a room must be unique.
uid is optional. The default value is 0. If the uid is not specified (set to 0), the SDK automatically assigns a random uid and returns the uid in the callback of onJoinChannel. The application layer must keep and maintain the return value. The SDK does not maintain the return value.
返回
  • 0: Success.
  • Other values: Failure.

◆ leaveChannel()

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.

◆ queryInterface()

virtual int nertc::IRtcEngine::queryInterface ( NERtcInterfaceIdType  iid,
void **  inter 
)
pure virtual

Gets the pointer of device administrators object.

参数
[in]iidThe iid of interface preferred.
[in]interThe pointer indicates DeviceManager object.
返回
  • 0: Success.
  • Other values: Failure.

◆ release()

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]syncThe 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.

◆ setChannelProfile()

virtual int nertc::IRtcEngine::setChannelProfile ( NERtcChannelProfileType  profile)
pure virtual

Sets a room scene.

You can set a room scene for a call or live event. Different QoS policies are applied to different scenes.

注解
You must set the profile after joining a call. The setting is invalid after the call ends.
参数
[in]profileSets the room scene. For more information, see NERtcChannelProfileType.
返回
  • 0: Success.
  • Other values: Failure.

◆ setClientRole()

virtual int nertc::IRtcEngine::setClientRole ( NERtcClientRole  role)
pure virtual

Sets the role of a user in live streaming.

The method sets the role to host or audience. The permissions of a host and a viewer are different.

  • A host has the permissions to open or close a camera, publish streams, call methods related to publishing streams in interactive live streaming. The status of the host is visible to the users in the room when the host joins or leaves the room.
  • The audience has no permissions to open or close a camera, call methods related to publishing streams in interactive live streaming, and is invisible to other users in the room when the user that has the audience role joins or leaves the room.
注解
  • 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. Users can switch the role of a user through the interface after joining the room.
  • If the user switches the role to audience, the SDK automatically closes the audio and video devices.
参数
[in]roleThe role of a user. NERtcClientRole.
返回
  • 0: Success.
  • Other values: Failure.

◆ setupLocalVideoCanvas()

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]canvasThe video canvas information.
返回
  • 0: Success.
  • Other values: Failure.

◆ setupRemoteVideoCanvas()

virtual int nertc::IRtcEngine::setupRemoteVideoCanvas ( uid_t  uid,
NERtcVideoCanvas canvas 
)
pure virtual

Sets views for remote users.

This method is used to associate remote users with display views and configure the rendering mode and mirror mode for remote views that are displayed locally. The method affects only video display viewed by local users.

注解
  • You need to specify the uid of remote video when the interface is called. In general cases, the uid can be set before users join the room.
  • If the user ID is not retrieved, the App calls this method after the onUserJoined event is triggered. To disassociate a specified user from a view, you can leave the canvas parameter empty.
  • After a user leaves the room, the association between a remote user and the view is cleared.
参数
[in]uidThe ID of a remote user.
[in]canvasThe video canvas information.
返回
  • 0: Success.
  • Other values: Failure.

◆ subscribeRemoteVideoStream()

virtual int nertc::IRtcEngine::subscribeRemoteVideoStream ( uid_t  uid,
NERtcRemoteVideoStreamType  type,
bool  subscribe 
)
pure virtual

Subscribes or unsubscribes video streams from specified remote users.

  • After a user joins a room, the video streams from remote users are not subscribed by default. If you want to view video streams from specified remote users, you can call this method to subscribe to the video streams from the user when the user joins the room or publishes the video streams.
  • This method can be called only if a user joins a room.
参数
[in]uidThe user ID.
[in]typeThe type of the subscribed video streams. NERtcRemoteVideoStreamType.
[in]subscribe
  • true: Subscribes to specified video streams. This is the default value.
  • false: Not subscribing to specified video streams.
返回
  • 0: Success.
  • Other values: Failure.

◆ switchChannel()

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]tokenThe 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_nameThe room name that a user wants to switch to.
返回
  • 0: Success.
  • Other values: Failure.

该类的文档由以下文件生成: