One-to-one video call (VOIP)

7.1 Obtain XHVoipManager instance and add VOIP event listener

XHVoipManager voipManager = XHClient.getInstance().getVoipManager();
voipManager.addListener(new IXHVoipManagerListener() {
@Override
public void onCalling(String fromID) {
//Receive a call
}

@Override
public void onAudioCalling(String fromID) {
////Receive a audio call
}

@Override
public void onCancled(String fromID) {
//the other side has canceled the call
}

@Override
public void onRefused(String fromID) {
//The call has been refused
}

@Override
public void onBusy(String fromID) {
//the other side is busy now
}

@Override
public void onMiss(String fromID) {
//Missed call (calling by someone else during the call)
}

@Override
public void onConnected(String fromID) {
//the other side has been connected now
}

@Override
public void onHangup(String fromID) {
//The other side has hung up
}

@Override
public void onError(String errorCode) {
//Connection error
}

@Override
public void onReceiveRealtimeData(byte[] data) {
//Receive real-time whiteboard data
}

@Override
public void onTransStateChanged(int state) {
//Transmission status change 0: Server relay 1: P2P direct connection
}
});

7.2 XHVoipManager API Description

/**
* Add VOIP event listener
* @param voipManagerListener IXHVoipManagerListener Receive VOIP related events
*/
void addListener(IXHVoipManagerListener voipManagerListener);

/**
* Set the media type (audio and video, audio, video)
* @param mediaTypeEnum media type
*/
void setRtcMediaType(XHConstants.XHRtcMediaTypeEnum mediaTypeEnum);
/**
* Get the media type(audio and video, audio, video)
*/
XHConstants.XHRtcMediaTypeEnum getRtcMediaType();

/**
* Switch camera direction
*/
void switchCamera();

/**
* Switch camera direction
* @param cameraId Specified camera ID
*/
void switchCamera(int cameraId);

/**
* Set the Player that displays the two screens. You can pass null when you don't need to display the video view.
* @param selfPlayer Your own view
* @param targetPlayer Target view
* @param callback Result callback
*/
void setupView(StarPlayer selfPlayer, StarPlayer targetPlayer, IXHResultCallback callback);

/**
* The calling party call the function
* Start a video call
* @param context Context
* @param toID The called user ID
* @param callback Result callback. The sessionid will be returned upon success, which is used for query of recording records on the server.
*/
void call(Context context,String toID, IXHResultCallback callback);

/**
* The calling call the function
* Start an audio call
* @param context Context
* @param toID The called user ID
* @param callback Result callback. The sessionid will be returned upon success, which is used for query of recording records on the server.
*/
void audioCall(Context context,String toID, IXHResultCallback callback);

/**
* cancel the call(Calling party call the function)
* Before the other party answers or rejects, the calling party cancels the call actively.
* @param callback
*/
void cancel(IXHResultCallback callback);

/**
* Agree to talk to the calling party (called by the called party)
* @param context Context
* @param fromID the caller ID
* @param callback Result callback. The sessionid will be returned upon success, which is used for query of recording records on the server.
*/
void accept(Context context,String fromID, IXHResultCallback callback);

/**
* Refuse to talk to the calling party (called by the called party)
* @param callback Result callback
*/
void refuse(IXHResultCallback callback);

/**
* hangup
* @param callback Result callback
*/
void hangup(IXHResultCallback callback);

/**
* Dynamically switch audio:the audio can be switched at any time during the live broadcast, and the status is automatically reset after the live broadcast ends.
*/
void setAudioEnable(Boolean enable);

/**
* Dynamically switch video:the video can be switched at any time during the live broadcast, and the status is automatically reset after the live broadcast ends.
*/
void setVideoEnable(Boolean enable);

/**
* Set recorder
* @param recorder
*/
void setRecorder(IXHRecorder recorder);

/**
* Switch recorder
* @param recorder
*/
void resetRecorder(IXHRecorder recorder);