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 42df4674..6fb1aaca 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 @@ -93,34 +93,32 @@ class TalkViewNativeDecodeLogic extends BaseGetXController { Future _initVideoDecoder() async { try { state.isLoading.value = true; - - // ios第一次点击监控没画面 - // 等待视频参数就绪,设置超时时间 int width = StartChartManage().videoWidth; int height = StartChartManage().videoHeight; - - // 如果视频参数未就绪,等待一段时间直到参数就绪或超时 - if (width == 0 || height == 0) { - int attempts = 0; - const maxAttempts = 20; // 最多等待2秒 (20 * 100ms) - - while ((width == 0 || height == 0) && attempts < maxAttempts) { - await Future.delayed(const Duration(milliseconds: 100)); - width = StartChartManage().videoWidth; - height = StartChartManage().videoHeight; - attempts++; - } - - // 如果仍然没有获取到参数,使用默认值 + + if(Platform.isIOS){ + // ios第一次点击监控没画面 if (width == 0 || height == 0) { - width = 864; - height = 480; - AppLog.log('使用默认视频参数: ${width}x$height'); - } else { - AppLog.log('获取到视频参数: ${width}x$height'); + int attempts = 0; + const maxAttempts = 20; // 最多等待2秒 (20 * 100ms) + + while ((width == 0 || height == 0) && attempts < maxAttempts) { + await Future.delayed(const Duration(milliseconds: 100)); + width = StartChartManage().videoWidth; + height = StartChartManage().videoHeight; + attempts++; + } + + // 如果仍然没有获取到参数,使用默认值 + if (width == 0 || height == 0) { + width = 864; + height = 480; + AppLog.log('使用默认视频参数: ${width}x$height'); + } else { + AppLog.log('获取到视频参数: ${width}x$height'); + } } } - // 创建解码器配置 final config = VideoDecoderConfig( width: width, @@ -128,7 +126,6 @@ class TalkViewNativeDecodeLogic extends BaseGetXController { height: height, codecType: 'h264', ); - AppLog.log('解码器配置的宽高为:${config.width}x${config.height}'); // 初始化解码器并获取textureId final textureId = await VideoDecodePlugin.initDecoder(config); if (textureId != null) { @@ -272,7 +269,8 @@ class TalkViewNativeDecodeLogic extends BaseGetXController { // 取消已有定时器 state.frameProcessTimer?.cancel(); - // 使用配置的间隔时间 + // 计算定时器间隔,确保以目标帧率处理帧 + // final int intervalMs = (1000 / state.targetFps).round(); final int intervalMs = state.frameProcessIntervalMs; // 创建新定时器 diff --git a/lib/talk/starChart/views/talkView/talk_view_logic.dart b/lib/talk/starChart/views/talkView/talk_view_logic.dart index c4000dbb..706b24b0 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 = 3; // 增大缓冲区,满时才渲染 + int bufferSize = 8; // 增大缓冲区,满时才渲染 int audioBufferSize = 2; // 音频默认缓冲2帧 bool _isFirstAudioFrame = true; // 是否是第一帧 diff --git a/lib/talk/starChart/webView/h264_web_logic.dart b/lib/talk/starChart/webView/h264_web_logic.dart index 158e3f1a..b7307383 100644 --- a/lib/talk/starChart/webView/h264_web_logic.dart +++ b/lib/talk/starChart/webView/h264_web_logic.dart @@ -504,25 +504,6 @@ class H264WebViewLogic extends BaseGetXController { return result; } - // 添加音频降噪处理方法 - List _applyDenoise(List pcmData) { - // 使用简单的噪声门限处理 - const int noiseThreshold = 150; // 设定噪音阈值 - - List result = List.filled(pcmData.length, 0); - - for (int i = 0; i < pcmData.length; i++) { - // 如果样本值小于噪音阈值,则将其设为0 - if (pcmData[i].abs() < noiseThreshold) { - result[i] = 0; - } else { - result[i] = pcmData[i]; - } - } - - return result; - } - /// 挂断 void udpHangUpAction() async { if (state.talkStatus.value == TalkStatus.answeredSuccessfully) {