Skip to main content

1-to-1 call

This page describes the current public 1-to-1 calling capabilities in Nexconn Call SDK for Android.

Key types

TypeDescription
NCCallEngineCall entry point. Starts, accepts, and ends calls, controls devices, and queries call logs.
NCCallSessionCurrent call session object. Includes callId, callType, mediaType, participant list, and related data.
NCCallUserParticipant state object.
NCCallEventHandlerCallback for incoming calls, connected calls, ended calls, participant state changes, media switching, and call logs.
NCCallAPIResultHandlerAsynchronous result callback for startCall, acceptCall, endCall, requestChangeMediaType, and related APIs.

Add handlers

Register the event handler before Chat SDK connects, and register the result handler after initialization completes.

Java
NCCallEngine engine = NCCallEngine.getInstance();

engine.setCallEventHandler(new NCCallEventHandler() {
@Override
public void onCallReceived(NCCallReceivedEvent event) {
}

@Override
public void onCallConnected(NCCallConnectedEvent event) {
}

@Override
public void onCallEnded(NCCallEndedEvent event) {
}

@Override
public void onRemoteUserStateChanged(NCCallRemoteUserStateChangedEvent event) {
}
});

engine.setAPIResultHandler(new NCCallAPIResultHandler() {
@Override
public void onStartCall(NCCallStartCallResult result) {
}

@Override
public void onAcceptCall(NCCallAcceptCallResult result) {
}

@Override
public void onEndCall(NCCallEndCallResult result) {
}
});

Set video views

For a 1-to-1 video call, you typically need one local view and one remote view.

Java
NCCallLocalVideoView localView = new NCCallLocalVideoSurfaceView(context);
localView.setRenderMode(NCCallRenderMode.FILL);

NCCallRemoteVideoView remoteView =
new NCCallRemoteVideoSurfaceView(context, remoteUserId, false);
remoteView.setRenderMode(NCCallRenderMode.FILL);

//TODO: add the created localView and remoteView to your own UI layout

NCCallEngine engine = NCCallEngine.getInstance();
engine.setLocalVideoView(localView);
engine.setRemoteVideoView(Collections.singletonList(remoteView));

If you no longer need to show a remote video stream, call:

Java
NCCallEngine.getInstance().removeVideoView(
Collections.singletonList(remoteUserId)
);

Start a 1-to-1 call

For a 1-to-1 call, callType must be NCCallType.SINGLE, and userIds must contain exactly one callee.

Java

NCCallStartCallParams params = new NCCallStartCallParams(
Collections.singletonList(remoteUserId),
NCCallType.SINGLE,
NCCallMediaType.AUDIO_VIDEO
);
params.setPushConfig(pushConfigs); // optional: android&iOS push config
params.setExtra(extra); //optional: extra content sent to receivers

NCCallEngine.getInstance().startCall(params);

The result is returned through onStartCall(NCCallStartCallResult). If the callee accepts the call, both users receive onCallConnected(NCCallConnectedEvent).

Receive and accept an incoming call

The callee receives the call session and extra through onCallReceived(NCCallReceivedEvent):

Java
@Override
public void onCallReceived(NCCallReceivedEvent event) {
NCCallSession callSession = event.getCallSession();
String extra = event.getExtra();
String callId = callSession.getCallId();

if (callSession.getMediaType() == NCCallMediaType.AUDIO_VIDEO) {
NCCallLocalVideoView localView = new NCCallLocalVideoSurfaceView(context);
localView.setRenderMode(NCCallRenderMode.FILL);

NCCallRemoteVideoView remoteView = new NCCallRemoteVideoSurfaceView(context, callSession.getCallerUserId(), false);
remoteView.setRenderMode(NCCallRenderMode.FILL);

//TODO: add the created localView and remoteView to your own UI layout

NCCallEngine engine = NCCallEngine.getInstance();
engine.setLocalVideoView(localView);
engine.setRemoteVideoView(Collections.singletonList(remoteView));
}

NCCallAcceptCallParams params = new NCCallAcceptCallParams(callId);
NCCallEngine.getInstance().acceptCall(params);
}

If the user is already on another call, end the current call with endCall(NCCallEndCallParams) before calling acceptCall(NCCallAcceptCallParams) for the new incoming call.

End the call

Java
// the current active call or end a specific call by callId
NCCallEndCallParams params = new NCCallEndCallParams(callId);
params.setPushConfig(null); // optional

NCCallEngine.getInstance().endCall(params);

The asynchronous result is returned through NCCallAPIResultHandler#onEndCall(NCCallEndCallResult), and the call end event is returned through NCCallEventHandler#onCallEnded(NCCallEndedEvent).

Control devices during the call

Microphone and speaker

Java
NCCallEngine engine = NCCallEngine.getInstance();

engine.enableMicrophone(true);
boolean micEnabled = engine.isMicrophoneEnabled();

engine.enableSpeaker(true);
boolean speakerEnabled = engine.isSpeakerphoneEnabled();

Camera

Java
NCCallEngine engine = NCCallEngine.getInstance();

engine.enableCamera(true);
engine.switchCamera();

The current Android code comments indicate that the camera is off by default after a video call is connected. Your app must explicitly call enableCamera(true).

Audio and video configuration

Before the call is connected, configure capture parameters with setVideoConfig(...).

Java
NCCallVideoConfig videoConfig = new NCCallVideoConfig();
videoConfig.setResolution(NCCallVideoResolution.RESOLUTION_480X640);
videoConfig.setFrameRate(NCCallVideoFrameRate.FPS_15);
videoConfig.setMinBitrate(200);
videoConfig.setMaxBitrate(900);

NCCallEngine.getInstance().setVideoConfig(videoConfig);

Switch media type

1-to-1 calls support switching between audio and audio-video modes.

Send a change request

Java
NCCallRequestChangeMediaTypeParams params = new NCCallRequestChangeMediaTypeParams(NCCallMediaType.AUDIO_VIDEO);

NCCallEngine.getInstance().requestChangeMediaType(params);

The result is returned through onRequestChangeMediaType(NCCallRequestChangeMediaTypeResult). The remote user receives onMediaTypeChangeRequestReceived(NCCallMediaTypeChangeRequestReceivedEvent).

Respond to a change request

Java
@Override
public void onMediaTypeChangeRequestReceived(NCCallMediaTypeChangeRequestReceivedEvent event) {
NCCallReplyChangeMediaTypeParams params = new NCCallReplyChangeMediaTypeParams(
event.getTransactionId(),
true
);

NCCallEngine.getInstance().replyChangeMediaType(params);
}

The final result is returned through onMediaTypeChangeResultReceived(NCCallMediaTypeChangeResultReceivedEvent).

To cancel an existing request, pass the transaction ID into NCCallCancelChangeMediaTypeParams:

Java
NCCallCancelChangeMediaTypeParams cancelParams =
new NCCallCancelChangeMediaTypeParams(transactionId);

NCCallEngine.getInstance().cancelChangeMediaType(cancelParams);

Call logs

Call log callbacks after the call ends

  • onLocalCallLogReceived(NCCallLocalCallLogReceivedEvent)
  • onServerCallLogReceived(NCCallServerCallLogReceivedEvent)

Query history with pagination

Java
NCCallGetHistoryCallLogsParams params = new NCCallGetHistoryCallLogsParams(-1, 20);
params.setOrder(NCCallLogOrder.DESC);

NCCallEngine.getInstance().getHistoryCallLogs(params);

The result is returned through onGetHistoryCallLogs(NCCallGetHistoryCallLogsResult). If result.getCallLogInfo().isHasMore() is true, use result.getCallLogInfo().getSyncTime() to request the next page.

Delete logs

Java
NCCallDeleteCallLogsForMeParams deleteParams = new NCCallDeleteCallLogsForMeParams(
Collections.singletonList(callId)
);
NCCallEngine.getInstance().deleteCallLogsForMe(deleteParams);

NCCallEngine.getInstance().deleteAllCallLogsForMe();

Quality metrics and frame capture

If you need network quality data or captured audio and video frames, use:

  • setConnectionQualityHandler(...)
  • setVideoFrameCaptureHandler(...)
  • setAudioFrameCaptureHandler(...)

These callbacks are useful for quality dashboards, debugging, and custom data processing.