优化对讲发送问题

This commit is contained in:
魏少阳 2023-12-29 18:11:36 +08:00
parent b8a2c78836
commit fda85f95a5
6 changed files with 123 additions and 61 deletions

File diff suppressed because one or more lines are too long

View File

@ -47,6 +47,9 @@ PODS:
- Flutter - Flutter
- flutter_sound_core (= 9.2.13) - flutter_sound_core (= 9.2.13)
- flutter_sound_core (9.2.13) - flutter_sound_core (9.2.13)
- flutter_voice_processor (1.1.0):
- Flutter
- ios-voice-processor (~> 1.1.0)
- fluttertoast (0.0.2): - fluttertoast (0.0.2):
- Flutter - Flutter
- Toast - Toast
@ -58,15 +61,16 @@ PODS:
- google_maps_flutter_ios (0.0.1): - google_maps_flutter_ios (0.0.1):
- Flutter - Flutter
- GoogleMaps (< 9.0) - GoogleMaps (< 9.0)
- GoogleMaps (7.4.0): - GoogleMaps (6.2.1):
- GoogleMaps/Maps (= 7.4.0) - GoogleMaps/Maps (= 6.2.1)
- GoogleMaps/Base (7.4.0) - GoogleMaps/Base (6.2.1)
- GoogleMaps/Maps (7.4.0): - GoogleMaps/Maps (6.2.1):
- GoogleMaps/Base - GoogleMaps/Base
- image_gallery_saver (2.0.2): - image_gallery_saver (2.0.2):
- Flutter - Flutter
- image_picker_ios (0.0.1): - image_picker_ios (0.0.1):
- Flutter - Flutter
- ios-voice-processor (1.1.0)
- just_audio (0.0.1): - just_audio (0.0.1):
- Flutter - Flutter
- network_info_plus (0.0.1): - network_info_plus (0.0.1):
@ -113,6 +117,7 @@ DEPENDENCIES:
- flutter_native_contact_picker (from `.symlinks/plugins/flutter_native_contact_picker/ios`) - flutter_native_contact_picker (from `.symlinks/plugins/flutter_native_contact_picker/ios`)
- flutter_pcm_sound (from `.symlinks/plugins/flutter_pcm_sound/ios`) - flutter_pcm_sound (from `.symlinks/plugins/flutter_pcm_sound/ios`)
- flutter_sound (from `.symlinks/plugins/flutter_sound/ios`) - flutter_sound (from `.symlinks/plugins/flutter_sound/ios`)
- flutter_voice_processor (from `.symlinks/plugins/flutter_voice_processor/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- g711_flutter (from `.symlinks/plugins/g711_flutter/ios`) - g711_flutter (from `.symlinks/plugins/g711_flutter/ios`)
- google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`) - google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`)
@ -145,6 +150,7 @@ SPEC REPOS:
- flutter_sound_core - flutter_sound_core
- FMDB - FMDB
- GoogleMaps - GoogleMaps
- ios-voice-processor
- Protobuf - Protobuf
- SwiftProtobuf - SwiftProtobuf
- Toast - Toast
@ -176,6 +182,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_pcm_sound/ios" :path: ".symlinks/plugins/flutter_pcm_sound/ios"
flutter_sound: flutter_sound:
:path: ".symlinks/plugins/flutter_sound/ios" :path: ".symlinks/plugins/flutter_sound/ios"
flutter_voice_processor:
:path: ".symlinks/plugins/flutter_voice_processor/ios"
fluttertoast: fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios" :path: ".symlinks/plugins/fluttertoast/ios"
g711_flutter: g711_flutter:
@ -233,13 +241,15 @@ SPEC CHECKSUMS:
flutter_pcm_sound: de0572ca4f99091cc2abfcc31601b8a4ddd33c0e flutter_pcm_sound: de0572ca4f99091cc2abfcc31601b8a4ddd33c0e
flutter_sound: c60effa2a350fb977885f0db2fbc4c1ad5160900 flutter_sound: c60effa2a350fb977885f0db2fbc4c1ad5160900
flutter_sound_core: 26c10e5832e76aaacfae252d8925232281c486ae flutter_sound_core: 26c10e5832e76aaacfae252d8925232281c486ae
flutter_voice_processor: 53afbf59ad3feb82f4a379fea9ed8dc98495210f
fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265 fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
g711_flutter: 8f2769052d2cf3549f83d11e1c42d81d94441123 g711_flutter: 8f2769052d2cf3549f83d11e1c42d81d94441123
google_maps_flutter_ios: 590249c67f34f422122c232f2a626192adbc78ee google_maps_flutter_ios: 590249c67f34f422122c232f2a626192adbc78ee
GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac GoogleMaps: 20d7b12be49a14287f797e88e0e31bc4156aaeb4
image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5 image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
ios-voice-processor: 8e32d7f980a06d392d128ef1cd19cf6ddcaca3c1
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
network_info_plus: 6d0c3eb8367b8164fa3fb0c19875e3f59d49697f network_info_plus: 6d0c3eb8367b8164fa3fb0c19875e3f59d49697f
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
@ -255,6 +265,6 @@ SPEC CHECKSUMS:
video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126 video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126
webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a
PODFILE CHECKSUM: 85f69c27139c5112fdd69e85b95c1cc6de403d3e PODFILE CHECKSUM: 42aa7ffc6134b996f93caa6a9b6a2b5b580ff28a
COCOAPODS: 1.14.3 COCOAPODS: 1.14.3

View File

@ -38,14 +38,80 @@ class LockMonitoringLogic extends BaseGetXController {
}); });
} }
/// /// UDP发送的状
StreamSubscription? _getUDPStatusRefreshUIEvent; StreamSubscription? _getUDPStatusRefreshUIEvent;
void _getUDPStatusRefreshUIAction() { void _getUDPStatusRefreshUIAction() {
_getUDPStatusRefreshUIEvent = eventBus.on<GetUDPStatusRefreshUI>().listen((event) { _getUDPStatusRefreshUIEvent = eventBus.on<GetUDPStatusRefreshUI>().listen((event) {
state.udpStatus.value = event.udpStatus; state.udpStatus.value = event.udpStatus;
if(state.udpStatus.value == 8){
// 60
state.oneMinuteTimeTimer = Timer.periodic(const Duration(seconds:1), (Timer t) async {
state.oneMinuteTime.value++;
Get.log('state.oneMinuteTime.value:${state.oneMinuteTime.value}');
if(state.oneMinuteTime.value >= 60){
// 60
state.oneMinuteTimeTimer.cancel();
state.oneMinuteTime.value = 0;
//
UDPSenderManage.sendMainProtocol(
command: 150,
commandTypeIsCalling: 1,
subCommand: 30,
lockID: UDPManage().lockId,
lockIP: UDPManage().host,
userMobile: await state.userMobile,
userMobileIP: await state.userMobileIP,
endData: []);
//
Get.back();
}
});
}
}); });
} }
///
udpAnswerAction() async {
UDPSenderManage.sendMainProtocol(
command: 150,
commandTypeIsCalling: 1,
subCommand: 6,
lockID: UDPManage().lockId,
lockIP: UDPManage().host,
userMobile: await state.userMobile,
userMobileIP: await state.userMobileIP,
endData: []
);
}
///
udpHangUpAction() async {
UDPSenderManage.sendMainProtocol(
command: 150,
commandTypeIsCalling: 1,
subCommand: 30,
lockID: UDPManage().lockId,
lockIP: UDPManage().host,
userMobile: await state.userMobile,
userMobileIP: await state.userMobileIP,
endData: []);
}
///
udpOpenDoorAction() async {
UDPSenderManage.sendMainProtocol(
command: 150,
commandTypeIsCalling: 1,
subCommand: 10,
lockID: UDPManage().lockId,
lockIP: UDPManage().host,
userMobile: await state.userMobile,
userMobileIP: await state.userMobileIP,
endData: []);
Get.back();
}
Future<void> _readG711Data() async { Future<void> _readG711Data() async {
String filePath = 'assets/s10-g711.bin'; String filePath = 'assets/s10-g711.bin';
List<int> audioData = await G711().readAssetFile(filePath); List<int> audioData = await G711().readAssetFile(filePath);
@ -83,11 +149,11 @@ class LockMonitoringLogic extends BaseGetXController {
Future<void> startProcessing() async { Future<void> startProcessing() async {
frameListener(List<int> frame) async { frameListener(List<int> frame) async {
Get.log('Get data.length:${frame.length} Received data:$frame'); // Get.log('Get data.length:${frame.length} Received data:$frame');
for (int i = 0; i < frame.length; i++) { for (int i = 0; i < frame.length; i++) {
frame[i] = linearToULaw(frame[i]); frame[i] = linearToULaw(frame[i]);
} }
Get.log('change Get data.length:${frame.length} change Received data:$frame'); // Get.log('change Get data.length:${frame.length} change Received data:$frame');
await Future.delayed(const Duration(milliseconds: 50)); await Future.delayed(const Duration(milliseconds: 50));
sendRecordData({ sendRecordData({
"bytes": frame, "bytes": frame,
@ -330,7 +396,7 @@ class LockMonitoringLogic extends BaseGetXController {
print("锁详情界面销毁了"); print("锁详情界面销毁了");
_getTVDataRefreshUIEvent!.cancel(); _getTVDataRefreshUIEvent!.cancel();
_getUDPStatusRefreshUIEvent!.cancel(); _getUDPStatusRefreshUIEvent!.cancel();
state.oneMinuteTimeTimer.cancel();
stopProcessing(); stopProcessing();
} }
} }

View File

@ -41,25 +41,34 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
)), )),
Positioned( Positioned(
top: ScreenUtil().statusBarHeight + 30.h, top: ScreenUtil().statusBarHeight + 30.h,
child: Row(children: [ width: 1.sw,
SizedBox(width: 30.w), child: Obx(() {
GestureDetector( var sec = (state.oneMinuteTime.value % 60).toString().padLeft(2,'0');
onTap: () { var min = (state.oneMinuteTime.value ~/ 60).toString().padLeft(2,'0');
Get.back(); return Row(
}, mainAxisAlignment: MainAxisAlignment.center,
child: Container( children: [
decoration: BoxDecoration( Text("$min:$sec", style: TextStyle(fontSize: 26.sp, color: Colors.white)),
color: Colors.white, // SizedBox(width: 30.w),
borderRadius: BorderRadius.circular(25.h)), // GestureDetector(
padding: EdgeInsets.all(10.w), // onTap: () {
child: Image( // Get.back();
width: 40.w, // },
height: 40.w, // child: Container(
image: const AssetImage("images/icon_left_black.png"), // decoration: BoxDecoration(
), // color: Colors.white,
), // borderRadius: BorderRadius.circular(25.h)),
), // padding: EdgeInsets.all(10.w),
]), // child: Image(
// width: 40.w,
// height: 40.w,
// image: const AssetImage("images/icon_left_black.png"),
// ),
// ),
// ),
]
);
}),
), ),
Positioned( Positioned(
bottom: 10.w, bottom: 10.w,
@ -156,16 +165,7 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
// state.isSenderAudioData.value = false; // state.isSenderAudioData.value = false;
print("发送接听了"); print("发送接听了");
// //
UDPSenderManage.sendMainProtocol( logic.udpAnswerAction();
command: 150,
commandTypeIsCalling: 1,
subCommand: 6,
lockID: UDPManage().lockId,
lockIP: UDPManage().host,
userMobile: await state.userMobile,
userMobileIP: await state.userMobileIP,
endData: []
);
}); });
}, },
longPress: (){ longPress: (){
@ -191,15 +191,7 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
logic.stopProcessing(); logic.stopProcessing();
// //
UDPSenderManage.sendMainProtocol( logic.udpHangUpAction();
command: 150,
commandTypeIsCalling: 1,
subCommand: 30,
lockID: UDPManage().lockId,
lockIP: UDPManage().host,
userMobile: await state.userMobile,
userMobileIP: await state.userMobileIP,
endData: []);
}), }),
bottomBtnItemWidget("images/main/icon_lockDetail_monitoringUnlock.png", "开锁", AppColors.mainColor, () { bottomBtnItemWidget("images/main/icon_lockDetail_monitoringUnlock.png", "开锁", AppColors.mainColor, () {
showDeletPasswordAlertDialog(context); showDeletPasswordAlertDialog(context);
@ -280,16 +272,7 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
} }
// //
UDPSenderManage.sendMainProtocol( logic.udpOpenDoorAction();
command: 150,
commandTypeIsCalling: 1,
subCommand: 10,
lockID: UDPManage().lockId,
lockIP: UDPManage().host,
userMobile: await state.userMobile,
userMobileIP: await state.userMobileIP,
endData: []);
Get.back();
}, },
cancelClick: () { cancelClick: () {
Get.back(); Get.back();

View File

@ -24,8 +24,10 @@ class LockMonitoringState {
late final VoiceProcessor? voiceProcessor; late final VoiceProcessor? voiceProcessor;
// 60
late Timer oneMinuteTimeTimer; late Timer oneMinuteTimeTimer;// 60
var oneMinuteTime = 0.obs;//
// 10 // 10
late Timer answerTimer; late Timer answerTimer;
late Timer hangUpTimer; late Timer hangUpTimer;

View File

@ -10,6 +10,8 @@ import '../call/callTalk.dart';
import 'udp_talkClass.dart'; import 'udp_talkClass.dart';
class CommandUDPReciverManager { class CommandUDPReciverManager {
static void appDataReceive(List<int> data) async { static void appDataReceive(List<int> data) async {
/// ///
if (data.isEmpty) { if (data.isEmpty) {