NERtc iOS SDK  V4.4.301
构造函数 | 所有成员列表
<INERtcEngine>协议 参考

The common interface of NERtcEngine. 更多...

#import <INERtcEngine.h>

类 <INERtcEngine> 继承关系图:
<INERtcEngineEx> NERtcEngine

构造函数

(NERtcConnectionStateType- connectionState
 Gets the connection status. 更多...
 
(int) - setupEngineWithContext:
 Creates an NERtcEngine instance and initializes the NERTC SDK. 更多...
 
(int) - joinChannelWithToken:channelName:myUid:completion:
 Joins an RTC room. 更多...
 
(int) - leaveChannel
 Leaves a room, such as hanging up or ending a call. 更多...
 
(int) - switchChannelWithToken:channelName:completion:
 Switches to a different RTC room. 更多...
 
(int) - enableLocalAudio:
 Enables or disables local audio capture. 更多...
 
(int) - enableLocalVideo:
 Specifies whether to enable local video capture. 更多...
 
(int) - setChannelProfile:
 Sets a room scene. 更多...
 
(int) - setLocalVideoConfig:
 Sets the video encoding profile. 更多...
 
(int) - setAudioProfile:scenario:
 Sets the audio encoding profile. 更多...
 
(int) - setupLocalVideoCanvas:
 Sets the local view. 更多...
 
(int) - setupRemoteVideoCanvas:forUserID:
 Sets views for remote users. 更多...
 
(int) - switchCamera
 Switches between the front and rear cameras. 更多...
 
(int) - setClientRole:
 Sets the role of a user in live streaming. 更多...
 
(int) - setParameters:
 Sets parameters for audio and video calls. 更多...
 

详细描述

The common interface of NERtcEngine.

函数文档

◆ connectionState

- (NERtcConnectionStateType) connectionState

Gets the connection status.

返回
The current network status is returned. For more information, see {@Link NERtcEngineEnum.NERtcConnectionStateType}.

◆ enableLocalAudio:

- (int) enableLocalAudio: (BOOL)  enabled

Enables or disables local audio capture.

When an app joins a room, the voice module is enabled by default.

The method does not affect receiving or playing back the remote audio stream. The enableLocalAudio(NO) method is suitable for scenarios where a user wants to receive the remote audio stream without sending audio streams to other users in the room.

注解
  • The enableLocalAudio method is different from muteLocalAudioStream. The enableLocalAudio method is used to enable local audio capture and processing whereas the muteLocalAudioStream method is used to stop or restart pushing the local audio stream.
  • The method enables the internal engine. The setting remains unchanged after the leaveChannel method is called.
  • Starting from V4.4.0, turning on or off local audio capture does not affect the playback of music files. You can still play music files by calling startAudioMixingWithOption after you set enableLocalAudio(NO).
参数
enabledThe option whether to enable local Audio capture.
返回
The value returned. A value of 0 indicates that the operation is successful.

◆ enableLocalVideo:

- (int) enableLocalVideo: (BOOL)  enabled

Specifies whether to enable local video capture.

注解
  • You can call this method before or after you join a room.
  • After you enable or disable local video capture, the onNERtcEngineUserVideoDidStartWithUserID or onNERtcEngineUserVideoDidStop callback is triggered on a remote client.
参数
enabledThe option whether to enable local video capture.
返回
The value returned. A value of 0 indicates that the operation is successful.

◆ joinChannelWithToken:channelName:myUid:completion:

- (int) joinChannelWithToken: (NSString *)  token
channelName: (NSString *)  channelName
myUid: (uint64_t)  uId
completion: (NERtcJoinChannelCompletion completion 

Joins an RTC 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.

  • 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.
  • If you join a room by calling this method, onNERtcEngineUserDidJoinWithUserID is triggered on a remote client.
  • 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 mute method.
  • In live streaming, the audience can switch rooms by calling switchChannelWithToken.
参数
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.
channelNameThe name of the room. Users that use the same name can join the same room. < br>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, !#$%&()+-:;≤.,>? @[]^_{|}~”
uidThe unique identifier of a user. The uid of each user in a room must 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 NERtcJoinChannelCompletion. The application layer must keep and maintain the return value. The SDK does not maintain the return value.
completionThe callback when the operation is complete.
返回
The value returned. A value of 0 indicates that the operation is performed.

◆ leaveChannel

- (int) leaveChannel

Leaves a room, such as hanging up or ending a call.

A user must call the leaveChannel method to end the call before the user makes another call.

After you leave the room by calling the method, the onNERtcEngineDidLeaveChannelWithResult callback is triggered on the local client, and the onNERtcEngineUserDidLeaveWithUserID callback is triggered on a remote client.

返回
The value returned. A value of 0 indicates that the operation is successful.

◆ setAudioProfile:scenario:

- (int) setAudioProfile: (NERtcAudioProfileType profile
scenario: (NERtcAudioScenarioType scenario 

Sets the audio encoding profile.

注解
You must call this method before you call the joinChannel method. Otherwise, the settings of joinChannel do not take effect.
参数
profileThe sample rate, bitrate, encoding mode, and the number of channels. For more information, see NERtcAudioProfileType.
scenarioThe type of an audio scenario. For more information, see NERtcAudioScenarioType.
返回
The value returned. A value of 0 indicates that the operation is successful.

◆ setChannelProfile:

- (int) setChannelProfile: (NERtcChannelProfileType channelProfile

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 call the method before you join a room. If you have joined a room, you cannot set the room scene.
参数
channelProfileThe room scene. For more information, see NERtcEngineEnum.NERtcChannelProfileType.
返回
The value returned. A value of 0 indicates that the operation is successful.

◆ setClientRole:

- (int) setClientRole: (NERtcClientRole role

Sets the role of a user in live streaming.

The method sets the role to host or audience. The permissions of a host and an audience 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 the audiences. After a user joins a room, the user can call this method to switch the client role.
  • If the user switches the role to the audiences, the SDK automatically closes the audio and video devices.
参数
roleThe role of a user. For more information, see NERtcClientRole.
返回
The value returned. A value of 0 indicates that the operation is successful.

◆ setLocalVideoConfig:

- (int) setLocalVideoConfig: (NERtcVideoEncodeConfiguration *)  config

Sets the video encoding profile.

注解

  • The audio-only SDK disables this API. If you need to use the API, you can download the standard SDK from the official website of YunXin and replace the audio-only SDK.
  • You can call this method before or after you join the room.
  • After the setting is configured. The setting takes effect the next time local video is enabled.
  • Each profile has a set of video parameters, such as resolution, frame rate, and bitrate. All the specified values of the parameters are the maximum values in optimal conditions. If the video engine cannot use the maximum value of resolution, frame rate, or bitrate due to unreliable network conditions, the value closest to the maximum value is used.
参数
configThe video encoding profile. For more information, see NERtcVideoEncodeConfiguration.
返回
The value returned. A value of 0 indicates that the operation is successful.

◆ setParameters:

- (int) setParameters: (NSDictionary *)  parameters

Sets parameters for audio and video calls.

注解

  • You can call the method only after you join a room. When you use kNERtcKeyVideoPreferHWEncode and kNERtcKeyVideoPreferHWDecode, you must call this method before you initialize the SDK.
  • This method provides a technology preview or personalized features. If you want to use this API, contact technical support.
参数
parametersThe parameters that you want to specify. For more information about the key parameters, see the definition in NERtcEngineBase.h.
返回
The value returned. A value of 0 indicates that the operation is successful.

◆ setupEngineWithContext:

- (int) setupEngineWithContext: (NERtcEngineContext *)  context

Creates an NERtcEngine instance and initializes the NERTC SDK.

注解
  • Before you call other APIs, you must first call this method to create and initialize an NERtc instance.
  • Apps that use the same AppKey can make audio or video calls, or perform live events in the same room.
  • One AppKey can be used to create only one NERtc instance. If you want to change the AppKey, you must first delete the current instance by calling the destroyEngine method, then, call this method to create a new instance.
  • If you do not need the NERtc instance, you can delete the instance by calling the destroyEngine method.
参数
contextThe RTC engine context object passed. For more information, see NERtcEngineContext.
返回
The value returned. A value of 0 indicates that the operation is successful.

◆ setupLocalVideoCanvas:

- (int) setupLocalVideoCanvas: (NERtcVideoCanvas *_Nullable)  canvas

Sets the local view.

This method is used to set the display information about the local video. The method is applicable only to 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.

注解
The audio-only SDK disables this API. If you need to use the API, you can download the standard SDK from the official website of YunXin and replace the audio-only SDK.
参数
canvasThe video canvas. For more information, see NERtcVideoCanvas. If you want to delete the canvas, you can set the value to nil.
返回
The value returned. A value of 0 indicates that the operation is successful.

◆ setupRemoteVideoCanvas:forUserID:

- (int) setupRemoteVideoCanvas: (NERtcVideoCanvas *)  canvas
forUserID: (uint64_t)  userID 

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 displayed locally. The method affects only the video screen viewed by local users.

注解
  • The audio-only SDK disables this API. If you need to use the API, you can download the standard SDK from the official website of YunXin and replace the audio-only SDK.
  • If the user ID is not retrieved, you can set the user ID after the app receives a message delivered when the onNERtcEngineUserDidJoinWithUserID 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.
参数
userIDThe ID of a remote user.
canvasThe video window. if you want to delete the canvas, you can set the value to nil.
返回
The value returned. A value of 0 indicates that the operation is successful.

◆ switchCamera

- (int) switchCamera

Switches between the front and rear cameras.

Make sure that you call this method after the camera starts. For example, you can call this method after you call startPreview or joinChannel.

注解
The audio-only SDK disables this API. If you need to use the API, you can download the standard SDK from the official website of YunXin and replace the audio-only SDK.
返回
The value returned. A value of 0 indicates that the operation is successful.

◆ switchChannelWithToken:channelName:completion:

- (int) switchChannelWithToken: (NSString *)  token
channelName: (NSString *)  channelName
completion: (NERtcJoinChannelCompletion completion 

Switches to a different RTC room.

In live streaming, the audience can call this method to switch from the current room to another room.

After you successfully switch to the destination room, the local client receives a message sent by onNERtcEngineDidLeaveChannelWithResult. The remote user receives messages sent by onNERtcEngineUserDidLeaveWithUserID and onNERtcEngineUserDidJoinWithUserID.

注解
  • 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 from the previous audio stream, you can call the subscribeRemoteAudio method.
  • The method applies to only 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 the audiences by calling the setClientRole method.
参数
tokenThe certification signature generated in the server and used for authentication. 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 channel. We recommend that you use the safe mode.
channelNameThe room name that a user wants to switch to.
completionThe callback when the operation is complete.
返回
The value returned. A value of 0 indicates that the operation is successful. A value that is less than 0 indicates that The operation fails.

该协议的文档由以下文件生成: