فهرست منبع

#ADD 添加探视功能

weizhengliang 3 سال پیش
والد
کامیت
fca5fc11a6
22فایلهای تغییر یافته به همراه334 افزوده شده و 83 حذف شده
  1. 1 0
      common/src/main/res/values/colors.xml
  2. 5 0
      middleware/src/main/code/com/wdkl/ncs/android/middleware/common/Constants.kt
  3. 0 6
      middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/TcpClientHandler.java
  4. 1 0
      middleware/src/main/code/com/wdkl/ncs/android/middleware/utils/CommonUtils.java
  5. 30 8
      nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/activity/NurseHomeActivity.kt
  6. 1 1
      nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/fragment/FramePartFragment.kt
  7. 1 1
      nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/settingconfig/SettingConfig.java
  8. 5 5
      nursehome/src/main/res/layout/activity_nurse_home.xml
  9. 4 2
      webrtc/src/main/java/com/wdkl/core/socket/SocketManager.java
  10. 1 1
      webrtc/src/main/java/com/wdkl/core/voip/CallForegroundNotification.java
  11. 18 6
      webrtc/src/main/java/com/wdkl/core/voip/CallMultiActivity.java
  12. 11 3
      webrtc/src/main/java/com/wdkl/core/voip/CallSingleActivity.java
  13. 21 5
      webrtc/src/main/java/com/wdkl/core/voip/FragmentMeeting.java
  14. 68 34
      webrtc/src/main/java/com/wdkl/core/voip/FragmentVideo.java
  15. 0 2
      webrtc/src/main/java/com/wdkl/core/voip/SingleCallFragment.java
  16. 1 1
      webrtc/src/main/java/com/wdkl/core/voip/VoipReceiver.java
  17. 103 0
      webrtc/src/main/java/com/wdkl/core/window/VisitingWindow.java
  18. 6 0
      webrtc/src/main/res/drawable/alert_window_bg.xml
  19. 1 1
      webrtc/src/main/res/layout/activity_multi_call.xml
  20. 4 4
      webrtc/src/main/res/layout/adapter_visit_bed.xml
  21. 10 3
      webrtc/src/main/res/layout/fragment_video.xml
  22. 42 0
      webrtc/src/main/res/layout/window_visiting.xml

+ 1 - 0
common/src/main/res/values/colors.xml

@@ -6,6 +6,7 @@
     <color name="black">#000000</color>
     <color name="color_mask">#77000000</color>
     <color name="color_white">#ffffffff</color>
+    <color name="color_transparent">#bbe4e6e5</color>
     <color name="color_gray">#e4e6e5</color>
     <color name="color_red">#ea3a3d</color>
     <color name="color_pop_header">#878a8a</color>

+ 5 - 0
middleware/src/main/code/com/wdkl/ncs/android/middleware/common/Constants.kt

@@ -56,6 +56,11 @@ class Constants {
         //被探视床位分机id
         var visitedId: Int? = -1
 
+        //是否探视
+        var isVisit: Boolean = false
+        //探视床位
+        var visit_bed_name: String? =""
+
         //Interaction ID
         var interactionId: Int? = -1
 

+ 0 - 6
middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/TcpClientHandler.java

@@ -116,12 +116,6 @@ public class TcpClientHandler extends SimpleChannelInboundHandler<String> {
     public void sendMsg(String msg) {
         if (ctx == null) {
             System.out.println("ctx is null");
-            /*try {
-                Thread.sleep(1000);
-                sendMsg(msg);
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }*/
             return;
         }
         ctx.writeAndFlush(Unpooled.copiedBuffer(msg, CharsetUtil.UTF_8));

+ 1 - 0
middleware/src/main/code/com/wdkl/ncs/android/middleware/utils/CommonUtils.java

@@ -10,6 +10,7 @@ public class CommonUtils {
     private static ArrayList<FrameBedVO> bedVOS = new ArrayList<>();
 
     public static void setInBedVos(ArrayList<FrameBedVO> data) {
+        bedVOS.clear();
         for (FrameBedVO bedVO : data) {
             if (bedVO != null && !TextUtils.isEmpty(bedVO.getCustomerName())) {
                 //有入住才加入进来

+ 30 - 8
nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/activity/NurseHomeActivity.kt

@@ -27,9 +27,9 @@ import com.google.gson.Gson
 import com.wdkl.core.consts.Urls
 import com.wdkl.core.socket.IUserState
 import com.wdkl.core.socket.SocketManager
-import com.wdkl.core.voip.CallMultiActivity
 import com.wdkl.core.voip.CallSingleActivity
 import com.wdkl.core.voip.SpeechUtil
+import com.wdkl.core.window.VisitingWindow
 import com.wdkl.ncs.android.component.nursehome.BuildConfig
 import com.wdkl.ncs.android.component.nursehome.R
 import com.wdkl.ncs.android.component.nursehome.SipUtil.SipCallBack
@@ -147,7 +147,7 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
             }
         }).start()
         regReceiver()//注册时间广播
-        time_tv.text = TimeTransition.getDateTime("yyyy-MM-dd HH:mm E")
+
         if(Constants.hospital_name!=null&& !Constants.hospital_name.equals("")){
             name_of_organization_tv.text = Constants.hospital_name+ Constants.part_name
             Log.e(TAG, Constants.hospital_name+ Constants.part_name)
@@ -643,7 +643,6 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
     }
 
     private fun updateTime() {
-        time_tv.text = TimeTransition.getDateTime("yyyy-MM-dd HH:mm E")
         //根据时间判断白昼进行相关的配置设置
         var currentTime = TimeTransition.getDateTime("yyyy-MM-dd HH:mm:ss")
         //转时间戳
@@ -745,9 +744,9 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
                         DeviceChannel.calling = true
                         Constants.CALL_STATE = Constants.CALL_CALLING
                         if (Constants.call_type == 1) {
-                            CallSingleActivity.openActivity(activity, interactionVO.toSipId, true, interactionVO.toSipId, false, false)
+                            CallSingleActivity.openActivity(activity, interactionVO.toSipId, true, interactionVO.toSipId, false, false, false)
                         } else {
-                            CallSingleActivity.openActivity(activity, interactionVO.toSipId, true, interactionVO.toSipId, true, false)
+                            CallSingleActivity.openActivity(activity, interactionVO.toSipId, true, interactionVO.toSipId, true, false, false)
                         }
                     } else if (tcpModel.getAction() == TcpAction.VoiceAction.REJECT) {//对方拒绝
                         Constants.CALL_STATE = Constants.CALL_STANDBY
@@ -848,12 +847,16 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
                         }, View.OnClickListener {
                             //接受探视,创建多人视频房间
                             //VideoUtil.acceptVideoCall(Integer.parseInt(Constants.ids), Constants.fromId, Constants.interactionId)
-                            VideoUtil.sendVideoInCall(Integer.parseInt(Constants.ids), Constants.fromId, Constants.interactionId)
+                            //VideoUtil.sendVideoInCall(Integer.parseInt(Constants.ids), Constants.fromId, Constants.interactionId)
                             CallDialogHelper.dismissCallDialog()
 
+                            //发送tcp,同时发起视频通话
+                            VideoUtil.sendVideoInCall(Integer.parseInt(Constants.ids), Constants.fromId, Constants.interactionId)
+                            CallSingleActivity.openActivity(activity, interactionVO.fromSipId, true, interactionVO.fromSipId, false, false, true)
+
                             // 创建一个房间并进入
-                            val roomId = "visit-room-" + Constants.interactionId
-                            CallMultiActivity.openActivity(activity, roomId, true)
+                            //val roomId = "visit-room-" + Constants.interactionId
+                            //CallMultiActivity.openActivity(activity, roomId, true)
                         }, View.OnClickListener {
                             //拒接探视
                             DeviceChannel.calling = false
@@ -868,6 +871,25 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
                         Constants.CALL_STATE = Constants.CALL_STANDBY
                         DeviceChannel.calling = false
                         CallDialogHelper.dismissCallDialog()
+                    } else if (tcpModel.action == TcpAction.VideoAction.HANDOFF) {
+                        Constants.CALL_STATE = Constants.CALL_STANDBY
+                        DeviceChannel.calling = false
+                        VisitingWindow.release()
+                    } else if (tcpModel.action == TcpAction.VideoAction.SUCCESS) {
+                        //显示探视窗口
+                        Constants.CALL_STATE = Constants.CALL_STANDBY
+                        DeviceChannel.calling = false
+                        VisitingWindow.createFloatView(activity, Constants.visit_bed_name)
+                    } else if (tcpModel.action == TcpAction.VideoAction.FAILED) {
+                        Constants.CALL_STATE = Constants.CALL_STANDBY
+                        DeviceChannel.calling = false
+                        CallDialogHelper.dismissCallDialog()
+                        showMessage("分机连线失败,请稍后再试...")
+                    } else if (tcpModel.action == TcpAction.VideoAction.CALLING) {
+                        Constants.CALL_STATE = Constants.CALL_STANDBY
+                        DeviceChannel.calling = false
+                        CallDialogHelper.dismissCallDialog()
+                        showMessage("分机正在通话中,请稍后再试...")
                     }
                 }
             }

+ 1 - 1
nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/fragment/FramePartFragment.kt

@@ -307,7 +307,7 @@ class FramePartFragment: BaseFragment<FramePartPresenter, FragmentFramePartBindi
      */
     override fun showData(data: FramePartVO) {
 
-        if (data!=null){
+        if (data!=null && data.frameRoomVos != null){
             var frameRoomVos = data.frameRoomVos as ArrayList<FrameRoomVO>
             var frameBedVO = ArrayList<FrameBedVO>()
 

+ 1 - 1
nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/settingconfig/SettingConfig.java

@@ -117,7 +117,7 @@ public class SettingConfig {
 
     //语音播报模式
     public static int getTtsMode(Context context) {
-        return getSP(context).getInt(KEY_SP_TTS_MODE, TTS_ON);
+        return getSP(context).getInt(KEY_SP_TTS_MODE, TTS_OFF);
     }
 
     public static void setTtsMode(Context context, int mode) {

+ 5 - 5
nursehome/src/main/res/layout/activity_nurse_home.xml

@@ -37,13 +37,13 @@
                     android:textColor="#2F9DF1"
                     android:textSize="16sp" />
 
-                <TextView
-                    android:id="@+id/time_tv"
+                <TextClock
                     android:layout_width="wrap_content"
-                    android:layout_height="match_parent"
+                    android:layout_height="wrap_content"
                     android:layout_centerHorizontal="true"
-                    android:gravity="center_vertical"
-                    android:text="2021-03-09 12:22:22 周六"
+                    android:layout_centerVertical="true"
+                    android:format12Hour="yyyy-MM-dd HH:mm:ss EEEE"
+                    android:format24Hour="yyyy-MM-dd HH:mm:ss EEEE"
                     android:textColor="#2F9DF1"
                     android:textSize="16sp" />
 

+ 4 - 2
webrtc/src/main/java/com/wdkl/core/socket/SocketManager.java

@@ -223,7 +223,7 @@ public class SocketManager implements IEvent {
         SkyEngineKit.init(new VoipEvent());
         boolean b = SkyEngineKit.Instance().startInCall(mContext, room, inviteId, audioOnly);
         if (b) {
-            CallSingleActivity.openActivity(mContext, inviteId, false, inviteId, audioOnly, false);
+            CallSingleActivity.openActivity(mContext, inviteId, false, inviteId, audioOnly, false, false);
         }
     }
 
@@ -360,7 +360,9 @@ public class SocketManager implements IEvent {
     @Override
     public void reConnect() {
         handler.post(() -> {
-            webSocket.reconnect();
+            if (webSocket != null) {
+                webSocket.reconnect();
+            }
         });
     }
     //===========================================================================================

+ 1 - 1
webrtc/src/main/java/com/wdkl/core/voip/CallForegroundNotification.java

@@ -107,7 +107,7 @@ public class CallForegroundNotification extends ContextWrapper {
             Context context, String targetId, Boolean isOutgoing, String inviteUserName,
             Boolean isAudioOnly, Boolean isClearTop
     ) {
-        Intent fullScreenIntent = CallSingleActivity.getCallIntent(context, targetId, isOutgoing, inviteUserName, isAudioOnly, isClearTop);
+        Intent fullScreenIntent = CallSingleActivity.getCallIntent(context, targetId, isOutgoing, inviteUserName, isAudioOnly, isClearTop, false);
         fullScreenIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(this, new Random().nextInt(100), fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT);
         NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, id)

+ 18 - 6
webrtc/src/main/java/com/wdkl/core/voip/CallMultiActivity.java

@@ -60,6 +60,7 @@ public class CallMultiActivity extends BaseActivity implements CallSession.CallS
     private FrameLayout mainView;
     //是否已经邀请
     private boolean invited = false;
+    private boolean leave;
 
 
     public static void openActivity(Activity activity, String room, boolean isOutgoing) {
@@ -169,9 +170,10 @@ public class CallMultiActivity extends BaseActivity implements CallSession.CallS
         } else {
             session.setSessionCallback(this);
             session.toggleSpeaker(true);
-        }
-
 
+            //等待房间创建完成之后再发送tcp给探视分机,通知探视分机加入房间
+            //VideoUtil.sendVideoInCall(Integer.parseInt(Constants.Companion.getIds()), Constants.Companion.getFromId(), Constants.Companion.getInteractionId());
+        }
     }
 
 
@@ -220,6 +222,13 @@ public class CallMultiActivity extends BaseActivity implements CallSession.CallS
     public void didUserLeave(String userId) {
         //handler.post(() -> currentFragment.didUserLeave(userId));
 
+        if (!leave) {
+            leave = true;
+            handoffVideoCall();
+            SkyEngineKit.Instance().leaveRoom();
+            Constants.Companion.setCALL_STATE(Constants.Companion.getCALL_STANDBY());
+            DeviceChannel.calling = false;
+        }
         finish();
     }
 
@@ -249,10 +258,13 @@ public class CallMultiActivity extends BaseActivity implements CallSession.CallS
 
     // 处理挂断事件
     private void handleHangup() {
-        handoffVideoCall();
-        SkyEngineKit.Instance().leaveRoom();
-        Constants.Companion.setCALL_STATE(Constants.Companion.getCALL_STANDBY());
-        DeviceChannel.calling = false;
+        if (!leave) {
+            leave = true;
+            handoffVideoCall();
+            SkyEngineKit.Instance().leaveRoom();
+            Constants.Companion.setCALL_STATE(Constants.Companion.getCALL_STANDBY());
+            DeviceChannel.calling = false;
+        }
     }
 
     private void handoffVideoCall() {

+ 11 - 3
webrtc/src/main/java/com/wdkl/core/voip/CallSingleActivity.java

@@ -53,6 +53,7 @@ public class CallSingleActivity extends BaseActivity implements CallSession.Call
     public static final String EXTRA_AUDIO_ONLY = "audioOnly";
     public static final String EXTRA_USER_NAME = "userName";
     public static final String EXTRA_FROM_FLOATING_VIEW = "fromFloatingView";
+    public static final String EXTRA_VISIT = "visit";
     private static final String TAG = "CallSingleActivity";
 
     private Handler handler = new Handler(Looper.getMainLooper());
@@ -70,15 +71,17 @@ public class CallSingleActivity extends BaseActivity implements CallSession.Call
 
     private boolean sosCallIn = false;
     private TcpModel tcpModel = null;
+    private boolean isVisit = false;
 
     public static Intent getCallIntent(Context context, String targetId, boolean isOutgoing, String inviteUserName,
-                                       boolean isAudioOnly, boolean isClearTop) {
+                                       boolean isAudioOnly, boolean isClearTop, boolean isVisit) {
         Intent voip = new Intent(context, CallSingleActivity.class);
         voip.putExtra(CallSingleActivity.EXTRA_MO, isOutgoing);
         voip.putExtra(CallSingleActivity.EXTRA_TARGET, targetId);
         voip.putExtra(CallSingleActivity.EXTRA_USER_NAME, inviteUserName);
         voip.putExtra(CallSingleActivity.EXTRA_AUDIO_ONLY, isAudioOnly);
         voip.putExtra(CallSingleActivity.EXTRA_FROM_FLOATING_VIEW, false);
+        voip.putExtra(CallSingleActivity.EXTRA_VISIT, isVisit);
         //if (isClearTop) {
         //    voip.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         //}
@@ -87,8 +90,8 @@ public class CallSingleActivity extends BaseActivity implements CallSession.Call
 
 
     public static void openActivity(Context context, String targetId, boolean isOutgoing, String inviteUserName,
-                                    boolean isAudioOnly, boolean isClearTop) {
-        Intent intent = getCallIntent(context, targetId, isOutgoing, inviteUserName, isAudioOnly, isClearTop);
+                                    boolean isAudioOnly, boolean isClearTop, boolean isVisit) {
+        Intent intent = getCallIntent(context, targetId, isOutgoing, inviteUserName, isAudioOnly, isClearTop, isVisit);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         context.startActivity(intent);
     }
@@ -117,6 +120,7 @@ public class CallSingleActivity extends BaseActivity implements CallSession.Call
         isFromFloatingView = intent.getBooleanExtra(EXTRA_FROM_FLOATING_VIEW, false);
         isOutgoing = intent.getBooleanExtra(EXTRA_MO, false);
         isAudioOnly = intent.getBooleanExtra(EXTRA_AUDIO_ONLY, false);
+        isVisit = intent.getBooleanExtra(EXTRA_VISIT, false);
 
         init(targetId, isOutgoing, isAudioOnly);
 
@@ -227,6 +231,10 @@ public class CallSingleActivity extends BaseActivity implements CallSession.Call
         return isOutgoing;
     }
 
+    public boolean isVisit() {
+        return isVisit;
+    }
+
 
     public boolean isFromFloatingView() {
         return isFromFloatingView;

+ 21 - 5
webrtc/src/main/java/com/wdkl/core/voip/FragmentMeeting.java

@@ -5,6 +5,7 @@ import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
 import android.support.v4.app.Fragment;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -23,6 +24,9 @@ public class FragmentMeeting extends Fragment implements CallSession.CallSession
     private CallMultiActivity activity;
     private NineGridView grid_view;
 
+    //是否探视中
+    private boolean visiting = false;
+
     @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -81,21 +85,33 @@ public class FragmentMeeting extends Fragment implements CallSession.CallSession
 
     @Override
     public void didCreateLocalVideoTrack() {
+        Log.d("wzlll", "didCreateLocalVideoTrack");
         View surfaceView = gEngineKit.getCurrentSession().setupLocalVideo(true);
         if (surfaceView != null) {
             CallSession callSession = SkyEngineKit.Instance().getCurrentSession();
             grid_view.addView(callSession.mMyId, surfaceView);
-
-
         }
 
     }
 
     @Override
     public void didReceiveRemoteVideoTrack(String userId) {
-        View surfaceView = gEngineKit.getCurrentSession().setupRemoteVideo(userId, true);
-        if (surfaceView != null) {
-            grid_view.addView(userId, surfaceView);
+        Log.d("wzlll", "didReceiveRemoteVideoTrack  user: " + userId);
+        if (!visiting) {
+            //当前没有在探视中,待下一次分机加入则进入探视
+            visiting = true;
+            View surfaceView = gEngineKit.getCurrentSession().setupRemoteVideo(userId, true);
+            if (surfaceView != null) {
+                grid_view.addView(userId, surfaceView);
+            }
+        } else {
+            CallSession callSession = SkyEngineKit.Instance().getCurrentSession();
+            grid_view.removeView(callSession.mMyId);
+
+            View surfaceView = gEngineKit.getCurrentSession().setupRemoteVideo(userId, true);
+            if (surfaceView != null) {
+                grid_view.addView(userId, surfaceView);
+            }
         }
     }
 

+ 68 - 34
webrtc/src/main/java/com/wdkl/core/voip/FragmentVideo.java

@@ -2,7 +2,9 @@ package com.wdkl.core.voip;
 
 import android.content.Context;
 import android.os.Build;
+import android.os.Handler;
 import android.support.annotation.NonNull;
+import android.support.v7.widget.RecyclerView;
 import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
@@ -10,9 +12,17 @@ import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.RelativeLayout;
+import android.widget.Toast;
 
+import com.alibaba.android.vlayout.VirtualLayoutManager;
 import com.blankj.utilcode.util.BarUtils;
+import com.wdkl.core.adapter.BedItemAdapter;
 import com.wdkl.core.util.OSUtils;
+import com.wdkl.ncs.android.component.nursehome.common.Constants;
+import com.wdkl.ncs.android.middleware.model.vo.FrameBedVO;
+import com.wdkl.ncs.android.middleware.tcp.channel.DeviceChannel;
+import com.wdkl.ncs.android.middleware.tcp.channel.VideoUtil;
+import com.wdkl.ncs.android.middleware.utils.CommonUtils;
 import com.wdkl.skywebrtc.CallSession;
 import com.wdkl.skywebrtc.EnumType.CallState;
 import com.wdkl.skywebrtc.SkyEngineKit;
@@ -42,6 +52,9 @@ public class FragmentVideo extends SingleCallFragment implements View.OnClickLis
     private SurfaceViewRenderer localSurfaceView;
     private SurfaceViewRenderer remoteSurfaceView;
 
+    private BedItemAdapter bedItemAdapter;
+    private RecyclerView recyclerView;
+
     @Override
     public void onAttach(@NonNull Context context) {
         super.onAttach(context);
@@ -101,6 +114,61 @@ public class FragmentVideo extends SingleCallFragment implements View.OnClickLis
 //            }, 10000);
 //        }
 
+        //探视请求处理
+        if (callSingleActivity.isVisit()) {
+            bedItemAdapter = new BedItemAdapter(callSingleActivity, CommonUtils.getInBedVOS());
+            recyclerView = view.findViewById(R.id.visit_list_view);
+            recyclerView.setAdapter(bedItemAdapter);
+            recyclerView.setLayoutManager(new VirtualLayoutManager(callSingleActivity));
+            recyclerView.setVisibility(View.VISIBLE);
+            fullscreenRenderer.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    if (recyclerView.getVisibility() == View.GONE) {
+                        recyclerView.setVisibility(View.VISIBLE);
+                    } else {
+                        recyclerView.setVisibility(View.GONE);
+                    }
+                }
+            });
+
+            initListener();
+        }
+
+    }
+
+    private void initListener() {
+        bedItemAdapter.setInvitClickListener(new BedItemAdapter.InviteClickListener() {
+            @Override
+            public void onClick(FrameBedVO bedVO) {
+                Constants.Companion.setVisitedId(bedVO.getBedDeviceId());
+                recyclerView.setVisibility(View.GONE);
+                //Toast.makeText(callSingleActivity, "已发送探视邀请,请稍后...", Toast.LENGTH_LONG).show();
+                DeviceChannel.calling = false;
+                Constants.Companion.setVisit_bed_name(bedVO.getFrameBed().getFullName());
+
+                //延迟发送
+                new Handler().postDelayed(new Runnable() {
+                    @Override
+                    public void run() {
+                        //发送探视邀请给分机
+                        VideoUtil.sendInviteVideoCall(Integer.parseInt(Constants.Companion.getIds()),
+                                bedVO.getBedDeviceId(),
+                                Constants.Companion.getInteractionId());
+                    }
+                }, 2000);
+
+                //关闭主机和探视机的视频,然后由分机向探视机发视频通话
+                if (gEngineKit.getCurrentSession() != null) {
+                    Log.d(TAG, "endCall");
+                    SkyEngineKit.Instance().endCall();
+                }
+
+                if (callSingleActivity != null) {
+                    callSingleActivity.finish();
+                }
+            }
+        });
     }
 
 
@@ -274,40 +342,6 @@ public class FragmentVideo extends SingleCallFragment implements View.OnClickLis
             }
             if (callSingleActivity != null) callSingleActivity.finish();
         }
-
-        // 切换摄像头
-        if (id == R.id.switchCameraImageView) {
-            session.switchCamera();
-        }
-        if (id == R.id.pip_video_view) {
-            boolean isFullScreenRemote = fullscreenRenderer.getChildAt(0) == remoteSurfaceView;
-            fullscreenRenderer.removeAllViews();
-            pipRenderer.removeAllViews();
-            if (isFullScreenRemote) {
-                remoteSurfaceView.setZOrderMediaOverlay(true);
-                pipRenderer.addView(remoteSurfaceView);
-                localSurfaceView.setZOrderMediaOverlay(false);
-                fullscreenRenderer.addView(localSurfaceView);
-            } else {
-                localSurfaceView.setZOrderMediaOverlay(true);
-                pipRenderer.addView(localSurfaceView);
-                remoteSurfaceView.setZOrderMediaOverlay(false);
-                fullscreenRenderer.addView(remoteSurfaceView);
-            }
-        }
-
-        // 切换到语音拨打
-        if (id == R.id.outgoingAudioOnlyImageView || id == R.id.incomingAudioOnlyImageView || id == R.id.connectedAudioOnlyImageView) {
-            if (session != null) {
-                if (callSingleActivity != null) callSingleActivity.isAudioOnly = true;
-                session.switchToAudio();
-            }
-        }
-
-        // 小窗
-        /*if (id == R.id.minimizeImageView) {
-            if (callSingleActivity != null) callSingleActivity.showFloatingView();
-        }*/
     }
 
 

+ 0 - 2
webrtc/src/main/java/com/wdkl/core/voip/SingleCallFragment.java

@@ -199,8 +199,6 @@ public abstract class SingleCallFragment extends Fragment {
                 break;
             }
             case Hangup: {
-                //自己挂断
-                VoiceUtil.handoffAudioCall(Integer.parseInt(Constants.Companion.getIds()), Constants.Companion.getFromId(), Constants.Companion.getInteractionId());
                 tvStatus.setText("挂断");
                 break;
             }

+ 1 - 1
webrtc/src/main/java/com/wdkl/core/voip/VoipReceiver.java

@@ -199,7 +199,7 @@ public class VoipReceiver extends BroadcastReceiver {
                 if (context instanceof CallSingleActivity) {
                     ((CallSingleActivity) context).finish();
                 }
-                CallSingleActivity.openActivity(context, inviteId, false, inviteUserName, audioOnly, true);
+                //CallSingleActivity.openActivity(context, inviteId, false, inviteUserName, audioOnly, true);
             } else {
                 // 群聊
             }

+ 103 - 0
webrtc/src/main/java/com/wdkl/core/window/VisitingWindow.java

@@ -0,0 +1,103 @@
+package com.wdkl.core.window;
+
+import android.content.Context;
+import android.graphics.PixelFormat;
+import android.os.Build;
+import android.os.SystemClock;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Chronometer;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.wdkl.ncs.android.component.nursehome.common.Constants;
+import com.wdkl.ncs.android.middleware.tcp.channel.DeviceChannel;
+import com.wdkl.ncs.android.middleware.tcp.channel.VideoUtil;
+import com.wdkl.webrtc.R;
+
+public class VisitingWindow {
+
+    private static WindowManager mWindowManager;
+    private static View view;
+
+    //创建悬浮按钮
+    public static void createFloatView(Context context, String text) {
+        //如果当前没有显示则创建view并显示,如果已经显示则仅更新事件列表
+        if (view == null) {
+            WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams();
+            //获取的是WindowManagerImpl.CompatModeWrapper
+            mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+                //设置window type 这个只能在8.0以下系统使用
+                wmParams.type = WindowManager.LayoutParams.TYPE_PHONE;
+            } else {
+                //8.0及以上系统使用这个
+                wmParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
+            }
+
+            //设置图片格式,效果为背景透明
+            wmParams.format = PixelFormat.RGBA_8888;
+            //设置浮动窗口不可聚焦(实现操作除浮动窗口外的其他可见窗口的操作)
+            //wmParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
+            //调整悬浮窗显示的停靠位置为左侧置顶
+//        wmParams.gravity = Gravity.RIGHT or Gravity.TOP
+            wmParams.gravity = Gravity.CENTER_HORIZONTAL;
+            // 以屏幕左上角为原点,设置x、y初始值,相对于gravity
+            wmParams.x = 0;
+            wmParams.y = 0;
+            //设置悬浮窗口长宽数据
+            wmParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
+            wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
+
+            //获取浮动窗口视图所在布局
+            view = LayoutInflater.from(context).inflate(R.layout.window_visiting, null);
+
+            TextView title = view.findViewById(R.id.window_visiting_title);
+            Chronometer time = view.findViewById(R.id.window_visiting_time);
+            ImageView end = view.findViewById(R.id.window_visiting_end);
+
+            title.setText(text + " 正在探视中...");
+            time.setBase(SystemClock.elapsedRealtime());
+            time.start();
+            end.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    time.stop();
+                    //挂断探视机
+                    VideoUtil.handoffVideoCall(Integer.parseInt(Constants.Companion.getIds()), Constants.Companion.getFromId(), Constants.Companion.getInteractionId());
+                    //挂断分机
+                    if (Constants.Companion.getVisitedId() != -1) {
+                        VideoUtil.handoffVideoCall(Integer.parseInt(Constants.Companion.getIds()), Constants.Companion.getVisitedId(), Constants.Companion.getInteractionId());
+                        Constants.Companion.setVisitedId(-1);
+                    }
+                    release();
+                }
+            });
+
+            //添加mFloatLayout
+            mWindowManager.addView(view, wmParams);
+
+        }
+
+    }
+
+
+    /**
+     * 删除窗口
+     */
+    public static void release() {
+        DeviceChannel.calling = false;
+        if (view != null) {
+            Chronometer time = view.findViewById(R.id.window_visiting_time);
+            if (time != null) {
+                time.stop();
+            }
+            //移除悬浮窗口
+            mWindowManager.removeView(view);
+        }
+        mWindowManager = null;
+        view = null;
+    }
+}

+ 6 - 0
webrtc/src/main/res/drawable/alert_window_bg.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="#878a8a" />
+    <corners
+        android:radius="18dp" />
+</shape>

+ 1 - 1
webrtc/src/main/res/layout/activity_multi_call.xml

@@ -25,5 +25,5 @@
         android:id="@+id/room_list_view"
         android:layout_width="200dp"
         android:layout_height="match_parent"
-        android:background="@color/color_white" />
+        android:background="@color/color_transparent" />
 </RelativeLayout>

+ 4 - 4
webrtc/src/main/res/layout/adapter_visit_bed.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="40dp"
+    android:layout_height="80dp"
     android:gravity="center_vertical">
     <TextView
         android:id="@+id/tv_visit_bed"
@@ -11,7 +11,7 @@
         android:layout_weight="1"
         android:text="床位"
         android:textColor="#2F9DF1"
-        android:textSize="12sp"/>
+        android:textSize="16sp"/>
     <TextView
         android:id="@+id/tv_visit_name"
         android:layout_width="0dp"
@@ -20,7 +20,7 @@
         android:layout_weight="1"
         android:text="名字"
         android:textColor="#2F9DF1"
-        android:textSize="12sp"/>
+        android:textSize="16sp"/>
 
     <Button
         android:id="@+id/btn_visit"
@@ -30,5 +30,5 @@
         android:gravity="center"
         android:text="邀请"
         android:textColor="#2F9DF1"
-        android:textSize="12sp"/>
+        android:textSize="16sp"/>
 </LinearLayout>

+ 10 - 3
webrtc/src/main/res/layout/fragment_video.xml

@@ -14,8 +14,8 @@
 
     <FrameLayout
         android:id="@+id/pip_video_view"
-        android:layout_width="100dp"
-        android:layout_height="140dp"
+        android:layout_width="200dp"
+        android:layout_height="240dp"
         android:layout_gravity="top|end"
         android:layout_marginHorizontal="10dp"
         android:layout_marginTop="10dp" />
@@ -26,6 +26,13 @@
         android:layout_height="match_parent"
         android:background="@android:color/transparent">
 
+        <android.support.v7.widget.RecyclerView
+            android:id="@+id/visit_list_view"
+            android:layout_width="200dp"
+            android:layout_height="match_parent"
+            android:background="@color/color_transparent"
+            android:visibility="gone"/>
+
         <LinearLayout
             android:id="@+id/inviteeInfoContainer"
             android:layout_width="wrap_content"
@@ -36,7 +43,7 @@
             android:layout_marginEnd="20dp"
             android:gravity="center_vertical"
             android:orientation="horizontal"
-            android:visibility="visible">
+            android:visibility="gone">
 
             <ImageView
                 android:id="@+id/portraitImageView"

+ 42 - 0
webrtc/src/main/res/layout/window_visiting.xml

@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout>
+    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="460dp"
+        android:layout_height="140dp"
+        android:background="@drawable/alert_window_bg">
+
+        <LinearLayout
+            android:layout_width="460dp"
+            android:layout_height="140dp"
+            android:gravity="center_vertical">
+
+            <TextView
+                android:id="@+id/window_visiting_title"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="3"
+                android:padding="8dp"
+                android:text="01-01床正在探视中"
+                android:textSize="24sp"/>
+
+            <Chronometer
+                android:id="@+id/window_visiting_time"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:gravity="center"
+                android:textSize="24sp"/>
+
+            <ImageView
+                android:id="@+id/window_visiting_end"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:src="@drawable/av_hangup_selector"
+                android:layout_weight="1"/>
+
+        </LinearLayout>
+
+    </FrameLayout>
+
+
+</layout>