enable hwcodec

This commit is contained in:
csf
2022-06-30 16:19:36 +08:00
parent eaaeefd90b
commit 09937049a6
3 changed files with 70 additions and 4 deletions

View File

@@ -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
}