Skip to content

Commit

Permalink
core media, some sneaky core video stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoff-it authored and slimsag committed Oct 3, 2024
1 parent c1e93f6 commit 6d452a4
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
22 changes: 21 additions & 1 deletion core_media_manual.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion screen_capture_kit_manual.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 21 additions & 1 deletion src/core_media.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/screen_capture_kit.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6d452a4

Please sign in to comment.