diff --git a/core_media_manual.zig b/core_media_manual.zig index dc58a08..619cdd6 100644 --- a/core_media_manual.zig +++ b/core_media_manual.zig @@ -10,7 +10,27 @@ pub const TimeValue = i64; pub const TimeScale = i32; pub const TimeEpoch = u32; pub const CMClockRef = *opaque {}; -pub const CMSampleBufferRef = *opaque {}; + +pub const CVImageBufferRef = *CVImageBuffer; +pub const CVImageBuffer = opaque { + extern fn CVPixelBufferGetBaseAddress(CVImageBufferRef) ?*anyopaque; + pub inline fn getBaseAddress(pxl: CVImageBufferRef) ?*anyopaque { + return CVPixelBufferGetBaseAddress(pxl); + } + extern fn CVPixelBufferGetBaseAddressOfPlane(CVImageBufferRef) ?*anyopaque; + pub inline fn getBaseAddressOfPlane(pxl: CVImageBufferRef) ?*anyopaque { + return CVPixelBufferGetBaseAddressOfPlane(pxl); + } +}; + +pub const CMSampleBufferRef = *CMSampleBuffer; +pub const CMSampleBuffer = opaque { + extern fn CMSampleBufferGetDataBuffer(*anyopaque) callconv(.C) ?CVImageBufferRef; + + pub inline fn getImageBuffer(sbuf: *CMSampleBuffer) ?CVImageBufferRef { + return CMSampleBufferGetDataBuffer(sbuf); + } +}; pub const Time = extern struct { value: TimeValue, diff --git a/screen_capture_kit_manual.zig b/screen_capture_kit_manual.zig index c5f62df..fdf452f 100644 --- a/screen_capture_kit_manual.zig +++ b/screen_capture_kit_manual.zig @@ -10,7 +10,7 @@ const size_t = usize; const OSType = [4]u8; const CMTime = cm.Time; const CMClockRef = cm.CMClockRef; -const CMSampleBufferRef = cm.CMSampleBufferRef; +pub const CMSampleBufferRef = cm.CMSampleBufferRef; pub const dispatch_queue_t = *anyopaque; // pub const applicationMain = NSApplicationMain; diff --git a/src/core_media.zig b/src/core_media.zig index 3666a14..49bfed0 100644 --- a/src/core_media.zig +++ b/src/core_media.zig @@ -10,7 +10,27 @@ pub const TimeValue = i64; pub const TimeScale = i32; pub const TimeEpoch = u32; pub const CMClockRef = *opaque {}; -pub const CMSampleBufferRef = *opaque {}; + +pub const CVImageBufferRef = *CVImageBuffer; +pub const CVImageBuffer = opaque { + extern fn CVPixelBufferGetBaseAddress(CVImageBufferRef) ?*anyopaque; + pub inline fn getBaseAddress(pxl: CVImageBufferRef) ?*anyopaque { + return CVPixelBufferGetBaseAddress(pxl); + } + extern fn CVPixelBufferGetBaseAddressOfPlane(CVImageBufferRef) ?*anyopaque; + pub inline fn getBaseAddressOfPlane(pxl: CVImageBufferRef) ?*anyopaque { + return CVPixelBufferGetBaseAddressOfPlane(pxl); + } +}; + +pub const CMSampleBufferRef = *CMSampleBuffer; +pub const CMSampleBuffer = opaque { + extern fn CMSampleBufferGetDataBuffer(*anyopaque) callconv(.C) ?CVImageBufferRef; + + pub inline fn getImageBuffer(sbuf: *CMSampleBuffer) ?CVImageBufferRef { + return CMSampleBufferGetDataBuffer(sbuf); + } +}; pub const Time = extern struct { value: TimeValue, diff --git a/src/main.zig b/src/main.zig index 65afd32..4342536 100644 --- a/src/main.zig +++ b/src/main.zig @@ -4,6 +4,7 @@ pub const objc = @import("objc.zig"); pub const avf_audio = @import("avf_audio.zig"); pub const core_foundation = @import("core_foundation.zig"); pub const core_graphics = @import("core_graphics.zig"); +pub const core_media = @import("core_media.zig"); pub const foundation = @import("foundation.zig"); pub const metal = @import("metal.zig"); pub const quartz_core = @import("quartz_core.zig"); diff --git a/src/screen_capture_kit.zig b/src/screen_capture_kit.zig index 9593fca..72dff45 100644 --- a/src/screen_capture_kit.zig +++ b/src/screen_capture_kit.zig @@ -10,7 +10,7 @@ const size_t = usize; const OSType = [4]u8; const CMTime = cm.Time; const CMClockRef = cm.CMClockRef; -const CMSampleBufferRef = cm.CMSampleBufferRef; +pub const CMSampleBufferRef = cm.CMSampleBufferRef; pub const dispatch_queue_t = *anyopaque; // pub const applicationMain = NSApplicationMain;