fix(sender): 串流窗口锁定视频比例,关窗即停流,修正文件传输取 IP

- 独立窗口首帧到达后按视频宽高比自动调整并居中;WM_SIZING 锁定比例,最小 320x180

- 去掉 WS_MAXIMIZEBOX 与双击/F11 全屏,只保留关闭与最小化

- 移除停止投屏按钮;WM_DESTROY 通过 ttstd/video 通道回调 windowClosed,Dart 侧下发 stopMirror

- 文件传输地址优先取设备局域网 IP,取不到时回退控制通道 peerIp,并在文件页提供可编辑 IP 输入
This commit is contained in:
tongtong committed 2026-11-27 10:42:48 +08:00
1 parent d3ff293877
commit d8357a8491
8 files changed
+321 -127

No files matched your search

@@ -832,10 +832,16 @@ class VideoTexturePlugin : public flutter::Plugin {
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>>
result) { HandleMethodCall(call, std::move(result)); });
// 用户点窗口关闭按钮或按 ESC:通知 Flutter 停止投屏。
video_window_.SetCloseHandler([this]() { OnVideoWindowClosed(); });
worker_ = std::thread([this, shared_frames]() { RunWorker(shared_frames); });
}
~VideoTexturePlugin() override {
// 先摘掉回调,避免析构期间 DestroyWindow 触发 InvokeMethod。
video_window_.SetCloseHandler(nullptr);
video_window_.Close();
stop_.store(true);
if (worker_.joinable()) {
worker_.join();
@@ -866,6 +872,19 @@ class VideoTexturePlugin : public flutter::Plugin {
return &descriptor_;
}
// 独立窗口被用户关闭:让 Dart 侧停止投屏。
void OnVideoWindowClosed() {
if (closing_from_channel_) {
closing_from_channel_ = false;
return;
}
if (channel_ == nullptr) {
return;
}
channel_->InvokeMethod("windowClosed",
std::make_unique<flutter::EncodableValue>(true));
}
void HandleMethodCall(
const flutter::MethodCall<flutter::EncodableValue>& call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
@@ -882,6 +901,9 @@ class VideoTexturePlugin : public flutter::Plugin {
return;
}
if (call.method_name() == "closeWindow") {
// 由 Flutter 主动关闭时不回调 windowClosed,避免重复下发停止投屏。
// 窗口本来就没开时不要置位,否则下一次用户关窗会被错误抑制。
closing_from_channel_ = video_window_.IsOpen();
video_window_.Close();
result->Success(flutter::EncodableValue(true));
return;
@@ -1029,6 +1051,8 @@ class VideoTexturePlugin : public flutter::Plugin {
std::shared_ptr<FrameStore> frames_;
// 与主窗口纹理共享同一份 FrameStore 的独立串流窗口。
VideoWindow video_window_;
// 本次关闭是由 Flutter 主动发起的(不需要再回调 windowClosed)。
bool closing_from_channel_ = false;
RustVideoApi api_;
VideoDecoder decoder_;
std::atomic<bool> stop_{false};