Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class EaseCallKit {
private String channelName;
private String fromUserId; //被叫获取主叫的
public static String deviceId = "android_";
public String clallee_devId;
public String callee_devId;
private String callID = null;
private JSONObject inviteExt = null;
private EaseCallInfo callInfo = new EaseCallInfo();
Expand Down Expand Up @@ -202,9 +202,10 @@ public enum CALL_PROCESS_ERROR {
* @param type 通话类型(只能为SINGLE_VOICE_CALL或SINGLE_VIDEO_CALL类型)
* @param user 被叫用户ID(也就是环信ID)
* @param ext 扩展字段(用户扩展字段)
* @param resultId 自定义标识,用来区分呼叫失败的callback是由哪个方法引起的
*/
public void startSingleCall(final EaseCallType type, final String user,final Map<String, Object> ext){
startSingleCall(type, user, ext, defaultVideoCallCls);
public void startSingleCall(final EaseCallType type, final String user,final Map<String, Object> ext, String resultId){
startSingleCall(type, user, ext, defaultVideoCallCls, resultId);
}

/**
Expand All @@ -214,23 +215,24 @@ public void startSingleCall(final EaseCallType type, final String user,final Ma
* @param user 被叫用户ID(也就是环信ID)
* @param ext 扩展字段(用户扩展字段)
* @param cls 继承自{@link EaseVideoCallActivity}的activity
* @param resultId 自定义标识,用来区分呼叫失败的callback是由哪个方法引起的
*/
public void startSingleCall(final EaseCallType type, final String user,final Map<String, Object> ext, Class<? extends EaseVideoCallActivity> cls){
public void startSingleCall(final EaseCallType type, final String user,final Map<String, Object> ext, Class<? extends EaseVideoCallActivity> cls, String resultId){
if(callState != EaseCallState.CALL_IDLE){
if(callListener != null){
callListener.onCallError(EaseCallError.PROCESS_ERROR,CALL_PROCESS_ERROR.CALL_STATE_ERROR.code,"current state is busy");
callListener.onCallError(EaseCallError.PROCESS_ERROR,CALL_PROCESS_ERROR.CALL_STATE_ERROR.code,"current state is busy", resultId);
}
return;
}
if(type == EaseCallType.CONFERENCE_CALL){
if(callListener != null){
callListener.onCallError(EaseCallError.PROCESS_ERROR,CALL_PROCESS_ERROR.CALL_TYPE_ERROR.code,"call type is error");
callListener.onCallError(EaseCallError.PROCESS_ERROR,CALL_PROCESS_ERROR.CALL_TYPE_ERROR.code,"call type is error",resultId);
}
return;
}
if(user != null && user.length() == 0){
if(callListener != null){
callListener.onCallError(EaseCallError.PROCESS_ERROR,CALL_PROCESS_ERROR.CALL_PARAM_ERROR.code,"user is null");
callListener.onCallError(EaseCallError.PROCESS_ERROR,CALL_PROCESS_ERROR.CALL_PARAM_ERROR.code,"user is null",resultId);
}
return;
}
Expand Down Expand Up @@ -261,8 +263,8 @@ public void startSingleCall(final EaseCallType type, final String user,final Ma
* @param users 用户ID列表(环信ID列表)
* @param ext 扩展字段(用户扩展字段)
*/
public void startInviteMultipleCall(final String[] users,final Map<String, Object> ext){
startInviteMultipleCall(users, ext, defaultMultiVideoCls);
public void startInviteMultipleCall(final String[] users,final Map<String, Object> ext, String resultId){
startInviteMultipleCall(users, ext, defaultMultiVideoCls, resultId);
}

/**
Expand All @@ -272,10 +274,10 @@ public void startInviteMultipleCall(final String[] users,final Map<String, Objec
* @param ext 扩展字段(用户扩展字段)
* @param cls 继承自{@link EaseMultipleVideoActivity}的activity
*/
public void startInviteMultipleCall(final String[] users,final Map<String, Object> ext, Class<? extends EaseMultipleVideoActivity> cls){
public void startInviteMultipleCall(final String[] users,final Map<String, Object> ext, Class<? extends EaseMultipleVideoActivity> cls, String resultId){
if(callState != EaseCallState.CALL_IDLE && callType != EaseCallType.CONFERENCE_CALL){
if(callListener != null){
callListener.onCallError(EaseCallError.PROCESS_ERROR,CALL_PROCESS_ERROR.CALL_STATE_ERROR.code,"current state is busy");
callListener.onCallError(EaseCallError.PROCESS_ERROR,CALL_PROCESS_ERROR.CALL_STATE_ERROR.code,"current state is busy", resultId);
}
return;
}
Expand All @@ -287,7 +289,7 @@ public void startInviteMultipleCall(final String[] users,final Map<String, Objec
appContext.startActivity(intent);
}else{
if(callListener != null){
callListener.onCallError(EaseCallError.PROCESS_ERROR,CALL_PROCESS_ERROR.CALL_PARAM_ERROR.code,"users is null");
callListener.onCallError(EaseCallError.PROCESS_ERROR,CALL_PROCESS_ERROR.CALL_PARAM_ERROR.code,"users is null", resultId);
}
}
}else{
Expand Down Expand Up @@ -332,8 +334,8 @@ public Class<? extends EaseBaseCallActivity> getCurrentCallClass() {
}

/**
* If you call {@link #startSingleCall(EaseCallType, String, Map)}, {@link #startSingleCall(EaseCallType, String, Map, Class)}
* or {@link #startInviteMultipleCall(String[], Map)}, you should call the method of {@link #releaseCall()} when the {@link #curCallCls} is finishing.
* If you call {@link #startSingleCall(EaseCallType, String, Map, String)}, {@link #startSingleCall(EaseCallType, String, Map, Class, String)}
* or {@link #startInviteMultipleCall(String[], Map, String)}, you should call the method of {@link #releaseCall()} when the {@link #curCallCls} is finishing.
*/
public void releaseCall() {
if(curCallCls != null) {
Expand Down Expand Up @@ -369,7 +371,7 @@ public void onMessageReceived(List<EMMessage> messages) {

if(action == null || callerDevId == null || fromCallId == null || fromUser ==null || channel == null){
if(callListener != null){
callListener.onCallError(EaseCallError.PROCESS_ERROR,CALL_PROCESS_ERROR.CALL_RECEIVE_ERROR.code,"receive message error");
callListener.onCallError(EaseCallError.PROCESS_ERROR,CALL_PROCESS_ERROR.CALL_RECEIVE_ERROR.code,"receive message error", null);
}
continue;
}
Expand Down Expand Up @@ -483,7 +485,7 @@ public void onCmdMessageReceived(List<EMMessage> messages) {
if(callState == EaseCallState.CALL_IDLE){
callState = EaseCallState.CALL_ALERTING;
//对方主叫的设备信息
clallee_devId = callerDevId;
callee_devId = callerDevId;
callID = fromCallId;
EaseCallInfo info = callInfoMap.get(fromCallId);
if(info != null){
Expand Down Expand Up @@ -644,8 +646,8 @@ public void setCallState(EaseCallState callState) {

public void setCallID(String callID) { this.callID = callID; }

public String getClallee_devId() {
return clallee_devId;
public String getCallee_devId() {
return callee_devId;
}

public EaseCallKitListener getCallListener() {
Expand Down Expand Up @@ -701,7 +703,7 @@ public void onError(int code, String error) {
EMLog.e(TAG, "Invite call error " + code + ", " + error);
conversation.removeMessage(message.getMsgId());
if(callListener != null){
callListener.onCallError(EaseCallError.IM_ERROR,code,error);
callListener.onCallError(EaseCallError.IM_ERROR,code,error, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public interface EaseCallKitListener{
* @param type 错误类型
* @param errorCode 错误码
* @param description 错误描述
* @param resultId 自定义id,呼叫时传入,用来标识本次callback是由哪次呼叫触发
*/
void onCallError(EaseCallKit.EaseCallError type, int errorCode, String description);
void onCallError(EaseCallKit.EaseCallError type, int errorCode, String description, String resultId);


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class EaseMultipleVideoActivity extends EaseBaseCallActivity implements V
private static final String TAG = EaseMultipleVideoActivity.class.getSimpleName();

private TimeHandler timehandler;
private TimeHandler timeUpdataTimer;
private TimeHandler timeUpdateTimer;
private RtcEngine mRtcEngine;

private EaseCommingCallView incomingCallView;
Expand All @@ -114,7 +114,7 @@ public class EaseMultipleVideoActivity extends EaseBaseCallActivity implements V
private ImageButton cameraSwitch;
private ImageButton speakerSwitch;
private ImageButton changeCameraSwitch;
private ImageButton hangupBtn;;
private ImageButton hangupBtn;
private ImageView inviteBtn;
private ImageView floatBtn;

Expand Down Expand Up @@ -165,15 +165,15 @@ public void onError(int err) {
super.onError(err);
EMLog.d(TAG,"IRtcEngineEventHandler onError:" + err);
if(listener != null){
listener.onCallError(EaseCallKit.EaseCallError.RTC_ERROR,err,"rtc error");
listener.onCallError(EaseCallKit.EaseCallError.RTC_ERROR,err,"rtc error",null);
}
}

@Override
public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
EMLog.d(TAG,"onJoinChannelSuccess channel:"+ channel + " uid" +uid);
//加入频道开始计时
timeUpdataTimer.startTime(CALL_TIMER_CALL_TIME);
timeUpdateTimer.startTime(CALL_TIMER_CALL_TIME);
if(!isInComingCall){
ArrayList<String> userList = EaseCallKit.getInstance().getInviteeUsers();
if(userList != null && userList.size() > 0){
Expand Down Expand Up @@ -523,7 +523,7 @@ protected void onCreate(Bundle savedInstanceState) {
checkSelfPermission(REQUESTED_PERMISSIONS[2], PERMISSION_REQ_ID)) {
}
timehandler = new TimeHandler();
timeUpdataTimer = new TimeHandler();
timeUpdateTimer = new TimeHandler();
checkConference(true);
}

Expand Down Expand Up @@ -744,7 +744,7 @@ public void onClick(View view) {
changeCameraDirect(!isCameraFront);
}else if(view.getId() == R.id.btn_hangup){
if(listener != null){
listener.onEndCallWithReason(callType,channelName, EaseCallEndReason.EaseCallEndReasonHangup,timeUpdataTimer.timePassed*1000);
listener.onEndCallWithReason(callType,channelName, EaseCallEndReason.EaseCallEndReasonHangup,timeUpdateTimer.timePassed*1000);
}
exitChannel();
}else if(view.getId() == R.id.btn_float){
Expand Down Expand Up @@ -940,7 +940,7 @@ public void onPickupClick(View v) {
AnswerEvent event = new AnswerEvent();
event.result = EaseMsgUtils.CALL_ANSWER_ACCEPT;
event.callId = EaseCallKit.getInstance().getCallID();
event.callerDevId = EaseCallKit.getInstance().getClallee_devId();
event.callerDevId = EaseCallKit.getInstance().getCallee_devId();
event.calleeDevId = EaseCallKit.deviceId;
sendCmdMsg(event,username);
}
Expand All @@ -955,7 +955,7 @@ public void onRejectClick(View v) {
AnswerEvent event = new AnswerEvent();
event.result = EaseMsgUtils.CALL_ANSWER_REFUSE;
event.callId = EaseCallKit.getInstance().getCallID();
event.callerDevId = EaseCallKit.getInstance().getClallee_devId();
event.callerDevId = EaseCallKit.getInstance().getCallee_devId();
event.calleeDevId = EaseCallKit.deviceId;
sendCmdMsg(event,username);
}
Expand Down Expand Up @@ -1237,7 +1237,7 @@ public void onError(int code, String error) {
EMLog.e(TAG, "Invite call error " + code + ", " + error + " username:" + username);

if (listener != null) {
listener.onCallError(EaseCallKit.EaseCallError.IM_ERROR, code, error);
listener.onCallError(EaseCallKit.EaseCallError.IM_ERROR, code, error, null);
listener.onInViteCallMessageSent();
}
}
Expand Down Expand Up @@ -1308,7 +1308,7 @@ public void onError(int code, String error) {
EMLog.e(TAG, "Invite call error " + code + ", " + error);
conversation.removeMessage(message.getMsgId());
if(listener != null){
listener.onCallError(EaseCallKit.EaseCallError.IM_ERROR,code,error);
listener.onCallError(EaseCallKit.EaseCallError.IM_ERROR,code,error, null);
}
if(event.callAction == EaseCallAction.CALL_CANCEL){
//退出频道
Expand Down Expand Up @@ -1514,9 +1514,9 @@ public void run() {
@Override
public void doShowFloatWindow() {
super.doShowFloatWindow();
if(timeUpdataTimer != null) {
Log.e(TAG, "timeUpdataTimer cost seconds: "+timeUpdataTimer.timePassed);
EaseCallFloatWindow.getInstance().setCostSeconds(timeUpdataTimer.timePassed);
if(timeUpdateTimer != null) {
Log.e(TAG, "timeUpdataTimer cost seconds: "+timeUpdateTimer.timePassed);
EaseCallFloatWindow.getInstance().setCostSeconds(timeUpdateTimer.timePassed);
}
EaseCallFloatWindow.getInstance().show();
setConferenceInfoAfterShowFloat();
Expand Down Expand Up @@ -1609,9 +1609,9 @@ private void checkConference(boolean isNew) {
// 防止activity在后台被start至前台导致window还存在
long costSeconds = EaseCallFloatWindow.getInstance().getTotalCostSeconds();
Log.e(TAG, "costSeconds: "+costSeconds);
if(timeUpdataTimer != null) {
timeUpdataTimer.timePassed = (int) costSeconds;
updateTime(timeUpdataTimer);
if(timeUpdateTimer != null) {
timeUpdateTimer.timePassed = (int) costSeconds;
updateTime(timeUpdateTimer);
}
EaseCallFloatWindow.getInstance().dismiss();
}
Expand Down Expand Up @@ -1686,8 +1686,8 @@ protected void onDestroy() {
if(timehandler != null){
timehandler.stopTime();
}
if(timeUpdataTimer != null){
timeUpdataTimer.stopTime();
if(timeUpdateTimer != null){
timeUpdateTimer.stopTime();
}
if(mUidsList != null){
mUidsList.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void onError(int err) {
super.onError(err);
EMLog.d(TAG,"IRtcEngineEventHandler onError:" + err);
if(listener != null){
listener.onCallError(EaseCallKit.EaseCallError.RTC_ERROR,err,"rtc error");
listener.onCallError(EaseCallKit.EaseCallError.RTC_ERROR,err,"rtc error", null);
}
}

Expand Down Expand Up @@ -733,7 +733,7 @@ public void onClick(View view) {
AnswerEvent event = new AnswerEvent();
event.result = EaseMsgUtils.CALL_ANSWER_REFUSE;
event.callId = EaseCallKit.getInstance().getCallID();
event.callerDevId = EaseCallKit.getInstance().getClallee_devId();
event.callerDevId = EaseCallKit.getInstance().getCallee_devId();
event.calleeDevId = EaseCallKit.deviceId;
sendCmdMsg(event,username);
}
Expand All @@ -745,7 +745,7 @@ public void onClick(View view) {
AnswerEvent event = new AnswerEvent();
event.result = EaseMsgUtils.CALL_ANSWER_ACCEPT;
event.callId = EaseCallKit.getInstance().getCallID();
event.callerDevId = EaseCallKit.getInstance().getClallee_devId();
event.callerDevId = EaseCallKit.getInstance().getCallee_devId();
event.calleeDevId = EaseCallKit.deviceId;
sendCmdMsg(event,username);
}
Expand Down Expand Up @@ -840,7 +840,7 @@ public void onClick(View view) {
AnswerEvent event = new AnswerEvent();
event.result = EaseMsgUtils.CALL_ANSWER_ACCEPT;
event.callId = EaseCallKit.getInstance().getCallID();
event.callerDevId = EaseCallKit.getInstance().getClallee_devId();
event.callerDevId = EaseCallKit.getInstance().getCallee_devId();
event.calleeDevId = EaseCallKit.deviceId;
event.transVoice = true;
sendCmdMsg(event,username);
Expand Down Expand Up @@ -1223,7 +1223,7 @@ public void onSuccess() {
public void onError(int code, String error) {
EMLog.e(TAG, "Invite call error " + code + ", " + error);
if(listener != null){
listener.onCallError(EaseCallKit.EaseCallError.IM_ERROR,code,error);
listener.onCallError(EaseCallKit.EaseCallError.IM_ERROR,code,error, null);
listener.onInViteCallMessageSent();
}
}
Expand Down Expand Up @@ -1334,7 +1334,7 @@ public void onError(int code, String error) {
conversation.removeMessage(message.getMsgId());
}
if(listener != null){
listener.onCallError(EaseCallKit.EaseCallError.IM_ERROR,code,error);
listener.onCallError(EaseCallKit.EaseCallError.IM_ERROR,code,error, null);
}
if(event.callAction == EaseCallAction.CALL_CANCEL){
//退出频道
Expand Down