hwcodec uses one repository (#7701)

* update hwcodec, gpucodec repo is merged to hwcodec

Signed-off-by: 21pages <pages21@163.com>

* rename gpucodec.rs to vram.rs

Signed-off-by: 21pages <pages21@163.com>

* rename all gpucodec to vram, because vram is a feature of hwcodec

Signed-off-by: 21pages <pages21@163.com>

* use one check process and one config file

* set check encode image size to 720p

Signed-off-by: 21pages <pages21@163.com>

---------

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2024-04-12 17:26:24 +08:00
committed by GitHub
parent d8875f381b
commit 98df2b111e
32 changed files with 330 additions and 478 deletions

View File

@@ -4,7 +4,7 @@ use crate::{
ui_session_interface::{io_loop, InvokeUiSession, Session},
};
use flutter_rust_bridge::StreamSink;
#[cfg(any(feature = "flutter_texture_render", feature = "gpucodec"))]
#[cfg(any(feature = "flutter_texture_render", feature = "vram"))]
use hbb_common::dlopen::{
symbor::{Library, Symbol},
Error as LibError,
@@ -16,7 +16,7 @@ use hbb_common::{
use serde::Serialize;
use serde_json::json;
#[cfg(any(feature = "flutter_texture_render", feature = "gpucodec"))]
#[cfg(any(feature = "flutter_texture_render", feature = "vram"))]
use std::os::raw::c_void;
use std::{
@@ -63,7 +63,7 @@ lazy_static::lazy_static! {
pub static ref TEXTURE_RGBA_RENDERER_PLUGIN: Result<Library, LibError> = Library::open_self();
}
#[cfg(all(target_os = "windows", feature = "gpucodec"))]
#[cfg(all(target_os = "windows", feature = "vram"))]
lazy_static::lazy_static! {
pub static ref TEXTURE_GPU_RENDERER_PLUGIN: Result<Library, LibError> = Library::open("flutter_gpu_texture_renderer_plugin.dll");
}
@@ -168,15 +168,15 @@ pub unsafe extern "C" fn get_rustdesk_app_name(buffer: *mut u16, length: i32) ->
#[derive(Default)]
struct SessionHandler {
event_stream: Option<StreamSink<EventToUI>>,
#[cfg(any(feature = "flutter_texture_render", feature = "gpucodec"))]
#[cfg(any(feature = "flutter_texture_render", feature = "vram"))]
renderer: VideoRenderer,
}
#[cfg(any(feature = "flutter_texture_render", feature = "gpucodec"))]
#[cfg(any(feature = "flutter_texture_render", feature = "vram"))]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
enum RenderType {
PixelBuffer,
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
Texture,
}
@@ -214,41 +214,41 @@ pub type FlutterRgbaRendererPluginOnRgba = unsafe extern "C" fn(
dst_rgba_stride: c_int,
);
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
pub type FlutterGpuTextureRendererPluginCApiSetTexture =
unsafe extern "C" fn(output: *mut c_void, texture: *mut c_void);
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
pub type FlutterGpuTextureRendererPluginCApiGetAdapterLuid = unsafe extern "C" fn() -> i64;
#[cfg(feature = "flutter_texture_render")]
pub(super) type TextureRgbaPtr = usize;
#[cfg(any(feature = "flutter_texture_render", feature = "gpucodec"))]
#[cfg(any(feature = "flutter_texture_render", feature = "vram"))]
struct DisplaySessionInfo {
// TextureRgba pointer in flutter native.
#[cfg(feature = "flutter_texture_render")]
texture_rgba_ptr: TextureRgbaPtr,
#[cfg(feature = "flutter_texture_render")]
size: (usize, usize),
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
gpu_output_ptr: usize,
notify_render_type: Option<RenderType>,
}
// Video Texture Renderer in Flutter
#[cfg(any(feature = "flutter_texture_render", feature = "gpucodec"))]
#[cfg(any(feature = "flutter_texture_render", feature = "vram"))]
#[derive(Clone)]
struct VideoRenderer {
is_support_multi_ui_session: bool,
map_display_sessions: Arc<RwLock<HashMap<usize, DisplaySessionInfo>>>,
#[cfg(feature = "flutter_texture_render")]
on_rgba_func: Option<Symbol<'static, FlutterRgbaRendererPluginOnRgba>>,
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
on_texture_func: Option<Symbol<'static, FlutterGpuTextureRendererPluginCApiSetTexture>>,
}
#[cfg(any(feature = "flutter_texture_render", feature = "gpucodec"))]
#[cfg(any(feature = "flutter_texture_render", feature = "vram"))]
impl Default for VideoRenderer {
fn default() -> Self {
#[cfg(feature = "flutter_texture_render")]
@@ -270,7 +270,7 @@ impl Default for VideoRenderer {
None
}
};
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
let on_texture_func = match &*TEXTURE_GPU_RENDERER_PLUGIN {
Ok(lib) => {
let find_sym_res = unsafe {
@@ -297,13 +297,13 @@ impl Default for VideoRenderer {
is_support_multi_ui_session: false,
#[cfg(feature = "flutter_texture_render")]
on_rgba_func,
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
on_texture_func,
}
}
}
#[cfg(any(feature = "flutter_texture_render", feature = "gpucodec"))]
#[cfg(any(feature = "flutter_texture_render", feature = "vram"))]
impl VideoRenderer {
#[inline]
#[cfg(feature = "flutter_texture_render")]
@@ -318,7 +318,7 @@ impl VideoRenderer {
DisplaySessionInfo {
texture_rgba_ptr: usize::default(),
size: (width, height),
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
gpu_output_ptr: usize::default(),
notify_render_type: None,
},
@@ -345,7 +345,7 @@ impl VideoRenderer {
DisplaySessionInfo {
texture_rgba_ptr: ptr as _,
size: (0, 0),
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
gpu_output_ptr: usize::default(),
notify_render_type: None,
},
@@ -355,7 +355,7 @@ impl VideoRenderer {
}
}
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
pub fn register_gpu_output(&self, display: usize, ptr: usize) {
let mut sessions_lock = self.map_display_sessions.write().unwrap();
if ptr == 0 {
@@ -434,7 +434,7 @@ impl VideoRenderer {
}
}
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
pub fn on_texture(&self, display: usize, texture: *mut c_void) -> bool {
let mut write_lock = self.map_display_sessions.write().unwrap();
let opt_info = if !self.is_support_multi_ui_session {
@@ -793,7 +793,7 @@ impl InvokeUiSession for FlutterHandler {
}
#[inline]
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
fn on_texture(&self, display: usize, texture: *mut c_void) {
for (_, session) in self.session_handlers.read().unwrap().iter() {
if session.renderer.on_texture(display, texture) {
@@ -1073,9 +1073,9 @@ pub fn session_add(
Some(switch_uuid.to_string())
};
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
let adapter_luid = get_adapter_luid();
#[cfg(not(feature = "gpucodec"))]
#[cfg(not(feature = "vram"))]
let adapter_luid = None;
session.lc.write().unwrap().initialize(
@@ -1453,7 +1453,7 @@ pub fn session_register_pixelbuffer_texture(_session_id: SessionID, _display: us
#[inline]
pub fn session_register_gpu_texture(_session_id: SessionID, _display: usize, _output_ptr: usize) {
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
for s in sessions::get_sessions() {
if let Some(h) = s
.ui_handler
@@ -1468,7 +1468,7 @@ pub fn session_register_gpu_texture(_session_id: SessionID, _display: usize, _ou
}
}
#[cfg(feature = "gpucodec")]
#[cfg(feature = "vram")]
pub fn get_adapter_luid() -> Option<i64> {
let get_adapter_luid_func = match &*TEXTURE_GPU_RENDERER_PLUGIN {
Ok(lib) => {