diff --git a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt index 57b97b7c2..1a709747e 100644 --- a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt +++ b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt @@ -103,6 +103,9 @@ class MainService : Service() { put("scale",SCREEN_INFO.scale) }.toString() } + "is_start" -> { + isStart.toString() + } else -> "" } } @@ -172,10 +175,10 @@ class MainService : Service() { Log.d(logTag, "from rust:stop_capture") stopCapture() } - "is_hardware_codec" -> { - val isHwCodec = arg1.toBoolean() - if (isHardwareCodec != isHwCodec) { - isHardwareCodec = isHwCodec + "half_scale" -> { + val halfScale = arg1.toBoolean() + if (isHalfScale != halfScale) { + isHalfScale = halfScale updateScreenInfo(resources.configuration.orientation) } @@ -251,7 +254,7 @@ class MainService : Service() { super.onDestroy() } - private var isHardwareCodec: Boolean? = null; + private var isHalfScale: Boolean? = null; private fun updateScreenInfo(orientation: Int) { var w: Int var h: Int @@ -284,7 +287,7 @@ class MainService : Service() { Log.d(logTag,"updateScreenInfo:w:$w,h:$h") var scale = 1 if (w != 0 && h != 0) { - if (isHardwareCodec == false && (w > MAX_SCREEN_SIZE || h > MAX_SCREEN_SIZE)) { + if (isHalfScale == true && (w > MAX_SCREEN_SIZE || h > MAX_SCREEN_SIZE)) { scale = 2 w /= scale h /= scale diff --git a/flutter/lib/consts.dart b/flutter/lib/consts.dart index 9cbfd265e..4568a3f02 100644 --- a/flutter/lib/consts.dart +++ b/flutter/lib/consts.dart @@ -134,6 +134,7 @@ const String kOptionEnableCheckUpdate = "enable-check-update"; const String kOptionAllowLinuxHeadless = "allow-linux-headless"; const String kOptionAllowRemoveWallpaper = "allow-remove-wallpaper"; const String kOptionStopService = "stop-service"; +const String kOptionDirectxCapture = "enable-directx-capture"; const String kOptionToggleViewOnly = "view-only"; diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dart index 04385ce50..81717de3b 100644 --- a/flutter/lib/desktop/pages/desktop_setting_page.dart +++ b/flutter/lib/desktop/pages/desktop_setting_page.dart @@ -315,11 +315,11 @@ class _GeneralState extends State<_General> { children: [ service(), theme(), + _Card(title: 'Language', children: [language()]), hwcodec(), audio(context), record(context), WaylandCard(), - _Card(title: 'Language', children: [language()]), other() ], ).marginOnly(bottom: _kListViewBottomMargin)); @@ -413,6 +413,12 @@ class _GeneralState extends State<_General> { 'Check for software update on startup', kOptionEnableCheckUpdate, isServer: false, + ), + if (isWindows && !bind.isOutgoingOnly()) + _OptionCheckBox( + context, + 'Capture screen using DirectX', + kOptionDirectxCapture, ) ], ]; diff --git a/libs/hbb_common/src/config.rs b/libs/hbb_common/src/config.rs index 3c37bd8e9..5846563bb 100644 --- a/libs/hbb_common/src/config.rs +++ b/libs/hbb_common/src/config.rs @@ -2084,6 +2084,9 @@ pub mod keys { pub const OPTION_KEY: &str = "key"; pub const OPTION_PRESET_ADDRESS_BOOK_NAME: &str = "preset-address-book-name"; pub const OPTION_PRESET_ADDRESS_BOOK_TAG: &str = "preset-address-book-tag"; + pub const OPTION_ENABLE_DIRECTX_CAPTURE: &str = "enable-directx-capture"; + pub const OPTION_ENABLE_ANDRIOD_SOFTWARE_ENCODING_HALF_SCALE: &str = + "enable-andriod-software-encoding-half-scale"; // flutter local options pub const OPTION_FLUTTER_REMOTE_MENUBAR_STATE: &str = "remoteMenubarState"; @@ -2206,6 +2209,8 @@ pub mod keys { OPTION_KEY, OPTION_PRESET_ADDRESS_BOOK_NAME, OPTION_PRESET_ADDRESS_BOOK_TAG, + OPTION_ENABLE_DIRECTX_CAPTURE, + OPTION_ENABLE_ANDRIOD_SOFTWARE_ENCODING_HALF_SCALE, ]; } diff --git a/libs/scrap/src/common/android.rs b/libs/scrap/src/common/android.rs index dffbc9ff7..49956fcce 100644 --- a/libs/scrap/src/common/android.rs +++ b/libs/scrap/src/common/android.rs @@ -182,3 +182,8 @@ fn get_size() -> Option<(u16, u16, u16)> { } None } + +pub fn is_start() -> Option { + let res = call_main_service_get_by_name("is_start").ok()?; + Some(res == "true") +} diff --git a/libs/scrap/src/common/codec.rs b/libs/scrap/src/common/codec.rs index a095cdd6c..9fbcae2cd 100644 --- a/libs/scrap/src/common/codec.rs +++ b/libs/scrap/src/common/codec.rs @@ -21,8 +21,8 @@ use crate::{ use hbb_common::{ anyhow::anyhow, bail, - config::PeerConfig, - log, + config::{keys::OPTION_ENABLE_HWCODEC, option2bool, Config, PeerConfig}, + lazy_static, log, message_proto::{ supported_decoding::PreferCodec, video_frame, Chroma, CodecAbility, EncodedVideoFrames, SupportedDecoding, SupportedEncoding, VideoFrame, @@ -31,8 +31,6 @@ use hbb_common::{ tokio::time::Instant, ResultType, }; -#[cfg(any(feature = "hwcodec", feature = "mediacodec", feature = "vram"))] -use hbb_common::{config::Config2, lazy_static}; lazy_static::lazy_static! { static ref PEER_DECODINGS: Arc>> = Default::default(); @@ -201,7 +199,7 @@ impl Encoder { #[allow(unused_mut)] let mut h265vram_encoding = false; #[cfg(feature = "vram")] - if enable_vram_option() { + if enable_vram_option(true) { if _all_support_h264_decoding { if VRamEncoder::available(CodecFormat::H264).len() > 0 { h264vram_encoding = true; @@ -340,7 +338,7 @@ impl Encoder { encoding.h265 |= HwRamEncoder::try_get(CodecFormat::H265).is_some(); } #[cfg(feature = "vram")] - if enable_vram_option() { + if enable_vram_option(true) { encoding.h264 |= VRamEncoder::available(CodecFormat::H264).len() > 0; encoding.h265 |= VRamEncoder::available(CodecFormat::H265).len() > 0; } @@ -451,7 +449,7 @@ impl Decoder { }; } #[cfg(feature = "vram")] - if enable_vram_option() && _use_texture_render { + if enable_vram_option(false) && _use_texture_render { decoding.ability_h264 |= if VRamDecoder::available(CodecFormat::H264, _luid).len() > 0 { 1 } else { @@ -530,7 +528,7 @@ impl Decoder { } CodecFormat::H264 => { #[cfg(feature = "vram")] - if !valid && enable_vram_option() && _luid.clone().unwrap_or_default() != 0 { + if !valid && enable_vram_option(false) && _luid.clone().unwrap_or_default() != 0 { match VRamDecoder::new(format, _luid) { Ok(v) => h264_vram = Some(v), Err(e) => log::error!("create H264 vram decoder failed: {}", e), @@ -556,7 +554,7 @@ impl Decoder { } CodecFormat::H265 => { #[cfg(feature = "vram")] - if !valid && enable_vram_option() && _luid.clone().unwrap_or_default() != 0 { + if !valid && enable_vram_option(false) && _luid.clone().unwrap_or_default() != 0 { match VRamDecoder::new(format, _luid) { Ok(v) => h265_vram = Some(v), Err(e) => log::error!("create H265 vram decoder failed: {}", e), @@ -839,19 +837,37 @@ impl Decoder { #[cfg(any(feature = "hwcodec", feature = "mediacodec"))] pub fn enable_hwcodec_option() -> bool { if cfg!(windows) || cfg!(target_os = "linux") || cfg!(target_os = "android") { - if let Some(v) = Config2::get().options.get("enable-hwcodec") { - return v != "N"; - } - return true; // default is true + return option2bool( + OPTION_ENABLE_HWCODEC, + &Config::get_option(OPTION_ENABLE_HWCODEC), + ); } false } #[cfg(feature = "vram")] -pub fn enable_vram_option() -> bool { - if let Some(v) = Config2::get().options.get("enable-hwcodec") { - return v != "N"; +pub fn enable_vram_option(encode: bool) -> bool { + if cfg!(windows) { + let enable = option2bool( + OPTION_ENABLE_HWCODEC, + &Config::get_option(OPTION_ENABLE_HWCODEC), + ); + if encode { + enable && enable_directx_capture() + } else { + enable + } + } else { + false } - return true; // default is true +} + +#[cfg(windows)] +pub fn enable_directx_capture() -> bool { + use hbb_common::config::keys::OPTION_ENABLE_DIRECTX_CAPTURE as OPTION; + option2bool( + OPTION, + &Config::get_option(hbb_common::config::keys::OPTION_ENABLE_DIRECTX_CAPTURE), + ) } #[derive(Debug, Clone, Copy, PartialEq, Eq)] diff --git a/libs/scrap/src/common/mod.rs b/libs/scrap/src/common/mod.rs index 13129db55..085d1e501 100644 --- a/libs/scrap/src/common/mod.rs +++ b/libs/scrap/src/common/mod.rs @@ -491,3 +491,8 @@ pub trait GoogleImage { pub fn screen_size() -> (u16, u16, u16) { SCREEN_SIZE.lock().unwrap().clone() } + +#[cfg(target_os = "android")] +pub fn is_start() -> Option { + android::is_start() +} diff --git a/libs/scrap/src/common/vram.rs b/libs/scrap/src/common/vram.rs index 241908b74..a2b4d348c 100644 --- a/libs/scrap/src/common/vram.rs +++ b/libs/scrap/src/common/vram.rs @@ -354,7 +354,7 @@ impl VRamDecoder { } pub fn possible_available_without_check() -> (bool, bool) { - if !enable_vram_option() { + if !enable_vram_option(false) { return (false, false); } let v = crate::hwcodec::HwCodecConfig::get().vram_decode; diff --git a/src/lang/ar.rs b/src/lang/ar.rs index 034831410..ab5e6a629 100644 --- a/src/lang/ar.rs +++ b/src/lang/ar.rs @@ -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(); } diff --git a/src/lang/bg.rs b/src/lang/bg.rs index 42da65078..b72b24545 100644 --- a/src/lang/bg.rs +++ b/src/lang/bg.rs @@ -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(); } diff --git a/src/lang/ca.rs b/src/lang/ca.rs index 0e86032d7..1a59ae9c7 100644 --- a/src/lang/ca.rs +++ b/src/lang/ca.rs @@ -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(); } diff --git a/src/lang/cn.rs b/src/lang/cn.rs index ad4026dc3..553a4b27a 100644 --- a/src/lang/cn.rs +++ b/src/lang/cn.rs @@ -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(); } diff --git a/src/lang/cs.rs b/src/lang/cs.rs index 1fbc0bf8c..1ff602be7 100644 --- a/src/lang/cs.rs +++ b/src/lang/cs.rs @@ -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(); } diff --git a/src/lang/da.rs b/src/lang/da.rs index 42f9c751c..3e4a673bd 100644 --- a/src/lang/da.rs +++ b/src/lang/da.rs @@ -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(); } diff --git a/src/lang/de.rs b/src/lang/de.rs index c950648ba..dab7a9cc3 100644 --- a/src/lang/de.rs +++ b/src/lang/de.rs @@ -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(); } diff --git a/src/lang/el.rs b/src/lang/el.rs index 35b2e7c35..69fa86276 100644 --- a/src/lang/el.rs +++ b/src/lang/el.rs @@ -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(); } diff --git a/src/lang/eo.rs b/src/lang/eo.rs index 49ce149bc..1afae0870 100644 --- a/src/lang/eo.rs +++ b/src/lang/eo.rs @@ -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(); } diff --git a/src/lang/es.rs b/src/lang/es.rs index c9ceba5d0..8fc97a9e9 100644 --- a/src/lang/es.rs +++ b/src/lang/es.rs @@ -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(); } diff --git a/src/lang/et.rs b/src/lang/et.rs index e96eaa276..f1d04fe27 100644 --- a/src/lang/et.rs +++ b/src/lang/et.rs @@ -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(); } diff --git a/src/lang/fa.rs b/src/lang/fa.rs index 923aca2e2..189fd4e34 100644 --- a/src/lang/fa.rs +++ b/src/lang/fa.rs @@ -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(); } diff --git a/src/lang/fr.rs b/src/lang/fr.rs index 54894c667..0d8525dbf 100644 --- a/src/lang/fr.rs +++ b/src/lang/fr.rs @@ -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(); } diff --git a/src/lang/he.rs b/src/lang/he.rs index 6ef587819..1b415de90 100644 --- a/src/lang/he.rs +++ b/src/lang/he.rs @@ -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(); } diff --git a/src/lang/hr.rs b/src/lang/hr.rs index 34ade8489..e919325d4 100644 --- a/src/lang/hr.rs +++ b/src/lang/hr.rs @@ -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(); } diff --git a/src/lang/hu.rs b/src/lang/hu.rs index 9ddeb3f9f..7bb267a86 100644 --- a/src/lang/hu.rs +++ b/src/lang/hu.rs @@ -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(); } diff --git a/src/lang/id.rs b/src/lang/id.rs index 5dbd233ec..e77ad4504 100644 --- a/src/lang/id.rs +++ b/src/lang/id.rs @@ -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(); } diff --git a/src/lang/it.rs b/src/lang/it.rs index d1499b8f7..7e33b6fbe 100644 --- a/src/lang/it.rs +++ b/src/lang/it.rs @@ -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(); } diff --git a/src/lang/ja.rs b/src/lang/ja.rs index 0ee196941..c0bbf7038 100644 --- a/src/lang/ja.rs +++ b/src/lang/ja.rs @@ -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(); } diff --git a/src/lang/ko.rs b/src/lang/ko.rs index 756a5a04c..c101d1513 100644 --- a/src/lang/ko.rs +++ b/src/lang/ko.rs @@ -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(); } diff --git a/src/lang/kz.rs b/src/lang/kz.rs index 3d4793d67..8d5a214dd 100644 --- a/src/lang/kz.rs +++ b/src/lang/kz.rs @@ -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(); } diff --git a/src/lang/lt.rs b/src/lang/lt.rs index 7fb256f33..ab2dde495 100644 --- a/src/lang/lt.rs +++ b/src/lang/lt.rs @@ -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(); } diff --git a/src/lang/lv.rs b/src/lang/lv.rs index b1db124c2..1b00e7de2 100644 --- a/src/lang/lv.rs +++ b/src/lang/lv.rs @@ -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(); } diff --git a/src/lang/nb.rs b/src/lang/nb.rs index 098fa82ba..edebfc7af 100644 --- a/src/lang/nb.rs +++ b/src/lang/nb.rs @@ -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(); } diff --git a/src/lang/nl.rs b/src/lang/nl.rs index 8ba24d862..85d1d63a5 100644 --- a/src/lang/nl.rs +++ b/src/lang/nl.rs @@ -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(); } diff --git a/src/lang/pl.rs b/src/lang/pl.rs index 0b9e1ba6e..0f4707ddb 100644 --- a/src/lang/pl.rs +++ b/src/lang/pl.rs @@ -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(); } diff --git a/src/lang/pt_PT.rs b/src/lang/pt_PT.rs index b77af7dc1..e5b53e559 100644 --- a/src/lang/pt_PT.rs +++ b/src/lang/pt_PT.rs @@ -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(); } diff --git a/src/lang/ptbr.rs b/src/lang/ptbr.rs index 1e4ad748e..072426ff2 100644 --- a/src/lang/ptbr.rs +++ b/src/lang/ptbr.rs @@ -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(); } diff --git a/src/lang/ro.rs b/src/lang/ro.rs index e81f5ed32..acdd4a987 100644 --- a/src/lang/ro.rs +++ b/src/lang/ro.rs @@ -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(); } diff --git a/src/lang/ru.rs b/src/lang/ru.rs index 9364ebbfa..364946a39 100644 --- a/src/lang/ru.rs +++ b/src/lang/ru.rs @@ -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(); } diff --git a/src/lang/sk.rs b/src/lang/sk.rs index 3f085251e..542373de2 100644 --- a/src/lang/sk.rs +++ b/src/lang/sk.rs @@ -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(); } diff --git a/src/lang/sl.rs b/src/lang/sl.rs index 97554bb97..dcf5192d9 100755 --- a/src/lang/sl.rs +++ b/src/lang/sl.rs @@ -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(); } diff --git a/src/lang/sq.rs b/src/lang/sq.rs index 94d560c9e..d7abb5b4a 100644 --- a/src/lang/sq.rs +++ b/src/lang/sq.rs @@ -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(); } diff --git a/src/lang/sr.rs b/src/lang/sr.rs index 550f73e5c..8c3cea8b6 100644 --- a/src/lang/sr.rs +++ b/src/lang/sr.rs @@ -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(); } diff --git a/src/lang/sv.rs b/src/lang/sv.rs index 1ebac149b..2aceeba28 100644 --- a/src/lang/sv.rs +++ b/src/lang/sv.rs @@ -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(); } diff --git a/src/lang/template.rs b/src/lang/template.rs index d15af13d8..3166f9194 100644 --- a/src/lang/template.rs +++ b/src/lang/template.rs @@ -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(); } diff --git a/src/lang/th.rs b/src/lang/th.rs index b2dfe9a25..2c4e32aaa 100644 --- a/src/lang/th.rs +++ b/src/lang/th.rs @@ -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(); } diff --git a/src/lang/tr.rs b/src/lang/tr.rs index 103c5c833..47a7a133a 100644 --- a/src/lang/tr.rs +++ b/src/lang/tr.rs @@ -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(); } diff --git a/src/lang/tw.rs b/src/lang/tw.rs index 459e45c82..7833d5747 100644 --- a/src/lang/tw.rs +++ b/src/lang/tw.rs @@ -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(); } diff --git a/src/lang/ua.rs b/src/lang/ua.rs index 8412a6959..fee60a93a 100644 --- a/src/lang/ua.rs +++ b/src/lang/ua.rs @@ -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(); } diff --git a/src/lang/vn.rs b/src/lang/vn.rs index 46ee58c67..acefe2fa5 100644 --- a/src/lang/vn.rs +++ b/src/lang/vn.rs @@ -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(); } diff --git a/src/server/video_service.rs b/src/server/video_service.rs index 7cdaa521f..eb9ec8689 100644 --- a/src/server/video_service.rs +++ b/src/server/video_service.rs @@ -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.