711音频数据解析
This commit is contained in:
parent
4a131c88f5
commit
4f5e95ce00
@ -1,6 +1,8 @@
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:convert/convert.dart';
|
import 'package:convert/convert.dart';
|
||||||
import 'package:flutter_sound/flutter_sound.dart';
|
import 'package:flutter_sound/flutter_sound.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/appRouters.dart';
|
||||||
// import 'package:just_audio/just_audio.dart';
|
// import 'package:just_audio/just_audio.dart';
|
||||||
import 'package:star_lock/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart';
|
import 'package:star_lock/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart';
|
||||||
import 'package:star_lock/talk/call/g711Decoder.dart';
|
import 'package:star_lock/talk/call/g711Decoder.dart';
|
||||||
@ -19,7 +21,7 @@ class CallTalk {
|
|||||||
int status = 0; // 假设有这个成员变量
|
int status = 0; // 假设有这个成员变量
|
||||||
IframeInfo iframe = IframeInfo(); // 假设有这个成员变量
|
IframeInfo iframe = IframeInfo(); // 假设有这个成员变量
|
||||||
LockMonitoringPage callOut = const LockMonitoringPage();
|
LockMonitoringPage callOut = const LockMonitoringPage();
|
||||||
late FlutterSoundPlayer _player;
|
FlutterSoundPlayer _audioPlayer = FlutterSoundPlayer();
|
||||||
|
|
||||||
Future<void> getAVData(Uint8List bb, int len) async {
|
Future<void> getAVData(Uint8List bb, int len) async {
|
||||||
//视频数据
|
//视频数据
|
||||||
@ -34,13 +36,12 @@ class CallTalk {
|
|||||||
// 音频数据
|
// 音频数据
|
||||||
if (bb[61] == 1) {
|
if (bb[61] == 1) {
|
||||||
// 如果是音频数据且状态符合条件
|
// 如果是音频数据且状态符合条件
|
||||||
_player = FlutterSoundPlayer();
|
|
||||||
_initPlayer();
|
|
||||||
|
|
||||||
// 解码
|
_initializeAudioPlayer();
|
||||||
Uint8List g711Data = G711Decoder().decodeG711uLaw(bb);
|
|
||||||
|
|
||||||
await _playAudio(g711Data);
|
// 用你的711音频数据替换这里的Uint8List
|
||||||
|
Uint8List rawData = G711Decoder().decodeG711uLaw(bb);
|
||||||
|
_playRawData(rawData);
|
||||||
}
|
}
|
||||||
// 视频数据
|
// 视频数据
|
||||||
else {
|
else {
|
||||||
@ -74,6 +75,8 @@ class CallTalk {
|
|||||||
|
|
||||||
Uint8List data = iframe.bb!.sublist(0, iframe.cur_len);
|
Uint8List data = iframe.bb!.sublist(0, iframe.cur_len);
|
||||||
|
|
||||||
|
Get.toNamed(Routers.lockMonitoringPage,
|
||||||
|
arguments: {"lockId": widget.lockListInfoItemEntity.lockId});
|
||||||
// 打印拷贝后的目标数据
|
// 打印拷贝后的目标数据
|
||||||
print(iframe.bb);
|
print(iframe.bb);
|
||||||
}
|
}
|
||||||
@ -98,14 +101,18 @@ class CallTalk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _initPlayer() async {
|
Future<void> _initializeAudioPlayer() async {
|
||||||
await _player.openPlayer();
|
await _audioPlayer.openPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _playAudio(Uint8List audioData) async {
|
Future<void> _playRawData(Uint8List rawData) async {
|
||||||
await _player.startPlayer(
|
await _audioPlayer.startPlayer(
|
||||||
fromDataBuffer: audioData,
|
fromDataBuffer: rawData,
|
||||||
codec: Codec.pcm16WAV,
|
codec: Codec.pcm16,
|
||||||
|
whenFinished: () {
|
||||||
|
// 播放完成时的回调
|
||||||
|
print("Playback finished");
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user