mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 04:05:34 +08:00
Fix compile error
This commit is contained in:
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Xmake cache
|
||||||
|
.xmake/
|
||||||
|
build/
|
||||||
|
|
||||||
|
# MacOS Cache
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# VSCode cache
|
||||||
|
.vscode
|
||||||
|
continuous-desk.code-workspace
|
||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "thirdparty/projectx"]
|
||||||
|
path = thirdparty/projectx
|
||||||
|
url = git@github.com:dijunkun/projectx.git
|
||||||
16
config/config.ini
Normal file
16
config/config.ini
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
[signal server]
|
||||||
|
ip = 120.77.216.215
|
||||||
|
port = 9099
|
||||||
|
|
||||||
|
[stun server]
|
||||||
|
ip = 120.77.216.215
|
||||||
|
port = 3478
|
||||||
|
|
||||||
|
[turn server]
|
||||||
|
ip = 120.77.216.215
|
||||||
|
port = 3478
|
||||||
|
username = dijunkun
|
||||||
|
password = dijunkunpw
|
||||||
|
|
||||||
|
[hardware acceleration]
|
||||||
|
turn_on = true
|
||||||
127
src/log/log.h
Normal file
127
src/log/log.h
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
#ifndef _LOG_H_
|
||||||
|
#define _LOG_H_
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "spdlog/common.h"
|
||||||
|
#include "spdlog/logger.h"
|
||||||
|
#include "spdlog/sinks/base_sink.h"
|
||||||
|
#include "spdlog/sinks/rotating_file_sink.h"
|
||||||
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||||
|
#include "spdlog/spdlog.h"
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
|
||||||
|
|
||||||
|
// SPDLOG_TRACE(...)
|
||||||
|
// SPDLOG_DEBUG(...)
|
||||||
|
// SPDLOG_INFO(...)
|
||||||
|
// SPDLOG_WARN(...)
|
||||||
|
// SPDLOG_ERROR(...)
|
||||||
|
// SPDLOG_CRITICAL(...)
|
||||||
|
|
||||||
|
#ifdef SIGNAL_LOGGER
|
||||||
|
constexpr auto LOGGER_NAME = "siganl_server";
|
||||||
|
#else
|
||||||
|
constexpr auto LOGGER_NAME = "remote_desk";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LOG_INFO(...) \
|
||||||
|
if (nullptr == spdlog::get(LOGGER_NAME)) { \
|
||||||
|
auto now = std::chrono::system_clock::now() + std::chrono::hours(8); \
|
||||||
|
auto timet = std::chrono::system_clock::to_time_t(now); \
|
||||||
|
auto localTime = *std::gmtime(&timet); \
|
||||||
|
std::stringstream ss; \
|
||||||
|
std::string filename; \
|
||||||
|
ss << LOGGER_NAME; \
|
||||||
|
ss << std::put_time(&localTime, "-%Y%m%d-%H%M%S.log"); \
|
||||||
|
ss >> filename; \
|
||||||
|
std::string path = "logs/" + filename; \
|
||||||
|
std::vector<spdlog::sink_ptr> sinks; \
|
||||||
|
sinks.push_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>()); \
|
||||||
|
sinks.push_back(std::make_shared<spdlog::sinks::rotating_file_sink_mt>( \
|
||||||
|
path, 1048576 * 5, 3)); \
|
||||||
|
auto combined_logger = std::make_shared<spdlog::logger>( \
|
||||||
|
LOGGER_NAME, begin(sinks), end(sinks)); \
|
||||||
|
combined_logger->flush_on(spdlog::level::info); \
|
||||||
|
spdlog::register_logger(combined_logger); \
|
||||||
|
SPDLOG_LOGGER_INFO(combined_logger, __VA_ARGS__); \
|
||||||
|
} else { \
|
||||||
|
SPDLOG_LOGGER_INFO(spdlog::get(LOGGER_NAME), __VA_ARGS__); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define LOG_WARN(...) \
|
||||||
|
if (nullptr == spdlog::get(LOGGER_NAME)) { \
|
||||||
|
auto now = std::chrono::system_clock::now() + std::chrono::hours(8); \
|
||||||
|
auto timet = std::chrono::system_clock::to_time_t(now); \
|
||||||
|
auto localTime = *std::gmtime(&timet); \
|
||||||
|
std::stringstream ss; \
|
||||||
|
std::string filename; \
|
||||||
|
ss << LOGGER_NAME; \
|
||||||
|
ss << std::put_time(&localTime, "-%Y%m%d-%H%M%S.log"); \
|
||||||
|
ss >> filename; \
|
||||||
|
std::string path = "logs/" + filename; \
|
||||||
|
std::vector<spdlog::sink_ptr> sinks; \
|
||||||
|
sinks.push_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>()); \
|
||||||
|
sinks.push_back(std::make_shared<spdlog::sinks::rotating_file_sink_mt>( \
|
||||||
|
path, 1048576 * 5, 3)); \
|
||||||
|
auto combined_logger = std::make_shared<spdlog::logger>( \
|
||||||
|
LOGGER_NAME, begin(sinks), end(sinks)); \
|
||||||
|
spdlog::register_logger(combined_logger); \
|
||||||
|
SPDLOG_LOGGER_WARN(combined_logger, __VA_ARGS__); \
|
||||||
|
} else { \
|
||||||
|
SPDLOG_LOGGER_WARN(spdlog::get(LOGGER_NAME), __VA_ARGS__); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define LOG_ERROR(...) \
|
||||||
|
if (nullptr == spdlog::get(LOGGER_NAME)) { \
|
||||||
|
auto now = std::chrono::system_clock::now() + std::chrono::hours(8); \
|
||||||
|
auto timet = std::chrono::system_clock::to_time_t(now); \
|
||||||
|
auto localTime = *std::gmtime(&timet); \
|
||||||
|
std::stringstream ss; \
|
||||||
|
std::string filename; \
|
||||||
|
ss << LOGGER_NAME; \
|
||||||
|
ss << std::put_time(&localTime, "-%Y%m%d-%H%M%S.log"); \
|
||||||
|
ss >> filename; \
|
||||||
|
std::string path = "logs/" + filename; \
|
||||||
|
std::vector<spdlog::sink_ptr> sinks; \
|
||||||
|
sinks.push_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>()); \
|
||||||
|
sinks.push_back(std::make_shared<spdlog::sinks::rotating_file_sink_mt>( \
|
||||||
|
path, 1048576 * 5, 3)); \
|
||||||
|
auto combined_logger = std::make_shared<spdlog::logger>( \
|
||||||
|
LOGGER_NAME, begin(sinks), end(sinks)); \
|
||||||
|
spdlog::register_logger(combined_logger); \
|
||||||
|
SPDLOG_LOGGER_ERROR(combined_logger, __VA_ARGS__); \
|
||||||
|
} else { \
|
||||||
|
SPDLOG_LOGGER_ERROR(spdlog::get(LOGGER_NAME), __VA_ARGS__); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define LOG_FATAL(...) \
|
||||||
|
if (nullptr == spdlog::get(LOGGER_NAME)) { \
|
||||||
|
auto now = std::chrono::system_clock::now() + std::chrono::hours(8); \
|
||||||
|
auto timet = std::chrono::system_clock::to_time_t(now); \
|
||||||
|
auto localTime = *std::gmtime(&timet); \
|
||||||
|
std::stringstream ss; \
|
||||||
|
std::string filename; \
|
||||||
|
ss << LOGGER_NAME; \
|
||||||
|
ss << std::put_time(&localTime, "-%Y%m%d-%H%M%S.log"); \
|
||||||
|
ss >> filename; \
|
||||||
|
std::string path = "logs/" + filename; \
|
||||||
|
std::vector<spdlog::sink_ptr> sinks; \
|
||||||
|
sinks.push_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>()); \
|
||||||
|
sinks.push_back(std::make_shared<spdlog::sinks::rotating_file_sink_mt>( \
|
||||||
|
path, 1048576 * 5, 3)); \
|
||||||
|
auto combined_logger = std::make_shared<spdlog::logger>( \
|
||||||
|
LOGGER_NAME, begin(sinks), end(sinks)); \
|
||||||
|
spdlog::register_logger(combined_logger); \
|
||||||
|
SPDLOG_LOGGER_CRITICAL(combined_logger, __VA_ARGS__); \
|
||||||
|
} else { \
|
||||||
|
SPDLOG_LOGGER_CRITICAL(spdlog::get(LOGGER_NAME), __VA_ARGS__); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -43,7 +43,7 @@ extern "C" {
|
|||||||
#elif __linux__
|
#elif __linux__
|
||||||
#include "screen_capture_x11.h"
|
#include "screen_capture_x11.h"
|
||||||
#endif
|
#endif
|
||||||
#include "x.h"
|
#include "../../thirdparty/projectx/src/interface/x.h"
|
||||||
|
|
||||||
#define NV12_BUFFER_SIZE 1280 * 720 * 3 / 2
|
#define NV12_BUFFER_SIZE 1280 * 720 * 3 / 2
|
||||||
|
|
||||||
@@ -54,6 +54,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int screen_w = 1280, screen_h = 720;
|
int screen_w = 1280, screen_h = 720;
|
||||||
|
int window_w = 1280, window_h = 720;
|
||||||
const int pixel_w = 1280, pixel_h = 720;
|
const int pixel_w = 1280, pixel_h = 720;
|
||||||
|
|
||||||
unsigned char dst_buffer[pixel_w * pixel_h * 3 / 2];
|
unsigned char dst_buffer[pixel_w * pixel_h * 3 / 2];
|
||||||
@@ -118,7 +119,7 @@ typedef struct {
|
|||||||
} RemoteAction;
|
} RemoteAction;
|
||||||
|
|
||||||
inline int ProcessMouseKeyEven(SDL_Event &ev) {
|
inline int ProcessMouseKeyEven(SDL_Event &ev) {
|
||||||
float ratio = 1280.0 / screen_w;
|
float ratio = 1280.0 / window_w;
|
||||||
|
|
||||||
RemoteAction remote_action;
|
RemoteAction remote_action;
|
||||||
|
|
||||||
@@ -427,6 +428,67 @@ int main() {
|
|||||||
std::string client_user_id = "C-" + std::string(GetMac(mac_addr));
|
std::string client_user_id = "C-" + std::string(GetMac(mac_addr));
|
||||||
Init(peer_client, client_user_id.c_str());
|
Init(peer_client, client_user_id.c_str());
|
||||||
|
|
||||||
|
{
|
||||||
|
static char server_password[20] = "";
|
||||||
|
std::string user_id = "S-" + std::string(GetMac(mac_addr));
|
||||||
|
CreateConnection(peer_server, mac_addr, server_password);
|
||||||
|
|
||||||
|
nv12_buffer = new char[NV12_BUFFER_SIZE];
|
||||||
|
#ifdef _WIN32
|
||||||
|
screen_capture = new ScreenCaptureWgc();
|
||||||
|
|
||||||
|
RECORD_DESKTOP_RECT rect;
|
||||||
|
rect.left = 0;
|
||||||
|
rect.top = 0;
|
||||||
|
rect.right = GetSystemMetrics(SM_CXSCREEN);
|
||||||
|
rect.bottom = GetSystemMetrics(SM_CYSCREEN);
|
||||||
|
|
||||||
|
last_frame_time_ = std::chrono::high_resolution_clock::now();
|
||||||
|
screen_capture->Init(
|
||||||
|
rect, 60,
|
||||||
|
[](unsigned char *data, int size, int width, int height) -> void {
|
||||||
|
auto now_time = std::chrono::high_resolution_clock::now();
|
||||||
|
std::chrono::duration<double> duration = now_time - last_frame_time_;
|
||||||
|
auto tc = duration.count() * 1000;
|
||||||
|
|
||||||
|
if (tc >= 0) {
|
||||||
|
BGRAToNV12FFmpeg(data, width, height, (unsigned char *)nv12_buffer);
|
||||||
|
SendData(peer_server, DATA_TYPE::VIDEO, (const char *)nv12_buffer,
|
||||||
|
NV12_BUFFER_SIZE);
|
||||||
|
// std::cout << "Send" << std::endl;
|
||||||
|
last_frame_time_ = now_time;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
screen_capture->Start();
|
||||||
|
|
||||||
|
#elif __linux__
|
||||||
|
screen_capture = new ScreenCaptureX11();
|
||||||
|
|
||||||
|
RECORD_DESKTOP_RECT rect;
|
||||||
|
rect.left = 0;
|
||||||
|
rect.top = 0;
|
||||||
|
rect.right = 0;
|
||||||
|
rect.bottom = 0;
|
||||||
|
|
||||||
|
last_frame_time_ = std::chrono::high_resolution_clock::now();
|
||||||
|
screen_capture->Init(
|
||||||
|
rect, 60,
|
||||||
|
[](unsigned char *data, int size, int width, int height) -> void {
|
||||||
|
auto now_time = std::chrono::high_resolution_clock::now();
|
||||||
|
std::chrono::duration<double> duration = now_time - last_frame_time_;
|
||||||
|
auto tc = duration.count() * 1000;
|
||||||
|
|
||||||
|
if (tc >= 0) {
|
||||||
|
SendData(peer_server, DATA_TYPE::VIDEO, (const char *)data,
|
||||||
|
NV12_BUFFER_SIZE);
|
||||||
|
last_frame_time_ = now_time;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
screen_capture->Start();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Setup SDL
|
// Setup SDL
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) !=
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) !=
|
||||||
0) {
|
0) {
|
||||||
@@ -443,21 +505,13 @@ int main() {
|
|||||||
SDL_WindowFlags window_flags =
|
SDL_WindowFlags window_flags =
|
||||||
(SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
(SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
window = SDL_CreateWindow("Remote Desk", SDL_WINDOWPOS_CENTERED,
|
window = SDL_CreateWindow("Remote Desk", SDL_WINDOWPOS_CENTERED,
|
||||||
SDL_WINDOWPOS_CENTERED, screen_w, screen_h,
|
SDL_WINDOWPOS_CENTERED, window_w, window_h,
|
||||||
window_flags);
|
window_flags);
|
||||||
|
|
||||||
// int new_screen_w = 0;
|
SDL_DisplayMode DM;
|
||||||
// int new_screen_h = 0;
|
SDL_GetCurrentDisplayMode(0, &DM);
|
||||||
// SDL_GetWindowSize(window, &new_screen_w, &new_screen_h);
|
screen_w = DM.w;
|
||||||
|
screen_h = DM.h;
|
||||||
// if (new_screen_w != screen_w) {
|
|
||||||
// screen_w = new_screen_w;
|
|
||||||
// screen_h = new_screen_w * 9 / 16;
|
|
||||||
// } else if (new_screen_h != screen_h) {
|
|
||||||
// screen_w = new_screen_h * 16 / 9;
|
|
||||||
// screen_h = new_screen_h;
|
|
||||||
// }
|
|
||||||
// SDL_SetWindowSize(window, screen_w, screen_h);
|
|
||||||
|
|
||||||
sdlRenderer = SDL_CreateRenderer(
|
sdlRenderer = SDL_CreateRenderer(
|
||||||
window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
||||||
@@ -509,108 +563,117 @@ int main() {
|
|||||||
|
|
||||||
const ImGuiViewport *main_viewport = ImGui::GetMainViewport();
|
const ImGuiViewport *main_viewport = ImGui::GetMainViewport();
|
||||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Once);
|
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Once);
|
||||||
ImGui::SetNextWindowSize(ImVec2(180, 225));
|
ImGui::SetNextWindowSize(ImVec2(180, 130));
|
||||||
|
|
||||||
ImGui::Begin("Menu", nullptr, ImGuiWindowFlags_NoResize);
|
ImGui::Begin("Menu", nullptr, ImGuiWindowFlags_NoResize);
|
||||||
|
|
||||||
{
|
{
|
||||||
ImGui::Text("LOCAL ID: ");
|
// ImGui::Text("LOCAL ID: ");
|
||||||
ImGui::SameLine();
|
// ImGui::SameLine();
|
||||||
|
|
||||||
ImGui::Selectable(mac_addr, false,
|
// ImGui::Selectable(mac_addr, false,
|
||||||
ImGuiSelectableFlags_AllowDoubleClick);
|
// ImGuiSelectableFlags_AllowDoubleClick);
|
||||||
|
|
||||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) {
|
// if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) {
|
||||||
ImGui::SetClipboardText(mac_addr);
|
// ImGui::SetClipboardText(mac_addr);
|
||||||
}
|
// }
|
||||||
|
|
||||||
ImGui::Spacing();
|
// ImGui::Spacing();
|
||||||
|
|
||||||
ImGui::Text("PASSWORD: ");
|
// ImGui::Text("PASSWORD: ");
|
||||||
ImGui::SameLine();
|
// ImGui::SameLine();
|
||||||
ImGui::SetNextItemWidth(110);
|
// ImGui::SetNextItemWidth(110);
|
||||||
static char server_password[20] = "";
|
// static char server_password[20] = "";
|
||||||
ImGui::InputTextWithHint("server_password", "000001", server_password,
|
// ImGui::InputTextWithHint("server_password", "000001",
|
||||||
IM_ARRAYSIZE(server_password),
|
// server_password,
|
||||||
ImGuiInputTextFlags_AllowTabInput);
|
// IM_ARRAYSIZE(server_password),
|
||||||
|
// ImGuiInputTextFlags_AllowTabInput);
|
||||||
|
|
||||||
ImGui::Spacing();
|
// ImGui::Spacing();
|
||||||
{
|
// {
|
||||||
static bool online_button_pressed = false;
|
// static bool online_button_pressed = false;
|
||||||
static const char *online_label = "Online";
|
// static const char *online_label = "Online";
|
||||||
|
|
||||||
if (ImGui::Button(online_label)) {
|
// if (ImGui::Button(online_label)) {
|
||||||
std::string user_id = "S-" + std::string(GetMac(mac_addr));
|
// std::string user_id = "S-" +
|
||||||
|
// std::string(GetMac(mac_addr));
|
||||||
|
|
||||||
if (strcmp(online_label, "Online") == 0) {
|
// if (strcmp(online_label, "Online") == 0) {
|
||||||
CreateConnection(peer_server, mac_addr, server_password);
|
// CreateConnection(peer_server, mac_addr,
|
||||||
|
// server_password);
|
||||||
|
|
||||||
nv12_buffer = new char[NV12_BUFFER_SIZE];
|
// nv12_buffer = new char[NV12_BUFFER_SIZE];
|
||||||
#ifdef _WIN32
|
// #ifdef _WIN32
|
||||||
screen_capture = new ScreenCaptureWgc();
|
// screen_capture = new ScreenCaptureWgc();
|
||||||
|
|
||||||
RECORD_DESKTOP_RECT rect;
|
// RECORD_DESKTOP_RECT rect;
|
||||||
rect.left = 0;
|
// rect.left = 0;
|
||||||
rect.top = 0;
|
// rect.top = 0;
|
||||||
rect.right = GetSystemMetrics(SM_CXSCREEN);
|
// rect.right = GetSystemMetrics(SM_CXSCREEN);
|
||||||
rect.bottom = GetSystemMetrics(SM_CYSCREEN);
|
// rect.bottom = GetSystemMetrics(SM_CYSCREEN);
|
||||||
|
|
||||||
last_frame_time_ = std::chrono::high_resolution_clock::now();
|
// last_frame_time_ =
|
||||||
screen_capture->Init(
|
// std::chrono::high_resolution_clock::now();
|
||||||
rect, 60,
|
// screen_capture->Init(
|
||||||
[](unsigned char *data, int size, int width,
|
// rect, 60,
|
||||||
int height) -> void {
|
// [](unsigned char *data, int size, int width,
|
||||||
auto now_time = std::chrono::high_resolution_clock::now();
|
// int height) -> void {
|
||||||
std::chrono::duration<double> duration =
|
// auto now_time =
|
||||||
now_time - last_frame_time_;
|
// std::chrono::high_resolution_clock::now();
|
||||||
auto tc = duration.count() * 1000;
|
// std::chrono::duration<double> duration =
|
||||||
|
// now_time - last_frame_time_;
|
||||||
|
// auto tc = duration.count() * 1000;
|
||||||
|
|
||||||
if (tc >= 0) {
|
// if (tc >= 0) {
|
||||||
BGRAToNV12FFmpeg(data, width, height,
|
// BGRAToNV12FFmpeg(data, width, height,
|
||||||
(unsigned char *)nv12_buffer);
|
// (unsigned char *)nv12_buffer);
|
||||||
SendData(peer_server, DATA_TYPE::VIDEO,
|
// SendData(peer_server, DATA_TYPE::VIDEO,
|
||||||
(const char *)nv12_buffer, NV12_BUFFER_SIZE);
|
// (const char *)nv12_buffer,
|
||||||
// std::cout << "Send" << std::endl;
|
// NV12_BUFFER_SIZE);
|
||||||
last_frame_time_ = now_time;
|
// // std::cout << "Send" << std::endl;
|
||||||
}
|
// last_frame_time_ = now_time;
|
||||||
});
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
screen_capture->Start();
|
// screen_capture->Start();
|
||||||
|
|
||||||
#elif __linux__
|
// #elif __linux__
|
||||||
screen_capture = new ScreenCaptureX11();
|
// screen_capture = new ScreenCaptureX11();
|
||||||
|
|
||||||
RECORD_DESKTOP_RECT rect;
|
// RECORD_DESKTOP_RECT rect;
|
||||||
rect.left = 0;
|
// rect.left = 0;
|
||||||
rect.top = 0;
|
// rect.top = 0;
|
||||||
rect.right = 0;
|
// rect.right = 0;
|
||||||
rect.bottom = 0;
|
// rect.bottom = 0;
|
||||||
|
|
||||||
last_frame_time_ = std::chrono::high_resolution_clock::now();
|
// last_frame_time_ =
|
||||||
screen_capture->Init(
|
// std::chrono::high_resolution_clock::now();
|
||||||
rect, 60,
|
// screen_capture->Init(
|
||||||
[](unsigned char *data, int size, int width,
|
// rect, 60,
|
||||||
int height) -> void {
|
// [](unsigned char *data, int size, int width,
|
||||||
auto now_time = std::chrono::high_resolution_clock::now();
|
// int height) -> void {
|
||||||
std::chrono::duration<double> duration =
|
// auto now_time =
|
||||||
now_time - last_frame_time_;
|
// std::chrono::high_resolution_clock::now();
|
||||||
auto tc = duration.count() * 1000;
|
// std::chrono::duration<double> duration =
|
||||||
|
// now_time - last_frame_time_;
|
||||||
|
// auto tc = duration.count() * 1000;
|
||||||
|
|
||||||
if (tc >= 0) {
|
// if (tc >= 0) {
|
||||||
SendData(peer_server, DATA_TYPE::VIDEO,
|
// SendData(peer_server, DATA_TYPE::VIDEO,
|
||||||
(const char *)data, NV12_BUFFER_SIZE);
|
// (const char *)data, NV12_BUFFER_SIZE);
|
||||||
last_frame_time_ = now_time;
|
// last_frame_time_ = now_time;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
screen_capture->Start();
|
// screen_capture->Start();
|
||||||
#endif
|
// #endif
|
||||||
} else {
|
// } else {
|
||||||
LeaveConnection(peer_server);
|
// LeaveConnection(peer_server);
|
||||||
}
|
// }
|
||||||
online_button_pressed = !online_button_pressed;
|
// online_button_pressed = !online_button_pressed;
|
||||||
online_label = online_button_pressed ? "Offline" : "Online";
|
// online_label = online_button_pressed ? "Offline" :
|
||||||
}
|
// "Online";
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
@@ -632,14 +695,14 @@ int main() {
|
|||||||
|
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
ImGui::Text("PASSWORD: ");
|
// ImGui::Text("PASSWORD: ");
|
||||||
ImGui::SameLine();
|
// ImGui::SameLine();
|
||||||
ImGui::SetNextItemWidth(110);
|
// ImGui::SetNextItemWidth(110);
|
||||||
static char client_password[20] = "";
|
static char client_password[20] = "";
|
||||||
ImGui::InputTextWithHint("client_password", "000003",
|
// ImGui::InputTextWithHint("client_password", "000003",
|
||||||
client_password,
|
// client_password,
|
||||||
IM_ARRAYSIZE(client_password),
|
// IM_ARRAYSIZE(client_password),
|
||||||
ImGuiInputTextFlags_AllowTabInput);
|
// ImGuiInputTextFlags_AllowTabInput);
|
||||||
|
|
||||||
if (ImGui::Button(connect_label)) {
|
if (ImGui::Button(connect_label)) {
|
||||||
if (strcmp(connect_label, "Connect") == 0 && !joined) {
|
if (strcmp(connect_label, "Connect") == 0 && !joined) {
|
||||||
@@ -667,13 +730,13 @@ int main() {
|
|||||||
|
|
||||||
{
|
{
|
||||||
if (ImGui::Button("Fix ratio")) {
|
if (ImGui::Button("Fix ratio")) {
|
||||||
SDL_GetWindowSize(window, &screen_w, &screen_h);
|
SDL_GetWindowSize(window, &window_w, &window_h);
|
||||||
|
|
||||||
if (screen_h != screen_w * 9 / 16) {
|
if (window_h != window_w * 9 / 16) {
|
||||||
screen_w = screen_h * 16 / 9;
|
window_w = window_h * 16 / 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetWindowSize(window, screen_w, screen_h);
|
SDL_SetWindowSize(window, window_w, window_h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -692,9 +755,9 @@ int main() {
|
|||||||
done = true;
|
done = true;
|
||||||
} else if (event.type == SDL_WINDOWEVENT &&
|
} else if (event.type == SDL_WINDOWEVENT &&
|
||||||
event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||||
SDL_GetWindowSize(window, &screen_w, &screen_h);
|
SDL_GetWindowSize(window, &window_w, &window_h);
|
||||||
SDL_SetWindowSize(window, screen_w, screen_h);
|
SDL_SetWindowSize(window, window_w, window_h);
|
||||||
// printf("Resize windows: %dx%d\n", screen_w, screen_h);
|
// printf("Resize windows: %dx%d\n", window_w, window_h);
|
||||||
} else if (event.type == SDL_WINDOWEVENT &&
|
} else if (event.type == SDL_WINDOWEVENT &&
|
||||||
event.window.event == SDL_WINDOWEVENT_CLOSE &&
|
event.window.event == SDL_WINDOWEVENT_CLOSE &&
|
||||||
event.window.windowID == SDL_GetWindowID(window)) {
|
event.window.windowID == SDL_GetWindowID(window)) {
|
||||||
@@ -702,13 +765,13 @@ int main() {
|
|||||||
} else if (event.type == REFRESH_EVENT) {
|
} else if (event.type == REFRESH_EVENT) {
|
||||||
sdlRect.x = 0;
|
sdlRect.x = 0;
|
||||||
sdlRect.y = 0;
|
sdlRect.y = 0;
|
||||||
sdlRect.w = screen_w;
|
sdlRect.w = window_w;
|
||||||
sdlRect.h = screen_h;
|
sdlRect.h = window_h;
|
||||||
|
|
||||||
SDL_UpdateTexture(sdlTexture, NULL, dst_buffer, pixel_w);
|
SDL_UpdateTexture(sdlTexture, NULL, dst_buffer, pixel_w);
|
||||||
} else {
|
} else {
|
||||||
if (joined) {
|
if (joined) {
|
||||||
// ProcessMouseKeyEven(event);
|
ProcessMouseKeyEven(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -741,6 +804,8 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
|
LeaveConnection(peer_server);
|
||||||
|
|
||||||
ImGui_ImplSDLRenderer2_Shutdown();
|
ImGui_ImplSDLRenderer2_Shutdown();
|
||||||
ImGui_ImplSDL2_Shutdown();
|
ImGui_ImplSDL2_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
1
thirdparty/projectx
vendored
Submodule
1
thirdparty/projectx
vendored
Submodule
Submodule thirdparty/projectx added at 19506af831
2
thirdparty/xmake.lua
vendored
2
thirdparty/xmake.lua
vendored
@@ -1,4 +1,4 @@
|
|||||||
includes("sdl2")
|
includes("sdl2", "projectx")
|
||||||
if is_plat("windows") then
|
if is_plat("windows") then
|
||||||
elseif is_plat("linux") then
|
elseif is_plat("linux") then
|
||||||
includes("ffmpeg")
|
includes("ffmpeg")
|
||||||
|
|||||||
24
xmake.lua
24
xmake.lua
@@ -10,6 +10,7 @@ add_requires("imgui 1.89.9", {configs = {sdl2 = true, sdl2_renderer = true}})
|
|||||||
add_defines("UNICODE")
|
add_defines("UNICODE")
|
||||||
|
|
||||||
add_requires("sdl2", {system = false})
|
add_requires("sdl2", {system = false})
|
||||||
|
add_requires("projectx")
|
||||||
|
|
||||||
if is_os("windows") then
|
if is_os("windows") then
|
||||||
add_links("Shell32", "windowsapp", "dwmapi", "User32", "kernel32")
|
add_links("Shell32", "windowsapp", "dwmapi", "User32", "kernel32")
|
||||||
@@ -32,29 +33,28 @@ includes("thirdparty")
|
|||||||
target("log")
|
target("log")
|
||||||
set_kind("headeronly")
|
set_kind("headeronly")
|
||||||
add_packages("spdlog")
|
add_packages("spdlog")
|
||||||
add_headerfiles("../utils/log/log.h")
|
add_headerfiles("src/log/log.h")
|
||||||
add_includedirs("../utils/log", {public = true})
|
add_includedirs("src/log", {public = true})
|
||||||
|
|
||||||
target("screen_capture")
|
target("screen_capture")
|
||||||
set_kind("static")
|
set_kind("static")
|
||||||
add_packages("log", "ffmpeg")
|
add_packages("log", "ffmpeg")
|
||||||
if is_os("windows") then
|
if is_os("windows") then
|
||||||
add_files("screen_capture/windows/*.cpp")
|
add_files("src/screen_capture/windows/*.cpp")
|
||||||
add_includedirs("screen_capture/windows", {public = true})
|
add_includedirs("src/screen_capture/windows", {public = true})
|
||||||
elseif is_os("macosx") then
|
elseif is_os("macosx") then
|
||||||
add_files("screen_capture/macosx/*.cpp")
|
add_files("src/screen_capture/macosx/*.cpp")
|
||||||
add_includedirs("screen_capture/macosx", {public = true})
|
add_includedirs("ssrc/creen_capture/macosx", {public = true})
|
||||||
elseif is_os("linux") then
|
elseif is_os("linux") then
|
||||||
add_files("screen_capture/linux/*.cpp")
|
add_files("src/screen_capture/linux/*.cpp")
|
||||||
add_includedirs("screen_capture/linux", {public = true})
|
add_includedirs("src/screen_capture/linux", {public = true})
|
||||||
end
|
end
|
||||||
|
|
||||||
target("remote_desk")
|
target("remote_desk")
|
||||||
set_kind("binary")
|
set_kind("binary")
|
||||||
add_deps("projectx", "screen_capture")
|
add_deps("log", "screen_capture")
|
||||||
add_packages("log", "sdl2", "imgui", "ffmpeg")
|
add_packages("sdl2", "imgui", "ffmpeg", "projectx")
|
||||||
add_files("remote_desk_gui/main.cpp")
|
add_files("src/remote_desk_gui/main.cpp")
|
||||||
add_includedirs("../../src/interface")
|
|
||||||
if is_os("windows") then
|
if is_os("windows") then
|
||||||
add_links("SDL2-static", "SDL2main", "gdi32", "winmm",
|
add_links("SDL2-static", "SDL2main", "gdi32", "winmm",
|
||||||
"setupapi", "version", "Imm32", "iphlpapi")
|
"setupapi", "version", "Imm32", "iphlpapi")
|
||||||
|
|||||||
Reference in New Issue
Block a user