Handling call events

Listening to the call events#

In order to listen to the call events you need to set listener to the call sdk using the below method

ArgumentTypeDescription
CALLBACKCallEventsListenerlistener to observe all the call events
CallManager.setCallEventsListener(new CallEventsListener() {
@Override
public void onCallStatusUpdated(@NonNull String callStatus, @NonNull String userJid) {
}
@Override
public void onCallAction(@NonNull String callAction, @NonNull String userJid) {
}
@Override
public void onVideoTrackAdded(@NonNull String userJid) {
}
@Override
public void onMuteStatusUpdated(@NonNull String muteEvent, @NonNull String userJid) {
}
@Override
public void onUserSpeaking(@NonNull String userJid, int audioLevel) {
}
@Override
public void onUserStoppedSpeaking(@NonNull String userJid) {
}
@Override
public void onLocalVideoTrackAdded() {
}
});

Inorder to remove the call events listener call the method below:

ArgumentTypeDescription
listenerCallEventsListenerlistener to observe all the call events
CallManager.removeCallEventsListener(listener);

Handling mute events#

Whenever call end user mute/unmute video or audio, the below callback will be triggered.

@Override
public void onMuteStatusUpdated(@NotNull String muteEvent, @NotNull String userJid) {
switch (muteEvent){
case MuteEvent.ACTION_REMOTE_VIDEO_MUTE:
break;
case MuteEvent.ACTION_REMOTE_VIDEO_UN_MUTE:
break;
case MuteEvent.ACTION_REMOTE_AUDIO_MUTE:
break;
case MuteEvent.ACTION_REMOTE_AUDIO_UN_MUTE:
break;
}
}

muteEvent value will be anyone of the values of annotation class MuteEvent.

muteEvent ValueCall event
MuteEvent.ACTION_REMOTE_VIDEO_MUTEwhen the remote user muted his video
MuteEvent.ACTION_REMOTE_VIDEO_UN_MUTEwhen the remote user unmuted his video
MuteEvent.ACTION_REMOTE_AUDIO_MUTEwhen the remote user muted his audio
MuteEvent.ACTION_REMOTE_AUDIO_UN_MUTEwhen the remote user unmuted his video

Handling call status events#

Whenever call status changed in video or audio call, the below callback will be triggered.

@Override
public void onCallStatusUpdated(@NotNull String callStatus, @NotNull String userJid) {
}

callStatus value will be anyone of the values of annotation class CallStatus.

callStatus ValueCall event
CallStatus.CALLINGthe initial state of the call
CallStatus.CONNECTINGThe current call is in connecting state
CallStatus.RINGINGthe remote user is having internet and acknowledged the call
CallStatus.CONNECTEDthe call is successfully connected and audio/video tracks transmission is about to start
CallStatus.DISCONNECTEDthe call is disconnected and call UI can be closed
CallStatus.RECONNECTINGthe call is in reconnecting state
CallStatus.RECONNECTEDthe call is connected back after a reconnecting state
CallStatus.ON_HOLDthe remote user has put your call on hold, it will happedn when the remote user attended gsm call
CallStatus.ON_RESUMEthe remote user has resumed your call after a on hold, it will happen when the remote user disconnected gsm call
CallStatus.OUTGOING_CALL_TIME_OUTwhen we don't receive ack for the outgoing call from the remote user within 30 seconds
CallStatus.INCOMING_CALL_TIME_OUTWhen we don't receive ack for the incoming call from the caller within 30 seconds
CallStatus.USER_JOINEDuser is joined to the call
CallStatus.USER_LEFTuser is left from the call
CallStatus.INVITE_CALL_TIME_OUTWhen we don't receive ack for the call invite from the invited user within 30 seconds

Handling call action events#

Whenever call action received in video or audio call, the below callback will be triggered.

@Override
public void onCallAction(@NotNull String callAction, @NotNull String userJid) {
}

callAction value will be anyone of the values of annotation class CallAction.

callAction ValueCall event
CallAction.ACTION_LOCAL_HANGUPwhenever you disconnect the call, the action will be received
CallAction.ACTION_DENY_CALLwhen you decline the incoming call, the action will be received for callee
CallAction.ACTION_PERMISSION_DENIEDwhen you attend the incoming call without required permissions, the action will be received for the callee
CallAction.ACTION_REMOTE_HANGUPwhen the remote user disconnect the connected call, the action will be received for caller
CallAction.ACTION_REMOTE_ENGAGEDwhen the remote user is engaged in the another call, the action will be received for the caller
CallAction.ACTION_REMOTE_BUSYwhen the remote user declines incoming the call, the action will be received for the caller
CallAction.ACTION_AUDIO_DEVICE_CHANGEDwhenever the audio device changed in call, update the audio device UI
CallAction.ACTION_REMOTE_OTHER_BUSYWhen any one of users is busy in group call
CallAction.ACTION_INVITE_USERSWhen you invite users to the call, this will be triggered so that you can update your UI
CallAction.ACTION_VIDEO_CALL_CONVERSION_REJECTEDWhen remote user declined our video call switch request
CallAction.ACTION_VIDEO_CALL_CONVERSION_ACCEPTEDWhen remote user accepted our video call switch request
CallAction.ACTION_VIDEO_CALL_CANCEL_CONVERSIONWhen remote user cancels the video call switch request made by them
CallAction.ACTION_REMOTE_VIDEO_STATUSWhen user pause/resume video in group call
CallAction.ACTION_CAMERA_SWITCH_SUCCESSWhen camera switch done successfully, the action will be received
CallAction.ACTION_CAMERA_SWITCH_FAILUREWhen camera switch error occurs, the action will be received
CallAction.CHANGE_TO_AUDIO_CALLWhen ui needs to be changed as audio call ui this action will be received

Handling the video track events#

For the video call you need to set your local surface view to the below sdk method:

ArgumentTypeDescription
LOCAL_VIDEO_VIEWSurfaceViewRenderersurface view for showing local video
CallManager.getLocalProxyVideoSink().setTarget(LOCAL_VIDEO_VIEW);

Whenever video tack is received in video call, the below callback will be triggered.

@Override
public void onVideoTrackAdded(@NotNull String userJid) {
}

userJid value will be the end user JID who has sent the video track.

You can get the remote video sink using the code below:

ArgumentTypeDescription
USER_JIDStringJid of the remote user
REMOTE_VIDEO_VIEWSurfaceViewRenderersurface view for showing remote user video
CallManager.getRemoteProxyVideoSink(USER_JID).setTarget(REMOTE_VIDEO_VIEW);