128 lines
4.6 KiB
Zig
128 lines
4.6 KiB
Zig
const std = @import("std");
|
|
pub const c = @import("c.zig").c;
|
|
|
|
pub const PixelFormat = enum(c_int) {
|
|
pixelformatYv12, //Planar mode: Y + V + U (3 planes)
|
|
pixelformatIyuv, //Planar mode: Y + U + V (3 planes)
|
|
pixelformatYuy2, //Packed mode: Y0+U0+Y1+V0 (1 plane)
|
|
pixelformatUyvy, //Packed mode: U0+Y0+V0+Y1 (1 plane)
|
|
pixelformatYvyu, //Packed mode: Y0+V0+Y1+U0 (1 plane)
|
|
pixelformatNv12, //Planar mode: Y + U/V interleaved (2 planes)
|
|
pixelformatNv21, //Planar mode: Y + V/U interleaved (2 planes)
|
|
pixelformatP010, //Planar mode: Y + U/V interleaved (2 planes)
|
|
pixelformatExternalOes, //Android video texture format
|
|
pixelformatMjpg, //Motion JPEG
|
|
};
|
|
|
|
pub const Surface = opaque {};
|
|
|
|
pub const Colorspace = enum(c_int) {
|
|
colorspaceSrgb, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
|
|
colorRangeFull,
|
|
colorPrimariesBt709,
|
|
transferCharacteristicsSrgb,
|
|
matrixCoefficientsIdentity,
|
|
colorspaceSrgbLinear, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709
|
|
transferCharacteristicsLinear,
|
|
colorspaceHdr10, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
|
|
colorPrimariesBt2020,
|
|
transferCharacteristicsPq,
|
|
colorspaceJpeg, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601
|
|
transferCharacteristicsBt601,
|
|
matrixCoefficientsBt601,
|
|
colorspaceBt601Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
|
colorRangeLimited,
|
|
colorPrimariesBt601,
|
|
colorspaceBt601Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
|
colorspaceBt709Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
|
transferCharacteristicsBt709,
|
|
matrixCoefficientsBt709,
|
|
colorspaceBt709Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
|
colorspaceBt2020Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020
|
|
matrixCoefficientsBt2020Ncl,
|
|
colorspaceBt2020Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020
|
|
colorspaceRgbDefault, //The default colorspace for RGB surfaces if no colorspace is specified
|
|
colorspaceYuvDefault, //The default colorspace for YUV surfaces if no colorspace is specified
|
|
};
|
|
|
|
pub const PropertiesID = u32;
|
|
|
|
pub const CameraID = u32;
|
|
|
|
pub const Camera = opaque {
|
|
pub inline fn getCameraPermissionState(camera: *Camera) c_int {
|
|
return c.SDL_GetCameraPermissionState(camera);
|
|
}
|
|
|
|
pub inline fn getCameraID(camera: *Camera) CameraID {
|
|
return c.SDL_GetCameraID(camera);
|
|
}
|
|
|
|
pub inline fn getCameraProperties(camera: *Camera) PropertiesID {
|
|
return c.SDL_GetCameraProperties(camera);
|
|
}
|
|
|
|
pub inline fn getCameraFormat(camera: *Camera, spec: ?*CameraSpec) bool {
|
|
return c.SDL_GetCameraFormat(camera, spec);
|
|
}
|
|
|
|
pub inline fn acquireCameraFrame(camera: *Camera, timestampNS: *u64) ?*Surface {
|
|
return c.SDL_AcquireCameraFrame(camera, @ptrCast(timestampNS));
|
|
}
|
|
|
|
pub inline fn releaseCameraFrame(camera: *Camera, frame: ?*Surface) void {
|
|
return c.SDL_ReleaseCameraFrame(camera, frame);
|
|
}
|
|
|
|
pub inline fn closeCamera(camera: *Camera) void {
|
|
return c.SDL_CloseCamera(camera);
|
|
}
|
|
};
|
|
|
|
pub const CameraSpec = extern struct {
|
|
format: PixelFormat, // Frame format
|
|
colorspace: Colorspace, // Frame colorspace
|
|
width: c_int, // Frame width
|
|
height: c_int, // Frame height
|
|
framerate_numerator: c_int, // Frame rate numerator ((num / denom) == FPS, (denom / num) == duration in seconds)
|
|
framerate_denominator: c_int, // Frame rate demoninator ((num / denom) == FPS, (denom / num) == duration in seconds)
|
|
};
|
|
|
|
pub const CameraPosition = enum(c_int) {
|
|
cameraPositionUnknown,
|
|
cameraPositionFrontFacing,
|
|
cameraPositionBackFacing,
|
|
};
|
|
|
|
pub inline fn getNumCameraDrivers() c_int {
|
|
return c.SDL_GetNumCameraDrivers();
|
|
}
|
|
|
|
pub inline fn getCameraDriver(index: c_int) [*c]const u8 {
|
|
return c.SDL_GetCameraDriver(index);
|
|
}
|
|
|
|
pub inline fn getCurrentCameraDriver() [*c]const u8 {
|
|
return c.SDL_GetCurrentCameraDriver();
|
|
}
|
|
|
|
pub inline fn getCameras(count: *c_int) ?*CameraID {
|
|
return c.SDL_GetCameras(@ptrCast(count));
|
|
}
|
|
|
|
pub inline fn getCameraSupportedFormats(instance_id: CameraID, count: *c_int) [*c][*c]CameraSpec {
|
|
return c.SDL_GetCameraSupportedFormats(instance_id, @ptrCast(count));
|
|
}
|
|
|
|
pub inline fn getCameraName(instance_id: CameraID) [*c]const u8 {
|
|
return c.SDL_GetCameraName(instance_id);
|
|
}
|
|
|
|
pub inline fn getCameraPosition(instance_id: CameraID) CameraPosition {
|
|
return c.SDL_GetCameraPosition(instance_id);
|
|
}
|
|
|
|
pub inline fn openCamera(instance_id: CameraID, spec: *const CameraSpec) ?*Camera {
|
|
return c.SDL_OpenCamera(instance_id, @ptrCast(spec));
|
|
}
|