diff --git a/Info.plist b/Info.plist
index 8a20f46..ccd79bf 100644
--- a/Info.plist
+++ b/Info.plist
@@ -30,6 +30,10 @@
NSCameraUseContinuityCameraDeviceType
Your usage description here
+ >
+ NSHighResolutionCapable
+
+
\ No newline at end of file
diff --git a/src/device_controller/mouse/mac/mouse_controller.cpp b/src/device_controller/mouse/mac/mouse_controller.cpp
index 3f58ff2..24ee943 100644
--- a/src/device_controller/mouse/mac/mouse_controller.cpp
+++ b/src/device_controller/mouse/mac/mouse_controller.cpp
@@ -12,14 +12,19 @@ int MouseController::Init(int screen_width, int screen_height) {
screen_width_ = screen_width;
screen_height_ = screen_height;
+ pixel_width_ =
+ CGDisplayModeGetPixelWidth(CGDisplayCopyDisplayMode(CGMainDisplayID()));
+ pixel_height_ =
+ CGDisplayModeGetPixelHeight(CGDisplayCopyDisplayMode(CGMainDisplayID()));
+
return 0;
}
int MouseController::Destroy() { return 0; }
int MouseController::SendCommand(RemoteAction remote_action) {
- int mouse_pos_x = remote_action.m.x;
- int mouse_pos_y = remote_action.m.y;
+ int mouse_pos_x = remote_action.m.x * screen_width_ / pixel_width_;
+ int mouse_pos_y = remote_action.m.y * screen_height_ / pixel_height_;
if (remote_action.type == ControlType::mouse) {
CGEventRef mouse_event;
diff --git a/src/device_controller/mouse/mac/mouse_controller.h b/src/device_controller/mouse/mac/mouse_controller.h
index 7ad3e9c..8c07df6 100644
--- a/src/device_controller/mouse/mac/mouse_controller.h
+++ b/src/device_controller/mouse/mac/mouse_controller.h
@@ -22,6 +22,9 @@ class MouseController : public DeviceController {
private:
int screen_width_ = 0;
int screen_height_ = 0;
+
+ int pixel_width_ = 0;
+ int pixel_height_ = 0;
};
#endif
\ No newline at end of file
diff --git a/src/screen_capturer/macosx/screen_capturer_avf.cpp b/src/screen_capturer/macosx/screen_capturer_avf.cpp
index 8c7514a..317f1c1 100644
--- a/src/screen_capturer/macosx/screen_capturer_avf.cpp
+++ b/src/screen_capturer/macosx/screen_capturer_avf.cpp
@@ -6,6 +6,8 @@
#include "rd_log.h"
+#define USE_SCALE_FACTOR 0
+
ScreenCapturerAvf::ScreenCapturerAvf() {}
ScreenCapturerAvf::~ScreenCapturerAvf() {
@@ -44,7 +46,7 @@ ScreenCapturerAvf::~ScreenCapturerAvf() {
packet_ = nullptr;
}
-#if 1
+#if USE_SCALE_FACTOR
if (img_convert_ctx_) {
sws_freeContext(img_convert_ctx_);
img_convert_ctx_ = nullptr;
@@ -122,7 +124,7 @@ int ScreenCapturerAvf::Init(const int fps, cb_desktop_data cb) {
pFrame_->width = screen_w;
pFrame_->height = screen_h;
-#if 1
+#if USE_SCALE_FACTOR
pFrame_resized_ = av_frame_alloc();
pFrame_resized_->width = CGDisplayPixelsWide(CGMainDisplayID());
pFrame_resized_->height = CGDisplayPixelsHigh(CGMainDisplayID());
@@ -164,17 +166,7 @@ int ScreenCapturerAvf::Start() {
got_picture_ = avcodec_receive_frame(pCodecCtx_, pFrame_);
if (!got_picture_) {
-#if 0
- memcpy(nv12_frame_, pFrame_->data[0],
- pFrame_->linesize[0] * pFrame_->height);
- memcpy(nv12_frame_ + pFrame_->linesize[0] * pFrame_->height,
- pFrame_->data[1],
- pFrame_->linesize[1] * pFrame_->height / 2);
- LOG_ERROR("size {} {}", pFrame_->width, pFrame_->height);
- _on_data((unsigned char *)nv12_frame_,
- pFrame_->width * pFrame_->height * 3 / 2, pFrame_->width,
- pFrame_->height);
-#else
+#if USE_SCALE_FACTOR
av_image_fill_arrays(pFrame_resized_->data,
pFrame_resized_->linesize, nv12_frame_,
AV_PIX_FMT_NV12, pFrame_resized_->width,
@@ -187,6 +179,15 @@ int ScreenCapturerAvf::Start() {
_on_data((unsigned char *)nv12_frame_,
pFrame_resized_->width * pFrame_resized_->height * 3 / 2,
pFrame_resized_->width, pFrame_resized_->height);
+#else
+ memcpy(nv12_frame_, pFrame_->data[0],
+ pFrame_->linesize[0] * pFrame_->height);
+ memcpy(nv12_frame_ + pFrame_->linesize[0] * pFrame_->height,
+ pFrame_->data[1],
+ pFrame_->linesize[1] * pFrame_->height / 2);
+ _on_data((unsigned char *)nv12_frame_,
+ pFrame_->width * pFrame_->height * 3 / 2, pFrame_->width,
+ pFrame_->height);
#endif
}
}