修复对讲接收视频bug

This commit is contained in:
魏少阳 2023-12-21 13:56:48 +08:00
parent 5f9e061ee3
commit 81488b599e
6 changed files with 36 additions and 17 deletions

View File

@ -28,7 +28,7 @@ class LockMonitoringLogic extends BaseGetXController {
StreamSubscription? _getUDPStatusRefreshUIEvent; StreamSubscription? _getUDPStatusRefreshUIEvent;
void _getUDPStatusRefreshUIAction() { void _getUDPStatusRefreshUIAction() {
// eventBus // eventBus
_getTVDataRefreshUIEvent = eventBus.on<GetUDPStatusRefreshUI>().listen((event) { _getUDPStatusRefreshUIEvent = eventBus.on<GetUDPStatusRefreshUI>().listen((event) {
state.udpStatus.value = event.udpStatus; state.udpStatus.value = event.udpStatus;
}); });
} }

View File

@ -8,6 +8,7 @@ import 'package:network_info_plus/network_info_plus.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../talk/udp/udp_manage.dart'; import '../../../../talk/udp/udp_manage.dart';
import '../../../../talk/udp/udp_senderManage.dart'; import '../../../../talk/udp/udp_senderManage.dart';
import '../../../../talk/udp/udp_talkClass.dart';
import '../../../../tools/showTFView.dart'; import '../../../../tools/showTFView.dart';
import '../../../../tools/storage.dart'; import '../../../../tools/storage.dart';
import '../../../../tools/toast.dart'; import '../../../../tools/toast.dart';
@ -158,6 +159,7 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
Widget bottomBottomBtnWidget() { Widget bottomBottomBtnWidget() {
return Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ return Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
//
Obx(() => bottomBtnItemWidget( Obx(() => bottomBtnItemWidget(
getAnswerBtnImg(), getAnswerBtnName(), Colors.white, () async { getAnswerBtnImg(), getAnswerBtnName(), Colors.white, () async {
var userMobileIP = await NetworkInfo().getWifiIP(); var userMobileIP = await NetworkInfo().getWifiIP();
@ -281,6 +283,10 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
title: "请输入开锁密码", title: "请输入开锁密码",
tipTitle: "", tipTitle: "",
controller: state.passwordTF, controller: state.passwordTF,
inputFormatters: [
LengthLimitingTextInputFormatter(6), //
FilteringTextInputFormatter.allow(RegExp("[0-9]")),
],
sureClick: () async { sureClick: () async {
// //
if (state.passwordTF.text.isEmpty) { if (state.passwordTF.text.isEmpty) {
@ -311,6 +317,13 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
); );
} }
@override
void dispose() {
super.dispose();
// UDPTalkClass().isBeCall = false;
}
// //
_initRecorder() { _initRecorder() {
recorder = FlutterSoundRecorder(); recorder = FlutterSoundRecorder();

View File

@ -67,7 +67,8 @@ class CallTalk {
// 63 // 63
int getIframeIndex = int getIframeIndex =
bb[POS_iframe_index] + bb[POS_iframe_index + 1] * 256; bb[POS_iframe_index] + bb[POS_iframe_index + 1] * 256;
print('获取帧序号 getIframeIndex$getIframeIndex'); // print('获取帧序号 getIframeIndex$getIframeIndex');
// 65 // 65
// int alen = bb[POS_alen] & 0xff; // int alen = bb[POS_alen] & 0xff;
// var alenList = bb.sublist(POS_alen, POS_alen + 4); // var alenList = bb.sublist(POS_alen, POS_alen + 4);
@ -79,13 +80,13 @@ class CallTalk {
// 71 // 71
int getBagIndex = bb[POS_bag_index] & 0xff; int getBagIndex = bb[POS_bag_index] & 0xff;
print('当前包号 getBagIndex$getBagIndex'); // print('当前包号 getBagIndex$getBagIndex');
// 69 // 69
int getBagNum = bb[POS_bag_num] & 0xff; int getBagNum = bb[POS_bag_num] & 0xff;
print('总包数 getBagNum$getBagNum'); // print('总包数 getBagNum$getBagNum');
// 73 // 73
int blen = bb[POS_blen] + bb[POS_blen + 1] * 256; int blen = bb[POS_blen] + bb[POS_blen + 1] * 256;
print('数据长度 blen$blen'); // print('数据长度 blen$blen');
// IframeInfo // IframeInfo
if (getIframeIndex != iframe!.iframeIndex) { if (getIframeIndex != iframe!.iframeIndex) {
@ -104,13 +105,11 @@ class CallTalk {
var getList = bb.sublist(77, bb.length); var getList = bb.sublist(77, bb.length);
growableList.addAll(getList); growableList.addAll(getList);
} }
print( // print('iframe.bagNum: ${iframe!.bagNum} iframe.bagReceive: ${iframe!.bagReceive}');
'iframe.bagNum: ${iframe!.bagNum} iframe.bagReceive: ${iframe!.bagReceive}');
// //
if (iframe!.bagNum == iframe!.bagReceive) { if (iframe!.bagNum == iframe!.bagReceive) {
print( // print('播放第${iframe!.iframeIndex}帧 一帧图片的hexStringData: ${Uint8List.fromList(growableList)}');
'播放第${iframe!.iframeIndex}帧 一帧图片的hexStringData: ${Uint8List.fromList(growableList)}');
// //
if (iframe!.iframeIndex == 0) { if (iframe!.iframeIndex == 0) {

View File

@ -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) {
@ -52,7 +52,7 @@ class CommandUDPReciverManager {
var lockId = data.sublist(9, 29); var lockId = data.sublist(9, 29);
var lockIdStr = utf8String(lockId); var lockIdStr = utf8String(lockId);
UDPManage().lockId = lockIdStr; UDPManage().lockId = lockIdStr;
UDPTalkClass().status = 0;
UDPTalkClass().beCallW(data: data); UDPTalkClass().beCallW(data: data);
} }
break; break;
@ -112,6 +112,7 @@ class CommandUDPReciverManager {
print("结束对讲反馈"); print("结束对讲反馈");
} }
UDPTalkClass().status = 0; UDPTalkClass().status = 0;
UDPTalkClass().isBeCall = false;
Get.back(); Get.back();
UDPTalkClass().stopLocalAudio(); UDPTalkClass().stopLocalAudio();
eventBus.fire(GetUDPStatusRefreshUI(UDPTalkClass().status)); eventBus.fire(GetUDPStatusRefreshUI(UDPTalkClass().status));

View File

@ -23,7 +23,9 @@ class UDPTalkClass {
UDPTalkClass._init(); UDPTalkClass._init();
var status = 0; //0 1 2 3 4 5 6 8 // var status = 0; //0 1 2 3 4 5 6 8
int status = 0;
var remoteEquid; // var remoteEquid; //
late Timer timer; late Timer timer;
// 退 // 退
@ -31,7 +33,7 @@ class UDPTalkClass {
final audioPlayer = AudioPlayer(); final audioPlayer = AudioPlayer();
beCallW({List<int>? data, String? ip, int? port}) async { beCallW({List<int>? data, String? ip, int? port}) async {
// print("beCall"); print("beCall status:$status");
// if (await isCallMe(data)) { // if (await isCallMe(data)) {
// return; // return;
// } // }
@ -60,8 +62,8 @@ class UDPTalkClass {
// fullscreenDialog: true // fullscreenDialog: true
// )); // ));
if (UDPTalkClass().isBeCall == false) { if (isBeCall == false) {
UDPTalkClass().isBeCall = true; isBeCall = true;
// //
timer = Timer.periodic(1.seconds, (timer) { timer = Timer.periodic(1.seconds, (timer) {
data[7] = 1; data[7] = 1;
@ -70,10 +72,10 @@ class UDPTalkClass {
}); });
// _getFirstFrameGoPushAction(); // _getFirstFrameGoPushAction();
Future.delayed(const Duration(seconds: 1), () { // Future.delayed(const Duration(seconds: 1), () {
// //
Get.toNamed(Routers.lockMonitoringPage, arguments: {"lockId": "111"}); Get.toNamed(Routers.lockMonitoringPage, arguments: {"lockId": "111"});
}); // });
} }
playLocalAudio(); playLocalAudio();

View File

@ -1,5 +1,6 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -9,6 +10,7 @@ class ShowTFView extends StatelessWidget {
String? title; String? title;
String? tipTitle; String? tipTitle;
TextEditingController? controller; TextEditingController? controller;
List<TextInputFormatter>? inputFormatters;
Function()? sureClick; Function()? sureClick;
Function()? cancelClick; Function()? cancelClick;
@ -17,6 +19,7 @@ class ShowTFView extends StatelessWidget {
this.title, this.title,
this.tipTitle, this.tipTitle,
this.controller, this.controller,
this.inputFormatters,
this.sureClick, this.sureClick,
this.cancelClick}) this.cancelClick})
: super(key: key); : super(key: key);
@ -44,6 +47,7 @@ class ShowTFView extends StatelessWidget {
maxLines: 1, maxLines: 1,
controller: controller, controller: controller,
autofocus: false, autofocus: false,
inputFormatters: inputFormatters,
decoration: InputDecoration( decoration: InputDecoration(
contentPadding: contentPadding:
const EdgeInsets.only(left: 5, top: -8, bottom: 6), const EdgeInsets.only(left: 5, top: -8, bottom: 6),