fix:调整发送g711音频数据、增加回声消除、增大缓冲区、调整A律解码效果
This commit is contained in:
parent
911396e1f3
commit
6f76a7d5b5
@ -77,6 +77,9 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
if (reply is GatewayGetStatusReply) {
|
||||
_replyGatewayGetStatusReply(reply);
|
||||
}
|
||||
if (reply is GatewayGetStatusReply) {
|
||||
_replyStatusInfo(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -329,4 +332,6 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _replyStatusInfo(reply) {}
|
||||
}
|
||||
|
||||
@ -1,14 +1,17 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_pcm_sound/flutter_pcm_sound.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/blue/blue_manage.dart';
|
||||
import 'package:star_lock/main/lockMian/lockList/lockList_xhj_page.dart';
|
||||
import 'package:star_lock/main/lockMian/lockMain/lockMain_state.dart';
|
||||
import 'package:star_lock/talk/call/g711.dart';
|
||||
import 'package:star_lock/talk/startChart/proto/talk_data.pb.dart';
|
||||
import 'package:star_lock/talk/startChart/proto/talk_expect.pb.dart';
|
||||
import 'package:star_lock/talk/startChart/proto/talk_request.pb.dart';
|
||||
|
||||
@ -36,6 +36,7 @@ class TalkePingOverTimeTimerManager {
|
||||
StartChartManage().sendTalkHangupMessage();
|
||||
talkStatus.setNotTalkPing();
|
||||
talkStatus.setEnd();
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
@ -11,6 +13,7 @@ import 'package:flutter_screen_recording/flutter_screen_recording.dart';
|
||||
import 'package:flutter_voice_processor/flutter_voice_processor.dart';
|
||||
import 'package:gallery_saver/gallery_saver.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:image_gallery_saver/image_gallery_saver.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
@ -43,7 +46,8 @@ class TalkViewLogic extends BaseGetXController {
|
||||
Timer? _syncTimer; // 音视频播放刷新率定时器
|
||||
Timer? _audioTimer; // 音视频播放刷新率定时器
|
||||
int _startTime = 0; // 开始播放时间戳,用于判断帧数据中的时间戳位置
|
||||
int bufferSize = 50; // 缓冲区大小(以帧为单位)
|
||||
int bufferSize = 40; // 缓冲区大小(以帧为单位)
|
||||
int audioBufferSize = 500; // 缓冲区大小(以帧为单位)
|
||||
|
||||
int frameIntervalMs = 45; // 初始帧间隔设置为45毫秒(约22FPS)
|
||||
int audioFrameIntervalMs = 20; // 初始帧间隔设置为45毫秒(约22FPS)
|
||||
@ -85,18 +89,13 @@ class TalkViewLogic extends BaseGetXController {
|
||||
void _startListenTalkData() {
|
||||
state.talkDataRepository.talkDataStream.listen((TalkData talkData) async {
|
||||
final contentType = talkData.contentType;
|
||||
int currentTimestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
// 判断数据类型,进行分发处理
|
||||
switch (contentType) {
|
||||
case TalkData_ContentTypeE.G711:
|
||||
if (state.audioBuffer.length >= bufferSize) {
|
||||
if (state.audioBuffer.length >= audioBufferSize) {
|
||||
state.audioBuffer.removeAt(0); // 丢弃最旧的数据
|
||||
// readAudioBufferSize.removeAt(0); // 丢弃最旧的数据
|
||||
}
|
||||
state.audioBuffer.add(talkData); // 添加新数据
|
||||
|
||||
// readAudioBufferSize.add(talkData.content);
|
||||
|
||||
break;
|
||||
case TalkData_ContentTypeE.Image:
|
||||
if (state.videoBuffer.length >= bufferSize) {
|
||||
@ -133,8 +132,9 @@ class TalkViewLogic extends BaseGetXController {
|
||||
void _playAudioData(TalkData talkData) async {
|
||||
if (state.isOpenVoice.value) {
|
||||
// final list = G711().convertList(talkData.content);
|
||||
final list = G711().convertList(talkData.content);
|
||||
// final list = G711().decodeAndDenoise(talkData.content, true,8000, 300, 50);
|
||||
// final list = G711().convertList(talkData.content);
|
||||
final list =
|
||||
G711().decodeAndDenoise(talkData.content, true, 8000, 300, 150);
|
||||
// // 将 PCM 数据转换为 PcmArrayInt16
|
||||
final PcmArrayInt16 fromList = PcmArrayInt16.fromList(list);
|
||||
FlutterPcmSound.feed(fromList);
|
||||
@ -445,6 +445,9 @@ class TalkViewLogic extends BaseGetXController {
|
||||
state.videoBuffer.clear(); // 清空视频缓冲区
|
||||
_syncTimer?.cancel(); // 取消定时器
|
||||
_syncTimer = null; // 释放定时器引用
|
||||
_audioTimer?.cancel();
|
||||
_audioTimer = null; // 释放定时器引用
|
||||
|
||||
stopProcessingAudio();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@ -84,9 +84,10 @@ class TalkViewState {
|
||||
late VoiceProcessor? voiceProcessor; // 音频处理器、录音
|
||||
final int frameLength = 320; //录音视频帧长度为640
|
||||
final int sampleRate = 8000; //录音频采样率为8000
|
||||
List<List<int>> recordingAudioAllFrames = <List<int>>[]; // 录制音频的所有帧
|
||||
List<int> recordingAudioAllFrames = <int>[]; // 录制音频的所有帧
|
||||
List<int> lockRecordingAudioAllFrames = <int>[]; // 录制音频的所有帧
|
||||
RxInt rotateAngle = 0.obs; // 旋转角度(以弧度为单位)
|
||||
RxBool isLongPressing = false.obs; // 旋转角度(以弧度为单位)
|
||||
RxBool hasAudioData = false.obs; // 是否有音频数据
|
||||
RxInt lastAudioTimestamp = 0.obs; // 最后接收到的音频数据的时间戳
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user