mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[feat] add self-hosted server configuration section in settings window
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -91,14 +91,22 @@ static std::vector<std::string> enable_hardware_video_codec = {
|
|||||||
"Enable Hardware Video Codec:"};
|
"Enable Hardware Video Codec:"};
|
||||||
static std::vector<std::string> enable_turn = {
|
static std::vector<std::string> enable_turn = {
|
||||||
reinterpret_cast<const char*>(u8"启用中继服务:"), "Enable TURN Service:"};
|
reinterpret_cast<const char*>(u8"启用中继服务:"), "Enable TURN Service:"};
|
||||||
|
|
||||||
static std::vector<std::string> enable_srtp = {
|
static std::vector<std::string> enable_srtp = {
|
||||||
reinterpret_cast<const char*>(u8"启用SRTP:"), "Enable SRTP:"};
|
reinterpret_cast<const char*>(u8"启用SRTP:"), "Enable SRTP:"};
|
||||||
|
|
||||||
static std::vector<std::string> self_hosted_server_config = {
|
static std::vector<std::string> self_hosted_server_config = {
|
||||||
reinterpret_cast<const char*>(u8"自托管服务器配置"),
|
reinterpret_cast<const char*>(u8"自托管服务器配置"),
|
||||||
"Self-Hosted Server Config"};
|
"Self-Hosted Server Config"};
|
||||||
|
static std::vector<std::string> self_hosted_server_settings = {
|
||||||
|
reinterpret_cast<const char*>(u8"自托管服务器设置"),
|
||||||
|
"Self-Hosted Server Settings"};
|
||||||
|
static std::vector<std::string> self_hosted_server_address = {
|
||||||
|
reinterpret_cast<const char*>(u8"服务器地址:"), "Server Address:"};
|
||||||
|
static std::vector<std::string> self_hosted_server_port = {
|
||||||
|
reinterpret_cast<const char*>(u8"服务器端口:"), "Server Port:"};
|
||||||
|
static std::vector<std::string> self_hosted_server_certificate_path = {
|
||||||
|
reinterpret_cast<const char*>(u8"证书文件路径:"), "Certificate File Path:"};
|
||||||
|
static std::vector<std::string> select_a_file = {
|
||||||
|
reinterpret_cast<const char*>(u8"请选择文件"), "Please select a file"};
|
||||||
static std::vector<std::string> ok = {reinterpret_cast<const char*>(u8"确认"),
|
static std::vector<std::string> ok = {reinterpret_cast<const char*>(u8"确认"),
|
||||||
"OK"};
|
"OK"};
|
||||||
static std::vector<std::string> cancel = {
|
static std::vector<std::string> cancel = {
|
||||||
|
|||||||
@@ -18,28 +18,39 @@
|
|||||||
#define IPUT_WINDOW_WIDTH 160
|
#define IPUT_WINDOW_WIDTH 160
|
||||||
#define INPUT_WINDOW_PADDING_CN 66
|
#define INPUT_WINDOW_PADDING_CN 66
|
||||||
#define INPUT_WINDOW_PADDING_EN 96
|
#define INPUT_WINDOW_PADDING_EN 96
|
||||||
#define SETTINGS_WINDOW_WIDTH_CN 182
|
#define SETTINGS_WINDOW_WIDTH_CN 202
|
||||||
#define SETTINGS_WINDOW_WIDTH_EN 248
|
#define SETTINGS_WINDOW_WIDTH_EN 248
|
||||||
#define SETTINGS_WINDOW_HEIGHT_CN 300
|
#define SETTINGS_WINDOW_HEIGHT_CN 315
|
||||||
#define SETTINGS_WINDOW_HEIGHT_EN 300
|
#define SETTINGS_WINDOW_HEIGHT_EN 315
|
||||||
#define LANGUAGE_SELECT_WINDOW_PADDING_CN 100
|
#define SELF_HOSTED_SERVER_CONFIG_WINDOW_WIDTH_CN 228
|
||||||
|
#define SELF_HOSTED_SERVER_CONFIG_WINDOW_WIDTH_EN 275
|
||||||
|
#define SELF_HOSTED_SERVER_CONFIG_WINDOW_HEIGHT_CN 165
|
||||||
|
#define SELF_HOSTED_SERVER_CONFIG_WINDOW_HEIGHT_EN 165
|
||||||
|
#define LANGUAGE_SELECT_WINDOW_PADDING_CN 120
|
||||||
#define LANGUAGE_SELECT_WINDOW_PADDING_EN 167
|
#define LANGUAGE_SELECT_WINDOW_PADDING_EN 167
|
||||||
#define VIDEO_QUALITY_SELECT_WINDOW_PADDING_CN 100
|
#define VIDEO_QUALITY_SELECT_WINDOW_PADDING_CN 120
|
||||||
#define VIDEO_QUALITY_SELECT_WINDOW_PADDING_EN 167
|
#define VIDEO_QUALITY_SELECT_WINDOW_PADDING_EN 167
|
||||||
#define VIDEO_FRAME_RATE_SELECT_WINDOW_PADDING_CN 100
|
#define VIDEO_FRAME_RATE_SELECT_WINDOW_PADDING_CN 120
|
||||||
#define VIDEO_FRAME_RATE_SELECT_WINDOW_PADDING_EN 167
|
#define VIDEO_FRAME_RATE_SELECT_WINDOW_PADDING_EN 167
|
||||||
#define VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_CN 100
|
#define VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_CN 120
|
||||||
#define VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_EN 167
|
#define VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_EN 167
|
||||||
#define ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_CN 151
|
#define ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_CN 171
|
||||||
#define ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_EN 218
|
#define ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_EN 218
|
||||||
#define ENABLE_TURN_CHECKBOX_PADDING_CN 151
|
#define ENABLE_TURN_CHECKBOX_PADDING_CN 171
|
||||||
#define ENABLE_TURN_CHECKBOX_PADDING_EN 218
|
#define ENABLE_TURN_CHECKBOX_PADDING_EN 218
|
||||||
#define ENABLE_SRTP_CHECKBOX_PADDING_CN 151
|
#define ENABLE_SRTP_CHECKBOX_PADDING_CN 171
|
||||||
#define ENABLE_SRTP_CHECKBOX_PADDING_EN 218
|
#define ENABLE_SRTP_CHECKBOX_PADDING_EN 218
|
||||||
#define ENABLE_SELF_HOSTED_SERVER_CHECKBOX_PADDING_CN 151
|
#define ENABLE_SELF_HOSTED_SERVER_CHECKBOX_PADDING_CN 171
|
||||||
#define ENABLE_SELF_HOSTED_SERVER_CHECKBOX_PADDING_EN 218
|
#define ENABLE_SELF_HOSTED_SERVER_CHECKBOX_PADDING_EN 218
|
||||||
|
#define SELF_HOSTED_SERVER_HOST_INPUT_BOX_PADDING_CN 90
|
||||||
|
#define SELF_HOSTED_SERVER_HOST_INPUT_BOX_PADDING_EN 137
|
||||||
|
#define SELF_HOSTED_SERVER_PORT_INPUT_BOX_PADDING_CN 90
|
||||||
|
#define SELF_HOSTED_SERVER_PORT_INPUT_BOX_PADDING_EN 137
|
||||||
#define SETTINGS_SELECT_WINDOW_WIDTH 73
|
#define SETTINGS_SELECT_WINDOW_WIDTH 73
|
||||||
#define SETTINGS_OK_BUTTON_PADDING_CN 55
|
#define SELF_HOSTED_SERVER_INPUT_WINDOW_WIDTH 130
|
||||||
#define SETTINGS_OK_BUTTON_PADDING_EN 78
|
#define SETTINGS_OK_BUTTON_PADDING_CN 65
|
||||||
|
#define SETTINGS_OK_BUTTON_PADDING_EN 83
|
||||||
|
#define SELF_HOSTED_SERVER_CONFIG_OK_BUTTON_PADDING_CN 78
|
||||||
|
#define SELF_HOSTED_SERVER_CONFIG_OK_BUTTON_PADDING_EN 91
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -152,6 +152,8 @@ class Render {
|
|||||||
int RemoteWindow();
|
int RemoteWindow();
|
||||||
int RecentConnectionsWindow();
|
int RecentConnectionsWindow();
|
||||||
int SettingWindow();
|
int SettingWindow();
|
||||||
|
int SelfHostedServerWindow();
|
||||||
|
int ShowSimpleFileBrowser();
|
||||||
int ControlWindow(std::shared_ptr<SubStreamWindowProperties>& props);
|
int ControlWindow(std::shared_ptr<SubStreamWindowProperties>& props);
|
||||||
int ControlBar(std::shared_ptr<SubStreamWindowProperties>& props);
|
int ControlBar(std::shared_ptr<SubStreamWindowProperties>& props);
|
||||||
int AboutWindow();
|
int AboutWindow();
|
||||||
@@ -355,6 +357,9 @@ class Render {
|
|||||||
SDL_Event last_mouse_event;
|
SDL_Event last_mouse_event;
|
||||||
SDL_AudioStream* output_stream_;
|
SDL_AudioStream* output_stream_;
|
||||||
uint32_t STREAM_REFRESH_EVENT = 0;
|
uint32_t STREAM_REFRESH_EVENT = 0;
|
||||||
|
char self_hosted_server_host_[256] = "";
|
||||||
|
char self_hosted_server_port_[6] = "";
|
||||||
|
char self_hosted_server_cert_path_[256] = "";
|
||||||
|
|
||||||
// stream window render
|
// stream window render
|
||||||
SDL_Window* stream_window_ = nullptr;
|
SDL_Window* stream_window_ = nullptr;
|
||||||
@@ -383,6 +388,7 @@ class Render {
|
|||||||
bool password_validating_ = false;
|
bool password_validating_ = false;
|
||||||
uint32_t password_validating_time_ = 0;
|
uint32_t password_validating_time_ = 0;
|
||||||
bool show_settings_window_ = false;
|
bool show_settings_window_ = false;
|
||||||
|
bool show_self_hosted_server_config_window_ = false;
|
||||||
bool rejoin_ = false;
|
bool rejoin_ = false;
|
||||||
bool local_id_copied_ = false;
|
bool local_id_copied_ = false;
|
||||||
bool show_password_ = true;
|
bool show_password_ = true;
|
||||||
@@ -439,6 +445,9 @@ class Render {
|
|||||||
bool enable_turn_last_ = false;
|
bool enable_turn_last_ = false;
|
||||||
bool enable_srtp_last_ = true;
|
bool enable_srtp_last_ = true;
|
||||||
bool settings_window_pos_reset_ = true;
|
bool settings_window_pos_reset_ = true;
|
||||||
|
bool self_hosted_server_config_window_pos_reset_ = true;
|
||||||
|
std::string selected_current_file_path_ = "";
|
||||||
|
std::string selected_file_ = "";
|
||||||
/* ------ main window property end ------ */
|
/* ------ main window property end ------ */
|
||||||
|
|
||||||
/* ------ sub stream window property start ------ */
|
/* ------ sub stream window property start ------ */
|
||||||
|
|||||||
335
src/single_window/server_settings_window.cpp
Normal file
335
src/single_window/server_settings_window.cpp
Normal file
@@ -0,0 +1,335 @@
|
|||||||
|
#include <filesystem>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "layout_style.h"
|
||||||
|
#include "localization.h"
|
||||||
|
#include "rd_log.h"
|
||||||
|
#include "render.h"
|
||||||
|
|
||||||
|
std::vector<std::string> GetRootEntries() {
|
||||||
|
std::vector<std::string> roots;
|
||||||
|
#ifdef _WIN32
|
||||||
|
DWORD mask = GetLogicalDrives();
|
||||||
|
for (char letter = 'A'; letter <= 'Z'; ++letter) {
|
||||||
|
if (mask & 1) {
|
||||||
|
roots.push_back(std::string(1, letter) + ":\\");
|
||||||
|
}
|
||||||
|
mask >>= 1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
roots.push_back("/");
|
||||||
|
#endif
|
||||||
|
return roots;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Render::ShowSimpleFileBrowser() {
|
||||||
|
std::string display_text;
|
||||||
|
if (!selected_file_.empty()) {
|
||||||
|
display_text = std::filesystem::path(selected_file_).filename().string();
|
||||||
|
} else if (selected_current_file_path_ != "Root") {
|
||||||
|
display_text =
|
||||||
|
std::filesystem::path(selected_current_file_path_).filename().string();
|
||||||
|
if (display_text.empty()) {
|
||||||
|
display_text = selected_current_file_path_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (display_text.empty()) {
|
||||||
|
display_text =
|
||||||
|
localization::select_a_file[localization_language_index_].c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginCombo("##select_a_file", display_text.c_str())) {
|
||||||
|
if (selected_current_file_path_ == "Root" ||
|
||||||
|
!std::filesystem::exists(selected_current_file_path_) ||
|
||||||
|
!std::filesystem::is_directory(selected_current_file_path_)) {
|
||||||
|
auto roots = GetRootEntries();
|
||||||
|
for (const auto& root : roots) {
|
||||||
|
if (ImGui::Selectable(root.c_str())) {
|
||||||
|
selected_current_file_path_ = root;
|
||||||
|
selected_file_.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::filesystem::path p(selected_current_file_path_);
|
||||||
|
|
||||||
|
if (ImGui::Selectable("..")) {
|
||||||
|
if (p.has_parent_path() && p != p.root_path())
|
||||||
|
selected_current_file_path_ = p.parent_path().string();
|
||||||
|
else
|
||||||
|
selected_current_file_path_ = "Root";
|
||||||
|
selected_file_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (const auto& entry :
|
||||||
|
std::filesystem::directory_iterator(selected_current_file_path_)) {
|
||||||
|
std::string name = entry.path().filename().string();
|
||||||
|
if (entry.is_directory()) {
|
||||||
|
if (ImGui::Selectable(name.c_str())) {
|
||||||
|
selected_current_file_path_ = entry.path().string();
|
||||||
|
selected_file_.clear();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ImGui::Selectable(name.c_str())) {
|
||||||
|
selected_file_ = entry.path().string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
ImGui::TextColored(ImVec4(1, 0, 0, 1), "Error: %s", e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndCombo();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Render::SelfHostedServerWindow() {
|
||||||
|
if (show_self_hosted_server_config_window_) {
|
||||||
|
if (self_hosted_server_config_window_pos_reset_) {
|
||||||
|
const ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||||
|
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||||
|
ImGui::SetNextWindowPos(
|
||||||
|
ImVec2((viewport->WorkSize.x - viewport->WorkPos.x -
|
||||||
|
SELF_HOSTED_SERVER_CONFIG_WINDOW_WIDTH_CN) /
|
||||||
|
2,
|
||||||
|
(viewport->WorkSize.y - viewport->WorkPos.y -
|
||||||
|
SELF_HOSTED_SERVER_CONFIG_WINDOW_HEIGHT_CN) /
|
||||||
|
2));
|
||||||
|
|
||||||
|
ImGui::SetNextWindowSize(
|
||||||
|
ImVec2(SELF_HOSTED_SERVER_CONFIG_WINDOW_WIDTH_CN,
|
||||||
|
SELF_HOSTED_SERVER_CONFIG_WINDOW_HEIGHT_CN));
|
||||||
|
} else {
|
||||||
|
ImGui::SetNextWindowPos(
|
||||||
|
ImVec2((viewport->WorkSize.x - viewport->WorkPos.x -
|
||||||
|
SELF_HOSTED_SERVER_CONFIG_WINDOW_WIDTH_EN) /
|
||||||
|
2,
|
||||||
|
(viewport->WorkSize.y - viewport->WorkPos.y -
|
||||||
|
SELF_HOSTED_SERVER_CONFIG_WINDOW_HEIGHT_EN) /
|
||||||
|
2));
|
||||||
|
|
||||||
|
ImGui::SetNextWindowSize(
|
||||||
|
ImVec2(SELF_HOSTED_SERVER_CONFIG_WINDOW_WIDTH_EN,
|
||||||
|
SELF_HOSTED_SERVER_CONFIG_WINDOW_HEIGHT_EN));
|
||||||
|
}
|
||||||
|
|
||||||
|
self_hosted_server_config_window_pos_reset_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
{
|
||||||
|
static int settings_items_padding = 30;
|
||||||
|
int settings_items_offset = 0;
|
||||||
|
|
||||||
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.0f);
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||||
|
|
||||||
|
ImGui::Begin(localization::self_hosted_server_settings
|
||||||
|
[localization_language_index_]
|
||||||
|
.c_str(),
|
||||||
|
nullptr,
|
||||||
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||||
|
ImGuiWindowFlags_NoSavedSettings);
|
||||||
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
|
||||||
|
{
|
||||||
|
settings_items_offset += settings_items_padding;
|
||||||
|
ImGui::SetCursorPosY(settings_items_offset + 2);
|
||||||
|
ImGui::Text("%s", localization::self_hosted_server_address
|
||||||
|
[localization_language_index_]
|
||||||
|
.c_str());
|
||||||
|
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||||
|
ImGui::SetCursorPosX(SELF_HOSTED_SERVER_HOST_INPUT_BOX_PADDING_CN);
|
||||||
|
} else {
|
||||||
|
ImGui::SetCursorPosX(SELF_HOSTED_SERVER_HOST_INPUT_BOX_PADDING_EN);
|
||||||
|
}
|
||||||
|
ImGui::SetCursorPosY(settings_items_offset);
|
||||||
|
ImGui::SetNextItemWidth(SELF_HOSTED_SERVER_INPUT_WINDOW_WIDTH);
|
||||||
|
|
||||||
|
ImGui::InputText("##self_hosted_server_host_", self_hosted_server_host_,
|
||||||
|
IM_ARRAYSIZE(self_hosted_server_host_));
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
{
|
||||||
|
settings_items_offset += settings_items_padding;
|
||||||
|
ImGui::SetCursorPosY(settings_items_offset + 2);
|
||||||
|
ImGui::Text(
|
||||||
|
"%s",
|
||||||
|
localization::self_hosted_server_port[localization_language_index_]
|
||||||
|
.c_str());
|
||||||
|
|
||||||
|
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||||
|
ImGui::SetCursorPosX(SELF_HOSTED_SERVER_PORT_INPUT_BOX_PADDING_CN);
|
||||||
|
} else {
|
||||||
|
ImGui::SetCursorPosX(SELF_HOSTED_SERVER_PORT_INPUT_BOX_PADDING_EN);
|
||||||
|
}
|
||||||
|
ImGui::SetCursorPosY(settings_items_offset);
|
||||||
|
ImGui::SetNextItemWidth(SELF_HOSTED_SERVER_INPUT_WINDOW_WIDTH);
|
||||||
|
|
||||||
|
ImGui::InputText("##self_hosted_server_port_", self_hosted_server_port_,
|
||||||
|
IM_ARRAYSIZE(self_hosted_server_port_));
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
{
|
||||||
|
settings_items_offset += settings_items_padding;
|
||||||
|
ImGui::SetCursorPosY(settings_items_offset + 2);
|
||||||
|
ImGui::Text("%s", localization::self_hosted_server_certificate_path
|
||||||
|
[localization_language_index_]
|
||||||
|
.c_str());
|
||||||
|
|
||||||
|
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||||
|
ImGui::SetCursorPosX(SELF_HOSTED_SERVER_PORT_INPUT_BOX_PADDING_CN);
|
||||||
|
} else {
|
||||||
|
ImGui::SetCursorPosX(SELF_HOSTED_SERVER_PORT_INPUT_BOX_PADDING_EN);
|
||||||
|
}
|
||||||
|
ImGui::SetCursorPosY(settings_items_offset);
|
||||||
|
ImGui::SetNextItemWidth(SELF_HOSTED_SERVER_INPUT_WINDOW_WIDTH);
|
||||||
|
|
||||||
|
ShowSimpleFileBrowser();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stream_window_inited_) {
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||||
|
ImGui::SetCursorPosX(SELF_HOSTED_SERVER_CONFIG_OK_BUTTON_PADDING_CN);
|
||||||
|
} else {
|
||||||
|
ImGui::SetCursorPosX(SELF_HOSTED_SERVER_CONFIG_OK_BUTTON_PADDING_EN);
|
||||||
|
}
|
||||||
|
|
||||||
|
settings_items_offset += settings_items_padding + 10;
|
||||||
|
ImGui::SetCursorPosY(settings_items_offset);
|
||||||
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
|
// OK
|
||||||
|
if (ImGui::Button(
|
||||||
|
localization::ok[localization_language_index_].c_str())) {
|
||||||
|
show_self_hosted_server_config_window_ = false;
|
||||||
|
|
||||||
|
// Language
|
||||||
|
if (language_button_value_ == 0) {
|
||||||
|
config_center_.SetLanguage(ConfigCenter::LANGUAGE::CHINESE);
|
||||||
|
} else {
|
||||||
|
config_center_.SetLanguage(ConfigCenter::LANGUAGE::ENGLISH);
|
||||||
|
}
|
||||||
|
language_button_value_last_ = language_button_value_;
|
||||||
|
localization_language_ = (ConfigCenter::LANGUAGE)language_button_value_;
|
||||||
|
localization_language_index_ = language_button_value_;
|
||||||
|
LOG_INFO("Set localization language: {}",
|
||||||
|
localization_language_index_ == 0 ? "zh" : "en");
|
||||||
|
|
||||||
|
// Video quality
|
||||||
|
if (video_quality_button_value_ == 0) {
|
||||||
|
config_center_.SetVideoQuality(ConfigCenter::VIDEO_QUALITY::HIGH);
|
||||||
|
} else if (video_quality_button_value_ == 1) {
|
||||||
|
config_center_.SetVideoQuality(ConfigCenter::VIDEO_QUALITY::MEDIUM);
|
||||||
|
} else {
|
||||||
|
config_center_.SetVideoQuality(ConfigCenter::VIDEO_QUALITY::LOW);
|
||||||
|
}
|
||||||
|
video_quality_button_value_last_ = video_quality_button_value_;
|
||||||
|
|
||||||
|
// Video encode format
|
||||||
|
if (video_encode_format_button_value_ == 0) {
|
||||||
|
config_center_.SetVideoEncodeFormat(
|
||||||
|
ConfigCenter::VIDEO_ENCODE_FORMAT::AV1);
|
||||||
|
} else if (video_encode_format_button_value_ == 1) {
|
||||||
|
config_center_.SetVideoEncodeFormat(
|
||||||
|
ConfigCenter::VIDEO_ENCODE_FORMAT::H264);
|
||||||
|
}
|
||||||
|
video_encode_format_button_value_last_ =
|
||||||
|
video_encode_format_button_value_;
|
||||||
|
|
||||||
|
// Hardware video codec
|
||||||
|
if (enable_hardware_video_codec_) {
|
||||||
|
config_center_.SetHardwareVideoCodec(true);
|
||||||
|
} else {
|
||||||
|
config_center_.SetHardwareVideoCodec(false);
|
||||||
|
}
|
||||||
|
enable_hardware_video_codec_last_ = enable_hardware_video_codec_;
|
||||||
|
|
||||||
|
// TURN mode
|
||||||
|
if (enable_turn_) {
|
||||||
|
config_center_.SetTurn(true);
|
||||||
|
} else {
|
||||||
|
config_center_.SetTurn(false);
|
||||||
|
}
|
||||||
|
enable_turn_last_ = enable_turn_;
|
||||||
|
|
||||||
|
// SRTP
|
||||||
|
if (enable_srtp_) {
|
||||||
|
config_center_.SetSrtp(true);
|
||||||
|
} else {
|
||||||
|
config_center_.SetSrtp(false);
|
||||||
|
}
|
||||||
|
enable_srtp_last_ = enable_srtp_;
|
||||||
|
|
||||||
|
SaveSettingsIntoCacheFile();
|
||||||
|
self_hosted_server_config_window_pos_reset_ = true;
|
||||||
|
|
||||||
|
// Recreate peer instance
|
||||||
|
LoadSettingsFromCacheFile();
|
||||||
|
|
||||||
|
// Recreate peer instance
|
||||||
|
if (!stream_window_inited_) {
|
||||||
|
LOG_INFO("Recreate peer instance");
|
||||||
|
CleanupPeers();
|
||||||
|
CreateConnectionPeer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
// Cancel
|
||||||
|
if (ImGui::Button(
|
||||||
|
localization::cancel[localization_language_index_].c_str())) {
|
||||||
|
show_self_hosted_server_config_window_ = false;
|
||||||
|
if (language_button_value_ != language_button_value_last_) {
|
||||||
|
language_button_value_ = language_button_value_last_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (video_quality_button_value_ != video_quality_button_value_last_) {
|
||||||
|
video_quality_button_value_ = video_quality_button_value_last_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (video_encode_format_button_value_ !=
|
||||||
|
video_encode_format_button_value_last_) {
|
||||||
|
video_encode_format_button_value_ =
|
||||||
|
video_encode_format_button_value_last_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enable_hardware_video_codec_ != enable_hardware_video_codec_last_) {
|
||||||
|
enable_hardware_video_codec_ = enable_hardware_video_codec_last_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enable_turn_ != enable_turn_last_) {
|
||||||
|
enable_turn_ = enable_turn_last_;
|
||||||
|
}
|
||||||
|
|
||||||
|
self_hosted_server_config_window_pos_reset_ = true;
|
||||||
|
}
|
||||||
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
|
ImGui::End();
|
||||||
|
ImGui::PopStyleVar(2);
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -220,7 +220,7 @@ int Render::SettingWindow() {
|
|||||||
if (ImGui::Button(localization::self_hosted_server_config
|
if (ImGui::Button(localization::self_hosted_server_config
|
||||||
[localization_language_index_]
|
[localization_language_index_]
|
||||||
.c_str())) {
|
.c_str())) {
|
||||||
LOG_ERROR("Self Built Server");
|
show_self_hosted_server_config_window_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||||
@@ -243,7 +243,7 @@ int Render::SettingWindow() {
|
|||||||
ImGui::SetCursorPosX(SETTINGS_OK_BUTTON_PADDING_EN);
|
ImGui::SetCursorPosX(SETTINGS_OK_BUTTON_PADDING_EN);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings_items_offset += settings_items_padding;
|
settings_items_offset += settings_items_padding + 10;
|
||||||
ImGui::SetCursorPosY(settings_items_offset);
|
ImGui::SetCursorPosY(settings_items_offset);
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
@@ -251,6 +251,7 @@ int Render::SettingWindow() {
|
|||||||
if (ImGui::Button(
|
if (ImGui::Button(
|
||||||
localization::ok[localization_language_index_].c_str())) {
|
localization::ok[localization_language_index_].c_str())) {
|
||||||
show_settings_window_ = false;
|
show_settings_window_ = false;
|
||||||
|
show_self_hosted_server_config_window_ = false;
|
||||||
|
|
||||||
// Language
|
// Language
|
||||||
if (language_button_value_ == 0) {
|
if (language_button_value_ == 0) {
|
||||||
@@ -328,6 +329,8 @@ int Render::SettingWindow() {
|
|||||||
if (ImGui::Button(
|
if (ImGui::Button(
|
||||||
localization::cancel[localization_language_index_].c_str())) {
|
localization::cancel[localization_language_index_].c_str())) {
|
||||||
show_settings_window_ = false;
|
show_settings_window_ = false;
|
||||||
|
show_self_hosted_server_config_window_ = false;
|
||||||
|
|
||||||
if (language_button_value_ != language_button_value_last_) {
|
if (language_button_value_ != language_button_value_last_) {
|
||||||
language_button_value_ = language_button_value_last_;
|
language_button_value_ = language_button_value_last_;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ int Render::TitleBar(bool main_window) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
SettingWindow();
|
SettingWindow();
|
||||||
|
SelfHostedServerWindow();
|
||||||
AboutWindow();
|
AboutWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user