mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -365,7 +365,7 @@ impl Connection {
|
||||
video_service::notify_video_frame_feched(id, None);
|
||||
super::video_service::update_test_latency(id, 0);
|
||||
super::video_service::update_image_quality(id, None);
|
||||
scrap::codec::Encoder::update_video_encoder(id, None);
|
||||
scrap::codec::Encoder::update_video_encoder(id, scrap::codec::EncoderUpdate::Remove);
|
||||
if let Err(err) = conn.try_port_forward_loop(&mut rx_from_cm).await {
|
||||
conn.on_close(&err.to_string(), false);
|
||||
}
|
||||
@@ -1190,15 +1190,14 @@ impl Connection {
|
||||
|
||||
// TODO: add option
|
||||
if let Some(q) = o.video_codec_state.clone().take() {
|
||||
scrap::codec::Encoder::update_video_encoder(self.inner.id(), Some(q));
|
||||
scrap::codec::Encoder::update_video_encoder(
|
||||
self.inner.id(),
|
||||
scrap::codec::EncoderUpdate::State(q),
|
||||
);
|
||||
} else {
|
||||
scrap::codec::Encoder::update_video_encoder(
|
||||
self.inner.id(),
|
||||
Some(VideoCodecState {
|
||||
H264: false,
|
||||
H265: false,
|
||||
..Default::default()
|
||||
}),
|
||||
scrap::codec::EncoderUpdate::DisableHwIfNotExist,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,9 +184,9 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
let encoder_cfg = match Encoder::current_hw_encoder_name() {
|
||||
Some(codec_name) => EncoderCfg::HW(HwEncoderConfig {
|
||||
codec_name,
|
||||
fps,
|
||||
width,
|
||||
height,
|
||||
quallity: convert_quality_back(q),
|
||||
}),
|
||||
None => EncoderCfg::VPX(VpxEncoderConfig {
|
||||
width: width as _,
|
||||
@@ -516,6 +516,20 @@ fn convert_quality(q: i32) -> i32 {
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_quality_back(q: i32) -> ImageQuality {
|
||||
let q = q >> 8;
|
||||
if q == 100 * 2 / 3 {
|
||||
ImageQuality::Balanced
|
||||
} else if q == 100 / 2 {
|
||||
ImageQuality::Low
|
||||
} else if q == 100 {
|
||||
ImageQuality::Best
|
||||
} else {
|
||||
log::error!("Error convert quality:{}", q);
|
||||
ImageQuality::Balanced
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_image_quality(id: i32, q: Option<i32>) {
|
||||
match q {
|
||||
Some(q) => {
|
||||
|
||||
Reference in New Issue
Block a user