modify
This commit is contained in:
parent
6542f27437
commit
9219168df5
@ -93,34 +93,32 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
|
||||
Future<void> _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;
|
||||
|
||||
// 创建新定时器
|
||||
|
||||
@ -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; // 是否是第一帧
|
||||
|
||||
@ -504,25 +504,6 @@ class H264WebViewLogic extends BaseGetXController {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 添加音频降噪处理方法
|
||||
List<int> _applyDenoise(List<int> pcmData) {
|
||||
// 使用简单的噪声门限处理
|
||||
const int noiseThreshold = 150; // 设定噪音阈值
|
||||
|
||||
List<int> result = List<int>.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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user