From a7a70f41b1d43329f0953896f1005ef7106e543d Mon Sep 17 00:00:00 2001 From: liyi Date: Tue, 13 May 2025 10:19:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=88=86=E8=BE=A8=E7=8E=87=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handle/impl/udp_talk_accept_handler.dart | 31 +++++++-- .../handle/impl/udp_talk_request_handler.dart | 66 +++++++++++++++++-- 2 files changed, 87 insertions(+), 10 deletions(-) diff --git a/lib/talk/starChart/handle/impl/udp_talk_accept_handler.dart b/lib/talk/starChart/handle/impl/udp_talk_accept_handler.dart index baaae2e8..35389a70 100644 --- a/lib/talk/starChart/handle/impl/udp_talk_accept_handler.dart +++ b/lib/talk/starChart/handle/impl/udp_talk_accept_handler.dart @@ -15,6 +15,7 @@ import 'package:star_lock/talk/starChart/proto/generic.pb.dart'; import 'package:star_lock/talk/starChart/proto/talk_accept.pb.dart'; import 'package:star_lock/talk/starChart/proto/talk_expect.pb.dart'; import 'package:star_lock/tools/commonDataManage.dart'; +import 'package:star_lock/tools/storage.dart'; import '../../star_chart_manage.dart'; @@ -34,7 +35,7 @@ class UdpTalkAcceptHandler extends ScpMessageBaseHandle // 停止同意接听的重发 startChartManage.stopTalkAcceptTimer(); // 接听之后增加期望音频的接收 - _handleSendExpect(); + _handleSendExpect(lockPeerID: scpMessage.FromPeerId!); // 停止播放铃声 stopRingtone(); // 设置状态为接听成功 @@ -79,11 +80,33 @@ class UdpTalkAcceptHandler extends ScpMessageBaseHandle } /// 收到同意接听回复之后增加音频的期望数据 - void _handleSendExpect() { + void _handleSendExpect({ + required String lockPeerID, + }) async { final LockListInfoItemEntity currentKeyInfo = CommonDataManage().currentKeyInfo; - final isH264 = currentKeyInfo.lockFeature?.isH264 == 1; - final isMJpeg = currentKeyInfo.lockFeature?.isMJpeg == 1; + + var isH264 = currentKeyInfo.lockFeature?.isH264 == 1; + var isMJpeg = currentKeyInfo.lockFeature?.isMJpeg == 1; + + final LockListInfoGroupEntity? lockListInfoGroupEntity = + await Storage.getLockMainListData(); + if (lockListInfoGroupEntity != null) { + lockListInfoGroupEntity!.groupList?.forEach((element) { + final lockList = element.lockList; + if (lockList != null && lockList.length != 0) { + for (var lockInfo in lockList) { + final peerId = lockInfo.network?.peerId; + if (peerId != null && peerId != '') { + if (peerId == lockPeerID) { + isH264 = lockInfo.lockFeature?.isH264 == 1; + isMJpeg = lockInfo.lockFeature?.isMJpeg == 1; + } + } + } + } + }); + } // 优先使用H264,其次是MJPEG if (isH264) { diff --git a/lib/talk/starChart/handle/impl/udp_talk_request_handler.dart b/lib/talk/starChart/handle/impl/udp_talk_request_handler.dart index 55a2ac27..7ce19cf6 100644 --- a/lib/talk/starChart/handle/impl/udp_talk_request_handler.dart +++ b/lib/talk/starChart/handle/impl/udp_talk_request_handler.dart @@ -37,7 +37,10 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle startChartManage.ToPeerId = scpMessage.FromPeerId!; startChartManage.lockPeerId = scpMessage.FromPeerId!; // 处理收到接听请求后的事件 - _talkRequestEvent(talkObjectName: talkReq.callerName); + _talkRequestEvent( + talkObjectName: talkReq.callerName, + lockPeerID: scpMessage.FromPeerId!, + ); // 回复成功 replySuccessMessage(scpMessage); @@ -78,9 +81,12 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle void handleRealTimeData(ScpMessage scpMessage) {} // 来电事件的处理 - void _talkRequestEvent({required String talkObjectName}) { + void _talkRequestEvent({ + required String talkObjectName, + required String lockPeerID, + }) async { // 发送预期数据、通知锁板需要获取视频数据 - _handleRequestSendExpect(); + _handleRequestSendExpect(lockPeerID: lockPeerID); // 播放铃声 //test:使用自定义铃声 playRingtone(); @@ -88,6 +94,33 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle // _showTalkRequestNotification(talkObjectName: talkObjectName); // 设置为等待接听状态 talkStatus.setPassiveCallWaitingAnswer(); + + // 获取锁支持项 + final LockListInfoItemEntity currentKeyInfo = + CommonDataManage().currentKeyInfo; + var isWifiLockType = currentKeyInfo.lockFeature?.wifiLockType == 1; + + final LockListInfoGroupEntity? lockListInfoGroupEntity = + await Storage.getLockMainListData(); + if (lockListInfoGroupEntity != null) { + lockListInfoGroupEntity!.groupList?.forEach((element) { + final lockList = element.lockList; + if (lockList != null && lockList.length != 0) { + for (var lockInfo in lockList) { + final peerId = lockInfo.network?.peerId; + if (peerId != null && peerId != '') { + if (peerId == lockPeerID) { + isWifiLockType = lockInfo.lockFeature?.wifiLockType == 1; + } + } + } + } + }); + } + if (isWifiLockType) { + Get.toNamed(Routers.imageTransmissionView); + return; + } if (startChartManage .getDefaultTalkExpect() .videoType @@ -170,12 +203,33 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle } /// app收到的对讲请求后,发送的预期数据 - void _handleRequestSendExpect() { + void _handleRequestSendExpect({ + required String lockPeerID, + }) async { final LockListInfoItemEntity currentKeyInfo = CommonDataManage().currentKeyInfo; - final isH264 = currentKeyInfo.lockFeature?.isH264 == 1; - final isMJpeg = currentKeyInfo.lockFeature?.isMJpeg == 1; + var isH264 = currentKeyInfo.lockFeature?.isH264 == 1; + var isMJpeg = currentKeyInfo.lockFeature?.isMJpeg == 1; + + final LockListInfoGroupEntity? lockListInfoGroupEntity = + await Storage.getLockMainListData(); + if (lockListInfoGroupEntity != null) { + lockListInfoGroupEntity!.groupList?.forEach((element) { + final lockList = element.lockList; + if (lockList != null && lockList.length != 0) { + for (var lockInfo in lockList) { + final peerId = lockInfo.network?.peerId; + if (peerId != null && peerId != '') { + if (peerId == lockPeerID) { + isH264 = lockInfo.lockFeature?.isH264 == 1; + isMJpeg = lockInfo.lockFeature?.isMJpeg == 1; + } + } + } + } + }); + } // 优先使用H264,其次是MJPEG if (isH264) { // 锁支持H264,发送H264视频和G711音频期望