Procházet zdrojové kódy

sip视频通话调通

weizhengliang před 1 rokem
rodič
revize
854fc02cdf

+ 9 - 2
android_host/src/main/common/java/com/wdkl/ncs/host/service/WdklSipService.java

@@ -137,10 +137,17 @@ public class WdklSipService extends Service {
                             //call.acceptWithParams(params);
 
                             //sip remote address==> sip:1001@192.168.3.26
+                            CallParams remoteParams = call.getRemoteParams();
+                            String remoteName = "";
                             if (call.getRemoteAddress().getUsername() != null) {
-                                EventBus.getDefault().post(MessageEvent.Companion.build(Constants.SIP_INCOMING_CALL, call.getRemoteAddress().getUsername()));
+                                remoteName = call.getRemoteAddress().getUsername();
                             } else {
-                                EventBus.getDefault().post(MessageEvent.Companion.build(Constants.SIP_INCOMING_CALL, call.getRemoteAddress().asString()));
+                                remoteName = call.getRemoteAddress().asString();
+                            }
+                            if (remoteParams != null && remoteParams.videoEnabled()) {
+                                EventBus.getDefault().post(MessageEvent.Companion.build(Constants.SIP_INCOMING_VIDEO_CALL, remoteName));
+                            } else {
+                                EventBus.getDefault().post(MessageEvent.Companion.build(Constants.SIP_INCOMING_VOICE_CALL, remoteName));
                             }
                         }
                     } else if (state == Call.State.Connected) {

+ 13 - 1
android_host/src/main/h10_wke_1h/java/com/wdkl/ncs/android/component/nursehome/activity/NurseHomeActivity.kt

@@ -2266,7 +2266,7 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
                 LedHelper.updateLedInfo(item, false, false)
             }
 
-            Constants.SIP_INCOMING_CALL -> {
+            Constants.SIP_INCOMING_VOICE_CALL -> {
                 val callName = messageEvent.getMessage() as String
                 val fragment = SipComingCallFragment()
                 val bundle = Bundle()
@@ -2278,6 +2278,18 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
                 addCallFragment(fragment)
             }
 
+            Constants.SIP_INCOMING_VIDEO_CALL -> {
+                val callName = messageEvent.getMessage() as String
+                val fragment = SipComingCallFragment()
+                val bundle = Bundle()
+                bundle.putInt("call_state", 1)
+                bundle.putBoolean("visiting", false)
+                bundle.putBoolean("audio_only", false)
+                bundle.putString("call_name", callName)
+                fragment.arguments = bundle
+                addCallFragment(fragment)
+            }
+
             Constants.EVENT_REJECT_CALL -> {
                 //拒接电话
                 val item = messageEvent.getMessage() as InteractionVO

+ 16 - 8
android_host/src/main/h10_wke_1h/java/com/wdkl/ncs/android/component/nursehome/fragment/SipComingCallFragment.kt

@@ -3,7 +3,6 @@ package com.wdkl.ncs.android.component.nursehome.fragment
 import android.os.*
 import android.util.Log
 import android.view.View
-import android.widget.Switch
 import com.wdkl.ncs.android.component.nursehome.R
 import com.wdkl.ncs.android.component.nursehome.util.AppUtil
 import com.wdkl.ncs.android.component.nursehome.util.RingPlayHelper
@@ -11,11 +10,10 @@ import com.wdkl.ncs.android.component.nursehome.util.SpeechUtil
 import com.wdkl.ncs.android.lib.base.BaseApplication
 import com.wdkl.ncs.android.lib.utils.showMessage
 import com.wdkl.ncs.android.middleware.common.Constants
-import com.wdkl.ncs.android.middleware.model.bean.SettingConfiguration
 import com.wdkl.ncs.android.middleware.utils.MessageEvent
 import com.wdkl.ncs.host.service.WdklSipService
+import kotlinx.android.synthetic.main.sip_call_layout.*
 //import com.wdkl.ncs.host.util.AudioRouteUtils
-import kotlinx.android.synthetic.main.sky_voice_call_layout.*
 import org.greenrobot.eventbus.Subscribe
 import org.greenrobot.eventbus.ThreadMode
 import org.linphone.core.Core
@@ -33,13 +31,15 @@ class SipComingCallFragment: BaseCallFragment() {
     private var sipCore: Core? = null
 
     override fun getLayId(): Int {
-        return R.layout.sky_voice_call_layout
+        return R.layout.sip_call_layout
     }
 
     override fun init() {
         initCountDownTimer()
 
         sipCore = WdklSipService.getCore()
+        sipCore?.setNativePreviewWindowId(local_video_frame)
+        sipCore?.setNativeVideoWindowId(remote_video_frame)
 
         when (callState) {
             0 -> {
@@ -97,6 +97,7 @@ class SipComingCallFragment: BaseCallFragment() {
             val params = sipCore?.createCallParams(null)
             //视频开关
             //params?.isVideoEnabled = false
+            params?.enableVideo(true)
 
             //录音文件路径
             params?.recordFile = Environment.getExternalStorageDirectory().path + "/" + Environment.DIRECTORY_DOWNLOADS + "/" + AppUtil.getTimeFilename() + ".wav"
@@ -116,7 +117,11 @@ class SipComingCallFragment: BaseCallFragment() {
                 call = sipCore!!.calls[0]
             }
             val params = sipCore?.createCallParams(call)
-            //params?.isVideoEnabled = false
+            if (onlyAudio) {
+                params?.enableVideo(false)
+            } else {
+                params?.enableVideo(true)
+            }
 
             //录音文件路径
             params?.recordFile = Environment.getExternalStorageDirectory().path + "/" + Environment.DIRECTORY_DOWNLOADS + "/" + AppUtil.getTimeFilename() + ".wav"
@@ -164,6 +169,10 @@ class SipComingCallFragment: BaseCallFragment() {
             sky_voice_call_outgoing.visibility = View.GONE
             sky_voice_call_timer.visibility = View.GONE
         }
+
+        if (!onlyAudio) {
+            video_call_view.visibility = View.VISIBLE
+        }
     }
 
     private fun showCalling(audioOnly: Boolean) {
@@ -175,8 +184,7 @@ class SipComingCallFragment: BaseCallFragment() {
             ll_voice_call.visibility = View.VISIBLE
         } else {
             //显示视频画面
-            fullscreen_video_frame.visibility = View.VISIBLE
-            pip_video_frame.visibility = View.VISIBLE
+            video_call_view.visibility = View.VISIBLE
             ll_voice_call.visibility = View.GONE
         }
 
@@ -234,7 +242,7 @@ class SipComingCallFragment: BaseCallFragment() {
             }
 
             Constants.SIP_CONNECTED -> {
-                showCalling(true)
+                showCalling(onlyAudio)
             }
 
             Constants.EVENT_HOOK_OFF -> {

+ 213 - 0
android_host/src/main/h10_wke_1h/res/layout/sip_call_layout.xml

@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout>
+    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="@color/gray_deep">
+
+        <RelativeLayout
+            android:id="@+id/video_call_view"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:visibility="gone">
+
+            <!--对方画面-->
+            <TextureView
+                android:id="@+id/remote_video_frame"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_gravity="center" />
+
+            <!--本机画面-->
+            <TextureView
+                android:id="@+id/local_video_frame"
+                android:layout_width="200dp"
+                android:layout_height="240dp"
+                android:layout_marginTop="10dp"
+                android:layout_marginRight="10dp"
+                android:layout_alignParentRight="true" />
+        </RelativeLayout>
+
+        <LinearLayout
+            android:id="@+id/video_visit_call_view"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:visibility="gone">
+            <FrameLayout
+                android:id="@+id/visit_video_frame1"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1">
+                <ImageView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:src="@drawable/ic_camera"/>
+            </FrameLayout>
+
+            <FrameLayout
+                android:id="@+id/visit_video_frame2"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1"/>
+        </LinearLayout>
+
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
+
+            <android.support.v7.widget.RecyclerView
+                android:id="@+id/visit_list_view"
+                android:layout_width="320dp"
+                android:layout_height="match_parent"
+                android:background="@color/color_transparent"
+                android:visibility="gone"/>
+
+            <TextView
+                android:id="@+id/tv_visit_title"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerInParent="true"
+                android:text="@string/str_visiting"
+                android:textSize="36sp"
+                android:textColor="@color/white"
+                android:visibility="gone"/>
+
+            <LinearLayout
+                android:id="@+id/ll_out_call"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="40dp"
+                android:gravity="center"
+                android:visibility="gone">
+
+                <EditText
+                    android:id="@+id/edit_call_number"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="sip:7550000506003011802201@192.168.3.26"
+                    android:textColor="@color/white"
+                    android:textSize="28sp" />
+
+                <Button
+                    android:id="@+id/button_call"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="10dp"
+                    android:text="呼叫"
+                    android:textColor="@color/main_color"
+                    android:textSize="32sp" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/ll_voice_call"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="240dp"
+                android:gravity="center_horizontal"
+                android:orientation="vertical">
+
+                <TextView
+                    android:id="@+id/sky_call_name"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:gravity="center"
+                    android:text=""
+                    android:textColor="@color/white"
+                    android:textSize="32sp" />
+
+                <TextView
+                    android:id="@+id/sky_voice_call_calling_text"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="10dp"
+                    android:gravity="center"
+                    android:text=""
+                    android:textColor="@color/white"
+                    android:textSize="32sp" />
+            </LinearLayout>
+
+            <!--呼出-->
+            <LinearLayout
+                android:id="@+id/sky_voice_call_outgoing"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentBottom="true"
+                android:layout_centerHorizontal="true"
+                android:layout_marginBottom="80dp"
+                android:gravity="center_horizontal"
+                android:orientation="vertical"
+                android:visibility="visible">
+
+                <Chronometer
+                    android:id="@+id/sky_voice_call_timer"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:gravity="center"
+                    android:text="00:00"
+                    android:textColor="@color/white"
+                    android:textSize="24sp" />
+
+                <LinearLayout
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="32dp">
+                    <ImageView
+                        android:id="@+id/sky_voice_call_hangup"
+                        android:layout_width="100dp"
+                        android:layout_height="100dp"
+                        android:src="@drawable/selector_call_hangup" />
+
+                    <ImageView
+                        android:id="@+id/sky_call_speaker_on"
+                        android:layout_width="100dp"
+                        android:layout_height="100dp"
+                        android:layout_marginStart="40dp"
+                        android:src="@drawable/ic_speaker_on"
+                        android:visibility="gone"/>
+                </LinearLayout>
+
+            </LinearLayout>
+
+            <!--来电-->
+            <LinearLayout
+                android:id="@+id/sky_voice_call_incoming"
+                android:layout_width="match_parent"
+                android:layout_height="140dp"
+                android:layout_alignParentBottom="true"
+                android:layout_centerHorizontal="true"
+                android:layout_marginBottom="80dp"
+                android:gravity="bottom"
+                android:orientation="horizontal"
+                android:visibility="gone">
+
+                <View
+                    android:layout_width="0dp"
+                    android:layout_height="1dp"
+                    android:layout_weight="2" />
+
+                <ImageView
+                    android:id="@+id/sky_voice_call_ring_reject"
+                    android:layout_width="100dp"
+                    android:layout_height="100dp"
+                    android:src="@drawable/selector_call_hangup" />
+
+                <View
+                    android:layout_width="0dp"
+                    android:layout_height="1dp"
+                    android:layout_weight="1" />
+
+                <ImageView
+                    android:id="@+id/sky_voice_call_ring_pickup_audio"
+                    android:layout_width="100dp"
+                    android:layout_height="100dp"
+                    android:src="@drawable/selector_call_answer" />
+
+                <View
+                    android:layout_width="0dp"
+                    android:layout_height="1dp"
+                    android:layout_weight="2" />
+            </LinearLayout>
+        </RelativeLayout>
+    </FrameLayout>
+</layout>

+ 3 - 1
middleware/src/main/code/com/wdkl/ncs/android/middleware/common/Constants.kt

@@ -173,7 +173,9 @@ class Constants {
 
         const val EVENT_TOGGLE_SPEAKER = 0X22
 
-        const val SIP_INCOMING_CALL = 0x23
+        const val SIP_INCOMING_VOICE_CALL = 0x23
+
+        const val SIP_INCOMING_VIDEO_CALL = 0x24
 
         //手柄拿起
         const val HOOK_OFF = "com.android.PhoneWinowManager.HOOK_OFF"