fix(sender): 修复断开后重连一直超时,串流窗口按被控端比例开局
- rust_core: stop 先关闭控制连接再 join 监听线程,保证端口真正释放 - rust_core: start 前回收残留线程,按 AddrInUse 重试绑定,失败不再静默 - rust_core: 监听套接字异常时把 running 置回 false;半开握手读超时缩到 1.2s - rust_core: 新增 demo_reconnect 回归测试(stop 后立刻 start 仍可接入) - flutter_sender: connect 检查本机监听结果,失败直接提示端口被占用 - flutter_sender: 断开时一并关闭独立串流窗口,重连不再残留旧帧 - flutter_sender: openWindow 传入被控端分辨率,窗口开局即按竖屏比例居中
This commit is contained in:
1 parent
77ce882397
commit
32e7ca26d8
7 files changed
+269
-33
No files matched your search
@@ -118,7 +118,10 @@ class SenderBridge {
|
||||
final native = _native;
|
||||
if (native != null) {
|
||||
// 先确保本机控制/媒体端口在监听,再让被控端立刻拨号(不必等它下次广播)。
|
||||
native.startDemoServer();
|
||||
// 监听失败必须显式报错:否则被控端拨号会没人接,界面只能笼统地等到超时。
|
||||
if (!native.startDemoServer()) {
|
||||
throw Exception('本机监听启动失败(TCP 41001 / UDP 41000、41002 可能被占用)');
|
||||
}
|
||||
if (device.ip.isNotEmpty) {
|
||||
native.discoveryConnect(device.ip);
|
||||
}
|
||||
@@ -281,9 +284,15 @@ class SenderBridge {
|
||||
}
|
||||
|
||||
/// 把串流画面弹出为独立原生窗口(Windows);返回是否成功。
|
||||
Future<bool> openVideoWindow() async {
|
||||
///
|
||||
/// [width] / [height] 是被控端屏幕尺寸提示:传了就按该比例开局,
|
||||
/// 不再先弹出一个 16:9 的大窗口等首帧再缩回去。
|
||||
Future<bool> openVideoWindow({int? width, int? height}) async {
|
||||
try {
|
||||
final opened = await _video.invokeMethod<bool>('openWindow');
|
||||
final arguments = (width != null && height != null && width > 0 && height > 0)
|
||||
? <String, dynamic>{'width': width, 'height': height}
|
||||
: null;
|
||||
final opened = await _video.invokeMethod<bool>('openWindow', arguments);
|
||||
return opened ?? false;
|
||||
} on MissingPluginException {
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user