NERtc Android SDK  V4.5.0
Public Member Functions | Static Public Member Functions | List of all members
com.netease.lava.nertc.sdk.NERtc Class Referenceabstract
Inheritance diagram for com.netease.lava.nertc.sdk.NERtc:
com.netease.lava.nertc.sdk.NERtcEx

Public Member Functions

abstract void init (Context context, String appkey, NERtcCallback callback, NERtcOption option) throws Exception
 
abstract void release ()
 
abstract int joinChannel (String token, String channelName, long uid)
 
abstract int leaveChannel ()
 
abstract int enableLocalAudio (boolean enable)
 
abstract int subscribeRemoteAudioStream (long uid, boolean subscribe)
 
abstract int subscribeAllRemoteAudioStreams (boolean subscribe)
 
abstract int setAudioProfile (int profile, int scenario)
 
abstract int setLocalVideoConfig (NERtcVideoConfig videoConfig)
 
abstract int setCameraCaptureConfig (NERtcCameraCaptureConfig captureConfig)
 
abstract int startVideoPreview ()
 
abstract int stopVideoPreview ()
 
abstract int setupLocalVideoCanvas (IVideoRender render)
 
abstract int setupRemoteVideoCanvas (IVideoRender render, long uid)
 
abstract int enableLocalVideo (boolean enable)
 
abstract int subscribeRemoteVideoStream (long uid, NERtcRemoteVideoStreamType streamType, boolean subscribe)
 
abstract void setParameters (NERtcParameters params) throws IllegalArgumentException
 

Static Public Member Functions

static NERtc getInstance ()
 
static NERtcVersion version ()
 
static List< String > checkPermission (Context context)
 

Detailed Description

NERtc

Member Function Documentation

◆ checkPermission()

static List<String> com.netease.lava.nertc.sdk.NERtc.checkPermission ( Context  context)
static

Checks permissions for media devices that are used to make audio and video calls.

Parameters
contextspecifies the context parameter.
Returns
unauthorized permissions are returned.

◆ enableLocalAudio()

abstract int com.netease.lava.nertc.sdk.NERtc.enableLocalAudio ( boolean  enable)
abstract

Enables or disables local audio capture.
When an app joins a room, the audio module is enabled by default.
The method does not affect receiving or playing remote audio streams. The enableLocalAudio(false) method is suitable for scenarios where the user wants to receive remote audio streams without sending audio streams to other users in the room.

Parameters
enablespecifies whether to enable local audio.
  • true: enables local audio capture. This is the default value.
  • false: disables local audio capture.
Returns
0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.
Note
- The enableLocalAudio method is different from muteLocalAudioStream. The enableLocalAudio method is used to enable local audio capturing and processing whereas the muteLocalAudioStream method is used to stop or restart pushing local audio streams.
  • The method enables the internal engine. The setting remains unchanged after the leaveChannel method is called.
  • From V4.4.0, the operation to enable or disable the local audio capture does not affect playback of the music file. If you have called enableLocalAudio(NO), you can still play back the music file by calling startAudioMixing.

◆ enableLocalVideo()

abstract int com.netease.lava.nertc.sdk.NERtc.enableLocalVideo ( boolean  enable)
abstract

Specifies whether to enable local video capture.

Parameters
enablespecifies whether to enable local video capture.
  • true: enables local video capture. This is the default value.
  • false: disables local cameras. 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.
Returns
0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.
Note
  • You can call this method before or after joining a room.
  • After local video capture is successfully enabled or disabled, the onUserVideoStop or onUserVideoStart callback is remotely triggered.

◆ getInstance()

static NERtc com.netease.lava.nertc.sdk.NERtc.getInstance ( )
static

Get a NERtc instance.

Returns
NERtc instance

Reimplemented in com.netease.lava.nertc.sdk.NERtcEx.

◆ init()

abstract void com.netease.lava.nertc.sdk.NERtc.init ( Context  context,
String  appkey,
NERtcCallback  callback,
NERtcOption  option 
) throws Exception
abstract

Creates a NERtc instance and initializes the NERTC SDK.

  • Before you call other APIs, you must first call this method to create and initialize a NERtc instance.
  • Apps that use the same AppKey can make audio or video calls, or perform live streaming in the same room.
  • One AppKey can be used to create only one NERtc instance. If you need to change the AppKey, you must first delete the current instance by calling the NERtc#release() 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 NERtc#release() method.
  • If you specify invalid parameters when you create an instance, an error may occur, such as RuntimeException and UnsatisfiedLinkError.
    Parameters
    contextThe RTC engine context object passed.
    appkeyThe AppKey of an app. You can view the AppKey in the CommsEase console after you create an app.
    callbackThe callback function. All APIs are called in the main thread. A simple implement AbsNERtcCallbackEx
    optionOther options. For more information, see NERtcOption. You can set the value to null.

◆ joinChannel()

abstract int com.netease.lava.nertc.sdk.NERtc.joinChannel ( String  token,
String  channelName,
long  uid 
)
abstract

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 servers provided by CommsEase.

Parameters
tokenThe signature used in authentication (NERTC Token). Valid values:
  • null. You can specify null in the debugging mode. This poses a security risk. We recommend that you change to the safe mode in the CommsEase console by using the authentication mode before your product is officially launched.
  • The NERTC token that is obtained. In safe mode, the acquired token must be specified. If the specified token is invalid, users are unable to join a room. Safe mode is recommended.
channelNameThe name of the room. Users that use the same name can join the same room.
  • The name is in STRING format 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 be unique.
The uid is optional. The default value is 0. If the parameter is not specified or set to 0, the SDK assigns a random uid and returns by the onJoinChannel callback. The app instead of the SDk keeps the return value.
Returns
0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.
Note
- After joining a room by calling methods supported by the SDK, users in the same room can make audio or video calls with each other. Multiple users that join the same room can start group chat. Apps that use different App Keys cannot communicate with each other.
  • After you call the method, the onJoinChannel callback is triggered on the local client, and the onUserJoined callback is triggered on the remote client.
  • If you join a room, the audio streams from other users in the same room are subscribed by default. In this case, the data usage is billed. To unsubscribe, you can call the mute method.
  • In live streaming, audience can switch rooms by calling switchChannel. 调用 joinChannel 之后,NERTC SDK 会通过 Android 的 AudioManager.setMode() 方法调整音频模式(audio mode),此后请勿修改 SDK 调整过的音频模式,否则会导致音频路由错误等问题。
See also
NERtc::leaveChannel()

◆ leaveChannel()

abstract int com.netease.lava.nertc.sdk.NERtc.leaveChannel ( )
abstract

Allows a user to leave a room, such as hanging up or exiting a call.
After joining a room, the user must call the leaveChannel method to end the call before joining another room.
After the method is called successfully, the onLeaveChannel callback is locally triggered, and the onUserLeave callback is remotely triggered.

Returns
0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.
See also
NERtc::joinChannel(String, String, long)

◆ release()

abstract void com.netease.lava.nertc.sdk.NERtc.release ( )
abstract

Deletes a NERtc instance to release resources.
This method frees up all resources used by the NERTC SDK. In some cases, real-time communication is only needed upon your demands. If no audio or video 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.

Note
  • After you delete an instance, you must wait until the release method is complete before you create a new instance.
  • release 方法需要和 leaveChannel 方法在同一线程中,且需要在 leaveChannel 后执行。

◆ setAudioProfile()

abstract int com.netease.lava.nertc.sdk.NERtc.setAudioProfile ( int  profile,
int  scenario 
)
abstract

Sets the audio profile.

Parameters
profilesets the sample rate, bitrate, encoding mode, and the number of rooms. For more information, see NERtcConstants.AudioProfile.
scenariosets the audio application scenario. For more information, see NERtcConstants.AudioScenario
Returns
0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.
Note
You must call this init method before you call the joinChannel method.

◆ setCameraCaptureConfig()

abstract int com.netease.lava.nertc.sdk.NERtc.setCameraCaptureConfig ( NERtcCameraCaptureConfig  captureConfig)
abstract

Sets the camera capturer configuration.
For a video call or live streaming, generally the SDK controls the camera output parameters. By default, the SDK matches the most appropriate resolution based on the user's setLocalVideoConfig configuration. When the default camera capture settings do not meet special requirements, we recommend using this method to set the camera capturer configuration:

  • If you want better quality for the local video preview, we recommend setting config as CAPTURE_PREFERENCE_OUTPUT_QUALITY. The SDK sets the camera output parameters with higher picture quality.
  • To customize the width and height of the video image captured by the local camera, set the camera capture configuration as CAPTURE_PREFERENCE_MANUAL.
    Note
  • Call this method before or after joining the channel. The setting takes effect immediately without restarting the camera.
  • Higher collection parameters means higher performance consumption, such as CPU and memory usage, especially when video pre-processing is enabled.
    Since
    V4.5.0
    Parameters
    captureConfigThe camera capturer configuration. For details, see video.NERtcCameraCaptureConfig
    Returns
    0
    A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.

◆ setLocalVideoConfig()

abstract int com.netease.lava.nertc.sdk.NERtc.setLocalVideoConfig ( NERtcVideoConfig  videoConfig)
abstract

Sets local video parameters.
You can call this method before or after you join the channel.

Parameters
videoConfigsets the video parameters. For more information, see video.NERtcVideoConfig.
Returns
0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.
Note
  • Since V4.5.0, 'setLocalVideoConfig' method takes effect in real time. In previous versions, 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.
  • This method is a full parameter configuration method. If this method is invoked repeatedly, the SDK refreshes all previous parameter configurations and uses the latest parameter. Therefore, you need to set all parameters each time you modify the configuration, otherwise, unconfigured parameters will be set to the default value.

◆ setParameters()

abstract void com.netease.lava.nertc.sdk.NERtc.setParameters ( NERtcParameters  params) throws IllegalArgumentException
abstract

Set parameters for audio and video calls.

Parameters
paramsspecifies parameters for audio and video calls.
Note
  • You must call this method before calling the init method.
  • This method provides a technology preview or personalized features. If you want to use this API, contact technical support.

◆ setupLocalVideoCanvas()

abstract int com.netease.lava.nertc.sdk.NERtc.setupLocalVideoCanvas ( IVideoRender  render)
abstract

Sets local views.
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.
In the application development, you can call this method to set local views after an instance is initialized. Then, you can join a room.

Parameters
renderspecifies the video canvas. For more information, see NERtcVideoView。
Returns
0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.
See also
NERtcVideoView

◆ setupRemoteVideoCanvas()

abstract int com.netease.lava.nertc.sdk.NERtc.setupRemoteVideoCanvas ( IVideoRender  render,
long  uid 
)
abstract

Sets views for remote users.
This method is used to associate remote users with display views and configure the rendering mode and mirroring mode for remote user views that displays locally. The method affects only the video displays viewed by local users.

Parameters
renderspecifies the video canvas. For more information, see NERtcVideoView。
uidindicates the ID of a remote user.
Returns
0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.
Note
  • 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 render parameter empty.
  • After the user exit the room, the association between a remote user and the view is cleared.
See also
NERtcVideoView

◆ startVideoPreview()

abstract int com.netease.lava.nertc.sdk.NERtc.startVideoPreview ( )
abstract

Enables video preview.

  • The method is used to enable local video preview before you enter a room. Before you can call the API, you must call setupLocalVideoCanvas to set up a video canvas.
  • If local video preview is enabled, you must call the stopVideoPreview method to stop local video preview before you join the room.
    Returns
    0
    A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.

◆ stopVideoPreview()

abstract int com.netease.lava.nertc.sdk.NERtc.stopVideoPreview ( )
abstract

Stops video preview.

Returns
0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.
Note
You must call the method before you join the room.

◆ subscribeAllRemoteAudioStreams()

abstract int com.netease.lava.nertc.sdk.NERtc.subscribeAllRemoteAudioStreams ( boolean  subscribe)
abstract

Subscribes to or unsubscribes from audio streams from all remote users.

Parameters
subscribespecifies whether to unsubscribe audio streams from all remote users.
  • true: subscribes audio streams. This is the default value.
  • false: unsubscribes audio streams.
Returns
0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.
Note
- After a user joins a room, audio streams from all remote users are subscribed by default. In this case, do not repeat subscribing audio streams from all remote users by calling the subscribeAllRemoteAudioStreams(true) method.
  • This method can be called only if a user joins a room.
  • This is applicable for subsequent users that join the room.

◆ subscribeRemoteAudioStream()

abstract int com.netease.lava.nertc.sdk.NERtc.subscribeRemoteAudioStream ( long  uid,
boolean  subscribe 
)
abstract

Subscribes or unsubscribes audio streams from specified remote users.
After a user joins a room, audio streams from all remote users are subscribed by default. You can call this method to subscribe or unsubscribe audio streams from all remote users.

Parameters
uidindicates the user ID.
subscribespecifies whether to subscribe specified audio streams.
  • true: subscribes audio steams. This is the default value.
  • false: unsubscribes audio streams.
Returns
0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.
Note
This method can be called only if a user joins a room.

◆ subscribeRemoteVideoStream()

abstract int com.netease.lava.nertc.sdk.NERtc.subscribeRemoteVideoStream ( long  uid,
NERtcRemoteVideoStreamType  streamType,
boolean  subscribe 
)
abstract

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.
You must join a room before you can call the method.

Parameters
uidspecifies the user ID.
streamTypespecified the type of the video streams. For more information, see video.NERtcRemoteVideoStreamType.
subscribespecifies whether to unsubscribe local video streams.
  • true: subscribe specified video streams. This is the default value.
  • false: does not subscribe to the specified video streams.
Returns
0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.

◆ version()

static NERtcVersion com.netease.lava.nertc.sdk.NERtc.version ( )
static

Query the SDK version number.
You can call this method before or after the user join a room.

Returns
NERtcVersion The version number is returned.

The documentation for this class was generated from the following file: