mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
disable hardware encoding if encoding fails too many times (#8327)
Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -308,6 +308,8 @@ impl EncoderApi for AomEncoder {
|
||||
fn is_hardware(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn disable(&self) {}
|
||||
}
|
||||
|
||||
impl AomEncoder {
|
||||
|
||||
@@ -76,6 +76,8 @@ pub trait EncoderApi {
|
||||
fn latency_free(&self) -> bool;
|
||||
|
||||
fn is_hardware(&self) -> bool;
|
||||
|
||||
fn disable(&self);
|
||||
}
|
||||
|
||||
pub struct Encoder {
|
||||
@@ -145,7 +147,6 @@ impl Encoder {
|
||||
Err(e) => {
|
||||
log::error!("new hw encoder failed: {e:?}, clear config");
|
||||
HwCodecConfig::clear(false, true);
|
||||
Self::update(EncodingUpdate::Check);
|
||||
*ENCODE_CODEC_FORMAT.lock().unwrap() = CodecFormat::VP9;
|
||||
Err(e)
|
||||
}
|
||||
@@ -158,7 +159,6 @@ impl Encoder {
|
||||
Err(e) => {
|
||||
log::error!("new vram encoder failed: {e:?}, clear config");
|
||||
HwCodecConfig::clear(true, true);
|
||||
Self::update(EncodingUpdate::Check);
|
||||
*ENCODE_CODEC_FORMAT.lock().unwrap() = CodecFormat::VP9;
|
||||
Err(e)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ use hbb_common::{
|
||||
};
|
||||
use hwcodec::{
|
||||
common::{
|
||||
get_gpu_signature, DataFormat,
|
||||
DataFormat,
|
||||
Quality::{self, *},
|
||||
RateControl::{self, *},
|
||||
},
|
||||
@@ -210,6 +210,10 @@ impl EncoderApi for HwRamEncoder {
|
||||
fn is_hardware(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn disable(&self) {
|
||||
HwCodecConfig::clear(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
impl HwRamEncoder {
|
||||
@@ -582,7 +586,7 @@ impl HwCodecConfig {
|
||||
None => {
|
||||
log::info!("try load cached hwcodec config");
|
||||
let c = hbb_common::config::common_load::<HwCodecConfig>("_hwcodec");
|
||||
let new_signature = get_gpu_signature();
|
||||
let new_signature = hwcodec::common::get_gpu_signature();
|
||||
if c.signature == new_signature {
|
||||
log::debug!("load cached hwcodec config: {c:?}");
|
||||
*CONFIG.lock().unwrap() = Some(c.clone());
|
||||
@@ -647,6 +651,7 @@ impl HwCodecConfig {
|
||||
}
|
||||
}
|
||||
}
|
||||
crate::codec::Encoder::update(crate::codec::EncodingUpdate::Check);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -679,7 +684,7 @@ pub fn check_available_hwcodec() -> String {
|
||||
vram_encode: vram.0,
|
||||
#[cfg(feature = "vram")]
|
||||
vram_decode: vram.1,
|
||||
signature: get_gpu_signature(),
|
||||
signature: hwcodec::common::get_gpu_signature(),
|
||||
};
|
||||
log::debug!("{c:?}");
|
||||
serde_json::to_string(&c).unwrap_or_default()
|
||||
|
||||
@@ -246,6 +246,8 @@ impl EncoderApi for VpxEncoder {
|
||||
fn is_hardware(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn disable(&self) {}
|
||||
}
|
||||
|
||||
impl VpxEncoder {
|
||||
|
||||
@@ -194,6 +194,10 @@ impl EncoderApi for VRamEncoder {
|
||||
fn is_hardware(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn disable(&self) {
|
||||
HwCodecConfig::clear(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
impl VRamEncoder {
|
||||
|
||||
Reference in New Issue
Block a user