浏览代码

## [1.2.2] version 82 - 2020-11-09
### Fixed
- 未能成功通话后挂断toId是空问题
- 通话过程中出错后,两方重新通话

allen 3 年之前
父节点
当前提交
30f882e044

+ 2 - 2
build.gradle

@@ -47,12 +47,12 @@ buildscript {
     /**
     /**
      * APP版本码
      * APP版本码
      */
      */
-    ext.app_version_code = 81
+    ext.app_version_code = 82
 
 
     /**
     /**
      * APP版本号
      * APP版本号
      */
      */
-    ext.app_version = "1.2.1"
+    ext.app_version = "1.2.2"
 
 
     /**
     /**
      * 项目依赖库
      * 项目依赖库

+ 4 - 0
home/src/main/code/com/wdkl/ncs/android/component/home/activity/SOSEmergencyCallActivity.kt

@@ -76,6 +76,7 @@ class SOSEmergencyCallActivity : Activity(), View.OnClickListener {
         when (p0.id) {
         when (p0.id) {
             R.id.hang_up_imagev -> {
             R.id.hang_up_imagev -> {
                 DeviceChannel.calling = false    //解除通话状态中
                 DeviceChannel.calling = false    //解除通话状态中
+                DeviceChannel.callId = 0
                 MediaPlayHelper.getInstance().releaseMusic()
                 MediaPlayHelper.getInstance().releaseMusic()
                 //给服务器发送处理SOStcp
                 //给服务器发送处理SOStcp
                 var otherUtilTcpModel = OtherUtil.SOSCancel(Constants.deviceId.toInt(), tcpModel?.fromId, interactionVO?.id)
                 var otherUtilTcpModel = OtherUtil.SOSCancel(Constants.deviceId.toInt(), tcpModel?.fromId, interactionVO?.id)
@@ -99,6 +100,7 @@ class SOSEmergencyCallActivity : Activity(), View.OnClickListener {
     override fun onStop() {
     override fun onStop() {
         super.onStop()
         super.onStop()
         DeviceChannel.calling = false    //解除通话状态中
         DeviceChannel.calling = false    //解除通话状态中
+        DeviceChannel.callId = 0
         mVibrator.cancel()
         mVibrator.cancel()
         MediaPlayHelper.getInstance().releaseMusic()
         MediaPlayHelper.getInstance().releaseMusic()
         EventBus.getDefault().unregister(this)
         EventBus.getDefault().unregister(this)
@@ -111,6 +113,7 @@ class SOSEmergencyCallActivity : Activity(), View.OnClickListener {
         }
         }
 
 
         DeviceChannel.calling = false    //解除通话状态中
         DeviceChannel.calling = false    //解除通话状态中
+        DeviceChannel.callId = 0
         mVibrator.cancel()
         mVibrator.cancel()
         MediaPlayHelper.getInstance().releaseMusic()
         MediaPlayHelper.getInstance().releaseMusic()
         EventBus.getDefault().unregister(this)
         EventBus.getDefault().unregister(this)
@@ -126,6 +129,7 @@ class SOSEmergencyCallActivity : Activity(), View.OnClickListener {
                     val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                     val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                     showMessage(interactionVO.toRoleName + " " + interactionVO.toMemberName + " 已处理")
                     showMessage(interactionVO.toRoleName + " " + interactionVO.toMemberName + " 已处理")
                     DeviceChannel.calling = false    //解除通话状态中
                     DeviceChannel.calling = false    //解除通话状态中
+                    DeviceChannel.callId = 0
                     MediaPlayHelper.getInstance().stopMusic()
                     MediaPlayHelper.getInstance().stopMusic()
                     mVibrator.cancel()
                     mVibrator.cancel()
                     finish()
                     finish()

+ 1 - 0
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WatchCallRecordsActivity.kt

@@ -288,6 +288,7 @@ class WatchCallRecordsActivity : BaseActivity<WatchCallRecordsFragmentPresenter,
                     loadingDialog.dismiss()
                     loadingDialog.dismiss()
                     call_relyout.isEnabled = true
                     call_relyout.isEnabled = true
                     DeviceChannel.calling = false;
                     DeviceChannel.calling = false;
+                    DeviceChannel.callId = 0
                     showMessage("呼叫失败,可能对方不在线")
                     showMessage("呼叫失败,可能对方不在线")
                 }else if (tcpModel.action == TcpAction.VoiceAction.CALLING){
                 }else if (tcpModel.action == TcpAction.VoiceAction.CALLING){
                     showMessage("对方通话中")
                     showMessage("对方通话中")

+ 8 - 3
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WebRTCVoipAudioActivity.kt

@@ -83,6 +83,7 @@ class WebRTCVoipAudioActivity : Activity(), View.OnClickListener, CallSessionCal
         targetId = intent.getStringExtra("targetId")
         targetId = intent.getStringExtra("targetId")
         Log.i(TAG, "SIP账号$targetId")
         Log.i(TAG, "SIP账号$targetId")
         tcpModel = intent.getSerializableExtra("TcpModel") as TcpModel
         tcpModel = intent.getSerializableExtra("TcpModel") as TcpModel
+        DeviceChannel.callId = if (tcpModel.toId==Constants.deviceId) tcpModel.fromId else tcpModel.toId
         action = intent.getStringExtra(ACTION)
         action = intent.getStringExtra(ACTION)
 
 
         Log.i(TAG, "tcpModel  " + tcpModel.toJson())
         Log.i(TAG, "tcpModel  " + tcpModel.toJson())
@@ -175,7 +176,8 @@ class WebRTCVoipAudioActivity : Activity(), View.OnClickListener, CallSessionCal
 
 
                                 gEngineKit?.endCall()
                                 gEngineKit?.endCall()
                                 val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                                 val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
-                                val voiceUtilTcpModel = VoiceUtil.voiceHandoff(Constants.deviceId, tcpModel.toId, interactionVO.id)
+                                var toId = if (interactionVO.fromDeviceId.equals(Constants.deviceId)) interactionVO.toDeviceId else interactionVO.fromDeviceId
+                                val voiceUtilTcpModel = VoiceUtil.voiceHandoff(Constants.deviceId, toId, interactionVO.id)
                                 NettyClient.instance.sendMsg(voiceUtilTcpModel.toJson()).subscribe {
                                 NettyClient.instance.sendMsg(voiceUtilTcpModel.toJson()).subscribe {
                                     if (it) {
                                     if (it) {
                                         Log.d(TAG, "TCP.发送消息完成")
                                         Log.d(TAG, "TCP.发送消息完成")
@@ -267,7 +269,8 @@ class WebRTCVoipAudioActivity : Activity(), View.OnClickListener, CallSessionCal
         //给服务器发送挂断 tcp
         //给服务器发送挂断 tcp
         if (tcpModel.type == TcpType.VOICE) {
         if (tcpModel.type == TcpType.VOICE) {
             if (tcpModel.action === TcpAction.VoiceAction.SUCCESS) {
             if (tcpModel.action === TcpAction.VoiceAction.SUCCESS) {
-                val voiceUtilTcpModel = VoiceUtil.voiceHandoff(Constants.deviceId, interactionVO.toDeviceId, interactionVO.id)
+                var toId = if (interactionVO.fromDeviceId.equals(Constants.deviceId)) interactionVO.toDeviceId else interactionVO.fromDeviceId
+                val voiceUtilTcpModel = VoiceUtil.voiceHandoff(Constants.deviceId, toId, interactionVO.id)
                 NettyClient.instance.sendMsg(voiceUtilTcpModel.toJson()).subscribe {
                 NettyClient.instance.sendMsg(voiceUtilTcpModel.toJson()).subscribe {
                     if (it) {
                     if (it) {
                         Log.d(TAG, "TCP.发送消息完成")
                         Log.d(TAG, "TCP.发送消息完成")
@@ -277,7 +280,8 @@ class WebRTCVoipAudioActivity : Activity(), View.OnClickListener, CallSessionCal
                     }
                     }
                 }
                 }
             } else if (tcpModel.action === TcpAction.VoiceAction.CALL) {
             } else if (tcpModel.action === TcpAction.VoiceAction.CALL) {
-                val voiceUtilTcpModel = VoiceUtil.voiceHandoff(Constants.deviceId, tcpModel.fromId, interactionVO.id)
+                var toId = if (interactionVO.fromDeviceId.equals(Constants.deviceId)) interactionVO.toDeviceId else interactionVO.fromDeviceId
+                val voiceUtilTcpModel = VoiceUtil.voiceHandoff(Constants.deviceId, toId, interactionVO.id)
                 NettyClient.instance.sendMsg(voiceUtilTcpModel.toJson()).subscribe {
                 NettyClient.instance.sendMsg(voiceUtilTcpModel.toJson()).subscribe {
                     if (it) {
                     if (it) {
                         Log.d(TAG, "TCP.发送消息完成")
                         Log.d(TAG, "TCP.发送消息完成")
@@ -419,6 +423,7 @@ class WebRTCVoipAudioActivity : Activity(), View.OnClickListener, CallSessionCal
     override fun onDestroy() {
     override fun onDestroy() {
         super.onDestroy()
         super.onDestroy()
         DeviceChannel.calling = false
         DeviceChannel.calling = false
+        DeviceChannel.callId = 0
         if(countDownTimer != null){
         if(countDownTimer != null){
             countDownTimer.cancel()
             countDownTimer.cancel()
         }
         }

+ 9 - 0
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WebRTCVoipAudioRingingActivity.kt

@@ -62,6 +62,7 @@ class WebRTCVoipAudioRingingActivity : Activity(), View.OnClickListener {
 
 
         targetId = intent.getStringExtra("targetId")
         targetId = intent.getStringExtra("targetId")
         tcpModel = intent.getSerializableExtra("TcpModel") as TcpModel
         tcpModel = intent.getSerializableExtra("TcpModel") as TcpModel
+        DeviceChannel.callId = if (tcpModel.toId==Constants.deviceId) tcpModel.fromId else tcpModel.toId
         interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
         interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
         init()
         init()
 
 
@@ -116,6 +117,7 @@ class WebRTCVoipAudioRingingActivity : Activity(), View.OnClickListener {
                 countDownTimer?.cancel()
                 countDownTimer?.cancel()
                 //todo 给服务器发送转接 tcp
                 //todo 给服务器发送转接 tcp
                 DeviceChannel.calling = false
                 DeviceChannel.calling = false
+                DeviceChannel.callId = 0
                 val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                 val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                 val voiceTransferTcpModel = VoiceUtil.voiceTransfer(Constants.deviceId, tcpModel.fromId, interactionVO)
                 val voiceTransferTcpModel = VoiceUtil.voiceTransfer(Constants.deviceId, tcpModel.fromId, interactionVO)
                 NettyClient.instance.sendMsg(voiceTransferTcpModel.toJson()).subscribe {
                 NettyClient.instance.sendMsg(voiceTransferTcpModel.toJson()).subscribe {
@@ -141,6 +143,7 @@ class WebRTCVoipAudioRingingActivity : Activity(), View.OnClickListener {
 
 
     fun rejectCall(){
     fun rejectCall(){
         DeviceChannel.calling = false
         DeviceChannel.calling = false
+        DeviceChannel.callId = 0
         isAnswerOrHangUp = true
         isAnswerOrHangUp = true
         MediaPlayHelper.getInstance().stopMusic()
         MediaPlayHelper.getInstance().stopMusic()
         countDownTimer?.cancel()
         countDownTimer?.cancel()
@@ -201,6 +204,7 @@ class WebRTCVoipAudioRingingActivity : Activity(), View.OnClickListener {
             override fun onFinish() {
             override fun onFinish() {
                 if (isAnswerOrHangUp) return
                 if (isAnswerOrHangUp) return
                 DeviceChannel.calling = false
                 DeviceChannel.calling = false
+                DeviceChannel.callId = 0
                 Log.i(TAG, "时间到 转发了")
                 Log.i(TAG, "时间到 转发了")
                 MediaPlayHelper.getInstance().stopMusic()
                 MediaPlayHelper.getInstance().stopMusic()
                 //todo 给服务器发送转接 tcp
                 //todo 给服务器发送转接 tcp
@@ -260,6 +264,7 @@ class WebRTCVoipAudioRingingActivity : Activity(), View.OnClickListener {
                     MediaPlayHelper.getInstance().stopMusic()
                     MediaPlayHelper.getInstance().stopMusic()
                     mVibrator.cancel()
                     mVibrator.cancel()
                     DeviceChannel.calling = false
                     DeviceChannel.calling = false
+                    DeviceChannel.callId = 0
 //                asyncPlayer.stop()
 //                asyncPlayer.stop()
                     finish()
                     finish()
                 }
                 }
@@ -267,6 +272,10 @@ class WebRTCVoipAudioRingingActivity : Activity(), View.OnClickListener {
             }
             }
         } else if (messageEvent.tag == Constants.EVENT_BLUETOOTH_ACCEPT_CALL){
         } else if (messageEvent.tag == Constants.EVENT_BLUETOOTH_ACCEPT_CALL){
             answerCall()
             answerCall()
+        } else if (messageEvent.tag == 11){
+            MediaPlayHelper.getInstance().stopMusic()
+            mVibrator.cancel()
+            finish()
         }
         }
     }
     }
 
 

+ 27 - 2
home/src/main/code/com/wdkl/ncs/android/component/home/service/WdKeepAliveService.kt

@@ -99,7 +99,8 @@ class WdKeepAliveService : AbsWorkService() {
 
 
                     if (tcpModel.action == TcpAction.VoiceAction.SUCCESS) {  //拨出成功
                     if (tcpModel.action == TcpAction.VoiceAction.SUCCESS) {  //拨出成功
                         Log.i(TAG, "拨出成功 ${interactionVO.fromMemberName} ${interactionVO.id}")
                         Log.i(TAG, "拨出成功 ${interactionVO.fromMemberName} ${interactionVO.id}")
-                        DeviceChannel.calling = true;
+                        DeviceChannel.calling = true
+                        DeviceChannel.callId = if (tcpModel.toId==Constants.deviceId) tcpModel.fromId else tcpModel.toId
                         intent.setClass(this, WebRTCVoipAudioActivity::class.java)
                         intent.setClass(this, WebRTCVoipAudioActivity::class.java)
                         intent.putExtra("targetId", interactionVO?.toSipId)
                         intent.putExtra("targetId", interactionVO?.toSipId)
                         intent.putExtra("TcpModel", tcpModel)
                         intent.putExtra("TcpModel", tcpModel)
@@ -107,7 +108,8 @@ class WdKeepAliveService : AbsWorkService() {
                         intent.putExtra(WebRTCVoipAudioActivity().ACTION, WebRTCVoipAudioActivity().CALL)
                         intent.putExtra(WebRTCVoipAudioActivity().ACTION, WebRTCVoipAudioActivity().CALL)
                         startActivity(intent)
                         startActivity(intent)
                     } else if (tcpModel.action == TcpAction.VoiceAction.CALL) {  //有来电
                     } else if (tcpModel.action == TcpAction.VoiceAction.CALL) {  //有来电
-                        DeviceChannel.calling = true;
+                        DeviceChannel.calling = true
+                        DeviceChannel.callId = if (tcpModel.toId==Constants.deviceId) tcpModel.fromId else tcpModel.toId
                         Log.i(TAG, "来电:" + JSON.toJSONString(interactionVO))
                         Log.i(TAG, "来电:" + JSON.toJSONString(interactionVO))
                         intent.setClass(this, WebRTCVoipAudioRingingActivity::class.java)
                         intent.setClass(this, WebRTCVoipAudioRingingActivity::class.java)
                         intent.putExtra("targetId", interactionVO?.fromSipId)
                         intent.putExtra("targetId", interactionVO?.fromSipId)
@@ -117,6 +119,29 @@ class WdKeepAliveService : AbsWorkService() {
                     }
                     }
                 }
                 }
             }
             }
+            11 -> {
+                Util.wakeUpAndUnlock(this)
+                SpeechUtil.getInstance().stopSpeak()
+                val tcpModel = messageEvent.getMessage() as TcpModel
+                if (tcpModel.type == TcpType.VOICE && tcpModel.action == TcpAction.VoiceAction.CALL){
+                    DeviceChannel.calling = true
+                    DeviceChannel.callId = if (tcpModel.toId==Constants.deviceId) tcpModel.fromId else tcpModel.toId
+
+                    val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
+                    val intent = Intent()
+                    Log.i(TAG, "来电:" + JSON.toJSONString(interactionVO))
+                    intent.setClass(this, WebRTCVoipAudioRingingActivity::class.java)
+                    intent.putExtra("targetId", interactionVO?.fromSipId)
+                    intent.putExtra("TcpModel", tcpModel)
+                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+
+                    Thread(Runnable {
+                        Thread.sleep(400)
+                        startActivity(intent)
+                    }).start()
+
+                }
+            }
             //事件与语音留言通道
             //事件与语音留言通道
             3 -> {
             3 -> {
                 if (!mNewEventListActive) {
                 if (!mNewEventListActive) {

+ 10 - 4
middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/channel/DeviceChannel.java

@@ -28,6 +28,7 @@ public class DeviceChannel {
 
 
     //通话中模拟
     //通话中模拟
     public static boolean calling = false;
     public static boolean calling = false;
+    public static int callId = 0;
 
 
     public static TcpModel handleTcpReceived(TcpModel tcpModel){
     public static TcpModel handleTcpReceived(TcpModel tcpModel){
         TcpModel responseTcpModel = null;
         TcpModel responseTcpModel = null;
@@ -50,10 +51,15 @@ public class DeviceChannel {
                     EventBus.getDefault().post(new MessageEvent(tcpModel, 1));
                     EventBus.getDefault().post(new MessageEvent(tcpModel, 1));
                 } else if(tcpModel.getAction() == TcpAction.VoiceAction.CALL){
                 } else if(tcpModel.getAction() == TcpAction.VoiceAction.CALL){
                     if (calling) {
                     if (calling) {
-                        InteractionVO interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
-                        responseTcpModel = VoiceUtil.voiceCalling(Constants.Companion.getDeviceId(), tcpModel.getFromId(), interactionVO.getId());
-                        //给服务器发送正在通话中 tcp
-                        return responseTcpModel;
+                        //相同来源,重新建立通话
+                        if (tcpModel.getFromId().equals(callId)){
+                            EventBus.getDefault().post(new MessageEvent(tcpModel, 11));
+                        } else {
+                            InteractionVO interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
+                            responseTcpModel = VoiceUtil.voiceCalling(Constants.Companion.getDeviceId(), tcpModel.getFromId(), interactionVO.getId());
+                            //给服务器发送正在通话中 tcp
+                            return responseTcpModel;
+                        }
                     } else { //得到通话
                     } else { //得到通话
                         EventBus.getDefault().post(new MessageEvent(tcpModel, 1));
                         EventBus.getDefault().post(new MessageEvent(tcpModel, 1));
                     }
                     }

+ 7 - 0
readme.md

@@ -26,6 +26,13 @@
 
 
 ---
 ---
 
 
+## [1.2.2] version 82 - 2020-11-09
+### Fixed
+- 未能成功通话后挂断toId是空问题
+- 通话过程中出错后,两方重新通话
+
+---
+
 ## [1.2.1] version 81 - 2020-11-03
 ## [1.2.1] version 81 - 2020-11-03
 ### Changed
 ### Changed
 - NettyClient重构重连,判断是否在连接过程中
 - NettyClient重构重连,判断是否在连接过程中