Class NCCallEngine
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidacceptCall(String callId) Accepts a call.abstract voidcancelChangeMediaType(String transactionId) Cancels an already sent media type change request (one-to-one only).abstract voidDeletes all call logs of the current user.abstract voiddeleteCallLogsForMe(List<String> callIds) Deletes the current user's call logs in batches.abstract voidenableCamera(boolean enable) Enables or disables the camera.abstract NCCallResultCodeenableMicrophone(boolean enable) Enables or disables the microphone.abstract voidenableSpeaker(boolean enable) Enables or disables the speaker.abstract voidendCall()Ends the current call.abstract voidEnds the specified call.abstract voidendCall(String callId, INCCallPushConfig config) Ends the specified call with push configuration.abstract INCCallSessionReturns the current call session instance.abstract voidgetHistoryCallLogs(long syncTime, int count, NCCallLogOrder order) Retrieves the current user's call logs with sorting.static NCCallEngineReturns the `NCCallEngine` instance.abstract voidRetrieves the current user's unfinished call logs from the server.static StringReturns the SDK version.abstract NCCallResultCodeinitialize(android.content.Context context, INCCallInitOptions options) Initializes the call configuration.static voidinstall()Installs the SDK's underlying dependencies.abstract voidinviteToCall(List<String> userIds) Invites new users into a one-to-one or group call.abstract voidinviteToCall(List<String> userIds, INCCallPushConfig pushConfig, String extra) Invites new users into a one-to-one or group call with push configuration and extra data.abstract booleanReturns whether the microphone is enabled.abstract booleanReturns whether the speaker is enabled.abstract voidJoins an ongoing group call.abstract voidremoveVideoView(List<String> userIds) Removes remote user rendering views.abstract voidreplyChangeMediaType(String transactionId, boolean isAgreed) Replies to a media type change request (one-to-one only).abstract voidrequestChangeMediaType(NCCallMediaType mediaType) Requests a media type change during a call (one-to-one only).abstract voidsetAPIResultListener(INCCallAPIResultListener listener) Sets the listener for call API execution results.abstract NCCallResultCodesetAudioConfig(INCCallAudioConfig config) Sets the audio configuration, including audio quality, call mode, and so on.abstract voidsetAudioFrameCaptureListener(INCCallAudioFrameCaptureListener audioFrameListener) Sets the local audio data callback.abstract voidSets the audio route listener.abstract voidsetCallEventsListener(INCCallEventsListener listener) Sets the call event listener.abstract voidsetConnectionQualityListener(INCCallConnectionQualityListener statusReportListener) Sets the listener for call quality data.abstract NCCallResultCodesetVideoConfig(INCCallVideoConfig config) Sets the video configuration, including resolution, max/min bitrate, frame rate, and so on.abstract voidsetVideoFrameCaptureListener(INCCallVideoFrameCaptureListener videoFrameListener) Sets the local video capture callback.abstract voidsetVideoView(INCCallLocalVideoView localVideoView) Sets the local rendering view (`SurfaceView` or `TextureView`).abstract voidsetVideoView(List<? extends INCCallRemoteVideoView> remoteVideoViewList) Sets the list of remote user rendering views.abstract voidstartCall(List<String> userIds, NCCallType callType, NCCallMediaType mediaType) Starts a call asynchronously.abstract voidstartCall(List<String> userIds, NCCallType callType, NCCallMediaType mediaType, INCCallPushConfig pushConfig, String extra) Starts a call with push configuration and extra data.abstract voidstartCall(List<String> userIds, NCCallType callType, NCCallMediaType mediaType, INCCallStartCallOptions option) Starts a call with optional configuration.abstract voidSwitches between the front and rear cameras.abstract voidswitchCamera(int cameraId, boolean mirror) Switches to the specified camera.abstract voidUninitializes the call engine.
-
Field Details
-
SDK_VERSION
SDK version.- See Also:
-
-
Constructor Details
-
NCCallEngine
public NCCallEngine()
-
-
Method Details
-
getInstance
Returns the `NCCallEngine` instance.- Returns:
- `NCCallEngine` instance
-
install
public static void install()Installs the SDK's underlying dependencies. Call this once globally and beforeNCEngine.initialize(InitParams). -
initialize
public abstract NCCallResultCode initialize(android.content.Context context, INCCallInitOptions options) Initializes the call configuration. Call this afterNCEngine.initialize(InitParams). It is recommended to call it before each call.- Parameters:
context- contextoptions- global call configuration- Returns:
- initialization result
-
unInitialize
public abstract void unInitialize()Uninitializes the call engine. If a call is in progress when destruction is requested, the SDK internally hangs up before destruction. Other listeners are released, butsetCallEventsListener(INCCallEventsListener)is not cleared automatically, so call `setCallEventsListener(null)` yourself to unregister it. -
setVideoConfig
Sets the video configuration, including resolution, max/min bitrate, frame rate, and so on. This takes effect only if set before the call is established.- Parameters:
config- video configuration
-
setAudioConfig
Sets the audio configuration, including audio quality, call mode, and so on. This takes effect only if set before the call is established.- Parameters:
config- local audio configuration
-
setCallEventsListener
Sets the call event listener. Setting it multiple times overwrites the previous one. Pass `null` to release it. Note that `unInit()` does not release this listener. To receive push call notifications throughINCCallEventsListener.onCallReceived(INCCallSession, String), register it before the `NCEngine` is initialized and connected.- Parameters:
listener- call event listener
-
setAPIResultListener
Sets the listener for call API execution results. Setting it multiple times overwrites the previous one. Pass `null` to release it.- Parameters:
listener- result callback listener
-
setConnectionQualityListener
public abstract void setConnectionQualityListener(INCCallConnectionQualityListener statusReportListener) Sets the listener for call quality data. Setting it multiple times overwrites the previous one. Pass `null` to release it. The callback frequency is once per second.- Parameters:
statusReportListener- call quality data listener
-
startCall
public abstract void startCall(List<String> userIds, NCCallType callType, NCCallMediaType mediaType) Starts a call asynchronously. The result is returned throughINCCallAPIResultListener.onStartCall(NCCallCode, String, List).If the request fails due to a network disconnection, an `NCEngine` disconnection, or a similar issue, this method retries according to the SDK's internal strategy. If retries keep failing, the maximum wait time is about 47 seconds before a failure callback is returned.
- Parameters:
userIds- callee user ID list. When `callType` isNCCallType.SINGLE, `userIds` must contain exactly one entrycallType- call type: one-to-one or multi-partymediaType- call media type: audio or audio/video
-
startCall
public abstract void startCall(List<String> userIds, NCCallType callType, NCCallMediaType mediaType, INCCallPushConfig pushConfig, String extra) Starts a call with push configuration and extra data. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onStartCall(NCCallCode, String, List).If the request fails due to a network disconnection, an `NCEngine` disconnection, or a similar issue, this method retries according to the SDK's internal strategy. If retries keep failing, the maximum wait time is about 47 seconds before a failure callback is returned.
- Parameters:
userIds- callee user ID list. When `callType` isNCCallType.SINGLE, `userIds` must contain exactly one entrycallType- call type: one-to-one or multi-partymediaType- call media type: audio or audio/videopushConfig- push configuration, including Android/iOS push title, content, icon, jump target, and so onextra- extra data transparently passed to the callee, which can be obtained from the `extra` parameter inINCCallEventsListener.onCallReceived(INCCallSession, String)
-
startCall
public abstract void startCall(List<String> userIds, NCCallType callType, NCCallMediaType mediaType, INCCallStartCallOptions option) Starts a call with optional configuration. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onStartCall(NCCallCode, String, List).If the request fails due to a network disconnection, an `NCEngine` disconnection, or a similar issue, this method retries according to the SDK's internal strategy. If retries keep failing, the maximum wait time is about 47 seconds before a failure callback is returned.
- Parameters:
userIds- callee user ID list. When `callType` isNCCallType.SINGLE, `userIds` must contain exactly one entrycallType- call type: one-to-one or multi-partymediaType- call media type: audio or audio/videooption- optional configuration (nullable), including `pushConfig`, `extra`, and `channelID`
-
joinCall
Joins an ongoing group call. You can join as long as you have the group call ID, whether or not you were invited. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onJoinCall(NCCallCode, String).If the request fails due to a network disconnection, an `NCEngine` disconnection, or a similar issue, this method retries according to the SDK's internal strategy. If retries keep failing, the maximum wait time is about 47 seconds before a failure callback is returned.
- Parameters:
callId- call ID to join
-
inviteToCall
Invites new users into a one-to-one or group call. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onJoinCall(NCCallCode, String).Invited online users receive a callback through
INCCallEventsListener.onCallReceived(INCCallSession, String).- Parameters:
userIds- invited user list
-
inviteToCall
Invites new users into a one-to-one or group call with push configuration and extra data. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onJoinCall(NCCallCode, String).Invited online users receive a callback through
INCCallEventsListener.onCallReceived(INCCallSession, String).- Parameters:
userIds- invited user listpushConfig- push configuration, including Android/iOS push title, content, icon, jump target, and so onextra- extra data transparently passed to invited users
-
acceptCall
Accepts a call. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onAcceptCall(NCCallCode, String).- Parameters:
callId- call ID
-
endCall
Ends the specified call. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onEndCall(NCCallCode, String). If `callId` is not the current call, the current call is not affected.- Parameters:
callId- call ID to end
-
endCall
Ends the specified call with push configuration. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onEndCall(NCCallCode, String). If `callId` is not the current call, the current call is not affected.- Parameters:
callId- call ID to endconfig- push configuration, including Android/iOS push title, content, icon, jump target, and so on
-
endCall
public abstract void endCall()Ends the current call. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onEndCall(NCCallCode, String). -
setVideoView
Sets the list of remote user rendering views. The subscribed large/small stream can be adjusted dynamically.- Parameters:
remoteVideoViewList- list of remote user rendering views
-
setVideoView
Sets the local rendering view (`SurfaceView` or `TextureView`). Set it to `null` again to release it.- Parameters:
localVideoView- local view, nullable
-
removeVideoView
Removes remote user rendering views.- Parameters:
userIds- list of remote user UIDs to remove
-
enableCamera
public abstract void enableCamera(boolean enable) Enables or disables the camera. When `enable` is `false`, the camera is turned off. After a video call is established, the camera is off by default and must be turned on explicitly. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onEnableCamera(NCCallCode).- Parameters:
enable- `true` to enable, `false` to disable
-
switchCamera
public abstract void switchCamera()Switches between the front and rear cameras. This takes effect only after the camera has been enabled via `enableCamera`. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onSwitchCamera(NCCallCode, boolean)}. -
switchCamera
public abstract void switchCamera(int cameraId, boolean mirror) Switches to the specified camera. This takes effect only after `enableCamera` has been called. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onSwitchCamera(NCCallCode, int, boolean, boolean)}.- Parameters:
cameraId- camera IDmirror- whether capture is mirrored
-
enableMicrophone
Enables or disables the microphone. It is enabled by default after the call is established. Synchronous method.- Parameters:
enable- `true` to enable, `false` to disable- Returns:
- result code
-
isMicrophoneEnabled
public abstract boolean isMicrophoneEnabled()Returns whether the microphone is enabled. Synchronous method. -
enableSpeaker
public abstract void enableSpeaker(boolean enable) Enables or disables the speaker. It is enabled by default for video calls and disabled by default for audio calls. Synchronous method.- Parameters:
enable- whether to enable the speaker
-
isSpeakerphoneEnabled
public abstract boolean isSpeakerphoneEnabled()Returns whether the speaker is enabled. -
setVideoFrameCaptureListener
public abstract void setVideoFrameCaptureListener(INCCallVideoFrameCaptureListener videoFrameListener) Sets the local video capture callback. Setting it multiple times overwrites the previous one. Pass `null` to release it. The returned data type can be controlled byINCCallInitOptions.Builder.enableEncoderTexture(boolean).- Parameters:
videoFrameListener- local video capture callback
-
setAudioFrameCaptureListener
public abstract void setAudioFrameCaptureListener(INCCallAudioFrameCaptureListener audioFrameListener) Sets the local audio data callback. Setting it multiple times overwrites the previous one. Pass `null` to release it. Audio data is in PCM format.- Parameters:
audioFrameListener- local audio data callback
-
getHistoryCallLogs
Retrieves the current user's call logs with sorting. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onGetHistoryCallLogs(NCCallCode, INCCallLogInfo, NCCallLogOrder).- Parameters:
syncTime- sync timestamp in ms; pass `-1` for the first requestcount- number of records to fetch each timeorder- sort order, for exampleNCCallLogOrder.ASCfor ascending orNCCallLogOrder.DESCfor descending
-
deleteCallLogsForMe
Deletes the current user's call logs in batches. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onDeleteCallLogsForMe(NCCallCode, List).- Parameters:
callIds- list of call IDs to delete
-
getOngoingCallLogs
public abstract void getOngoingCallLogs()Retrieves the current user's unfinished call logs from the server. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onGetOngoingCallLogs(NCCallCode, List). -
deleteAllCallLogsForMe
public abstract void deleteAllCallLogsForMe()Deletes all call logs of the current user. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onDeleteAllCallLogsForMe(NCCallCode). -
requestChangeMediaType
Requests a media type change during a call (one-to-one only). When switching from audio to audio/video, the SDK automatically publishes the camera stream after it receives the remote party's acceptance, and you must call `enableCamera` to turn on the camera. When switching from audio/video to audio, you do not need to turn off the camera manually. Executed asynchronously. The result is returned throughINCCallAPIResultListener.onRequestChangeMediaType(NCCallCode, String, String, NCCallMediaType).- Parameters:
mediaType- target media type
-
replyChangeMediaType
Replies to a media type change request (one-to-one only). Executed asynchronously. The result is returned throughINCCallAPIResultListener.onReplyChangeMediaType(NCCallCode, String, String, boolean).- Parameters:
transactionId- transaction ID obtained fromINCCallEventsListener.onMediaTypeChangeRequestReceived(String, String, NCCallMediaType)isAgreed- whether to accept the switch
-
cancelChangeMediaType
Cancels an already sent media type change request (one-to-one only). Executed asynchronously. The result is returned throughINCCallAPIResultListener.onCancelChangeMediaType(NCCallCode, String, String).- Parameters:
transactionId- transaction ID obtained fromINCCallEventsListener.onMediaTypeChangeRequestReceived(String, String, NCCallMediaType)
-
getCurrentCallSession
Returns the current call session instance.- Returns:
- current call object, or `null` if none exists
-
getVersion
Returns the SDK version. -
setAudioRouteListener
Sets the audio route listener. If this callback is not set, the SDK does not handle audio events such as device plug-in or unplug.- Parameters:
listener- audio route listener; passing `null` removes the listener
-