88 lines
1.9 KiB
Rust
Raw Normal View History

pub use self::vpxcodec::*;
2021-03-29 15:59:14 +08:00
cfg_if! {
if #[cfg(quartz)] {
mod quartz;
pub use self::quartz::*;
} else if #[cfg(x11)] {
2021-07-23 17:52:38 +08:00
cfg_if! {
if #[cfg(feature="wayland")] {
mod linux;
mod wayland;
2021-03-29 15:59:14 +08:00
mod x11;
2021-07-23 17:52:38 +08:00
pub use self::linux::*;
pub use self::x11::Frame;
pub use self::wayland::set_map_err;
2021-07-23 17:52:38 +08:00
} else {
mod x11;
pub use self::x11::*;
}
}
2021-03-29 15:59:14 +08:00
} else if #[cfg(dxgi)] {
mod dxgi;
pub use self::dxgi::*;
2022-06-01 17:52:21 +08:00
} else if #[cfg(target_os = "android")] {
2022-05-12 17:35:25 +08:00
mod android;
pub use self::android::*;
}else {
2021-03-29 15:59:14 +08:00
//TODO: Fallback implementation.
}
}
pub mod codec;
mod convert;
#[cfg(feature = "hwcodec")]
pub mod hwcodec;
#[cfg(feature = "mediacodec")]
pub mod mediacodec;
pub mod vpxcodec;
2021-03-29 15:59:14 +08:00
pub use self::convert::*;
2022-04-12 23:31:42 +08:00
pub const STRIDE_ALIGN: usize = 64; // commonly used in libvpx vpx_img_alloc caller
pub const HW_STRIDE_ALIGN: usize = 0; // recommended by av_frame_get_buffer
2021-03-29 15:59:14 +08:00
pub mod record;
2021-03-29 15:59:14 +08:00
mod vpx;
2022-04-24 02:50:28 +08:00
#[inline]
2022-12-26 17:44:29 +08:00
pub fn would_block_if_equal(old: &mut Vec<u8>, b: &[u8]) -> std::io::Result<()> {
// does this really help?
2022-04-24 02:50:28 +08:00
if b == &old[..] {
return Err(std::io::ErrorKind::WouldBlock.into());
}
old.resize(b.len(), 0);
old.copy_from_slice(b);
Ok(())
2022-06-01 17:52:21 +08:00
}
pub trait TraitCapturer {
fn set_use_yuv(&mut self, use_yuv: bool);
fn frame<'a>(&'a mut self, timeout: std::time::Duration) -> std::io::Result<Frame<'a>>;
#[cfg(windows)]
fn is_gdi(&self) -> bool;
#[cfg(windows)]
fn set_gdi(&mut self) -> bool;
}
#[cfg(x11)]
#[inline]
pub fn is_x11() -> bool {
"x11" == hbb_common::platform::linux::get_display_server()
}
#[cfg(x11)]
#[inline]
pub fn is_cursor_embedded() -> bool {
if is_x11() {
x11::IS_CURSOR_EMBEDDED
} else {
wayland::is_cursor_embedded()
}
}
#[cfg(not(x11))]
#[inline]
pub fn is_cursor_embedded() -> bool {
false
}