Commit 0e366aa8 by 刘鹏

feat : 收到邀请跳转接听界面,未加入中转界面

parent f63843d3
...@@ -31,7 +31,11 @@ ...@@ -31,7 +31,11 @@
android:enabled="true" android:enabled="true"
android:exported="false" /> android:exported="false" />
<activity android:name="com.tencent.liteav.videocall.VideoCallingActivity"/> <activity
android:name="com.tencent.liteav.videocall.VideoCallingActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar" />
</application> </application>
......
...@@ -9,6 +9,8 @@ import android.text.TextUtils; ...@@ -9,6 +9,8 @@ import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.blankj.utilcode.util.ToastUtils; import com.blankj.utilcode.util.ToastUtils;
import com.tencent.liteav.basic.UserModel;
import com.tencent.liteav.basic.UserModelManager;
import com.tencent.liteav.trtccalling.model.TRTCCalling; import com.tencent.liteav.trtccalling.model.TRTCCalling;
import com.tencent.liteav.trtccalling.model.TRTCCallingDelegate; import com.tencent.liteav.trtccalling.model.TRTCCallingDelegate;
import com.tencent.liteav.trtccalling.model.impl.TRTCCallingCallback; import com.tencent.liteav.trtccalling.model.impl.TRTCCallingCallback;
...@@ -22,6 +24,8 @@ import com.tencent.liteav.trtccalling.ui.base.Status; ...@@ -22,6 +24,8 @@ import com.tencent.liteav.trtccalling.ui.base.Status;
import com.tencent.liteav.trtccalling.ui.service.TUICallService; import com.tencent.liteav.trtccalling.ui.service.TUICallService;
import com.tencent.liteav.trtccalling.ui.videocall.TUICallVideoView; import com.tencent.liteav.trtccalling.ui.videocall.TUICallVideoView;
import com.tencent.liteav.trtccalling.ui.videocall.TUIGroupCallVideoView; import com.tencent.liteav.trtccalling.ui.videocall.TUIGroupCallVideoView;
import com.tencent.liteav.videocall.Constant;
import com.tencent.liteav.videocall.VideoCallingActivity;
import com.tencent.trtc.TRTCCloudDef; import com.tencent.trtc.TRTCCloudDef;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -114,7 +118,13 @@ public final class TUICallingImpl implements TUICalling, TRTCCallingDelegate { ...@@ -114,7 +118,13 @@ public final class TUICallingImpl implements TUICalling, TRTCCallingDelegate {
} }
@Override @Override
public void internalCall(final String[] userIDs, final String sponsorID, final String groupID) { public void internalCall(final String[] userIDs, final String sponsorID, final String groupID) {
internalCall(userIDs,sponsorID,groupID,true,Type.VIDEO,Role.CALLED); // internalCall(userIDs,sponsorID,groupID,true,Type.VIDEO,Role.CALLED);
final UserModel userModel = UserModelManager.getInstance().getUserModel();
// Intent intent = new Intent(mContext, VideoCallingActivity.class);
// intent.putExtra(Constant.ROOM_ID, groupID);
// intent.putExtra(Constant.USER_ID, userModel.userId);
// mContext.startActivity(intent);
} }
void internalCall(final String[] userIDs, final String sponsorID, final String groupID, final boolean isFromGroup, final Type type, final Role role) { void internalCall(final String[] userIDs, final String sponsorID, final String groupID, final boolean isFromGroup, final Type type, final Role role) {
...@@ -164,18 +174,25 @@ public final class TUICallingImpl implements TUICalling, TRTCCallingDelegate { ...@@ -164,18 +174,25 @@ public final class TUICallingImpl implements TUICalling, TRTCCallingDelegate {
Runnable task = new Runnable() { Runnable task = new Runnable() {
@Override @Override
public void run() { public void run() {
Intent intent = new Intent(mContext, BaseCallActivity.class); final UserModel userModel = UserModelManager.getInstance().getUserModel();
intent.putExtra(TUICallingConstants.PARAM_NAME_TYPE, type);
intent.putExtra(TUICallingConstants.PARAM_NAME_ROLE, role); // Intent intent = new Intent(mContext, VideoCallingActivity.class);
if (Role.CALLED == role) { // intent.putExtra(Constant.ROOM_ID, groupID);
intent.putExtra(TUICallingConstants.PARAM_NAME_SPONSORID, sponsorID); // intent.putExtra(Constant.USER_ID, userModel.userId);
intent.putExtra(TUICallingConstants.PARAM_NAME_ISFROMGROUP, isFromGroup); // mContext.startActivity(intent);
}
intent.putExtra(TUICallingConstants.PARAM_NAME_USERIDS, userIDs); // Intent intent = new Intent(mContext, BaseCallActivity.class);
intent.putExtra(TUICallingConstants.PARAM_NAME_GROUPID, groupID); // intent.putExtra(TUICallingConstants.PARAM_NAME_TYPE, type);
intent.putExtra(TUICallingConstants.PARAM_NAME_FLOATWINDOW, mEnableFloatWindow); // intent.putExtra(TUICallingConstants.PARAM_NAME_ROLE, role);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // if (Role.CALLED == role) {
mContext.startActivity(intent); // intent.putExtra(TUICallingConstants.PARAM_NAME_SPONSORID, sponsorID);
// intent.putExtra(TUICallingConstants.PARAM_NAME_ISFROMGROUP, isFromGroup);
// }
// intent.putExtra(TUICallingConstants.PARAM_NAME_USERIDS, userIDs);
// intent.putExtra(TUICallingConstants.PARAM_NAME_GROUPID, groupID);
// intent.putExtra(TUICallingConstants.PARAM_NAME_FLOATWINDOW, mEnableFloatWindow);
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// mContext.startActivity(intent);
} }
}; };
mMainHandler.post(task); mMainHandler.post(task);
......
...@@ -2,6 +2,7 @@ package com.tencent.liteav.trtccalling.model; ...@@ -2,6 +2,7 @@ package com.tencent.liteav.trtccalling.model;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.hardware.Sensor; import android.hardware.Sensor;
import android.hardware.SensorEvent; import android.hardware.SensorEvent;
import android.hardware.SensorEventListener; import android.hardware.SensorEventListener;
...@@ -30,6 +31,8 @@ import com.tencent.imsdk.v2.V2TIMSimpleMsgListener; ...@@ -30,6 +31,8 @@ import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
import com.tencent.imsdk.v2.V2TIMUserFullInfo; import com.tencent.imsdk.v2.V2TIMUserFullInfo;
import com.tencent.imsdk.v2.V2TIMUserInfo; import com.tencent.imsdk.v2.V2TIMUserInfo;
import com.tencent.imsdk.v2.V2TIMValueCallback; import com.tencent.imsdk.v2.V2TIMValueCallback;
import com.tencent.liteav.basic.UserModel;
import com.tencent.liteav.basic.UserModelManager;
import com.tencent.liteav.beauty.TXBeautyManager; import com.tencent.liteav.beauty.TXBeautyManager;
import com.tencent.liteav.trtccalling.R; import com.tencent.liteav.trtccalling.R;
import com.tencent.liteav.trtccalling.model.impl.TRTCCallingCallback; import com.tencent.liteav.trtccalling.model.impl.TRTCCallingCallback;
...@@ -43,6 +46,8 @@ import com.tencent.liteav.trtccalling.model.impl.base.TRTCLogger; ...@@ -43,6 +46,8 @@ import com.tencent.liteav.trtccalling.model.impl.base.TRTCLogger;
import com.tencent.liteav.trtccalling.model.util.MediaPlayHelper; import com.tencent.liteav.trtccalling.model.util.MediaPlayHelper;
import com.tencent.liteav.trtccalling.model.util.PermissionUtil; import com.tencent.liteav.trtccalling.model.util.PermissionUtil;
import com.tencent.liteav.trtccalling.model.util.TUICallingConstants; import com.tencent.liteav.trtccalling.model.util.TUICallingConstants;
import com.tencent.liteav.videocall.Constant;
import com.tencent.liteav.videocall.VideoCallingActivity;
import com.tencent.qcloud.tuicore.TUILogin; import com.tencent.qcloud.tuicore.TUILogin;
import com.tencent.rtmp.TXLiveBase; import com.tencent.rtmp.TXLiveBase;
import com.tencent.rtmp.ui.TXCloudVideoView; import com.tencent.rtmp.ui.TXCloudVideoView;
...@@ -68,18 +73,18 @@ import java.util.Set; ...@@ -68,18 +73,18 @@ import java.util.Set;
* 本功能使用腾讯云实时音视频 / 腾讯云即时通信IM 组合实现 * 本功能使用腾讯云实时音视频 / 腾讯云即时通信IM 组合实现
*/ */
public class TRTCCalling { public class TRTCCalling {
private static final String TAG = "TRTCCalling"; private static final String TAG = "TRTCCalling";
/** /**
* 超时时间,单位秒 * 超时时间,单位秒
*/ */
public static final int TIME_OUT_COUNT = 30; public static final int TIME_OUT_COUNT = 30;
/** /**
* room id 的取值范围 * room id 的取值范围
*/ */
private static final int ROOM_ID_MIN = 1; private static final int ROOM_ID_MIN = 1;
private static final int ROOM_ID_MAX = Integer.MAX_VALUE; private static final int ROOM_ID_MAX = Integer.MAX_VALUE;
private final Context mContext; private final Context mContext;
/** /**
* 底层SDK调用实例 * 底层SDK调用实例
...@@ -89,36 +94,36 @@ public class TRTCCalling { ...@@ -89,36 +94,36 @@ public class TRTCCalling {
/** /**
* 是否首次邀请 * 是否首次邀请
*/ */
private boolean isOnCalling = false; private boolean isOnCalling = false;
private String mCurCallID = ""; private String mCurCallID = "";
private String mSwitchToAudioCallID = ""; private String mSwitchToAudioCallID = "";
private int mCurRoomID = 0; private int mCurRoomID = 0;
/** /**
* C2C多人通话添加: 记录每个userId对应的CallId * C2C多人通话添加: 记录每个userId对应的CallId
*/ */
private Map<String, String> mUserCallIDMap = new HashMap<>(); private Map<String, String> mUserCallIDMap = new HashMap<>();
/** /**
* C2C多人通话添加: 记录已经接通在TRTC房间内的远端用户 * C2C多人通话添加: 记录已经接通在TRTC房间内的远端用户
*/ */
private List<String> mRemoteUserInTRTCRoom = new ArrayList<>(); private List<String> mRemoteUserInTRTCRoom = new ArrayList<>();
/** /**
* 当前是否在TRTC房间中 * 当前是否在TRTC房间中
*/ */
private boolean mIsInRoom = false; private boolean mIsInRoom = false;
private long mEnterRoomTime = 0; private long mEnterRoomTime = 0;
/** /**
* 当前邀请列表 * 当前邀请列表
* C2C通话时会记录自己邀请的用户 * C2C通话时会记录自己邀请的用户
* IM群组通话时会同步群组内邀请的用户 * IM群组通话时会同步群组内邀请的用户
* 当用户接听、拒绝、忙线、超时会从列表中移除该用户 * 当用户接听、拒绝、忙线、超时会从列表中移除该用户
*/ */
private List<String> mCurInvitedList = new ArrayList<>(); private List<String> mCurInvitedList = new ArrayList<>();
/** /**
* 当前语音通话中的远端用户 * 当前语音通话中的远端用户
*/ */
private Set<String> mCurRoomRemoteUserSet = new HashSet<>(); private Set<String> mCurRoomRemoteUserSet = new HashSet<>();
/** /**
* C2C通话的邀请人 * C2C通话的邀请人
...@@ -129,45 +134,45 @@ public class TRTCCalling { ...@@ -129,45 +134,45 @@ public class TRTCCalling {
/** /**
* 当前通话的类型 * 当前通话的类型
*/ */
private int mCurCallType = TYPE_UNKNOWN; private int mCurCallType = TYPE_UNKNOWN;
/** /**
* 当前群组通话的群组ID * 当前群组通话的群组ID
*/ */
private String mCurGroupId = ""; private String mCurGroupId = "";
/** /**
* 最近使用的通话信令,用于快速处理 * 最近使用的通话信令,用于快速处理
*/ */
private CallModel mLastCallModel = new CallModel(); private CallModel mLastCallModel = new CallModel();
/** /**
* 上层传入回调 * 上层传入回调
*/ */
private TRTCInternalListenerManager mTRTCInternalListenerManager; private TRTCInternalListenerManager mTRTCInternalListenerManager;
private String mNickName; private String mNickName;
private String mFaceUrl; private String mFaceUrl;
private boolean mIsUseFrontCamera; private boolean mIsUseFrontCamera;
private MediaPlayHelper mMediaPlayHelper; // 音效 private MediaPlayHelper mMediaPlayHelper; // 音效
private SensorManager mSensorManager; private SensorManager mSensorManager;
private SensorEventListener mSensorEventListener; private SensorEventListener mSensorEventListener;
private boolean mIsBeingCalled = true; // 默认是被叫 private boolean mIsBeingCalled = true; // 默认是被叫
private boolean mEnableMuteMode = false; // 是否开启静音模式 private boolean mEnableMuteMode = false; // 是否开启静音模式
private String mCallingBellPath = ""; // 被叫铃音路径 private String mCallingBellPath = ""; // 被叫铃音路径
private static final String PROFILE_TUICALLING = "per_profile_tuicalling"; private static final String PROFILE_TUICALLING = "per_profile_tuicalling";
private static final String PROFILE_CALL_BELL = "per_call_bell"; private static final String PROFILE_CALL_BELL = "per_call_bell";
public static final int TYPE_UNKNOWN = 0; public static final int TYPE_UNKNOWN = 0;
public static final int TYPE_AUDIO_CALL = 1; public static final int TYPE_AUDIO_CALL = 1;
public static final int TYPE_VIDEO_CALL = 2; public static final int TYPE_VIDEO_CALL = 2;
//通话邀请缓存,便于查询通话是否有效 //通话邀请缓存,便于查询通话是否有效
private final Map<String, CallModel> mInviteMap = new HashMap<>(); private final Map<String, CallModel> mInviteMap = new HashMap<>();
private final Handler mMainHandler = new Handler(Looper.getMainLooper()); private final Handler mMainHandler = new Handler(Looper.getMainLooper());
private static final int CHECK_INVITE_PERIOD = 10; //邀请信令的检测周期(毫秒) private static final int CHECK_INVITE_PERIOD = 10; //邀请信令的检测周期(毫秒)
private static final int CHECK_INVITE_DURATION = 100; //邀请信令的检测总时长(毫秒) private static final int CHECK_INVITE_DURATION = 100; //邀请信令的检测总时长(毫秒)
//多端登录增加字段:用于标记当前是否是自己发给自己的请求(多端触发),以及自己是否处理了该请求. //多端登录增加字段:用于标记当前是否是自己发给自己的请求(多端触发),以及自己是否处理了该请求.
...@@ -317,7 +322,16 @@ public class TRTCCalling { ...@@ -317,7 +322,16 @@ public class TRTCCalling {
List<String> inviteeList, String data) { List<String> inviteeList, String data) {
TRTCLogger.d(TAG, "onReceiveNewInvitation inviteID:" + inviteID + ", inviter:" + inviter TRTCLogger.d(TAG, "onReceiveNewInvitation inviteID:" + inviteID + ", inviter:" + inviter
+ ", groupID:" + groupID + ", inviteeList:" + inviteeList + " data:" + data); + ", groupID:" + groupID + ", inviteeList:" + inviteeList + " data:" + data);
handleRecvCallModel(inviteID, inviter, groupID, inviteeList, data);
final UserModel userModel = UserModelManager.getInstance().getUserModel();
Intent intent = new Intent(mContext, VideoCallingActivity.class);
intent.putExtra(Constant.ROOM_ID, groupID);
intent.putExtra(Constant.USER_ID, userModel.userId);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
// handleRecvCallModel(inviteID, inviter, groupID, inviteeList, data);
} }
@Override @Override
...@@ -1153,7 +1167,13 @@ public class TRTCCalling { ...@@ -1153,7 +1167,13 @@ public class TRTCCalling {
if (isCollectionEmpty(userIdList)) { if (isCollectionEmpty(userIdList)) {
return; return;
} }
internalCall(userIdList, type, groupId); final UserModel userModel = UserModelManager.getInstance().getUserModel();
Intent intent = new Intent(mContext, VideoCallingActivity.class);
intent.putExtra(Constant.ROOM_ID, groupId);
intent.putExtra(Constant.USER_ID, userModel.userId);
mContext.startActivity(intent);
// internalCall(userIdList, type, groupId);
} }
/** /**
...@@ -1171,7 +1191,7 @@ public class TRTCCalling { ...@@ -1171,7 +1191,7 @@ public class TRTCCalling {
mCurCallType = type; mCurCallType = type;
mIsBeingCalled = false; mIsBeingCalled = false;
TRTCLogger.d(TAG, "First calling, generate room id " + mCurRoomID); TRTCLogger.d(TAG, "First calling, generate room id " + mCurRoomID);
enterTRTCRoom(mCurRoomID,mCurCallType); enterTRTCRoom(mCurRoomID, mCurCallType);
startCall(); startCall();
startDialingMusic(); startDialingMusic();
} }
...@@ -1255,14 +1275,14 @@ public class TRTCCalling { ...@@ -1255,14 +1275,14 @@ public class TRTCCalling {
public void accept() { public void accept() {
mIsProcessedBySelf = true; mIsProcessedBySelf = true;
enterTRTCRoom(mCurRoomID,mCurCallType); enterTRTCRoom(mCurRoomID, mCurCallType);
stopRing(); stopRing();
} }
/** /**
* trtc 进房 * trtc 进房
*/ */
public void enterTRTCRoom(int roomId,int callType) { public void enterTRTCRoom(int roomId, int callType) {
if (callType == TYPE_VIDEO_CALL) { if (callType == TYPE_VIDEO_CALL) {
// 开启基础美颜 // 开启基础美颜
TXBeautyManager txBeautyManager = mTRTCCloud.getBeautyManager(); TXBeautyManager txBeautyManager = mTRTCCloud.getBeautyManager();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment