mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-12-16 20:17:10 +08:00
Compare commits
6 Commits
v1.1.2-202
...
v1.1.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2188adb1f1 | ||
|
|
51409e16c8 | ||
|
|
6ca3b58ae2 | ||
|
|
692e176e34 | ||
|
|
4fb7acaa61 | ||
|
|
c0d6429a54 |
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -174,7 +174,7 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.xmake/packages
|
||||
key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }}
|
||||
key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-
|
||||
|
||||
@@ -237,7 +237,7 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: D:\xmake_global\.xmake\packages
|
||||
key: ${{ runner.os }}-xmake-deps-intel-${{ hashFiles('**/xmake.lua') }}
|
||||
key: ${{ runner.os }}-xmake-deps-intel-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-xmake-deps-intel-
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ CrossDesk 是 [MiniRTC](https://github.com/kunkundi/minirtc.git) 实时音视频
|
||||
Linux环境下需安装以下包:
|
||||
|
||||
```
|
||||
sudo apt-get install -y software-properties-common git curl unzip build-essential libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev libxcb-xfixes0-dev libxv-dev libxtst-dev libasound2-dev libsndio-dev libxcb-shm0-dev libasound2-dev libpulse-dev
|
||||
sudo apt-get install -y software-properties-common git curl unzip build-essential libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev libxcb-xfixes0-dev libxfixes-dev libxv-dev libxtst-dev libasound2-dev libsndio-dev libxcb-shm0-dev libasound2-dev libpulse-dev
|
||||
```
|
||||
|
||||
编译
|
||||
|
||||
@@ -64,7 +64,7 @@ Requirements:
|
||||
Following packages need to be installed on Linux:
|
||||
|
||||
```
|
||||
sudo apt-get install -y software-properties-common git curl unzip build-essential libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev libxcb-xfixes0-dev libxv-dev libxtst-dev libasound2-dev libsndio-dev libxcb-shm0-dev libasound2-dev libpulse-dev
|
||||
sudo apt-get install -y software-properties-common git curl unzip build-essential libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev libxcb-xfixes0-dev libxfixes-dev libxv-dev libxtst-dev libasound2-dev libsndio-dev libxcb-shm0-dev libasound2-dev libpulse-dev
|
||||
```
|
||||
|
||||
Build:
|
||||
|
||||
@@ -79,7 +79,7 @@ class ConfigCenter {
|
||||
VIDEO_FRAME_RATE video_frame_rate_ = VIDEO_FRAME_RATE::FPS_60;
|
||||
VIDEO_ENCODE_FORMAT video_encode_format_ = VIDEO_ENCODE_FORMAT::H264;
|
||||
bool hardware_video_codec_ = false;
|
||||
bool enable_turn_ = false;
|
||||
bool enable_turn_ = true;
|
||||
bool enable_srtp_ = false;
|
||||
std::string signal_server_host_ = "api.crossdesk.cn";
|
||||
std::string signal_server_host_default_ = "api.crossdesk.cn";
|
||||
|
||||
@@ -448,7 +448,7 @@ class Render {
|
||||
int video_frame_rate_button_value_ = 1;
|
||||
int video_encode_format_button_value_ = 0;
|
||||
bool enable_hardware_video_codec_ = false;
|
||||
bool enable_turn_ = false;
|
||||
bool enable_turn_ = true;
|
||||
bool enable_srtp_ = false;
|
||||
char signal_server_ip_[256] = "api.crossdesk.cn";
|
||||
char signal_server_port_[6] = "9099";
|
||||
@@ -460,7 +460,7 @@ class Render {
|
||||
int video_frame_rate_button_value_last_ = 0;
|
||||
int video_encode_format_button_value_last_ = 0;
|
||||
bool enable_hardware_video_codec_last_ = false;
|
||||
bool enable_turn_last_ = false;
|
||||
bool enable_turn_last_ = true;
|
||||
bool enable_srtp_last_ = false;
|
||||
bool enable_self_hosted_last_ = false;
|
||||
bool enable_autostart_ = false;
|
||||
|
||||
@@ -469,12 +469,12 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char* user_id,
|
||||
render->need_to_send_host_info_ = true;
|
||||
render->start_screen_capturer_ = true;
|
||||
render->start_speaker_capturer_ = true;
|
||||
#ifdef CROSSDESK_DEBUG
|
||||
render->start_mouse_controller_ = false;
|
||||
render->start_keyboard_capturer_ = false;
|
||||
#else
|
||||
// #ifdef CROSSDESK_DEBUG
|
||||
// render->start_mouse_controller_ = false;
|
||||
// render->start_keyboard_capturer_ = false;
|
||||
// #else
|
||||
render->start_mouse_controller_ = true;
|
||||
#endif
|
||||
// #endif
|
||||
if (std::all_of(render->connection_status_.begin(),
|
||||
render->connection_status_.end(), [](const auto& kv) {
|
||||
return kv.first.find("web") != std::string::npos;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "screen_capturer_x11.h"
|
||||
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
@@ -100,6 +102,7 @@ int ScreenCapturerX11::Destroy() {
|
||||
|
||||
int ScreenCapturerX11::Start(bool show_cursor) {
|
||||
if (running_) return 0;
|
||||
show_cursor_ = show_cursor;
|
||||
running_ = true;
|
||||
paused_ = false;
|
||||
thread_ = std::thread([this]() {
|
||||
@@ -156,6 +159,20 @@ void ScreenCapturerX11::OnFrame() {
|
||||
AllPlanes, ZPixmap);
|
||||
if (!image) return;
|
||||
|
||||
// if enable show cursor, draw cursor
|
||||
if (show_cursor_) {
|
||||
Window root_return, child_return;
|
||||
int root_x, root_y, win_x, win_y;
|
||||
unsigned int mask;
|
||||
if (XQueryPointer(display_, root_, &root_return, &child_return, &root_x,
|
||||
&root_y, &win_x, &win_y, &mask)) {
|
||||
if (root_x >= left_ && root_x < left_ + width_ && root_y >= top_ &&
|
||||
root_y < top_ + height_) {
|
||||
DrawCursor(image, root_x - left_, root_y - top_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool needs_copy = image->bytes_per_line != width_ * 4;
|
||||
std::vector<uint8_t> argb_buf;
|
||||
uint8_t* src_argb = nullptr;
|
||||
@@ -186,4 +203,82 @@ void ScreenCapturerX11::OnFrame() {
|
||||
|
||||
XDestroyImage(image);
|
||||
}
|
||||
|
||||
void ScreenCapturerX11::DrawCursor(XImage* image, int x, int y) {
|
||||
if (!display_ || !image) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check XFixes extension
|
||||
int event_base, error_base;
|
||||
if (!XFixesQueryExtension(display_, &event_base, &error_base)) {
|
||||
return;
|
||||
}
|
||||
|
||||
XFixesCursorImage* cursor_image = XFixesGetCursorImage(display_);
|
||||
if (!cursor_image) {
|
||||
return;
|
||||
}
|
||||
|
||||
int cursor_width = cursor_image->width;
|
||||
int cursor_height = cursor_image->height;
|
||||
|
||||
int draw_x = x - cursor_image->xhot;
|
||||
int draw_y = y - cursor_image->yhot;
|
||||
|
||||
// draw cursor on image
|
||||
for (int cy = 0; cy < cursor_height; ++cy) {
|
||||
for (int cx = 0; cx < cursor_width; ++cx) {
|
||||
int img_x = draw_x + cx;
|
||||
int img_y = draw_y + cy;
|
||||
|
||||
if (img_x < 0 || img_x >= image->width || img_y < 0 ||
|
||||
img_y >= image->height) {
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned long cursor_pixel = cursor_image->pixels[cy * cursor_width + cx];
|
||||
unsigned char a = (cursor_pixel >> 24) & 0xFF;
|
||||
|
||||
// if alpha is 0, skip
|
||||
if (a == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned long img_pixel = XGetPixel(image, img_x, img_y);
|
||||
|
||||
unsigned char img_r = (img_pixel >> 16) & 0xFF;
|
||||
unsigned char img_g = (img_pixel >> 8) & 0xFF;
|
||||
unsigned char img_b = img_pixel & 0xFF;
|
||||
|
||||
unsigned char cursor_r = (cursor_pixel >> 16) & 0xFF;
|
||||
unsigned char cursor_g = (cursor_pixel >> 8) & 0xFF;
|
||||
unsigned char cursor_b = cursor_pixel & 0xFF;
|
||||
|
||||
// alpha mix
|
||||
unsigned char final_r, final_g, final_b;
|
||||
if (a == 255) {
|
||||
// if alpha is 255, use cursor color
|
||||
final_r = cursor_r;
|
||||
final_g = cursor_g;
|
||||
final_b = cursor_b;
|
||||
} else {
|
||||
float alpha = a / 255.0f;
|
||||
float inv_alpha = 1.0f - alpha;
|
||||
final_r =
|
||||
static_cast<unsigned char>(cursor_r * alpha + img_r * inv_alpha);
|
||||
final_g =
|
||||
static_cast<unsigned char>(cursor_g * alpha + img_g * inv_alpha);
|
||||
final_b =
|
||||
static_cast<unsigned char>(cursor_b * alpha + img_b * inv_alpha);
|
||||
}
|
||||
|
||||
// set pixel
|
||||
unsigned long new_pixel = (final_r << 16) | (final_g << 8) | final_b;
|
||||
XPutPixel(image, img_x, img_y, new_pixel);
|
||||
}
|
||||
}
|
||||
|
||||
XFree(cursor_image);
|
||||
}
|
||||
} // namespace crossdesk
|
||||
Submodule submodules/minirtc updated: 8bcad95896...0008123221
@@ -45,7 +45,7 @@ elseif is_os("linux") then
|
||||
add_links("pulse-simple", "pulse")
|
||||
add_requires("libyuv")
|
||||
add_syslinks("pthread", "dl")
|
||||
add_links("SDL3", "asound", "X11", "Xtst", "Xrandr")
|
||||
add_links("SDL3", "asound", "X11", "Xtst", "Xrandr", "Xfixes")
|
||||
add_cxflags("-Wno-unused-variable")
|
||||
elseif is_os("macosx") then
|
||||
add_links("SDL3")
|
||||
|
||||
Reference in New Issue
Block a user