diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 7c086ba5..cf9eda27 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -773,7 +773,7 @@ class LockDetailLogic extends BaseGetXController { return; } // 重置丢包率监控 - PacketLossStatistics().reset(); + // PacketLossStatistics().reset(); // 发送监控id StartChartManage() .startCallRequestMessageTimer(ToPeerId: network!.peerId ?? ''); diff --git a/lib/talk/starChart/star_chart_manage.dart b/lib/talk/starChart/star_chart_manage.dart index d64cb808..2d8b4529 100644 --- a/lib/talk/starChart/star_chart_manage.dart +++ b/lib/talk/starChart/star_chart_manage.dart @@ -606,7 +606,7 @@ class StartChartManage { void startTalkRejectMessageTimer() async { try { int count = 0; - final int maxCount = 10; // 最大执行次数为10秒 + final int maxCount = 3; // 最大执行次数为10秒 talkRejectTimer ??= Timer.periodic( Duration(seconds: _defaultIntervalTime), @@ -632,6 +632,8 @@ class StartChartManage { stopCallRequestMessageTimer(); stopSendingRbcuInfoMessages(); stopSendingRbcuProBeMessages(); + stopTalkAcceptTimer(); + stopCallRequestMessageTimer(); // 取消定时器 talkePingOverTimeTimerManager.cancel(); @@ -730,6 +732,8 @@ class StartChartManage { stopCallRequestMessageTimer(); stopSendingRbcuInfoMessages(); stopSendingRbcuProBeMessages(); + stopTalkAcceptTimer(); + stopCallRequestMessageTimer(); // 取消定时器 talkePingOverTimeTimerManager.cancel(); talkDataOverTimeTimerManager.cancel(); 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 033c3f57..af05d336 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 @@ -148,7 +148,6 @@ class TalkViewNativeDecodeLogic extends BaseGetXController { ) { // 只允许frameSeq严格递增,乱序或重复帧直接丢弃 if (_lastFrameSeq != null && frameSeq <= _lastFrameSeq!) { - // 可选:打印日志 AppLog.log('丢弃乱序或重复帧: frameSeq=$frameSeq, lastFrameSeq=$_lastFrameSeq'); return; } @@ -162,13 +161,19 @@ class TalkViewNativeDecodeLogic extends BaseGetXController { 'pts': pts, }; + // 如果缓冲区超出最大大小,优先丢弃P/B帧 + while (state.h264FrameBuffer.length >= state.maxFrameBufferSize) { + int pbIndex = state.h264FrameBuffer.indexWhere((f) => + f['frameType'] == TalkDataH264Frame_FrameTypeE.P); + if (pbIndex != -1) { + state.h264FrameBuffer.removeAt(pbIndex); + } else { + state.h264FrameBuffer.removeAt(0); + } + } + // 将帧添加到缓冲区 state.h264FrameBuffer.add(frameMap); - - // 如果缓冲区超出最大大小,移除最早的帧 - while (state.h264FrameBuffer.length > state.maxFrameBufferSize) { - state.h264FrameBuffer.removeAt(0); - } } /// 启动帧处理定时器 @@ -212,16 +217,16 @@ class TalkViewNativeDecodeLogic extends BaseGetXController { int pts = frameMap['pts']; // int pts = DateTime.now().millisecondsSinceEpoch; - // if (frameType == TalkDataH264Frame_FrameTypeE.P) { - // // 以frameSeqI为I帧序号标识 - // if (!(_decodedIFrames.contains(frameSeqI))) { - // AppLog.log('丢弃P帧:未收到对应I帧,frameSeqI=${frameSeqI}'); - // return; - // } - // } else if (frameType == TalkDataH264Frame_FrameTypeE.I) { - // // 记录已解码I帧序号 - // _decodedIFrames.add(frameSeq); - // } + if (frameType == TalkDataH264Frame_FrameTypeE.P) { + // 以frameSeqI为I帧序号标识 + if (!(_decodedIFrames.contains(frameSeqI))) { + AppLog.log('丢弃P帧:未收到对应I帧,frameSeqI=${frameSeqI}'); + return; + } + } else if (frameType == TalkDataH264Frame_FrameTypeE.I) { + // 记录已解码I帧序号 + _decodedIFrames.add(frameSeq); + } // 实时写入h264文件 // _appendH264FrameToFile(frameData, frameType); diff --git a/lib/talk/starChart/views/native/talk_view_native_decode_state.dart b/lib/talk/starChart/views/native/talk_view_native_decode_state.dart index 8703012d..b63ffc29 100644 --- a/lib/talk/starChart/views/native/talk_view_native_decode_state.dart +++ b/lib/talk/starChart/views/native/talk_view_native_decode_state.dart @@ -109,7 +109,7 @@ class TalkViewNativeDecodeState { // H264帧缓冲区相关 final List> h264FrameBuffer = >[]; // H264帧缓冲区,存储帧数据和类型 - final int maxFrameBufferSize = 7; // 最大缓冲区大小 + final int maxFrameBufferSize = 15; // 最大缓冲区大小 final int targetFps = 30; // 目标解码帧率,只是为了快速填充native的缓冲区 Timer? frameProcessTimer; // 帧处理定时器 bool isProcessingFrame = false; // 是否正在处理帧