瀏覽代碼

## [1.0.4] version 4 - 2021-08-27
### CHANGE
- 优化通话逻辑

weizhengliang 3 年之前
父節點
當前提交
d883f59186

+ 2 - 2
build.gradle

@@ -47,12 +47,12 @@ buildscript {
     /**
     /**
      * APP版本码
      * APP版本码
      */
      */
-    ext.app_version_code = 3
+    ext.app_version_code = 4
 
 
     /**
     /**
      * APP版本号
      * APP版本号
      */
      */
-    ext.app_version = "1.0.3"
+    ext.app_version = "1.0.4"
 
 
     /**
     /**
      * 项目依赖库
      * 项目依赖库

+ 31 - 5
nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/fragment/SkyCallFragment.kt

@@ -42,6 +42,8 @@ class SkyCallFragment: BaseCallFragment(), CallSession.CallSessionCallback {
 
 
     private var callEnded: Boolean = false
     private var callEnded: Boolean = false
 
 
+    private var outGoing: Boolean = false
+
     override fun getLayId(): Int {
     override fun getLayId(): Int {
         return R.layout.sky_voice_call_layout
         return R.layout.sky_voice_call_layout
     }
     }
@@ -67,6 +69,7 @@ class SkyCallFragment: BaseCallFragment(), CallSession.CallSessionCallback {
         when (callState) {
         when (callState) {
             0 -> {
             0 -> {
                 //发起通话
                 //发起通话
+                outGoing = true
                 if (!startCall(targetId!!, onlyAudio)) {
                 if (!startCall(targetId!!, onlyAudio)) {
                     //通话失败,重置并返回主界面
                     //通话失败,重置并返回主界面
                     Constants.CALL_STATE = Constants.CALL_STANDBY
                     Constants.CALL_STATE = Constants.CALL_STANDBY
@@ -81,6 +84,7 @@ class SkyCallFragment: BaseCallFragment(), CallSession.CallSessionCallback {
 
 
             1 -> {
             1 -> {
                 //接受通话
                 //接受通话
+                outGoing = false
                 Constants.CALL_STATE = Constants.CALL_CALLING
                 Constants.CALL_STATE = Constants.CALL_CALLING
                 DeviceChannel.calling = true
                 DeviceChannel.calling = true
                 val session = gEngineKit?.getCurrentSession()
                 val session = gEngineKit?.getCurrentSession()
@@ -150,7 +154,7 @@ class SkyCallFragment: BaseCallFragment(), CallSession.CallSessionCallback {
         sky_voice_call_timer.visibility = View.GONE
         sky_voice_call_timer.visibility = View.GONE
     }
     }
 
 
-    //语音接通
+    //语音来电接通
     private fun joinAudioCall() {
     private fun joinAudioCall() {
         val session = gEngineKit?.getCurrentSession()
         val session = gEngineKit?.getCurrentSession()
         if (session != null) {
         if (session != null) {
@@ -175,7 +179,7 @@ class SkyCallFragment: BaseCallFragment(), CallSession.CallSessionCallback {
         }
         }
     }
     }
 
 
-    //视频接通
+    //视频来电接通
     private fun joinVideoCall() {
     private fun joinVideoCall() {
         val session = gEngineKit?.getCurrentSession()
         val session = gEngineKit?.getCurrentSession()
         if (session != null) {
         if (session != null) {
@@ -322,7 +326,27 @@ class SkyCallFragment: BaseCallFragment(), CallSession.CallSessionCallback {
                     Log.e("dds", "didCreateLocalVideoTrack surfaceView: " + surfaceView)
                     Log.e("dds", "didCreateLocalVideoTrack surfaceView: " + surfaceView)
                     if (surfaceView != null) {
                     if (surfaceView != null) {
                         localSurfaceView = surfaceView as SurfaceViewRenderer
                         localSurfaceView = surfaceView as SurfaceViewRenderer
+                    } else {
+                        callEnd()
+                    }
+                } else {
+                    localSurfaceView!!.setZOrderMediaOverlay(true)
+                }
+
+                if (localSurfaceView!!.parent != null) {
+                    (localSurfaceView!!.parent as ViewGroup).removeView(localSurfaceView)
+                }
+
+                if (outGoing && remoteSurfaceView == null) {
+                    if (fullscreen_video_frame != null && fullscreen_video_frame.getChildCount() != 0) {
+                        fullscreen_video_frame.removeAllViews()
                     }
                     }
+                    fullscreen_video_frame.addView(localSurfaceView)
+                } else {
+                    if (pip_video_frame != null && pip_video_frame.getChildCount() != 0) {
+                        pip_video_frame.removeAllViews()
+                    }
+                    pip_video_frame.addView(localSurfaceView)
                 }
                 }
             }
             }
         }
         }
@@ -337,10 +361,12 @@ class SkyCallFragment: BaseCallFragment(), CallSession.CallSessionCallback {
                 //本地画面
                 //本地画面
                 if (localSurfaceView != null) {
                 if (localSurfaceView != null) {
                     localSurfaceView!!.setZOrderMediaOverlay(true)
                     localSurfaceView!!.setZOrderMediaOverlay(true)
-                    if (localSurfaceView!!.parent != null) {
-                        (localSurfaceView!!.parent as ViewGroup).removeView(localSurfaceView)
+                    if (outGoing) {
+                        if (localSurfaceView!!.parent != null) {
+                            (localSurfaceView!!.parent as ViewGroup).removeView(localSurfaceView)
+                        }
+                        pip_video_frame!!.addView(localSurfaceView)
                     }
                     }
-                    pip_video_frame!!.addView(localSurfaceView)
                 }
                 }
 
 
                 //远端画面
                 //远端画面

+ 4 - 0
readme.md

@@ -26,6 +26,10 @@
 
 
 ---
 ---
 
 
+## [1.0.4] version 4 - 2021-08-27
+### CHANGE
+- 优化通话逻辑
+
 ## [1.0.3] version 3 - 2021-08-17
 ## [1.0.3] version 3 - 2021-08-17
 ### CHANGE
 ### CHANGE
 - 解决界面切换会跳的问题
 - 解决界面切换会跳的问题