enable hwcodec
This commit is contained in:
parent
eaaeefd90b
commit
09937049a6
@ -11,8 +11,9 @@ use crate::vpxcodec::*;
|
|||||||
|
|
||||||
use hbb_common::{
|
use hbb_common::{
|
||||||
anyhow::anyhow,
|
anyhow::anyhow,
|
||||||
|
config::Config2,
|
||||||
log,
|
log,
|
||||||
message_proto::{video_frame, Message, VP9s, VideoCodecState, test_delay},
|
message_proto::{test_delay, video_frame, Message, VP9s, VideoCodecState},
|
||||||
ResultType,
|
ResultType,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "hwcodec")]
|
#[cfg(feature = "hwcodec")]
|
||||||
@ -187,7 +188,11 @@ impl Encoder {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn current_hw_encoder_name() -> Option<String> {
|
pub fn current_hw_encoder_name() -> Option<String> {
|
||||||
#[cfg(feature = "hwcodec")]
|
#[cfg(feature = "hwcodec")]
|
||||||
|
if check_hwcodec_config() {
|
||||||
return HwEncoder::current_name().lock().unwrap().clone();
|
return HwEncoder::current_name().lock().unwrap().clone();
|
||||||
|
} else {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
#[cfg(not(feature = "hwcodec"))]
|
#[cfg(not(feature = "hwcodec"))]
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -208,7 +213,14 @@ impl Decoder {
|
|||||||
// video_codec_state is mainted by creation and destruction of Decoder.
|
// video_codec_state is mainted by creation and destruction of Decoder.
|
||||||
// It has been ensured to use after Decoder's creation.
|
// It has been ensured to use after Decoder's creation.
|
||||||
#[cfg(feature = "hwcodec")]
|
#[cfg(feature = "hwcodec")]
|
||||||
|
if check_hwcodec_config() {
|
||||||
return MY_DECODER_STATE.lock().unwrap().clone();
|
return MY_DECODER_STATE.lock().unwrap().clone();
|
||||||
|
} else {
|
||||||
|
return VideoCodecState {
|
||||||
|
ScoreVpx: SCORE_VPX,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
}
|
||||||
#[cfg(not(feature = "hwcodec"))]
|
#[cfg(not(feature = "hwcodec"))]
|
||||||
VideoCodecState {
|
VideoCodecState {
|
||||||
ScoreVpx: SCORE_VPX,
|
ScoreVpx: SCORE_VPX,
|
||||||
@ -330,3 +342,10 @@ impl Decoder {
|
|||||||
return Ok(ret);
|
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
|
||||||
|
}
|
||||||
|
@ -753,6 +753,13 @@ impl UI {
|
|||||||
self.get_option_("custom-rendezvous-server"),
|
self.get_option_("custom-rendezvous-server"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn has_hwcodec(&self) -> bool {
|
||||||
|
#[cfg(not(feature = "hwcodec"))]
|
||||||
|
return false;
|
||||||
|
#[cfg(feature = "hwcodec")]
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl sciter::EventHandler for UI {
|
impl sciter::EventHandler for UI {
|
||||||
@ -829,6 +836,7 @@ impl sciter::EventHandler for UI {
|
|||||||
fn discover();
|
fn discover();
|
||||||
fn get_lan_peers();
|
fn get_lan_peers();
|
||||||
fn get_uuid();
|
fn get_uuid();
|
||||||
|
fn has_hwcodec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +165,44 @@ class AudioInputs: Reactor.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var enhancementsMenu;
|
||||||
|
class Enhancements: Reactor.Component {
|
||||||
|
function this() {
|
||||||
|
enhancementsMenu = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
function render() {
|
||||||
|
var has_hwcodec = handler.has_hwcodec();
|
||||||
|
var me = this;
|
||||||
|
self.timer(1ms, function() { me.toggleMenuState() });
|
||||||
|
return <li>{translate('Enhancements')}
|
||||||
|
<menu #enhancements-menu>
|
||||||
|
{has_hwcodec ? <li #enable-hwcodec><span>{svg_checkmark}</span>{translate("Hardware Codec")}</li> : ""}
|
||||||
|
<li #enable-abr><span>{svg_checkmark}</span>{translate("ABR")}</li>
|
||||||
|
</menu>
|
||||||
|
</li>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleMenuState() {
|
||||||
|
for (var el in $$(menu#enhancements-menu>li)) {
|
||||||
|
if (el.id && el.id.indexOf("enable-") == 0) {
|
||||||
|
var enabled = handler.get_option(el.id) != "N";
|
||||||
|
el.attributes.toggleClass("selected", enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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' : '');
|
||||||
|
}
|
||||||
|
this.toggleMenuState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function getUserName() {
|
function getUserName() {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(handler.get_local_option("user_info")).name;
|
return JSON.parse(handler.get_local_option("user_info")).name;
|
||||||
@ -204,6 +242,7 @@ class MyIdMenu: Reactor.Component {
|
|||||||
<li #enable-file-transfer><span>{svg_checkmark}</span>{translate('Enable File Transfer')}</li>
|
<li #enable-file-transfer><span>{svg_checkmark}</span>{translate('Enable File Transfer')}</li>
|
||||||
<li #enable-tunnel><span>{svg_checkmark}</span>{translate('Enable TCP Tunneling')}</li>
|
<li #enable-tunnel><span>{svg_checkmark}</span>{translate('Enable TCP Tunneling')}</li>
|
||||||
<AudioInputs />
|
<AudioInputs />
|
||||||
|
<Enhancements />
|
||||||
<li #allow-remote-config-modification><span>{svg_checkmark}</span>{translate('Enable remote configuration modification')}</li>
|
<li #allow-remote-config-modification><span>{svg_checkmark}</span>{translate('Enable remote configuration modification')}</li>
|
||||||
<div .separator />
|
<div .separator />
|
||||||
<li #custom-server>{translate('ID/Relay Server')}</li>
|
<li #custom-server>{translate('ID/Relay Server')}</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user