Przeglądaj źródła

完善sip通话相关修改

weizhengliang 3 lat temu
rodzic
commit
0bb6675315

+ 12 - 10
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/activity/CallingdoorActivity.kt

@@ -794,16 +794,18 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
         if (WdklSipService.getCore() != null) {
             mAccountCreator = WdklSipService.getCore().createAccountCreator(null)
             // 以下三项必须
-            mAccountCreator!!.setDomain(Constant.TCP_SERVER_URL)
-            mAccountCreator!!.setUsername("3305")
-            mAccountCreator!!.setPassword("3305")
-            //默认使用udp
-            mAccountCreator!!.transport = TransportType.Udp
-
-            // 这里会自动创建代理配置、认证信息到 SIP核心
-            val cfg = mAccountCreator!!.createProxyConfig()
-            // 确保新创建的是最新
-            WdklSipService.getCore().defaultProxyConfig = cfg
+            if (!TextUtils.isEmpty(Constant.TCP_SERVER_URL) && !TextUtils.isEmpty(Constant.SIP_ID)) {
+                mAccountCreator!!.setDomain(Constant.TCP_SERVER_URL)
+                mAccountCreator!!.setUsername(Constant.SIP_ID)
+                mAccountCreator!!.setPassword(Constant.SIP_ID)
+                //默认使用udp
+                mAccountCreator!!.transport = TransportType.Udp
+
+                // 这里会自动创建代理配置、认证信息到 SIP核心
+                val cfg = mAccountCreator!!.createProxyConfig()
+                // 确保新创建的是最新
+                WdklSipService.getCore().defaultProxyConfig = cfg
+            }
         }
 
         //检查版本

+ 4 - 4
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/fragment/SipCallFragment.kt

@@ -51,7 +51,7 @@ class SipCallFragment: BaseCallFragment() {
             state: Call.State,
             message: String
         ) {
-            Log.d(TAG, "received call state: $state, ${call.remoteAddress}")
+            Log.e(TAG, "received call state: $state, ${call.remoteAddress.displayName}, $message")
             if (state == Call.State.IncomingReceived) {
                 //来电时将自动接听
                 if (sipCore != null) {
@@ -339,7 +339,7 @@ class SipCallFragment: BaseCallFragment() {
                             Constant.interactionId = curInteractionVO.id
                             fromId = curTcpModel.fromId
                             acceptCall()
-                            if (sipCore == null && TextUtils.isEmpty(curInteractionVO.toSipId)) {
+                            if (sipCore == null || TextUtils.isEmpty(curInteractionVO.toSipId)) {
                                 //通话失败,重置并返回主界面
                                 showMessage("Core或targetSipId为空!")
                                 Constant.CALL_STATE = Constant.CALL_STANDBY
@@ -348,12 +348,12 @@ class SipCallFragment: BaseCallFragment() {
                                 }
                                 callEnd(true)
                             } else {
-                                //todo: 这里需要修改target sip
-                                val addressToCall = sipCore!!.interpretUrl("3309")
+                                val addressToCall = sipCore!!.interpretUrl(curInteractionVO.toSipId)
                                 val params = sipCore!!.createCallParams(null)
                                 params.enableVideo(false)
                                 if (addressToCall != null) {
                                     sipCore!!.inviteAddressWithParams(addressToCall, params)
+                                    Log.d(TAG, "invite target device: " + addressToCall.asString())
                                 }
                             }
                         } else if (curTcpModel.getAction() == TcpAction.VoiceAction.REJECT) {