fix:增加视频旋转角度,调整监控时获取锁peerId的逻辑
This commit is contained in:
parent
0af232e42c
commit
a546989a25
@ -743,43 +743,40 @@ class LockDetailLogic extends BaseGetXController {
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
}
|
||||
|
||||
/// 请求设备网络信息并设置
|
||||
void requestDeviceNetworkInfo() async {
|
||||
final DeviceNetwork deviceNetworkInfo =
|
||||
await ApiRepository.to.getDeviceNetwork(
|
||||
deviceType: 2,
|
||||
deviceMac: state.keyInfos.value.mac!,
|
||||
);
|
||||
if (deviceNetworkInfo.data?.wifiName == null ||
|
||||
deviceNetworkInfo.data?.wifiName == '') {
|
||||
return;
|
||||
} else {
|
||||
final peerId = deviceNetworkInfo?.data?.peerId;
|
||||
if (peerId == null || peerId.isEmpty || peerId == '') {
|
||||
throw Exception('设备peerId为空');
|
||||
}
|
||||
// 设置锁的peerID
|
||||
StartChartManage().lockNetworkInfo =
|
||||
deviceNetworkInfo.data ?? DeviceNetworkInfo();
|
||||
StartChartManage().lockPeerId = peerId;
|
||||
}
|
||||
}
|
||||
// /// 请求设备网络信息并设置
|
||||
// void requestDeviceNetworkInfo() async {
|
||||
// final DeviceNetwork deviceNetworkInfo =
|
||||
// await ApiRepository.to.getDeviceNetwork(
|
||||
// deviceType: 2,
|
||||
// deviceMac: state.keyInfos.value.mac!,
|
||||
// );
|
||||
// if (deviceNetworkInfo.data?.peerId == null ||
|
||||
// deviceNetworkInfo.data?.peerId == '') {
|
||||
// return;
|
||||
// }
|
||||
// final peerId = deviceNetworkInfo!.data!.peerId;
|
||||
// // 设置锁的peerID
|
||||
// StartChartManage().lockNetworkInfo =
|
||||
// deviceNetworkInfo.data ?? DeviceNetworkInfo();
|
||||
// StartChartManage().lockPeerId = peerId!;
|
||||
// }
|
||||
|
||||
/// 发送监控消息
|
||||
void sendMonitorMessage() {
|
||||
final catEyeConfig = state.keyInfos.value.lockSetting?.catEyeConfig ?? [];
|
||||
final network = state.keyInfos.value.network;
|
||||
if (catEyeConfig.isNotEmpty &&
|
||||
catEyeConfig.length > 0 &&
|
||||
catEyeConfig[0].catEyeMode != 0) {
|
||||
if ((StartChartManage().lockNetworkInfo.wifiName == null ||
|
||||
StartChartManage().lockNetworkInfo.wifiName == '') ) {
|
||||
if (network == null || network?.peerId == null || network?.peerId == '') {
|
||||
showToast('设备未配网'.tr);
|
||||
return;
|
||||
}
|
||||
// 重置丢包率监控
|
||||
PacketLossStatistics().reset();
|
||||
// 发送监控id
|
||||
StartChartManage().startCallRequestMessageTimer(
|
||||
ToPeerId: StartChartManage().lockNetworkInfo.peerId ?? '');
|
||||
StartChartManage()
|
||||
.startCallRequestMessageTimer(ToPeerId: network!.peerId ?? '');
|
||||
} else {
|
||||
showToast('猫眼设置为省电模式时无法进行监控,请在猫眼设置中切换为其他模式'.tr);
|
||||
}
|
||||
@ -791,7 +788,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
getServerDatetime();
|
||||
await PermissionDialog.request(Permission.location);
|
||||
await PermissionDialog.requestBluetooth();
|
||||
requestDeviceNetworkInfo();
|
||||
// requestDeviceNetworkInfo();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -844,11 +841,11 @@ class LockDetailLogic extends BaseGetXController {
|
||||
}
|
||||
});
|
||||
|
||||
state.SuccessfulDistributionNetworkEvent = eventBus
|
||||
.on<SuccessfulDistributionNetwork>()
|
||||
.listen((SuccessfulDistributionNetwork event) {
|
||||
// 配网成功获取一下配网信息
|
||||
requestDeviceNetworkInfo();
|
||||
});
|
||||
// state.SuccessfulDistributionNetworkEvent = eventBus
|
||||
// .on<SuccessfulDistributionNetwork>()
|
||||
// .listen((SuccessfulDistributionNetwork event) {
|
||||
// // 配网成功获取一下配网信息
|
||||
// requestDeviceNetworkInfo();
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import 'dart:typed_data';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/talk/starChart/constant/message_type_constant.dart';
|
||||
import 'package:star_lock/talk/starChart/constant/talk_status.dart';
|
||||
import 'package:star_lock/talk/starChart/entity/scp_message.dart';
|
||||
@ -42,6 +43,7 @@ class UdpTalkExpectHandler extends ScpMessageBaseHandle
|
||||
startChartManage.stopCallRequestMessageTimer();
|
||||
// talkViewState.rotateAngle.value = talkExpectResp.rotate ?? 0;
|
||||
startChartManage.rotateAngle = talkExpectResp.rotate;
|
||||
AppLog.log('视频画面需要旋转:${talkExpectResp.rotate}');
|
||||
// 收到预期数据的应答后,代表建立了连接,启动通话保持的监听
|
||||
// 启动通话保持监听定时器(用来判断如果x秒内没有收到通话保持则执行的操作);
|
||||
talkePingOverTimeTimerManager.start();
|
||||
|
||||
@ -180,15 +180,15 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle
|
||||
if (isH264) {
|
||||
// 锁支持H264,发送H264视频和G711音频期望
|
||||
startChartManage.sendOnlyH264VideoTalkExpectData();
|
||||
print('锁支持H264,发送H264视频格式期望数据');
|
||||
print('app收到的对讲请求后,发送的预期数据=========锁支持H264,发送H264视频格式期望数据');
|
||||
} else if (isMJpeg) {
|
||||
// 锁只支持MJPEG,发送图像视频和G711音频期望
|
||||
startChartManage.sendOnlyImageVideoTalkExpectData();
|
||||
print('锁不支持H264,支持MJPEG,发送MJPEG视频格式期望数据');
|
||||
print('app收到的对讲请求后,发送的预期数据=========锁不支持H264,支持MJPEG,发送MJPEG视频格式期望数据');
|
||||
} else {
|
||||
// 默认使用图像视频
|
||||
startChartManage.sendOnlyImageVideoTalkExpectData();
|
||||
print('锁不支持H264和MJPEG,默认发送图像视频格式期望数据');
|
||||
print('app收到的对讲请求后,发送的预期数据=========锁不支持H264和MJPEG,默认发送图像视频格式期望数据');
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,15 +203,15 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle
|
||||
if (isH264) {
|
||||
// 锁支持H264,发送H264视频和G711音频期望
|
||||
startChartManage.sendH264VideoAndG711AudioTalkExpectData();
|
||||
print('锁支持H264,发送H264视频格式期望数据');
|
||||
print('app主动发请求,收到回复后发送的预期数据=======锁支持H264,发送H264视频格式期望数据');
|
||||
} else if (isMJpeg) {
|
||||
// 锁只支持MJPEG,发送图像视频和G711音频期望
|
||||
startChartManage.sendImageVideoAndG711AudioTalkExpectData();
|
||||
print('锁不支持H264,支持MJPEG,发送MJPEG视频格式期望数据');
|
||||
print('app主动发请求,收到回复后发送的预期数据=======锁不支持H264,支持MJPEG,发送MJPEG视频格式期望数据');
|
||||
} else {
|
||||
// 默认使用图像视频
|
||||
startChartManage.sendImageVideoAndG711AudioTalkExpectData();
|
||||
print('锁不支持H264和MJPEG,默认发送图像视频格式期望数据');
|
||||
print('app主动发请求,收到回复后发送的预期数据=======锁不支持H264和MJPEG,默认发送图像视频格式期望数据');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,6 +45,7 @@ import 'package:star_lock/talk/starChart/proto/talk_expect.pb.dart';
|
||||
import 'package:star_lock/talk/starChart/proto/talk_expect.pbserver.dart';
|
||||
import 'package:star_lock/talk/starChart/status/star_chart_talk_status.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/commonDataManage.dart';
|
||||
import 'package:star_lock/tools/deviceInfo_utils.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
@ -407,17 +408,36 @@ class StartChartManage {
|
||||
/// 启动持续发送对讲请求
|
||||
void startCallRequestMessageTimer({required String ToPeerId}) async {
|
||||
// 如果已经处于等待接听状态就不发送
|
||||
if (talkStatus.status != TalkStatus.proactivelyCallWaitingAnswer) {
|
||||
// 如果是h264则跳转至webview
|
||||
if (_defaultTalkExpect.videoType.contains(VideoTypeE.H264)) {
|
||||
Get.toNamed(
|
||||
Routers.h264WebView,
|
||||
);
|
||||
} else {
|
||||
Get.toNamed(
|
||||
Routers.starChartTalkView,
|
||||
);
|
||||
}
|
||||
// if (talkStatus.status != TalkStatus.proactivelyCallWaitingAnswer) {
|
||||
// // 如果是h264则跳转至webview
|
||||
// if (_defaultTalkExpect.videoType.contains(VideoTypeE.H264)) {
|
||||
// Get.toNamed(
|
||||
// Routers.h264WebView,
|
||||
// );
|
||||
// } else {
|
||||
// Get.toNamed(
|
||||
// Routers.starChartTalkView,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
final LockListInfoItemEntity currentKeyInfo =
|
||||
CommonDataManage().currentKeyInfo;
|
||||
final isH264 = currentKeyInfo.lockFeature?.isH264 == 1;
|
||||
final isMJpeg = currentKeyInfo.lockFeature?.isMJpeg == 1;
|
||||
|
||||
// 优先使用H264,其次是MJPEG
|
||||
if (isH264) {
|
||||
Get.toNamed(
|
||||
Routers.h264WebView,
|
||||
);
|
||||
} else if (isMJpeg) {
|
||||
Get.toNamed(
|
||||
Routers.starChartTalkView,
|
||||
);
|
||||
} else {
|
||||
Get.toNamed(
|
||||
Routers.starChartTalkView,
|
||||
);
|
||||
}
|
||||
// 启动定时器持续发送对讲请求
|
||||
talkRequestTimer ??= Timer.periodic(
|
||||
|
||||
@ -59,6 +59,9 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
|
||||
// 添加一个集合来跟踪已成功解码的I帧序号
|
||||
final Set<int> _decodedIFrames = <int>{};
|
||||
|
||||
// 定义一个变量来保存上一帧的时间戳
|
||||
int? _previousFrameTimestamp;
|
||||
|
||||
// 初始化视频解码器
|
||||
Future<void> _initVideoDecoder() async {
|
||||
try {
|
||||
@ -227,16 +230,27 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
|
||||
_playAudioFrames();
|
||||
break;
|
||||
case TalkData_ContentTypeE.H264:
|
||||
// 获取当前时间戳
|
||||
final currentTimestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
// 如果存在上一帧时间戳,则计算时间间隔
|
||||
if (_previousFrameTimestamp != null) {
|
||||
final timeDifference = currentTimestamp - _previousFrameTimestamp!;
|
||||
AppLog.log('当前帧与上一帧的时间间隔: $timeDifference 毫秒');
|
||||
}
|
||||
// 更新上一帧时间戳为当前帧的时间戳
|
||||
_previousFrameTimestamp = currentTimestamp;
|
||||
|
||||
// 添加到视频帧缓冲区,而不是直接处理
|
||||
// _processH264Frame(talkData, talkDataH264Frame!);
|
||||
// 直接处理H264视频帧
|
||||
_processH264Frame(talkData, talkDataH264Frame!);
|
||||
|
||||
// 记录关键调试信息
|
||||
if (talkDataH264Frame!.frameType == TalkDataH264Frame_FrameTypeE.I) {
|
||||
AppLog.log(
|
||||
'帧序号${talkDataH264Frame.frameSeq};帧类型:${talkDataH264Frame.frameType.toString()};时间戳:${DateTime.now().millisecondsSinceEpoch}');
|
||||
}
|
||||
// _processH264Frame(talkData, talkDataH264Frame!);
|
||||
//
|
||||
// // 记录关键调试信息
|
||||
// if (talkDataH264Frame!.frameType == TalkDataH264Frame_FrameTypeE.I) {
|
||||
// AppLog.log(
|
||||
// '帧序号${talkDataH264Frame.frameSeq};帧类型:${talkDataH264Frame.frameType.toString()};时间戳:${DateTime.now().millisecondsSinceEpoch}');
|
||||
// }
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
@ -134,7 +134,7 @@ class _TalkViewPageState extends State<TalkViewPage>
|
||||
key: state.globalKey,
|
||||
child: SizedBox.expand(
|
||||
child: RotatedBox(
|
||||
quarterTurns: startChartManage.remotePort ~/ 90,
|
||||
quarterTurns: startChartManage.rotateAngle ~/ 90,
|
||||
child: Obx(
|
||||
() => state.currentImage.value != null
|
||||
? RawImage(
|
||||
|
||||
@ -75,7 +75,7 @@ class _H264WebViewState extends State<H264WebView>
|
||||
)
|
||||
: SizedBox.expand(
|
||||
child: RotatedBox(
|
||||
quarterTurns: startChartManage.remotePort ~/ 90,
|
||||
quarterTurns: startChartManage.rotateAngle ~/ 90,
|
||||
child: WebViewWidget(
|
||||
controller: state.webViewController,
|
||||
),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user