Group call
This page describes the public group calling capabilities in Nexconn Call SDK for Android, including how to start a group call, join a call, invite participants, and handle call type upgrades.
Related APIs
| Capability | API |
|---|---|
| Start a group call | startCall(NCCallStartCallParams) |
| Join an existing group call | joinCall(NCCallJoinCallParams) |
| Invite participants | inviteToCall(NCCallInviteToCallParams) |
| End or leave a call | endCall(NCCallEndCallParams) |
Start a group call
Set callType to NCCallType.MULTI for group calls.
List<String> userIds = Arrays.asList("user_a", "user_b");
NCCallStartCallParams params = new NCCallStartCallParams(
userIds,
NCCallType.MULTI,
NCCallMediaType.AUDIO_VIDEO
);
params.setTargetId("group-id"); // optional: bind the call to a group or channel ID
params.setPushConfig(pushConfigs); // optional: android&iOS push config
params.setExtra(extra); //optional: extra content sent to receivers
NCCallEngine.getInstance().startCall(params);
The asynchronous result is returned through NCCallAPIResultHandler#onStartCall(NCCallStartCallResult):
NCCallEngine.getInstance().setAPIResultHandler(new NCCallAPIResultHandler() {
@Override
public void onStartCall(NCCallStartCallResult result) {
// result.getCode() == NCCallCode.SUCCESS means the call started successfully
// result.getBusyLineUserList() contains users who are already on another call
}
});
Receive and join a group call
Invited users receive the incoming call through NCCallEventHandler#onCallReceived(NCCallReceivedEvent). After that, they can:
- Call
acceptCall(NCCallAcceptCallParams)to accept the current invitation. - Call
joinCall(NCCallJoinCallParams)to join an ongoing group call whencallIdis already known. - Call
endCall(NCCallEndCallParams)to reject the invitation or leave the current call.
@Override
public void onCallReceived(NCCallReceivedEvent event) {
String callId = event.getCallSession().getCallId();
// Example: accept the current group call
NCCallAcceptCallParams params = new NCCallAcceptCallParams(callId);
NCCallEngine.getInstance().acceptCall(params);
}
Invite additional users
After a 1-to-1 call or a group call is established, you can invite more users:
List<String> userIds = Arrays.asList("user_c", "user_d");
NCCallInviteToCallParams params = new NCCallInviteToCallParams(userIds);
params.setPushConfig(null); // optional
params.setExtra(""); // optional
NCCallEngine.getInstance().inviteToCall(params);
The result is returned through NCCallAPIResultHandler#onInviteToCall(NCCallInviteToCallResult). Other participants receive the invitation event through NCCallEventHandler#onRemoteUserInvited(NCCallRemoteUserInvitedEvent).
@Override
public void onRemoteUserInvited(NCCallRemoteUserInvitedEvent event) {
String callId = event.getCallId();
ArrayList<String> inviteeUserList = event.getInviteeUserList();
String inviterUserId = event.getInviterUserId();
// Invitation event broadcast received
}
Upgrade a 1-to-1 call to a group call
When a third participant is successfully invited into a 1-to-1 call, the current call can be upgraded to a group call. The SDK reports this through onCallTypeChanged(NCCallTypeChangedEvent):
@Override
public void onCallTypeChanged(NCCallTypeChangedEvent event) {
if (event.getCallType() == NCCallType.MULTI) {
// The current call session has been upgraded to a group call
}
}
Video views in a group call
In a group call, you usually create a separate remote view for each participant:
List<NCCallRemoteVideoView> remoteViews = new ArrayList<>();
remoteViews.add(new NCCallRemoteVideoSurfaceView(context, "user_a", false));
remoteViews.add(new NCCallRemoteVideoSurfaceView(context, "user_b", true));
NCCallEngine.getInstance().setRemoteVideoView(remoteViews);
If a participant leaves or you no longer need to show that participant's video, call removeVideoView(List<String> userIds) to remove the corresponding remote view.
End the call and manage call logs
- To leave the current group call, call
endCall(NCCallEndCallParams). - The end result is returned through
onEndCall(NCCallEndCallResult). - The final server-side call log is returned through
onServerCallLogReceived(NCCallServerCallLogReceivedEvent). - Query call history with
getHistoryCallLogs(NCCallGetHistoryCallLogsParams).