Add macos support

This commit is contained in:
Harshit-Dhanwalkar 2026-06-10 20:30:10 +05:30
parent 49b58febba
commit 14cc7dcc2e
10 changed files with 616 additions and 250 deletions

View file

@ -1,18 +1,22 @@
#ifndef CAPTURE_H
#define CAPTURE_H
#include <stddef.h>
#include <stdint.h>
#include <linux/videodev2.h>
typedef struct webcam_impl webcam_impl_t;
typedef struct {
int fd;
int width;
int height;
void *buffer;
struct v4l2_buffer buf_info;
int fd; /* Linux: V4L2 fd. macOS: -1 (unused externally) */
int width;
int height;
void *buffer;
webcam_impl_t *impl;
} webcam_t;
// Initialize webcam
// On Linux: device = "/dev/video0"
// On macOS: device = NULL (uses system default camera) or a device name string
int webcam_init(webcam_t *cam, const char *device, int width, int height);
// Wait for frame to be ready

20
C/include/platform.h Normal file
View file

@ -0,0 +1,20 @@
#ifndef PLATFORM_H
#define PLATFORM_H
#if defined(__linux__)
#define PLATFORM_LINUX 1
#elif defined(__APPLE__) && defined(__MACH__)
#define PLATFORM_MACOS 1
#else
#error "Unsupported platform (only Linux and macOS are supported)"
#endif
#if defined(__x86_64__) || defined(_M_X64)
#define ARCH_X86_64 1
#elif defined(__aarch64__) || defined(_M_ARM64)
#define ARCH_ARM64 1
#else
#error "Unsupported architecture (only x86_64 and ARM64 are supported)"
#endif
#endif