modify
This commit is contained in:
parent
203377f6ca
commit
6542f27437
@ -76,9 +76,6 @@ class ImageTransmissionLogic extends BaseGetXController {
|
||||
// 拒绝
|
||||
StartChartManage().startTalkRejectMessageTimer();
|
||||
}
|
||||
// 完全释放资源,确保不会自动重新连接
|
||||
await Future.delayed(Duration(milliseconds: 500));
|
||||
StartChartManage().destruction();
|
||||
Get.back();
|
||||
}
|
||||
|
||||
|
||||
@ -111,6 +111,9 @@ class TalkViewNativeDecodeState {
|
||||
final List<Map<String, dynamic>> h264FrameBuffer = <Map<String, dynamic>>[]; // H264帧缓冲区,存储帧数据和类型
|
||||
int maxFrameBufferSize = 3; // 最大缓冲区大小,减小以降低延迟
|
||||
final int targetFps = 25; // 目标解码帧率,只是为了快速填充native的缓冲区
|
||||
final int adaptiveBufferSizeMin = 2; // 自适应缓冲区最小大小
|
||||
final int adaptiveBufferSizeMax = 6; // 自适应缓冲区最大大小
|
||||
final int networkQualityCheckIntervalMs = 2000; // 网络质量检查间隔(毫秒)
|
||||
final int frameProcessIntervalMs = 10; // 帧处理间隔(毫秒),提高响应速度
|
||||
Timer? frameProcessTimer; // 帧处理定时器
|
||||
bool isProcessingFrame = false; // 是否正在处理帧
|
||||
@ -126,4 +129,4 @@ class TalkViewNativeDecodeState {
|
||||
|
||||
// 是否拉伸至全屏
|
||||
RxBool isFullScreen = false.obs;
|
||||
}
|
||||
}
|
||||
@ -646,15 +646,7 @@ class TalkViewLogic extends BaseGetXController {
|
||||
|
||||
// 音频帧处理
|
||||
Future<void> _onFrame(List<int> frame) async {
|
||||
// 根据平台调整增益,避免iOS端发送音频过强导致锁端接收音量相对变小
|
||||
double gainFactor = 1.0; // 默认无增益
|
||||
if (Platform.isAndroid) {
|
||||
gainFactor = 1.2; // Android端适当增强
|
||||
} else if (Platform.isIOS) {
|
||||
gainFactor = 0.8; // iOS端降低增益,避免锁端接收音量过大而使回传音量显得过小
|
||||
}
|
||||
|
||||
final applyGain = _applyGain(frame, gainFactor);
|
||||
final applyGain = _applyGain(frame, 1.6);
|
||||
|
||||
// 编码为G711数据
|
||||
List<int> encodedData = G711Tool.encode(applyGain, 0); // 0表示A-law
|
||||
|
||||
@ -445,15 +445,8 @@ class H264WebViewLogic extends BaseGetXController {
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据平台调整增益,避免iOS端发送音频过强导致锁端接收音量相对变小
|
||||
double gainFactor = 1.0; // 默认无增益
|
||||
if (Platform.isAndroid) {
|
||||
gainFactor = 1.2; // Android端适当增强
|
||||
} else if (Platform.isIOS) {
|
||||
gainFactor = 0.8; // iOS端降低增益,避免锁端接收音量过大而使回传音量显得过小
|
||||
}
|
||||
|
||||
List<int> amplifiedFrame = _applyGain(frame, gainFactor);
|
||||
// 首先应用固定增益提升基础音量
|
||||
List<int> amplifiedFrame = _applyGain(frame, 1.8);
|
||||
// 编码为G711数据
|
||||
List<int> encodedData = G711Tool.encode(amplifiedFrame, 0); // 0表示A-law
|
||||
_bufferedAudioFrames.addAll(encodedData);
|
||||
@ -511,6 +504,25 @@ 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