mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-10-18 01:46:47 +08:00
[fix] apply settings without reconnecting signaling
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* @Author: DI JUNKUN
|
||||
* @Date: 2026-10-09
|
||||
* Copyright (c) 2026 by DI JUNKUN, All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _SIGNAL_SERVER_SETTINGS_H_
|
||||
#define _SIGNAL_SERVER_SETTINGS_H_
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#include "config_center.h"
|
||||
|
||||
namespace crossdesk {
|
||||
|
||||
// Include the identity namespace as well as the effective endpoint. Editing
|
||||
// an inactive self-hosted endpoint must not disconnect the public server.
|
||||
inline auto GetSignalServerSettings(const ConfigCenter& config) {
|
||||
const bool self_hosted = config.IsSelfHosted();
|
||||
return std::make_tuple(
|
||||
self_hosted,
|
||||
self_hosted ? config.GetSignalServerHost() : config.GetDefaultServerHost(),
|
||||
self_hosted ? config.GetSignalServerPort()
|
||||
: config.GetDefaultSignalServerPort());
|
||||
}
|
||||
|
||||
} // namespace crossdesk
|
||||
|
||||
#endif
|
||||
@@ -62,6 +62,7 @@
|
||||
#endif
|
||||
#include "rd_log.h"
|
||||
#include "server_window_state.h"
|
||||
#include "signal_server_settings.h"
|
||||
#include "ui/announcement_text.h"
|
||||
#include "ui/ui_localization.h"
|
||||
#include "update_checker.h"
|
||||
@@ -3496,6 +3497,7 @@ void GuiApplication::SyncServerWindow() {
|
||||
}
|
||||
|
||||
void GuiApplication::SaveSettingsFromUi() {
|
||||
const auto previous_server = GetSignalServerSettings(*config_center_);
|
||||
auto& main = ui_->main;
|
||||
language_button_value_ =
|
||||
localization::detail::ClampLanguageIndex(main->get_language_index());
|
||||
@@ -3530,10 +3532,18 @@ void GuiApplication::SaveSettingsFromUi() {
|
||||
reload_recent_connections_ = true;
|
||||
#ifdef _WIN32
|
||||
if (!HasActiveSession()) {
|
||||
const auto previous_capture_method = config_center_->GetScreenCaptureMethod();
|
||||
const auto capture_method = static_cast<ScreenCaptureMethod>(
|
||||
std::clamp(main->get_capture_method_index(), 0, 3));
|
||||
if (config_center_->SetScreenCaptureMethod(capture_method) != 0) {
|
||||
LOG_ERROR("Failed to save screen capture method");
|
||||
} else if (capture_method != previous_capture_method) {
|
||||
// Reconfigure only capture; its backend does not own signaling.
|
||||
devices_.StopScreenCapturer();
|
||||
screen_capturer_is_started_ = false;
|
||||
if (devices_.InitializeScreenCapturer() != 0) {
|
||||
LOG_ERROR("Failed to apply screen capture method");
|
||||
}
|
||||
}
|
||||
}
|
||||
main->set_capture_method_index(
|
||||
@@ -3563,7 +3573,8 @@ void GuiApplication::SaveSettingsFromUi() {
|
||||
}
|
||||
|
||||
config_center_->SetSelfHosted(enable_self_hosted_);
|
||||
ApplySettingsFromConfig(!HasActiveSession());
|
||||
ApplySettingsFromConfig(previous_server !=
|
||||
GetSignalServerSettings(*config_center_));
|
||||
}
|
||||
|
||||
void GuiApplication::ApplySettingsFromConfig(bool reconnect) {
|
||||
@@ -3603,6 +3614,24 @@ void GuiApplication::ApplySettingsFromConfig(bool reconnect) {
|
||||
// Tick recreates the peer after asynchronous cleanup, using the committed
|
||||
// configuration. Keep the application and its console running throughout.
|
||||
CloseAllRemoteSessions();
|
||||
} else {
|
||||
const bool hardware = config_center_->IsHardwareVideoCodec();
|
||||
const bool av1 = config_center_->GetVideoEncodeFormat() ==
|
||||
ConfigCenter::VIDEO_ENCODE_FORMAT::AV1;
|
||||
const auto turn = static_cast<TurnMode>(config_center_->GetTurnMode());
|
||||
if (hardware != params_.hardware_acceleration || av1 != params_.av1_encoding ||
|
||||
turn != params_.turn_mode) {
|
||||
// Update the listening peer for incoming connections and the template
|
||||
// copied by ConnectTo for outgoing connections. Existing sessions retain
|
||||
// the codec/ICE snapshot with which they negotiated.
|
||||
if (!peer_ || UpdateConnectionSettings(peer_, hardware, av1, turn) == 0) {
|
||||
params_.hardware_acceleration = hardware;
|
||||
params_.av1_encoding = av1;
|
||||
params_.turn_mode = turn;
|
||||
} else {
|
||||
LOG_ERROR("Failed to apply connection settings without reconnecting");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ struct PeerState {
|
||||
std::string file_label_ = kFileStream;
|
||||
std::string file_feedback_label_ = kFileFeedbackStream;
|
||||
std::string clipboard_label_ = kClipboardStream;
|
||||
Params params_;
|
||||
Params params_{};
|
||||
};
|
||||
|
||||
// OS-specific service and permission state is kept separate from transport
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <optional>
|
||||
|
||||
#include "config_center.h"
|
||||
#include "signal_server_settings.h"
|
||||
|
||||
namespace crossdesk {
|
||||
namespace {
|
||||
@@ -142,11 +143,15 @@ SettingResult ApplyConsoleSetting(ConfigCenter& config, const std::string& key,
|
||||
return {true, SettingEffect::none, "console_settings_unchanged"};
|
||||
}
|
||||
}
|
||||
const auto previous_server = GetSignalServerSettings(config);
|
||||
status = save();
|
||||
if (status != 0) return {false, SettingEffect::none, "console_settings_save_failed"};
|
||||
if (network && ((key != "server_host" && key != "server_port") || config.IsSelfHosted())) {
|
||||
if (previous_server != GetSignalServerSettings(config)) {
|
||||
effect = SettingEffect::reconnect;
|
||||
message = "console_settings_reconnect";
|
||||
} else if (key == "codec" || key == "hardware" || key == "turn") {
|
||||
effect = SettingEffect::next_connection;
|
||||
message = "console_settings_next_connection";
|
||||
}
|
||||
return {true, effect, message};
|
||||
}
|
||||
|
||||
Vendored
+1
-1
Submodule deps/submodules/minirtc updated: d3bac046d1...ec6e20c242
Reference in New Issue
Block a user