From d3969b6ba5efa96fd8d28d40b288933eb089b53a Mon Sep 17 00:00:00 2001 From: sky_min Date: Mon, 17 Nov 2025 17:58:38 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9F=A5=E7=9C=8B=E6=93=8D=E4=BD=9C=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=8C=89=E9=97=A8=E9=93=83=E5=B8=A6=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E9=97=AE=E9=A2=98=202.=E8=A7=86=E9=A2=91=E5=AF=B9=E8=AE=B2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configuringWifi_logic.dart | 1 - .../message/messageList/messageList_page.dart | 14 ++++-- .../native/talk_view_native_decode_logic.dart | 49 ++++++++++--------- .../views/talkView/talk_view_logic.dart | 20 ++++++-- 4 files changed, 49 insertions(+), 35 deletions(-) diff --git a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart index 548e6e51..599f65fc 100755 --- a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart +++ b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart @@ -142,7 +142,6 @@ class ConfiguringWifiLogic extends BaseGetXController { String result = utf8String(secretKeyList); AppLog.log('解析配网信息: $result'); - AppLog.log('使用传入的RSSI值: ${state.rssi.value}'); // 解析 JSON 字符串为 Map Map jsonMap = json.decode(result); diff --git a/lib/mine/message/messageList/messageList_page.dart b/lib/mine/message/messageList/messageList_page.dart index 92e097c2..481a5a71 100755 --- a/lib/mine/message/messageList/messageList_page.dart +++ b/lib/mine/message/messageList/messageList_page.dart @@ -318,7 +318,7 @@ class _MessageListPageState extends State Container( width: 0.5, height: 120.h, - color: AppColors.placeholderTextColor, + color: Color.fromRGBO(0, 0, 0, 0.2), ) ], )), @@ -352,12 +352,13 @@ class _MessageListPageState extends State ), child: Container( width: 1.sw, - margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 8.h), + margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.h, bottom: 20.h), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Wrap( children: [ + // 时间 Container( margin: EdgeInsets.only(top: 4.h), child: Text( @@ -370,6 +371,7 @@ class _MessageListPageState extends State ), ), ), + // 竖线 Container( width: 1, height: 10, @@ -378,8 +380,10 @@ class _MessageListPageState extends State ? AppColors.blackColor : AppColors.placeholderTextColor, ), - Container(transform: Matrix4.translationValues(0, -22, 0), - child: Text(' ${messageItemEntity.data!}', + // 标题 + Container( + margin: EdgeInsets.only(top: 2.h), + child: Text('${messageItemEntity.data!}', maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -389,7 +393,7 @@ class _MessageListPageState extends State : AppColors.placeholderTextColor, ), )), - Container(transform: Matrix4.translationValues(0, -8, 0), child: GestureDetector( + Container(margin: EdgeInsets.only(top: 10.h), child: GestureDetector( child: Text('点击查看', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 20.sp, color: AppColors.mainColor),), ),alignment: Alignment.centerRight,) ], diff --git a/lib/talk/starChart/views/native/talk_view_native_decode_logic.dart b/lib/talk/starChart/views/native/talk_view_native_decode_logic.dart index 95fba8b0..ba87d327 100644 --- a/lib/talk/starChart/views/native/talk_view_native_decode_logic.dart +++ b/lib/talk/starChart/views/native/talk_view_native_decode_logic.dart @@ -44,29 +44,6 @@ class TalkViewNativeDecodeLogic extends BaseGetXController { // 添加成员变量缓存帧索引 final Map>> _frameIndexCache = {}; bool _frameIndexDirty = true; - // 更新帧缓冲区时标记索引为脏数据 - void _invalidateFrameIndex() { - _frameIndexDirty = true; - } - // 构建帧索引 - List> _buildFrameIndex(TalkDataH264Frame_FrameTypeE frameType) { - if (!_frameIndexDirty && _frameIndexCache.containsKey(frameType)) { - return _frameIndexCache[frameType]!; - } - - final List> index = []; - for (int i = 0; i < state.h264FrameBuffer.length; i++) { - final frame = state.h264FrameBuffer[i]; - if (frame['frameType'] == frameType) { - index.add(MapEntry(frame['frameSeq'] as int, i)); - } - } - index.sort((a, b) => a.key.compareTo(b.key)); - - _frameIndexCache[frameType] = index; - _frameIndexDirty = false; - return index; - } // 添加网络质量评估变量 int _networkQualityScore = 5; // 1-5分,5为最佳 @@ -532,6 +509,30 @@ class TalkViewNativeDecodeLogic extends BaseGetXController { } } + // 更新帧缓冲区时标记索引为脏数据 + void _invalidateFrameIndex() { + _frameIndexDirty = true; + } + // 构建帧索引 + List> _buildFrameIndex(TalkDataH264Frame_FrameTypeE frameType) { + if (!_frameIndexDirty && _frameIndexCache.containsKey(frameType)) { + return _frameIndexCache[frameType]!; + } + + final List> index = []; + for (int i = 0; i < state.h264FrameBuffer.length; i++) { + final frame = state.h264FrameBuffer[i]; + if (frame['frameType'] == frameType) { + index.add(MapEntry(frame['frameSeq'] as int, i)); + } + } + index.sort((a, b) => a.key.compareTo(b.key)); + + _frameIndexCache[frameType] = index; + _frameIndexDirty = false; + return index; + } + int _findEarliestIFrame() { final iFrameIndexes = _buildFrameIndex(TalkDataH264Frame_FrameTypeE.I); return iFrameIndexes.isNotEmpty ? iFrameIndexes.first.value : -1; @@ -1344,7 +1345,7 @@ class TalkViewNativeDecodeLogic extends BaseGetXController { try { // 使用较短超时时间 final textureId = await VideoDecodePlugin.initDecoder(config) - .timeout(Duration(milliseconds: 800)); + .timeout(Duration(milliseconds: 500)); if (textureId != null) { state.textureId.value = textureId; diff --git a/lib/talk/starChart/views/talkView/talk_view_logic.dart b/lib/talk/starChart/views/talkView/talk_view_logic.dart index 0b22a68a..c4000dbb 100644 --- a/lib/talk/starChart/views/talkView/talk_view_logic.dart +++ b/lib/talk/starChart/views/talkView/talk_view_logic.dart @@ -41,7 +41,7 @@ class TalkViewLogic extends BaseGetXController { final LockDetailState lockDetailState = Get.put(LockDetailLogic()).state; - int bufferSize = 8; // 增大缓冲区,满时才渲染 + int bufferSize = 3; // 增大缓冲区,满时才渲染 int audioBufferSize = 2; // 音频默认缓冲2帧 bool _isFirstAudioFrame = true; // 是否是第一帧 @@ -123,11 +123,12 @@ class TalkViewLogic extends BaseGetXController { _playAudioFrames(); break; case TalkData_ContentTypeE.Image: + // 如果缓冲区已满,移除最旧的帧 + if (state.videoBuffer.length >= bufferSize) { + state.videoBuffer.removeAt(0); + } // 固定长度缓冲区,最多保留bufferSize帧 state.videoBuffer.add(talkData); - if (state.videoBuffer.length > bufferSize) { - state.videoBuffer.removeAt(0); // 移除最旧帧 - } break; } }); @@ -370,12 +371,21 @@ class TalkViewLogic extends BaseGetXController { requestPermissions(); + bool _isValidImageData(List data) { + // 检查数据长度 + if (data.length < 10) return false; + // 检查JPEG格式 (0xFFD8FF) + if (data[0] == 0xFF && data[1] == 0xD8 && data[2] == 0xFF) return true; + // 检查PNG格式 (0x89504E47) + if (data[0] == 0x89 && data[1] == 0x50 && data[2] == 0x4E && data[3] == 0x47) return true; + return false; + } // 启动视频渲染定时器(10fps) videoRenderTimer = Timer.periodic(const Duration(milliseconds: 100), (_) { final int now = DateTime.now().millisecondsSinceEpoch; if (state.videoBuffer.isNotEmpty) { final TalkData oldestFrame = state.videoBuffer.removeAt(0); - if (oldestFrame.content.isNotEmpty) { + if (oldestFrame.content.isNotEmpty && _isValidImageData(oldestFrame.content)) { state.listData.value = Uint8List.fromList(oldestFrame.content); // 备份原始数据 final int decodeStart = DateTime.now().millisecondsSinceEpoch;