From 7fc1344756b7c24733e57f390c2515437261aa86 Mon Sep 17 00:00:00 2001 From: dijunkun Date: Tue, 15 Sep 2026 02:01:13 +0800 Subject: [PATCH] [feat] enable enhanced UDP punching on desktop --- .../src/config_center/config_center.cpp | 21 ++++++--------- .../desktop/src/config_center/config_center.h | 2 -- .../src/gui/application/gui_application.cpp | 5 ---- apps/desktop/src/gui/assets/layouts/layout.h | 2 -- .../src/gui/assets/layouts/layout_relative.h | 2 -- .../assets/localization/localization_data.h | 1 - .../features/settings/settings_manager.cpp | 2 -- apps/desktop/src/gui/runtime/runtime_state.h | 2 -- apps/desktop/src/gui/ui/main_window.slint | 7 ----- apps/desktop/src/gui/ui/stream_window.slint | 15 +---------- apps/desktop/src/gui/ui/ui_localization.h | 1 - .../views/windows/main_settings_window.cpp | 27 ------------------- .../src/gui/views/windows/stream_window.cpp | 7 ++--- deps/submodules/minirtc | 2 +- 14 files changed, 12 insertions(+), 84 deletions(-) diff --git a/apps/desktop/src/config_center/config_center.cpp b/apps/desktop/src/config_center/config_center.cpp index 5df11de5..86225b93 100644 --- a/apps/desktop/src/config_center/config_center.cpp +++ b/apps/desktop/src/config_center/config_center.cpp @@ -103,7 +103,12 @@ int ConfigCenter::Load() { ini_.SetLongValue(section_, "turn_mode", static_cast(turn_mode_)); persist_config_migration = true; } - enable_srtp_ = ini_.GetBoolValue(section_, "enable_srtp", enable_srtp_); + // Migrate the former user switch. Keep true in the file for older builds, + // while the current application always requests encrypted native media. + if (!ini_.GetBoolValue(section_, "enable_srtp", false)) { + ini_.SetBoolValue(section_, "enable_srtp", true); + persist_config_migration = true; + } enable_self_hosted_ = ini_.GetBoolValue(section_, "enable_self_hosted", enable_self_hosted_); @@ -165,7 +170,7 @@ int ConfigCenter::Save() { ini_.SetLongValue(section_, "turn_mode", static_cast(turn_mode_)); ini_.SetBoolValue(section_, "enable_turn", turn_mode_ != TURN_MODE::DISABLED); - ini_.SetBoolValue(section_, "enable_srtp", enable_srtp_); + ini_.SetBoolValue(section_, "enable_srtp", true); ini_.SetBoolValue(section_, "enable_self_hosted", enable_self_hosted_); // only save when self hosted @@ -301,16 +306,6 @@ int ConfigCenter::SetTurn(bool enable_turn) { return SetTurnMode(turn_mode_); } -int ConfigCenter::SetSrtp(bool enable_srtp) { - enable_srtp_ = enable_srtp; - ini_.SetBoolValue(section_, "enable_srtp", enable_srtp_); - SI_Error rc = ini_.SaveFile(config_path_.c_str()); - if (rc < 0) { - return -1; - } - return 0; -} - int ConfigCenter::SetServerHost(const std::string& signal_server_host) { signal_server_host_ = signal_server_host; ini_.SetValue(section_, "signal_server_host", signal_server_host_.c_str()); @@ -472,7 +467,7 @@ bool ConfigCenter::IsEnableTurn() const { return turn_mode_ != TURN_MODE::DISABLED; } -bool ConfigCenter::IsEnableSrtp() const { return enable_srtp_; } +bool ConfigCenter::IsEnableSrtp() const { return true; } std::string ConfigCenter::GetSignalServerHost() const { return signal_server_host_; diff --git a/apps/desktop/src/config_center/config_center.h b/apps/desktop/src/config_center/config_center.h index 7e6fe61e..9047eb00 100644 --- a/apps/desktop/src/config_center/config_center.h +++ b/apps/desktop/src/config_center/config_center.h @@ -47,7 +47,6 @@ class ConfigCenter { int SetHardwareVideoCodec(bool hardware_video_codec); int SetTurnMode(TURN_MODE turn_mode); int SetTurn(bool enable_turn); - int SetSrtp(bool enable_srtp); int SetServerHost(const std::string& signal_server_host); int SetServerPort(int signal_server_port); int SetSelfHosted(bool enable_self_hosted); @@ -99,7 +98,6 @@ class ConfigCenter { VIDEO_ENCODE_FORMAT video_encode_format_ = VIDEO_ENCODE_FORMAT::H264; bool hardware_video_codec_ = false; TURN_MODE turn_mode_ = TURN_MODE::AUTO_UDP_TCP; - bool enable_srtp_ = false; std::string signal_server_host_ = ""; std::string signal_server_host_default_ = "api.crossdesk.cn"; int signal_server_port_ = 0; diff --git a/apps/desktop/src/gui/application/gui_application.cpp b/apps/desktop/src/gui/application/gui_application.cpp index 5b518230..6dc25667 100644 --- a/apps/desktop/src/gui/application/gui_application.cpp +++ b/apps/desktop/src/gui/application/gui_application.cpp @@ -1230,7 +1230,6 @@ void GuiApplication::ResetSettingsUi() { ui_->main->set_hardware_codec_enabled(hardware_codec_available && enable_hardware_video_codec_); ui_->main->set_turn_enabled(enable_turn_); - ui_->main->set_srtp_enabled(enable_srtp_); ui_->main->set_self_hosted_enabled(enable_self_hosted_); ui_->main->set_autostart_enabled(enable_autostart_); ui_->main->set_daemon_enabled(enable_daemon_); @@ -2419,7 +2418,6 @@ void GuiApplication::SyncStreamWindow() { return; } (*ui_->stream)->set_window_maximized((*ui_->stream)->window().is_maximized()); - (*ui_->stream)->set_srtp_enabled(enable_srtp_); #if defined(__APPLE__) if (ui_->stream_live_resize_configuration_attempts > 0) { if (ConfigureStreamWindowLiveResize( @@ -2987,7 +2985,6 @@ void GuiApplication::SaveSettingsFromUi() { enable_hardware_video_codec_ = ConfigCenter::IsHardwareVideoCodecAvailable() && main->get_hardware_codec_enabled(); enable_turn_ = main->get_turn_enabled(); - enable_srtp_ = main->get_srtp_enabled(); enable_self_hosted_ = main->get_self_hosted_enabled(); enable_autostart_ = main->get_autostart_enabled(); enable_daemon_ = main->get_daemon_enabled(); @@ -3010,7 +3007,6 @@ void GuiApplication::SaveSettingsFromUi() { video_encode_format_button_value_)); config_center_->SetHardwareVideoCodec(enable_hardware_video_codec_); config_center_->SetTurn(enable_turn_); - config_center_->SetSrtp(enable_srtp_); config_center_->SetSelfHosted(enable_self_hosted_); config_center_->SetAutostart(enable_autostart_); config_center_->SetDaemon(enable_daemon_); @@ -3056,7 +3052,6 @@ void GuiApplication::SaveSettingsFromUi() { video_encode_format_button_value_last_ = video_encode_format_button_value_; enable_hardware_video_codec_last_ = enable_hardware_video_codec_; enable_turn_last_ = enable_turn_; - enable_srtp_last_ = enable_srtp_; enable_self_hosted_last_ = enable_self_hosted_; enable_autostart_last_ = enable_autostart_; enable_daemon_last_ = enable_daemon_; diff --git a/apps/desktop/src/gui/assets/layouts/layout.h b/apps/desktop/src/gui/assets/layouts/layout.h index d5b83742..27748a76 100644 --- a/apps/desktop/src/gui/assets/layouts/layout.h +++ b/apps/desktop/src/gui/assets/layouts/layout.h @@ -53,8 +53,6 @@ #define ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_EN 218 * dpi_scale_ #define ENABLE_TURN_CHECKBOX_PADDING_CN 171 * dpi_scale_ #define ENABLE_TURN_CHECKBOX_PADDING_EN 218 * dpi_scale_ -#define ENABLE_SRTP_CHECKBOX_PADDING_CN 171 * dpi_scale_ -#define ENABLE_SRTP_CHECKBOX_PADDING_EN 218 * dpi_scale_ #define ENABLE_SELF_HOSTED_SERVER_CHECKBOX_PADDING_CN 171 * dpi_scale_ #define ENABLE_SELF_HOSTED_SERVER_CHECKBOX_PADDING_EN 218 * dpi_scale_ #define ENABLE_AUTOSTART_PADDING_CN 171 * dpi_scale_ diff --git a/apps/desktop/src/gui/assets/layouts/layout_relative.h b/apps/desktop/src/gui/assets/layouts/layout_relative.h index e58a0e44..687627dd 100644 --- a/apps/desktop/src/gui/assets/layouts/layout_relative.h +++ b/apps/desktop/src/gui/assets/layouts/layout_relative.h @@ -57,8 +57,6 @@ #define ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_EN 218 #define ENABLE_TURN_CHECKBOX_PADDING_CN 171 #define ENABLE_TURN_CHECKBOX_PADDING_EN 218 -#define ENABLE_SRTP_CHECKBOX_PADDING_CN 171 -#define ENABLE_SRTP_CHECKBOX_PADDING_EN 218 #define ENABLE_SELF_HOSTED_SERVER_CHECKBOX_PADDING_CN 171 #define ENABLE_SELF_HOSTED_SERVER_CHECKBOX_PADDING_EN 218 #define ENABLE_AUTOSTART_PADDING_CN 171 diff --git a/apps/desktop/src/gui/assets/localization/localization_data.h b/apps/desktop/src/gui/assets/localization/localization_data.h index 82e9dc2d..a269ca59 100644 --- a/apps/desktop/src/gui/assets/localization/localization_data.h +++ b/apps/desktop/src/gui/assets/localization/localization_data.h @@ -149,7 +149,6 @@ struct TranslationRow { "Enable Hardware Video Codec:", u8"Использовать аппаратный кодек:") \ X(enable_turn, u8"启用中继服务:", \ "Enable TURN Service:", u8"Включить TURN-сервис:") \ - X(enable_srtp, u8"启用SRTP:", "Enable SRTP:", u8"Включить SRTP:") \ X(self_hosted_server_config, u8"自托管配置", "Self-Hosted Config", \ u8"Конфигурация self-hosted") \ X(self_hosted_server_settings, u8"自托管设置", "Self-Hosted Settings", \ diff --git a/apps/desktop/src/gui/features/settings/settings_manager.cpp b/apps/desktop/src/gui/features/settings/settings_manager.cpp index 89abcdea..87585851 100644 --- a/apps/desktop/src/gui/features/settings/settings_manager.cpp +++ b/apps/desktop/src/gui/features/settings/settings_manager.cpp @@ -308,7 +308,6 @@ int SettingsManager::Load() { owner_.enable_hardware_video_codec_ = owner_.config_center_->IsHardwareVideoCodec(); owner_.enable_turn_ = owner_.config_center_->IsEnableTurn(); - owner_.enable_srtp_ = owner_.config_center_->IsEnableSrtp(); owner_.enable_self_hosted_ = owner_.config_center_->IsSelfHosted(); owner_.enable_autostart_ = owner_.config_center_->IsEnableAutostart(); owner_.enable_daemon_ = owner_.config_center_->IsEnableDaemon(); @@ -335,7 +334,6 @@ int SettingsManager::Load() { owner_.enable_hardware_video_codec_last_ = owner_.enable_hardware_video_codec_; owner_.enable_turn_last_ = owner_.enable_turn_; - owner_.enable_srtp_last_ = owner_.enable_srtp_; owner_.enable_self_hosted_last_ = owner_.enable_self_hosted_; owner_.enable_autostart_last_ = owner_.enable_autostart_; diff --git a/apps/desktop/src/gui/runtime/runtime_state.h b/apps/desktop/src/gui/runtime/runtime_state.h index 464df2b1..e50a85cb 100644 --- a/apps/desktop/src/gui/runtime/runtime_state.h +++ b/apps/desktop/src/gui/runtime/runtime_state.h @@ -136,7 +136,6 @@ struct UserSettingsState { int video_encode_format_button_value_ = 0; bool enable_hardware_video_codec_ = true; bool enable_turn_ = true; - bool enable_srtp_ = false; char signal_server_ip_[256] = "api.crossdesk.cn"; char signal_server_port_[6] = "9099"; bool enable_self_hosted_ = false; @@ -147,7 +146,6 @@ struct UserSettingsState { int video_encode_format_button_value_last_ = 0; bool enable_hardware_video_codec_last_ = false; bool enable_turn_last_ = true; - bool enable_srtp_last_ = false; bool enable_self_hosted_last_ = false; bool enable_autostart_ = false; bool enable_autostart_last_ = false; diff --git a/apps/desktop/src/gui/ui/main_window.slint b/apps/desktop/src/gui/ui/main_window.slint index 7d9255f1..aeb2fafa 100644 --- a/apps/desktop/src/gui/ui/main_window.slint +++ b/apps/desktop/src/gui/ui/main_window.slint @@ -48,7 +48,6 @@ export global UiStrings { in-out property codec: "Video codec"; in-out property hardware-codec: "Hardware video codec"; in-out property turn-relay: "TURN relay"; - in-out property srtp: "SRTP encryption"; in-out property self-hosted: "Self-hosted server"; in-out property autostart: "Start with system"; in-out property daemon: "Run in background"; @@ -247,7 +246,6 @@ export component MainWindow inherits Window { in-out property codec-index: 0; in-out property hardware-codec-enabled: true; in-out property turn-enabled: true; - in-out property srtp-enabled: false; in-out property self-hosted-enabled: false; in-out property autostart-enabled: false; in-out property daemon-enabled: false; @@ -1488,11 +1486,6 @@ export component MainWindow inherits Window { Text { x: 8px; y: 3px; width: root.compact-language ? 145px : 212px; height: 24px; text: UiStrings.turn-relay; font-size: ImGuiFontStyle.body; overflow: elide; vertical-alignment: center; } ImGuiCheckBox { x: root.compact-language ? 157px : 224px; y: 3px; checked <=> root.turn-enabled; enabled: !root.settings-session-active; } } - Rectangle { - height: 30px; - Text { x: 8px; y: 3px; width: root.compact-language ? 145px : 212px; height: 24px; text: UiStrings.srtp; font-size: ImGuiFontStyle.body; overflow: elide; vertical-alignment: center; } - ImGuiCheckBox { x: root.compact-language ? 157px : 224px; y: 3px; checked <=> root.srtp-enabled; enabled: !root.settings-session-active; } - } Rectangle { height: 30px; Text { x: 8px; y: 3px; width: root.compact-language ? 145px : 212px; height: 24px; text: UiStrings.privacy-on-connect; color: root.privacy-setting-available ? #202124 : #8b8f95; font-size: ImGuiFontStyle.body; overflow: elide; vertical-alignment: center; } diff --git a/apps/desktop/src/gui/ui/stream_window.slint b/apps/desktop/src/gui/ui/stream_window.slint index 1e419c68..7fd408fc 100644 --- a/apps/desktop/src/gui/ui/stream_window.slint +++ b/apps/desktop/src/gui/ui/stream_window.slint @@ -160,7 +160,6 @@ export component StreamWindow inherits Window { in property remote-cursor-active: false; in property remote-cursor-shape: 0; in property audio-enabled: true; - in property srtp-enabled: false; in property fullscreen-enabled: false; in property stats-visible: false; in property <[NetworkStatsRow]> stats-rows; @@ -506,20 +505,8 @@ export component StreamWindow inherits Window { width: parent.width - 27px; height: parent.height; background: transparent; - if root.srtp-enabled: Text { - x: 0px; - width: 12px; - height: parent.height; - text: FontAwesomeIcons.shield-halved; - color: #30343b; - font-family: "Font Awesome 6 Free"; - font-weight: 900; - font-size: ImGuiFontStyle.base; - horizontal-alignment: center; - vertical-alignment: center; - } Text { - x: root.srtp-enabled ? 16px : 0px; + x: 0px; width: parent.width - self.x; height: parent.height; text: tab.title; diff --git a/apps/desktop/src/gui/ui/ui_localization.h b/apps/desktop/src/gui/ui/ui_localization.h index c848def4..1ee4a127 100644 --- a/apps/desktop/src/gui/ui/ui_localization.h +++ b/apps/desktop/src/gui/ui/ui_localization.h @@ -69,7 +69,6 @@ inline int ApplyMainWindowStrings( strings.set_hardware_codec( Text(localization::enable_hardware_video_codec[language])); strings.set_turn_relay(Text(localization::enable_turn[language])); - strings.set_srtp(Text(localization::enable_srtp[language])); strings.set_self_hosted( Text(localization::self_hosted_server_config[language])); strings.set_autostart(Text(localization::enable_autostart[language])); diff --git a/apps/desktop/src/gui/views/windows/main_settings_window.cpp b/apps/desktop/src/gui/views/windows/main_settings_window.cpp index c304493c..d2f85dde 100644 --- a/apps/desktop/src/gui/views/windows/main_settings_window.cpp +++ b/apps/desktop/src/gui/views/windows/main_settings_window.cpp @@ -268,25 +268,6 @@ int GuiApplication::SettingWindow() { ImGui::Separator(); - { - settings_items_offset += settings_items_padding; - ImGui::SetCursorPosY(settings_items_offset); - ImGui::AlignTextToFramePadding(); - ImGui::Text( - "%s", - localization::enable_srtp[localization_language_index_].c_str()); - ImGui::SameLine(); - if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) { - ImGui::SetCursorPosX(title_bar_button_width_ * 4.275f); - } else { - ImGui::SetCursorPosX(title_bar_button_width_ * 5.955f); - } - - ImGui::Checkbox("##enable_srtp", &enable_srtp_); - } - - ImGui::Separator(); - { settings_items_offset += settings_items_padding; ImGui::SetCursorPosY(settings_items_offset + 1); @@ -569,14 +550,6 @@ int GuiApplication::SettingWindow() { } enable_turn_last_ = enable_turn_; - // SRTP - if (enable_srtp_) { - config_center_->SetSrtp(true); - } else { - config_center_->SetSrtp(false); - } - enable_srtp_last_ = enable_srtp_; - if (enable_self_hosted_) { config_center_->SetSelfHosted(true); } else { diff --git a/apps/desktop/src/gui/views/windows/stream_window.cpp b/apps/desktop/src/gui/views/windows/stream_window.cpp index fa6450b0..7b54eb47 100644 --- a/apps/desktop/src/gui/views/windows/stream_window.cpp +++ b/apps/desktop/src/gui/views/windows/stream_window.cpp @@ -136,10 +136,7 @@ int GuiApplication::StreamWindow() { continue; } - std::string tab_label = - enable_srtp_ - ? std::string(ICON_FA_SHIELD_HALVED) + " " + props->remote_id_ - : props->remote_id_; + const std::string& tab_label = props->remote_id_; if (ImGui::BeginTabItem(tab_label.c_str(), &props->tab_opened_)) { props->tab_selected_ = true; ImGui::SetWindowFontScale(0.6f); @@ -308,4 +305,4 @@ int GuiApplication::StreamWindow() { return 0; } -} // namespace crossdesk \ No newline at end of file +} // namespace crossdesk diff --git a/deps/submodules/minirtc b/deps/submodules/minirtc index f169a696..a037bb82 160000 --- a/deps/submodules/minirtc +++ b/deps/submodules/minirtc @@ -1 +1 @@ -Subproject commit f169a696cb4e6cb59037ec02e85532e30d3c1262 +Subproject commit a037bb829d164bfc00a8243e31e21fe12bddc446