Merge remote-tracking branch 'origin/develop_liyi' into develop_liyi
This commit is contained in:
commit
f421f59325
BIN
assets/talk.h264
BIN
assets/talk.h264
Binary file not shown.
@ -235,12 +235,6 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
: null)),
|
: null)),
|
||||||
SubmitBtn(
|
|
||||||
btnName: '跳转至通话',
|
|
||||||
onClick: () {
|
|
||||||
Get.toNamed(Routers.lockMonitoringPage);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(height: 50.w),
|
SizedBox(height: 50.w),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
|||||||
@ -16,18 +16,22 @@ class UdpHeartBeatHandler extends ScpMessageBaseHandle
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void handleResp(ScpMessage scpMessage) {
|
void handleResp(ScpMessage scpMessage) {
|
||||||
// TODO: 收到心跳消息回复
|
|
||||||
final HeartbeatResponse heartbeatResponse = scpMessage.Payload;
|
final HeartbeatResponse heartbeatResponse = scpMessage.Payload;
|
||||||
final statusCode = heartbeatResponse.statusCode;
|
final statusCode = heartbeatResponse.statusCode;
|
||||||
if (statusCode != null &&
|
if (statusCode != null &&
|
||||||
statusCode != PayloadTypeConstant.heartHeatSuccessResponse) {
|
statusCode != PayloadTypeConstant.heartHeatSuccessResponse) {
|
||||||
// 心跳响应失败,重新上线
|
// 心跳回复失败,停止发送心跳
|
||||||
|
startChartManage.stopHeartbeat();
|
||||||
|
// 心跳响应失败,重新上线
|
||||||
|
startChartManage.isOnlineStartChartServer = false;
|
||||||
startChartManage.reStartOnlineStartChartServer();
|
startChartManage.reStartOnlineStartChartServer();
|
||||||
|
} else {
|
||||||
|
// 修改间隔为返回的心跳间隔
|
||||||
|
startChartManage.heartbeatIntervalTime =
|
||||||
|
heartbeatResponse.nextPingTime ?? 1;
|
||||||
|
// 修改完间隔之后重新启动发送心跳
|
||||||
|
startChartManage.reStartHeartBeat();
|
||||||
}
|
}
|
||||||
startChartManage.heartbeatIntervalTime =
|
|
||||||
heartbeatResponse.nextPingTime ?? 1;
|
|
||||||
// 修改完间隔之后重新启动发送心跳
|
|
||||||
startChartManage.reStartHeartBeat();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -28,6 +28,7 @@ class UdpTalkAcceptHandler extends ScpMessageBaseHandle
|
|||||||
if (checkGenericRespSuccess(genericResp)) {
|
if (checkGenericRespSuccess(genericResp)) {
|
||||||
// 启动通话保持定时器
|
// 启动通话保持定时器
|
||||||
_handleStartTalkPing();
|
_handleStartTalkPing();
|
||||||
|
// 延迟2秒后启动监听
|
||||||
Future.delayed(Duration(seconds: 2), () {
|
Future.delayed(Duration(seconds: 2), () {
|
||||||
// 启动发送预期数据请求
|
// 启动发送预期数据请求
|
||||||
_handleStartSendTalkExpectDataRequest();
|
_handleStartSendTalkExpectDataRequest();
|
||||||
@ -37,6 +38,7 @@ class UdpTalkAcceptHandler extends ScpMessageBaseHandle
|
|||||||
// 停止播放铃声
|
// 停止播放铃声
|
||||||
stopRingtone();
|
stopRingtone();
|
||||||
// 设置状态为接听中
|
// 设置状态为接听中
|
||||||
|
talkStatus.setAnsweredSuccessfully();
|
||||||
talkStatus.setDuringCall();
|
talkStatus.setDuringCall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,12 +51,14 @@ class UdpTalkDataHandler extends ScpMessageBaseHandle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 处理h264协议的数据
|
||||||
void _handleVideoH264(TalkData talkData) {
|
void _handleVideoH264(TalkData talkData) {
|
||||||
final List<int> content = talkData.content;
|
talkDataRepository.addTalkData(talkData);
|
||||||
talkDataRepository.addTalkData(content);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 处理图片数据
|
||||||
void _handleVideoImage(TalkData talkData) {}
|
void _handleVideoImage(TalkData talkData) {}
|
||||||
|
|
||||||
|
/// 处理g711音频数据
|
||||||
void _handleVideoG711(TalkData talkData) {}
|
void _handleVideoG711(TalkData talkData) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,7 @@ class UdpTalkHangUpHandler extends ScpMessageBaseHandle
|
|||||||
// 停止发送通话保持的命令
|
// 停止发送通话保持的命令
|
||||||
startChartManage.stopTalkPingMessageTimer();
|
startChartManage.stopTalkPingMessageTimer();
|
||||||
startChartManage.stopTalkExpectMessageTimer();
|
startChartManage.stopTalkExpectMessageTimer();
|
||||||
|
talkStatus.setHangingUpDuring();
|
||||||
talkStatus.setEnd();
|
talkStatus.setEnd();
|
||||||
stopRingtone();
|
stopRingtone();
|
||||||
}
|
}
|
||||||
@ -32,6 +33,7 @@ class UdpTalkHangUpHandler extends ScpMessageBaseHandle
|
|||||||
// 停止发送通话保持的命令
|
// 停止发送通话保持的命令
|
||||||
startChartManage.stopTalkPingMessageTimer();
|
startChartManage.stopTalkPingMessageTimer();
|
||||||
startChartManage.stopTalkExpectMessageTimer();
|
startChartManage.stopTalkExpectMessageTimer();
|
||||||
|
talkStatus.setHangingUpDuring();
|
||||||
talkStatus.setEnd();
|
talkStatus.setEnd();
|
||||||
stopRingtone();
|
stopRingtone();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,13 +13,13 @@ class TalkDataRepository {
|
|||||||
static TalkDataRepository get instance => _instance;
|
static TalkDataRepository get instance => _instance;
|
||||||
|
|
||||||
// 创建一个 StreamController
|
// 创建一个 StreamController
|
||||||
final StreamController<List<int>> _talkDataStreamController = StreamController<List<int>>.broadcast();
|
final StreamController<TalkData> _talkDataStreamController = StreamController<TalkData>.broadcast();
|
||||||
|
|
||||||
// 提供一个方法来获取 Stream
|
// 提供一个方法来获取 Stream
|
||||||
Stream<List<int>> get talkDataStream => _talkDataStreamController.stream;
|
Stream<TalkData> get talkDataStream => _talkDataStreamController.stream;
|
||||||
|
|
||||||
// 提供一个方法来添加 TalkData 到 Stream
|
// 提供一个方法来添加 TalkData 到 Stream
|
||||||
void addTalkData(List<int> talkData) {
|
void addTalkData(TalkData talkData) {
|
||||||
_talkDataStreamController.add(talkData);
|
_talkDataStreamController.add(talkData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,8 +4,10 @@ import 'package:star_lock/talk/startChart/events/talk_status_change_event.dart';
|
|||||||
|
|
||||||
enum TalkStatus {
|
enum TalkStatus {
|
||||||
waitingAnswer, // 等待接听
|
waitingAnswer, // 等待接听
|
||||||
|
answeredSuccessfully, // 接听成功
|
||||||
waitingData, // 等待数据
|
waitingData, // 等待数据
|
||||||
duringCall, // 通话中
|
duringCall, // 通话中
|
||||||
|
hangingUpDuring, // 通话中挂断
|
||||||
rejected, // 被拒绝
|
rejected, // 被拒绝
|
||||||
uninitialized, // 未初始化
|
uninitialized, // 未初始化
|
||||||
initializationCompleted, // 初始化完成
|
initializationCompleted, // 初始化完成
|
||||||
@ -104,6 +106,16 @@ class StartChartTalkStatus {
|
|||||||
// 可以在这里添加特定于 "error" 状态的逻辑
|
// 可以在这里添加特定于 "error" 状态的逻辑
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 设置状态为通话中挂断
|
||||||
|
void setHangingUpDuring() {
|
||||||
|
_setStatus(TalkStatus.hangingUpDuring);
|
||||||
|
// 可以在这里添加特定于 "hangingUpDuring" 状态的逻辑
|
||||||
|
} /// 设置状态为接听成功
|
||||||
|
void setAnsweredSuccessfully() {
|
||||||
|
_setStatus(TalkStatus.answeredSuccessfully);
|
||||||
|
// 可以在这里添加特定于 "hangingUpDuring" 状态的逻辑
|
||||||
|
}
|
||||||
|
|
||||||
/// 设置状态为结束
|
/// 设置状态为结束
|
||||||
void setEnd() {
|
void setEnd() {
|
||||||
_setStatus(TalkStatus.end);
|
_setStatus(TalkStatus.end);
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'package:flutter/services.dart' show ByteData, Uint8List, rootBundle;
|
|||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:star_lock/app_settings/app_colors.dart';
|
import 'package:star_lock/app_settings/app_colors.dart';
|
||||||
import 'package:star_lock/talk/startChart/handle/other/talk_data_repository.dart';
|
import 'package:star_lock/talk/startChart/handle/other/talk_data_repository.dart';
|
||||||
|
import 'package:star_lock/talk/startChart/proto/talk_data.pbserver.dart';
|
||||||
import 'package:star_lock/tools/titleAppBar.dart';
|
import 'package:star_lock/tools/titleAppBar.dart';
|
||||||
import 'package:webview_flutter/webview_flutter.dart';
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
|
||||||
@ -70,15 +71,16 @@ class _H264WebViewState extends State<H264WebView> {
|
|||||||
current++;
|
current++;
|
||||||
List<int> frameData = byteData.sublist(start, end);
|
List<int> frameData = byteData.sublist(start, end);
|
||||||
if (frameData.length == 0) timer.cancel();
|
if (frameData.length == 0) timer.cancel();
|
||||||
talkDataRepository.addTalkData(frameData);
|
|
||||||
|
talkDataRepository.addTalkData(TalkData(contentType: TalkData_ContentTypeE.H264,content: frameData));
|
||||||
start = end;
|
start = end;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _sendFramesToHtml() async {
|
void _sendFramesToHtml() async {
|
||||||
// 接收到流数据,保存到缓冲区
|
// 接收到流数据,保存到缓冲区
|
||||||
talkDataRepository.talkDataStream.listen((event) async {
|
talkDataRepository.talkDataStream.listen((TalkData event) async {
|
||||||
_buffer.addAll(event);
|
_buffer.addAll(event.content);
|
||||||
});
|
});
|
||||||
// 缓冲800ms的数据,定时发送
|
// 缓冲800ms的数据,定时发送
|
||||||
_sendTimer ??= Timer.periodic(
|
_sendTimer ??= Timer.periodic(
|
||||||
|
|||||||
@ -299,7 +299,6 @@ flutter:
|
|||||||
- images/lockType/
|
- images/lockType/
|
||||||
- assets/
|
- assets/
|
||||||
- assets/html/h264.html
|
- assets/html/h264.html
|
||||||
- assets/talk.h264
|
|
||||||
- lan/
|
- lan/
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
# An image asset can refer to one or more resolution-specific "variants", see
|
||||||
# https://flutter.dev/assets-and-images/#resolution-aware
|
# https://flutter.dev/assets-and-images/#resolution-aware
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user