add enable directx option, android software encoding half resolution option (#8435)

* add option enable directx capture screen, default true

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

* option android software encoding half scale, check isStart flag

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

---------

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2024-06-21 18:54:32 +08:00
committed by GitHub
parent ff2e055a5a
commit 0f6538c1a7
50 changed files with 133 additions and 30 deletions

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", "从不"),
("During controlled", "被控期间"),
("During service is on", "服务开启期间"),
("Capture screen using DirectX", "使用 DirectX 捕获屏幕"),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", "Nikdy"),
("During controlled", "Během řízeného"),
("During service is on", "Během služby je v provozu"),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", "Niemals"),
("During controlled", "Wenn kontrolliert"),
("During service is on", "Wenn der Dienst läuft"),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", "Nunca"),
("During controlled", "Mientras está siendo controlado"),
("During service is on", "Mientras el servicio está activo"),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", "Mai"),
("During controlled", "Durante il controllo"),
("During service is on", "Quando il servizio è attivo"),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", "Nekad"),
("During controlled", "Lietošanas laikā"),
("During service is on", "Kamēr pakalpojums ir ieslēgts"),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -125,7 +125,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Good image quality", "Лучшее качество изображения"),
("Balanced", "Баланс между качеством и откликом"),
("Optimize reaction time", "Лучшее время отклика"),
("Custom", "Заданное пользователем"),
("Custom", "Заданное пользователем"),
("Show remote cursor", "Показывать удалённый курсор"),
("Show quality monitor", "Показывать монитор качества"),
("Disable clipboard", "Отключить буфер обмена"),
@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", "Нет"),
("During controlled", "При управлении"),
("During service is on", "При запущенной службе"),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", "Nikdy"),
("During controlled", "Počas kontrolovaného"),
("During service is on", "Počas služby je v prevádzke"),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", "從不"),
("During controlled", "被控期間"),
("During service is on", "服務開啟期間"),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -621,5 +621,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Never", ""),
("During controlled", ""),
("During service is on", ""),
("Capture screen using DirectX", ""),
].iter().cloned().collect();
}

View File

@@ -407,7 +407,11 @@ fn run(vs: VideoService) -> ResultType<()> {
let display_idx = vs.idx;
let sp = vs.sp;
let mut c = get_capturer(display_idx, last_portable_service_running)?;
#[cfg(windows)]
if !scrap::codec::enable_directx_capture() && !c.is_gdi() {
log::info!("disable dxgi with option, fall back to gdi");
c.set_gdi();
}
let mut video_qos = VIDEO_QOS.lock().unwrap();
video_qos.refresh(None);
let mut spf;
@@ -837,16 +841,33 @@ fn get_recorder(
#[cfg(target_os = "android")]
fn check_change_scale(hardware: bool) -> ResultType<()> {
use hbb_common::config::keys::OPTION_ENABLE_ANDRIOD_SOFTWARE_ENCODING_HALF_SCALE as SCALE_SOFT;
// isStart flag is set at the end of startCapture() in Android, wait it to be set.
for i in 0..6 {
if scrap::is_start() == Some(true) {
log::info!("start flag is set");
break;
}
log::info!("wait for start, {i}");
std::thread::sleep(Duration::from_millis(50));
if i == 5 {
log::error!("wait for start timeout");
}
}
let screen_size = scrap::screen_size();
log::info!("hardware: {hardware}, screen_size: {screen_size:?}",);
let scale_soft = hbb_common::config::option2bool(SCALE_SOFT, &Config::get_option(SCALE_SOFT));
let half_scale = !hardware && scale_soft;
log::info!("hardware: {hardware}, scale_soft: {scale_soft}, screen_size: {screen_size:?}",);
scrap::android::call_main_service_set_by_name(
"is_hardware_codec",
Some(hardware.to_string().as_str()),
"half_scale",
Some(half_scale.to_string().as_str()),
None,
)
.ok();
let old_scale = screen_size.2;
let new_scale = scrap::screen_size().2;
log::info!("old_scale: {old_scale}, new_scale: {new_scale}");
if old_scale != new_scale {
log::info!("switch due to scale changed, {old_scale} -> {new_scale}");
// switch is not a must, but it is better to do so.