Class NCCallEngine

java.lang.Object
ai.nexconn.call.api.NCCallEngine

public abstract class NCCallEngine extends Object
Entry point for the call client, providing session control, media control, push configuration, and call log query capabilities.
  • Field Details

  • Constructor Details

    • NCCallEngine

      public NCCallEngine()
  • Method Details

    • getInstance

      public static NCCallEngine getInstance()
      Returns the `NCCallEngine` instance.
      Returns:
      `NCCallEngine` instance
    • install

      public static void install()
      Installs the SDK's underlying dependencies. Call this once globally and before NCEngine.initialize(InitParams).
    • initialize

      public abstract NCCallResultCode initialize(android.content.Context context, INCCallInitOptions options)
      Initializes the call configuration. Call this after NCEngine.initialize(InitParams). It is recommended to call it before each call.
      Parameters:
      context - context
      options - 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, but setCallEventsListener(INCCallEventsListener) is not cleared automatically, so call `setCallEventsListener(null)` yourself to unregister it.
    • setVideoConfig

      public abstract NCCallResultCode setVideoConfig(INCCallVideoConfig config)
      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

      public abstract NCCallResultCode setAudioConfig(INCCallAudioConfig config)
      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

      public abstract void setCallEventsListener(INCCallEventsListener listener)
      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 through INCCallEventsListener.onCallReceived(INCCallSession, String), register it before the `NCEngine` is initialized and connected.
      Parameters:
      listener - call event listener
    • setAPIResultListener

      public abstract void setAPIResultListener(INCCallAPIResultListener listener)
      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 through INCCallAPIResultListener.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` is NCCallType.SINGLE, `userIds` must contain exactly one entry
      callType - call type: one-to-one or multi-party
      mediaType - 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 through INCCallAPIResultListener.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` is NCCallType.SINGLE, `userIds` must contain exactly one entry
      callType - call type: one-to-one or multi-party
      mediaType - call media type: audio or audio/video
      pushConfig - push configuration, including Android/iOS push title, content, icon, jump target, and so on
      extra - extra data transparently passed to the callee, which can be obtained from the `extra` parameter in INCCallEventsListener.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 through INCCallAPIResultListener.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` is NCCallType.SINGLE, `userIds` must contain exactly one entry
      callType - call type: one-to-one or multi-party
      mediaType - call media type: audio or audio/video
      option - optional configuration (nullable), including `pushConfig`, `extra`, and `channelID`
    • joinCall

      public abstract void joinCall(String callId)
      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 through INCCallAPIResultListener.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

      public abstract void inviteToCall(List<String> userIds)
      Invites new users into a one-to-one or group call. Executed asynchronously. The result is returned through INCCallAPIResultListener.onJoinCall(NCCallCode, String).

      Invited online users receive a callback through INCCallEventsListener.onCallReceived(INCCallSession, String).

      Parameters:
      userIds - invited user list
    • inviteToCall

      public abstract void inviteToCall(List<String> userIds, INCCallPushConfig pushConfig, String extra)
      Invites new users into a one-to-one or group call with push configuration and extra data. Executed asynchronously. The result is returned through INCCallAPIResultListener.onJoinCall(NCCallCode, String).

      Invited online users receive a callback through INCCallEventsListener.onCallReceived(INCCallSession, String).

      Parameters:
      userIds - invited user list
      pushConfig - push configuration, including Android/iOS push title, content, icon, jump target, and so on
      extra - extra data transparently passed to invited users
    • acceptCall

      public abstract void acceptCall(String callId)
      Accepts a call. Executed asynchronously. The result is returned through INCCallAPIResultListener.onAcceptCall(NCCallCode, String).
      Parameters:
      callId - call ID
    • endCall

      public abstract void endCall(String callId)
      Ends the specified call. Executed asynchronously. The result is returned through INCCallAPIResultListener.onEndCall(NCCallCode, String). If `callId` is not the current call, the current call is not affected.
      Parameters:
      callId - call ID to end
    • endCall

      public abstract void endCall(String callId, INCCallPushConfig config)
      Ends the specified call with push configuration. Executed asynchronously. The result is returned through INCCallAPIResultListener.onEndCall(NCCallCode, String). If `callId` is not the current call, the current call is not affected.
      Parameters:
      callId - call ID to end
      config - 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 through INCCallAPIResultListener.onEndCall(NCCallCode, String).
    • setVideoView

      public abstract void setVideoView(List<? extends INCCallRemoteVideoView> remoteVideoViewList)
      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

      public abstract void setVideoView(INCCallLocalVideoView localVideoView)
      Sets the local rendering view (`SurfaceView` or `TextureView`). Set it to `null` again to release it.
      Parameters:
      localVideoView - local view, nullable
    • removeVideoView

      public abstract void removeVideoView(List<String> userIds)
      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 through INCCallAPIResultListener.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 through INCCallAPIResultListener.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 through INCCallAPIResultListener.onSwitchCamera(NCCallCode, int, boolean, boolean)}.
      Parameters:
      cameraId - camera ID
      mirror - whether capture is mirrored
    • enableMicrophone

      public abstract NCCallResultCode enableMicrophone(boolean enable)
      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 by INCCallInitOptions.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

      public abstract void getHistoryCallLogs(long syncTime, int count, NCCallLogOrder order)
      Retrieves the current user's call logs with sorting. Executed asynchronously. The result is returned through INCCallAPIResultListener.onGetHistoryCallLogs(NCCallCode, INCCallLogInfo, NCCallLogOrder).
      Parameters:
      syncTime - sync timestamp in ms; pass `-1` for the first request
      count - number of records to fetch each time
      order - sort order, for example NCCallLogOrder.ASC for ascending or NCCallLogOrder.DESC for descending
    • deleteCallLogsForMe

      public abstract void deleteCallLogsForMe(List<String> callIds)
      Deletes the current user's call logs in batches. Executed asynchronously. The result is returned through INCCallAPIResultListener.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 through INCCallAPIResultListener.onGetOngoingCallLogs(NCCallCode, List).
    • deleteAllCallLogsForMe

      public abstract void deleteAllCallLogsForMe()
      Deletes all call logs of the current user. Executed asynchronously. The result is returned through INCCallAPIResultListener.onDeleteAllCallLogsForMe(NCCallCode).
    • requestChangeMediaType

      public abstract void requestChangeMediaType(NCCallMediaType mediaType)
      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 through INCCallAPIResultListener.onRequestChangeMediaType(NCCallCode, String, String, NCCallMediaType).
      Parameters:
      mediaType - target media type
    • replyChangeMediaType

      public abstract void replyChangeMediaType(String transactionId, boolean isAgreed)
      Replies to a media type change request (one-to-one only). Executed asynchronously. The result is returned through INCCallAPIResultListener.onReplyChangeMediaType(NCCallCode, String, String, boolean).
      Parameters:
      transactionId - transaction ID obtained from INCCallEventsListener.onMediaTypeChangeRequestReceived(String, String, NCCallMediaType)
      isAgreed - whether to accept the switch
    • cancelChangeMediaType

      public abstract void cancelChangeMediaType(String transactionId)
      Cancels an already sent media type change request (one-to-one only). Executed asynchronously. The result is returned through INCCallAPIResultListener.onCancelChangeMediaType(NCCallCode, String, String).
      Parameters:
      transactionId - transaction ID obtained from INCCallEventsListener.onMediaTypeChangeRequestReceived(String, String, NCCallMediaType)
    • getCurrentCallSession

      public abstract INCCallSession getCurrentCallSession()
      Returns the current call session instance.
      Returns:
      current call object, or `null` if none exists
    • getVersion

      public static String getVersion()
      Returns the SDK version.
    • setAudioRouteListener

      public abstract void setAudioRouteListener(INCCallAudioRouteListener listener)
      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