回调接口

IRongCallListener 是通话状态的监听类,CallKit 的 RongCallProxy.java 已经实现了该监听,并且会回调到 BaseCallActivity 中的各个方法,您可以继承 BaseCallActivity,根据需要复写其中的对应方法,即可获取对应的通话回调。

public class MyCallActivity extends BaseCallActivity {
    @Override
    public void onCallOutgoing(RongCallSession callSession, SurfaceView localVideo) {
        super.onCallOutgoing(callSession, localVideo);
    }

    @Override
    public void onCallConnected(RongCallSession callSession, SurfaceView localVideo) {
        super.onCallConnected(callSession, localVideo);
    }

    @Override
    public void onCallDisconnected(RongCallSession callSession, RongCallCommon.CallDisconnectedReason reason) {
        super.onCallDisconnected(callSession, reason);
    }

    @Override
    public void onRemoteUserRinging(String userId) {
        super.onRemoteUserRinging(userId);
    }

    @Override
    public void onRemoteUserJoined(String userId, RongCallCommon.CallMediaType mediaType, int userType, SurfaceView remoteVideo) {
        super.onRemoteUserJoined(userId, mediaType, userType, remoteVideo);
    }

    @Override
    public void onRemoteUserInvited(String userId, RongCallCommon.CallMediaType mediaType) {
        super.onRemoteUserInvited(userId, mediaType);
    }

    @Override
    public void onRemoteUserLeft(String userId, RongCallCommon.CallDisconnectedReason reason) {
        super.onRemoteUserLeft(userId, reason);
    }

    @Override
    public void onMediaTypeChanged(String userId, RongCallCommon.CallMediaType mediaType, SurfaceView video) {
        super.onMediaTypeChanged(userId, mediaType, video);
    }

    @Override
    public void onError(RongCallCommon.CallErrorCode errorCode) {
        super.onError(errorCode);
    }

    @Override
    public void onRemoteCameraDisabled(String userId, boolean disabled) {
        super.onRemoteCameraDisabled(userId, disabled);
    }

    @Override
    public void onWhiteBoardURL(String url) {
        super.onWhiteBoardURL(url);
    }

    @Override
    public void onNetWorkLossRate(int lossRate) {
        super.onNetWorkLossRate(lossRate);
    }

    @Override
    public void onNotifySharingScreen(String userId, boolean isSharing) {
        super.onNotifySharingScreen(userId, isSharing);
    }

    @Override
    public void onNotifyDegradeNormalUserToObserver(String userId) {
        super.onNotifyDegradeNormalUserToObserver(userId);
    }

    @Override
    public void onNotifyAnswerObserverRequestBecomeNormalUser(String userId, long status) {
        super.onNotifyAnswerObserverRequestBecomeNormalUser(userId, status);
    }

    @Override
    public void onNotifyUpgradeObserverToNormalUser() {
        super.onNotifyUpgradeObserverToNormalUser();
    }

    @Override
    public void onNotifyHostControlUserDevice(String userId, int dType, int isOpen) {
        super.onNotifyHostControlUserDevice(userId, dType, isOpen);
    }
}
如果上述方法不适合,您还可以通过修改 RongCallProxy.java 的代码,实现自己应用的监听。示例如下:

public class RongCallProxy implements IRongCallListener {

    private IRongCallListener mCallListener;  // 增加一个监听。

    /*设置自己应用的监听*/
    public void setAppCallListener(IRongCallListener listener) {
        this.mAppCallListener = listener;
    }

   /*修改对应的通话状态回调的方法,使其回调到您设置的应用自身的监听*/
    @Override
    public void onCallOutgoing(RongCallSession callSession, SurfaceView localVideo) {
        if (mCallListener != null) {
          mCallListener.onCallOutgoing(callSession, localVideo);
        }
        /*增加的代码,回调应用设置的监听*/
        if(mAppCallListener != null) {
          mAppCallListener.onCallOutgoing(callSession, localVideo);
        }
      }
      ... // 根据您的需要,同样的方式修改其它通话状态回调函数。
    }

修改完上述方法后,在您的应用里调用 setAppCallListener() 设置您自己的监听。