debug win, without hwcodec

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2023-02-22 09:43:57 +08:00
parent 77c4a14845
commit 173e3bcd0d
5 changed files with 39 additions and 21 deletions

View File

@ -20,6 +20,7 @@ inline = []
hbbs = []
cli = []
with_rc = ["simple_rc"]
flutter_texture_render = []
appimage = []
flatpak = []
use_samplerate = ["samplerate"]

View File

@ -1,5 +1,4 @@
use hbb_common::anyhow::Error;
use hbb_common::{bail, ResultType};
use hbb_common::{log, anyhow::Error, bail, ResultType};
use ndk::media::media_codec::{MediaCodec, MediaCodecDirection, MediaFormat};
use std::ops::Deref;
use std::{

View File

@ -945,9 +945,9 @@ impl VideoHandler {
match &vf.union {
Some(frame) => {
#[cfg(feature = "flutter_texture_render")]
let fmt = ImageFormat::ARGB;
#[cfg(not(feature = "flutter_texture_render"))]
let fmt = ImageFormat::ABGR;
#[cfg(not(feature = "flutter_texture_render"))]
let fmt = ImageFormat::ARGB;
let res = self.decoder.handle_video_frame(frame, fmt, &mut self.rgb);
if self.record {
self.recorder

View File

@ -4,14 +4,17 @@ use crate::{
ui_session_interface::{io_loop, InvokeUiSession, Session},
};
use flutter_rust_bridge::StreamSink;
#[cfg(feature = "flutter_texture_render")]
use hbb_common::libc::c_void;
use hbb_common::{
bail, config::LocalConfig, get_version_number, libc::c_void, message_proto::*,
rendezvous_proto::ConnType, ResultType,
bail, config::LocalConfig, get_version_number, message_proto::*, rendezvous_proto::ConnType,
ResultType,
};
#[cfg(feature = "flutter_texture_render")]
use libloading::{Library, Symbol};
use serde_json::json;
#[cfg(any(target_os = "android", target_os = "ios"))]
#[cfg(not(feature = "flutter_texture_render"))]
use std::sync::atomic::{AtomicBool, Ordering};
use std::{
collections::HashMap,
@ -30,7 +33,10 @@ lazy_static::lazy_static! {
pub static ref CUR_SESSION_ID: RwLock<String> = Default::default();
pub static ref SESSIONS: RwLock<HashMap<String, Session<FlutterHandler>>> = Default::default();
pub static ref GLOBAL_EVENT_STREAM: RwLock<HashMap<String, StreamSink<String>>> = Default::default(); // rust to dart event channel
#[cfg(not(any(target_os = "ios", target_os = "android")))]
}
#[cfg(feature = "flutter_texture_render")]
lazy_static::lazy_static! {
pub static ref TEXTURE_RGBA_RENDERER_PLUGIN: Library = {
unsafe {
#[cfg(target_os = "windows")]
@ -134,6 +140,7 @@ pub struct FlutterHandler {
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>>,
}
@ -556,7 +563,7 @@ impl InvokeUiSession for FlutterHandler {
#[inline]
fn get_rgba(&self) -> *const u8 {
#[cfg(any(target_os = "android", target_os = "ios"))]
#[cfg(not(feature = "flutter_texture_render"))]
if self.rgba_valid.load(Ordering::Relaxed) {
return self.rgba.read().unwrap().as_ptr();
}
@ -565,7 +572,7 @@ impl InvokeUiSession for FlutterHandler {
#[inline]
fn next_rgba(&self) {
#[cfg(any(target_os = "android", target_os = "ios"))]
#[cfg(not(feature = "flutter_texture_render"))]
self.rgba_valid.store(false, Ordering::Relaxed);
}
}
@ -825,23 +832,28 @@ pub fn set_cur_session_id(id: String) {
}
#[no_mangle]
pub fn session_get_rgba_size(_id: *const char) -> usize {
#[cfg(any(target_os = "android", target_os = "ios"))]
let id = unsafe { std::ffi::CStr::from_ptr(_id as _) };
#[cfg(any(target_os = "android", target_os = "ios"))]
#[cfg(not(feature = "flutter_texture_render"))]
pub fn session_get_rgba_size(id: *const char) -> usize {
let id = unsafe { std::ffi::CStr::from_ptr(id as _) };
if let Ok(id) = id.to_str() {
if let Some(session) = SESSIONS.write().unwrap().get_mut(id) {
if let Some(session) = SESSIONS.read().unwrap().get(id) {
return session.rgba.read().unwrap().len();
}
}
0
}
#[no_mangle]
#[cfg(feature = "flutter_texture_render")]
pub fn session_get_rgba_size(_id: *const char) -> usize {
0
}
#[no_mangle]
pub fn session_get_rgba(id: *const char) -> *const u8 {
let id = unsafe { std::ffi::CStr::from_ptr(id as _) };
if let Ok(id) = id.to_str() {
if let Some(session) = SESSIONS.write().unwrap().get_mut(id) {
if let Some(session) = SESSIONS.read().unwrap().get(id) {
return session.get_rgba();
}
}
@ -852,18 +864,23 @@ pub fn session_get_rgba(id: *const char) -> *const u8 {
pub fn session_next_rgba(id: *const char) {
let id = unsafe { std::ffi::CStr::from_ptr(id as _) };
if let Ok(id) = id.to_str() {
if let Some(session) = SESSIONS.write().unwrap().get_mut(id) {
if let Some(session) = SESSIONS.read().unwrap().get(id) {
return session.next_rgba();
}
}
}
#[no_mangle]
#[cfg(feature = "flutter_texture_render")]
pub fn session_register_texture(id: *const char, ptr: usize) {
let id = unsafe { std::ffi::CStr::from_ptr(id as _) };
if let Ok(id) = id.to_str() {
if let Some(session) = SESSIONS.write().unwrap().get_mut(id) {
if let Some(session) = SESSIONS.read().unwrap().get(id) {
return session.register_texture(ptr);
}
}
}
#[no_mangle]
#[cfg(not(feature = "flutter_texture_render"))]
pub fn session_register_texture(_id: *const char, _ptr: usize) {}

View File

@ -529,9 +529,10 @@ pub fn session_switch_sides(id: String) {
}
}
pub fn session_set_size(id: String, width: i32, height: i32) {
if let Some(session) = SESSIONS.write().unwrap().get_mut(&id) {
session.set_size(width, height);
pub fn session_set_size(_id: String, _width: i32, _height: i32) {
#[cfg(feature = "flutter_texture_render")]
if let Some(session) = SESSIONS.write().unwrap().get_mut(&_id) {
session.set_size(_width, _height);
}
}