فهرست منبع

sip通话优化

weizhengliang 1 سال پیش
والد
کامیت
d6dbdcdb86

+ 11 - 4
android_host/src/main/h10_wke_1h_chile/java/com/wdkl/ncs/android/component/nursehome/fragment/SipCallFragment.kt

@@ -7,9 +7,12 @@ import android.os.SystemClock
 import android.text.TextUtils
 import android.util.Log
 import android.view.View
+import android.widget.SeekBar
 import com.google.gson.Gson
 import com.wdkl.ncs.android.component.nursehome.R
+import com.wdkl.ncs.android.component.nursehome.settingconfig.SettingConfig
 import com.wdkl.ncs.android.component.nursehome.util.RingPlayHelper
+import com.wdkl.ncs.android.component.nursehome.util.VoiceManagerUtil
 import com.wdkl.ncs.android.lib.base.BaseApplication
 import com.wdkl.ncs.android.lib.utils.showMessage
 import com.wdkl.ncs.android.middleware.common.Constants
@@ -35,7 +38,6 @@ class SipCallFragment: BaseCallFragment() {
     private val handler = Handler(Looper.getMainLooper())
 
     private var callEnded: Boolean = false
-
     private var outGoing: Boolean = false
 
     //呼叫倒计时
@@ -62,6 +64,7 @@ class SipCallFragment: BaseCallFragment() {
                 showCallView(true)
                 Constants.CALL_STATE = Constants.CALL_OUTGOING
                 DeviceChannel.calling = true
+                Constants.IN_CALL = true
                 RingPlayHelper.playRingTone(BaseApplication.appContext, R.raw.ring_back2, true)
             }
 
@@ -91,7 +94,7 @@ class SipCallFragment: BaseCallFragment() {
 
             override fun onFinish() {
                 //呼叫超时,退出呼叫界面
-                showMessage("无响应")
+                showMessage(R.string.no_response)
                 DeviceChannel.calling = false
                 Constants.CALL_STATE = Constants.CALL_STANDBY
                 //VoiceUtil.cancelAudioCall(Constants.ids, Constants.targetDeviceId)
@@ -129,6 +132,8 @@ class SipCallFragment: BaseCallFragment() {
     }
 
     override fun destroy() {
+        Constants.showCall = false
+        Constants.IN_CALL = false
         RingPlayHelper.stopRingTone()
         Constants.CALL_STATE = Constants.CALL_STANDBY
         DeviceChannel.calling = false
@@ -149,6 +154,7 @@ class SipCallFragment: BaseCallFragment() {
         }
         sky_voice_call_outgoing.visibility = View.VISIBLE
         sky_voice_call_timer.visibility = View.GONE
+        Constants.showCall = true
     }
 
     private fun showCalling(audioOnly: Boolean) {
@@ -256,7 +262,7 @@ class SipCallFragment: BaseCallFragment() {
 
                             if (sipCore == null || TextUtils.isEmpty(curIt.toSipId)) {
                                 //通话失败,重置并返回主界面
-                                showMessage("Core或targetSipId为空!")
+                                showMessage("sipCore targetSipId empty!")
                                 Constants.CALL_STATE = Constants.CALL_STANDBY
                                 if (sky_voice_call_timer != null) {
                                     sky_voice_call_timer.stop()
@@ -273,7 +279,7 @@ class SipCallFragment: BaseCallFragment() {
                             }
                         } else if (curTcpModel.action == TcpAction.VoiceAction.REJECT) {//对方拒绝
                             if (Constants.interactionId == curIt.id) {
-                                showMessage("对方拒绝")
+                                showMessage(R.string.call_reject)
                                 Constants.CALL_STATE = Constants.CALL_STANDBY
                                 DeviceChannel.calling = false
                                 callEnd(false)
@@ -297,6 +303,7 @@ class SipCallFragment: BaseCallFragment() {
             }
 
             Constants.SIP_CONNECTED -> {
+                Constants.IN_CALL = true
                 showCalling(true)
             }
 

+ 0 - 16
android_host/src/main/h10_z3128_1h_chile/java/com/wdkl/ncs/android/component/nursehome/activity/NurseHomeActivity.kt

@@ -1868,22 +1868,6 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
                         name = item.fromFrameFullName
                     }
                     acceptCall(name, callingItem.tid)
-
-                    //VoiceUtil.acceptAudioCall(Constants.ids, Constants.fromId, Constants.interactionId)
-                    /*val callTcp = VoiceUtil.voiceAccept(callingItem.tid, Constants.ids, Constants.fromId, Constants.interactionId)
-                    val transaction = object : TcpCallback(callTcp.tid) {
-                        override fun onSuccess(jsonObject: JSONObject) {
-                            super.onSuccess(jsonObject)
-                        }
-
-                        override fun onFailed(jsonObject: JSONObject) {
-                            // 这里写发送失败的方法
-                            val callbackString = jsonObject.getString(CALLBACK)
-                            showMessage("accept fail: $callbackString")
-                            super.onFailed(jsonObject)
-                        }
-                    }
-                    TcpClient.getInstance().sendTcp(callTcp, false, transaction)*/
                 } else {
                     showMessage(R.string.net_error)
                     //VoiceUtil.rejectAudioCall(Constants.ids, Constants.fromId, Constants.interactionId)

+ 17 - 6
android_host/src/main/h10_z3128_1h_chile/java/com/wdkl/ncs/android/component/nursehome/fragment/SipCallFragment.kt

@@ -7,9 +7,12 @@ import android.os.SystemClock
 import android.text.TextUtils
 import android.util.Log
 import android.view.View
+import android.widget.SeekBar
 import com.google.gson.Gson
 import com.wdkl.ncs.android.component.nursehome.R
+import com.wdkl.ncs.android.component.nursehome.settingconfig.SettingConfig
 import com.wdkl.ncs.android.component.nursehome.util.RingPlayHelper
+import com.wdkl.ncs.android.component.nursehome.util.VoiceManagerUtil
 import com.wdkl.ncs.android.lib.base.BaseApplication
 import com.wdkl.ncs.android.lib.utils.showMessage
 import com.wdkl.ncs.android.middleware.common.Constants
@@ -35,7 +38,6 @@ class SipCallFragment: BaseCallFragment() {
     private val handler = Handler(Looper.getMainLooper())
 
     private var callEnded: Boolean = false
-
     private var outGoing: Boolean = false
 
     //呼叫倒计时
@@ -53,7 +55,7 @@ class SipCallFragment: BaseCallFragment() {
 
         sipCore = WdklSipService.getCore()
 
-//        Log.d(TAG, "callState: $callState, local sip: ${Constants.sip_id}, target sip: ${Constants.targetSipId}")
+        //Log.d(TAG, "callState: $callState, local sip: ${Constants.sip_id}, target sip: ${Constants.targetSipId}")
         when (callState) {
             0 -> {
                 //发起通话
@@ -61,6 +63,7 @@ class SipCallFragment: BaseCallFragment() {
                 showCallView(true)
                 Constants.CALL_STATE = Constants.CALL_OUTGOING
                 DeviceChannel.calling = true
+                Constants.IN_CALL = true
                 RingPlayHelper.playRingTone(BaseApplication.appContext, R.raw.ring_back2, true)
             }
 
@@ -70,6 +73,10 @@ class SipCallFragment: BaseCallFragment() {
                 showCallView(false)
                 Constants.CALL_STATE = Constants.CALL_CALLING
                 DeviceChannel.calling = true
+
+                //发送accept消息
+                val callTcp = VoiceUtil.voiceAccept(tid, Constants.ids, Constants.fromId, Constants.interactionId)
+                TcpClient.getInstance().sendMsg(callTcp.toJson())
             }
         }
     }
@@ -86,7 +93,7 @@ class SipCallFragment: BaseCallFragment() {
 
             override fun onFinish() {
                 //呼叫超时,退出呼叫界面
-                showMessage("无响应")
+                showMessage(R.string.no_response)
                 DeviceChannel.calling = false
                 Constants.CALL_STATE = Constants.CALL_STANDBY
                 //VoiceUtil.cancelAudioCall(Constants.ids, Constants.targetDeviceId)
@@ -119,11 +126,13 @@ class SipCallFragment: BaseCallFragment() {
             if (call == null) {
                 call = sipCore!!.calls[0]
             }
-            call!!.terminate()
+            call?.terminate()
         }
     }
 
     override fun destroy() {
+        Constants.showCall = false
+        Constants.IN_CALL = false
         RingPlayHelper.stopRingTone()
         Constants.CALL_STATE = Constants.CALL_STANDBY
         DeviceChannel.calling = false
@@ -144,6 +153,7 @@ class SipCallFragment: BaseCallFragment() {
         }
         sky_voice_call_outgoing.visibility = View.VISIBLE
         sky_voice_call_timer.visibility = View.GONE
+        Constants.showCall = true
     }
 
     private fun showCalling(audioOnly: Boolean) {
@@ -251,7 +261,7 @@ class SipCallFragment: BaseCallFragment() {
 
                             if (sipCore == null || TextUtils.isEmpty(curIt.toSipId)) {
                                 //通话失败,重置并返回主界面
-                                showMessage("Core或targetSipId为空!")
+                                showMessage("Core targetSipId empty!")
                                 Constants.CALL_STATE = Constants.CALL_STANDBY
                                 if (sky_voice_call_timer != null) {
                                     sky_voice_call_timer.stop()
@@ -268,7 +278,7 @@ class SipCallFragment: BaseCallFragment() {
                             }
                         } else if (curTcpModel.action == TcpAction.VoiceAction.REJECT) {//对方拒绝
                             if (Constants.interactionId == curIt.id) {
-                                showMessage("对方拒绝")
+                                showMessage(R.string.call_reject)
                                 Constants.CALL_STATE = Constants.CALL_STANDBY
                                 DeviceChannel.calling = false
                                 callEnd(false)
@@ -292,6 +302,7 @@ class SipCallFragment: BaseCallFragment() {
             }
 
             Constants.SIP_CONNECTED -> {
+                Constants.IN_CALL = true
                 showCalling(true)
             }