54 lines
2.9 KiB
C
54 lines
2.9 KiB
C
// mcap's ScreenCaptureKit shim (capture.m): plain C, for Jai (src/app/screen_capture_macos.jai).
|
|
#pragma once
|
|
#include <stdint.h>
|
|
|
|
// One screen to copy. display_id, width and height (its size in pixels) are given; ScreenCaptureKit's
|
|
// own width and height and the pixels (packed RGBA, opaque, sRGB; free with mcap_sck_free) come back.
|
|
typedef struct {
|
|
uint32_t display_id;
|
|
int32_t width, height;
|
|
uint8_t *pixels;
|
|
} Mcap_Sck_Shot;
|
|
|
|
// Copies each screen, all at once, and waits for them. 1 when every one was copied; else 0, with why
|
|
// in error (pixels already made are left set, to be freed).
|
|
int mcap_sck_screenshots(Mcap_Sck_Shot *shots, int count, char *error, int error_size);
|
|
|
|
void mcap_sck_free(void *pointer);
|
|
|
|
// ---------------------------------------------------------------- recording (macos-plan, phase 7)
|
|
|
|
// A stream of one display's region, with the sound wanted. Frames are kept one at a time, the
|
|
// newest; sound is queued, per source, until taken.
|
|
typedef struct Mcap_Sck_Stream Mcap_Sck_Stream;
|
|
|
|
enum { MCAP_SCK_SYSTEM = 0, MCAP_SCK_MICROPHONE = 1 };
|
|
|
|
// The region (x, y, w, h) in the display's points from its top left; width and height the frames'
|
|
// size in pixels. excluded: window numbers kept out of the frames (mcap's border and toolbar).
|
|
// The microphone comes from the stream itself, which macOS 15 has; on 14 it cannot be turned on.
|
|
// NULL, with why in error, when it could not start.
|
|
Mcap_Sck_Stream *mcap_sck_stream_start(uint32_t display_id, double x, double y, double w, double h,
|
|
int32_t width, int32_t height, int32_t fps, int show_cursor,
|
|
int system_audio, int microphone,
|
|
const uint32_t *excluded, int excluded_count,
|
|
char *error, int error_size);
|
|
|
|
// The newest frame since the last taken, as packed BGRA into pixels (width * height * 4), with the
|
|
// host time it was shown at (mach_absolute_time, in nanoseconds). 1 for a frame; 0 when none came in
|
|
// timeout_ms; -1 when the stream stopped by itself (error says why).
|
|
int mcap_sck_next_frame(Mcap_Sck_Stream *s, uint8_t *pixels, int64_t *host_time_ns, int timeout_ms, char *error, int error_size);
|
|
|
|
// The oldest sound packet of a source not yet taken: up to max_frames frames of 48 kHz stereo float,
|
|
// interleaved, into samples, and the host time of its first frame. Its frame count; 0 for none.
|
|
int mcap_sck_next_audio(Mcap_Sck_Stream *s, int source, float *samples, int max_frames, int64_t *host_time_ns);
|
|
|
|
// Turns the sources on and off while it runs (the stream's configuration changed). 1 when done.
|
|
int mcap_sck_stream_set_audio(Mcap_Sck_Stream *s, int system_audio, int microphone, char *error, int error_size);
|
|
|
|
// Whether this macOS can take the microphone from the stream.
|
|
int mcap_sck_microphone_supported(void);
|
|
|
|
// Stops it, waits for it, and frees it.
|
|
void mcap_sck_stream_stop(Mcap_Sck_Stream *s);
|