win, debug

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2023-02-23 10:21:31 +08:00
parent 9559a889fb
commit b8e381d79d
3 changed files with 27 additions and 31 deletions

1
Cargo.lock generated
View File

@ -4902,7 +4902,6 @@ dependencies = [
"include_dir", "include_dir",
"jni 0.19.0", "jni 0.19.0",
"lazy_static", "lazy_static",
"libloading",
"libpulse-binding", "libpulse-binding",
"libpulse-simple-binding", "libpulse-simple-binding",
"mac_address", "mac_address",

View File

@ -69,7 +69,6 @@ dlopen = "0.1"
reqwest = { version = "0.11", features = ["blocking", "json", "rustls-tls"], default-features=false } reqwest = { version = "0.11", features = ["blocking", "json", "rustls-tls"], default-features=false }
chrono = "0.4.23" chrono = "0.4.23"
cidr-utils = "0.5.9" cidr-utils = "0.5.9"
libloading = "0.7.4"
[target.'cfg(not(any(target_os = "android", target_os = "linux")))'.dependencies] [target.'cfg(not(any(target_os = "android", target_os = "linux")))'.dependencies]
cpal = "0.13.5" cpal = "0.13.5"

View File

@ -4,21 +4,18 @@ use crate::{
ui_session_interface::{io_loop, InvokeUiSession, Session}, ui_session_interface::{io_loop, InvokeUiSession, Session},
}; };
#[cfg(feature = "flutter_texture_render")] #[cfg(feature = "flutter_texture_render")]
#[cfg(target_os = "macos")] // #[cfg(target_os = "macos")]
use dlopen::{ use dlopen::{
symbor::{Library, Symbol}, symbor::{Library, Symbol},
Error as LibError, Error as LibError,
}; };
use flutter_rust_bridge::StreamSink; use flutter_rust_bridge::StreamSink;
#[cfg(feature = "flutter_texture_render")]
use hbb_common::libc::c_void;
use hbb_common::{ use hbb_common::{
bail, config::LocalConfig, get_version_number, log, message_proto::*, bail, config::LocalConfig, get_version_number, message_proto::*, rendezvous_proto::ConnType,
rendezvous_proto::ConnType, ResultType, ResultType,
}; };
#[cfg(feature = "flutter_texture_render")] #[cfg(feature = "flutter_texture_render")]
#[cfg(not(target_os = "macos"))] use hbb_common::{libc::c_void, log};
use libloading::{Error as LibError, Library, Symbol};
use serde_json::json; use serde_json::json;
#[cfg(not(feature = "flutter_texture_render"))] #[cfg(not(feature = "flutter_texture_render"))]
@ -42,19 +39,19 @@ lazy_static::lazy_static! {
pub static ref GLOBAL_EVENT_STREAM: RwLock<HashMap<String, StreamSink<String>>> = Default::default(); // rust to dart event channel pub static ref GLOBAL_EVENT_STREAM: RwLock<HashMap<String, StreamSink<String>>> = Default::default(); // rust to dart event channel
} }
#[cfg(feature = "flutter_texture_render")] #[cfg(all(target_os = "windows", feature = "flutter_texture_render"))]
lazy_static::lazy_static! { lazy_static::lazy_static! {
pub static ref TEXTURE_RGBA_RENDERER_PLUGIN: Result<Library, LibError> = { pub static ref TEXTURE_RGBA_RENDERER_PLUGIN: Result<Library, LibError> = Library::open("texture_rgba_renderer_plugin.dll");
#[cfg(not(target_os = "macos"))] }
unsafe {
#[cfg(target_os = "windows")] #[cfg(all(target_os = "linux", feature = "flutter_texture_render"))]
Library::new("texture_rgba_renderer_plugin.dll"); lazy_static::lazy_static! {
#[cfg(target_os = "linux")] pub static ref TEXTURE_RGBA_RENDERER_PLUGIN: Result<Library, LibError> = Library::open("libtexture_rgba_renderer_plugin.so");
Library::new("libtexture_rgba_renderer_plugin.so"); }
}
#[cfg(target_os = "macos")] #[cfg(all(target_os = "macos", feature = "flutter_texture_render"))]
Library::open_self() lazy_static::lazy_static! {
}; pub static ref TEXTURE_RGBA_RENDERER_PLUGIN: Result<Library, LibError> = Library::open_self();
} }
/// FFI for rustdesk core's main entry. /// FFI for rustdesk core's main entry.
@ -136,21 +133,26 @@ pub unsafe extern "C" fn free_c_args(ptr: *mut *mut c_char, len: c_int) {
// Afterwards the vector will be dropped and thus freed. // Afterwards the vector will be dropped and thus freed.
} }
#[cfg(feature = "flutter_texture_render")]
#[derive(Default, Clone)]
pub struct FlutterHandler {
pub event_stream: Arc<RwLock<Option<StreamSink<EventToUI>>>>,
notify_rendered: Arc<RwLock<bool>>,
renderer: Arc<RwLock<VideoRenderer>>,
peer_info: Arc<RwLock<PeerInfo>>,
}
#[cfg(not(feature = "flutter_texture_render"))]
#[derive(Default, Clone)] #[derive(Default, Clone)]
pub struct FlutterHandler { pub struct FlutterHandler {
pub event_stream: Arc<RwLock<Option<StreamSink<EventToUI>>>>, pub event_stream: Arc<RwLock<Option<StreamSink<EventToUI>>>>,
// SAFETY: [rgba] is guarded by [rgba_valid], and it's safe to reach [rgba] with `rgba_valid == true`. // SAFETY: [rgba] is guarded by [rgba_valid], and it's safe to reach [rgba] with `rgba_valid == true`.
// We must check the `rgba_valid` before reading [rgba]. // We must check the `rgba_valid` before reading [rgba].
#[cfg(not(feature = "flutter_texture_render"))]
pub rgba: Arc<RwLock<Vec<u8>>>, pub rgba: Arc<RwLock<Vec<u8>>>,
#[cfg(not(feature = "flutter_texture_render"))]
pub rgba_valid: Arc<AtomicBool>, pub rgba_valid: Arc<AtomicBool>,
#[cfg(feature = "flutter_texture_render")]
notify_rendered: Arc<RwLock<bool>>,
#[cfg(feature = "flutter_texture_render")]
renderer: Arc<RwLock<VideoRenderer>>,
peer_info: Arc<RwLock<PeerInfo>>, peer_info: Arc<RwLock<PeerInfo>>,
} }
#[cfg(feature = "flutter_texture_render")] #[cfg(feature = "flutter_texture_render")]
pub type FlutterRgbaRendererPluginOnRgba = pub type FlutterRgbaRendererPluginOnRgba =
unsafe extern "C" fn(texture_rgba: *mut c_void, buffer: *const u8, width: c_int, height: c_int); unsafe extern "C" fn(texture_rgba: *mut c_void, buffer: *const u8, width: c_int, height: c_int);
@ -172,10 +174,6 @@ impl Default for VideoRenderer {
fn default() -> Self { fn default() -> Self {
let on_rgba_func = match &*TEXTURE_RGBA_RENDERER_PLUGIN { let on_rgba_func = match &*TEXTURE_RGBA_RENDERER_PLUGIN {
Ok(lib) => { Ok(lib) => {
#[cfg(not(target_os = "macos"))]
let find_sym_res =
lib.get::<FlutterRgbaRendererPluginOnRgba>(b"FlutterRgbaRendererPluginOnRgba");
#[cfg(target_os = "macos")]
let find_sym_res = unsafe { let find_sym_res = unsafe {
lib.symbol::<FlutterRgbaRendererPluginOnRgba>("FlutterRgbaRendererPluginOnRgba") lib.symbol::<FlutterRgbaRendererPluginOnRgba>("FlutterRgbaRendererPluginOnRgba")
}; };