diff --git a/src/device_controller/mouse/linux/mouse_controller.cpp b/src/device_controller/mouse/linux/mouse_controller.cpp index 5467002..d6f9355 100644 --- a/src/device_controller/mouse/linux/mouse_controller.cpp +++ b/src/device_controller/mouse/linux/mouse_controller.cpp @@ -1,6 +1,6 @@ #include "mouse_controller.h" -#include "log.h" +#include "rd_log.h" MouseController::MouseController() {} @@ -80,13 +80,13 @@ int MouseController::SendMouseCommand(RemoteAction remote_action) { event.type = EV_REL; event.code = REL_WHEEL; event.value = remote_action.m.s; - write(uinput_fd_, &event, sizeof(event)); + (void)write(uinput_fd_, &event, sizeof(event)); break; case MouseFlag::wheel_horizontal: event.type = EV_REL; event.code = REL_HWHEEL; event.value = remote_action.m.s; - write(uinput_fd_, &event, sizeof(event)); + (void)write(uinput_fd_, &event, sizeof(event)); break; default: SetMousePosition(uinput_fd_, mouse_pos_x, mouse_pos_y); @@ -148,4 +148,4 @@ void MouseController::SetMousePosition(int fd, int x, int y) { ev_sync.value = 0; ev_sync.code = 0; int res_ev_sync = write(fd, &ev_sync, sizeof(ev_sync)); -} \ No newline at end of file +} diff --git a/src/screen_capturer/linux/screen_capturer_x11.cpp b/src/screen_capturer/linux/screen_capturer_x11.cpp index b95d721..ba60ccf 100644 --- a/src/screen_capturer/linux/screen_capturer_x11.cpp +++ b/src/screen_capturer/linux/screen_capturer_x11.cpp @@ -2,7 +2,7 @@ #include -#include "log.h" +#include "rd_log.h" #define NV12_BUFFER_SIZE 1280 * 720 * 3 / 2 unsigned char nv12_buffer_[NV12_BUFFER_SIZE]; @@ -16,8 +16,7 @@ ScreenCapturerX11::~ScreenCapturerX11() { } } -int ScreenCapturerX11::Init(const RECORD_DESKTOP_RECT &rect, const int fps, - cb_desktop_data cb) { +int ScreenCapturerX11::Init(const int fps, cb_desktop_data cb) { if (cb) { _on_data = cb; } @@ -44,14 +43,22 @@ int ScreenCapturerX11::Init(const RECORD_DESKTOP_RECT &rect, const int fps, LOG_ERROR("Couldn't find_input_format [{}]", capture_method.c_str()); } + const char *display = std::getenv("DISPLAY"); // Grab at position 10,20 - if (avformat_open_input(&pFormatCtx_, ":0.0", ifmt_, &options_) != 0) { - printf("Couldn't open input stream.\n"); + if (display) { + if (avformat_open_input(&pFormatCtx_, display, ifmt_, &options_) != 0) { + LOG_ERROR("Couldn't open input stream {}", display); + return -1; + } else { + LOG_INFO("Open input stream [{}]", display); + } + } else { + LOG_ERROR("DISPLAY environment variable not set"); return -1; } if (avformat_find_stream_info(pFormatCtx_, NULL) < 0) { - printf("Couldn't find stream information.\n"); + LOG_ERROR("Couldn't find stream information"); return -1; } @@ -62,7 +69,7 @@ int ScreenCapturerX11::Init(const RECORD_DESKTOP_RECT &rect, const int fps, break; } if (videoindex_ == -1) { - printf("Didn't find a video stream.\n"); + LOG_ERROR("Didn't find a video stream"); return -1; } @@ -73,11 +80,11 @@ int ScreenCapturerX11::Init(const RECORD_DESKTOP_RECT &rect, const int fps, pCodec_ = const_cast(avcodec_find_decoder(pCodecCtx_->codec_id)); if (pCodec_ == NULL) { - printf("Codec not found.\n"); + LOG_ERROR("Codec not found"); return -1; } if (avcodec_open2(pCodecCtx_, pCodec_, NULL) < 0) { - printf("Could not open codec.\n"); + LOG_ERROR("Could not open codec"); return -1; } @@ -109,6 +116,7 @@ int ScreenCapturerX11::Destroy() { } int ScreenCapturerX11::Start() { + running_ = true; capture_thread_ = std::thread([this]() { while (running_) { if (av_read_frame(pFormatCtx_, packet_) >= 0) { diff --git a/src/screen_capturer/linux/screen_capturer_x11.h b/src/screen_capturer/linux/screen_capturer_x11.h index 9d68d9b..3be21b0 100644 --- a/src/screen_capturer/linux/screen_capturer_x11.h +++ b/src/screen_capturer/linux/screen_capturer_x11.h @@ -25,8 +25,7 @@ class ScreenCapturerX11 : public ScreenCapturer { ~ScreenCapturerX11(); public: - virtual int Init(const RECORD_DESKTOP_RECT &rect, const int fps, - cb_desktop_data cb) override; + virtual int Init(const int fps, cb_desktop_data cb) override; virtual int Destroy() override; virtual int Start() override; virtual int Stop() override; @@ -48,8 +47,6 @@ class ScreenCapturerX11 : public ScreenCapturer { std::string _device_name; - RECORD_DESKTOP_RECT _rect; - int _fps; cb_desktop_data _on_data; diff --git a/src/single_window/render.h b/src/single_window/render.h index f94e998..9bc2367 100644 --- a/src/single_window/render.h +++ b/src/single_window/render.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/src/single_window/thumbnail.h b/src/single_window/thumbnail.h index 44d43d0..ff77832 100644 --- a/src/single_window/thumbnail.h +++ b/src/single_window/thumbnail.h @@ -11,6 +11,7 @@ #include #include +#include class Thumbnail { public: diff --git a/thirdparty/projectx b/thirdparty/projectx index 1a34c6b..7ae1dc9 160000 --- a/thirdparty/projectx +++ b/thirdparty/projectx @@ -1 +1 @@ -Subproject commit 1a34c6bc1d2f46685e7f1c30a219325c90702d47 +Subproject commit 7ae1dc90f03bd5f441fbb721f9528a2da181c1e9 diff --git a/xmake.lua b/xmake.lua index 2b60142..5e1fec6 100644 --- a/xmake.lua +++ b/xmake.lua @@ -18,7 +18,6 @@ end add_requires("spdlog 1.14.1", {system = false}) add_requires("imgui v1.91.5-docking", {configs = {sdl2 = true, sdl2_renderer = true}}) -add_requires("miniaudio 0.11.21") add_requires("openssl3 3.3.2", {system = false}) if is_os("windows") then @@ -30,7 +29,7 @@ if is_os("windows") then elseif is_os("linux") then add_requires("ffmpeg 5.1.2", {system = false}) add_syslinks("pthread", "dl") - add_linkdirs("thirdparty/projectx/thirdparty/nvcodec/Lib/x64") + add_linkdirs("thirdparty/projectx/thirdparty/nvcodec/lib/x64") add_links("SDL2", "cuda", "nvidia-encode", "nvcuvid") add_ldflags("-lavformat", "-lavdevice", "-lavfilter", "-lavcodec", "-lswscale", "-lavutil", "-lswresample", @@ -224,4 +223,4 @@ target("remote_desk") -- target("mouse_control") -- set_kind("binary") -- add_files("test/linux_mouse_control/mouse_control.cpp") --- add_includedirs("test/linux_mouse_control") \ No newline at end of file +-- add_includedirs("test/linux_mouse_control")