capture_hook.h(3)Bark

NAME

capture_hook.h - Bark screen and window capture provider interface.

SYNOPSIS

Classes

struct bark_capture_cfg

Capture stream configuration passed to bark_capture_start().

struct bark_capture_source

Selectable monitor or window descriptor returned by bark_capture_list_sources().

struct bark_capture_frame_meta

Metadata produced by single-frame capture via bark_capture_grab_frame().

struct bark_capture_ops

Custom screen-capture provider vtable passed to bark_capture_register().

Macros

#define BARK_CAPTURE_SOURCE_TITLE_MAX 128u

Maximum UTF-8 byte length (including NUL) for a capture source title.

#define BARK_CAPTURE_FLAG_ASYNC_ZERO_COPY (1u << 0)

Provider uses asynchronous zero-copy media transport (e.g. browser MediaStream).

#define BARK_CAPTURE_FLAG_OS_PICKER (1u << 1)

Provider presents a native OS or browser picker when starting with BARK_CAPTURE_TARGET_PROMPT.

#define BARK_CAPTURE_FLAG_ENUM_SOURCES (1u << 2)

Provider supports enumerating sources via bark_capture_list_sources().

Typedefs

typedef struct bark_capture_cfg bark_capture_cfg_t

Capture stream configuration passed to bark_capture_start().

typedef struct bark_capture_source bark_capture_source_t

Selectable monitor or window descriptor returned by bark_capture_list_sources().

typedef struct bark_capture_frame_meta bark_capture_frame_meta_t

Metadata produced by single-frame capture via bark_capture_grab_frame().

typedef void(* bark_capture_frame_fn) (const uint8_t *rgba, uint16_t w, uint16_t h, void *user)

Worker-thread RGBA8 capture frame callback.

typedef void(* bark_capture_state_fn) (int active, uint16_t w, uint16_t h, void *user)

Main-thread capture lifecycle callback driven by bark_capture_poll().

typedef int(* bark_capture_gate_fn) (void *gate_user)

Optional host permission gate returning BARK_OK to permit or BARK_ERR_UNAVAILABLE to deny.

typedef struct bark_capture_ops bark_capture_ops_t

Custom screen-capture provider vtable passed to bark_capture_register().

Enumerations

enum bark_capture_target_kind { BARK_CAPTURE_TARGET_PROMPT = 0u, BARK_CAPTURE_TARGET_MONITOR = 1u, BARK_CAPTURE_TARGET_WINDOW = 2u }

Capture target selection modes.

enum bark_capture_backend { BARK_CAPTURE_BACKEND_NONE = 0u, BARK_CAPTURE_BACKEND_HEADLESS = 1u, BARK_CAPTURE_BACKEND_X11 = 2u, BARK_CAPTURE_BACKEND_GDI = 3u, BARK_CAPTURE_BACKEND_CG = 4u, BARK_CAPTURE_BACKEND_WAYLAND = 5u, BARK_CAPTURE_BACKEND_WGC = 6u, BARK_CAPTURE_BACKEND_SCK = 7u }

Active OS screen-capture backend identifier.

Functions

int bark_capture_grab_frame (uint8_t *rgba_out, uint32_t max_w, uint32_t max_h, bark_capture_frame_meta_t *meta_out)

Grab a single RGBA8 screenshot frame into caller memory.

const bark_capture_ops_t * bark_capture_builtin_ops (void)

Return the built-in cross-platform capture provider vtable.

void bark_capture_set_gate (bark_capture_gate_fn fn, void *gate_user)

Install or clear (NULL) a host authorization gate for capture and source enumeration.

int bark_capture_register (const bark_capture_ops_t *ops, void *prov_ctx)

Register a capture provider implementation.

int bark_capture_unregister (const bark_capture_ops_t *ops)

Unregister a previously registered capture provider.

int bark_capture_autoload (void)

Load and register the default (or BARK_CAPTURE_MODULE override) capture provider.

void bark_capture_unload (void)

Release a reference acquired via bark_capture_autoload().

int bark_capture_available (void)

Return non-zero if a capture provider is installed and permitted.

const char * bark_capture_provider_name (void)

Return the active capture provider's name, or NULL if none.

uint32_t bark_capture_flags (void)

Return capability flags (BARK_CAPTURE_FLAG_*) of the active capture provider.

int bark_capture_list_sources (bark_capture_source_t *out, uint32_t max_count)

Enumerate selectable monitors and windows (respects host permission gate).

int bark_capture_start (const bark_capture_cfg_t *cfg, bark_capture_frame_fn on_frame, void *user)

Start screen capture streaming RGBA8 frames to on_frame.

int bark_capture_start_ex (const bark_capture_cfg_t *cfg, bark_capture_frame_fn on_frame, bark_capture_state_fn on_state, void *user)

Start screen capture with both worker-thread frame and main-thread state callbacks.

int bark_capture_update (const bark_capture_cfg_t *cfg)

Update live capture resolution or FPS.

void bark_capture_poll (void)

Pump pending main-thread capture state callbacks.

void bark_capture_stop (void)

Stop active screen capture.

int bark_capture_probe (void)

Probe whether capture can start and deliver a valid RGBA8 frame.

Detailed Description

Bark screen and window capture provider interface.

Capability-gated screen capture primitive and custom provider hook.

Provides OS monitor/window enumeration and screen capture across Linux (Wayland portal/PipeWire + X11), macOS (ScreenCaptureKit/CoreGraphics), Windows (WGC/GDI), browser WASM (getDisplayMedia), and headless mode, with an optional host authorization gate.

Typedef Documentation

typedef void(* bark_capture_frame_fn) (const uint8_t *rgba, uint16_t w, uint16_t h, void *user)

Worker-thread RGBA8 capture frame callback. Called with tightly-packed RGBA8 pixels (w * h * 4 bytes), or with rgba=NULL, w=0, h=0 when the picker is canceled or target is lost.

Enumeration Type Documentation

enum bark_capture_backend

Active OS screen-capture backend identifier.

Enumerator

BARK_CAPTURE_BACKEND_NONE
No backend active.
BARK_CAPTURE_BACKEND_HEADLESS
Deterministic synthetic RGBA8 pattern.
BARK_CAPTURE_BACKEND_X11
Linux X11 MIT-SHM / XComposite capture.
BARK_CAPTURE_BACKEND_GDI
Windows GDI capture.
BARK_CAPTURE_BACKEND_CG
macOS CoreGraphics capture.
BARK_CAPTURE_BACKEND_WAYLAND
Linux Wayland xdg-desktop-portal + PipeWire.
BARK_CAPTURE_BACKEND_WGC
Windows Graphics Capture (D3D11).
BARK_CAPTURE_BACKEND_SCK
macOS ScreenCaptureKit.

enum bark_capture_target_kind

Capture target selection modes.

Enumerator

BARK_CAPTURE_TARGET_PROMPT
Show OS/browser picker if supported, else default display.
BARK_CAPTURE_TARGET_MONITOR
Capture a specific monitor by target_id or display_index.
BARK_CAPTURE_TARGET_WINDOW
Capture a specific application window by target_id.

Author

Generated automatically by Doxygen for Bark from the source code.