mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[fix] fix all unused variables and type conversions
This commit is contained in:
@@ -25,13 +25,13 @@ std::string GetMac() {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
IP_ADAPTER_INFO adapterInfo[16];
|
IP_ADAPTER_INFO adapterInfo[16];
|
||||||
DWORD bufferSize = sizeof(adapterInfo);
|
DWORD bufferSize = sizeof(adapterInfo);
|
||||||
|
|
||||||
DWORD result = GetAdaptersInfo(adapterInfo, &bufferSize);
|
DWORD result = GetAdaptersInfo(adapterInfo, &bufferSize);
|
||||||
if (result == ERROR_SUCCESS) {
|
if (result == ERROR_SUCCESS) {
|
||||||
PIP_ADAPTER_INFO adapter = adapterInfo;
|
PIP_ADAPTER_INFO adapter = adapterInfo;
|
||||||
while (adapter) {
|
while (adapter) {
|
||||||
for (UINT i = 0; i < adapter->AddressLength; i++) {
|
for (UINT i = 0; i < adapter->AddressLength; i++) {
|
||||||
len += sprintf(mac_addr + len, "%.2X", adapter->Address[i]);
|
len += sprintf_s(mac_addr + len, sizeof(mac_addr) - len, "%.2X",
|
||||||
|
adapter->Address[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ int KeyboardCapturer::Unhook() {
|
|||||||
int KeyboardCapturer::SendKeyboardCommand(int key_code, bool is_down) {
|
int KeyboardCapturer::SendKeyboardCommand(int key_code, bool is_down) {
|
||||||
INPUT input = {0};
|
INPUT input = {0};
|
||||||
input.type = INPUT_KEYBOARD;
|
input.type = INPUT_KEYBOARD;
|
||||||
input.ki.wVk = key_code;
|
input.ki.wVk = (WORD)key_code;
|
||||||
|
|
||||||
if (!is_down) {
|
if (!is_down) {
|
||||||
input.ki.dwFlags = KEYEVENTF_KEYUP;
|
input.ki.dwFlags = KEYEVENTF_KEYUP;
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ int MouseController::SendCommand(RemoteAction remote_action) {
|
|||||||
|
|
||||||
if (remote_action.type == ControlType::mouse) {
|
if (remote_action.type == ControlType::mouse) {
|
||||||
ip.type = INPUT_MOUSE;
|
ip.type = INPUT_MOUSE;
|
||||||
ip.mi.dx = remote_action.m.x;
|
ip.mi.dx = (LONG)remote_action.m.x;
|
||||||
ip.mi.dy = remote_action.m.y;
|
ip.mi.dy = (LONG)remote_action.m.y;
|
||||||
if (remote_action.m.flag == MouseFlag::left_down) {
|
if (remote_action.m.flag == MouseFlag::left_down) {
|
||||||
ip.mi.dwFlags = MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE;
|
ip.mi.dwFlags = MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE;
|
||||||
} else if (remote_action.m.flag == MouseFlag::left_up) {
|
} else if (remote_action.m.flag == MouseFlag::left_up) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "rd_log.h"
|
#include "rd_log.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main([[maybe_unused]] int argc, [[maybe_unused]] char *argv[]) {
|
||||||
LOG_INFO("Remote desk");
|
LOG_INFO("Remote desk");
|
||||||
Render render;
|
Render render;
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,20 @@ std::shared_ptr<spdlog::logger> get_logger() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto now = std::chrono::system_clock::now() + std::chrono::hours(8);
|
auto now = std::chrono::system_clock::now() + std::chrono::hours(8);
|
||||||
auto timet = std::chrono::system_clock::to_time_t(now);
|
auto now_time = std::chrono::system_clock::to_time_t(now);
|
||||||
auto localTime = *std::gmtime(&timet);
|
|
||||||
|
std::tm tm_info;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
gmtime_s(&tm_info, &now_time);
|
||||||
|
#else
|
||||||
|
gmtime_r(&now_time, &tm_info);
|
||||||
|
#endif
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
ss << LOGGER_NAME;
|
ss << LOGGER_NAME;
|
||||||
ss << std::put_time(&localTime, "-%Y%m%d-%H%M%S.log");
|
ss << std::put_time(&tm_info, "-%Y%m%d-%H%M%S.log");
|
||||||
ss >> filename;
|
ss >> filename;
|
||||||
|
|
||||||
std::string path = "logs/" + filename;
|
std::string path = "logs/" + filename;
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
#include "libyuv.h"
|
#include "libyuv.h"
|
||||||
|
|
||||||
BOOL WINAPI EnumMonitorProc(HMONITOR hmonitor, HDC hdc, LPRECT lprc,
|
BOOL WINAPI EnumMonitorProc(HMONITOR hmonitor, [[maybe_unused]] HDC hdc,
|
||||||
LPARAM data) {
|
[[maybe_unused]] LPRECT lprc, LPARAM data) {
|
||||||
MONITORINFOEX info_ex;
|
MONITORINFOEX info_ex;
|
||||||
info_ex.cbSize = sizeof(MONITORINFOEX);
|
info_ex.cbSize = sizeof(MONITORINFOEX);
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ auto WgcSessionImpl::CreateD3D11Device() {
|
|||||||
|
|
||||||
if (DXGI_ERROR_UNSUPPORTED == hr) {
|
if (DXGI_ERROR_UNSUPPORTED == hr) {
|
||||||
// change D3D_DRIVER_TYPE
|
// change D3D_DRIVER_TYPE
|
||||||
D3D_DRIVER_TYPE type = D3D_DRIVER_TYPE_WARP;
|
type = D3D_DRIVER_TYPE_WARP;
|
||||||
hr = D3D11CreateDevice(nullptr, type, nullptr, flags, nullptr, 0,
|
hr = D3D11CreateDevice(nullptr, type, nullptr, flags, nullptr, 0,
|
||||||
D3D11_SDK_VERSION, d3d_device.put(), nullptr,
|
D3D11_SDK_VERSION, d3d_device.put(), nullptr,
|
||||||
nullptr);
|
nullptr);
|
||||||
@@ -213,7 +213,7 @@ HRESULT WgcSessionImpl::CreateMappedTexture(
|
|||||||
|
|
||||||
void WgcSessionImpl::OnFrame(
|
void WgcSessionImpl::OnFrame(
|
||||||
winrt::Windows::Graphics::Capture::Direct3D11CaptureFramePool const &sender,
|
winrt::Windows::Graphics::Capture::Direct3D11CaptureFramePool const &sender,
|
||||||
winrt::Windows::Foundation::IInspectable const &args) {
|
[[maybe_unused]] winrt::Windows::Foundation::IInspectable const &args) {
|
||||||
std::lock_guard locker(lock_);
|
std::lock_guard locker(lock_);
|
||||||
|
|
||||||
auto is_new_size = false;
|
auto is_new_size = false;
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
#include "rd_log.h"
|
#include "rd_log.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
int CountDigits(int number) {
|
int CountDigits(uint64_t number) {
|
||||||
if (number == 0) return 1;
|
if (number == 0) return 1;
|
||||||
return std::floor(std::log10(std::abs(number))) + 1;
|
return (int)std::floor(std::log10(std::abs((int)number))) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BitrateDisplay(uint64_t bitrate) {
|
int BitrateDisplay(uint64_t bitrate) {
|
||||||
@@ -192,7 +192,7 @@ int Render::ControlBar() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (net_traffic_stats_button_pressed_ && control_bar_expand_) {
|
if (net_traffic_stats_button_pressed_ && control_bar_expand_) {
|
||||||
NetTrafficStats(mouse_button_pos);
|
NetTrafficStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
@@ -200,7 +200,7 @@ int Render::ControlBar() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Render::NetTrafficStats(ImVec2 mouse_button_pos) {
|
int Render::NetTrafficStats() {
|
||||||
ImGui::SetCursorPos(ImVec2(
|
ImGui::SetCursorPos(ImVec2(
|
||||||
is_control_bar_in_left_ ? (control_window_width_ + 5.0f) : 5.0f, 40.0f));
|
is_control_bar_in_left_ ? (control_window_width_ + 5.0f) : 5.0f, 40.0f));
|
||||||
|
|
||||||
|
|||||||
@@ -2,18 +2,18 @@
|
|||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
int Render::ControlWindow() {
|
int Render::ControlWindow() {
|
||||||
auto time_duration = ImGui::GetTime() - control_bar_button_pressed_time_;
|
double time_duration = ImGui::GetTime() - control_bar_button_pressed_time_;
|
||||||
if (control_window_width_is_changing_) {
|
if (control_window_width_is_changing_) {
|
||||||
if (control_bar_expand_) {
|
if (control_bar_expand_) {
|
||||||
control_window_width_ =
|
control_window_width_ =
|
||||||
control_window_min_width_ +
|
(float)(control_window_min_width_ +
|
||||||
(control_window_max_width_ - control_window_min_width_) * 4 *
|
(control_window_max_width_ - control_window_min_width_) * 4 *
|
||||||
time_duration;
|
time_duration);
|
||||||
} else {
|
} else {
|
||||||
control_window_width_ =
|
control_window_width_ =
|
||||||
control_window_max_width_ -
|
(float)(control_window_max_width_ -
|
||||||
(control_window_max_width_ - control_window_min_width_) * 4 *
|
(control_window_max_width_ - control_window_min_width_) * 4 *
|
||||||
time_duration;
|
time_duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,14 +21,14 @@ int Render::ControlWindow() {
|
|||||||
if (control_window_height_is_changing_) {
|
if (control_window_height_is_changing_) {
|
||||||
if (control_bar_expand_ && net_traffic_stats_button_pressed_) {
|
if (control_bar_expand_ && net_traffic_stats_button_pressed_) {
|
||||||
control_window_height_ =
|
control_window_height_ =
|
||||||
control_window_min_height_ +
|
(float)(control_window_min_height_ +
|
||||||
(control_window_max_height_ - control_window_min_height_) * 4 *
|
(control_window_max_height_ - control_window_min_height_) *
|
||||||
time_duration;
|
4 * time_duration);
|
||||||
} else if (control_bar_expand_ && !net_traffic_stats_button_pressed_) {
|
} else if (control_bar_expand_ && !net_traffic_stats_button_pressed_) {
|
||||||
control_window_height_ =
|
control_window_height_ =
|
||||||
control_window_max_height_ -
|
(float)(control_window_max_height_ -
|
||||||
(control_window_max_height_ - control_window_min_height_) * 4 *
|
(control_window_max_height_ - control_window_min_height_) *
|
||||||
time_duration;
|
4 * time_duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ int Render::ControlWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (reset_control_bar_pos_) {
|
if (reset_control_bar_pos_) {
|
||||||
int new_control_window_pos_x, new_control_window_pos_y, new_cursor_pos_x,
|
float new_control_window_pos_x, new_control_window_pos_y, new_cursor_pos_x,
|
||||||
new_cursor_pos_y;
|
new_cursor_pos_y;
|
||||||
|
|
||||||
// set control window pos
|
// set control window pos
|
||||||
@@ -94,15 +94,16 @@ int Render::ControlWindow() {
|
|||||||
|
|
||||||
if (0 != mouse_diff_control_bar_pos_x_ &&
|
if (0 != mouse_diff_control_bar_pos_x_ &&
|
||||||
0 != mouse_diff_control_bar_pos_y_) {
|
0 != mouse_diff_control_bar_pos_y_) {
|
||||||
SDL_WarpMouseInWindow(stream_window_, new_cursor_pos_x, new_cursor_pos_y);
|
SDL_WarpMouseInWindow(stream_window_, (int)new_cursor_pos_x,
|
||||||
|
(int)new_cursor_pos_y);
|
||||||
}
|
}
|
||||||
reset_control_bar_pos_ = false;
|
reset_control_bar_pos_ = false;
|
||||||
} else if (!reset_control_bar_pos_ &&
|
} else if (!reset_control_bar_pos_ &&
|
||||||
ImGui::IsMouseReleased(ImGuiPopupFlags_MouseButtonLeft) ||
|
ImGui::IsMouseReleased(ImGuiPopupFlags_MouseButtonLeft) ||
|
||||||
control_window_width_is_changing_) {
|
control_window_width_is_changing_) {
|
||||||
if (control_winodw_pos_.x <= stream_window_width_ / 2) {
|
if (control_winodw_pos_.x <= stream_window_width_ / 2) {
|
||||||
int pos_x = 0;
|
float pos_x = 0;
|
||||||
int pos_y =
|
float pos_y =
|
||||||
(control_winodw_pos_.y >=
|
(control_winodw_pos_.y >=
|
||||||
(fullscreen_button_pressed_ ? 0 : (title_bar_height_ + 1)) &&
|
(fullscreen_button_pressed_ ? 0 : (title_bar_height_ + 1)) &&
|
||||||
control_winodw_pos_.y <=
|
control_winodw_pos_.y <=
|
||||||
@@ -133,8 +134,8 @@ int Render::ControlWindow() {
|
|||||||
ImGui::SetNextWindowPos(ImVec2(pos_x, pos_y), ImGuiCond_Always);
|
ImGui::SetNextWindowPos(ImVec2(pos_x, pos_y), ImGuiCond_Always);
|
||||||
is_control_bar_in_left_ = true;
|
is_control_bar_in_left_ = true;
|
||||||
} else if (control_winodw_pos_.x > stream_window_width_ / 2) {
|
} else if (control_winodw_pos_.x > stream_window_width_ / 2) {
|
||||||
int pos_x = 0;
|
float pos_x = 0;
|
||||||
int pos_y =
|
float pos_y =
|
||||||
(control_winodw_pos_.y >=
|
(control_winodw_pos_.y >=
|
||||||
(fullscreen_button_pressed_ ? 0 : (title_bar_height_ + 1)) &&
|
(fullscreen_button_pressed_ ? 0 : (title_bar_height_ + 1)) &&
|
||||||
control_winodw_pos_.y <=
|
control_winodw_pos_.y <=
|
||||||
@@ -195,7 +196,7 @@ int Render::ControlWindow() {
|
|||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
control_winodw_pos_ = ImGui::GetWindowPos();
|
control_winodw_pos_ = ImGui::GetWindowPos();
|
||||||
SDL_GetMouseState(&mouse_pos_x_, &mouse_pos_y_);
|
SDL_GetMouseState(&(int)mouse_pos_x_, &(int)mouse_pos_y_);
|
||||||
mouse_diff_control_bar_pos_x_ = mouse_pos_x_ - control_winodw_pos_.x;
|
mouse_diff_control_bar_pos_x_ = mouse_pos_x_ - control_winodw_pos_.x;
|
||||||
mouse_diff_control_bar_pos_y_ = mouse_pos_y_ - control_winodw_pos_.y;
|
mouse_diff_control_bar_pos_y_ = mouse_pos_y_ - control_winodw_pos_.y;
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ int Render::LocalWindow() {
|
|||||||
ImVec2(main_child_window_x_padding_,
|
ImVec2(main_child_window_x_padding_,
|
||||||
title_bar_height_ + main_child_window_y_padding_),
|
title_bar_height_ + main_child_window_y_padding_),
|
||||||
ImGuiCond_Always);
|
ImGuiCond_Always);
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg,
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(239.0f / 255, 240.0f / 255,
|
||||||
ImVec4(239.0 / 255, 240.0 / 255, 242.0 / 255, 1.0f));
|
242.0f / 255, 1.0f));
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
||||||
ImGui::BeginChild(
|
ImGui::BeginChild(
|
||||||
"LocalDesktopWindow_1",
|
"LocalDesktopWindow_1",
|
||||||
@@ -82,7 +82,7 @@ int Render::LocalWindow() {
|
|||||||
ImGui::SetWindowFontScale(1.0f);
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
ImGui::PopStyleColor(3);
|
ImGui::PopStyleColor(3);
|
||||||
|
|
||||||
auto time_duration = ImGui::GetTime() - copy_start_time_;
|
double time_duration = ImGui::GetTime() - copy_start_time_;
|
||||||
if (local_id_copied_ && time_duration < 1.0f) {
|
if (local_id_copied_ && time_duration < 1.0f) {
|
||||||
const ImGuiViewport *viewport = ImGui::GetMainViewport();
|
const ImGuiViewport *viewport = ImGui::GetMainViewport();
|
||||||
ImGui::SetNextWindowPos(
|
ImGui::SetNextWindowPos(
|
||||||
@@ -95,8 +95,9 @@ int Render::LocalWindow() {
|
|||||||
|
|
||||||
ImGui::SetNextWindowSize(
|
ImGui::SetNextWindowSize(
|
||||||
ImVec2(notification_window_width_, notification_window_height_));
|
ImVec2(notification_window_width_, notification_window_height_));
|
||||||
ImGui::PushStyleColor(ImGuiCol_WindowBg,
|
ImGui::PushStyleColor(
|
||||||
ImVec4(1.0, 1.0, 1.0, 1.0 - time_duration));
|
ImGuiCol_WindowBg,
|
||||||
|
ImVec4(1.0f, 1.0f, 1.0f, 1.0f - (float)time_duration));
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.0f);
|
||||||
ImGui::Begin("ConnectionStatusWindow", nullptr,
|
ImGui::Begin("ConnectionStatusWindow", nullptr,
|
||||||
@@ -114,7 +115,7 @@ int Render::LocalWindow() {
|
|||||||
ImGui::SetCursorPosX((window_width - text_width) * 0.5f);
|
ImGui::SetCursorPosX((window_width - text_width) * 0.5f);
|
||||||
ImGui::SetCursorPosY(window_height * 0.5f);
|
ImGui::SetCursorPosY(window_height * 0.5f);
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text,
|
ImGui::PushStyleColor(ImGuiCol_Text,
|
||||||
ImVec4(0, 0, 0, 1.0 - time_duration));
|
ImVec4(0, 0, 0, 1.0f - (float)time_duration));
|
||||||
ImGui::Text("%s", text.c_str());
|
ImGui::Text("%s", text.c_str());
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
@@ -137,18 +138,20 @@ int Render::LocalWindow() {
|
|||||||
if (!password_inited_) {
|
if (!password_inited_) {
|
||||||
char a[] = {
|
char a[] = {
|
||||||
"123456789QWERTYUPASDFGHJKLZXCVBNMqwertyupasdfghijkzxcvbnm"};
|
"123456789QWERTYUPASDFGHJKLZXCVBNMqwertyupasdfghijkzxcvbnm"};
|
||||||
std::mt19937 generator(
|
std::mt19937 generator((unsigned int)std::chrono::system_clock::now()
|
||||||
std::chrono::system_clock::now().time_since_epoch().count());
|
.time_since_epoch()
|
||||||
std::uniform_int_distribution<int> distribution(0, strlen(a) - 1);
|
.count());
|
||||||
|
std::uniform_int_distribution<int> distribution(0,
|
||||||
|
(int)(strlen(a) - 1));
|
||||||
|
|
||||||
random_password_.clear();
|
random_password_.clear();
|
||||||
for (int i = 0, len = strlen(a); i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
random_password_ += a[distribution(generator)];
|
random_password_ += a[distribution(generator)];
|
||||||
}
|
}
|
||||||
password_inited_ = true;
|
password_inited_ = true;
|
||||||
if (0 != strcmp(random_password_.c_str(), password_saved_)) {
|
if (0 != strcmp(random_password_.c_str(), password_saved_)) {
|
||||||
strncpy(password_saved_, random_password_.c_str(),
|
memcpy(password_saved_, random_password_.c_str(),
|
||||||
sizeof(password_saved_));
|
sizeof(password_saved_));
|
||||||
LOG_INFO("Generate new password and save into cache file");
|
LOG_INFO("Generate new password and save into cache file");
|
||||||
SaveSettingsIntoCacheFile();
|
SaveSettingsIntoCacheFile();
|
||||||
}
|
}
|
||||||
@@ -279,7 +282,7 @@ int Render::LocalWindow() {
|
|||||||
} else {
|
} else {
|
||||||
show_reset_password_window_ = false;
|
show_reset_password_window_ = false;
|
||||||
LOG_INFO("Generate new password and save into cache file");
|
LOG_INFO("Generate new password and save into cache file");
|
||||||
strncpy(password_saved_, new_password_, sizeof(password_saved_));
|
memcpy(password_saved_, new_password_, sizeof(password_saved_));
|
||||||
memset(new_password_, 0, sizeof(new_password_));
|
memset(new_password_, 0, sizeof(new_password_));
|
||||||
SaveSettingsIntoCacheFile();
|
SaveSettingsIntoCacheFile();
|
||||||
LeaveConnection(peer_, client_id_);
|
LeaveConnection(peer_, client_id_);
|
||||||
|
|||||||
@@ -38,12 +38,12 @@ int Render::ShowRecentConnections() {
|
|||||||
ImGui::SetCursorPosX(25.0f);
|
ImGui::SetCursorPosX(25.0f);
|
||||||
ImVec2 sub_window_pos = ImGui::GetCursorPos();
|
ImVec2 sub_window_pos = ImGui::GetCursorPos();
|
||||||
std::map<std::string, ImVec2> sub_containers_pos;
|
std::map<std::string, ImVec2> sub_containers_pos;
|
||||||
int recent_connection_sub_container_width =
|
float recent_connection_sub_container_width =
|
||||||
recent_connection_image_width_ + 16.0f;
|
recent_connection_image_width_ + 16.0f;
|
||||||
int recent_connection_sub_container_height =
|
float recent_connection_sub_container_height =
|
||||||
recent_connection_image_height_ + 36.0f;
|
recent_connection_image_height_ + 36.0f;
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg,
|
ImGui::PushStyleColor(ImGuiCol_ChildBg,
|
||||||
ImVec4(239.0 / 255, 240.0 / 255, 242.0 / 255, 1.0f));
|
ImVec4(239.0f / 255, 240.0f / 255, 242.0f / 255, 1.0f));
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
||||||
ImGui::BeginChild("RecentConnectionsContainer",
|
ImGui::BeginChild("RecentConnectionsContainer",
|
||||||
ImVec2(main_window_width_default_ - 50.0f, 145.0f),
|
ImVec2(main_window_width_default_ - 50.0f, 145.0f),
|
||||||
@@ -56,10 +56,10 @@ int Render::ShowRecentConnections() {
|
|||||||
ImGuiWindowFlags_NoScrollWithMouse);
|
ImGuiWindowFlags_NoScrollWithMouse);
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
int recent_connections_count = recent_connection_textures_.size();
|
size_t recent_connections_count = recent_connection_textures_.size();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int button_width = 22;
|
float button_width = 22;
|
||||||
int button_height = 22;
|
float button_height = 22;
|
||||||
for (auto it = recent_connection_textures_.begin();
|
for (auto it = recent_connection_textures_.begin();
|
||||||
it != recent_connection_textures_.end(); ++it) {
|
it != recent_connection_textures_.end(); ++it) {
|
||||||
sub_containers_pos[it->first] = ImGui::GetCursorPos();
|
sub_containers_pos[it->first] = ImGui::GetCursorPos();
|
||||||
@@ -180,7 +180,7 @@ int Render::ShowRecentConnections() {
|
|||||||
if (!password.empty() && password.size() == 6) {
|
if (!password.empty() && password.size() == 6) {
|
||||||
remember_password_ = true;
|
remember_password_ = true;
|
||||||
}
|
}
|
||||||
strncpy(remote_password_, password.c_str(), 6);
|
memcpy(remote_password_, password.c_str(), 6);
|
||||||
ConnectTo();
|
ConnectTo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ int Render::RemoteWindow() {
|
|||||||
ImVec2(local_window_width_ + main_child_window_x_padding_ - 1.0f,
|
ImVec2(local_window_width_ + main_child_window_x_padding_ - 1.0f,
|
||||||
title_bar_height_ + main_child_window_y_padding_),
|
title_bar_height_ + main_child_window_y_padding_),
|
||||||
ImGuiCond_Always);
|
ImGuiCond_Always);
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg,
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(239.0f / 255, 240.0f / 255,
|
||||||
ImVec4(239.0 / 255, 240.0 / 255, 242.0 / 255, 1.0f));
|
242.0f / 255, 1.0f));
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
||||||
|
|
||||||
ImGui::BeginChild(
|
ImGui::BeginChild(
|
||||||
|
|||||||
@@ -75,16 +75,16 @@ Render::~Render() {}
|
|||||||
|
|
||||||
int Render::SaveSettingsIntoCacheFile() {
|
int Render::SaveSettingsIntoCacheFile() {
|
||||||
cd_cache_mutex_.lock();
|
cd_cache_mutex_.lock();
|
||||||
std::ofstream cd_cache_file_("cache.cd", std::ios::binary);
|
std::ofstream cd_cache_file("cache.cd", std::ios::binary);
|
||||||
if (!cd_cache_file_) {
|
if (!cd_cache_file) {
|
||||||
cd_cache_mutex_.unlock();
|
cd_cache_mutex_.unlock();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&cd_cache_.client_id, 0, sizeof(cd_cache_.client_id));
|
memset(&cd_cache_.client_id, 0, sizeof(cd_cache_.client_id));
|
||||||
strncpy(cd_cache_.client_id, client_id_, sizeof(client_id_));
|
memcpy(cd_cache_.client_id, client_id_, sizeof(client_id_));
|
||||||
memset(&cd_cache_.password, 0, sizeof(cd_cache_.password));
|
memset(&cd_cache_.password, 0, sizeof(cd_cache_.password));
|
||||||
strncpy(cd_cache_.password, password_saved_, sizeof(password_saved_));
|
memcpy(cd_cache_.password, password_saved_, sizeof(password_saved_));
|
||||||
memcpy(&cd_cache_.language, &language_button_value_,
|
memcpy(&cd_cache_.language, &language_button_value_,
|
||||||
sizeof(language_button_value_));
|
sizeof(language_button_value_));
|
||||||
memcpy(&cd_cache_.video_quality, &video_quality_button_value_,
|
memcpy(&cd_cache_.video_quality, &video_quality_button_value_,
|
||||||
@@ -95,8 +95,8 @@ int Render::SaveSettingsIntoCacheFile() {
|
|||||||
sizeof(enable_hardware_video_codec_));
|
sizeof(enable_hardware_video_codec_));
|
||||||
memcpy(&cd_cache_.enable_turn, &enable_turn_, sizeof(enable_turn_));
|
memcpy(&cd_cache_.enable_turn, &enable_turn_, sizeof(enable_turn_));
|
||||||
|
|
||||||
cd_cache_file_.write(reinterpret_cast<char*>(&cd_cache_), sizeof(CDCache));
|
cd_cache_file.write(reinterpret_cast<char*>(&cd_cache_), sizeof(CDCache));
|
||||||
cd_cache_file_.close();
|
cd_cache_file.close();
|
||||||
cd_cache_mutex_.unlock();
|
cd_cache_mutex_.unlock();
|
||||||
|
|
||||||
config_center_.SetLanguage((ConfigCenter::LANGUAGE)language_button_value_);
|
config_center_.SetLanguage((ConfigCenter::LANGUAGE)language_button_value_);
|
||||||
@@ -114,8 +114,8 @@ int Render::SaveSettingsIntoCacheFile() {
|
|||||||
|
|
||||||
int Render::LoadSettingsFromCacheFile() {
|
int Render::LoadSettingsFromCacheFile() {
|
||||||
cd_cache_mutex_.lock();
|
cd_cache_mutex_.lock();
|
||||||
std::ifstream cd_cache_file_("cache.cd", std::ios::binary);
|
std::ifstream cd_cache_file("cache.cd", std::ios::binary);
|
||||||
if (!cd_cache_file_) {
|
if (!cd_cache_file) {
|
||||||
cd_cache_mutex_.unlock();
|
cd_cache_mutex_.unlock();
|
||||||
|
|
||||||
LOG_INFO("Init cache file by using default settings");
|
LOG_INFO("Init cache file by using default settings");
|
||||||
@@ -145,13 +145,13 @@ int Render::LoadSettingsFromCacheFile() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cd_cache_file_.read(reinterpret_cast<char*>(&cd_cache_), sizeof(CDCache));
|
cd_cache_file.read(reinterpret_cast<char*>(&cd_cache_), sizeof(CDCache));
|
||||||
cd_cache_file_.close();
|
cd_cache_file.close();
|
||||||
cd_cache_mutex_.unlock();
|
cd_cache_mutex_.unlock();
|
||||||
|
|
||||||
memset(&client_id_, 0, sizeof(client_id_));
|
memset(&client_id_, 0, sizeof(client_id_));
|
||||||
strncpy(client_id_, cd_cache_.client_id, sizeof(client_id_));
|
memcpy(client_id_, cd_cache_.client_id, sizeof(client_id_));
|
||||||
strncpy(password_saved_, cd_cache_.password, sizeof(password_saved_));
|
memcpy(password_saved_, cd_cache_.password, sizeof(password_saved_));
|
||||||
if (0 != strcmp(password_saved_, "") && 7 == sizeof(password_saved_)) {
|
if (0 != strcmp(password_saved_, "") && 7 == sizeof(password_saved_)) {
|
||||||
password_inited_ = true;
|
password_inited_ = true;
|
||||||
}
|
}
|
||||||
@@ -365,7 +365,7 @@ int Render::CreateConnectionPeer() {
|
|||||||
|
|
||||||
int Render::AudioDeviceInit() {
|
int Render::AudioDeviceInit() {
|
||||||
// Audio
|
// Audio
|
||||||
SDL_AudioSpec want_in, have_in, want_out, have_out;
|
SDL_AudioSpec want_in, want_out;
|
||||||
SDL_zero(want_in);
|
SDL_zero(want_in);
|
||||||
want_in.freq = 48000;
|
want_in.freq = 48000;
|
||||||
want_in.format = AUDIO_S16LSB;
|
want_in.format = AUDIO_S16LSB;
|
||||||
@@ -453,12 +453,12 @@ int Render::CreateMainWindow() {
|
|||||||
|
|
||||||
ImGui::SetCurrentContext(main_ctx_);
|
ImGui::SetCurrentContext(main_ctx_);
|
||||||
|
|
||||||
SDL_WindowFlags window_flags =
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(
|
||||||
(SDL_WindowFlags)(SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS |
|
SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS | SDL_WINDOW_HIDDEN);
|
||||||
SDL_WINDOW_HIDDEN);
|
main_window_ =
|
||||||
main_window_ = SDL_CreateWindow(
|
SDL_CreateWindow("Remote Desk", SDL_WINDOWPOS_UNDEFINED,
|
||||||
"Remote Desk", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED, (int)main_window_width_default_,
|
||||||
main_window_width_default_, main_window_height_default_, window_flags);
|
(int)main_window_height_default_, window_flags);
|
||||||
|
|
||||||
main_renderer_ = SDL_CreateRenderer(
|
main_renderer_ = SDL_CreateRenderer(
|
||||||
main_window_, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
main_window_, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
||||||
@@ -506,10 +506,10 @@ int Render::CreateStreamWindow() {
|
|||||||
|
|
||||||
SDL_WindowFlags window_flags =
|
SDL_WindowFlags window_flags =
|
||||||
(SDL_WindowFlags)(SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS);
|
(SDL_WindowFlags)(SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS);
|
||||||
stream_window_ =
|
stream_window_ = SDL_CreateWindow(
|
||||||
SDL_CreateWindow("Stream window", SDL_WINDOWPOS_UNDEFINED,
|
"Stream window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||||
SDL_WINDOWPOS_UNDEFINED, stream_window_width_default_,
|
(int)stream_window_width_default_, (int)stream_window_height_default_,
|
||||||
stream_window_height_default_, window_flags);
|
window_flags);
|
||||||
|
|
||||||
stream_renderer_ = SDL_CreateRenderer(
|
stream_renderer_ = SDL_CreateRenderer(
|
||||||
stream_window_, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
stream_window_, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
||||||
@@ -551,7 +551,7 @@ int Render::DestroyStreamWindow() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Render::SetupFontAndStyle(bool is_main_window) {
|
int Render::SetupFontAndStyle() {
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.ConfigFlags |=
|
io.ConfigFlags |=
|
||||||
@@ -583,14 +583,12 @@ int Render::SetupMainWindow() {
|
|||||||
|
|
||||||
ImGui::SetCurrentContext(main_ctx_);
|
ImGui::SetCurrentContext(main_ctx_);
|
||||||
|
|
||||||
SetupFontAndStyle(true);
|
SetupFontAndStyle();
|
||||||
|
|
||||||
SDL_GL_GetDrawableSize(main_window_, &main_window_width_real_,
|
SDL_GL_GetDrawableSize(main_window_, &main_window_width_real_,
|
||||||
&main_window_height_real_);
|
&main_window_height_real_);
|
||||||
main_window_dpi_scaling_w_ =
|
main_window_dpi_scaling_w_ = main_window_width_real_ / main_window_width_;
|
||||||
(float)main_window_width_real_ / (float)main_window_width_;
|
main_window_dpi_scaling_h_ = main_window_width_real_ / main_window_width_;
|
||||||
main_window_dpi_scaling_h_ =
|
|
||||||
(float)main_window_width_real_ / (float)main_window_width_;
|
|
||||||
SDL_RenderSetScale(main_renderer_, main_window_dpi_scaling_w_,
|
SDL_RenderSetScale(main_renderer_, main_window_dpi_scaling_w_,
|
||||||
main_window_dpi_scaling_h_);
|
main_window_dpi_scaling_h_);
|
||||||
LOG_INFO("Use dpi scaling [{}x{}] for main window",
|
LOG_INFO("Use dpi scaling [{}x{}] for main window",
|
||||||
@@ -623,14 +621,14 @@ int Render::SetupStreamWindow() {
|
|||||||
|
|
||||||
ImGui::SetCurrentContext(stream_ctx_);
|
ImGui::SetCurrentContext(stream_ctx_);
|
||||||
|
|
||||||
SetupFontAndStyle(false);
|
SetupFontAndStyle();
|
||||||
|
|
||||||
SDL_GL_GetDrawableSize(stream_window_, &stream_window_width_real_,
|
SDL_GL_GetDrawableSize(stream_window_, &main_window_width_real_,
|
||||||
&stream_window_height_real_);
|
&main_window_height_real_);
|
||||||
stream_window_dpi_scaling_w_ =
|
stream_window_dpi_scaling_w_ =
|
||||||
(float)stream_window_width_real_ / (float)stream_window_width_;
|
stream_window_width_real_ / stream_window_width_;
|
||||||
stream_window_dpi_scaling_h_ =
|
stream_window_dpi_scaling_h_ =
|
||||||
(float)stream_window_width_real_ / (float)stream_window_width_;
|
stream_window_width_real_ / stream_window_width_;
|
||||||
SDL_RenderSetScale(stream_renderer_, stream_window_dpi_scaling_w_,
|
SDL_RenderSetScale(stream_renderer_, stream_window_dpi_scaling_w_,
|
||||||
stream_window_dpi_scaling_h_);
|
stream_window_dpi_scaling_h_);
|
||||||
LOG_INFO("Use dpi scaling [{}x{}] for stream window",
|
LOG_INFO("Use dpi scaling [{}x{}] for stream window",
|
||||||
@@ -758,9 +756,9 @@ int Render::Run() {
|
|||||||
screen_height_ = DM.h;
|
screen_height_ = DM.h;
|
||||||
|
|
||||||
stream_render_rect_.x = 0;
|
stream_render_rect_.x = 0;
|
||||||
stream_render_rect_.y = title_bar_height_;
|
stream_render_rect_.y = (int)title_bar_height_;
|
||||||
stream_render_rect_.w = stream_window_width_;
|
stream_render_rect_.w = (int)stream_window_width_;
|
||||||
stream_render_rect_.h = stream_window_height_ - title_bar_height_;
|
stream_render_rect_.h = (int)(stream_window_height_ - title_bar_height_);
|
||||||
|
|
||||||
// use linear filtering to render textures otherwise the graphics will be
|
// use linear filtering to render textures otherwise the graphics will be
|
||||||
// blurry
|
// blurry
|
||||||
@@ -885,8 +883,8 @@ int Render::Run() {
|
|||||||
memset(&net_traffic_stats_, 0, sizeof(net_traffic_stats_));
|
memset(&net_traffic_stats_, 0, sizeof(net_traffic_stats_));
|
||||||
SDL_SetWindowFullscreen(main_window_, SDL_FALSE);
|
SDL_SetWindowFullscreen(main_window_, SDL_FALSE);
|
||||||
memset(audio_buffer_, 0, 720);
|
memset(audio_buffer_, 0, 720);
|
||||||
SDL_SetWindowSize(main_window_, main_window_width_default_,
|
SDL_SetWindowSize(main_window_, (int)main_window_width_default_,
|
||||||
main_window_height_default_);
|
(int)main_window_height_default_);
|
||||||
|
|
||||||
// SDL_Rect display_bounds;
|
// SDL_Rect display_bounds;
|
||||||
// SDL_GetDisplayBounds(0, &display_bounds);
|
// SDL_GetDisplayBounds(0, &display_bounds);
|
||||||
@@ -905,14 +903,14 @@ int Render::Run() {
|
|||||||
window_maximized_ = false;
|
window_maximized_ = false;
|
||||||
} else if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
} else if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||||
reset_control_bar_pos_ = true;
|
reset_control_bar_pos_ = true;
|
||||||
SDL_GetWindowSize(stream_window_, &stream_window_width_,
|
SDL_GetWindowSize(stream_window_, &((int)stream_window_width_),
|
||||||
&stream_window_height_);
|
&((int)stream_window_height_));
|
||||||
|
|
||||||
float video_ratio = (float)video_width_ / (float)video_height_;
|
float video_ratio = (float)video_width_ / (float)video_height_;
|
||||||
float video_ratio_reverse = (float)video_height_ / (float)video_width_;
|
float video_ratio_reverse = (float)video_height_ / (float)video_width_;
|
||||||
|
|
||||||
int render_area_width = stream_window_width_;
|
float render_area_width = stream_window_width_;
|
||||||
int render_area_height =
|
float render_area_height =
|
||||||
stream_window_height_ -
|
stream_window_height_ -
|
||||||
(fullscreen_button_pressed_ ? 0 : title_bar_height_);
|
(fullscreen_button_pressed_ ? 0 : title_bar_height_);
|
||||||
|
|
||||||
@@ -920,25 +918,27 @@ int Render::Run() {
|
|||||||
if (render_area_width < render_area_height * video_ratio) {
|
if (render_area_width < render_area_height * video_ratio) {
|
||||||
stream_render_rect_.x = 0;
|
stream_render_rect_.x = 0;
|
||||||
stream_render_rect_.y =
|
stream_render_rect_.y =
|
||||||
abs(render_area_height -
|
(int)(abs(render_area_height -
|
||||||
render_area_width * video_ratio_reverse) /
|
render_area_width * video_ratio_reverse) /
|
||||||
2 +
|
2 +
|
||||||
(fullscreen_button_pressed_ ? 0 : title_bar_height_);
|
(fullscreen_button_pressed_ ? 0 : title_bar_height_));
|
||||||
stream_render_rect_.w = render_area_width;
|
stream_render_rect_.w = (int)render_area_width;
|
||||||
stream_render_rect_.h = render_area_width * video_ratio_reverse;
|
stream_render_rect_.h =
|
||||||
|
(int)(render_area_width * video_ratio_reverse);
|
||||||
} else if (render_area_width > render_area_height * video_ratio) {
|
} else if (render_area_width > render_area_height * video_ratio) {
|
||||||
stream_render_rect_.x =
|
stream_render_rect_.x =
|
||||||
abs(render_area_width - render_area_height * video_ratio) / 2;
|
(int)abs(render_area_width - render_area_height * video_ratio) /
|
||||||
|
2;
|
||||||
stream_render_rect_.y =
|
stream_render_rect_.y =
|
||||||
fullscreen_button_pressed_ ? 0 : title_bar_height_;
|
fullscreen_button_pressed_ ? 0 : (int)title_bar_height_;
|
||||||
stream_render_rect_.w = render_area_height * video_ratio;
|
stream_render_rect_.w = (int)(render_area_height * video_ratio);
|
||||||
stream_render_rect_.h = render_area_height;
|
stream_render_rect_.h = (int)render_area_height;
|
||||||
} else {
|
} else {
|
||||||
stream_render_rect_.x = 0;
|
stream_render_rect_.x = 0;
|
||||||
stream_render_rect_.y =
|
stream_render_rect_.y =
|
||||||
fullscreen_button_pressed_ ? 0 : title_bar_height_;
|
fullscreen_button_pressed_ ? 0 : (int)title_bar_height_;
|
||||||
stream_render_rect_.w = render_area_width;
|
stream_render_rect_.w = (int)render_area_width;
|
||||||
stream_render_rect_.h = render_area_height;
|
stream_render_rect_.h = (int)render_area_height;
|
||||||
}
|
}
|
||||||
} else if (event.type == SDL_WINDOWEVENT &&
|
} else if (event.type == SDL_WINDOWEVENT &&
|
||||||
event.window.event == SDL_WINDOWEVENT_CLOSE) {
|
event.window.event == SDL_WINDOWEVENT_CLOSE) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class Render {
|
|||||||
int DestroyMainWindow();
|
int DestroyMainWindow();
|
||||||
int CreateStreamWindow();
|
int CreateStreamWindow();
|
||||||
int DestroyStreamWindow();
|
int DestroyStreamWindow();
|
||||||
int SetupFontAndStyle(bool is_main_window);
|
int SetupFontAndStyle();
|
||||||
int SetupMainWindow();
|
int SetupMainWindow();
|
||||||
int DestroyMainWindowContext();
|
int DestroyMainWindowContext();
|
||||||
int SetupStreamWindow();
|
int SetupStreamWindow();
|
||||||
@@ -65,7 +65,7 @@ class Render {
|
|||||||
int DrawMainWindow();
|
int DrawMainWindow();
|
||||||
int DrawStreamWindow();
|
int DrawStreamWindow();
|
||||||
int ConfirmDeleteConnection();
|
int ConfirmDeleteConnection();
|
||||||
int NetTrafficStats(ImVec2 mouse_button_pos);
|
int NetTrafficStats();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void OnReceiveVideoBufferCb(const XVideoFrame *video_frame,
|
static void OnReceiveVideoBufferCb(const XVideoFrame *video_frame,
|
||||||
@@ -139,7 +139,6 @@ class Render {
|
|||||||
} CDCache;
|
} CDCache;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::ifstream cd_cache_file_;
|
|
||||||
CDCache cd_cache_;
|
CDCache cd_cache_;
|
||||||
std::mutex cd_cache_mutex_;
|
std::mutex cd_cache_mutex_;
|
||||||
|
|
||||||
@@ -171,57 +170,57 @@ class Render {
|
|||||||
char client_password_[20] = "";
|
char client_password_[20] = "";
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int title_bar_width_ = 640;
|
float title_bar_width_ = 640;
|
||||||
int title_bar_height_ = 30;
|
float title_bar_height_ = 30;
|
||||||
int screen_width_ = 1280;
|
int screen_width_ = 1280;
|
||||||
int screen_height_ = 720;
|
int screen_height_ = 720;
|
||||||
int main_window_width_default_ = 640;
|
float main_window_width_default_ = 640;
|
||||||
int main_window_height_default_ = 480;
|
float main_window_height_default_ = 480;
|
||||||
int main_window_width_ = 640;
|
float main_window_width_ = 640;
|
||||||
int main_window_height_ = 480;
|
float main_window_height_ = 480;
|
||||||
int main_window_width_last_ = 640;
|
float main_window_width_last_ = 640;
|
||||||
int main_window_height_last_ = 480;
|
float main_window_height_last_ = 480;
|
||||||
int stream_window_width_default_ = 1280;
|
float stream_window_width_default_ = 1280;
|
||||||
int stream_window_height_default_ = 720;
|
float stream_window_height_default_ = 720;
|
||||||
int stream_window_width_ = 1280;
|
float stream_window_width_ = 1280;
|
||||||
int stream_window_height_ = 720;
|
float stream_window_height_ = 720;
|
||||||
int stream_window_width_last_ = 1280;
|
int stream_window_width_last_ = 1280;
|
||||||
int stream_window_height_last_ = 720;
|
int stream_window_height_last_ = 720;
|
||||||
int stream_window_width_before_maximized_ = 1280;
|
float stream_window_width_before_maximized_ = 1280;
|
||||||
int stream_window_height_before_maximized_ = 720;
|
float stream_window_height_before_maximized_ = 720;
|
||||||
int control_window_min_width_ = 20;
|
float control_window_min_width_ = 20;
|
||||||
int control_window_max_width_ = 200;
|
float control_window_max_width_ = 200;
|
||||||
int control_window_min_height_ = 40;
|
float control_window_min_height_ = 40;
|
||||||
int control_window_max_height_ = 150;
|
float control_window_max_height_ = 150;
|
||||||
int control_window_width_ = 200;
|
float control_window_width_ = 200;
|
||||||
int control_window_height_ = 40;
|
float control_window_height_ = 40;
|
||||||
int local_window_width_ = 320;
|
float local_window_width_ = 320;
|
||||||
int local_window_height_ = 235;
|
float local_window_height_ = 235;
|
||||||
int remote_window_width_ = 320;
|
float remote_window_width_ = 320;
|
||||||
int remote_window_height_ = 235;
|
float remote_window_height_ = 235;
|
||||||
int local_child_window_width_ = 266;
|
float local_child_window_width_ = 266;
|
||||||
int local_child_window_height_ = 180;
|
float local_child_window_height_ = 180;
|
||||||
int remote_child_window_width_ = 266;
|
float remote_child_window_width_ = 266;
|
||||||
int remote_child_window_height_ = 180;
|
float remote_child_window_height_ = 180;
|
||||||
int main_window_text_y_padding_ = 10;
|
float main_window_text_y_padding_ = 10;
|
||||||
int main_child_window_x_padding_ = 27;
|
float main_child_window_x_padding_ = 27;
|
||||||
int main_child_window_y_padding_ = 45;
|
float main_child_window_y_padding_ = 45;
|
||||||
int status_bar_height_ = 22;
|
float status_bar_height_ = 22;
|
||||||
int connection_status_window_width_ = 200;
|
float connection_status_window_width_ = 200;
|
||||||
int connection_status_window_height_ = 150;
|
float connection_status_window_height_ = 150;
|
||||||
int notification_window_width_ = 200;
|
float notification_window_width_ = 200;
|
||||||
int notification_window_height_ = 80;
|
float notification_window_height_ = 80;
|
||||||
int about_window_width_ = 200;
|
float about_window_width_ = 200;
|
||||||
int about_window_height_ = 150;
|
float about_window_height_ = 150;
|
||||||
|
|
||||||
int control_bar_pos_x_ = 0;
|
float control_bar_pos_x_ = 0;
|
||||||
int control_bar_pos_y_ = 30;
|
float control_bar_pos_y_ = 30;
|
||||||
int mouse_diff_control_bar_pos_x_ = 0;
|
float mouse_diff_control_bar_pos_x_ = 0;
|
||||||
int mouse_diff_control_bar_pos_y_ = 0;
|
float mouse_diff_control_bar_pos_y_ = 0;
|
||||||
int mouse_pos_x_ = 0;
|
float mouse_pos_x_ = 0;
|
||||||
int mouse_pos_y_ = 0;
|
float mouse_pos_y_ = 0;
|
||||||
int mouse_pos_x_last_ = 0;
|
float mouse_pos_x_last_ = 0;
|
||||||
int mouse_pos_y_last_ = 0;
|
float mouse_pos_y_last_ = 0;
|
||||||
|
|
||||||
int main_window_width_real_ = 720;
|
int main_window_width_real_ = 720;
|
||||||
int main_window_height_real_ = 540;
|
int main_window_height_real_ = 540;
|
||||||
@@ -238,7 +237,7 @@ class Render {
|
|||||||
|
|
||||||
int video_width_ = 1280;
|
int video_width_ = 1280;
|
||||||
int video_height_ = 720;
|
int video_height_ = 720;
|
||||||
int video_size_ = 1280 * 720 * 3;
|
size_t video_size_ = 1280 * 720 * 3;
|
||||||
|
|
||||||
SDL_Window *main_window_ = nullptr;
|
SDL_Window *main_window_ = nullptr;
|
||||||
SDL_Renderer *main_renderer_ = nullptr;
|
SDL_Renderer *main_renderer_ = nullptr;
|
||||||
@@ -346,7 +345,7 @@ class Render {
|
|||||||
unsigned char audio_buffer_[720];
|
unsigned char audio_buffer_[720];
|
||||||
int audio_len_ = 0;
|
int audio_len_ = 0;
|
||||||
unsigned char *dst_buffer_ = nullptr;
|
unsigned char *dst_buffer_ = nullptr;
|
||||||
int dst_buffer_capacity_ = 0;
|
size_t dst_buffer_capacity_ = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScreenCapturerFactory *screen_capturer_factory_ = nullptr;
|
ScreenCapturerFactory *screen_capturer_factory_ = nullptr;
|
||||||
@@ -356,7 +355,7 @@ class Render {
|
|||||||
DeviceControllerFactory *device_controller_factory_ = nullptr;
|
DeviceControllerFactory *device_controller_factory_ = nullptr;
|
||||||
MouseController *mouse_controller_ = nullptr;
|
MouseController *mouse_controller_ = nullptr;
|
||||||
KeyboardCapturer *keyboard_capturer_ = nullptr;
|
KeyboardCapturer *keyboard_capturer_ = nullptr;
|
||||||
uint32_t last_frame_time_;
|
uint64_t last_frame_time_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char client_id_[10] = "";
|
char client_id_[10] = "";
|
||||||
|
|||||||
@@ -124,7 +124,9 @@ void Render::SdlCaptureAudioIn(void *userdata, Uint8 *stream, int len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Render::SdlCaptureAudioOut(void *userdata, Uint8 *stream, int len) {
|
void Render::SdlCaptureAudioOut([[maybe_unused]] void *userdata,
|
||||||
|
[[maybe_unused]] Uint8 *stream,
|
||||||
|
[[maybe_unused]] int len) {
|
||||||
// Render *render = (Render *)userdata;
|
// Render *render = (Render *)userdata;
|
||||||
// if ("Connected" == render->connection_status_str_) {
|
// if ("Connected" == render->connection_status_str_) {
|
||||||
// SendAudioFrame(render->peer_, (const char *)stream, len);
|
// SendAudioFrame(render->peer_, (const char *)stream, len);
|
||||||
@@ -148,7 +150,8 @@ void Render::SdlCaptureAudioOut(void *userdata, Uint8 *stream, int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Render::OnReceiveVideoBufferCb(const XVideoFrame *video_frame,
|
void Render::OnReceiveVideoBufferCb(const XVideoFrame *video_frame,
|
||||||
const char *user_id, size_t user_id_size,
|
[[maybe_unused]] const char *user_id,
|
||||||
|
[[maybe_unused]] size_t user_id_size,
|
||||||
void *user_data) {
|
void *user_data) {
|
||||||
Render *render = (Render *)user_data;
|
Render *render = (Render *)user_data;
|
||||||
if (!render) {
|
if (!render) {
|
||||||
@@ -186,7 +189,8 @@ void Render::OnReceiveVideoBufferCb(const XVideoFrame *video_frame,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Render::OnReceiveAudioBufferCb(const char *data, size_t size,
|
void Render::OnReceiveAudioBufferCb(const char *data, size_t size,
|
||||||
const char *user_id, size_t user_id_size,
|
[[maybe_unused]] const char *user_id,
|
||||||
|
[[maybe_unused]] size_t user_id_size,
|
||||||
void *user_data) {
|
void *user_data) {
|
||||||
Render *render = (Render *)user_data;
|
Render *render = (Render *)user_data;
|
||||||
if (!render) {
|
if (!render) {
|
||||||
@@ -207,7 +211,7 @@ void Render::OnReceiveDataBufferCb(const char *data, size_t size,
|
|||||||
|
|
||||||
std::string user(user_id, user_id_size);
|
std::string user(user_id, user_id_size);
|
||||||
RemoteAction remote_action;
|
RemoteAction remote_action;
|
||||||
memcpy(&remote_action, data, sizeof(remote_action));
|
memcpy(&remote_action, data, size);
|
||||||
|
|
||||||
if (ControlType::mouse == remote_action.type && render->mouse_controller_) {
|
if (ControlType::mouse == remote_action.type && render->mouse_controller_) {
|
||||||
render->mouse_controller_->SendCommand(remote_action);
|
render->mouse_controller_->SendCommand(remote_action);
|
||||||
@@ -218,7 +222,8 @@ void Render::OnReceiveDataBufferCb(const char *data, size_t size,
|
|||||||
render->StopSpeakerCapturer();
|
render->StopSpeakerCapturer();
|
||||||
}
|
}
|
||||||
} else if (ControlType::keyboard == remote_action.type) {
|
} else if (ControlType::keyboard == remote_action.type) {
|
||||||
render->ProcessKeyEvent(remote_action.k.key_value, remote_action.k.flag);
|
render->ProcessKeyEvent((int)remote_action.k.key_value,
|
||||||
|
remote_action.k.flag);
|
||||||
} else if (ControlType::host_infomation == remote_action.type) {
|
} else if (ControlType::host_infomation == remote_action.type) {
|
||||||
render->host_name_ =
|
render->host_name_ =
|
||||||
std::string(remote_action.i.host_name, remote_action.i.host_name_size);
|
std::string(remote_action.i.host_name, remote_action.i.host_name_size);
|
||||||
@@ -255,8 +260,10 @@ void Render::OnSignalStatusCb(SignalStatus status, void *user_data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Render::OnConnectionStatusCb(ConnectionStatus status, const char *user_id,
|
void Render::OnConnectionStatusCb(ConnectionStatus status,
|
||||||
const size_t user_id_size, void *user_data) {
|
[[maybe_unused]] const char *user_id,
|
||||||
|
[[maybe_unused]] const size_t user_id_size,
|
||||||
|
void *user_data) {
|
||||||
Render *render = (Render *)user_data;
|
Render *render = (Render *)user_data;
|
||||||
if (!render) {
|
if (!render) {
|
||||||
return;
|
return;
|
||||||
@@ -352,7 +359,7 @@ void Render::NetStatusReport(const char *client_id, size_t client_id_size,
|
|||||||
|
|
||||||
if (0 == strcmp(render->client_id_, "")) {
|
if (0 == strcmp(render->client_id_, "")) {
|
||||||
memset(&render->client_id_, 0, sizeof(render->client_id_));
|
memset(&render->client_id_, 0, sizeof(render->client_id_));
|
||||||
strncpy(render->client_id_, client_id, client_id_size);
|
memcpy(render->client_id_, client_id, client_id_size);
|
||||||
LOG_INFO("Use client id [{}] and save id into cache file", client_id);
|
LOG_INFO("Use client id [{}] and save id into cache file", client_id);
|
||||||
render->SaveSettingsIntoCacheFile();
|
render->SaveSettingsIntoCacheFile();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,6 +155,8 @@ LICENSE
|
|||||||
See end of file for license information.
|
See end of file for license information.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4996)
|
||||||
|
|
||||||
#ifndef INCLUDE_STB_IMAGE_WRITE_H
|
#ifndef INCLUDE_STB_IMAGE_WRITE_H
|
||||||
#define INCLUDE_STB_IMAGE_WRITE_H
|
#define INCLUDE_STB_IMAGE_WRITE_H
|
||||||
@@ -1933,6 +1935,7 @@ STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // STB_IMAGE_WRITE_IMPLEMENTATION
|
#endif // STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
/* Revision history
|
/* Revision history
|
||||||
1.16 (2021-07-11)
|
1.16 (2021-07-11)
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ std::string Thumbnail::AES_encrypt(const std::string& plaintext,
|
|||||||
ret = EVP_EncryptUpdate(
|
ret = EVP_EncryptUpdate(
|
||||||
ctx, ciphertext.data(), &len,
|
ctx, ciphertext.data(), &len,
|
||||||
reinterpret_cast<const unsigned char*>(plaintext.data()),
|
reinterpret_cast<const unsigned char*>(plaintext.data()),
|
||||||
plaintext.size());
|
(int)plaintext.size());
|
||||||
if (1 != ret) {
|
if (1 != ret) {
|
||||||
LOG_ERROR("Error in EVP_EncryptUpdate");
|
LOG_ERROR("Error in EVP_EncryptUpdate");
|
||||||
EVP_CIPHER_CTX_free(ctx);
|
EVP_CIPHER_CTX_free(ctx);
|
||||||
@@ -339,7 +339,7 @@ std::string Thumbnail::AES_decrypt(const std::string& ciphertext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = EVP_DecryptUpdate(ctx, plaintext, &plaintext_len, ciphertext_buf,
|
ret = EVP_DecryptUpdate(ctx, plaintext, &plaintext_len, ciphertext_buf,
|
||||||
ciphertext_buf_len);
|
(int)ciphertext_buf_len);
|
||||||
if (1 != ret) {
|
if (1 != ret) {
|
||||||
LOG_ERROR("Error in EVP_DecryptUpdate");
|
LOG_ERROR("Error in EVP_DecryptUpdate");
|
||||||
|
|
||||||
|
|||||||
2
thirdparty/projectx
vendored
2
thirdparty/projectx
vendored
Submodule thirdparty/projectx updated: 7e3856a68d...826fc2d312
@@ -26,8 +26,7 @@ if is_os("windows") then
|
|||||||
add_links("Shell32", "windowsapp", "dwmapi", "User32", "kernel32",
|
add_links("Shell32", "windowsapp", "dwmapi", "User32", "kernel32",
|
||||||
"SDL2-static", "SDL2main", "gdi32", "winmm", "setupapi", "version",
|
"SDL2-static", "SDL2main", "gdi32", "winmm", "setupapi", "version",
|
||||||
"Imm32", "iphlpapi")
|
"Imm32", "iphlpapi")
|
||||||
-- add_cxflags("/W4", "/WX")
|
add_cxflags("/W4", "/WX")
|
||||||
add_cxflags("/W4")
|
|
||||||
elseif is_os("linux") then
|
elseif is_os("linux") then
|
||||||
add_requires("ffmpeg 5.1.2", {system = false})
|
add_requires("ffmpeg 5.1.2", {system = false})
|
||||||
add_syslinks("pthread", "dl")
|
add_syslinks("pthread", "dl")
|
||||||
|
|||||||
Reference in New Issue
Block a user