mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 12:15:34 +08:00
[fix] fix compile error on Linux
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#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 *>(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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class Thumbnail {
|
||||
public:
|
||||
|
||||
2
thirdparty/projectx
vendored
2
thirdparty/projectx
vendored
Submodule thirdparty/projectx updated: 1a34c6bc1d...7ae1dc90f0
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user