Merge branch 'talk_flutter' of gitee.com:starlock-cn/app-starlock into talk_flutter
# Conflicts: # star_lock/lib/talk/call/callTalk.dart
This commit is contained in:
commit
2aa56b65de
1
star_lock/.flutter-plugins-dependencies 2
Normal file
1
star_lock/.flutter-plugins-dependencies 2
Normal file
File diff suppressed because one or more lines are too long
@ -633,8 +633,7 @@ class LockDetailLogic extends BaseGetXController{
|
|||||||
print("有蓝牙权限开始扫描");
|
print("有蓝牙权限开始扫描");
|
||||||
startScanAction();
|
startScanAction();
|
||||||
}else{
|
}else{
|
||||||
getMicrophonePermission()
|
getMicrophonePermission().then((value) {
|
||||||
.then((value) {
|
|
||||||
if (value) {
|
if (value) {
|
||||||
// 有权限
|
// 有权限
|
||||||
print("有蓝牙权限开始扫描");
|
print("有蓝牙权限开始扫描");
|
||||||
|
|||||||
@ -65,6 +65,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
var saveSignKeyList = changeIntListToStringList(signKeyData);
|
var saveSignKeyList = changeIntListToStringList(signKeyData);
|
||||||
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
|
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
|
||||||
|
|
||||||
|
Storage.setStringList(saveBlueToken, [0, 0, 0, 0]);
|
||||||
// logic.startScanAction();
|
// logic.startScanAction();
|
||||||
|
|
||||||
listeningAnimations();
|
listeningAnimations();
|
||||||
|
|||||||
@ -223,6 +223,8 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
|
|||||||
}),
|
}),
|
||||||
bottomBtnItemWidget("images/main/icon_lockDetail_monitoringUnlock.png",
|
bottomBtnItemWidget("images/main/icon_lockDetail_monitoringUnlock.png",
|
||||||
"开锁", AppColors.mainColor, () {
|
"开锁", AppColors.mainColor, () {
|
||||||
|
|
||||||
|
// _playRecording();
|
||||||
showDeletPasswordAlertDialog(context);
|
showDeletPasswordAlertDialog(context);
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
@ -231,34 +233,22 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
|
|||||||
String getAnswerBtnImg() {
|
String getAnswerBtnImg() {
|
||||||
switch (state.udpStatus.value) {
|
switch (state.udpStatus.value) {
|
||||||
case 8:
|
case 8:
|
||||||
{
|
|
||||||
return "images/main/icon_lockDetail_monitoringUnTalkback.png";
|
return "images/main/icon_lockDetail_monitoringUnTalkback.png";
|
||||||
}
|
|
||||||
case 9:
|
case 9:
|
||||||
{
|
|
||||||
return "images/main/icon_lockDetail_monitoringTalkback.png";
|
return "images/main/icon_lockDetail_monitoringTalkback.png";
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
|
||||||
return "images/main/icon_lockDetail_monitoringAnswerCalls.png";
|
return "images/main/icon_lockDetail_monitoringAnswerCalls.png";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getAnswerBtnName() {
|
String getAnswerBtnName() {
|
||||||
switch (state.udpStatus.value) {
|
switch (state.udpStatus.value) {
|
||||||
case 8:
|
case 8:
|
||||||
{
|
|
||||||
return "长按说话";
|
return "长按说话";
|
||||||
}
|
|
||||||
case 9:
|
case 9:
|
||||||
{
|
|
||||||
return "松开发送";
|
return "松开发送";
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
|
||||||
return "接听";
|
return "接听";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,6 +346,9 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
|
|||||||
await recorder.startRecorder(
|
await recorder.startRecorder(
|
||||||
toFile: filePath,
|
toFile: filePath,
|
||||||
codec: Codec.pcm16WAV,
|
codec: Codec.pcm16WAV,
|
||||||
|
bitRate: 8000,
|
||||||
|
numChannels: 1,
|
||||||
|
sampleRate: 8000,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,9 +356,6 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
|
|||||||
_stopRecording() async {
|
_stopRecording() async {
|
||||||
await recorder.stopRecorder();
|
await recorder.stopRecorder();
|
||||||
|
|
||||||
var userMobileIP = await NetworkInfo().getWifiIP();
|
|
||||||
var userMobile = await Storage.getMobile();
|
|
||||||
|
|
||||||
// final file = File(filePath);
|
// final file = File(filePath);
|
||||||
File file = File(filePath); // 使用 create 方法创建文件
|
File file = File(filePath); // 使用 create 方法创建文件
|
||||||
|
|
||||||
@ -374,23 +364,13 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
|
|||||||
final List<int> bytes = await file.readAsBytes();
|
final List<int> bytes = await file.readAsBytes();
|
||||||
print('Recorded audio bytes.length:${bytes.length} bytes: $bytes');
|
print('Recorded audio bytes.length:${bytes.length} bytes: $bytes');
|
||||||
|
|
||||||
// 刚进来是接听状态,然后改为长按对讲
|
_sendRecordData(bytes);
|
||||||
UDPSenderManage.sendMainProtocol(
|
|
||||||
command: 150,
|
|
||||||
commandTypeIsCalling: 1,
|
|
||||||
subCommand: 8,
|
|
||||||
lockID: UDPManage().lockId,
|
|
||||||
lockIP: UDPManage().host,
|
|
||||||
userMobile: userMobile,
|
|
||||||
userMobileIP: userMobileIP,
|
|
||||||
endData: bytes
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getFilePath() async {
|
Future<String> getFilePath() async {
|
||||||
final directory = await getApplicationDocumentsDirectory();
|
final directory = await getApplicationDocumentsDirectory();
|
||||||
final filePath = '${directory.path}/recording.mp3';
|
final filePath = '${directory.path}/recording.wav';
|
||||||
|
|
||||||
// 创建文件
|
// 创建文件
|
||||||
File file = File(filePath);
|
File file = File(filePath);
|
||||||
@ -425,4 +405,33 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
|
|||||||
// _stopPlaying() async {
|
// _stopPlaying() async {
|
||||||
// await player.stopPlayer();
|
// await player.stopPlayer();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
_sendRecordData(List<int> bytes) async {
|
||||||
|
// 刚进来是接听状态,然后改为长按对讲
|
||||||
|
var userMobileIP = await NetworkInfo().getWifiIP();
|
||||||
|
var userMobile = await Storage.getMobile();
|
||||||
|
|
||||||
|
// 57
|
||||||
|
List<int> topBytes = [
|
||||||
|
1, 1, 1, 1, // 时间戳
|
||||||
|
1, 0, // 音频
|
||||||
|
1, 0, // 帧序号
|
||||||
|
64, 0, 0, 0, // 帧长度
|
||||||
|
1, 0, // 总包数
|
||||||
|
1, 0, // 当前包号
|
||||||
|
64, 1, // 数据长度
|
||||||
|
176, 4, // 保留
|
||||||
|
];
|
||||||
|
UDPSenderManage.sendMainProtocol(
|
||||||
|
command: 150,
|
||||||
|
commandTypeIsCalling: 1,
|
||||||
|
subCommand: 8,
|
||||||
|
lockID: UDPManage().lockId,
|
||||||
|
lockIP: UDPManage().host,
|
||||||
|
userMobile: userMobile,
|
||||||
|
userMobileIP: userMobileIP,
|
||||||
|
endData: bytes
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_sound/flutter_sound.dart';
|
import 'package:flutter_sound/flutter_sound.dart';
|
||||||
import 'package:star_lock/talk/call/g711.dart';
|
import 'package:star_lock/talk/call/g711.dart';
|
||||||
import 'package:star_lock/talk/call/iFrameInfo.dart';
|
import 'package:star_lock/talk/call/iFrameInfo.dart';
|
||||||
|
|
||||||
import '../../tools/eventBusEventManage.dart';
|
import '../../tools/eventBusEventManage.dart';
|
||||||
|
|
||||||
class CallTalk {
|
class CallTalk {
|
||||||
@ -22,6 +21,7 @@ class CallTalk {
|
|||||||
var growableList;
|
var growableList;
|
||||||
bool getFirstFrame = false; //是否得到了第一帧
|
bool getFirstFrame = false; //是否得到了第一帧
|
||||||
final FlutterSoundPlayer _audioPlayer = FlutterSoundPlayer();
|
final FlutterSoundPlayer _audioPlayer = FlutterSoundPlayer();
|
||||||
|
List<int>? allPcmData = [];
|
||||||
|
|
||||||
CallTalk._init() {
|
CallTalk._init() {
|
||||||
iframe = IframeInfo();
|
iframe = IframeInfo();
|
||||||
@ -39,6 +39,15 @@ class CallTalk {
|
|||||||
// 音频数据
|
// 音频数据
|
||||||
if (bb[61] == 1) {
|
if (bb[61] == 1) {
|
||||||
Uint8List g711Data = bb.sublist(77, bb.length);
|
Uint8List g711Data = bb.sublist(77, bb.length);
|
||||||
|
|
||||||
|
// // 解码为 PCM 数据
|
||||||
|
// Uint8List pcmData = G711Decoder().g711Decode(g711Data, G711Type.uLaw);
|
||||||
|
// // 现在你可以使用 pcmData 进行播放或其他处理
|
||||||
|
// print('得到的pcmData:$pcmData');
|
||||||
|
// allPcmData!.addAll(pcmData);
|
||||||
|
// await Future.delayed(const Duration(seconds: 3));
|
||||||
|
// _playRawData(allPcmData!);
|
||||||
|
|
||||||
print('dinglingling bb.length:${g711Data.length} 音频数据来:$g711Data ');
|
print('dinglingling bb.length:${g711Data.length} 音频数据来:$g711Data ');
|
||||||
|
|
||||||
List<int> pcmBytes = Uint8List.fromList([]);
|
List<int> pcmBytes = Uint8List.fromList([]);
|
||||||
@ -49,11 +58,14 @@ class CallTalk {
|
|||||||
print('Error decoding G.711 to PCM: $e');
|
print('Error decoding G.711 to PCM: $e');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allPcmData!.addAll(pcmBytes!);
|
||||||
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
|
||||||
print('PCM decoded data: $pcmBytes');
|
print('PCM decoded data: $pcmBytes');
|
||||||
|
|
||||||
if (pcmBytes != null) {
|
if (pcmBytes != null) {
|
||||||
_initializeAudioPlayer();
|
_initializeAudioPlayer();
|
||||||
_playRawData(pcmBytes);
|
_playRawData(Uint8List.fromList(allPcmData!));
|
||||||
} else {
|
} else {
|
||||||
print('Error decoding G.711 to PCM');
|
print('Error decoding G.711 to PCM');
|
||||||
}
|
}
|
||||||
@ -153,4 +165,8 @@ class CallTalk {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> stopLocalAudio() async {
|
||||||
|
await _audioPlayer.stopPlayer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,6 +62,8 @@ class UDPMainProtocolCommand extends UDPSenderProtocol {
|
|||||||
data.add(int.parse(element));
|
data.add(int.parse(element));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
data.addAll(endData!);
|
||||||
|
|
||||||
// print("datadatadata:$data");
|
// print("datadatadata:$data");
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class CommandUDPReciverManager {
|
|||||||
if (dataSize < 4) {
|
if (dataSize < 4) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// print("appReceiveUDPData:$data");
|
print("appReceiveUDPData:$data");
|
||||||
|
|
||||||
Uint8List data1 = Uint8List.fromList(data);
|
Uint8List data1 = Uint8List.fromList(data);
|
||||||
if (data1.length == 1) {
|
if (data1.length == 1) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user