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

View File

@ -19,7 +19,6 @@ class CallTalk {
int status = 0; //
IframeInfo? iframe; //
var growableList;
bool getFirstFrame = false; //
List<int> allDataBytes = <int>[]; //
@ -71,7 +70,7 @@ class CallTalk {
// 63
int getIframeIndex =
bb[POS_iframe_index] + bb[POS_iframe_index + 1] * 256;
print('获取帧序号 getIframeIndex$getIframeIndex');
// print('获取帧序号 getIframeIndex$getIframeIndex');
// 65
// int alen = bb[POS_alen] & 0xff;
@ -84,10 +83,10 @@ class CallTalk {
// 71
int getBagIndex = bb[POS_bag_index] & 0xff;
print('当前包号 getBagIndex$getBagIndex');
// print('当前包号 getBagIndex$getBagIndex');
// 69
int getBagNum = bb[POS_bag_num] & 0xff;
print('总包数 getBagNum$getBagNum');
// print('总包数 getBagNum$getBagNum');
// 73
int blen = bb[POS_blen] + bb[POS_blen + 1] * 256;
// print('数据长度 blen$blen');
@ -98,8 +97,8 @@ class CallTalk {
iframe!.iframeIndex = getIframeIndex;
iframe!.bagNum = getBagNum;
// iframe!.cur_len = alen;
// iframe!.bb = Uint8List(alen);
growableList = iframe!.bb!.toList(growable: true);
iframe!.bb = [];
// growableList = iframe!.bb!.toList(growable: true);
}
iframe!.bagReceive++;
@ -107,22 +106,14 @@ class CallTalk {
//
if (getIframeIndex == iframe!.iframeIndex) {
var getList = bb.sublist(77, bb.length);
growableList.addAll(getList);
iframe!.bb!.addAll(getList);
}
// print('iframe.bagNum: ${iframe!.bagNum} iframe.bagReceive: ${iframe!.bagReceive}');
//
if (iframe!.bagNum == iframe!.bagReceive) {
// print('播放第${iframe!.iframeIndex}帧 一帧图片的hexStringData: ${Uint8List.fromList(growableList)}');
//
// if (iframe!.iframeIndex == 0) {
// print('得到第一帧了么');
// getFirstFrame = true;
// eventBus.fire(GetFirstFrameGoPush(getFirstFrame));
// }
eventBus.fire(GetTVDataRefreshUI(growableList));
eventBus.fire(GetTVDataRefreshUI(iframe!.bb!));
}
}
}
@ -165,6 +156,6 @@ class CallTalk {
iframe!.iframeIndex = 0;
iframe!.bagNum = 0;
iframe!.bagReceive = 0;
growableList = [];
iframe!.bb = [];
}
}

View File

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

View File

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