From b1e140a3fe905c19b845dfea66b3b1aea02f0472 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Sun, 10 Nov 2024 18:57:37 +0800 Subject: [PATCH] expose CMSampleBuffer --- src/capturer/engine/mac/mod.rs | 2 ++ src/capturer/engine/mac/pixel_buffer.rs | 7 ++++++- src/capturer/engine/mod.rs | 2 +- src/capturer/mod.rs | 2 +- src/lib.rs | 5 +++++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/capturer/engine/mac/mod.rs b/src/capturer/engine/mac/mod.rs index 41f0ba0..b6ebfb7 100644 --- a/src/capturer/engine/mac/mod.rs +++ b/src/capturer/engine/mac/mod.rs @@ -29,6 +29,8 @@ mod apple_sys; mod pixel_buffer; mod pixelformat; +pub use pixel_buffer::PixelBuffer; + struct ErrorHandler; impl StreamErrorHandler for ErrorHandler { fn on_error(&self) { diff --git a/src/capturer/engine/mac/pixel_buffer.rs b/src/capturer/engine/mac/pixel_buffer.rs index af6956f..4537fff 100644 --- a/src/capturer/engine/mac/pixel_buffer.rs +++ b/src/capturer/engine/mac/pixel_buffer.rs @@ -99,6 +99,12 @@ impl PixelBuffer { } } +impl Into for PixelBuffer { + fn into(self) -> CMSampleBuffer { + self.buffer + } +} + #[derive(Debug)] pub struct Plane { buffer: CVPixelBufferRef, @@ -170,7 +176,6 @@ impl RawCapturer<'_> { pub unsafe fn sample_buffer_to_pixel_buffer(sample_buffer: &CMSampleBuffer) -> CVPixelBufferRef { let buffer_ref = &(*sample_buffer.sys_ref); - CMSampleBufferGetImageBuffer(buffer_ref) as CVPixelBufferRef } diff --git a/src/capturer/engine/mod.rs b/src/capturer/engine/mod.rs index b14e785..bbf1138 100644 --- a/src/capturer/engine/mod.rs +++ b/src/capturer/engine/mod.rs @@ -4,7 +4,7 @@ use super::Options; use crate::frame::Frame; #[cfg(target_os = "macos")] -mod mac; +pub mod mac; #[cfg(target_os = "windows")] mod win; diff --git a/src/capturer/mod.rs b/src/capturer/mod.rs index 9e3f9ab..14cb50b 100644 --- a/src/capturer/mod.rs +++ b/src/capturer/mod.rs @@ -1,4 +1,4 @@ -mod engine; +pub mod engine; use std::{error::Error, sync::mpsc}; diff --git a/src/lib.rs b/src/lib.rs index 9f02bea..20edc02 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,3 +11,8 @@ pub use targets::Target; pub use utils::has_permission; pub use utils::is_supported; pub use utils::request_permission; + +#[cfg(target_os = "macos")] +pub mod engine { + pub use crate::capturer::engine::mac; +}