mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
enable hwcodec
This commit is contained in:
@@ -11,8 +11,9 @@ use crate::vpxcodec::*;
|
||||
|
||||
use hbb_common::{
|
||||
anyhow::anyhow,
|
||||
config::Config2,
|
||||
log,
|
||||
message_proto::{video_frame, Message, VP9s, VideoCodecState, test_delay},
|
||||
message_proto::{test_delay, video_frame, Message, VP9s, VideoCodecState},
|
||||
ResultType,
|
||||
};
|
||||
#[cfg(feature = "hwcodec")]
|
||||
@@ -187,7 +188,11 @@ impl Encoder {
|
||||
#[inline]
|
||||
pub fn current_hw_encoder_name() -> Option<String> {
|
||||
#[cfg(feature = "hwcodec")]
|
||||
return HwEncoder::current_name().lock().unwrap().clone();
|
||||
if check_hwcodec_config() {
|
||||
return HwEncoder::current_name().lock().unwrap().clone();
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
#[cfg(not(feature = "hwcodec"))]
|
||||
return None;
|
||||
}
|
||||
@@ -208,7 +213,14 @@ impl Decoder {
|
||||
// video_codec_state is mainted by creation and destruction of Decoder.
|
||||
// It has been ensured to use after Decoder's creation.
|
||||
#[cfg(feature = "hwcodec")]
|
||||
return MY_DECODER_STATE.lock().unwrap().clone();
|
||||
if check_hwcodec_config() {
|
||||
return MY_DECODER_STATE.lock().unwrap().clone();
|
||||
} else {
|
||||
return VideoCodecState {
|
||||
ScoreVpx: SCORE_VPX,
|
||||
..Default::default()
|
||||
};
|
||||
}
|
||||
#[cfg(not(feature = "hwcodec"))]
|
||||
VideoCodecState {
|
||||
ScoreVpx: SCORE_VPX,
|
||||
@@ -330,3 +342,10 @@ impl Decoder {
|
||||
return Ok(ret);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_hwcodec_config() -> bool {
|
||||
if let Some(v) = Config2::get().options.get("enable-hwcodec") {
|
||||
return v != "N";
|
||||
}
|
||||
return true; // default is true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user