mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
android: for software encoding and screen size > 1200, display size reduced to half (#8167)
Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -7,7 +7,7 @@ use std::sync::Mutex;
|
||||
use std::{io, time::Duration};
|
||||
|
||||
lazy_static! {
|
||||
static ref SCREEN_SIZE: Mutex<(u16, u16, u16)> = Mutex::new((0, 0, 0)); // (width, height, scale)
|
||||
pub(crate) static ref SCREEN_SIZE: Mutex<(u16, u16, u16)> = Mutex::new((0, 0, 0)); // (width, height, scale)
|
||||
}
|
||||
|
||||
pub struct Capturer {
|
||||
|
||||
@@ -304,6 +304,10 @@ impl EncoderApi for AomEncoder {
|
||||
fn latency_free(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn is_hardware(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl AomEncoder {
|
||||
|
||||
@@ -74,6 +74,8 @@ pub trait EncoderApi {
|
||||
fn support_changing_quality(&self) -> bool;
|
||||
|
||||
fn latency_free(&self) -> bool;
|
||||
|
||||
fn is_hardware(&self) -> bool;
|
||||
}
|
||||
|
||||
pub struct Encoder {
|
||||
|
||||
@@ -213,6 +213,14 @@ pub fn convert_to_yuv(
|
||||
);
|
||||
}
|
||||
if src_pixfmt == crate::Pixfmt::BGRA || src_pixfmt == crate::Pixfmt::RGBA {
|
||||
// stride is calculated, not real, so we need to check it
|
||||
if src_stride[0] < src_width * 4 {
|
||||
bail!(
|
||||
"src_stride[0] < src_width * 4: {} < {}",
|
||||
src_stride[0],
|
||||
src_width * 4
|
||||
);
|
||||
}
|
||||
if src.len() < src_stride[0] * src_height {
|
||||
bail!(
|
||||
"wrong src len, {} < {} * {}",
|
||||
|
||||
@@ -198,6 +198,10 @@ impl EncoderApi for HwRamEncoder {
|
||||
fn latency_free(&self) -> bool {
|
||||
!self.config.name.contains("mediacodec")
|
||||
}
|
||||
|
||||
fn is_hardware(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl HwRamEncoder {
|
||||
|
||||
@@ -481,3 +481,8 @@ pub trait GoogleImage {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub fn screen_size() -> (u16, u16, u16) {
|
||||
SCREEN_SIZE.lock().unwrap().clone()
|
||||
}
|
||||
|
||||
@@ -242,6 +242,10 @@ impl EncoderApi for VpxEncoder {
|
||||
fn latency_free(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn is_hardware(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl VpxEncoder {
|
||||
|
||||
@@ -188,6 +188,10 @@ impl EncoderApi for VRamEncoder {
|
||||
fn latency_free(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn is_hardware(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl VRamEncoder {
|
||||
|
||||
Reference in New Issue
Block a user