mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-12-17 04:26:47 +08:00
Compare commits
7 Commits
v1.0.2-bet
...
self-hoste
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bd5b002d1 | ||
|
|
2f83301de7 | ||
|
|
c8152b5cbf | ||
|
|
b1df10c0de | ||
|
|
b78c9cf7d1 | ||
|
|
b3132db785 | ||
|
|
43db021326 |
19
.github/workflows/build.yml
vendored
19
.github/workflows/build.yml
vendored
@@ -292,7 +292,7 @@ jobs:
|
||||
run: |
|
||||
xmake f --CROSSDESK_VERSION=${{ env.VERSION_NUM }} -y
|
||||
xmake b -vy crossdesk
|
||||
|
||||
|
||||
- name: Decode and save certificate
|
||||
shell: powershell
|
||||
run: |
|
||||
@@ -385,3 +385,20 @@ jobs:
|
||||
remote_host: ${{ secrets.SERVER_HOST }}
|
||||
remote_user: ${{ secrets.SERVER_USER }}
|
||||
remote_key: ${{ secrets.SERVER_KEY }}
|
||||
|
||||
- name: Generate version.json
|
||||
run: |
|
||||
echo "{" > version.json
|
||||
echo " \"latest_version\": \"${{ steps.version.outputs.VERSION_NUM }}\"" >> version.json
|
||||
echo "}" >> version.json
|
||||
cat version.json
|
||||
|
||||
- name: Upload version.json to server
|
||||
uses: burnett01/rsync-deployments@5.2
|
||||
with:
|
||||
switches: -avzr --delete
|
||||
path: version.json
|
||||
remote_path: /var/www/html/version/
|
||||
remote_host: ${{ secrets.SERVER_HOST }}
|
||||
remote_user: ${{ secrets.SERVER_USER }}
|
||||
remote_key: ${{ secrets.SERVER_KEY }}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifdef _WIN32
|
||||
#ifdef DESK_PORT_DEBUG
|
||||
#ifdef CROSSDESK_DEBUG
|
||||
#pragma comment(linker, "/subsystem:\"console\"")
|
||||
#else
|
||||
#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
|
||||
|
||||
@@ -181,8 +181,9 @@ int ConfigCenter::SetServerPort(int signal_server_port) {
|
||||
|
||||
int ConfigCenter::SetCoturnServerPort(int coturn_server_port) {
|
||||
coturn_server_port_ = coturn_server_port;
|
||||
SI_Error rc = ini_.SetLongValue(section_, "coturn_server_port",
|
||||
static_cast<long>(coturn_server_port_));
|
||||
ini_.SetLongValue(section_, "coturn_server_port",
|
||||
static_cast<long>(coturn_server_port_));
|
||||
SI_Error rc = ini_.SaveFile(config_path_.c_str());
|
||||
if (rc < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -201,6 +202,7 @@ int ConfigCenter::SetCertFilePath(const std::string& cert_file_path) {
|
||||
|
||||
int ConfigCenter::SetSelfHosted(bool enable_self_hosted) {
|
||||
enable_self_hosted_ = enable_self_hosted;
|
||||
ini_.SetBoolValue(section_, "enable_self_hosted", enable_self_hosted_);
|
||||
SI_Error rc = ini_.SaveFile(config_path_.c_str());
|
||||
if (rc < 0) {
|
||||
return -1;
|
||||
@@ -210,6 +212,12 @@ int ConfigCenter::SetSelfHosted(bool enable_self_hosted) {
|
||||
|
||||
int ConfigCenter::SetMinimizeToTray(bool enable_minimize_to_tray) {
|
||||
enable_minimize_to_tray_ = enable_minimize_to_tray;
|
||||
ini_.SetBoolValue(section_, "enable_minimize_to_tray",
|
||||
enable_minimize_to_tray_);
|
||||
SI_Error rc = ini_.SaveFile(config_path_.c_str());
|
||||
if (rc < 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,6 +145,10 @@ int Render::ConnectTo(const std::string& remote_id, const char* password,
|
||||
memcpy(&props->params_, ¶ms_, sizeof(Params));
|
||||
props->params_.user_id = props->local_id_.c_str();
|
||||
props->peer_ = CreatePeer(&props->params_);
|
||||
|
||||
for (auto& display_info : display_info_list_) {
|
||||
AddVideoStream(peer_, display_info.name.c_str());
|
||||
}
|
||||
AddAudioStream(props->peer_, props->audio_label_.c_str());
|
||||
AddDataStream(props->peer_, props->data_label_.c_str());
|
||||
|
||||
|
||||
@@ -258,6 +258,7 @@ int Render::LoadSettingsFromCacheFile() {
|
||||
enable_hardware_video_codec_ = config_center_->IsHardwareVideoCodec();
|
||||
enable_turn_ = config_center_->IsEnableTurn();
|
||||
enable_srtp_ = config_center_->IsEnableSrtp();
|
||||
enable_self_hosted_ = config_center_->IsSelfHosted();
|
||||
|
||||
language_button_value_last_ = language_button_value_;
|
||||
video_quality_button_value_last_ = video_quality_button_value_;
|
||||
@@ -265,6 +266,7 @@ int Render::LoadSettingsFromCacheFile() {
|
||||
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_;
|
||||
|
||||
LOG_INFO("Load settings from cache file");
|
||||
|
||||
|
||||
@@ -445,13 +445,15 @@ class Render {
|
||||
char signal_server_port_[6] = "9099";
|
||||
char coturn_server_port_[6] = "3478";
|
||||
char cert_file_path_[256] = "";
|
||||
bool enable_self_hosted_server_ = false;
|
||||
bool enable_self_hosted_ = false;
|
||||
int language_button_value_last_ = 0;
|
||||
int video_quality_button_value_last_ = 0;
|
||||
int video_frame_rate_button_value_last_ = 0;
|
||||
int video_encode_format_button_value_last_ = 0;
|
||||
bool enable_hardware_video_codec_last_ = false;
|
||||
bool enable_turn_last_ = false;
|
||||
bool enable_srtp_last_ = false;
|
||||
bool enable_self_hosted_last_ = false;
|
||||
bool enable_minimize_to_tray_ = false;
|
||||
bool enable_minimize_to_tray_last_ = false;
|
||||
char signal_server_ip_self_[256] = "";
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define NV12_BUFFER_SIZE 1280 * 720 * 3 / 2
|
||||
|
||||
#ifdef DESK_PORT_DEBUG
|
||||
#ifdef CROSSDESK_DEBUG
|
||||
#else
|
||||
#define MOUSE_CONTROL 1
|
||||
#endif
|
||||
|
||||
@@ -231,8 +231,7 @@ int Render::SettingWindow() {
|
||||
ImGui::SetCursorPosX(ENABLE_SELF_HOSTED_SERVER_CHECKBOX_PADDING_EN);
|
||||
}
|
||||
ImGui::SetCursorPosY(settings_items_offset);
|
||||
ImGui::Checkbox("##enable_self_hosted_server",
|
||||
&enable_self_hosted_server_);
|
||||
ImGui::Checkbox("##enable_self_hosted", &enable_self_hosted_);
|
||||
}
|
||||
#if _WIN32
|
||||
ImGui::Separator();
|
||||
@@ -289,14 +288,23 @@ int Render::SettingWindow() {
|
||||
|
||||
// Video quality
|
||||
if (video_quality_button_value_ == 0) {
|
||||
config_center_->SetVideoQuality(ConfigCenter::VIDEO_QUALITY::HIGH);
|
||||
config_center_->SetVideoQuality(ConfigCenter::VIDEO_QUALITY::LOW);
|
||||
} else if (video_quality_button_value_ == 1) {
|
||||
config_center_->SetVideoQuality(ConfigCenter::VIDEO_QUALITY::MEDIUM);
|
||||
} else {
|
||||
config_center_->SetVideoQuality(ConfigCenter::VIDEO_QUALITY::LOW);
|
||||
config_center_->SetVideoQuality(ConfigCenter::VIDEO_QUALITY::HIGH);
|
||||
}
|
||||
video_quality_button_value_last_ = video_quality_button_value_;
|
||||
|
||||
if (video_frame_rate_button_value_ == 0) {
|
||||
config_center_->SetVideoFrameRate(
|
||||
ConfigCenter::VIDEO_FRAME_RATE::FPS_30);
|
||||
} else if (video_frame_rate_button_value_ == 1) {
|
||||
config_center_->SetVideoFrameRate(
|
||||
ConfigCenter::VIDEO_FRAME_RATE::FPS_60);
|
||||
}
|
||||
video_frame_rate_button_value_last_ = video_frame_rate_button_value_;
|
||||
|
||||
// Video encode format
|
||||
if (video_encode_format_button_value_ == 0) {
|
||||
config_center_->SetVideoEncodeFormat(
|
||||
@@ -332,11 +340,12 @@ int Render::SettingWindow() {
|
||||
}
|
||||
enable_srtp_last_ = enable_srtp_;
|
||||
|
||||
if (enable_self_hosted_server_) {
|
||||
if (enable_self_hosted_) {
|
||||
config_center_->SetSelfHosted(true);
|
||||
} else {
|
||||
config_center_->SetSelfHosted(false);
|
||||
}
|
||||
enable_self_hosted_last_ = enable_self_hosted_;
|
||||
|
||||
settings_window_pos_reset_ = true;
|
||||
|
||||
@@ -366,6 +375,11 @@ int Render::SettingWindow() {
|
||||
video_quality_button_value_ = video_quality_button_value_last_;
|
||||
}
|
||||
|
||||
if (video_frame_rate_button_value_ !=
|
||||
video_frame_rate_button_value_last_) {
|
||||
video_frame_rate_button_value_ = video_frame_rate_button_value_last_;
|
||||
}
|
||||
|
||||
if (video_encode_format_button_value_ !=
|
||||
video_encode_format_button_value_last_) {
|
||||
video_encode_format_button_value_ =
|
||||
|
||||
@@ -18,7 +18,11 @@ std::filesystem::path PathManager::GetConfigPath() {
|
||||
|
||||
std::filesystem::path PathManager::GetCachePath() {
|
||||
#ifdef _WIN32
|
||||
#ifdef CROSSDESK_DEBUG
|
||||
return "cache";
|
||||
#else
|
||||
return GetKnownFolder(FOLDERID_LocalAppData) / app_name_ / "cache";
|
||||
#endif
|
||||
#elif __APPLE__
|
||||
return GetEnvOrDefault("XDG_CACHE_HOME", GetHome() + "/.cache") / app_name_;
|
||||
#else
|
||||
@@ -72,22 +76,34 @@ std::filesystem::path PathManager::GetKnownFolder(REFKNOWNFOLDERID id) {
|
||||
#endif
|
||||
|
||||
std::string PathManager::GetHome() {
|
||||
if (const char* home = getenv("HOME")) {
|
||||
return std::string(home);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
char path[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_PROFILE, NULL, 0, path)))
|
||||
return std::string(path);
|
||||
#else
|
||||
if (const char* home = getenv("HOME")) {
|
||||
return std::string(home);
|
||||
}
|
||||
#endif
|
||||
return {};
|
||||
}
|
||||
|
||||
std::filesystem::path PathManager::GetEnvOrDefault(const char* env_var,
|
||||
const std::string& def) {
|
||||
#ifdef _WIN32
|
||||
char* buffer = nullptr;
|
||||
size_t size = 0;
|
||||
|
||||
if (_dupenv_s(&buffer, &size, env_var) == 0 && buffer != nullptr) {
|
||||
std::filesystem::path result(buffer);
|
||||
free(buffer);
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
if (const char* val = getenv(env_var)) {
|
||||
return std::filesystem::path(val);
|
||||
}
|
||||
#endif
|
||||
|
||||
return std::filesystem::path(def);
|
||||
}
|
||||
|
||||
@@ -14,33 +14,42 @@ namespace crossdesk {
|
||||
|
||||
static std::vector<DisplayInfo> gs_display_list;
|
||||
|
||||
std::string WideToUtf8(const wchar_t* wideStr) {
|
||||
int size_needed = WideCharToMultiByte(CP_UTF8, 0, wideStr, -1, nullptr, 0,
|
||||
nullptr, nullptr);
|
||||
std::string WideToUtf8(const std::wstring& wstr) {
|
||||
if (wstr.empty()) return {};
|
||||
int size_needed = WideCharToMultiByte(
|
||||
CP_UTF8, 0, wstr.data(), (int)wstr.size(), nullptr, 0, nullptr, nullptr);
|
||||
std::string result(size_needed, 0);
|
||||
WideCharToMultiByte(CP_UTF8, 0, wideStr, -1, &result[0], size_needed, nullptr,
|
||||
nullptr);
|
||||
result.pop_back();
|
||||
WideCharToMultiByte(CP_UTF8, 0, wstr.data(), (int)wstr.size(), result.data(),
|
||||
size_needed, nullptr, nullptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string CleanDisplayName(const std::wstring& wide_name) {
|
||||
std::string name = WideToUtf8(wide_name);
|
||||
name.erase(std::remove_if(name.begin(), name.end(),
|
||||
[](unsigned char c) { return !std::isalnum(c); }),
|
||||
name.end());
|
||||
return name;
|
||||
}
|
||||
|
||||
BOOL WINAPI EnumMonitorProc(HMONITOR hmonitor, [[maybe_unused]] HDC hdc,
|
||||
[[maybe_unused]] LPRECT lprc, LPARAM data) {
|
||||
MONITORINFOEX monitor_info_;
|
||||
monitor_info_.cbSize = sizeof(MONITORINFOEX);
|
||||
|
||||
if (GetMonitorInfo(hmonitor, &monitor_info_)) {
|
||||
std::string display_name = CleanDisplayName(monitor_info_.szDevice);
|
||||
if (monitor_info_.dwFlags & MONITORINFOF_PRIMARY) {
|
||||
gs_display_list.insert(
|
||||
gs_display_list.begin(),
|
||||
{(void*)hmonitor, WideToUtf8(monitor_info_.szDevice),
|
||||
{(void*)hmonitor, display_name,
|
||||
(monitor_info_.dwFlags & MONITORINFOF_PRIMARY) ? true : false,
|
||||
monitor_info_.rcMonitor.left, monitor_info_.rcMonitor.top,
|
||||
monitor_info_.rcMonitor.right, monitor_info_.rcMonitor.bottom});
|
||||
*(HMONITOR*)data = hmonitor;
|
||||
} else {
|
||||
gs_display_list.push_back(DisplayInfo(
|
||||
(void*)hmonitor, WideToUtf8(monitor_info_.szDevice),
|
||||
(void*)hmonitor, display_name,
|
||||
(monitor_info_.dwFlags & MONITORINFOF_PRIMARY) ? true : false,
|
||||
monitor_info_.rcMonitor.left, monitor_info_.rcMonitor.top,
|
||||
monitor_info_.rcMonitor.right, monitor_info_.rcMonitor.bottom));
|
||||
|
||||
@@ -118,13 +118,13 @@ void ScaleNv12ToABGR(char* src, int src_w, int src_h, int dst_w, int dst_h,
|
||||
|
||||
memset(dst_rgba, 0, dst_w * dst_h * 4);
|
||||
for (int i = 0; i < dst_w * dst_h; ++i) {
|
||||
dst_rgba[i * 4 + 3] = 0xFF;
|
||||
dst_rgba[i * 4 + 3] = static_cast<char>(0xFF);
|
||||
}
|
||||
|
||||
for (int y = 0; y < fit_h; ++y) {
|
||||
for (int row = 0; row < fit_h; ++row) {
|
||||
int dst_offset =
|
||||
((y + (dst_h - fit_h) / 2) * dst_w + (dst_w - fit_w) / 2) * 4;
|
||||
memcpy(dst_rgba + dst_offset, abgr.data() + y * fit_w * 4, fit_w * 4);
|
||||
((row + (dst_h - fit_h) / 2) * dst_w + (dst_w - fit_w) / 2) * 4;
|
||||
memcpy(dst_rgba + dst_offset, abgr.data() + row * fit_w * 4, fit_w * 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ int Thumbnail::SaveToThumbnail(const char* yuv420p, int width, int height,
|
||||
memset(rgba_buffer_, 0x00, thumbnail_width_ * thumbnail_height_ * 4);
|
||||
for (int i = 0; i < thumbnail_width_ * thumbnail_height_; ++i) {
|
||||
// Set alpha channel to opaque
|
||||
rgba_buffer_[i * 4 + 3] = 0xFF;
|
||||
rgba_buffer_[i * 4 + 3] = static_cast<char>(0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ int Thumbnail::LoadThumbnail(
|
||||
return -1;
|
||||
} else {
|
||||
for (int i = 0; i < image_paths.size(); i++) {
|
||||
size_t pos1 = image_paths[i].string().find('/') + 1;
|
||||
// size_t pos1 = image_paths[i].string().find('/') + 1;
|
||||
std::string cipher_image_name = image_paths[i].filename().string();
|
||||
std::string remote_id;
|
||||
std::string cipher_password;
|
||||
@@ -241,7 +241,7 @@ int Thumbnail::LoadThumbnail(
|
||||
AES_decrypt(cipher_password, aes128_key_, aes128_iv_);
|
||||
} else {
|
||||
size_t pos_n = cipher_image_name.find('N');
|
||||
size_t pos_at = cipher_image_name.find('@');
|
||||
// size_t pos_at = cipher_image_name.find('@');
|
||||
|
||||
if (pos_n == std::string::npos) {
|
||||
LOG_ERROR("Invalid filename");
|
||||
|
||||
Submodule submodules/minirtc updated: 40eaf93b42...1f999dbe1f
@@ -13,10 +13,11 @@ set_encodings("utf-8")
|
||||
|
||||
-- set_policy("build.warning", true)
|
||||
-- set_warnings("all", "extra")
|
||||
-- add_cxxflags("/W4", "/WX")
|
||||
|
||||
add_defines("UNICODE")
|
||||
if is_mode("debug") then
|
||||
add_defines("DESK_PORT_DEBUG")
|
||||
add_defines("CROSSDESK_DEBUG")
|
||||
end
|
||||
|
||||
add_requires("spdlog 1.14.1", {system = false})
|
||||
|
||||
Reference in New Issue
Block a user