1,解决对讲图片数据有问题时闪现白色错误图片

2,新增监控结束后 停止发送监视请求的计时器
This commit is contained in:
Daisy 2024-01-08 17:56:12 +08:00
parent 3cf7449b0e
commit e8aabb052a
5 changed files with 48 additions and 37 deletions

View File

@ -433,5 +433,9 @@ class RealTimePictureLogic extends BaseGetXController {
state.oneMinuteTimeTimer.cancel(); state.oneMinuteTimeTimer.cancel();
} }
stopProcessing(); stopProcessing();
state.listData.value = Uint8List(0);
if (state.realTimePicTimer != null) {
state.realTimePicTimer.cancel();
}
} }
} }

View File

@ -5,7 +5,6 @@ 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';
import 'package:star_lock/main/lockDetail/lockDetail/realTimePicture/realTimePicture_logic.dart'; import 'package:star_lock/main/lockDetail/lockDetail/realTimePicture/realTimePicture_logic.dart';
import 'package:star_lock/talk/call/callTalk.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../tools/showTFView.dart'; import '../../../../tools/showTFView.dart';
@ -70,20 +69,33 @@ class _RealTimePicturePageState extends State<RealTimePicturePage>
child: Stack( child: Stack(
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
Obx(() => state.listData.value.isEmpty Obx(
? Image.asset( () =>
'images/main/monitorBg.png', state.listData.value.isEmpty || state.listData.value.length == 0
width: ScreenUtil().screenWidth, ? Image.asset(
height: ScreenUtil().screenHeight, 'images/main/monitorBg.png',
fit: BoxFit.cover, width: ScreenUtil().screenWidth,
) height: ScreenUtil().screenHeight,
: Image.memory( fit: BoxFit.cover,
state.listData.value, )
gaplessPlayback: true, : Builder(
width: 1.sw, builder: (BuildContext context) {
height: 1.sh, try {
fit: BoxFit.cover, return Image.memory(
)), state.listData.value,
gaplessPlayback: true,
width: 1.sw,
height: 1.sh,
fit: BoxFit.cover,
);
} catch (e, stackTrace) {
print('Error loading image: $e');
print('Stack trace: $stackTrace');
return Container();
}
},
),
),
Obx(() => state.listData.value.isEmpty Obx(() => state.listData.value.isEmpty
? Positioned( ? Positioned(
bottom: 300.h, bottom: 300.h,
@ -339,14 +351,12 @@ class _RealTimePicturePageState extends State<RealTimePicturePage>
void _handleFailure() { void _handleFailure() {
// //
print('Failed to get response within 30 seconds.');
state.animationController.stop(); state.animationController.stop();
} }
@override @override
void dispose() { void dispose() {
state.animationController.dispose(); state.animationController.dispose();
super.dispose(); super.dispose();
} }
} }

View File

@ -19,7 +19,6 @@ class CallTalk {
int status = 0; // int status = 0; //
IframeInfo? iframe; // IframeInfo? iframe; //
var growableList;
bool getFirstFrame = false; // bool getFirstFrame = false; //
List<int> allDataBytes = <int>[]; // List<int> allDataBytes = <int>[]; //
@ -71,7 +70,7 @@ 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;
@ -84,10 +83,10 @@ 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');
@ -98,8 +97,8 @@ class CallTalk {
iframe!.iframeIndex = getIframeIndex; iframe!.iframeIndex = getIframeIndex;
iframe!.bagNum = getBagNum; iframe!.bagNum = getBagNum;
// iframe!.cur_len = alen; // iframe!.cur_len = alen;
// iframe!.bb = Uint8List(alen); iframe!.bb = [];
growableList = iframe!.bb!.toList(growable: true); // growableList = iframe!.bb!.toList(growable: true);
} }
iframe!.bagReceive++; iframe!.bagReceive++;
@ -107,22 +106,14 @@ class CallTalk {
// //
if (getIframeIndex == iframe!.iframeIndex) { if (getIframeIndex == iframe!.iframeIndex) {
var getList = bb.sublist(77, bb.length); var getList = bb.sublist(77, bb.length);
growableList.addAll(getList); iframe!.bb!.addAll(getList);
} }
// print('iframe.bagNum: ${iframe!.bagNum} iframe.bagReceive: ${iframe!.bagReceive}'); // print('iframe.bagNum: ${iframe!.bagNum} iframe.bagReceive: ${iframe!.bagReceive}');
// //
if (iframe!.bagNum == iframe!.bagReceive) { if (iframe!.bagNum == iframe!.bagReceive) {
// print('播放第${iframe!.iframeIndex}帧 一帧图片的hexStringData: ${Uint8List.fromList(growableList)}'); // print('播放第${iframe!.iframeIndex}帧 一帧图片的hexStringData: ${Uint8List.fromList(growableList)}');
eventBus.fire(GetTVDataRefreshUI(iframe!.bb!));
//
// if (iframe!.iframeIndex == 0) {
// print('得到第一帧了么');
// getFirstFrame = true;
// eventBus.fire(GetFirstFrameGoPush(getFirstFrame));
// }
eventBus.fire(GetTVDataRefreshUI(growableList));
} }
} }
} }
@ -165,6 +156,6 @@ class CallTalk {
iframe!.iframeIndex = 0; iframe!.iframeIndex = 0;
iframe!.bagNum = 0; iframe!.bagNum = 0;
iframe!.bagReceive = 0; iframe!.bagReceive = 0;
growableList = []; iframe!.bb = [];
} }
} }

View File

@ -4,11 +4,11 @@ class IframeInfo {
int iframeIndex = -1; int iframeIndex = -1;
int iframeTime = 0; int iframeTime = 0;
int bagNum = 0; int bagNum = 0;
int bagReceive = 0; int bagReceive = 1;
bool isFull = false; bool isFull = false;
int cur_len = 0; int cur_len = 0;
int bb_len = 0; int bb_len = 0;
Uint8List? bb; List<int>? bb;
int codecMode = 0; int codecMode = 0;
IframeInfo() { IframeInfo() {
@ -17,6 +17,6 @@ class IframeInfo {
bagReceive = 0; bagReceive = 0;
isFull = false; isFull = false;
cur_len = 0; cur_len = 0;
bb = Uint8List(0); bb = [];
} }
} }

View File

@ -196,6 +196,12 @@ class CommandUDPReciverManager {
// //
print("结束监视反馈"); print("结束监视反馈");
} }
UDPTalkClass().status = 0;
UDPTalkClass().isBeCall = false;
UDPTalkClass().stopLocalAudio();
CallTalk().stopPcmSound();
eventBus.fire(GetUDPStatusRefreshUI(UDPTalkClass().status));
Get.back();
} }
break; break;
default: default: