Option allow-d3d-render and fix ios ci (#11107)

* option `allow-d3d-render`, default false

Add this option because it fails on some machines

Signed-off-by: 21pages <sunboeasy@gmail.com>

* only add nokhwa to windows and linux dependencies

Signed-off-by: 21pages <sunboeasy@gmail.com>

---------

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2025-03-13 09:34:13 +08:00
committed by GitHub
parent 1403c939db
commit d1c8b331c5
60 changed files with 204 additions and 43 deletions

View File

@@ -1389,14 +1389,15 @@ impl VideoHandler {
}
/// Start or stop screen record.
pub fn record_screen(&mut self, start: bool, id: String, video_service_name: String) {
pub fn record_screen(&mut self, start: bool, id: String, display_idx: usize, camera: bool) {
self.record = false;
if start {
self.recorder = Recorder::new(RecorderContext {
server: false,
id,
dir: crate::ui_interface::video_save_directory(false),
video_service_name,
display_idx,
camera,
tx: None,
})
.map_or(Default::default(), |r| Arc::new(Mutex::new(Some(r))));
@@ -2437,14 +2438,7 @@ pub fn start_video_thread<F, T>(
{
let mut video_callback = video_callback;
let mut last_chroma = None;
let video_service_name = crate::video_service::get_service_name(
if session.is_view_camera() {
crate::video_service::VideoSource::Camera
} else {
crate::video_service::VideoSource::Monitor
},
display,
);
let is_view_camera = session.is_view_camera();
std::thread::spawn(move || {
#[cfg(windows)]
@@ -2487,7 +2481,7 @@ pub fn start_video_thread<F, T>(
let record_permission = session.lc.read().unwrap().record_permission;
let id = session.lc.read().unwrap().id.clone();
if record_state && record_permission {
handler.record_screen(true, id, video_service_name.clone());
handler.record_screen(true, id, display, is_view_camera);
}
video_handler = Some(handler);
}
@@ -2568,7 +2562,7 @@ pub fn start_video_thread<F, T>(
MediaData::RecordScreen(start) => {
let id = session.lc.read().unwrap().id.clone();
if let Some(handler) = video_handler.as_mut() {
handler.record_screen(start, id, video_service_name.clone());
handler.record_screen(start, id, display, is_view_camera);
}
}
_ => {}

View File

@@ -993,6 +993,7 @@ pub fn main_get_env(key: String) -> SyncReturn<String> {
pub fn main_set_local_option(key: String, value: String) {
let is_texture_render_key = key.eq(config::keys::OPTION_TEXTURE_RENDER);
let is_d3d_render_key = key.eq(config::keys::OPTION_ALLOW_D3D_RENDER);
set_local_option(key, value.clone());
if is_texture_render_key {
let session_event = [("v", &value)];
@@ -1002,6 +1003,11 @@ pub fn main_set_local_option(key: String, value: String) {
session.ui_handler.update_use_texture_render();
}
}
if is_d3d_render_key {
for session in sessions::get_sessions() {
session.update_supported_decodings();
}
}
}
// We do use use `main_get_local_option` and `main_set_local_option`.
@@ -1650,7 +1656,7 @@ pub fn session_alternative_codecs(session_id: SessionID) -> String {
pub fn session_change_prefer_codec(session_id: SessionID) {
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
session.change_prefer_codec();
session.update_supported_decodings();
}
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", "您的远程端不支持查看摄像头。"),
("Enable camera", "允许查看摄像头"),
("No cameras", "没有摄像头"),
("d3d_render_tip", "当启用 D3D 渲染时,某些机器可能无法显示远程画面。"),
("Use D3D rendering", "使用 D3D 渲染"),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -240,5 +240,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("View camera", "View camera"),
("upgrade_remote_rustdesk_client_to_{}_tip", "Please upgrade the RustDesk client to version {} or newer on the remote side!"),
("view_camera_unsupported_tip", "The remote device does not support viewing the camera."),
("d3d_render_tip", "When D3D rendering is enabled, the remote control screen may be black on some machines."),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", "Il dispositivo remoto non supporta la visualizzazione della camera."),
("Enable camera", "Abilita camera"),
("No cameras", "Nessuna camera"),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -657,5 +657,12 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
("View camera", ""),
("upgrade_remote_rustdesk_client_to_{}_tip", ""),
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", "您的遠端設備不支援查看鏡頭"),
("Enable camera", "允許查看鏡頭"),
("No cameras", "沒有鏡頭"),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -662,5 +662,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("view_camera_unsupported_tip", ""),
("Enable camera", ""),
("No cameras", ""),
("d3d_render_tip", ""),
("Use D3D rendering", ""),
].iter().cloned().collect();
}

View File

@@ -503,6 +503,7 @@ fn run(vs: VideoService) -> ResultType<()> {
record_incoming,
last_portable_service_running,
vs.source,
display_idx,
) {
Ok(result) => result,
Err(err) => {
@@ -522,6 +523,7 @@ fn run(vs: VideoService) -> ResultType<()> {
record_incoming,
last_portable_service_running,
vs.source,
display_idx,
)?
}
};
@@ -791,6 +793,7 @@ fn setup_encoder(
record_incoming: bool,
last_portable_service_running: bool,
source: VideoSource,
display_idx: usize,
) -> ResultType<(
Encoder,
EncoderCfg,
@@ -808,7 +811,7 @@ fn setup_encoder(
);
Encoder::set_fallback(&encoder_cfg);
let codec_format = Encoder::negotiated_codec();
let recorder = get_recorder(record_incoming, name);
let recorder = get_recorder(record_incoming, display_idx, source == VideoSource::Camera);
let use_i444 = Encoder::use_i444(&encoder_cfg);
let encoder = Encoder::new(encoder_cfg.clone(), use_i444)?;
Ok((encoder, encoder_cfg, codec_format, use_i444, recorder))
@@ -891,7 +894,11 @@ fn get_encoder_config(
}
}
fn get_recorder(record_incoming: bool, video_service_name: String) -> Arc<Mutex<Option<Recorder>>> {
fn get_recorder(
record_incoming: bool,
display_idx: usize,
camera: bool,
) -> Arc<Mutex<Option<Recorder>>> {
#[cfg(windows)]
let root = crate::platform::is_root();
#[cfg(not(windows))]
@@ -910,7 +917,8 @@ fn get_recorder(record_incoming: bool, video_service_name: String) -> Arc<Mutex<
server: true,
id: Config::get_id(),
dir: crate::ui_interface::video_save_directory(root),
video_service_name,
display_idx,
camera,
tx,
})
.map_or(Default::default(), |r| Arc::new(Mutex::new(Some(r))))

View File

@@ -415,7 +415,7 @@ class Header: Reactor.Component {
adaptDisplay();
} else if (type == "codec-preference") {
handler.set_option("codec-preference", me.id);
handler.change_prefer_codec();
handler.update_supported_decodings();
}
toggleMenuState();
}
@@ -587,7 +587,7 @@ function toggleQualityMonitor(name) {
function toggleI444(name) {
handler.toggle_option(name);
handler.change_prefer_codec();
handler.update_supported_decodings();
toggleMenuState();
}

View File

@@ -533,7 +533,7 @@ impl sciter::EventHandler for SciterSession {
fn is_keyboard_mode_supported(String);
fn save_keyboard_mode(String);
fn alternative_codecs();
fn change_prefer_codec();
fn update_supported_decodings();
fn restart_remote_device();
fn request_voice_call();
fn close_voice_call();

View File

@@ -488,14 +488,14 @@ impl<T: InvokeUiSession> Session<T> {
(vp8, av1, h264, h265)
}
pub fn change_prefer_codec(&self) {
pub fn update_supported_decodings(&self) {
let msg = self.lc.write().unwrap().update_supported_decodings();
self.send(Data::Message(msg));
}
pub fn use_texture_render_changed(&self) {
self.send(Data::ResetDecoder(None));
self.change_prefer_codec();
self.update_supported_decodings();
self.send(Data::Message(LoginConfigHandler::refresh()));
}