[fix] fix compile error on MacOSx

This commit is contained in:
dijunkun
2025-05-15 19:54:17 +08:00
parent eca4f614c8
commit 6ebf583a13
5 changed files with 32 additions and 15 deletions

View File

@@ -8,18 +8,22 @@ MouseController::MouseController() {}
MouseController::~MouseController() {} MouseController::~MouseController() {}
int MouseController::Init(int screen_width, int screen_height) { int MouseController::Init(std::vector<DisplayInfo> display_info_list) {
screen_width_ = screen_width; display_info_list_ = display_info_list;
screen_height_ = screen_height;
return 0; return 0;
} }
int MouseController::Destroy() { return 0; } int MouseController::Destroy() { return 0; }
int MouseController::SendMouseCommand(RemoteAction remote_action) { int MouseController::SendMouseCommand(RemoteAction remote_action,
int mouse_pos_x = remote_action.m.x * screen_width_; int display_index) {
int mouse_pos_y = remote_action.m.y * screen_height_; int mouse_pos_x =
remote_action.m.x * display_info_list_[display_index].width +
display_info_list_[display_index].left;
int mouse_pos_y =
remote_action.m.y * display_info_list_[display_index].height +
display_info_list_[display_index].top;
if (remote_action.type == ControlType::mouse) { if (remote_action.type == ControlType::mouse) {
CGEventRef mouse_event = nullptr; CGEventRef mouse_event = nullptr;

View File

@@ -7,6 +7,8 @@
#ifndef _MOUSE_CONTROLLER_H_ #ifndef _MOUSE_CONTROLLER_H_
#define _MOUSE_CONTROLLER_H_ #define _MOUSE_CONTROLLER_H_
#include <vector>
#include "device_controller.h" #include "device_controller.h"
class MouseController : public DeviceController { class MouseController : public DeviceController {
@@ -15,13 +17,12 @@ class MouseController : public DeviceController {
virtual ~MouseController(); virtual ~MouseController();
public: public:
virtual int Init(int screen_width, int screen_height); virtual int Init(std::vector<DisplayInfo> display_info_list);
virtual int Destroy(); virtual int Destroy();
virtual int SendMouseCommand(RemoteAction remote_action); virtual int SendMouseCommand(RemoteAction remote_action, int display_index);
private: private:
int screen_width_ = 0; std::vector<DisplayInfo> display_info_list_;
int screen_height_ = 0;
}; };
#endif #endif

View File

@@ -42,9 +42,9 @@ int ScreenCapturerSck::Start() {
int ScreenCapturerSck::Stop() { return 0; } int ScreenCapturerSck::Stop() { return 0; }
int ScreenCapturerSck::Pause() { return 0; } int ScreenCapturerSck::Pause(int monitor_index) { return 0; }
int ScreenCapturerSck::Resume() { return 0; } int ScreenCapturerSck::Resume(int monitor_index) { return 0; }
void ScreenCapturerSck::OnFrame() {} void ScreenCapturerSck::OnFrame() {}

View File

@@ -27,9 +27,13 @@ class ScreenCapturerSck : public ScreenCapturer {
virtual int Start() override; virtual int Start() override;
virtual int Stop() override; virtual int Stop() override;
int Pause(); int Pause(int monitor_index) override;
int Resume(); int Resume(int monitor_index) override;
int SwitchTo(int monitor_index) override { return 0; }
std::vector<DisplayInfo> GetDisplayInfoList() override { return {}; }
void OnFrame(); void OnFrame();

View File

@@ -56,6 +56,14 @@ public:
virtual int Stop() { return 0; } virtual int Stop() { return 0; }
virtual int Pause(int monitor_index) { return 0; }
virtual int Resume(int monitor_index) { return 0; }
virtual int SwitchTo(int monitor_index) { return 0; }
virtual std::vector<DisplayInfo> GetDisplayInfoList() { return {}; }
private: private:
SckHelper *__strong helper_; SckHelper *__strong helper_;
SCStream *__strong stream_; SCStream *__strong stream_;
@@ -246,7 +254,7 @@ void ScreenCapturerSckImpl::OnNewIOSurface(IOSurfaceRef io_surface,
nv12_frame_ = nv12_frame_ =
static_cast<unsigned char *>(IOSurfaceGetBaseAddress(io_surface)); static_cast<unsigned char *>(IOSurfaceGetBaseAddress(io_surface));
_on_data(nv12_frame_, width * height * 3 / 2, width, height); _on_data(nv12_frame_, width * height * 3 / 2, width, height, 0);
IOSurfaceUnlock(io_surface, kIOSurfaceLockReadOnly, &aseed); IOSurfaceUnlock(io_surface, kIOSurfaceLockReadOnly, &aseed);
} }