Skip to content

Commit

Permalink
expose CMSampleBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendonovich committed Nov 10, 2024
1 parent 83da3aa commit b1e140a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/capturer/engine/mac/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion src/capturer/engine/mac/pixel_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ impl PixelBuffer {
}
}

impl Into<CMSampleBuffer> for PixelBuffer {
fn into(self) -> CMSampleBuffer {
self.buffer
}
}

#[derive(Debug)]
pub struct Plane {
buffer: CVPixelBufferRef,
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/capturer/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/capturer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod engine;
pub mod engine;

use std::{error::Error, sync::mpsc};

Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit b1e140a

Please sign in to comment.