mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
enable ffmpeg native h26x software decoders for all platforms (#7750)
* enable ffmpeg native h26x software decoders for all platforms * h26x software decoders depend on hwcodec feature, so all platforms enable it, software h26x decoders are always available like vpx, no available check and no option * ffmpeg: - build: mac arm64 build ffmpeg with my m1, others build with ci - version: win/linux use ffmpeg release/5.1, becaues higher version require higher nvidia driver, other platforms use release/7.0 * test: - ios not test. - android: sometimes the screen will appear blurry, but it will recover after a while. - arm64 linux: test a example of hwcodec repo Signed-off-by: 21pages <pages21@163.com> * check hwcodec only when enabled and immediately when clicked enabled Signed-off-by: 21pages <pages21@163.com> --------- Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -2100,6 +2100,10 @@ pub fn main_get_hard_option(key: String) -> SyncReturn<String> {
|
||||
SyncReturn(get_hard_option(key))
|
||||
}
|
||||
|
||||
pub fn main_check_hwcodec() {
|
||||
check_hwcodec()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub mod server_side {
|
||||
use hbb_common::{config, log};
|
||||
|
||||
15
src/ipc.rs
15
src/ipc.rs
@@ -232,6 +232,7 @@ pub enum Data {
|
||||
#[cfg(windows)]
|
||||
ControlledSessionCount(usize),
|
||||
CmErr(String),
|
||||
CheckHwcodec,
|
||||
}
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
@@ -502,6 +503,14 @@ async fn handle(data: Data, stream: &mut Connection) {
|
||||
.await
|
||||
);
|
||||
}
|
||||
Data::CheckHwcodec =>
|
||||
{
|
||||
#[cfg(feature = "hwcodec")]
|
||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||
if crate::platform::is_root() {
|
||||
scrap::hwcodec::start_check_process(true);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -926,6 +935,12 @@ pub async fn connect_to_user_session(usid: Option<u32>) -> ResultType<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
pub async fn notify_server_to_check_hwcodec() -> ResultType<()> {
|
||||
connect(1_000, "").await?.send(&&Data::CheckHwcodec).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
@@ -449,7 +449,8 @@ pub async fn start_server(is_server: bool) {
|
||||
log::info!("XAUTHORITY={:?}", std::env::var("XAUTHORITY"));
|
||||
}
|
||||
#[cfg(feature = "hwcodec")]
|
||||
scrap::hwcodec::hwcodec_new_check_process();
|
||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||
scrap::hwcodec::start_check_process(false);
|
||||
#[cfg(windows)]
|
||||
hbb_common::platform::windows::start_cpu_performance_monitor();
|
||||
|
||||
|
||||
@@ -715,9 +715,6 @@ fn handle_hw_encoder(
|
||||
#[cfg(feature = "hwcodec")]
|
||||
match _name {
|
||||
CodecName::H264VRAM | CodecName::H265VRAM => {
|
||||
if !scrap::codec::enable_hwcodec_option() {
|
||||
return Err(());
|
||||
}
|
||||
let is_h265 = _name == CodecName::H265VRAM;
|
||||
let best = HwRamEncoder::best();
|
||||
if let Some(h264) = best.h264 {
|
||||
|
||||
@@ -621,6 +621,10 @@ impl UI {
|
||||
);
|
||||
format!("data:image/png;base64,{s}")
|
||||
}
|
||||
|
||||
pub fn check_hwcodec(&self) {
|
||||
check_hwcodec()
|
||||
}
|
||||
}
|
||||
|
||||
impl sciter::EventHandler for UI {
|
||||
@@ -711,6 +715,7 @@ impl sciter::EventHandler for UI {
|
||||
fn generate2fa();
|
||||
fn generate_2fa_img_src(String);
|
||||
fn verify2fa(String);
|
||||
fn check_hwcodec();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -240,7 +240,11 @@ class Enhancements: Reactor.Component {
|
||||
event click $(menu#enhancements-menu>li) (_, me) {
|
||||
var v = me.id;
|
||||
if (v.indexOf("enable-") == 0) {
|
||||
handler.set_option(v, handler.get_option(v) != 'N' ? 'N' : '');
|
||||
var set_value = handler.get_option(v) != 'N' ? 'N' : '';
|
||||
handler.set_option(v, set_value);
|
||||
if (v == "enable-hwcodec" && set_value == '') {
|
||||
handler.check_hwcodec();
|
||||
}
|
||||
} else if (v.indexOf("allow-") == 0) {
|
||||
handler.set_option(v, handler.get_option(v) == 'Y' ? '' : 'Y');
|
||||
} else if (v == 'screen-recording') {
|
||||
|
||||
@@ -829,10 +829,9 @@ pub fn get_api_server() -> String {
|
||||
|
||||
#[inline]
|
||||
pub fn has_hwcodec() -> bool {
|
||||
#[cfg(not(any(feature = "hwcodec", feature = "mediacodec")))]
|
||||
return false;
|
||||
#[cfg(any(feature = "hwcodec", feature = "mediacodec"))]
|
||||
return true;
|
||||
// Has real hardware codec using gpu
|
||||
(cfg!(feature = "hwcodec") && (cfg!(windows) || cfg!(target_os = "linux")))
|
||||
|| cfg!(feature = "mediacodec")
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -1315,3 +1314,14 @@ pub fn verify2fa(code: String) -> bool {
|
||||
}
|
||||
res
|
||||
}
|
||||
|
||||
pub fn check_hwcodec() {
|
||||
#[cfg(feature = "hwcodec")]
|
||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||
{
|
||||
scrap::hwcodec::start_check_process(true);
|
||||
if crate::platform::is_installed() {
|
||||
ipc::notify_server_to_check_hwcodec().ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user