Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
feat(cursor): capture real cursor telemetry on Wayland via the ScreenCast portal
Etienne Lescot5c7a9b89b4b9
diff --git a/.gitignore b/.gitignoreindex 82bb66e0d..80075ef83 100644--- a/.gitignore+++ b/.gitignore@@ -21,6 +21,8 @@ dist-ssr/electron/native/screencapturekit/.build//electron/native/screencapturekit/.swiftpm//electron/native/bin/+/electron/native/pipewire-capture/build/+/electron/native/pipewire-capture/target/# Native macOS generated filesDerivedData/diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.mdindex d96a2ad9b..38ce24d92 100644--- a/THIRD-PARTY-NOTICES.md+++ b/THIRD-PARTY-NOTICES.md@@ -49,11 +49,28 @@ distributed by their own registries, not redistributed inside our binaries.- The speech model (`ggml-*.bin`) is **not** bundled — it is downloaded into theuser's data directory on first use by `electron/stt/modelManager.ts`.+## PipeWire — headers (Linux only)++- **Components**: header sources under+ `electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/`, compiled+ into `openscreen-pipewire-helper` (the Linux cursor/capture helper) under+ `resources/electron/native/bin/linux-*/`.+- **License**: **MIT** — <https://gitlab.freedesktop.org/pipewire/pipewire>.+ Every vendored file keeps its upstream `SPDX-License-Identifier: MIT` header,+ and the project's licence text is copied alongside them as `COPYING`.+- **Upstream**: PipeWire release 1.0.5. Only the header subset the helper+ includes was vendored; `vendor/README.md` records exactly what was copied and+ how to reproduce the selection.+- **No PipeWire binary is redistributed.** The helper resolves+ `libpipewire-0.3.so.0` with `dlopen` at runtime, from the user's own system,+ so nothing of PipeWire's ships inside our installers beyond the compiled+ result of its headers (inline functions and struct layouts).+## OpenScreen native helpers-`wgc-capture` (Windows Graphics Capture), the ScreenCaptureKit helper (macOS)-and the D3D11 compositor addon are part of this repository and are covered by-[LICENSE](LICENSE).+`wgc-capture` (Windows Graphics Capture), the ScreenCaptureKit helper (macOS),+the PipeWire helper (Linux) and the compositor addon are part of this repository+and are covered by [LICENSE](LICENSE).---diff --git a/electron/native-bridge/cursor/recording/factory.ts b/electron/native-bridge/cursor/recording/factory.tsindex 9a82ffd55..facf1f078 100644--- a/electron/native-bridge/cursor/recording/factory.ts+++ b/electron/native-bridge/cursor/recording/factory.ts@@ -1,5 +1,6 @@import type { Rectangle } from "electron";import { MacNativeCursorRecordingSession } from "./macNativeCursorRecordingSession";+import { PipeWireCursorRecordingSession } from "./pipeWireCursorRecordingSession";import type { CursorRecordingSession } from "./session";import { TelemetryRecordingSession } from "./telemetryRecordingSession";import { WindowsNativeRecordingSession } from "./windowsNativeRecordingSession";@@ -35,8 +36,23 @@ export function createCursorRecordingSession(});}- // Linux: capture cursor positions via Electron's `screen` API on an interval.- // No cursor sprites/assets and no clicks, just position telemetry.+ if (options.platform === "linux") {+ // The ScreenCast portal's METADATA cursor mode is the only source of a real+ // pointer position on Wayland: `screen.getCursorScreenPoint()` returns+ // {0,0} there, so TelemetryRecordingSession produced well-formed recordings+ // with every sample pinned to the top-left corner. The helper throws when+ // it is unavailable rather than falling back here — the caller then records+ // without cursor data, which beats a file full of {0,0}.+ return new PipeWireCursorRecordingSession({+ maxSamples: options.maxSamples,+ sampleIntervalMs: options.sampleIntervalMs,+ startTimeMs: options.startTimeMs,+ });+ }++ // Anything else (a future platform, or a test harness): capture cursor+ // positions via Electron's `screen` API on an interval. No cursor+ // sprites/assets and no clicks, just position telemetry.return new TelemetryRecordingSession({getDisplayBounds: options.getDisplayBounds,maxSamples: options.maxSamples,diff --git a/electron/native-bridge/cursor/recording/pipeWireCursorRecordingSession.test.ts b/electron/native-bridge/cursor/recording/pipeWireCursorRecordingSession.test.tsnew file mode 100644index 000000000..3615bc388--- /dev/null+++ b/electron/native-bridge/cursor/recording/pipeWireCursorRecordingSession.test.ts@@ -0,0 +1,334 @@+import { EventEmitter } from "node:events";+import { PassThrough, Writable } from "node:stream";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++vi.mock("node:child_process", async (importOriginal) => {+ const actual = await importOriginal<typeof import("node:child_process")>();+ const spawn = vi.fn();+ return { ...actual, spawn, default: { ...(actual.default ?? {}), spawn } };+});++vi.mock("node:fs", async (importOriginal) => {+ const actual = await importOriginal<typeof import("node:fs")>();+ // The helper binary does not exist in a test checkout; pretend the first+ // candidate path is executable so path resolution is not what is under test.+ return {+ ...actual,+ accessSync: vi.fn(),+ default: { ...(actual.default ?? {}), accessSync: vi.fn() },+ };+});++import { spawn } from "node:child_process";+import { PipeWireCursorRecordingSession } from "./pipeWireCursorRecordingSession";++/** Minimal stand-in for the helper process: stdio pipes plus kill bookkeeping. */+class FakeHelper extends EventEmitter {+ stdout = new PassThrough();+ stderr = new PassThrough();+ stdinWrites: string[] = [];+ killed = false;+ signals: (string | undefined)[] = [];+ stdin: Writable;++ constructor() {+ super();+ const writes = this.stdinWrites;+ this.stdin = new Writable({+ write(chunk, _encoding, callback) {+ writes.push(chunk.toString());+ callback();+ },+ });+ }++ kill(signal?: string) {+ this.signals.push(signal);+ this.killed = true;+ return true;+ }++ /** Feeds one NDJSON line, the way the real helper emits them. */+ emitEvent(event: Record<string, unknown>) {+ this.stdout.write(`${JSON.stringify({ schemaVersion: 1, ...event })}\n`);+ }+}++const spawnMock = vi.mocked(spawn);+let helper: FakeHelper;++function newSession(overrides: Partial<{ maxSamples: number; sampleIntervalMs: number }> = {}) {+ return new PipeWireCursorRecordingSession({+ maxSamples: overrides.maxSamples ?? 100,+ sampleIntervalMs: overrides.sampleIntervalMs ?? 33,+ startTimeMs: 1_000,+ });+}++/** Starts a session that becomes ready as soon as the helper says so. */+async function startReady(session: PipeWireCursorRecordingSession) {+ const started = session.start();+ // The listeners are attached synchronously inside start(), so a microtask is+ // enough before the fake helper speaks.+ await Promise.resolve();+ helper.emitEvent({ event: "ready", timestampMs: 1_000, pipewireVersion: "1.0.5" });+ await started;+}++/** stdout is a stream: give the "data" listeners a turn before asserting. */+function flushStdout() {+ return new Promise((resolve) => setTimeout(resolve, 0));+}++beforeEach(() => {+ helper = new FakeHelper();+ spawnMock.mockReset();+ spawnMock.mockReturnValue(helper as unknown as ReturnType<typeof spawn>);+ const silence = () => {+ // The session logs every helper diagnostic; keep the test output readable.+ };+ vi.spyOn(console, "info").mockImplementation(silence);+ vi.spyOn(console, "warn").mockImplementation(silence);+ vi.spyOn(console, "error").mockImplementation(silence);+});++afterEach(() => {+ vi.restoreAllMocks();+});++describe("PipeWireCursorRecordingSession", () => {+ it("passes the sample interval to the helper as a JSON request argument", async () => {+ await startReady(newSession({ sampleIntervalMs: 20 }));+ const [, args] = spawnMock.mock.calls[0];+ expect(JSON.parse((args as string[])[0])).toEqual({ sampleIntervalMs: 20 });+ });++ it("resolves start() on `ready`, before the portal picker has been answered", async () => {+ const session = newSession();+ let resolved = false;+ const started = session.start().then(() => {+ resolved = true;+ });+ await Promise.resolve();+ expect(resolved).toBe(false);+ helper.emitEvent({ event: "ready", timestampMs: 1_000 });+ await started;+ expect(resolved).toBe(true);+ });++ it("rejects start() when the helper reports an error instead of becoming ready", async () => {+ const session = newSession();+ const started = session.start();+ await Promise.resolve();+ helper.emitEvent({+ event: "error",+ code: "cursor-metadata-unsupported",+ message: "no METADATA cursor mode",+ });+ await expect(started).rejects.toThrow("no METADATA cursor mode");+ });++ it("rejects start() when the helper exits before becoming ready", async () => {+ const session = newSession();+ const started = session.start();+ await Promise.resolve();+ helper.emit("exit", 1, null);+ await expect(started).rejects.toThrow(/exited before ready/);+ });++ it("normalises cursor positions against the stream size, not a display", async () => {+ const session = newSession();+ await startReady(session);+ helper.emitEvent({+ event: "cursor-sample",+ timestampMs: 2_000,+ x: 960,+ y: 270,+ width: 1920,+ height: 1080,+ visible: true,+ });+ await flushStdout();++ const data = await session.stop();+ expect(data.samples).toHaveLength(1);+ expect(data.samples[0]).toEqual({+ timeMs: 1_000,+ cx: 0.5,+ cy: 0.25,+ visible: true,+ interactionType: "move",+ });+ });++ it("clamps out-of-range positions and preserves the helper's visibility flag", async () => {+ const session = newSession();+ await startReady(session);+ helper.emitEvent({+ event: "cursor-sample",+ timestampMs: 2_000,+ x: -40,+ y: 5_000,+ width: 1920,+ height: 1080,+ visible: false,+ });+ await flushStdout();++ const [sample] = (await session.stop()).samples;+ expect(sample.cx).toBe(0);+ expect(sample.cy).toBe(1);+ expect(sample.visible).toBe(false);+ });++ it("never reports a click: Wayland exposes no mouse buttons to this process", async () => {+ const session = newSession();+ await startReady(session);+ for (let i = 0; i < 3; i++) {+ helper.emitEvent({+ event: "cursor-sample",+ timestampMs: 2_000 + i,+ x: i,+ y: i,+ width: 100,+ height: 100,+ visible: true,+ });+ }+ await flushStdout();++ const { samples } = await session.stop();+ expect(samples.map((sample) => sample.interactionType)).toEqual(["move", "move", "move"]);+ });++ it("collects each cursor sprite once and reports the native provider", async () => {+ const session = newSession();+ await startReady(session);+ const asset = {+ id: "sha-1",+ imageDataUrl: "data:image/png;base64,AAAA",+ width: 24,+ height: 24,+ hotspotX: 4,+ hotspotY: 3,+ };+ helper.emitEvent({+ event: "cursor-sample",+ timestampMs: 2_000,+ x: 0,+ y: 0,+ width: 100,+ height: 100,+ visible: true,+ assetId: "sha-1",+ asset,+ });+ // The helper only ships the payload once; later samples reference the id.+ helper.emitEvent({+ event: "cursor-sample",+ timestampMs: 2_100,+ x: 1,+ y: 1,+ width: 100,+ height: 100,+ visible: true,+ assetId: "sha-1",+ });+ await flushStdout();++ const data = await session.stop();+ expect(data.provider).toBe("native");+ expect(data.assets).toEqual([+ {+ id: "sha-1",+ platform: "linux",+ imageDataUrl: "data:image/png;base64,AAAA",+ width: 24,+ height: 24,+ hotspotX: 4,+ hotspotY: 3,+ scaleFactor: 1,+ },+ ]);+ expect(data.samples.map((sample) => sample.assetId)).toEqual(["sha-1", "sha-1"]);+ });++ it("reports the `none` provider when no sprite ever arrived", async () => {+ const session = newSession();+ await startReady(session);+ const data = await session.stop();+ expect(data.provider).toBe("none");+ expect(data.assets).toEqual([]);+ expect(data.version).toBe(2);+ });++ it("keeps only the newest samples once maxSamples is exceeded", async () => {+ const session = newSession({ maxSamples: 2 });+ await startReady(session);+ for (let i = 0; i < 4; i++) {+ helper.emitEvent({+ event: "cursor-sample",+ timestampMs: 1_000 + i,+ x: i,+ y: 0,+ width: 100,+ height: 100,+ visible: true,+ });+ }+ await flushStdout();++ const { samples } = await session.stop();+ expect(samples.map((sample) => sample.timeMs)).toEqual([2, 3]);+ });++ it("tolerates a JSON object split across two stdout chunks", async () => {+ const session = newSession();+ await startReady(session);+ const line = JSON.stringify({+ event: "cursor-sample",+ schemaVersion: 1,+ timestampMs: 1_500,+ x: 10,+ y: 20,+ width: 100,+ height: 200,+ visible: true,+ });+ helper.stdout.write(line.slice(0, 25));+ await flushStdout();+ helper.stdout.write(`${line.slice(25)}\n`);+ await flushStdout();++ const { samples } = await session.stop();+ expect(samples).toHaveLength(1);+ expect(samples[0].cx).toBeCloseTo(0.1);+ });++ it("ignores unparseable output rather than losing the rest of the stream", async () => {+ const session = newSession();+ await startReady(session);+ helper.stdout.write("not json at all\n");+ helper.emitEvent({+ event: "cursor-sample",+ timestampMs: 1_100,+ x: 50,+ y: 50,+ width: 100,+ height: 100,+ visible: true,+ });+ await flushStdout();++ const { samples } = await session.stop();+ expect(samples).toHaveLength(1);+ });++ it("asks the helper to stop over stdin before resorting to a signal", async () => {+ const session = newSession();+ await startReady(session);+ await session.stop();+ expect(helper.stdinWrites.join("")).toBe("stop\n");+ expect(helper.killed).toBe(false);+ });+});diff --git a/electron/native-bridge/cursor/recording/pipeWireCursorRecordingSession.ts b/electron/native-bridge/cursor/recording/pipeWireCursorRecordingSession.tsnew file mode 100644index 000000000..ccc150b84--- /dev/null+++ b/electron/native-bridge/cursor/recording/pipeWireCursorRecordingSession.ts@@ -0,0 +1,349 @@+import { type ChildProcessByStdio, spawn } from "node:child_process";+import { accessSync, constants as fsConstants } from "node:fs";+import path from "node:path";+import type { Readable, Writable } from "node:stream";+import type {+ CursorRecordingData,+ CursorRecordingSample,+ NativeCursorAsset,+} from "../../../../src/native/contracts";+import { clamp } from "../../../../src/utils/math";+import type { CursorRecordingSession } from "./session";++/**+ * Linux cursor recording via the ScreenCast portal's METADATA cursor mode.+ *+ * Why this exists at all: `screen.getCursorScreenPoint()` returns {0,0} under+ * Wayland, so `TelemetryRecordingSession` silently produced recordings whose+ * every sample sat in the top-left corner. The portal is the only source of a+ * real pointer position on Wayland — the compositor keeps the cursor out of the+ * captured pixels and attaches it to each frame as metadata instead.+ *+ * Two consequences the caller should know about:+ *+ * * `interactionType` is always "move". Wayland exposes no portal for mouse+ * buttons and /dev/input/event* is root:input, so clicks are unobtainable.+ * * The helper raises its own portal picker. On Wayland, Electron's+ * `desktopCapturer` already raised one, so the user currently picks a source+ * twice. Merging the two is the job of the capture stage that will reuse this+ * same portal session — SelectSources may only be called once per session,+ * so it has to be one session doing both.+ *+ * If the helper is missing or fails, this throws rather than falling back to+ * `TelemetryRecordingSession`. The caller (`startCursorRecording` in+ * electron/ipc/handlers.ts) catches that and records without cursor data, which+ * is the honest outcome: no cursor file beats a file full of {0,0}.+ */++const HELPER_NAME = "openscreen-pipewire-helper";+const READY_TIMEOUT_MS = 5_000;+const STOP_GRACE_MS = 500;++interface PipeWireCursorAssetPayload {+ id: string;+ imageDataUrl: string;+ width: number;+ height: number;+ hotspotX: number;+ hotspotY: number;+}++type PipeWireHelperEvent =+ | { event: "ready"; timestampMs: number; pipewireVersion?: string | null }+ | {+ event: "stream-started";+ timestampMs: number;+ nodeId: number;+ width: number;+ height: number;+ }+ | {+ event: "cursor-sample";+ timestampMs: number;+ x: number;+ y: number;+ width: number;+ height: number;+ visible: boolean;+ assetId?: string;+ asset?: PipeWireCursorAssetPayload;+ }+ | { event: "warning"; code: string; message: string }+ | { event: "error"; code: string; message: string }+ | { event: "debug"; code: string; [key: string]: unknown };++interface PipeWireCursorRecordingSessionOptions {+ maxSamples: number;+ sampleIntervalMs: number;+ startTimeMs?: number;+}++function platformArchTag() {+ return process.arch === "arm64" ? "linux-arm64" : "linux-x64";+}++function helperCandidates() {+ const envPath = process.env.OPENSCREEN_LINUX_CURSOR_HELPER_EXE?.trim();+ const appRoot = process.env.APP_ROOT ? path.resolve(process.env.APP_ROOT) : process.cwd();+ const archTag = platformArchTag();+ const resourceRoot =+ typeof process.resourcesPath === "string"+ ? process.resourcesPath+ : path.join(appRoot, "resources");++ return [+ envPath,+ path.join(appRoot, "electron", "native", "pipewire-capture", "build", HELPER_NAME),+ path.join(appRoot, "electron", "native", "bin", archTag, HELPER_NAME),+ path.join(resourceRoot, "electron", "native", "bin", archTag, HELPER_NAME),+ ].filter((candidate): candidate is string => Boolean(candidate));+}++export function findPipeWireCursorHelperPath() {+ for (const candidate of helperCandidates()) {+ try {+ accessSync(candidate, fsConstants.X_OK);+ return candidate;+ } catch {+ // Try the next helper location.+ }+ }++ return null;+}++export class PipeWireCursorRecordingSession implements CursorRecordingSession {+ private samples: CursorRecordingSample[] = [];+ private assets = new Map<string, NativeCursorAsset>();+ private process: ChildProcessByStdio<Writable, Readable, Readable> | null = null;+ private lineBuffer = "";+ private startTimeMs = 0;+ private readyResolve: (() => void) | null = null;+ private readyReject: ((error: Error) => void) | null = null;+ private readyTimer: NodeJS.Timeout | null = null;++ constructor(private readonly options: PipeWireCursorRecordingSessionOptions) {}++ async start(): Promise<void> {+ this.samples = [];+ this.assets.clear();+ this.lineBuffer = "";+ this.startTimeMs = this.options.startTimeMs ?? Date.now();++ const helperPath = findPipeWireCursorHelperPath();+ if (!helperPath) {+ throw new Error(+ "Linux cursor helper is not available. Build it with `npm run build:native:linux`.",+ );+ }++ const child = spawn(+ helperPath,+ [JSON.stringify({ sampleIntervalMs: this.options.sampleIntervalMs })],+ { stdio: ["pipe", "pipe", "pipe"] },+ );+ this.process = child;++ child.stdout.setEncoding("utf8");+ child.stdout.on("data", (chunk: string) => this.handleStdoutChunk(chunk));+ child.stderr.setEncoding("utf8");+ child.stderr.on("data", (chunk: string) => {+ const message = chunk.trim();+ if (message) {+ console.error("[cursor-linux]", message);+ }+ });+ child.once("exit", (code, signal) => {+ this.rejectReady(+ new Error(`Linux cursor helper exited before ready (code=${code}, signal=${signal})`),+ );+ this.process = null;+ });+ child.once("error", (error) => {+ this.rejectReady(error);+ this.process = null;+ });++ try {+ await this.waitUntilReady();+ } catch (error) {+ this.killHelperProcess(child);+ this.process = null;+ throw error;+ }+ }++ async stop(): Promise<CursorRecordingData> {+ const child = this.process;+ this.process = null;+ this.clearReadyState();++ if (child) {+ // `stop` on stdin lets the helper close the portal session cleanly;+ // SIGTERM is the fallback if it does not exit promptly.+ try {+ child.stdin.write("stop\n");+ child.stdin.end();+ } catch {+ // The pipe may already be closed if the helper died on its own.+ }+ this.killHelperProcess(child, STOP_GRACE_MS);+ }++ return {+ version: 2,+ provider: this.assets.size > 0 ? "native" : "none",+ samples: this.samples,+ assets: [...this.assets.values()],+ };+ }++ private handleStdoutChunk(chunk: string) {+ this.lineBuffer += chunk;+ const lines = this.lineBuffer.split(/\r?\n/);+ this.lineBuffer = lines.pop() ?? "";++ for (const line of lines) {+ const trimmedLine = line.trim();+ if (!trimmedLine) {+ continue;+ }++ try {+ this.handleEvent(JSON.parse(trimmedLine) as PipeWireHelperEvent);+ } catch (error) {+ console.error("Failed to parse Linux cursor helper output:", error, trimmedLine);+ }+ }+ }++ private handleEvent(payload: PipeWireHelperEvent) {+ switch (payload.event) {+ case "ready":+ this.resolveReady();+ return;+ case "stream-started":+ console.info(+ "[cursor-linux] portal stream started",+ JSON.stringify({+ nodeId: payload.nodeId,+ width: payload.width,+ height: payload.height,+ }),+ );+ return;+ case "cursor-sample":+ this.captureSample(payload);+ return;+ case "warning":+ console.warn(`[cursor-linux] ${payload.code}: ${payload.message}`);+ return;+ case "error":+ console.error(`[cursor-linux] ${payload.code}: ${payload.message}`);+ this.rejectReady(new Error(payload.message));+ return;+ case "debug":+ console.info("[cursor-linux][debug]", JSON.stringify(payload));+ return;+ }+ }++ private captureSample(payload: Extract<PipeWireHelperEvent, { event: "cursor-sample" }>) {+ this.rememberAsset(payload.asset);++ // Normalised against the stream's own dimensions, which the helper repeats+ // on every sample. Electron's display bounds are deliberately NOT used:+ // they are in DIPs, whereas the portal reports stream pixels, and the+ // portal's source is whatever the user picked in its own dialog, which+ // need not be the display the app thinks it is recording.+ const width = Math.max(1, payload.width);+ const height = Math.max(1, payload.height);++ this.samples.push({+ timeMs: Math.max(0, payload.timestampMs - this.startTimeMs),+ cx: clamp(payload.x / width, 0, 1),+ cy: clamp(payload.y / height, 0, 1),+ visible: payload.visible,+ // Wayland exposes no click events to an unprivileged process.+ interactionType: "move",+ ...(payload.assetId ? { assetId: payload.assetId } : {}),+ });++ if (this.samples.length > this.options.maxSamples) {+ this.samples.shift();+ }+ }++ private rememberAsset(asset: PipeWireCursorAssetPayload | undefined) {+ if (!asset?.id || this.assets.has(asset.id)) {+ return;+ }++ this.assets.set(asset.id, {+ id: asset.id,+ platform: "linux",+ imageDataUrl: asset.imageDataUrl,+ width: asset.width,+ height: asset.height,+ hotspotX: asset.hotspotX,+ hotspotY: asset.hotspotY,+ // The portal reports cursor bitmaps in stream pixels, the same space+ // the positions are in, so no extra scaling applies.+ scaleFactor: 1,+ });+ }++ private waitUntilReady() {+ return new Promise<void>((resolve, reject) => {+ this.readyResolve = resolve;+ this.readyReject = reject;+ this.readyTimer = setTimeout(() => {+ this.rejectReady(new Error("Timed out waiting for Linux cursor helper"));+ }, READY_TIMEOUT_MS);+ });+ }++ private resolveReady() {+ const resolve = this.readyResolve;+ this.clearReadyState();+ resolve?.();+ }++ private rejectReady(error: Error) {+ const reject = this.readyReject;+ this.clearReadyState();+ reject?.(error);+ }++ private clearReadyState() {+ if (this.readyTimer) {+ clearTimeout(this.readyTimer);+ this.readyTimer = null;+ }+ this.readyResolve = null;+ this.readyReject = null;+ }++ private killHelperProcess(child: ChildProcessByStdio<Writable, Readable, Readable>, graceMs = 0) {+ if (child.killed) {+ return;+ }++ const terminate = () => {+ if (!child.killed) {+ child.kill("SIGTERM");+ }+ setTimeout(() => {+ if (!child.killed) {+ child.kill("SIGKILL");+ }+ }, 500).unref();+ };++ if (graceMs > 0) {+ setTimeout(terminate, graceMs).unref();+ return;+ }+ terminate();+ }+}diff --git a/electron/native/README.md b/electron/native/README.mdindex 9c450339d..5b38de88e 100644--- a/electron/native/README.md+++ b/electron/native/README.md@@ -116,6 +116,102 @@ npm run test:wgc-mic:winRemove-Item Env:OPENSCREEN_WGC_TEST_MICROPHONE_DEVICE_NAME```+## Linux++Linux cursor recording is handled by `openscreen-pipewire-helper`+(`electron/native/pipewire-capture`). Stage 1 emits **cursor samples only** — no+video capture, no encoding.++It exists because `screen.getCursorScreenPoint()` returns `{0,0}` under Wayland.+`TelemetryRecordingSession` therefore produced well-formed recordings whose every+cursor sample sat in the top-left corner of the screen. The ScreenCast portal's+METADATA cursor mode is the only source of a real pointer position on Wayland:+the compositor keeps the cursor out of the captured pixels and attaches it to+each frame as `SPA_META_Cursor` instead.++Helper locations, in resolution order:++1. `OPENSCREEN_LINUX_CURSOR_HELPER_EXE`, for local development and diagnostics.+2. `electron/native/pipewire-capture/build/openscreen-pipewire-helper`, for a locally built binary.+3. `electron/native/bin/linux-x64/openscreen-pipewire-helper` (or `linux-arm64`), for packaged prebuilt helpers.++Build it with:++```bash+npm run build:native:linux+```++The build needs `cargo` and a C compiler and **nothing else** — in particular not+`libpipewire-0.3-dev`, which Ubuntu does not ship by default and which needs root+to install. The C shim compiles against headers vendored in+`electron/native/pipewire-capture/vendor/` and resolves `libpipewire-0.3.so.0`+with `dlopen` at runtime. On non-Linux hosts the command exits successfully.++The contract matches the other helpers: one JSON argument, newline-delimited JSON+events on stdout, `stop\n` (or EOF) on stdin. Events are `ready`, `stream-started`,+`cursor-sample`, `warning`, `error` and `debug`, each carrying `"schemaVersion": 1`.+`ready` is emitted before the portal picker is raised, so the app's readiness+timeout does not have to accommodate a human clicking a dialog; `stream-started`+marks the point where samples begin.++### Manual verification++**This raises the GNOME/portal source picker and streams until you stop it.**++```bash+OPENSCREEN_PIPEWIRE_DEBUG=1 electron/native/bin/linux-x64/openscreen-pipewire-helper '{"sampleIntervalMs":100}'+```++Pick a monitor in the dialog, move the mouse, and `cursor-sample` lines with real+coordinates should stream out. Type `stop` and press Enter, or Ctrl-D, to end it.++`OPENSCREEN_PIPEWIRE_DEBUG=1` additionally reports stream state transitions, the+negotiated SPA buffer data type, the full list of metadata blocks that survived+negotiation, and whether `SPA_META_Cursor` carries a sprite bitmap. Every line+carries `timestampMs`, so a log shows how long the stream actually lived.++### Field notes from the first real GNOME run++Two facts, and two bugs that run exposed. Both bugs are fixed; both are pinned by+tests that run without a portal.++- **mutter negotiates `MemFd`**, not DMA-BUF, even when the helper advertises+ `MemPtr|MemFd|DmaBuf`. Worth knowing for the video stage: the pixels arrive as+ a mappable fd, so a CPU path is viable and no DMA-BUF import is required.+- **`SPA_META_Cursor` was absent from every buffer.** Producers declare+ `SPA_PARAM_META_size` as a *fixed* value — mutter 46.2 uses+ `CURSOR_META_SIZE(384, 384)` = 589872 bytes — and PipeWire intersects it with+ the consumer's declaration. The helper's range was capped at 256×256 = 262192+ bytes, so the intersection was empty, the whole `ParamMeta` object was dropped,+ and the buffers arrived with no cursor metadata. There is no error for this: the+ stream negotiates and runs perfectly while reporting nothing. The ceiling is now+ 1024×1024, matching OBS. A range that does not *contain* the producer's constant+ is the failure mode to remember.+- **The stream was also dying on its own**, reporting `target not found`. That+ string comes from WirePlumber's `policy-node.lua`, in the branch taken when+ `node.dont-reconnect` is set — which `PW_STREAM_FLAG_DONT_RECONNECT` sets. That+ branch destroys the node outright, turning a transient link failure into a+ permanent, silent end of capture. The flag is gone.++To exercise everything except the picker — dlopen, D-Bus, and the portal's+cursor-mode check — run the non-interactive probe. This is also what+`npm run build:native:linux` runs after a successful build:++```bash+electron/native/bin/linux-x64/openscreen-pipewire-helper '{"probeOnly":true}'+```++### Known gaps++- **Mouse clicks are unobtainable.** Wayland exposes no portal for input events+ and `/dev/input/event*` is `root:input`, so every sample's `interactionType` is+ `"move"`.+- **The user picks a source twice.** Electron's `desktopCapturer` raises its own+ portal dialog for the video, and this helper raises a second one for the cursor.+ Collapsing them requires one portal session serving both, which is why the+ capture stage has to reuse this helper's session — `SelectSources` may only be+ called once per session.+## STT helperThe speech-to-text helper (`whisper-stt-server`) is built separately from thediff --git a/electron/native/pipewire-capture/Cargo.lock b/electron/native/pipewire-capture/Cargo.locknew file mode 100644index 000000000..fccd2359d--- /dev/null+++ b/electron/native/pipewire-capture/Cargo.lock@@ -0,0 +1,1523 @@+# This file is automatically @generated by Cargo.+# It is not intended for manual editing.+version = 4++[[package]]+name = "adler2"+version = "2.0.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"++[[package]]+name = "ashpd"+version = "0.9.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4f8bd58b44ea371b48d21cdc217380cfcafd4b2bb1ad50d27514ec5beca71a2d"+dependencies = [+ "async-fs",+ "async-net",+ "enumflags2",+ "futures-channel",+ "futures-util",+ "rand",+ "serde",+ "serde_repr",+ "url",+ "zbus",+]++[[package]]+name = "async-broadcast"+version = "0.7.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532"+dependencies = [+ "event-listener",+ "event-listener-strategy",+ "futures-core",+ "pin-project-lite",+]++[[package]]+name = "async-channel"+version = "2.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2"+dependencies = [+ "concurrent-queue",+ "event-listener-strategy",+ "futures-core",+ "pin-project-lite",+]++[[package]]+name = "async-executor"+version = "1.14.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c96bf972d85afc50bf5ab8fe2d54d1586b4e0b46c97c50a0c9e71e2f7bcd812a"+dependencies = [+ "async-task",+ "concurrent-queue",+ "fastrand",+ "futures-lite",+ "pin-project-lite",+ "slab",+]++[[package]]+name = "async-fs"+version = "2.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8034a681df4aed8b8edbd7fbe472401ecf009251c8b40556b304567052e294c5"+dependencies = [+ "async-lock",+ "blocking",+ "futures-lite",+]++[[package]]+name = "async-io"+version = "2.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc"+dependencies = [+ "autocfg",+ "cfg-if",+ "concurrent-queue",+ "futures-io",+ "futures-lite",+ "parking",+ "polling",+ "rustix",+ "slab",+ "windows-sys 0.61.2",+]++[[package]]+name = "async-lock"+version = "3.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "290f7f2596bd5b78a9fec8088ccd89180d7f9f55b94b0576823bbbdc72ee8311"+dependencies = [+ "event-listener",+ "event-listener-strategy",+ "pin-project-lite",+]++[[package]]+name = "async-net"+version = "2.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b948000fad4873c1c9339d60f2623323a0cfd3816e5181033c6a5cb68b2accf7"+dependencies = [+ "async-io",+ "blocking",+ "futures-lite",+]++[[package]]+name = "async-process"+version = "2.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75"+dependencies = [+ "async-channel",+ "async-io",+ "async-lock",+ "async-signal",+ "async-task",+ "blocking",+ "cfg-if",+ "event-listener",+ "futures-lite",+ "rustix",+]++[[package]]+name = "async-recursion"+version = "1.1.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "async-signal"+version = "0.2.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "52b5aaafa020cf5053a01f2a60e8ff5dccf550f0f77ec54a4e47285ac2bab485"+dependencies = [+ "async-io",+ "async-lock",+ "atomic-waker",+ "cfg-if",+ "futures-core",+ "futures-io",+ "rustix",+ "signal-hook-registry",+ "slab",+ "windows-sys 0.61.2",+]++[[package]]+name = "async-task"+version = "4.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de"++[[package]]+name = "async-trait"+version = "0.1.91"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ae36dc4177970ef04fde5178d3e2429882def40e57a451f919c098f72baa6cec"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.3",+]++[[package]]+name = "atomic-waker"+version = "1.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"++[[package]]+name = "autocfg"+version = "1.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"++[[package]]+name = "base64"+version = "0.22.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"++[[package]]+name = "bitflags"+version = "1.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"++[[package]]+name = "bitflags"+version = "2.13.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"++[[package]]+name = "block-buffer"+version = "0.10.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"+dependencies = [+ "generic-array",+]++[[package]]+name = "blocking"+version = "1.6.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e83f8d02be6967315521be875afa792a316e28d57b5a2d401897e2a7921b7f21"+dependencies = [+ "async-channel",+ "async-task",+ "futures-io",+ "futures-lite",+ "piper",+]++[[package]]+name = "cc"+version = "1.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5add81bb678e6cb321aff7fa0dc7689ad82b112dbc032cea19f91d6b8e3582b9"+dependencies = [+ "find-msvc-tools",+ "shlex",+]++[[package]]+name = "cfg-if"+version = "1.0.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"++[[package]]+name = "cfg_aliases"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"++[[package]]+name = "concurrent-queue"+version = "2.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973"+dependencies = [+ "crossbeam-utils",+]++[[package]]+name = "cpufeatures"+version = "0.2.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"+dependencies = [+ "libc",+]++[[package]]+name = "crc32fast"+version = "1.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"+dependencies = [+ "cfg-if",+]++[[package]]+name = "crossbeam-utils"+version = "0.8.22"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17"++[[package]]+name = "crypto-common"+version = "0.1.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"+dependencies = [+ "generic-array",+ "typenum",+]++[[package]]+name = "digest"+version = "0.10.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"+dependencies = [+ "block-buffer",+ "crypto-common",+]++[[package]]+name = "displaydoc"+version = "0.2.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.3",+]++[[package]]+name = "endi"+version = "1.1.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099"++[[package]]+name = "enumflags2"+version = "0.7.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef"+dependencies = [+ "enumflags2_derive",+ "serde",+]++[[package]]+name = "enumflags2_derive"+version = "0.7.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "equivalent"+version = "1.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"++[[package]]+name = "errno"+version = "0.3.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"+dependencies = [+ "libc",+ "windows-sys 0.61.2",+]++[[package]]+name = "event-listener"+version = "5.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2"+dependencies = [+ "parking",+ "pin-project-lite",+]++[[package]]+name = "event-listener-strategy"+version = "0.5.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93"+dependencies = [+ "event-listener",+ "pin-project-lite",+]++[[package]]+name = "fastrand"+version = "2.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"++[[package]]+name = "fdeflate"+version = "0.3.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c"+dependencies = [+ "simd-adler32",+]++[[package]]+name = "find-msvc-tools"+version = "0.1.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"++[[package]]+name = "flate2"+version = "1.1.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c"+dependencies = [+ "crc32fast",+ "miniz_oxide",+]++[[package]]+name = "form_urlencoded"+version = "1.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"+dependencies = [+ "percent-encoding",+]++[[package]]+name = "futures-channel"+version = "0.3.33"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "262590f4fe6afeb0bc83be1daa64e52657fe185690a958af7f3ad0e92085c5ae"+dependencies = [+ "futures-core",+]++[[package]]+name = "futures-core"+version = "0.3.33"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2cd50c473c80f6d7c3670a752354b8e569b1a7cbfdc0419ec88e5edad85e0dc7"++[[package]]+name = "futures-io"+version = "0.3.33"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4577ecaa3c4f96589d473f679a71b596316f6641bc350038b962a5daf0085d7a"++[[package]]+name = "futures-lite"+version = "2.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad"+dependencies = [+ "fastrand",+ "futures-core",+ "futures-io",+ "parking",+ "pin-project-lite",+]++[[package]]+name = "futures-macro"+version = "0.3.33"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2d6d3cde68c518367be28956066ddfef33813991b77a55005a69dae04bf3b10b"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "futures-sink"+version = "0.3.33"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e34418ac499d6305c2fb5ad0ed2f6ac998c5f8ca209b4510f7f94242c647e307"++[[package]]+name = "futures-task"+version = "0.3.33"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b231ed28831efb4a61a08580c4bc233ec56bc009f4cd8f52da2c3cb97df0c109"++[[package]]+name = "futures-util"+version = "0.3.33"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a77a90a256fce34da66415271e30f94ee91c57b04b8a2c042d9cf3220179deaa"+dependencies = [+ "futures-core",+ "futures-io",+ "futures-macro",+ "futures-sink",+ "futures-task",+ "memchr",+ "pin-project-lite",+ "slab",+]++[[package]]+name = "generic-array"+version = "0.14.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"+dependencies = [+ "typenum",+ "version_check",+]++[[package]]+name = "getrandom"+version = "0.2.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"+dependencies = [+ "cfg-if",+ "libc",+ "wasi",+]++[[package]]+name = "getrandom"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"+dependencies = [+ "cfg-if",+ "libc",+ "r-efi",+]++[[package]]+name = "hashbrown"+version = "0.17.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"++[[package]]+name = "hermit-abi"+version = "0.5.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c"++[[package]]+name = "hex"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"++[[package]]+name = "icu_collections"+version = "2.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c"+dependencies = [+ "displaydoc",+ "potential_utf",+ "utf8_iter",+ "yoke",+ "zerofrom",+ "zerovec",+]++[[package]]+name = "icu_locale_core"+version = "2.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29"+dependencies = [+ "displaydoc",+ "litemap",+ "tinystr",+ "writeable",+ "zerovec",+]++[[package]]+name = "icu_normalizer"+version = "2.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4"+dependencies = [+ "icu_collections",+ "icu_normalizer_data",+ "icu_properties",+ "icu_provider",+ "smallvec",+ "zerovec",+]++[[package]]+name = "icu_normalizer_data"+version = "2.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38"++[[package]]+name = "icu_properties"+version = "2.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de"+dependencies = [+ "icu_collections",+ "icu_locale_core",+ "icu_properties_data",+ "icu_provider",+ "zerotrie",+ "zerovec",+]++[[package]]+name = "icu_properties_data"+version = "2.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14"++[[package]]+name = "icu_provider"+version = "2.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421"+dependencies = [+ "displaydoc",+ "icu_locale_core",+ "writeable",+ "yoke",+ "zerofrom",+ "zerotrie",+ "zerovec",+]++[[package]]+name = "idna"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"+dependencies = [+ "idna_adapter",+ "smallvec",+ "utf8_iter",+]++[[package]]+name = "idna_adapter"+version = "1.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714"+dependencies = [+ "icu_normalizer",+ "icu_properties",+]++[[package]]+name = "indexmap"+version = "2.14.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"+dependencies = [+ "equivalent",+ "hashbrown",+]++[[package]]+name = "itoa"+version = "1.0.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"++[[package]]+name = "libc"+version = "0.2.189"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"++[[package]]+name = "linux-raw-sys"+version = "0.12.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"++[[package]]+name = "litemap"+version = "0.8.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0"++[[package]]+name = "memchr"+version = "2.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"++[[package]]+name = "memoffset"+version = "0.9.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"+dependencies = [+ "autocfg",+]++[[package]]+name = "miniz_oxide"+version = "0.8.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"+dependencies = [+ "adler2",+ "simd-adler32",+]++[[package]]+name = "nix"+version = "0.29.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"+dependencies = [+ "bitflags 2.13.1",+ "cfg-if",+ "cfg_aliases",+ "libc",+ "memoffset",+]++[[package]]+name = "once_cell"+version = "1.21.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"++[[package]]+name = "openscreen-pipewire-helper"+version = "0.0.0"+dependencies = [+ "ashpd",+ "base64",+ "cc",+ "png",+ "pollster",+ "serde",+ "serde_json",+ "sha2",+]++[[package]]+name = "ordered-stream"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50"+dependencies = [+ "futures-core",+ "pin-project-lite",+]++[[package]]+name = "parking"+version = "2.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"++[[package]]+name = "percent-encoding"+version = "2.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"++[[package]]+name = "pin-project-lite"+version = "0.2.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"++[[package]]+name = "piper"+version = "0.2.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1"+dependencies = [+ "atomic-waker",+ "fastrand",+ "futures-io",+]++[[package]]+name = "png"+version = "0.17.16"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526"+dependencies = [+ "bitflags 1.3.2",+ "crc32fast",+ "fdeflate",+ "flate2",+ "miniz_oxide",+]++[[package]]+name = "polling"+version = "3.11.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218"+dependencies = [+ "cfg-if",+ "concurrent-queue",+ "hermit-abi",+ "pin-project-lite",+ "rustix",+ "windows-sys 0.61.2",+]++[[package]]+name = "pollster"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3"++[[package]]+name = "potential_utf"+version = "0.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564"+dependencies = [+ "zerovec",+]++[[package]]+name = "ppv-lite86"+version = "0.2.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"+dependencies = [+ "zerocopy",+]++[[package]]+name = "proc-macro-crate"+version = "3.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f"+dependencies = [+ "toml_edit",+]++[[package]]+name = "proc-macro2"+version = "1.0.107"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"+dependencies = [+ "unicode-ident",+]++[[package]]+name = "quote"+version = "1.0.47"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"+dependencies = [+ "proc-macro2",+]++[[package]]+name = "r-efi"+version = "6.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"++[[package]]+name = "rand"+version = "0.8.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "22f6172bdec972074665ed81ed53b71da00bfc44b65a753cfde883ec4c702a1a"+dependencies = [+ "libc",+ "rand_chacha",+ "rand_core",+]++[[package]]+name = "rand_chacha"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"+dependencies = [+ "ppv-lite86",+ "rand_core",+]++[[package]]+name = "rand_core"+version = "0.6.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"+dependencies = [+ "getrandom 0.2.17",+]++[[package]]+name = "rustix"+version = "1.1.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"+dependencies = [+ "bitflags 2.13.1",+ "errno",+ "libc",+ "linux-raw-sys",+ "windows-sys 0.61.2",+]++[[package]]+name = "serde"+version = "1.0.229"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"+dependencies = [+ "serde_core",+ "serde_derive",+]++[[package]]+name = "serde_core"+version = "1.0.229"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"+dependencies = [+ "serde_derive",+]++[[package]]+name = "serde_derive"+version = "1.0.229"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.3",+]++[[package]]+name = "serde_json"+version = "1.0.151"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"+dependencies = [+ "itoa",+ "memchr",+ "serde",+ "serde_core",+ "zmij",+]++[[package]]+name = "serde_repr"+version = "0.1.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.3",+]++[[package]]+name = "sha1"+version = "0.10.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8"+dependencies = [+ "cfg-if",+ "cpufeatures",+ "digest",+]++[[package]]+name = "sha2"+version = "0.10.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"+dependencies = [+ "cfg-if",+ "cpufeatures",+ "digest",+]++[[package]]+name = "shlex"+version = "2.0.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"++[[package]]+name = "signal-hook-registry"+version = "1.4.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"+dependencies = [+ "errno",+ "libc",+]++[[package]]+name = "simd-adler32"+version = "0.3.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"++[[package]]+name = "slab"+version = "0.4.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"++[[package]]+name = "smallvec"+version = "1.15.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90"++[[package]]+name = "stable_deref_trait"+version = "1.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"++[[package]]+name = "static_assertions"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"++[[package]]+name = "syn"+version = "2.0.119"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"+dependencies = [+ "proc-macro2",+ "quote",+ "unicode-ident",+]++[[package]]+name = "syn"+version = "3.0.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"+dependencies = [+ "proc-macro2",+ "quote",+ "unicode-ident",+]++[[package]]+name = "synstructure"+version = "0.13.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "tempfile"+version = "3.27.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"+dependencies = [+ "fastrand",+ "getrandom 0.4.3",+ "once_cell",+ "rustix",+ "windows-sys 0.61.2",+]++[[package]]+name = "tinystr"+version = "0.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d"+dependencies = [+ "displaydoc",+ "zerovec",+]++[[package]]+name = "toml_datetime"+version = "1.1.1+spec-1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7"+dependencies = [+ "serde_core",+]++[[package]]+name = "toml_edit"+version = "0.25.13+spec-1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6975367e4d2ef766d86af01ffad14b622fecc8d4357a998fbc4deb6e9bacaf9b"+dependencies = [+ "indexmap",+ "toml_datetime",+ "toml_parser",+ "winnow",+]++[[package]]+name = "toml_parser"+version = "1.1.3+spec-1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56"+dependencies = [+ "winnow",+]++[[package]]+name = "tracing"+version = "0.1.44"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"+dependencies = [+ "pin-project-lite",+ "tracing-attributes",+ "tracing-core",+]++[[package]]+name = "tracing-attributes"+version = "0.1.31"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "tracing-core"+version = "0.1.36"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"+dependencies = [+ "once_cell",+]++[[package]]+name = "typenum"+version = "1.20.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"++[[package]]+name = "uds_windows"+version = "1.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"+dependencies = [+ "memoffset",+ "tempfile",+ "windows-sys 0.61.2",+]++[[package]]+name = "unicode-ident"+version = "1.0.24"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"++[[package]]+name = "url"+version = "2.5.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"+dependencies = [+ "form_urlencoded",+ "idna",+ "percent-encoding",+ "serde",+ "serde_derive",+]++[[package]]+name = "utf8_iter"+version = "1.0.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"++[[package]]+name = "version_check"+version = "0.9.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"++[[package]]+name = "wasi"+version = "0.11.1+wasi-snapshot-preview1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"++[[package]]+name = "windows-link"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"++[[package]]+name = "windows-sys"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"+dependencies = [+ "windows-targets",+]++[[package]]+name = "windows-sys"+version = "0.59.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"+dependencies = [+ "windows-targets",+]++[[package]]+name = "windows-sys"+version = "0.61.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"+dependencies = [+ "windows-link",+]++[[package]]+name = "windows-targets"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"+dependencies = [+ "windows_aarch64_gnullvm",+ "windows_aarch64_msvc",+ "windows_i686_gnu",+ "windows_i686_gnullvm",+ "windows_i686_msvc",+ "windows_x86_64_gnu",+ "windows_x86_64_gnullvm",+ "windows_x86_64_msvc",+]++[[package]]+name = "windows_aarch64_gnullvm"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"++[[package]]+name = "windows_aarch64_msvc"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"++[[package]]+name = "windows_i686_gnu"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"++[[package]]+name = "windows_i686_gnullvm"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"++[[package]]+name = "windows_i686_msvc"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"++[[package]]+name = "windows_x86_64_gnu"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"++[[package]]+name = "windows_x86_64_gnullvm"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"++[[package]]+name = "windows_x86_64_msvc"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"++[[package]]+name = "winnow"+version = "1.0.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81"+dependencies = [+ "memchr",+]++[[package]]+name = "writeable"+version = "0.6.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4"++[[package]]+name = "xdg-home"+version = "1.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6"+dependencies = [+ "libc",+ "windows-sys 0.59.0",+]++[[package]]+name = "yoke"+version = "0.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5"+dependencies = [+ "stable_deref_trait",+ "yoke-derive",+ "zerofrom",+]++[[package]]+name = "yoke-derive"+version = "0.8.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+ "synstructure",+]++[[package]]+name = "zbus"+version = "4.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725"+dependencies = [+ "async-broadcast",+ "async-executor",+ "async-fs",+ "async-io",+ "async-lock",+ "async-process",+ "async-recursion",+ "async-task",+ "async-trait",+ "blocking",+ "enumflags2",+ "event-listener",+ "futures-core",+ "futures-sink",+ "futures-util",+ "hex",+ "nix",+ "ordered-stream",+ "rand",+ "serde",+ "serde_repr",+ "sha1",+ "static_assertions",+ "tracing",+ "uds_windows",+ "windows-sys 0.52.0",+ "xdg-home",+ "zbus_macros",+ "zbus_names",+ "zvariant",+]++[[package]]+name = "zbus_macros"+version = "4.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e"+dependencies = [+ "proc-macro-crate",+ "proc-macro2",+ "quote",+ "syn 2.0.119",+ "zvariant_utils",+]++[[package]]+name = "zbus_names"+version = "3.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c"+dependencies = [+ "serde",+ "static_assertions",+ "zvariant",+]++[[package]]+name = "zerocopy"+version = "0.8.55"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b5a105cd7b140f6eeec8acff2ea38135d3cab283ada58540f629fe51e46696eb"+dependencies = [+ "zerocopy-derive",+]++[[package]]+name = "zerocopy-derive"+version = "0.8.55"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0fe976fb70c78cd64cccfe3a6fc142244e8a77b70959b30faf9d0ac37ee228eb"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "zerofrom"+version = "0.1.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272"+dependencies = [+ "zerofrom-derive",+]++[[package]]+name = "zerofrom-derive"+version = "0.1.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+ "synstructure",+]++[[package]]+name = "zerotrie"+version = "0.2.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf"+dependencies = [+ "displaydoc",+ "yoke",+ "zerofrom",+]++[[package]]+name = "zerovec"+version = "0.11.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239"+dependencies = [+ "yoke",+ "zerofrom",+ "zerovec-derive",+]++[[package]]+name = "zerovec-derive"+version = "0.11.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "zmij"+version = "1.0.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"++[[package]]+name = "zvariant"+version = "4.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe"+dependencies = [+ "endi",+ "enumflags2",+ "serde",+ "static_assertions",+ "url",+ "zvariant_derive",+]++[[package]]+name = "zvariant_derive"+version = "4.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449"+dependencies = [+ "proc-macro-crate",+ "proc-macro2",+ "quote",+ "syn 2.0.119",+ "zvariant_utils",+]++[[package]]+name = "zvariant_utils"+version = "2.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]diff --git a/electron/native/pipewire-capture/Cargo.toml b/electron/native/pipewire-capture/Cargo.tomlnew file mode 100644index 000000000..d412fe1ab--- /dev/null+++ b/electron/native/pipewire-capture/Cargo.toml@@ -0,0 +1,53 @@+# OpenScreen Linux capture helper (PipeWire + xdg-desktop-portal).+#+# WHY IT LIVES HERE AND NOT IN crates/.+#+# `crates/` is the compositor workspace: a rendering library plus the napi addon+# the app links, sharing wgpu/ffmpeg/windows dependencies and a French comment+# convention. This is not that. It is a sidecar executable spawned over stdio,+# exactly like `electron/native/screencapturekit/` (Swift) and+# `electron/native/wgc-capture/` (C++), and it shares nothing with the+# compositor — no wgpu, no ffmpeg, no napi. Putting it in the compositor+# workspace would drag its dependency tree (ashpd/zbus, cc, png) into every+# `cargo build -p compositor-view-napi` resolution for no benefit, and would put+# a Linux-only binary behind a workspace whose default member is a Windows POC.+#+# It is therefore a standalone package. `[workspace]` below makes that explicit+# so that a future root Cargo.toml cannot silently adopt it.++[package]+name = "openscreen-pipewire-helper"+version = "0.0.0"+edition = "2021"+publish = false+license = "MIT"++[workspace]++[[bin]]+name = "openscreen-pipewire-helper"+path = "src/main.rs"++[dependencies]+# Pure-Rust D-Bus. Deliberately NOT the `pipewire` feature (that one pulls+# pipewire-rs, which needs libpipewire-0.3-dev at build time — the exact+# dependency this crate exists to avoid) and NOT `gtk4`.+ashpd = { version = "0.9", default-features = false, features = ["async-std"] }+# ashpd's async-std feature routes zbus through async-io, whose reactor lives on+# its own thread, so a plain block_on is all the executor we need.+pollster = "0.4"+serde = { version = "1", features = ["derive"] }+serde_json = "1"+# Cursor sprites: the renderer wants a PNG data URL (see NativeCursorAsset in+# src/native/contracts.ts). Both crates are pure Rust, no C dependency.+png = "0.17"+base64 = "0.22"+sha2 = "0.10"++[build-dependencies]+cc = "1"++[profile.release]+opt-level = 2+lto = true+strip = truediff --git a/electron/native/pipewire-capture/build.rs b/electron/native/pipewire-capture/build.rsnew file mode 100644index 000000000..2b850214a--- /dev/null+++ b/electron/native/pipewire-capture/build.rs@@ -0,0 +1,36 @@+// Compiles csrc/pw_shim.c against the vendored PipeWire headers.+//+// There is deliberately no pkg-config probe and no `println!("cargo:rustc-link-lib=…")`:+// the shim resolves every libpipewire symbol with dlsym at runtime, so the only+// build input is a C compiler and the header tree under vendor/. That is what+// makes this crate buildable on a machine with no libpipewire-0.3-dev, which is+// most machines — Ubuntu ships only the runtime .so.0.++use std::path::PathBuf;++fn main() {+ let root = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR"));+ let vendor = root.join("vendor/pipewire-1.0.5/include");+ let shim = root.join("csrc/pw_shim.c");++ assert!(+ vendor.join("pipewire/pipewire.h").is_file(),+ "vendored PipeWire headers are missing at {} — see vendor/README.md",+ vendor.display()+ );++ cc::Build::new()+ .file(&shim)+ .include(&vendor)+ .include(root.join("csrc"))+ .flag_if_supported("-std=gnu11")+ .warnings(true)+ .compile("openscreen_pw_shim");++ println!("cargo:rerun-if-changed={}", shim.display());+ println!("cargo:rerun-if-changed={}", root.join("csrc/pw_shim.h").display());+ println!("cargo:rerun-if-changed={}", vendor.display());++ // dlopen/dlsym.+ println!("cargo:rustc-link-lib=dl");+}diff --git a/electron/native/pipewire-capture/csrc/pw_shim.c b/electron/native/pipewire-capture/csrc/pw_shim.cnew file mode 100644index 000000000..d6377b6d9--- /dev/null+++ b/electron/native/pipewire-capture/csrc/pw_shim.c@@ -0,0 +1,723 @@+/*+ * PipeWire glue for the OpenScreen Linux capture helper.+ *+ * WHY THIS FILE IS C AND NOT RUST.+ *+ * Two thirds of the PipeWire/SPA API a consumer needs is not in the shared+ * object at all: `spa_pod_builder_*`, the `SPA_POD_CHOICE_*` macros,+ * `spa_format_video_raw_parse` and `spa_buffer_find_meta` are `static inline`+ * in the headers. Rust cannot call them, and re-implementing the POD builder in+ * Rust would mean restating a binary serialisation format by hand — exactly the+ * kind of thing AGENTS.md flags as security-sensitive. Compiling the real+ * headers keeps every struct layout and every POD byte in the hands of the+ * upstream code that defines them.+ *+ * WHY dlopen AND NOT -lpipewire-0.3.+ *+ * Ubuntu ships `libpipewire-0.3.so.0` in the base system but the `.so` link and+ * the headers only come with `libpipewire-0.3-dev`. Linking normally would put+ * a dev package in every contributor's and CI runner's critical path, and would+ * bake a hard DT_NEEDED into the helper so that it could not even start to+ * print a clean "PipeWire is not available" error. dlopen at runtime gives us+ * the vendored headers' ABI at compile time and a recoverable failure at run+ * time — the same trade the compositor addon makes with ffmpeg.+ *+ * The headers under ../vendor/ are PipeWire 1.0.5, MIT, unmodified. The ABI has+ * been stable across 0.3.x/1.x for everything used here (pw_stream, pw_context,+ * spa_meta_cursor), so a runtime with a different minor version is fine.+ */++#include <dlfcn.h>+#include <errno.h>+#include <stdarg.h>+#include <stdio.h>+#include <stdlib.h>+#include <string.h>+#include <unistd.h>++#include <pipewire/pipewire.h>+#include <spa/buffer/meta.h>+#include <spa/param/video/format-utils.h>+#include <spa/pod/filter.h>+#include <spa/utils/result.h>++#include "pw_shim.h"++#define OSC_PW_SONAME "libpipewire-0.3.so.0"++/*+ * Cursor metadata budget: `struct spa_meta_cursor` + `struct spa_meta_bitmap` ++ * w*h*4 bytes of pixels.+ *+ * THE UPPER BOUND IS LOAD-BEARING, AND GETTING IT WRONG FAILS SILENTLY.+ *+ * PipeWire negotiates SPA_PARAM_Meta by intersecting the two ports' PODs+ * (spa_pod_filter). Producers declare SPA_PARAM_META_size as a FIXED+ * SPA_POD_Int, not a range — mutter 46.2 declares exactly+ * SPA_POD_Int(CURSOR_META_SIZE(384, 384)) = 589872 bytes+ * (src/backends/meta-screen-cast-stream-src.c). A consumer range that does not+ * CONTAIN that constant intersects to nothing, the whole ParamMeta object is+ * dropped, and the buffers simply arrive with no cursor metadata at all. There+ * is no error, no warning, and no clue: the stream negotiates and runs happily.+ *+ * This bit us. The original 256x256 ceiling (copied from PipeWire's own+ * video-play.c example, which targets cameras and never meets mutter) caps at+ * 262192 bytes — below mutter's 589872 — so every buffer came back with+ * hasCursorMeta=false. 1024x1024 = 4194352 bytes covers mutter's 384x384 and+ * leaves headroom for compositors with larger cursor planes; the range is only+ * an upper bound on what we accept, not an allocation we pay for.+ *+ * osc_pw_cursor_meta_accepts_producer_size() below turns this into something a+ * unit test can assert instead of something a maintainer rediscovers.+ */+#define OSC_CURSOR_META_SIZE(w, h) \+ (sizeof(struct spa_meta_cursor) + sizeof(struct spa_meta_bitmap) + (size_t)(w) * (h) * 4)++/*+ * How many buffers to describe before going quiet.+ *+ * One is not enough to answer the question this instrumentation exists for.+ * Metadata layout is fixed per buffer SET, so in theory one sample suffices —+ * but a single line cannot distinguish "the stream delivered one buffer and+ * died" from "the stream ran for a minute", and that ambiguity cost a debugging+ * round trip. A handful of lines makes stream liveness visible without turning+ * stdout into a firehose.+ */+#define OSC_BUFFER_INFO_REPORTS 5++/* Every libpipewire entry point the helper touches, resolved once by dlsym. */+struct osc_pw_api {+ void (*init)(int *argc, char ***argv);+ const char *(*get_library_version)(void);+ struct pw_thread_loop *(*thread_loop_new)(const char *name, const struct spa_dict *props);+ void (*thread_loop_destroy)(struct pw_thread_loop *loop);+ struct pw_loop *(*thread_loop_get_loop)(struct pw_thread_loop *loop);+ int (*thread_loop_start)(struct pw_thread_loop *loop);+ void (*thread_loop_stop)(struct pw_thread_loop *loop);+ void (*thread_loop_lock)(struct pw_thread_loop *loop);+ void (*thread_loop_unlock)(struct pw_thread_loop *loop);+ struct pw_context *(*context_new)(struct pw_loop *loop, struct pw_properties *props,+ size_t user_data_size);+ void (*context_destroy)(struct pw_context *context);+ struct pw_core *(*context_connect_fd)(struct pw_context *context, int fd,+ struct pw_properties *props, size_t user_data_size);+ int (*core_disconnect)(struct pw_core *core);+ struct pw_properties *(*properties_new)(const char *key, ...);+ struct pw_stream *(*stream_new)(struct pw_core *core, const char *name,+ struct pw_properties *props);+ void (*stream_destroy)(struct pw_stream *stream);+ void (*stream_add_listener)(struct pw_stream *stream, struct spa_hook *listener,+ const struct pw_stream_events *events, void *data);+ int (*stream_connect)(struct pw_stream *stream, enum pw_direction direction,+ uint32_t target_id, enum pw_stream_flags flags,+ const struct spa_pod **params, uint32_t n_params);+ int (*stream_disconnect)(struct pw_stream *stream);+ struct pw_buffer *(*stream_dequeue_buffer)(struct pw_stream *stream);+ int (*stream_queue_buffer)(struct pw_stream *stream, struct pw_buffer *buffer);+ int (*stream_update_params)(struct pw_stream *stream, const struct spa_pod **params,+ uint32_t n_params);+ const char *(*stream_state_as_string)(enum pw_stream_state state);+};++static struct osc_pw_api api;+static void *api_handle;++struct osc_pw_session {+ struct pw_thread_loop *loop;+ struct pw_context *context;+ struct pw_core *core;+ struct pw_stream *stream;+ struct spa_hook stream_listener;+ struct osc_pw_callbacks callbacks;+ struct spa_video_info_raw format;+ int buffer_info_reports;+};++static void osc_set_error(char *err, size_t err_len, const char *format, ...)+{+ va_list args;++ if (err == NULL || err_len == 0) {+ return;+ }+ va_start(args, format);+ vsnprintf(err, err_len, format, args);+ va_end(args);+}++int osc_pw_load(char *err, size_t err_len)+{+ if (api_handle != NULL) {+ return 0;+ }++ api_handle = dlopen(OSC_PW_SONAME, RTLD_NOW | RTLD_LOCAL);+ if (api_handle == NULL) {+ osc_set_error(err, err_len, "%s could not be loaded: %s", OSC_PW_SONAME, dlerror());+ return -1;+ }++/* The `*(void **)&field` dance is the POSIX-blessed way to assign a dlsym+ * result to a function pointer without tripping -Wpedantic. */+#define OSC_LOAD(field, symbol) \+ do { \+ *(void **)(&api.field) = dlsym(api_handle, symbol); \+ if (api.field == NULL) { \+ osc_set_error(err, err_len, "%s is missing symbol %s", OSC_PW_SONAME, \+ symbol); \+ dlclose(api_handle); \+ api_handle = NULL; \+ return -1; \+ } \+ } while (0)++ OSC_LOAD(init, "pw_init");+ OSC_LOAD(get_library_version, "pw_get_library_version");+ OSC_LOAD(thread_loop_new, "pw_thread_loop_new");+ OSC_LOAD(thread_loop_destroy, "pw_thread_loop_destroy");+ OSC_LOAD(thread_loop_get_loop, "pw_thread_loop_get_loop");+ OSC_LOAD(thread_loop_start, "pw_thread_loop_start");+ OSC_LOAD(thread_loop_stop, "pw_thread_loop_stop");+ OSC_LOAD(thread_loop_lock, "pw_thread_loop_lock");+ OSC_LOAD(thread_loop_unlock, "pw_thread_loop_unlock");+ OSC_LOAD(context_new, "pw_context_new");+ OSC_LOAD(context_destroy, "pw_context_destroy");+ OSC_LOAD(context_connect_fd, "pw_context_connect_fd");+ OSC_LOAD(core_disconnect, "pw_core_disconnect");+ OSC_LOAD(properties_new, "pw_properties_new");+ OSC_LOAD(stream_new, "pw_stream_new");+ OSC_LOAD(stream_destroy, "pw_stream_destroy");+ OSC_LOAD(stream_add_listener, "pw_stream_add_listener");+ OSC_LOAD(stream_connect, "pw_stream_connect");+ OSC_LOAD(stream_disconnect, "pw_stream_disconnect");+ OSC_LOAD(stream_dequeue_buffer, "pw_stream_dequeue_buffer");+ OSC_LOAD(stream_queue_buffer, "pw_stream_queue_buffer");+ OSC_LOAD(stream_update_params, "pw_stream_update_params");+ OSC_LOAD(stream_state_as_string, "pw_stream_state_as_string");++#undef OSC_LOAD++ api.init(NULL, NULL);+ return 0;+}++const char *osc_pw_library_version(void)+{+ return api_handle != NULL ? api.get_library_version() : NULL;+}++void osc_pw_constants(struct osc_pw_constants *out)+{+ out->video_format_rgbx = SPA_VIDEO_FORMAT_RGBx;+ out->video_format_bgrx = SPA_VIDEO_FORMAT_BGRx;+ out->video_format_xrgb = SPA_VIDEO_FORMAT_xRGB;+ out->video_format_xbgr = SPA_VIDEO_FORMAT_xBGR;+ out->video_format_rgba = SPA_VIDEO_FORMAT_RGBA;+ out->video_format_bgra = SPA_VIDEO_FORMAT_BGRA;+ out->video_format_argb = SPA_VIDEO_FORMAT_ARGB;+ out->video_format_abgr = SPA_VIDEO_FORMAT_ABGR;+ out->data_mem_ptr = SPA_DATA_MemPtr;+ out->data_mem_fd = SPA_DATA_MemFd;+ out->data_dma_buf = SPA_DATA_DmaBuf;+}++/*+ * Publish what we accept. The pixel format list is broad on purpose: Stage 1+ * never reads a pixel, and narrowing it would only make the compositor refuse+ * formats that Stage 2 may well want. What matters here is that the stream+ * negotiates at all, because SPA_META_Cursor rides on the video buffers.+ */+static const struct spa_pod *osc_build_enum_format(struct spa_pod_builder *builder)+{+ return spa_pod_builder_add_object(+ builder, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_FORMAT_mediaType,+ SPA_POD_Id(SPA_MEDIA_TYPE_video), SPA_FORMAT_mediaSubtype,+ SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw), SPA_FORMAT_VIDEO_format,+ /* SPA_POD_CHOICE_ENUM counts the DEFAULT plus the alternatives, and the+ * default is repeated as the first alternative. BGRx appearing twice is+ * the idiom, not a typo: 5 values = default BGRx + {BGRx,RGBx,BGRA,RGBA}. */+ SPA_POD_CHOICE_ENUM_Id(5, SPA_VIDEO_FORMAT_BGRx, SPA_VIDEO_FORMAT_BGRx,+ SPA_VIDEO_FORMAT_RGBx, SPA_VIDEO_FORMAT_BGRA,+ SPA_VIDEO_FORMAT_RGBA),+ SPA_FORMAT_VIDEO_size,+ SPA_POD_CHOICE_RANGE_Rectangle(&SPA_RECTANGLE(1920, 1080), &SPA_RECTANGLE(1, 1),+ &SPA_RECTANGLE(16384, 16384)),+ SPA_FORMAT_VIDEO_framerate,+ SPA_POD_CHOICE_RANGE_Fraction(&SPA_FRACTION(30, 1), &SPA_FRACTION(0, 1),+ &SPA_FRACTION(240, 1)));+}++/*+ * The consumer side of the SPA_META_Cursor negotiation, in one place so the+ * bytes a unit test checks are literally the bytes sent on the wire.+ */+static const struct spa_pod *osc_build_cursor_meta(struct spa_pod_builder *builder)+{+ return spa_pod_builder_add_object(+ builder, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_PARAM_META_type,+ SPA_POD_Id(SPA_META_Cursor), SPA_PARAM_META_size,+ SPA_POD_CHOICE_RANGE_Int((int32_t)OSC_CURSOR_META_SIZE(64, 64),+ (int32_t)OSC_CURSOR_META_SIZE(1, 1),+ (int32_t)OSC_CURSOR_META_SIZE(1024, 1024)));+}++int osc_pw_cursor_meta_accepts_producer_size(uint32_t width, uint32_t height)+{+ uint8_t ours_storage[512];+ uint8_t theirs_storage[512];+ uint8_t result_storage[512];+ struct spa_pod_builder ours = SPA_POD_BUILDER_INIT(ours_storage, sizeof(ours_storage));+ struct spa_pod_builder theirs = SPA_POD_BUILDER_INIT(theirs_storage, sizeof(theirs_storage));+ struct spa_pod_builder result = SPA_POD_BUILDER_INIT(result_storage, sizeof(result_storage));+ struct spa_pod *filtered = NULL;+ const struct spa_pod *consumer;+ const struct spa_pod *producer;++ consumer = osc_build_cursor_meta(&ours);+ /* Exactly how a compositor declares it: a FIXED size, not a range. */+ producer = spa_pod_builder_add_object(+ &theirs, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_PARAM_META_type,+ SPA_POD_Id(SPA_META_Cursor), SPA_PARAM_META_size,+ SPA_POD_Int((int32_t)OSC_CURSOR_META_SIZE(width, height)));+ if (consumer == NULL || producer == NULL) {+ return -1;+ }++ /* The same call pw_impl_link uses to intersect the two ports' params. A+ * negative result means the objects do not intersect, which is precisely the+ * failure mode that leaves buffers with no cursor metadata. */+ return spa_pod_filter(&result, &filtered, producer, consumer) < 0 ? 0 : 1;+}++static void osc_on_param_changed(void *userdata, uint32_t id, const struct spa_pod *param)+{+ struct osc_pw_session *session = userdata;+ uint8_t buffer[1024];+ struct spa_pod_builder builder = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));+ const struct spa_pod *params[3];+ struct osc_pw_format reported;+ uint32_t media_type;+ uint32_t media_subtype;++ if (param == NULL || id != SPA_PARAM_Format) {+ return;+ }+ if (spa_format_parse(param, &media_type, &media_subtype) < 0) {+ return;+ }+ if (media_type != SPA_MEDIA_TYPE_video || media_subtype != SPA_MEDIA_SUBTYPE_raw) {+ return;+ }+ if (spa_format_video_raw_parse(param, &session->format) < 0) {+ return;+ }+ reported.width = (int32_t)session->format.size.width;+ reported.height = (int32_t)session->format.size.height;+ reported.video_format = session->format.format;+ reported.framerate_num = (int32_t)session->format.framerate.num;+ reported.framerate_denom = (int32_t)session->format.framerate.denom;+ if (session->callbacks.on_format != NULL) {+ session->callbacks.on_format(session->callbacks.user, &reported);+ }++ /*+ * No `size`/`stride` constraint is published: Stage 1 does not map the+ * buffers (see the missing PW_STREAM_FLAG_MAP_BUFFERS in osc_pw_start), so+ * the compositor's own choice is fine. Every dataType is advertised so that+ * the value reported by on_buffer_info reflects what the compositor would+ * prefer, not what we forced it into.+ */+ params[0] = spa_pod_builder_add_object(+ &builder, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers, SPA_PARAM_BUFFERS_buffers,+ SPA_POD_CHOICE_RANGE_Int(4, 2, 16), SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(1),+ SPA_PARAM_BUFFERS_dataType,+ SPA_POD_CHOICE_FLAGS_Int((1 << SPA_DATA_MemPtr) | (1 << SPA_DATA_MemFd) |+ (1 << SPA_DATA_DmaBuf)));++ params[1] = spa_pod_builder_add_object(+ &builder, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_PARAM_META_type,+ SPA_POD_Id(SPA_META_Header), SPA_PARAM_META_size,+ SPA_POD_Int(sizeof(struct spa_meta_header)));++ params[2] = osc_build_cursor_meta(&builder);++ /* The builder returns NULL if its fixed buffer overflowed. 1 KiB is far more+ * than these three objects need, but handing NULLs to update_params would be+ * a null deref inside libpipewire, so it is checked rather than assumed. */+ if (params[0] == NULL || params[1] == NULL || params[2] == NULL) {+ return;+ }++ /* Buffers are reallocated on renegotiation, and the metadata layout comes+ * with them. Re-arm the reports so the instrumentation describes the buffer+ * set actually in use rather than a set that no longer exists. */+ session->buffer_info_reports = 0;++ api.stream_update_params(session->stream, params, 3);+}++static void osc_on_state_changed(void *userdata, enum pw_stream_state old,+ enum pw_stream_state state, const char *error)+{+ struct osc_pw_session *session = userdata;++ (void)old;+ if (session->callbacks.on_state != NULL) {+ session->callbacks.on_state(session->callbacks.user, api.stream_state_as_string(state),+ error);+ }+}++/*+ * Extract the cursor metadata, or return 0 if this buffer has none.+ *+ * This uses spa_buffer_find_meta rather than the more usual+ * spa_buffer_find_meta_data because the latter returns only the pointer and+ * throws away `spa_meta::size`. That size is the sole bound available for+ * validating the bitmap offsets below, so it has to be kept. The size check+ * find_meta_data would have performed is done explicitly instead.+ *+ * Every offset in `spa_meta_cursor` is attacker-controlled from this process's+ * point of view (it comes from another process's shared memory), so each one is+ * validated against the metadata block's declared size before it is followed.+ * The arithmetic is done in uint64_t so that a hostile 32-bit offset cannot+ * wrap past the bound.+ */+static int osc_read_cursor(const struct spa_buffer *buffer, struct osc_pw_cursor *out,+ uint32_t *meta_size_out)+{+ struct spa_meta *meta;+ struct spa_meta_cursor *cursor;+ struct spa_meta_bitmap *bitmap;+ uint64_t meta_size;+ uint64_t bitmap_offset;+ uint64_t pixels_offset;+ uint64_t pixels_len;++ memset(out, 0, sizeof(*out));++ meta = spa_buffer_find_meta(buffer, SPA_META_Cursor);+ if (meta == NULL) {+ return 0;+ }+ *meta_size_out = meta->size;+ meta_size = meta->size;+ if (meta_size < sizeof(struct spa_meta_cursor) || meta->data == NULL) {+ return 0;+ }++ cursor = meta->data;+ if (!spa_meta_cursor_is_valid(cursor)) {+ /* id == 0 means "nothing new"; the previous position still stands. */+ return 0;+ }++ out->id = cursor->id;+ out->flags = cursor->flags;+ out->x = cursor->position.x;+ out->y = cursor->position.y;+ out->hotspot_x = cursor->hotspot.x;+ out->hotspot_y = cursor->hotspot.y;++ bitmap_offset = cursor->bitmap_offset;+ if (bitmap_offset < sizeof(struct spa_meta_cursor) ||+ bitmap_offset + sizeof(struct spa_meta_bitmap) > meta_size) {+ return 1;+ }++ bitmap = SPA_PTROFF(cursor, (size_t)bitmap_offset, struct spa_meta_bitmap);+ if (!spa_meta_bitmap_is_valid(bitmap)) {+ return 1;+ }+ if (bitmap->stride <= 0 || bitmap->size.width == 0 || bitmap->size.height == 0) {+ return 1;+ }++ pixels_offset = bitmap_offset + bitmap->offset;+ if (bitmap->offset < sizeof(struct spa_meta_bitmap) || pixels_offset >= meta_size) {+ return 1;+ }+ pixels_len = (uint64_t)bitmap->stride * (uint64_t)bitmap->size.height;+ if (pixels_len == 0 || pixels_len > meta_size - pixels_offset) {+ return 1;+ }++ out->has_bitmap = 1;+ out->bitmap_format = bitmap->format;+ out->bitmap_width = (int32_t)bitmap->size.width;+ out->bitmap_height = (int32_t)bitmap->size.height;+ out->bitmap_stride = bitmap->stride;+ out->bitmap_data = SPA_PTROFF(cursor, (size_t)pixels_offset, const uint8_t);+ out->bitmap_len = (size_t)pixels_len;+ return 1;+}++static const char *osc_meta_type_name(uint32_t type)+{+ switch (type) {+ case SPA_META_Header:+ return "Header";+ case SPA_META_VideoCrop:+ return "VideoCrop";+ case SPA_META_VideoDamage:+ return "VideoDamage";+ case SPA_META_Bitmap:+ return "Bitmap";+ case SPA_META_Cursor:+ return "Cursor";+ case SPA_META_Control:+ return "Control";+ case SPA_META_Busy:+ return "Busy";+ case SPA_META_VideoTransform:+ return "VideoTransform";+ default:+ return "?";+ }+}++/*+ * "Header:12,Cursor:589872" — every metadata block the negotiation actually+ * produced, with its size.+ *+ * This exists because a missing SPA_META_Cursor used to be reported as a bare+ * `hasCursorMeta: false`, which cannot distinguish "our ParamMeta never reached+ * the negotiation" from "it reached it and was filtered out on size". Listing+ * the survivors answers that in one line: if Header is present and Cursor is+ * not, the params were sent and the cursor object lost the intersection.+ */+static void osc_describe_metas(const struct spa_buffer *buffer, char *out, size_t out_len)+{+ size_t used = 0;+ uint32_t i;++ if (out_len == 0) {+ return;+ }+ out[0] = '\0';+ for (i = 0; i < buffer->n_metas; i++) {+ int written = snprintf(out + used, out_len - used, "%s%s:%u", used > 0 ? "," : "",+ osc_meta_type_name(buffer->metas[i].type), buffer->metas[i].size);+ if (written < 0 || (size_t)written >= out_len - used) {+ /* Truncated: leave what fits, NUL-terminated by snprintf. */+ return;+ }+ used += (size_t)written;+ }+}++static void osc_inspect_buffer(struct osc_pw_session *session, const struct spa_buffer *buffer)+{+ struct osc_pw_cursor cursor;+ uint32_t meta_size = 0;++ if (session->buffer_info_reports < OSC_BUFFER_INFO_REPORTS &&+ session->callbacks.on_buffer_info != NULL) {+ uint32_t data_type = buffer->n_datas > 0 ? buffer->datas[0].type : 0;+ struct spa_meta *cursor_meta = spa_buffer_find_meta(buffer, SPA_META_Cursor);+ char metas[256];++ osc_describe_metas(buffer, metas, sizeof(metas));+ session->buffer_info_reports++;+ session->callbacks.on_buffer_info(session->callbacks.user, data_type, buffer->n_datas,+ cursor_meta != NULL,+ cursor_meta != NULL ? cursor_meta->size : 0, metas);+ }++ if (osc_read_cursor(buffer, &cursor, &meta_size) && session->callbacks.on_cursor != NULL) {+ session->callbacks.on_cursor(session->callbacks.user, &cursor);+ }+}++static void osc_on_process(void *userdata)+{+ struct osc_pw_session *session = userdata;+ struct pw_buffer *b;++ /*+ * EVERY dequeued buffer is inspected, in arrival order.+ *+ * The obvious optimisation — drain to the newest buffer and drop the rest —+ * is wrong here, and was the code this replaced. Cursor updates are not+ * guaranteed to be attached to buffers that also carry a video frame: a+ * compositor may deliver a buffer whose chunk size is 0 purely to ship a new+ * SPA_META_Cursor (KWin is documented as doing this). Dropping "stale"+ * buffers would silently throw those away, which is indistinguishable from+ * the cursor never moving.+ *+ * Reading metadata is a handful of struct field loads, so doing it per+ * buffer costs nothing, and nothing here touches the pixel data — there is+ * no reason to skip a buffer on the grounds that its frame is old.+ */+ while ((b = api.stream_dequeue_buffer(session->stream)) != NULL) {+ osc_inspect_buffer(session, b->buffer);+ api.stream_queue_buffer(session->stream, b);+ }+}++static const struct pw_stream_events osc_stream_events = {+ PW_VERSION_STREAM_EVENTS,+ .state_changed = osc_on_state_changed,+ .param_changed = osc_on_param_changed,+ .process = osc_on_process,+};++struct osc_pw_session *osc_pw_start(int fd, uint32_t node_id,+ const struct osc_pw_callbacks *callbacks, char *err,+ size_t err_len)+{+ struct osc_pw_session *session;+ uint8_t buffer[1024];+ struct spa_pod_builder builder = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));+ const struct spa_pod *params[1];+ int result;++ if (api_handle == NULL) {+ osc_set_error(err, err_len, "osc_pw_start called before osc_pw_load");+ close(fd);+ return NULL;+ }++ session = calloc(1, sizeof(*session));+ if (session == NULL) {+ osc_set_error(err, err_len, "out of memory");+ close(fd);+ return NULL;+ }+ session->callbacks = *callbacks;++ session->loop = api.thread_loop_new("openscreen-pipewire", NULL);+ if (session->loop == NULL) {+ osc_set_error(err, err_len, "pw_thread_loop_new failed");+ close(fd);+ free(session);+ return NULL;+ }++ /*+ * Everything below runs with the loop lock held. The loop is not started+ * yet, so nothing can race us, but taking the lock keeps the teardown path+ * (which does run concurrently) symmetric with the setup path.+ */+ api.thread_loop_lock(session->loop);++ session->context = api.context_new(api.thread_loop_get_loop(session->loop), NULL, 0);+ if (session->context == NULL) {+ osc_set_error(err, err_len, "pw_context_new failed");+ close(fd);+ goto fail;+ }++ /* Takes ownership of fd, on success and on failure alike. */+ session->core = api.context_connect_fd(session->context, fd, NULL, 0);+ if (session->core == NULL) {+ osc_set_error(err, err_len, "pw_context_connect_fd failed: %s", strerror(errno));+ goto fail;+ }++ session->stream = api.stream_new(session->core, "openscreen-cursor",+ api.properties_new(PW_KEY_MEDIA_TYPE, "Video",+ PW_KEY_MEDIA_CATEGORY, "Capture",+ PW_KEY_MEDIA_ROLE, "Screen", NULL));+ if (session->stream == NULL) {+ osc_set_error(err, err_len, "pw_stream_new failed");+ goto fail;+ }++ api.stream_add_listener(session->stream, &session->stream_listener, &osc_stream_events,+ session);++ params[0] = osc_build_enum_format(&builder);+ if (params[0] == NULL) {+ osc_set_error(err, err_len, "the EnumFormat POD did not fit its builder");+ goto fail;+ }++ /*+ * Flags, and the two that are absent on purpose:+ *+ * No PW_STREAM_FLAG_MAP_BUFFERS: Stage 1 reads metadata only, and mapping a+ * full-screen framebuffer on every buffer would be pure waste. Stage 2 adds+ * it when it starts consuming pixels. Metadata is unaffected — pw_stream maps+ * the buffer skeleton (and therefore every spa_meta) regardless of this flag;+ * MAP_BUFFERS only governs whether `datas[i].data` is populated.+ *+ * No PW_STREAM_FLAG_DONT_RECONNECT, which this code used to set. That flag+ * killed the first real GNOME run, and the chain is worth writing down+ * because the symptom names nothing that appears in our source:+ *+ * 1. pw_stream turns the flag into the node property `node.dont-reconnect`+ * (pipewire 1.0.5 src/pipewire/stream.c:2020).+ * 2. WirePlumber reads it as `reconnect = not node.dont-reconnect`+ * (/usr/share/wireplumber/scripts/policy-node.lua:653).+ * 3. When the session manager cannot resolve a target, the `not reconnect`+ * branch reports the error string "target not found" — the exact text we+ * saw — where the reconnecting branch would merely say "no target node+ * available" and wait (policy-node.lua:807).+ * 4. That same branch then DESTROYS the node (policy-node.lua:812), so the+ * stream is gone for good rather than re-linking.+ *+ * In other words the flag converts a transient link failure into a silent,+ * permanent end of capture. OBS's linux-pipewire plugin — the reference+ * implementation that works on GNOME — does not set it either.+ *+ * `node_id` is passed as the connect target rather than through+ * PW_KEY_TARGET_OBJECT. That is the older of the two spellings, but it is what+ * OBS does and it is verified working here (see the ignored integration test,+ * which connects by numeric id and reaches `streaming`).+ */+ result = api.stream_connect(session->stream, PW_DIRECTION_INPUT, node_id,+ PW_STREAM_FLAG_AUTOCONNECT, params, 1);+ if (result < 0) {+ osc_set_error(err, err_len, "pw_stream_connect failed: %s", spa_strerror(result));+ goto fail;+ }++ api.thread_loop_unlock(session->loop);++ if (api.thread_loop_start(session->loop) < 0) {+ osc_set_error(err, err_len, "pw_thread_loop_start failed");+ api.thread_loop_lock(session->loop);+ goto fail;+ }++ return session;++fail:+ api.thread_loop_unlock(session->loop);+ if (session->stream != NULL) {+ api.stream_destroy(session->stream);+ }+ if (session->core != NULL) {+ api.core_disconnect(session->core);+ }+ if (session->context != NULL) {+ api.context_destroy(session->context);+ }+ api.thread_loop_destroy(session->loop);+ free(session);+ return NULL;+}++void osc_pw_stop(struct osc_pw_session *session)+{+ if (session == NULL) {+ return;+ }++ /* pw_thread_loop_stop must be called WITHOUT the lock: it joins the thread. */+ api.thread_loop_stop(session->loop);++ if (session->stream != NULL) {+ api.stream_disconnect(session->stream);+ api.stream_destroy(session->stream);+ }+ if (session->core != NULL) {+ api.core_disconnect(session->core);+ }+ if (session->context != NULL) {+ api.context_destroy(session->context);+ }+ api.thread_loop_destroy(session->loop);+ free(session);+}diff --git a/electron/native/pipewire-capture/csrc/pw_shim.h b/electron/native/pipewire-capture/csrc/pw_shim.hnew file mode 100644index 000000000..666119788--- /dev/null+++ b/electron/native/pipewire-capture/csrc/pw_shim.h@@ -0,0 +1,142 @@+/*+ * Flat C ABI between the Rust helper and libpipewire.+ *+ * Every declaration here is mirrored by hand in `src/shim.rs`. The two files+ * are a matched pair: changing a struct on one side without the other is an ABI+ * break the compiler cannot catch, so keep the field order and the integer+ * widths identical.+ *+ * Only plain scalars and pointers cross this boundary — no SPA or PipeWire type+ * appears in a signature — so Rust never has to restate a PipeWire struct+ * layout. That is deliberate: the layouts live in the vendored headers and are+ * consumed by the C compiler that also compiled libpipewire's own users.+ */++#ifndef OPENSCREEN_PW_SHIM_H+#define OPENSCREEN_PW_SHIM_H++#include <stddef.h>+#include <stdint.h>++#ifdef __cplusplus+extern "C" {+#endif++/* One SPA_META_Cursor observation, already bounds-checked by the shim. */+struct osc_pw_cursor {+ /* Cursor position in stream pixels, top-left origin of the captured region. */+ int32_t x;+ int32_t y;+ /* Hotspot inside the bitmap. Meaningless when `has_bitmap` is 0. */+ int32_t hotspot_x;+ int32_t hotspot_y;+ /* Compositor-assigned shape id. 0 means "no cursor data in this frame". */+ uint32_t id;+ uint32_t flags;+ /* 1 when this frame carried a new shape bitmap. Compositors only send one+ * when the shape changes, so most frames have has_bitmap == 0. */+ int32_t has_bitmap;+ uint32_t bitmap_format; /* enum spa_video_format */+ int32_t bitmap_width;+ int32_t bitmap_height;+ int32_t bitmap_stride;+ /* Borrowed for the duration of the callback only. Copy before returning. */+ const uint8_t *bitmap_data;+ size_t bitmap_len;+};++/* The negotiated video format. Reported once, from param_changed. */+struct osc_pw_format {+ int32_t width;+ int32_t height;+ uint32_t video_format; /* enum spa_video_format */+ int32_t framerate_num;+ int32_t framerate_denom;+};++/*+ * Callbacks fire on the PipeWire thread, never on the caller's thread. They+ * must not block: the Rust side only pushes onto an unbounded channel.+ */+struct osc_pw_callbacks {+ void *user;+ void (*on_format)(void *user, const struct osc_pw_format *format);+ void (*on_cursor)(void *user, const struct osc_pw_cursor *cursor);+ /* Emitted once per negotiated buffer set. `data_type` is the SPA_DATA_* of+ * datas[0]; `metas` is a borrowed "Header:12,Cursor:589872" listing of every+ * metadata block that survived negotiation, which is what distinguishes a+ * ParamMeta that was never sent from one that lost the size intersection. */+ void (*on_buffer_info)(void *user, uint32_t data_type, uint32_t n_datas,+ int32_t has_cursor_meta, uint32_t cursor_meta_size,+ const char *metas);+ void (*on_state)(void *user, const char *state, const char *error);+};++/*+ * SPA enum values, read out of the vendored headers rather than restated in+ * Rust. Hardcoding `SPA_VIDEO_FORMAT_BGRA == 12` on the Rust side would work+ * today and rot silently the day upstream inserts a value; this cannot.+ */+struct osc_pw_constants {+ uint32_t video_format_rgbx;+ uint32_t video_format_bgrx;+ uint32_t video_format_xrgb;+ uint32_t video_format_xbgr;+ uint32_t video_format_rgba;+ uint32_t video_format_bgra;+ uint32_t video_format_argb;+ uint32_t video_format_abgr;+ uint32_t data_mem_ptr;+ uint32_t data_mem_fd;+ uint32_t data_dma_buf;+};++void osc_pw_constants(struct osc_pw_constants *out);++/*+ * Would our SPA_META_Cursor declaration survive negotiation against a producer+ * that declares a FIXED size of `width` x `height` pixels? 1 yes, 0 no, -1 if+ * the PODs could not be built.+ *+ * Compositors declare that size as a constant (mutter 46.2: 384x384), so our+ * accepted range has to contain it or the metadata is silently dropped from the+ * buffers. Exposed so a unit test can assert the bound without a portal, a+ * compositor, or a screen.+ */+int osc_pw_cursor_meta_accepts_producer_size(uint32_t width, uint32_t height);++struct osc_pw_session;++/*+ * dlopen("libpipewire-0.3.so.0") and resolve every symbol used below. Returns 0+ * on success, -1 with a NUL-terminated message in `err` otherwise. Idempotent.+ */+int osc_pw_load(char *err, size_t err_len);++/* Runtime library version string, or NULL before a successful osc_pw_load. */+const char *osc_pw_library_version(void);++/*+ * Connect to the PipeWire remote behind `fd` (from the portal's+ * OpenPipeWireRemote) and start consuming `node_id`.+ *+ * Takes ownership of `fd`: once handed to pw_context_connect_fd, libpipewire's+ * loop owns and closes it. Failures before that point close it here. In the one+ * narrow case where pw_context_connect_fd itself fails, upstream may or may not+ * have taken it, so it is deliberately leaked rather than risking a double+ * close — the caller is on its way to reporting a fatal error either way.+ *+ * Returns NULL on failure, with a message in `err`.+ */+struct osc_pw_session *osc_pw_start(int fd, uint32_t node_id,+ const struct osc_pw_callbacks *callbacks, char *err,+ size_t err_len);++/* Stops the thread loop, joins it, and frees everything. Safe with NULL. */+void osc_pw_stop(struct osc_pw_session *session);++#ifdef __cplusplus+}+#endif++#endif /* OPENSCREEN_PW_SHIM_H */diff --git a/electron/native/pipewire-capture/src/bitmap.rs b/electron/native/pipewire-capture/src/bitmap.rsnew file mode 100644index 000000000..ea8a10791--- /dev/null+++ b/electron/native/pipewire-capture/src/bitmap.rs@@ -0,0 +1,287 @@+//! SPA cursor bitmap → PNG data URL.+//!+//! The renderer consumes `NativeCursorAsset.imageDataUrl` (see+//! src/native/contracts.ts) exactly as the macOS helper produces it: a base64+//! `data:image/png` string, keyed by the SHA-256 of the PNG bytes so the same+//! shape is only ever serialised once.+//!+//! UNVERIFIED: Wayland cursor buffers are conventionally PREMULTIPLIED alpha,+//! and PNG expects straight alpha. No sprite has been observed on real hardware+//! yet (Stage 1's `debug` instrumentation exists to find out whether GNOME even+//! sends one), so the channels are copied through unchanged rather than+//! un-premultiplied on a guess. If sprites come back with dark fringes on their+//! antialiased edges, that is the bug, and the fix belongs here.++use base64::Engine;+use sha2::{Digest, Sha256};++use crate::shim::{Constants, CursorBitmap};++/// Refuse anything larger. Kept in step with the cursor metadata ceiling+/// negotiated in pw_shim.c (OSC_CURSOR_META_SIZE(1024, 1024)): a bitmap bigger+/// than the block we agreed to accept means the producer and this process+/// disagree about the buffer. For reference, mutter's own plane is 384×384 and+/// a real GNOME cursor is 24–96 px.+const MAX_DIMENSION: u32 = 1024;++#[derive(Debug, PartialEq, Eq)]+pub struct EncodedCursor {+ pub id: String,+ pub image_data_url: String,+ pub width: u32,+ pub height: u32,+}++/// Byte offsets of R, G, B, A within one source pixel, or `None` when the+/// format is not a 32-bit packed one we understand.+fn channel_order(constants: &Constants, format: u32) -> Option<[usize; 4]> {+ // Written as a lookup against the values the C shim read out of the+ // vendored headers, never against hardcoded enum numbers.+ let table = [+ (constants.video_format_rgbx, [0, 1, 2, 3]),+ (constants.video_format_bgrx, [2, 1, 0, 3]),+ (constants.video_format_xrgb, [1, 2, 3, 0]),+ (constants.video_format_xbgr, [3, 2, 1, 0]),+ (constants.video_format_rgba, [0, 1, 2, 3]),+ (constants.video_format_bgra, [2, 1, 0, 3]),+ (constants.video_format_argb, [1, 2, 3, 0]),+ (constants.video_format_abgr, [3, 2, 1, 0]),+ ];+ table+ .iter()+ .find(|(id, _)| *id == format)+ .map(|(_, order)| *order)+}++/// True when the format has no alpha channel, so the 4th byte is padding and+/// must be replaced by opaque rather than copied.+fn is_opaque(constants: &Constants, format: u32) -> bool {+ format == constants.video_format_rgbx+ || format == constants.video_format_bgrx+ || format == constants.video_format_xrgb+ || format == constants.video_format_xbgr+}++pub fn encode(constants: &Constants, bitmap: &CursorBitmap) -> Result<EncodedCursor, String> {+ if bitmap.width <= 0 || bitmap.height <= 0 {+ return Err(format!(+ "cursor bitmap has a non-positive size ({}x{})",+ bitmap.width, bitmap.height+ ));+ }+ let width = bitmap.width as u32;+ let height = bitmap.height as u32;+ if width > MAX_DIMENSION || height > MAX_DIMENSION {+ return Err(format!("cursor bitmap is implausibly large ({width}x{height})"));+ }++ let order = channel_order(constants, bitmap.format)+ .ok_or_else(|| format!("unsupported cursor bitmap format id {}", bitmap.format))?;+ let opaque = is_opaque(constants, bitmap.format);++ let stride = usize::try_from(bitmap.stride).map_err(|_| "negative stride".to_owned())?;+ let row_bytes = width as usize * 4;+ if stride < row_bytes {+ return Err(format!("stride {stride} is shorter than one {width}px row"));+ }+ // The C side already bounds-checked this against the metadata block; repeat+ // it here so the slicing below cannot panic even if that ever regresses.+ let needed = stride+ .checked_mul(height as usize)+ .ok_or_else(|| "cursor bitmap size overflows".to_owned())?;+ if bitmap.pixels.len() < needed {+ return Err(format!(+ "cursor bitmap is truncated: {} bytes for {}x{} at stride {}",+ bitmap.pixels.len(),+ width,+ height,+ stride+ ));+ }++ let mut rgba = Vec::with_capacity(row_bytes * height as usize);+ for row in 0..height as usize {+ let line = &bitmap.pixels[row * stride..row * stride + row_bytes];+ for pixel in line.chunks_exact(4) {+ rgba.push(pixel[order[0]]);+ rgba.push(pixel[order[1]]);+ rgba.push(pixel[order[2]]);+ rgba.push(if opaque { 0xff } else { pixel[order[3]] });+ }+ }++ let png = encode_png(width, height, &rgba)?;+ let id = Sha256::digest(&png)+ .iter()+ .map(|byte| format!("{byte:02x}"))+ .collect::<String>();+ let image_data_url = format!(+ "data:image/png;base64,{}",+ base64::engine::general_purpose::STANDARD.encode(&png)+ );++ Ok(EncodedCursor {+ id,+ image_data_url,+ width,+ height,+ })+}++fn encode_png(width: u32, height: u32, rgba: &[u8]) -> Result<Vec<u8>, String> {+ let mut png = Vec::new();+ {+ let mut encoder = png::Encoder::new(&mut png, width, height);+ encoder.set_color(png::ColorType::Rgba);+ encoder.set_depth(png::BitDepth::Eight);+ let mut writer = encoder+ .write_header()+ .map_err(|error| format!("png header: {error}"))?;+ writer+ .write_image_data(rgba)+ .map_err(|error| format!("png data: {error}"))?;+ }+ Ok(png)+}++#[cfg(test)]+mod tests {+ use super::*;++ fn constants() -> Constants {+ // Read from the compiled C shim, so the test also proves the Rust view+ // of the SPA enum matches the vendored headers.+ crate::shim::constants()+ }++ fn bitmap(format: u32, width: i32, height: i32, stride: i32, pixels: Vec<u8>) -> CursorBitmap {+ CursorBitmap {+ format,+ width,+ height,+ stride,+ pixels,+ }+ }++ fn decode(data_url: &str) -> (png::OutputInfo, Vec<u8>) {+ let base64 = data_url+ .strip_prefix("data:image/png;base64,")+ .expect("data url prefix");+ let bytes = base64::engine::general_purpose::STANDARD+ .decode(base64)+ .expect("base64");+ let decoder = png::Decoder::new(std::io::Cursor::new(bytes));+ let mut reader = decoder.read_info().expect("png info");+ let mut buffer = vec![0; reader.output_buffer_size()];+ let info = reader.next_frame(&mut buffer).expect("png frame");+ buffer.truncate(info.buffer_size());+ (info, buffer)+ }++ #[test]+ fn spa_format_ids_are_distinct() {+ // Guards against the constants struct being mis-ordered between C and Rust:+ // a field-order mismatch would collapse several of these onto one value.+ let c = constants();+ let ids = [+ c.video_format_rgbx,+ c.video_format_bgrx,+ c.video_format_xrgb,+ c.video_format_xbgr,+ c.video_format_rgba,+ c.video_format_bgra,+ c.video_format_argb,+ c.video_format_abgr,+ ];+ let mut sorted = ids.to_vec();+ sorted.sort_unstable();+ sorted.dedup();+ assert_eq!(sorted.len(), ids.len(), "duplicate SPA video format ids: {ids:?}");+ assert_ne!(c.data_mem_ptr, c.data_dma_buf);+ }++ #[test]+ fn bgra_channels_are_reordered_to_rgba() {+ let c = constants();+ // One pixel: B=1, G=2, R=3, A=4.+ let encoded = encode(&c, &bitmap(c.video_format_bgra, 1, 1, 4, vec![1, 2, 3, 4]))+ .expect("encode");+ let (info, pixels) = decode(&encoded.image_data_url);+ assert_eq!((info.width, info.height), (1, 1));+ assert_eq!(&pixels[..4], &[3, 2, 1, 4]);+ }++ #[test]+ fn argb_channels_are_reordered_to_rgba() {+ let c = constants();+ // One pixel: A=9, R=1, G=2, B=3.+ let encoded = encode(&c, &bitmap(c.video_format_argb, 1, 1, 4, vec![9, 1, 2, 3]))+ .expect("encode");+ let (_, pixels) = decode(&encoded.image_data_url);+ assert_eq!(&pixels[..4], &[1, 2, 3, 9]);+ }++ #[test]+ fn padding_byte_becomes_opaque_for_formats_without_alpha() {+ let c = constants();+ let encoded = encode(&c, &bitmap(c.video_format_bgrx, 1, 1, 4, vec![1, 2, 3, 0]))+ .expect("encode");+ let (_, pixels) = decode(&encoded.image_data_url);+ assert_eq!(&pixels[..4], &[3, 2, 1, 0xff]);+ }++ #[test]+ fn row_padding_is_skipped() {+ let c = constants();+ // 1px wide, 2 rows, stride 8: bytes 4..8 and 12..16 are padding.+ let pixels = vec![1, 2, 3, 4, 0xaa, 0xaa, 0xaa, 0xaa, 5, 6, 7, 8, 0xbb, 0xbb, 0xbb, 0xbb];+ let encoded =+ encode(&c, &bitmap(c.video_format_bgra, 1, 2, 8, pixels)).expect("encode");+ let (_, decoded) = decode(&encoded.image_data_url);+ assert_eq!(&decoded[..8], &[3, 2, 1, 4, 7, 6, 5, 8]);+ }++ #[test]+ fn identical_bitmaps_hash_to_the_same_asset_id() {+ let c = constants();+ let first = encode(&c, &bitmap(c.video_format_bgra, 1, 1, 4, vec![1, 2, 3, 4])).unwrap();+ let second = encode(&c, &bitmap(c.video_format_bgra, 1, 1, 4, vec![1, 2, 3, 4])).unwrap();+ let other = encode(&c, &bitmap(c.video_format_bgra, 1, 1, 4, vec![9, 9, 9, 9])).unwrap();+ assert_eq!(first.id, second.id);+ assert_ne!(first.id, other.id);+ assert_eq!(first.id.len(), 64, "sha-256 hex, like the macOS helper");+ }++ #[test]+ fn truncated_buffers_are_rejected_rather_than_sliced() {+ let c = constants();+ let error = encode(&c, &bitmap(c.video_format_bgra, 4, 4, 16, vec![0; 16]))+ .expect_err("must reject");+ assert!(error.contains("truncated"), "{error}");+ }++ #[test]+ fn short_stride_is_rejected() {+ let c = constants();+ let error = encode(&c, &bitmap(c.video_format_bgra, 4, 1, 8, vec![0; 64]))+ .expect_err("must reject");+ assert!(error.contains("shorter"), "{error}");+ }++ #[test]+ fn implausible_dimensions_are_rejected() {+ let c = constants();+ let error = encode(&c, &bitmap(c.video_format_bgra, 4096, 1, 16384, vec![0; 16384]))+ .expect_err("must reject");+ assert!(error.contains("implausibly large"), "{error}");+ }++ #[test]+ fn unknown_formats_are_reported_not_guessed() {+ let c = constants();+ let error =+ encode(&c, &bitmap(u32::MAX, 1, 1, 4, vec![0; 4])).expect_err("must reject");+ assert!(error.contains("unsupported"), "{error}");+ }+}diff --git a/electron/native/pipewire-capture/src/events.rs b/electron/native/pipewire-capture/src/events.rsnew file mode 100644index 000000000..4969199e5--- /dev/null+++ b/electron/native/pipewire-capture/src/events.rs@@ -0,0 +1,304 @@+//! NDJSON protocol spoken on stdout: one JSON object per line, flushed per+//! line, every object carrying `event` and `schemaVersion`.+//!+//! The vocabulary is the ScreenCaptureKit helper's (`ready` / `warning` /+//! `error`, see electron/native/screencapturekit/…/main.swift) plus what this+//! helper needs on top:+//!+//! * `stream-started` — the portal dialog is done and PipeWire is streaming.+//! It is separate from `ready` on purpose. `ready` fires in milliseconds,+//! before the portal picker is raised; `stream-started` cannot fire until+//! the user has clicked through a dialog, which has no upper bound. The+//! Electron session resolves `start()` on `ready` so its readiness timeout+//! does not have to accommodate a human.+//! * `cursor-sample` — one cursor observation.+//! * `debug` — the Stage 1 instrumentation, gated on OPENSCREEN_PIPEWIRE_DEBUG.++use std::io::{self, Write};++use serde::Serialize;++pub const SCHEMA_VERSION: u32 = 1;++/// The cursor sprite, sent once per distinct shape. Field names match+/// `NativeCursorAsset` in src/native/contracts.ts, minus `platform`, which the+/// Electron side fills in.+#[derive(Debug, Clone, Serialize, PartialEq)]+#[serde(rename_all = "camelCase")]+pub struct CursorAsset {+ pub id: String,+ pub image_data_url: String,+ pub width: u32,+ pub height: u32,+ pub hotspot_x: i32,+ pub hotspot_y: i32,+}++#[derive(Debug, Clone, Serialize, PartialEq)]+#[serde(tag = "event", rename_all = "kebab-case")]+pub enum Event {+ #[serde(rename_all = "camelCase")]+ Ready {+ timestamp_ms: u64,+ /// Runtime libpipewire version, not the vendored header version.+ pipewire_version: Option<String>,+ /// Whether the portal advertises METADATA cursor mode at all.+ cursor_metadata_supported: bool,+ },+ #[serde(rename_all = "camelCase")]+ StreamStarted {+ timestamp_ms: u64,+ node_id: u32,+ width: i32,+ height: i32,+ /// Position of the captured region in the compositor's coordinate+ /// space, when the portal reports one (monitor streams only).+ position_x: Option<i32>,+ position_y: Option<i32>,+ restore_token: Option<String>,+ },+ /// Cursor position in stream pixels. `width`/`height` repeat on every+ /// sample so a consumer never has to correlate with an earlier event to+ /// normalise, and so a mid-stream resolution change cannot desynchronise it.+ #[serde(rename_all = "camelCase")]+ CursorSample {+ timestamp_ms: u64,+ x: i32,+ y: i32,+ width: i32,+ height: i32,+ visible: bool,+ #[serde(skip_serializing_if = "Option::is_none")]+ asset_id: Option<String>,+ #[serde(skip_serializing_if = "Option::is_none")]+ asset: Option<CursorAsset>,+ },+ #[serde(rename_all = "camelCase")]+ Warning { code: String, message: String },+ #[serde(rename_all = "camelCase")]+ Error { code: String, message: String },+ /// Stage 1 instrumentation. `data` is free-form on purpose: these are+ /// answers to open questions, not a contract anything parses.+ #[serde(rename_all = "camelCase")]+ Debug {+ code: String,+ #[serde(flatten)]+ data: serde_json::Map<String, serde_json::Value>,+ },+}++/// Writes events as NDJSON. Generic over the sink so the framing can be tested+/// without a process.+pub struct Emitter<W: Write> {+ out: W,+ debug: bool,+}++impl<W: Write> Emitter<W> {+ pub fn new(out: W, debug: bool) -> Self {+ Self { out, debug }+ }++ /// `debug` events are dropped unless OPENSCREEN_PIPEWIRE_DEBUG was set.+ pub fn emit(&mut self, event: &Event) -> io::Result<()> {+ if matches!(event, Event::Debug { .. }) && !self.debug {+ return Ok(());+ }++ // Round-tripping through Value is what lets `schemaVersion` be added in+ // one place instead of being restated in every variant.+ let mut value = serde_json::to_value(event).expect("event serialisation is infallible");+ if let Some(object) = value.as_object_mut() {+ object.insert("schemaVersion".to_owned(), SCHEMA_VERSION.into());+ // Every line carries a wall clock, including `debug` and `warning`.+ // Without it a log can show a warning after a buffer report and give+ // no way to tell whether they were a millisecond or a minute apart —+ // which is exactly the difference between "the stream died instantly"+ // and "the stream ran fine and this is teardown". `or_insert` so the+ // events that carry a meaningful timestamp of their own (a sample's+ // capture time) keep it.+ object+ .entry("timestampMs".to_owned())+ .or_insert_with(|| timestamp_ms().into());+ }++ writeln!(self.out, "{value}")?;+ // Per line, not per buffer: the parent process reads this incrementally+ // and a half-written line would be a parse error on the other side.+ self.out.flush()+ }++ pub fn debug_enabled(&self) -> bool {+ self.debug+ }+}++/// Millisecond wall clock, matching the `timestampMs` the macOS and Windows+/// helpers emit (the Electron sessions subtract their own start time from it).+pub fn timestamp_ms() -> u64 {+ std::time::SystemTime::now()+ .duration_since(std::time::UNIX_EPOCH)+ .map(|d| d.as_millis() as u64)+ .unwrap_or(0)+}++#[cfg(test)]+mod tests {+ use super::*;++ fn emit_one(event: &Event, debug: bool) -> String {+ let mut buffer = Vec::new();+ Emitter::new(&mut buffer, debug).emit(event).expect("emit");+ String::from_utf8(buffer).expect("utf8")+ }++ fn parse_one(event: &Event) -> serde_json::Value {+ serde_json::from_str(&emit_one(event, true)).expect("valid json")+ }++ #[test]+ fn every_event_is_one_line_terminated_by_a_newline() {+ let text = emit_one(+ &Event::Ready {+ timestamp_ms: 42,+ pipewire_version: Some("1.0.5".to_owned()),+ cursor_metadata_supported: true,+ },+ false,+ );+ assert!(text.ends_with('\n'));+ assert_eq!(text.matches('\n').count(), 1);+ }++ #[test]+ fn every_event_carries_a_schema_version() {+ let value = parse_one(&Event::Warning {+ code: "x".to_owned(),+ message: "y".to_owned(),+ });+ assert_eq!(value["schemaVersion"], 1);+ }++ #[test]+ fn ready_uses_the_shared_helper_vocabulary() {+ let value = parse_one(&Event::Ready {+ timestamp_ms: 7,+ pipewire_version: None,+ cursor_metadata_supported: false,+ });+ assert_eq!(value["event"], "ready");+ assert_eq!(value["timestampMs"], 7);+ assert!(value["pipewireVersion"].is_null());+ assert_eq!(value["cursorMetadataSupported"], false);+ }++ #[test]+ fn stream_started_is_kebab_case_with_camel_case_fields() {+ let value = parse_one(&Event::StreamStarted {+ timestamp_ms: 1,+ node_id: 55,+ width: 2560,+ height: 1440,+ position_x: Some(0),+ position_y: Some(-1080),+ restore_token: None,+ });+ assert_eq!(value["event"], "stream-started");+ assert_eq!(value["nodeId"], 55);+ assert_eq!(value["positionY"], -1080);+ }++ #[test]+ fn cursor_samples_omit_asset_fields_when_absent() {+ let value = parse_one(&Event::CursorSample {+ timestamp_ms: 12,+ x: 100,+ y: 200,+ width: 1920,+ height: 1080,+ visible: true,+ asset_id: None,+ asset: None,+ });+ assert_eq!(value["event"], "cursor-sample");+ assert_eq!(value["x"], 100);+ assert_eq!(value["visible"], true);+ assert!(value.get("assetId").is_none());+ assert!(value.get("asset").is_none());+ }++ #[test]+ fn cursor_assets_match_the_native_cursor_asset_contract() {+ let value = parse_one(&Event::CursorSample {+ timestamp_ms: 12,+ x: 0,+ y: 0,+ width: 1,+ height: 1,+ visible: true,+ asset_id: Some("abc".to_owned()),+ asset: Some(CursorAsset {+ id: "abc".to_owned(),+ image_data_url: "data:image/png;base64,AA==".to_owned(),+ width: 24,+ height: 24,+ hotspot_x: 4,+ hotspot_y: 3,+ }),+ });+ assert_eq!(value["assetId"], "abc");+ assert_eq!(value["asset"]["imageDataUrl"], "data:image/png;base64,AA==");+ assert_eq!(value["asset"]["hotspotX"], 4);+ assert_eq!(value["asset"]["hotspotY"], 3);+ }++ #[test]+ fn events_without_their_own_clock_get_one() {+ let value = parse_one(&Event::Warning {+ code: "no-cursor-metadata".to_owned(),+ message: "x".to_owned(),+ });+ assert!(+ value["timestampMs"].as_u64().unwrap_or(0) > 0,+ "warnings must be timestamped so stream lifetime is readable from a log"+ );+ }++ #[test]+ fn events_carrying_a_meaningful_timestamp_keep_it() {+ let value = parse_one(&Event::CursorSample {+ timestamp_ms: 1234,+ x: 0,+ y: 0,+ width: 1,+ height: 1,+ visible: true,+ asset_id: None,+ asset: None,+ });+ assert_eq!(value["timestampMs"], 1234, "a sample's capture time must not be overwritten");+ }++ #[test]+ fn debug_events_are_suppressed_unless_enabled() {+ let event = Event::Debug {+ code: "buffer-info".to_owned(),+ data: serde_json::Map::new(),+ };+ assert_eq!(emit_one(&event, false), "");+ assert!(!emit_one(&event, true).is_empty());+ }++ #[test]+ fn debug_payloads_are_flattened_next_to_the_code() {+ let mut data = serde_json::Map::new();+ data.insert("dataType".to_owned(), "MemFd".into());+ let value = parse_one(&Event::Debug {+ code: "buffer-info".to_owned(),+ data,+ });+ assert_eq!(value["event"], "debug");+ assert_eq!(value["code"], "buffer-info");+ assert_eq!(value["dataType"], "MemFd");+ }+}diff --git a/electron/native/pipewire-capture/src/main.rs b/electron/native/pipewire-capture/src/main.rsnew file mode 100644index 000000000..6ef169078--- /dev/null+++ b/electron/native/pipewire-capture/src/main.rs@@ -0,0 +1,477 @@+//! OpenScreen Linux capture helper — Stage 1: cursor samples only.+//!+//! WHY THIS EXISTS. `screen.getCursorScreenPoint()` returns {0,0} under Wayland,+//! so `TelemetryRecordingSession` produced recordings whose every cursor sample+//! sat in the screen's top-left corner while looking perfectly well-formed. The+//! only source of truth for the pointer on Wayland is the ScreenCast portal's+//! METADATA cursor mode, where the compositor keeps the cursor out of the pixels+//! and attaches a SPA_META_Cursor to each frame instead.+//!+//! SHAPE. A stdio sidecar, like the macOS and Windows helpers: JSON request in+//! argv[1], NDJSON events on stdout, `stop` (or EOF) on stdin. It captures no+//! video and writes no file — that is Stage 2's job, and it will reuse this same+//! portal session because SelectSources may only be called once per session.+//!+//! WHAT IT CANNOT DO. Mouse buttons. Wayland exposes no portal for input+//! events, and /dev/input/event* is root:input. Every sample is therefore a+//! "move"; there is no click detection to be had here at any effort level.++mod bitmap;+mod events;+mod portal;+mod shim;++use std::collections::HashSet;+use std::io::{BufRead, Write};+use std::sync::mpsc::{self, RecvTimeoutError, Sender};+use std::time::{Duration, Instant};++use serde::Deserialize;++use events::{timestamp_ms, CursorAsset, Emitter, Event};+use shim::StreamEvent;++/// Matches the macOS helper's default and the Electron side's sampleIntervalMs.+const DEFAULT_SAMPLE_INTERVAL_MS: u64 = 33;+const MIN_SAMPLE_INTERVAL_MS: u64 = 8;++#[derive(Debug, Default, Deserialize)]+#[serde(rename_all = "camelCase", default)]+struct Request {+ sample_interval_ms: Option<u64>,+ /// Token from a previous run's `stream-started`. Lets the portal skip the+ /// picker for a source the user already approved.+ restore_token: Option<String>,+ /// Emit `ready` and exit, without ever calling the portal's `Start()`.+ ///+ /// Everything up to that point is non-interactive; `Start()` is the single+ /// call that raises the compositor's source picker. This flag is what makes+ /// the dlopen path, the portal connection and the cursor-mode check testable+ /// — in CI or by hand — without hijacking someone's screen.+ probe_only: bool,+}++enum Message {+ Portal(Box<Result<portal::PortalStream, portal::PortalError>>),+ Stream(StreamEvent),+ Stop,+}++fn main() {+ let debug = std::env::var("OPENSCREEN_PIPEWIRE_DEBUG")+ .map(|value| !matches!(value.as_str(), "" | "0" | "false"))+ .unwrap_or(false);+ let mut emitter = Emitter::new(std::io::stdout(), debug);++ let request = match parse_request() {+ Ok(request) => request,+ Err(message) => {+ fail(&mut emitter, "invalid-arguments", &message);+ }+ };+ let interval = Duration::from_millis(+ request+ .sample_interval_ms+ .unwrap_or(DEFAULT_SAMPLE_INTERVAL_MS)+ .max(MIN_SAMPLE_INTERVAL_MS),+ );++ if let Err(message) = shim::load() {+ fail(&mut emitter, "pipewire-unavailable", &message);+ }++ // Probed before `ready` so the event can report it, and so an unsupported+ // compositor fails immediately instead of after a pointless picker.+ match pollster::block_on(portal::cursor_metadata_supported()) {+ Ok(true) => {}+ Ok(false) => {+ let error = portal::PortalError::CursorMetadataUnsupported;+ fail(&mut emitter, error.code(), &error.message());+ }+ Err(error) => fail(&mut emitter, error.code(), &error.message()),+ }++ let _ = emitter.emit(&Event::Ready {+ timestamp_ms: timestamp_ms(),+ pipewire_version: shim::library_version(),+ cursor_metadata_supported: true,+ });++ if request.probe_only {+ std::process::exit(0);+ }++ let (sender, receiver) = mpsc::channel::<Message>();+ spawn_stdin_reader(sender.clone());+ spawn_portal(sender.clone(), request.restore_token.clone());++ let exit_code = run(&mut emitter, receiver, sender, interval);+ std::process::exit(exit_code);+}++fn parse_request() -> Result<Request, String> {+ match std::env::args().nth(1) {+ None => Ok(Request::default()),+ Some(raw) => serde_json::from_str(&raw)+ .map_err(|error| format!("could not parse the request argument as JSON: {error}")),+ }+}++fn fail<W: Write>(emitter: &mut Emitter<W>, code: &str, message: &str) -> ! {+ let _ = emitter.emit(&Event::Error {+ code: code.to_owned(),+ message: message.to_owned(),+ });+ std::process::exit(1);+}++/// EOF counts as `stop`: if the parent dies, so do we.+fn spawn_stdin_reader(sender: Sender<Message>) {+ std::thread::spawn(move || {+ let stdin = std::io::stdin();+ for line in stdin.lock().lines() {+ match line {+ Ok(line) if line.trim() == "stop" => break,+ Ok(_) => continue,+ Err(_) => break,+ }+ }+ let _ = sender.send(Message::Stop);+ });+}++/// The portal runs on its own thread because `Start()` blocks on the user for+/// an unbounded time, and a `stop` arriving during the picker must still be+/// honoured.+fn spawn_portal(sender: Sender<Message>, restore_token: Option<String>) {+ std::thread::spawn(move || {+ let result = pollster::block_on(portal::negotiate(restore_token.as_deref()));+ let _ = sender.send(Message::Portal(Box::new(result)));+ });+}++/// Latest known cursor state, resent on the heartbeat so a motionless pointer+/// still produces the steady sample cadence the editor's cursor track expects.+struct CursorState {+ x: i32,+ y: i32,+ asset_id: Option<String>,+}++/// What survives from the portal reply after its fd has been handed to+/// libpipewire — everything `stream-started` needs to report.+struct StreamInfo {+ node_id: u32,+ position: Option<(i32, i32)>,+ restore_token: Option<String>,+}++fn run<W: Write>(+ emitter: &mut Emitter<W>,+ receiver: mpsc::Receiver<Message>,+ sender: Sender<Message>,+ interval: Duration,+) -> i32 {+ let constants = shim::constants();+ // Held for the whole loop: dropping it stops and joins the PipeWire thread.+ let mut session: Option<shim::Session> = None;+ let mut portal_stream: Option<StreamInfo> = None;+ let mut size: Option<(i32, i32)> = None;+ let mut cursor: Option<CursorState> = None;+ let mut known_assets: HashSet<String> = HashSet::new();+ let mut pending_asset: Option<CursorAsset> = None;+ let mut reported_cursor_meta = false;+ // Backdated so the very first sample is not held back by the throttle.+ // `checked_sub` because a bare `Instant - Duration` panics on underflow, and+ // this runs milliseconds after process start.+ let mut last_emit = Instant::now().checked_sub(interval).unwrap_or_else(Instant::now);+ let mut exit_code = 0;++ loop {+ match receiver.recv_timeout(interval) {+ Ok(Message::Stop) => break,++ Ok(Message::Portal(result)) => match *result {+ Ok(stream) => {+ // The fd is consumed by libpipewire; the rest is kept for the+ // `stream-started` event, emitted once the format is negotiated.+ let portal::PortalStream {+ fd,+ node_id,+ position,+ size: logical_size,+ restore_token,+ } = stream;+ // The portal's size is in the compositor's coordinate space+ // and can differ from the negotiated pixel size on a scaled+ // display. Logged rather than used: cursor positions arrive+ // in stream pixels, so only the negotiated size normalises them.+ let _ = emitter.emit(&Event::Debug {+ code: "portal-stream".to_owned(),+ data: json_map([+ ("nodeId", node_id.into()),+ ("logicalWidth", logical_size.map(|(w, _)| w).into()),+ ("logicalHeight", logical_size.map(|(_, h)| h).into()),+ ("positionX", position.map(|(x, _)| x).into()),+ ("positionY", position.map(|(_, y)| y).into()),+ ]),+ });+ let forward = sender.clone();+ match shim::Session::start(+ fd,+ node_id,+ Box::new(move |event| {+ let _ = forward.send(Message::Stream(event));+ }),+ ) {+ Ok(started) => {+ session = Some(started);+ portal_stream = Some(StreamInfo {+ node_id,+ position,+ restore_token,+ });+ }+ Err(message) => {+ let _ = emitter.emit(&Event::Error {+ code: "pipewire-connect-failed".to_owned(),+ message,+ });+ exit_code = 1;+ break;+ }+ }+ }+ Err(error) => {+ let _ = emitter.emit(&Event::Error {+ code: error.code().to_owned(),+ message: error.message(),+ });+ exit_code = 1;+ break;+ }+ },++ Ok(Message::Stream(StreamEvent::Format(format))) => {+ size = Some((format.width, format.height));+ let _ = emitter.emit(&Event::Debug {+ code: "format".to_owned(),+ data: json_map([+ ("videoFormatId", format.video_format.into()),+ ("framerateNum", format.framerate_num.into()),+ ("framerateDenom", format.framerate_denom.into()),+ ]),+ });+ if let Some(stream) = portal_stream.take() {+ let _ = emitter.emit(&Event::StreamStarted {+ timestamp_ms: timestamp_ms(),+ node_id: stream.node_id,+ width: format.width,+ height: format.height,+ position_x: stream.position.map(|(x, _)| x),+ position_y: stream.position.map(|(_, y)| y),+ restore_token: stream.restore_token,+ });+ }+ }++ Ok(Message::Stream(StreamEvent::BufferInfo {+ data_type,+ n_datas,+ has_cursor_meta,+ cursor_meta_size,+ metas,+ })) => {+ // What memory type does the compositor hand us, and which+ // metadata blocks survived negotiation? `metas` is the load-+ // bearing field: a missing Cursor next to a present Header means+ // our ParamMeta was sent and lost the size intersection, which is+ // otherwise indistinguishable from never having sent it.+ let _ = emitter.emit(&Event::Debug {+ code: "buffer-info".to_owned(),+ data: json_map([+ ("dataType", data_type_name(&constants, data_type).into()),+ ("dataTypeId", data_type.into()),+ ("nDatas", n_datas.into()),+ ("hasCursorMeta", has_cursor_meta.into()),+ ("cursorMetaSize", cursor_meta_size.into()),+ ("metas", metas.clone().into()),+ ]),+ });+ if !has_cursor_meta {+ let _ = emitter.emit(&Event::Warning {+ code: "no-cursor-metadata".to_owned(),+ message: format!(+ "The negotiated buffers carry no SPA_META_Cursor, so no cursor \+ samples will be produced. Metadata present: [{metas}]. A cursor \+ block is dropped when the compositor's fixed SPA_PARAM_META_size \+ falls outside the range this helper accepts."+ ),+ });+ }+ }++ Ok(Message::Stream(StreamEvent::State { state, error })) => {+ // Every transition, not just the failures. Without this a run+ // that ends in "target not found" is ambiguous: there is no way+ // to tell a stream that never reached `streaming` from one that+ // streamed happily and then hit the error on teardown.+ let _ = emitter.emit(&Event::Debug {+ code: "stream-state".to_owned(),+ data: json_map([+ ("state", state.clone().into()),+ ("error", error.clone().into()),+ ]),+ });+ if let Some(error) = error {+ let _ = emitter.emit(&Event::Warning {+ code: "stream-error".to_owned(),+ message: format!("PipeWire stream reported an error in state {state}: {error}"),+ });+ }+ if state == "unconnected" && session.is_some() {+ let _ = emitter.emit(&Event::Warning {+ code: "stream-unconnected".to_owned(),+ message: "The PipeWire stream disconnected; no further cursor samples \+ will arrive."+ .to_owned(),+ });+ }+ }++ Ok(Message::Stream(StreamEvent::Cursor(event))) => {+ // Open question #2: does SPA_META_Cursor actually carry a bitmap?+ if !reported_cursor_meta {+ reported_cursor_meta = true;+ let _ = emitter.emit(&Event::Debug {+ code: "cursor-meta".to_owned(),+ data: json_map([+ ("hasBitmap", event.bitmap.is_some().into()),+ ("cursorId", event.id.into()),+ ("hotspotX", event.hotspot_x.into()),+ ("hotspotY", event.hotspot_y.into()),+ ]),+ });+ }++ let mut asset_is_new = false;+ if let Some(raw) = &event.bitmap {+ if emitter.debug_enabled() {+ let _ = emitter.emit(&Event::Debug {+ code: "cursor-bitmap".to_owned(),+ data: json_map([+ ("formatId", raw.format.into()),+ ("width", raw.width.into()),+ ("height", raw.height.into()),+ ("stride", raw.stride.into()),+ ("bytes", raw.pixels.len().into()),+ ]),+ });+ }+ match bitmap::encode(&constants, raw) {+ Ok(encoded) => {+ if known_assets.insert(encoded.id.clone()) {+ asset_is_new = true;+ pending_asset = Some(CursorAsset {+ id: encoded.id.clone(),+ image_data_url: encoded.image_data_url,+ width: encoded.width,+ height: encoded.height,+ hotspot_x: event.hotspot_x,+ hotspot_y: event.hotspot_y,+ });+ }+ cursor = Some(CursorState {+ x: event.x,+ y: event.y,+ asset_id: Some(encoded.id),+ });+ }+ Err(message) => {+ let _ = emitter.emit(&Event::Warning {+ code: "cursor-bitmap-unusable".to_owned(),+ message,+ });+ cursor = Some(CursorState {+ x: event.x,+ y: event.y,+ asset_id: cursor.and_then(|state| state.asset_id),+ });+ }+ }+ } else {+ cursor = Some(CursorState {+ x: event.x,+ y: event.y,+ asset_id: cursor.and_then(|state| state.asset_id),+ });+ }++ // A new sprite ships immediately; positions respect the sample+ // interval so a 120fps compositor cannot flood stdout.+ if asset_is_new || last_emit.elapsed() >= interval {+ emit_sample(emitter, &cursor, size, &mut pending_asset);+ last_emit = Instant::now();+ }+ }++ Err(RecvTimeoutError::Timeout) => {+ if cursor.is_some() {+ emit_sample(emitter, &cursor, size, &mut pending_asset);+ last_emit = Instant::now();+ }+ }++ Err(RecvTimeoutError::Disconnected) => break,+ }+ }++ // Explicit: this joins the PipeWire thread before the process exits, so no+ // callback can fire against a freed Sender.+ drop(session);+ exit_code+}++fn emit_sample<W: Write>(+ emitter: &mut Emitter<W>,+ cursor: &Option<CursorState>,+ size: Option<(i32, i32)>,+ pending_asset: &mut Option<CursorAsset>,+) {+ let (Some(state), Some((width, height))) = (cursor, size) else {+ return;+ };+ let visible = state.x >= 0 && state.y >= 0 && state.x < width && state.y < height;+ let _ = emitter.emit(&Event::CursorSample {+ timestamp_ms: timestamp_ms(),+ x: state.x,+ y: state.y,+ width,+ height,+ visible,+ asset_id: state.asset_id.clone(),+ asset: pending_asset.take(),+ });+}++fn data_type_name(constants: &shim::Constants, data_type: u32) -> &'static str {+ if data_type == constants.data_mem_ptr {+ "MemPtr"+ } else if data_type == constants.data_mem_fd {+ "MemFd"+ } else if data_type == constants.data_dma_buf {+ "DmaBuf"+ } else {+ "unknown"+ }+}++fn json_map<const N: usize>(+ entries: [(&str, serde_json::Value); N],+) -> serde_json::Map<String, serde_json::Value> {+ entries+ .into_iter()+ .map(|(key, value)| (key.to_owned(), value))+ .collect()+}+diff --git a/electron/native/pipewire-capture/src/portal.rs b/electron/native/pipewire-capture/src/portal.rsnew file mode 100644index 000000000..379c4af8f--- /dev/null+++ b/electron/native/pipewire-capture/src/portal.rs@@ -0,0 +1,165 @@+//! xdg-desktop-portal ScreenCast negotiation.+//!+//! The five-call dance is CreateSession → SelectSources → Start →+//! OpenPipeWireRemote, each async call answering on a Request object's Response+//! signal. ashpd subscribes to that signal before issuing the call, which is+//! the part that is easy to get wrong by hand (subscribe after, and the reply+//! can land before the match rule exists).+//!+//! Two properties of the protocol shape this module:+//!+//! * SelectSources may be called ONCE per session. A second call fails with+//! `Sources already selected`. Everything — cursor mode, source types,+//! persistence — has to be decided before the first call.+//! * Start is what raises the compositor's source picker. It does not return+//! until a human has clicked, so nothing downstream may hold a timeout.+//!+//! ashpd is used rather than raw zbus because it is pure Rust (no libdbus-1-dev)+//! and because its `pipewire` feature — which would drag in pipewire-rs and+//! therefore libpipewire-0.3-dev — is deliberately left off; the PipeWire half+//! lives in csrc/pw_shim.c instead.++use std::os::fd::OwnedFd;++use ashpd::desktop::screencast::{CursorMode, Screencast, SourceType};+use ashpd::desktop::PersistMode;+use ashpd::enumflags2::BitFlags;+use ashpd::WindowIdentifier;++/// Everything the PipeWire half needs, plus what the helper reports upward.+pub struct PortalStream {+ pub fd: OwnedFd,+ pub node_id: u32,+ pub position: Option<(i32, i32)>,+ pub size: Option<(i32, i32)>,+ pub restore_token: Option<String>,+}++#[derive(Debug)]+pub enum PortalError {+ /// The compositor's portal does not offer METADATA cursor mode. Nothing+ /// this helper does can work without it, and falling back to EMBEDDED would+ /// bake the cursor into the pixels, which is the opposite of what the+ /// editor needs.+ CursorMetadataUnsupported,+ /// The user dismissed the picker, or the portal refused.+ Cancelled,+ Failed(String),+}++impl PortalError {+ pub fn code(&self) -> &'static str {+ match self {+ Self::CursorMetadataUnsupported => "cursor-metadata-unsupported",+ Self::Cancelled => "portal-cancelled",+ Self::Failed(_) => "portal-failed",+ }+ }++ pub fn message(&self) -> String {+ match self {+ Self::CursorMetadataUnsupported => {+ "The ScreenCast portal does not advertise METADATA cursor mode, so real cursor \+ positions cannot be obtained on this session."+ .to_owned()+ }+ Self::Cancelled => "The screen capture request was cancelled.".to_owned(),+ Self::Failed(message) => message.clone(),+ }+ }+}++fn failed(context: &str, error: impl std::fmt::Display) -> PortalError {+ PortalError::Failed(format!("{context}: {error}"))+}++/// Cheap, non-interactive probe: does this portal offer METADATA cursor mode?+///+/// Split out from [`negotiate`] so the helper can answer that question — and+/// emit `ready` — before anything raises a dialog.+pub async fn cursor_metadata_supported() -> Result<bool, PortalError> {+ let proxy = Screencast::new()+ .await+ .map_err(|error| failed("cannot reach org.freedesktop.portal.ScreenCast", error))?;+ let cursor_modes = proxy+ .available_cursor_modes()+ .await+ .map_err(|error| failed("AvailableCursorModes", error))?;+ Ok(cursor_modes.contains(CursorMode::Metadata))+}++/// Runs the negotiation to completion. Blocks on the user for as long as the+/// picker is up: `Start()` is what raises it.+///+/// The returned `PortalStream` outlives the ashpd `Session` object on purpose.+/// ashpd has no `Drop` impl for sessions and holds its D-Bus connection in a+/// process-global `OnceLock`, so the portal session stays open until this+/// process exits — which is exactly the lifetime we want.+pub async fn negotiate(restore_token: Option<&str>) -> Result<PortalStream, PortalError> {+ let proxy = Screencast::new()+ .await+ .map_err(|error| failed("cannot reach org.freedesktop.portal.ScreenCast", error))?;++ let cursor_modes = proxy+ .available_cursor_modes()+ .await+ .map_err(|error| failed("AvailableCursorModes", error))?;+ if !cursor_modes.contains(CursorMode::Metadata) {+ return Err(PortalError::CursorMetadataUnsupported);+ }++ let session = proxy+ .create_session()+ .await+ .map_err(|error| failed("CreateSession", error))?;++ // Monitors and windows both; the picker decides which. Virtual sources are+ // excluded — a virtual monitor has no cursor to report.+ let types: BitFlags<SourceType> = SourceType::Monitor | SourceType::Window;+ proxy+ .select_sources(+ &session,+ CursorMode::Metadata,+ types,+ false,+ restore_token,+ // The picker is a per-recording interruption otherwise. Persisting+ // until the user revokes it means the restore token from a previous+ // run can skip it entirely.+ PersistMode::ExplicitlyRevoked,+ )+ .await+ .map_err(|error| failed("SelectSources", error))?+ .response()+ .map_err(|error| failed("SelectSources response", error))?;++ let streams = proxy+ .start(&session, &WindowIdentifier::default())+ .await+ .map_err(|error| failed("Start", error))?+ .response()+ .map_err(|error| match error {+ ashpd::Error::Response(ashpd::desktop::ResponseError::Cancelled) => {+ PortalError::Cancelled+ }+ other => failed("Start response", other),+ })?;++ let stream = streams+ .streams()+ .first()+ .ok_or_else(|| PortalError::Failed("the portal returned no stream".to_owned()))?;++ let fd = proxy+ .open_pipe_wire_remote(&session)+ .await+ .map_err(|error| failed("OpenPipeWireRemote", error))?;++ Ok(PortalStream {+ fd,+ node_id: stream.pipe_wire_node_id(),+ position: stream.position(),+ size: stream.size(),+ restore_token: streams.restore_token().map(str::to_owned),+ })+}diff --git a/electron/native/pipewire-capture/src/shim.rs b/electron/native/pipewire-capture/src/shim.rsnew file mode 100644index 000000000..b64b2a645--- /dev/null+++ b/electron/native/pipewire-capture/src/shim.rs@@ -0,0 +1,502 @@+//! Rust half of the C ABI declared in `csrc/pw_shim.h`.+//!+//! Every struct below mirrors its C counterpart field for field. They are a+//! matched pair; the compiler cannot check that for you, so if you touch one,+//! touch the other.+//!+//! Nothing here interprets PipeWire semantics — the shim already validated the+//! metadata offsets. This module's only jobs are (1) owning the raw handle+//! safely and (2) turning callback pointers into channel messages without ever+//! letting a Rust panic unwind into C.++use std::ffi::{c_char, c_void, CStr};+use std::os::fd::{IntoRawFd, OwnedFd};+use std::panic::{catch_unwind, AssertUnwindSafe};++#[repr(C)]+#[derive(Debug)]+pub struct RawCursor {+ pub x: i32,+ pub y: i32,+ pub hotspot_x: i32,+ pub hotspot_y: i32,+ pub id: u32,+ pub flags: u32,+ pub has_bitmap: i32,+ pub bitmap_format: u32,+ pub bitmap_width: i32,+ pub bitmap_height: i32,+ pub bitmap_stride: i32,+ pub bitmap_data: *const u8,+ pub bitmap_len: usize,+}++#[repr(C)]+#[derive(Debug, Clone, Copy)]+pub struct RawFormat {+ pub width: i32,+ pub height: i32,+ pub video_format: u32,+ pub framerate_num: i32,+ pub framerate_denom: i32,+}++#[repr(C)]+struct RawCallbacks {+ user: *mut c_void,+ on_format: extern "C" fn(*mut c_void, *const RawFormat),+ on_cursor: extern "C" fn(*mut c_void, *const RawCursor),+ on_buffer_info: extern "C" fn(*mut c_void, u32, u32, i32, u32, *const c_char),+ on_state: extern "C" fn(*mut c_void, *const c_char, *const c_char),+}++#[repr(C)]+#[derive(Debug, Default, Clone, Copy)]+pub struct Constants {+ pub video_format_rgbx: u32,+ pub video_format_bgrx: u32,+ pub video_format_xrgb: u32,+ pub video_format_xbgr: u32,+ pub video_format_rgba: u32,+ pub video_format_bgra: u32,+ pub video_format_argb: u32,+ pub video_format_abgr: u32,+ pub data_mem_ptr: u32,+ pub data_mem_fd: u32,+ pub data_dma_buf: u32,+}++#[repr(C)]+struct RawSession {+ _private: [u8; 0],+}++extern "C" {+ fn osc_pw_load(err: *mut c_char, err_len: usize) -> i32;+ fn osc_pw_library_version() -> *const c_char;+ fn osc_pw_constants(out: *mut Constants);+ /// Test-only: the shipped binary never negotiates against a synthetic+ /// producer, but the unit tests do. The C side is always compiled.+ #[cfg(test)]+ fn osc_pw_cursor_meta_accepts_producer_size(width: u32, height: u32) -> i32;+ fn osc_pw_start(+ fd: i32,+ node_id: u32,+ callbacks: *const RawCallbacks,+ err: *mut c_char,+ err_len: usize,+ ) -> *mut RawSession;+ fn osc_pw_stop(session: *mut RawSession);+}++/// Where stream events go. Called on the PipeWire thread, so it must not block:+/// the helper only forwards onto an unbounded channel.+pub type Sink = Box<dyn Fn(StreamEvent) + Send>;++/// What the PipeWire thread reports back. Owned data only: the bitmap pointer+/// handed to the callback dies when the callback returns, so it is copied.+#[derive(Debug)]+pub enum StreamEvent {+ Format(RawFormat),+ BufferInfo {+ data_type: u32,+ n_datas: u32,+ has_cursor_meta: bool,+ cursor_meta_size: u32,+ /// "Header:12,Cursor:589872" — every metadata block that survived+ /// negotiation. Empty when the buffers carry none at all.+ metas: String,+ },+ Cursor(CursorEvent),+ State {+ state: String,+ error: Option<String>,+ },+}++#[derive(Debug)]+pub struct CursorEvent {+ pub x: i32,+ pub y: i32,+ pub hotspot_x: i32,+ pub hotspot_y: i32,+ pub id: u32,+ pub bitmap: Option<CursorBitmap>,+}++#[derive(Debug)]+pub struct CursorBitmap {+ pub format: u32,+ pub width: i32,+ pub height: i32,+ pub stride: i32,+ pub pixels: Vec<u8>,+}++const ERR_LEN: usize = 256;++fn take_error(buffer: &[c_char; ERR_LEN]) -> String {+ // SAFETY: the shim always NUL-terminates within ERR_LEN, and the buffer is+ // zero-initialised, so a missing write still yields an empty C string.+ let text = unsafe { CStr::from_ptr(buffer.as_ptr()) };+ text.to_string_lossy().into_owned()+}++/// dlopen libpipewire and resolve its symbols. Idempotent.+pub fn load() -> Result<(), String> {+ let mut err = [0 as c_char; ERR_LEN];+ // SAFETY: `err` is a live, correctly sized buffer for the duration of the call.+ let result = unsafe { osc_pw_load(err.as_mut_ptr(), ERR_LEN) };+ if result != 0 {+ return Err(take_error(&err));+ }+ Ok(())+}++/// Runtime libpipewire version, or `None` before a successful [`load`].+pub fn library_version() -> Option<String> {+ // SAFETY: returns a static string owned by libpipewire, or NULL.+ let raw = unsafe { osc_pw_library_version() };+ if raw.is_null() {+ return None;+ }+ // SAFETY: non-NULL implies a NUL-terminated string from pw_get_library_version.+ Some(unsafe { CStr::from_ptr(raw) }.to_string_lossy().into_owned())+}++/// Would our SPA_META_Cursor declaration survive negotiation against a producer+/// declaring a fixed `width` x `height` cursor plane?+#[cfg(test)]+pub fn cursor_meta_accepts_producer_size(width: u32, height: u32) -> i32 {+ // SAFETY: no arguments to validate; the shim builds and frees its own PODs.+ unsafe { osc_pw_cursor_meta_accepts_producer_size(width, height) }+}++/// SPA enum values as compiled from the vendored headers.+pub fn constants() -> Constants {+ let mut out = Constants::default();+ // SAFETY: `out` is a live, correctly typed destination.+ unsafe { osc_pw_constants(&mut out) };+ out+}++/// A running PipeWire stream. Dropping it stops and joins the PipeWire thread.+pub struct Session {+ raw: *mut RawSession,+ // Kept alive for exactly as long as `raw`: the C side holds a pointer to it+ // and hands it back to every callback. Dropped after osc_pw_stop has joined+ // the loop thread, so no callback can be in flight at that point. The outer+ // Box exists to give the fat `dyn Fn` pointer a stable thin address.+ _sink: Box<Sink>,+}++impl Session {+ /// Consumes `fd` — libpipewire closes it, on the success and failure paths alike.+ pub fn start(fd: OwnedFd, node_id: u32, sink: Sink) -> Result<Self, String> {+ let boxed: Box<Sink> = Box::new(sink);+ let user = &*boxed as *const Sink as *mut c_void;+ let callbacks = RawCallbacks {+ user,+ on_format,+ on_cursor,+ on_buffer_info,+ on_state,+ };++ let mut err = [0 as c_char; ERR_LEN];+ // SAFETY: `callbacks` and `err` outlive the call; `boxed` outlives the+ // returned session, which is what keeps `user` valid for the callbacks.+ let raw = unsafe {+ osc_pw_start(fd.into_raw_fd(), node_id, &callbacks, err.as_mut_ptr(), ERR_LEN)+ };+ if raw.is_null() {+ return Err(take_error(&err));+ }++ Ok(Self { raw, _sink: boxed })+ }+}++impl Drop for Session {+ fn drop(&mut self) {+ // SAFETY: `raw` came from osc_pw_start and is stopped exactly once.+ unsafe { osc_pw_stop(self.raw) };+ }+}++/// Recovers the sink the C side is carrying and runs `body` with it.+///+/// `catch_unwind` is not defensive programming here: unwinding across an+/// `extern "C"` boundary is undefined behaviour, and these functions run on+/// PipeWire's thread where a panic would otherwise abort mid-callback.+fn with_sink<F>(user: *mut c_void, body: F)+where+ F: FnOnce(&Sink),+{+ if user.is_null() {+ return;+ }+ // SAFETY: `user` is the pointer we handed to osc_pw_start, pointing at a+ // sink owned by the live Session. Callbacks cannot outlive it: osc_pw_stop+ // joins the loop thread before the Session drops the box.+ let sink = unsafe { &*(user as *const Sink) };+ let _ = catch_unwind(AssertUnwindSafe(|| body(sink)));+}++extern "C" fn on_format(user: *mut c_void, format: *const RawFormat) {+ with_sink(user, |sink| {+ if format.is_null() {+ return;+ }+ // SAFETY: non-NULL for the duration of the callback, by contract.+ let format = unsafe { &*format };+ sink(StreamEvent::Format(*format));+ });+}++extern "C" fn on_buffer_info(+ user: *mut c_void,+ data_type: u32,+ n_datas: u32,+ has_cursor_meta: i32,+ cursor_meta_size: u32,+ metas: *const c_char,+) {+ with_sink(user, |sink| {+ let metas = if metas.is_null() {+ String::new()+ } else {+ // SAFETY: the shim always passes a NUL-terminated stack buffer that+ // outlives the callback.+ unsafe { CStr::from_ptr(metas) }.to_string_lossy().into_owned()+ };+ sink(StreamEvent::BufferInfo {+ data_type,+ n_datas,+ has_cursor_meta: has_cursor_meta != 0,+ cursor_meta_size,+ metas,+ });+ });+}++extern "C" fn on_cursor(user: *mut c_void, cursor: *const RawCursor) {+ with_sink(user, |sink| {+ if cursor.is_null() {+ return;+ }+ // SAFETY: non-NULL for the duration of the callback, by contract.+ let cursor = unsafe { &*cursor };++ let bitmap = if cursor.has_bitmap != 0+ && !cursor.bitmap_data.is_null()+ && cursor.bitmap_len > 0+ {+ // SAFETY: the shim validated that `bitmap_len` bytes starting at+ // `bitmap_data` lie inside the metadata block before setting+ // has_bitmap; the region stays mapped until the callback returns.+ let pixels =+ unsafe { std::slice::from_raw_parts(cursor.bitmap_data, cursor.bitmap_len) };+ Some(CursorBitmap {+ format: cursor.bitmap_format,+ width: cursor.bitmap_width,+ height: cursor.bitmap_height,+ stride: cursor.bitmap_stride,+ pixels: pixels.to_vec(),+ })+ } else {+ None+ };++ sink(StreamEvent::Cursor(CursorEvent {+ x: cursor.x,+ y: cursor.y,+ hotspot_x: cursor.hotspot_x,+ hotspot_y: cursor.hotspot_y,+ id: cursor.id,+ bitmap,+ }));+ });+}++extern "C" fn on_state(user: *mut c_void, state: *const c_char, error: *const c_char) {+ with_sink(user, |sink| {+ let to_string = |raw: *const c_char| {+ if raw.is_null() {+ None+ } else {+ // SAFETY: libpipewire hands us NUL-terminated static/owned strings.+ Some(unsafe { CStr::from_ptr(raw) }.to_string_lossy().into_owned())+ }+ };+ sink(StreamEvent::State {+ state: to_string(state).unwrap_or_else(|| "unknown".to_owned()),+ error: to_string(error),+ });+ });+}++#[cfg(test)]+mod tests {+ use super::*;+ use std::os::unix::net::UnixStream;+ use std::sync::mpsc;+ use std::time::Duration;++ /// The bound that made Stage 1 produce nothing on the first real run.+ ///+ /// Compositors declare SPA_PARAM_META_size for the cursor as a FIXED+ /// SPA_POD_Int; PipeWire then intersects it with the consumer's declaration+ /// via `spa_pod_filter`. If the consumer's accepted range does not contain+ /// that constant, the ENTIRE ParamMeta object is filtered out and the+ /// buffers arrive with no cursor metadata — no error, no warning, a stream+ /// that negotiates and runs perfectly while reporting nothing.+ ///+ /// mutter 46.2 declares CURSOR_META_SIZE(384, 384) = 589872 bytes+ /// (src/backends/meta-screen-cast-stream-src.c). The original ceiling of+ /// 256x256 = 262192 bytes sat below it, so every buffer came back with+ /// hasCursorMeta=false against real GNOME.+ ///+ /// This runs the same `spa_pod_filter` the link uses, against the same POD+ /// `param_changed` sends, so it fails here instead of on someone's desktop.+ #[test]+ fn cursor_meta_range_contains_what_real_compositors_declare() {+ // mutter 46.2. The regression case: this returned 0 before the fix.+ assert_eq!(+ cursor_meta_accepts_producer_size(384, 384),+ 1,+ "mutter 46.2 declares a fixed CURSOR_META_SIZE(384, 384); our range must contain it"+ );+ // Headroom for compositors with larger or smaller cursor planes.+ for (width, height) in [(1, 1), (64, 64), (256, 256), (512, 512), (1024, 1024)] {+ assert_eq!(+ cursor_meta_accepts_producer_size(width, height),+ 1,+ "a producer declaring {width}x{height} must still intersect"+ );+ }+ // And the bound is a real bound, not an accident of the filter always+ // succeeding: something past the ceiling must still be rejected.+ assert_eq!(+ cursor_meta_accepts_producer_size(2048, 2048),+ 0,+ "beyond the declared ceiling the intersection must genuinely be empty"+ );+ }++ /// End-to-end exercise of the PipeWire half with NO portal involved.+ ///+ /// `pw_context_connect_fd` accepts any socket already connected to a+ /// PipeWire daemon — the portal's `OpenPipeWireRemote` fd is exactly that,+ /// just pointed at a restricted instance. Connecting to the session daemon+ /// directly therefore drives the identical code path (POD negotiation,+ /// param_changed, on_process, buffer inspection) without raising a picker+ /// or capturing anyone's screen.+ ///+ /// Ignored by default: it needs a running PipeWire and a video node to read.+ /// The node has to offer one of the 32-bit packed formats the shim asks for+ /// (SPA's own `videotestsrc` plugin only offers RGB24 and UYVY, so it+ /// negotiates to "no more input formats" — that is the source's limitation,+ /// not a bug). GStreamer can publish a suitable one:+ ///+ /// ```sh+ /// gst-launch-1.0 videotestsrc is-live=true \+ /// ! video/x-raw,format=BGRx,width=640,height=480,framerate=30/1 \+ /// ! pipewiresink stream-properties="props,node.name=oscbgrxtest,media.class=Video/Source" &+ /// OPENSCREEN_PIPEWIRE_TEST_NODE=$(pw-dump | jq '.[]+ /// | select(.info.props["node.name"] == "oscbgrxtest") | .id') \+ /// cargo test -- --ignored --nocapture+ /// ```+ ///+ /// `cursorMeta` is expected to be false here: only a compositor's screencast+ /// source attaches SPA_META_Cursor. That part still needs the portal.+ #[test]+ #[ignore = "needs a live PipeWire daemon and OPENSCREEN_PIPEWIRE_TEST_NODE"]+ fn negotiates_a_stream_against_a_local_pipewire_node() {+ let node_id: u32 = std::env::var("OPENSCREEN_PIPEWIRE_TEST_NODE")+ .expect("set OPENSCREEN_PIPEWIRE_TEST_NODE to a video node id")+ .parse()+ .expect("node id must be an integer");++ load().expect("libpipewire must load");+ let runtime = std::env::var("XDG_RUNTIME_DIR").expect("XDG_RUNTIME_DIR");+ let socket = UnixStream::connect(format!("{runtime}/pipewire-0"))+ .expect("PipeWire daemon socket");++ let (sender, receiver) = mpsc::channel();+ let session = Session::start(+ socket.into(),+ node_id,+ Box::new(move |event| {+ let _ = sender.send(event);+ }),+ )+ .expect("stream must connect");++ let started = std::time::Instant::now();+ let stamp = |at: std::time::Instant| at.duration_since(started).as_millis();++ let mut format = None;+ let mut buffer_info = None;+ let mut buffer_reports = 0;+ // Run well past the first buffer. A stream that dies after one buffer and+ // a stream that runs for seconds look identical if you stop watching at+ // the first one — that ambiguity is what sent the last debugging round+ // down the wrong path.+ let observe_until = started + Duration::from_secs(5);+ while std::time::Instant::now() < observe_until {+ match receiver.recv_timeout(Duration::from_millis(250)) {+ Ok(StreamEvent::Format(value)) => {+ println!("[{:>5}ms] format {}x{}", stamp(std::time::Instant::now()), value.width, value.height);+ format = Some(value);+ }+ Ok(StreamEvent::BufferInfo {+ data_type,+ n_datas,+ has_cursor_meta,+ cursor_meta_size,+ metas,+ }) => {+ buffer_reports += 1;+ println!(+ "[{:>5}ms] buffer #{buffer_reports} dataType={data_type} nDatas={n_datas} \+ cursorMeta={has_cursor_meta} cursorMetaSize={cursor_meta_size} metas=[{metas}]",+ stamp(std::time::Instant::now())+ );+ buffer_info =+ Some((data_type, n_datas, has_cursor_meta, cursor_meta_size, metas));+ }+ Ok(StreamEvent::State { state, error }) => {+ println!(+ "[{:>5}ms] state {state}{}",+ stamp(std::time::Instant::now()),+ error.map(|e| format!(" error={e}")).unwrap_or_default()+ );+ }+ Ok(StreamEvent::Cursor(cursor)) => {+ println!("[{:>5}ms] cursor {cursor:?}", stamp(std::time::Instant::now()));+ }+ Err(_) => {}+ }+ }++ // Teardown, watched. Whatever the stream reports while being stopped is+ // what a maintainer's log will show at the end of every clean run, so it+ // must not be mistaken for a failure.+ println!("[{:>5}ms] -- dropping session --", stamp(std::time::Instant::now()));+ drop(session);+ println!("[{:>5}ms] -- session dropped --", stamp(std::time::Instant::now()));+ while let Ok(event) = receiver.recv_timeout(Duration::from_millis(250)) {+ println!("[{:>5}ms] after-drop {event:?}", stamp(std::time::Instant::now()));+ }++ let format = format.expect("param_changed must deliver a negotiated format");+ let (_, n_datas, _, _, _) = buffer_info.expect("on_process must run at least once");+ assert!(format.width > 0 && format.height > 0);+ assert!(n_datas > 0);+ assert!(+ buffer_reports > 1,+ "the stream delivered only {buffer_reports} buffer report(s); it is not staying alive"+ );+ }+}diff --git a/electron/native/pipewire-capture/vendor/README.md b/electron/native/pipewire-capture/vendor/README.mdnew file mode 100644index 000000000..377df3ab8--- /dev/null+++ b/electron/native/pipewire-capture/vendor/README.md@@ -0,0 +1,50 @@+# Vendored PipeWire headers++`pipewire-1.0.5/include/` holds the PipeWire and SPA headers `csrc/pw_shim.c`+compiles against. They are MIT (see `pipewire-1.0.5/COPYING`; every file keeps+its `SPDX-License-Identifier: MIT` line) and are copied unmodified from the+[PipeWire 1.0.5 release tarball](https://gitlab.freedesktop.org/pipewire/pipewire/-/releases/1.0.5),+with one exception noted below.++## Why they are here++`libpipewire-0.3-dev` and `libspa-0.2-dev` are not installed on a stock Ubuntu+24.04 (or in most CI images), and installing them needs root. The base system+ships only the runtime `libpipewire-0.3.so.0` — no `.so` symlink, no headers.++Vendoring the headers plus `dlopen`ing the runtime library removes the dev+package from the build entirely, and pins the ABI the helper was compiled+against, which matters because end users' distributions ship a wide spread of+PipeWire versions.++## What was copied++Exactly the transitive closure of what `csrc/pw_shim.c` includes — 76 files,+computed with `gcc -MM` — not the whole upstream tree. Adding a new `#include`+to the shim may therefore need another header vendored.++To re-vendor after changing the shim's includes, or to move to a newer PipeWire:++```sh+# 1. Unpack an upstream release next to the repo, then stage its two header roots:+# <src>/src/pipewire/*.h + extensions/ -> $STAGE/pipewire/+# <src>/spa/include/spa/ -> $STAGE/spa/+# 2. Generate pipewire/version.h from version.h.in (see below).+# 3. List what the shim actually needs and copy just those:+gcc -std=gnu11 -MM csrc/pw_shim.c -I"$STAGE" -Icsrc \+ | tr ' ' '\n' | grep "^$STAGE" | sort -u+```++`pipewire/version.h` is the exception: upstream generates it from+`version.h.in` at configure time, so it does not exist in the tarball. It was+produced with the substitutions meson makes (`meson.build:204`,+`src/pipewire/meson.build:85`) for release 1.0.5:++| placeholder | value |+| --------------------------- | ------- |+| `@PIPEWIRE_VERSION_MAJOR@` | `1` |+| `@PIPEWIRE_VERSION_MINOR@` | `0` |+| `@PIPEWIRE_VERSION_MICRO@` | `5` |+| `@PIPEWIRE_API_VERSION@` | `"0.3"` |++Nothing else was edited.diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/COPYING b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/COPYINGnew file mode 100644index 000000000..aa100ce9c--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/COPYING@@ -0,0 +1,26 @@+Copyright © 2018 Wim Taymans++Permission is hereby granted, free of charge, to any person obtaining a+copy of this software and associated documentation files (the "Software"),+to deal in the Software without restriction, including without limitation+the rights to use, copy, modify, merge, publish, distribute, sublicense,+and/or sell copies of the Software, and to permit persons to whom the+Software is furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice (including the next+paragraph) shall be included in all copies or substantial portions of the+Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER+DEALINGS IN THE SOFTWARE.++---++The above is the version of the MIT "Expat" License used by X.org:++ http://cgit.freedesktop.org/xorg/xserver/tree/COPYINGdiff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/array.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/array.hnew file mode 100644index 000000000..af0b59d26--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/array.h@@ -0,0 +1,156 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_ARRAY_H+#define PIPEWIRE_ARRAY_H++#ifdef __cplusplus+extern "C" {+#endif++#include <errno.h>++#include <spa/utils/defs.h>++/** \defgroup pw_array Array+ *+ * \brief An array object+ *+ * The array is a dynamically resizable data structure that can+ * hold items of the same size.+ */++/**+ * \addtogroup pw_array+ * \{+ */+struct pw_array {+ void *data; /**< pointer to array data */+ size_t size; /**< length of array in bytes */+ size_t alloc; /**< number of allocated memory in \a data */+ size_t extend; /**< number of bytes to extend with */+};++#define PW_ARRAY_INIT(extend) ((struct pw_array) { NULL, 0, 0, (extend) })++#define pw_array_get_len_s(a,s) ((a)->size / (s))+#define pw_array_get_unchecked_s(a,idx,s,t) SPA_PTROFF((a)->data,(idx)*(s),t)+#define pw_array_check_index_s(a,idx,s) ((idx) < pw_array_get_len_s(a,s))++/** Get the number of items of type \a t in array */+#define pw_array_get_len(a,t) pw_array_get_len_s(a,sizeof(t))+/** Get the item with index \a idx and type \a t from array */+#define pw_array_get_unchecked(a,idx,t) pw_array_get_unchecked_s(a,idx,sizeof(t),t)+/** Check if an item with index \a idx and type \a t exist in array */+#define pw_array_check_index(a,idx,t) pw_array_check_index_s(a,idx,sizeof(t))++#define pw_array_first(a) ((a)->data)+#define pw_array_end(a) SPA_PTROFF((a)->data, (a)->size, void)+#define pw_array_check(a,p) (SPA_PTROFF(p,sizeof(*(p)),void) <= pw_array_end(a))++#define pw_array_for_each(pos, array) \+ for ((pos) = (__typeof__(pos)) pw_array_first(array); \+ pw_array_check(array, pos); \+ (pos)++)++#define pw_array_consume(pos, array) \+ for ((pos) = (__typeof__(pos)) pw_array_first(array); \+ pw_array_check(array, pos); \+ (pos) = (__typeof__(pos)) pw_array_first(array))++#define pw_array_remove(a,p) \+({ \+ (a)->size -= sizeof(*(p)); \+ memmove(p, SPA_PTROFF((p), sizeof(*(p)), void), \+ SPA_PTRDIFF(pw_array_end(a),(p))); \+})++/** Initialize the array with given extend */+static inline void pw_array_init(struct pw_array *arr, size_t extend)+{+ arr->data = NULL;+ arr->size = arr->alloc = 0;+ arr->extend = extend;+}++/** Clear the array */+static inline void pw_array_clear(struct pw_array *arr)+{+ free(arr->data);+ pw_array_init(arr, arr->extend);+}++/** Reset the array */+static inline void pw_array_reset(struct pw_array *arr)+{+ arr->size = 0;+}++/** Make sure \a size bytes can be added to the array */+static inline int pw_array_ensure_size(struct pw_array *arr, size_t size)+{+ size_t alloc, need;++ alloc = arr->alloc;+ need = arr->size + size;++ if (SPA_UNLIKELY(alloc < need)) {+ void *data;+ alloc = SPA_MAX(alloc, arr->extend);+ spa_assert(alloc != 0); /* forgot pw_array_init */+ while (alloc < need)+ alloc *= 2;+ if (SPA_UNLIKELY((data = realloc(arr->data, alloc)) == NULL))+ return -errno;+ arr->data = data;+ arr->alloc = alloc;+ }+ return 0;+}++/** Add \a ref size bytes to \a arr. A pointer to memory that can+ * hold at least \a size bytes is returned */+static inline void *pw_array_add(struct pw_array *arr, size_t size)+{+ void *p;++ if (pw_array_ensure_size(arr, size) < 0)+ return NULL;++ p = SPA_PTROFF(arr->data, arr->size, void);+ arr->size += size;++ return p;+}++/** Add \a ref size bytes to \a arr. When there is not enough memory to+ * hold \a size bytes, NULL is returned */+static inline void *pw_array_add_fixed(struct pw_array *arr, size_t size)+{+ void *p;++ if (SPA_UNLIKELY(arr->alloc < arr->size + size)) {+ errno = ENOSPC;+ return NULL;+ }++ p = SPA_PTROFF(arr->data, arr->size, void);+ arr->size += size;++ return p;+}++/** Add a pointer to array */+#define pw_array_add_ptr(a,p) \+ *((void**) pw_array_add(a, sizeof(void*))) = (p)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* PIPEWIRE_ARRAY_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/buffers.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/buffers.hnew file mode 100644index 000000000..9c1ae2b78--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/buffers.h@@ -0,0 +1,56 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2019 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_BUFFERS_H+#define PIPEWIRE_BUFFERS_H++#include <spa/node/node.h>++#include <pipewire/context.h>+#include <pipewire/mem.h>++#ifdef __cplusplus+extern "C" {+#endif++/** \defgroup pw_buffers Buffers+ * Buffer handling+ */++/**+ * \addtogroup pw_buffers+ * \{+ */++#define PW_BUFFERS_FLAG_NONE 0+#define PW_BUFFERS_FLAG_NO_MEM (1<<0) /**< don't allocate buffer memory */+#define PW_BUFFERS_FLAG_SHARED (1<<1) /**< buffers can be shared */+#define PW_BUFFERS_FLAG_DYNAMIC (1<<2) /**< buffers have dynamic data */+#define PW_BUFFERS_FLAG_SHARED_MEM (1<<3) /**< buffers need shared memory */+#define PW_BUFFERS_FLAG_IN_PRIORITY (1<<4) /**< input parameters have priority */+#define PW_BUFFERS_FLAG_ASYNC (1<<5) /**< one of the nodes is async */++struct pw_buffers {+ struct pw_memblock *mem; /**< allocated buffer memory */+ struct spa_buffer **buffers; /**< port buffers */+ uint32_t n_buffers; /**< number of port buffers */+ uint32_t flags; /**< flags */+};++int pw_buffers_negotiate(struct pw_context *context, uint32_t flags,+ struct spa_node *outnode, uint32_t out_port_id,+ struct spa_node *innode, uint32_t in_port_id,+ struct pw_buffers *result);++void pw_buffers_clear(struct pw_buffers *buffers);++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_BUFFERS_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/client.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/client.hnew file mode 100644index 000000000..cd119643e--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/client.h@@ -0,0 +1,176 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_CLIENT_H+#define PIPEWIRE_CLIENT_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>+#include <spa/param/param.h>++#include <pipewire/proxy.h>+#include <pipewire/permission.h>++/** \defgroup pw_client Client+ * Client interface+ */++/**+ * \addtogroup pw_client+ * \{+ */+#define PW_TYPE_INTERFACE_Client PW_TYPE_INFO_INTERFACE_BASE "Client"++#define PW_CLIENT_PERM_MASK PW_PERM_RWXM++#define PW_VERSION_CLIENT 3+struct pw_client;++/* default ID of the current client after connect */+#define PW_ID_CLIENT 1++/** The client information. Extra information can be added in later versions */+struct pw_client_info {+ uint32_t id; /**< id of the global */+#define PW_CLIENT_CHANGE_MASK_PROPS (1 << 0)+#define PW_CLIENT_CHANGE_MASK_ALL ((1 << 1)-1)+ uint64_t change_mask; /**< bitfield of changed fields since last call */+ struct spa_dict *props; /**< extra properties */+};++/** Update an existing \ref pw_client_info with \a update with reset */+struct pw_client_info *+pw_client_info_update(struct pw_client_info *info,+ const struct pw_client_info *update);+/** Merge an existing \ref pw_client_info with \a update */+struct pw_client_info *+pw_client_info_merge(struct pw_client_info *info,+ const struct pw_client_info *update, bool reset);+/** Free a \ref pw_client_info */+void pw_client_info_free(struct pw_client_info *info);+++#define PW_CLIENT_EVENT_INFO 0+#define PW_CLIENT_EVENT_PERMISSIONS 1+#define PW_CLIENT_EVENT_NUM 2++/** Client events */+struct pw_client_events {+#define PW_VERSION_CLIENT_EVENTS 0+ uint32_t version;+ /**+ * Notify client info+ *+ * \param info info about the client+ */+ void (*info) (void *data, const struct pw_client_info *info);+ /**+ * Notify a client permission+ *+ * Event emitted as a result of the get_permissions method.+ *+ * \param default_permissions the default permissions+ * \param index the index of the first permission entry+ * \param n_permissions the number of permissions+ * \param permissions the permissions+ */+ void (*permissions) (void *data,+ uint32_t index,+ uint32_t n_permissions,+ const struct pw_permission *permissions);+};+++#define PW_CLIENT_METHOD_ADD_LISTENER 0+#define PW_CLIENT_METHOD_ERROR 1+#define PW_CLIENT_METHOD_UPDATE_PROPERTIES 2+#define PW_CLIENT_METHOD_GET_PERMISSIONS 3+#define PW_CLIENT_METHOD_UPDATE_PERMISSIONS 4+#define PW_CLIENT_METHOD_NUM 5++/** Client methods */+struct pw_client_methods {+#define PW_VERSION_CLIENT_METHODS 0+ uint32_t version;++ int (*add_listener) (void *object,+ struct spa_hook *listener,+ const struct pw_client_events *events,+ void *data);+ /**+ * Send an error to a client+ *+ * \param id the global id to report the error on+ * \param res an errno style error code+ * \param message an error string+ *+ * This requires W and X permissions on the client.+ */+ int (*error) (void *object, uint32_t id, int res, const char *message);+ /**+ * Update client properties+ *+ * \param props new properties+ *+ * This requires W and X permissions on the client.+ */+ int (*update_properties) (void *object, const struct spa_dict *props);++ /**+ * Get client permissions+ *+ * A permissions event will be emitted with the permissions.+ *+ * \param index the first index to query, 0 for first+ * \param num the maximum number of items to get+ *+ * This requires W and X permissions on the client.+ */+ int (*get_permissions) (void *object, uint32_t index, uint32_t num);+ /**+ * Manage the permissions of the global objects for this+ * client+ *+ * Update the permissions of the global objects using the+ * provided array with permissions+ *+ * Globals can use the default permissions or can have specific+ * permissions assigned to them.+ *+ * \param n_permissions number of permissions+ * \param permissions array of permissions+ *+ * This requires W and X permissions on the client.+ */+ int (*update_permissions) (void *object, uint32_t n_permissions,+ const struct pw_permission *permissions);+};++#define pw_client_method(o,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ spa_interface_call_res((struct spa_interface*)o, \+ struct pw_client_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++#define pw_client_add_listener(c,...) pw_client_method(c,add_listener,0,__VA_ARGS__)+#define pw_client_error(c,...) pw_client_method(c,error,0,__VA_ARGS__)+#define pw_client_update_properties(c,...) pw_client_method(c,update_properties,0,__VA_ARGS__)+#define pw_client_get_permissions(c,...) pw_client_method(c,get_permissions,0,__VA_ARGS__)+#define pw_client_update_permissions(c,...) pw_client_method(c,update_permissions,0,__VA_ARGS__)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* PIPEWIRE_CLIENT_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/conf.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/conf.hnew file mode 100644index 000000000..6031f3c44--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/conf.h@@ -0,0 +1,47 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2021 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_CONF_H+#define PIPEWIRE_CONF_H++#include <pipewire/context.h>++/** \defgroup pw_conf Configuration+ * Loading/saving properties from/to configuration files.+ */++/**+ * \addtogroup pw_conf+ * \{+ */++int pw_conf_load_conf_for_context(struct pw_properties *props, struct pw_properties *conf);+int pw_conf_load_conf(const char *prefix, const char *name, struct pw_properties *conf);+int pw_conf_load_state(const char *prefix, const char *name, struct pw_properties *conf);+int pw_conf_save_state(const char *prefix, const char *name, const struct pw_properties *conf);++int pw_conf_section_update_props(const struct spa_dict *conf,+ const char *section, struct pw_properties *props);++int pw_conf_section_for_each(const struct spa_dict *conf, const char *section,+ int (*callback) (void *data, const char *location, const char *section,+ const char *str, size_t len),+ void *data);++int pw_conf_match_rules(const char *str, size_t len, const char *location,+ const struct spa_dict *props,+ int (*callback) (void *data, const char *location, const char *action,+ const char *str, size_t len),+ void *data);++int pw_conf_section_match_rules(const struct spa_dict *conf, const char *section,+ const struct spa_dict *props,+ int (*callback) (void *data, const char *location, const char *action,+ const char *str, size_t len),+ void *data);+/**+ * \}+ */++#endif /* PIPEWIRE_CONF_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/context.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/context.hnew file mode 100644index 000000000..3adfe35d6--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/context.h@@ -0,0 +1,184 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_CONTEXT_H+#define PIPEWIRE_CONTEXT_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>+#include <spa/utils/hook.h>++/** \defgroup pw_context Context+ *+ * \brief The PipeWire context object manages all locally available+ * resources. It is used by both clients and servers.+ *+ * The context is used to:+ *+ * - Load modules and extend the functionality. This includes+ * extending the protocol with new object types or creating+ * any of the available objects.+ *+ * - Create implementations of various objects like nodes,+ * devices, factories, modules, etc.. This will usually also+ * create pw_global objects that can then be shared with+ * clients.+ *+ * - Connect to another PipeWire instance (the main daemon, for+ * example) and interact with it (See \ref page_core_api).+ *+ * - Export a local implementation of an object to another+ * instance.+ */++/**+ * \addtogroup pw_context+ * @{+ */+struct pw_context;++struct pw_global;+struct pw_impl_client;+struct pw_impl_node;++#include <pipewire/core.h>+#include <pipewire/loop.h>+#include <pipewire/properties.h>++/** context events emitted by the context object added with \ref pw_context_add_listener */+struct pw_context_events {+#define PW_VERSION_CONTEXT_EVENTS 1+ uint32_t version;++ /** The context is being destroyed */+ void (*destroy) (void *data);+ /** The context is being freed */+ void (*free) (void *data);+ /** a new client object is added */+ void (*check_access) (void *data, struct pw_impl_client *client);+ /** a new global object was added */+ void (*global_added) (void *data, struct pw_global *global);+ /** a global object was removed */+ void (*global_removed) (void *data, struct pw_global *global);++ /** a driver was added, since 0.3.75 version:1 */+ void (*driver_added) (void *data, struct pw_impl_node *node);+ /** a driver was removed, since 0.3.75 version:1 */+ void (*driver_removed) (void *data, struct pw_impl_node *node);+};++/** Make a new context object for a given main_loop. Ownership of the properties is taken */+struct pw_context * pw_context_new(struct pw_loop *main_loop, /**< a main loop to run in */+ struct pw_properties *props, /**< extra properties */+ size_t user_data_size /**< extra user data size */);++/** destroy a context object, all resources except the main_loop will be destroyed */+void pw_context_destroy(struct pw_context *context);++/** Get the context user data */+void *pw_context_get_user_data(struct pw_context *context);++/** Add a new event listener to a context */+void pw_context_add_listener(struct pw_context *context,+ struct spa_hook *listener,+ const struct pw_context_events *events,+ void *data);++/** Get the context properties */+const struct pw_properties *pw_context_get_properties(struct pw_context *context);++/** Update the context properties */+int pw_context_update_properties(struct pw_context *context, const struct spa_dict *dict);++/** Get a config section for this context. Since 0.3.22, deprecated,+ * use pw_context_conf_section_for_each(). */+const char *pw_context_get_conf_section(struct pw_context *context, const char *section);+/** Parse a standard config section for this context. Since 0.3.22 */+int pw_context_parse_conf_section(struct pw_context *context,+ struct pw_properties *conf, const char *section);++/** update properties from a section into props. Since 0.3.45 */+int pw_context_conf_update_props(struct pw_context *context, const char *section,+ struct pw_properties *props);+/** emit callback for all config sections. Since 0.3.45 */+int pw_context_conf_section_for_each(struct pw_context *context, const char *section,+ int (*callback) (void *data, const char *location, const char *section,+ const char *str, size_t len),+ void *data);+/** emit callback for all matched properties. Since 0.3.46 */+int pw_context_conf_section_match_rules(struct pw_context *context, const char *section,+ const struct spa_dict *props,+ int (*callback) (void *data, const char *location, const char *action,+ const char *str, size_t len),+ void *data);++/** Get the context support objects */+const struct spa_support *pw_context_get_support(struct pw_context *context, uint32_t *n_support);++/** get the context main loop */+struct pw_loop *pw_context_get_main_loop(struct pw_context *context);++/** get the context data loop. Since 0.3.56 */+struct pw_data_loop *pw_context_get_data_loop(struct pw_context *context);++/** Get the work queue from the context: Since 0.3.26 */+struct pw_work_queue *pw_context_get_work_queue(struct pw_context *context);++/** Get the memmory pool from the context: Since 0.3.74 */+struct pw_mempool *pw_context_get_mempool(struct pw_context *context);++/** Iterate the globals of the context. The callback should return+ * 0 to fetch the next item, any other value stops the iteration and returns+ * the value. When all callbacks return 0, this function returns 0 when all+ * globals are iterated. */+int pw_context_for_each_global(struct pw_context *context,+ int (*callback) (void *data, struct pw_global *global),+ void *data);++/** Find a context global by id */+struct pw_global *pw_context_find_global(struct pw_context *context, /**< the context */+ uint32_t id /**< the global id */);++/** add a spa library for the given factory_name regex */+int pw_context_add_spa_lib(struct pw_context *context, const char *factory_regex, const char *lib);++/** find the library name for a spa factory */+const char * pw_context_find_spa_lib(struct pw_context *context, const char *factory_name);++struct spa_handle *pw_context_load_spa_handle(struct pw_context *context,+ const char *factory_name,+ const struct spa_dict *info);+++/** data for registering export functions */+struct pw_export_type {+ struct spa_list link;+ const char *type;+ struct pw_proxy * (*func) (struct pw_core *core,+ const char *type, const struct spa_dict *props, void *object,+ size_t user_data_size);+};++/** register a type that can be exported on a context_proxy. This is usually used by+ * extension modules */+int pw_context_register_export_type(struct pw_context *context, struct pw_export_type *type);+/** find information about registered export type */+const struct pw_export_type *pw_context_find_export_type(struct pw_context *context, const char *type);++/** add an object to the context */+int pw_context_set_object(struct pw_context *context, const char *type, void *value);+/** get an object from the context */+void *pw_context_get_object(struct pw_context *context, const char *type);++/**+ * \}+ */+#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_CONTEXT_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/core.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/core.hnew file mode 100644index 000000000..2b5fa2745--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/core.h@@ -0,0 +1,629 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_CORE_H+#define PIPEWIRE_CORE_H++#ifdef __cplusplus+extern "C" {+#endif++#include <stdarg.h>+#include <errno.h>++#include <spa/utils/hook.h>++/** \defgroup pw_core Core+ *+ * \brief The core global object.+ *+ * This is a special singleton object. It is used for internal PipeWire+ * protocol features. Connecting to a PipeWire instance returns one core+ * object, the caller should then register event listeners+ * using \ref pw_core_add_listener.+ *+ * Updates to the core object are then provided through the \ref+ * pw_core_events interface. See \ref page_tutorial2 for an example.+ */++/**+ * \addtogroup pw_core+ * \{+ */+#define PW_TYPE_INTERFACE_Core PW_TYPE_INFO_INTERFACE_BASE "Core"+#define PW_TYPE_INTERFACE_Registry PW_TYPE_INFO_INTERFACE_BASE "Registry"++#define PW_CORE_PERM_MASK PW_PERM_R|PW_PERM_X|PW_PERM_M++#define PW_VERSION_CORE 4+struct pw_core;+#define PW_VERSION_REGISTRY 3+struct pw_registry;++/** The default remote name to connect to */+#define PW_DEFAULT_REMOTE "pipewire-0"++/** default ID for the core object after connect */+#define PW_ID_CORE 0++/* invalid ID that matches any object when used for permissions */+#define PW_ID_ANY (uint32_t)(0xffffffff)++/** The core information. Extra information may be added in later versions,+ * clients must not assume a constant struct size */+struct pw_core_info {+ uint32_t id; /**< id of the global */+ uint32_t cookie; /**< a random cookie for identifying this instance of PipeWire */+ const char *user_name; /**< name of the user that started the core */+ const char *host_name; /**< name of the machine the core is running on */+ const char *version; /**< version of the core */+ const char *name; /**< name of the core */+#define PW_CORE_CHANGE_MASK_PROPS (1 << 0)+#define PW_CORE_CHANGE_MASK_ALL ((1 << 1)-1)+ uint64_t change_mask; /**< bitfield of changed fields since last call */+ struct spa_dict *props; /**< extra properties */+};++#include <pipewire/context.h>+#include <pipewire/properties.h>+#include <pipewire/proxy.h>++/** Update an existing \ref pw_core_info with \a update with reset */+struct pw_core_info *+pw_core_info_update(struct pw_core_info *info,+ const struct pw_core_info *update);+/** Update an existing \ref pw_core_info with \a update */+struct pw_core_info *+pw_core_info_merge(struct pw_core_info *info,+ const struct pw_core_info *update, bool reset);+/** Free a \ref pw_core_info */+void pw_core_info_free(struct pw_core_info *info);++/** Core */++#define PW_CORE_EVENT_INFO 0+#define PW_CORE_EVENT_DONE 1+#define PW_CORE_EVENT_PING 2+#define PW_CORE_EVENT_ERROR 3+#define PW_CORE_EVENT_REMOVE_ID 4+#define PW_CORE_EVENT_BOUND_ID 5+#define PW_CORE_EVENT_ADD_MEM 6+#define PW_CORE_EVENT_REMOVE_MEM 7+#define PW_CORE_EVENT_BOUND_PROPS 8+#define PW_CORE_EVENT_NUM 9++/** \struct pw_core_events+ * \brief Core events+ */+struct pw_core_events {+#define PW_VERSION_CORE_EVENTS 1+ uint32_t version;++ /**+ * Notify new core info+ *+ * This event is emitted when first bound to the core or when the+ * hello method is called.+ *+ * \param info new core info+ */+ void (*info) (void *data, const struct pw_core_info *info);+ /**+ * Emit a done event+ *+ * The done event is emitted as a result of a sync method with the+ * same seq number.+ *+ * \param seq the seq number passed to the sync method call+ */+ void (*done) (void *data, uint32_t id, int seq);++ /** Emit a ping event+ *+ * The client should reply with a pong reply with the same seq+ * number.+ */+ void (*ping) (void *data, uint32_t id, int seq);++ /**+ * Fatal error event+ *+ * The error event is sent out when a fatal (non-recoverable)+ * error has occurred. The id argument is the proxy object where+ * the error occurred, most often in response to a request to that+ * object. The message is a brief description of the error,+ * for (debugging) convenience.+ *+ * This event is usually also emitted on the proxy object with+ * \a id.+ *+ * \param id object where the error occurred+ * \param seq the sequence number that generated the error+ * \param res error code+ * \param message error description+ */+ void (*error) (void *data, uint32_t id, int seq, int res, const char *message);+ /**+ * Remove an object ID+ *+ * This event is used internally by the object ID management+ * logic. When a client deletes an object, the server will send+ * this event to acknowledge that it has seen the delete request.+ * When the client receives this event, it will know that it can+ * safely reuse the object ID.+ *+ * \param id deleted object ID+ */+ void (*remove_id) (void *data, uint32_t id);++ /**+ * Notify an object binding+ *+ * This event is emitted when a local object ID is bound to a+ * global ID. It is emitted before the global becomes visible in the+ * registry.+ *+ * \param id bound object ID+ * \param global_id the global id bound to+ */+ void (*bound_id) (void *data, uint32_t id, uint32_t global_id);++ /**+ * Add memory for a client+ *+ * Memory is given to a client as \a fd of a certain+ * memory \a type.+ *+ * Further references to this fd will be made with the per memory+ * unique identifier \a id.+ *+ * \param id the unique id of the memory+ * \param type the memory type, one of enum spa_data_type+ * \param fd the file descriptor+ * \param flags extra flags+ */+ void (*add_mem) (void *data, uint32_t id, uint32_t type, int fd, uint32_t flags);++ /**+ * Remove memory for a client+ *+ * \param id the memory id to remove+ */+ void (*remove_mem) (void *data, uint32_t id);++ void (*bound_props) (void *data, uint32_t id, uint32_t global_id, const struct spa_dict *props);+};++#define PW_CORE_METHOD_ADD_LISTENER 0+#define PW_CORE_METHOD_HELLO 1+#define PW_CORE_METHOD_SYNC 2+#define PW_CORE_METHOD_PONG 3+#define PW_CORE_METHOD_ERROR 4+#define PW_CORE_METHOD_GET_REGISTRY 5+#define PW_CORE_METHOD_CREATE_OBJECT 6+#define PW_CORE_METHOD_DESTROY 7+#define PW_CORE_METHOD_NUM 8++/**+ * \struct pw_core_methods+ * \brief Core methods+ *+ * The core global object. This is a singleton object used for+ * creating new objects in the remote PipeWire instance. It is+ * also used for internal features.+ */+struct pw_core_methods {+#define PW_VERSION_CORE_METHODS 0+ uint32_t version;++ int (*add_listener) (void *object,+ struct spa_hook *listener,+ const struct pw_core_events *events,+ void *data);+ /**+ * Start a conversation with the server. This will send+ * the core info and will destroy all resources for the client+ * (except the core and client resource).+ *+ * This requires X permissions on the core.+ */+ int (*hello) (void *object, uint32_t version);+ /**+ * Do server roundtrip+ *+ * Ask the server to emit the 'done' event with \a seq.+ *+ * Since methods are handled in-order and events are delivered+ * in-order, this can be used as a barrier to ensure all previous+ * methods and the resulting events have been handled.+ *+ * \param seq the seq number passed to the done event+ *+ * This requires X permissions on the core.+ */+ int (*sync) (void *object, uint32_t id, int seq);+ /**+ * Reply to a server ping event.+ *+ * Reply to the server ping event with the same seq.+ *+ * \param seq the seq number received in the ping event+ *+ * This requires X permissions on the core.+ */+ int (*pong) (void *object, uint32_t id, int seq);+ /**+ * Fatal error event+ *+ * The error method is sent out when a fatal (non-recoverable)+ * error has occurred. The id argument is the proxy object where+ * the error occurred, most often in response to an event on that+ * object. The message is a brief description of the error,+ * for (debugging) convenience.+ *+ * This method is usually also emitted on the resource object with+ * \a id.+ *+ * \param id resource id where the error occurred+ * \param res error code+ * \param message error description+ *+ * This requires X permissions on the core.+ */+ int (*error) (void *object, uint32_t id, int seq, int res, const char *message);+ /**+ * Get the registry object+ *+ * Create a registry object that allows the client to list and bind+ * the global objects available from the PipeWire server+ * \param version the client version+ * \param user_data_size extra size+ *+ * This requires X permissions on the core.+ */+ struct pw_registry * (*get_registry) (void *object, uint32_t version,+ size_t user_data_size);++ /**+ * Create a new object on the PipeWire server from a factory.+ *+ * \param factory_name the factory name to use+ * \param type the interface to bind to+ * \param version the version of the interface+ * \param props extra properties+ * \param user_data_size extra size+ *+ * This requires X permissions on the core.+ */+ void * (*create_object) (void *object,+ const char *factory_name,+ const char *type,+ uint32_t version,+ const struct spa_dict *props,+ size_t user_data_size);+ /**+ * Destroy an resource+ *+ * Destroy the server resource for the given proxy.+ *+ * \param obj the proxy to destroy+ *+ * This requires X permissions on the core.+ */+ int (*destroy) (void *object, void *proxy);+};++#define pw_core_method(o,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ spa_interface_call_res((struct spa_interface*)o, \+ struct pw_core_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++#define pw_core_add_listener(c,...) pw_core_method(c,add_listener,0,__VA_ARGS__)+#define pw_core_hello(c,...) pw_core_method(c,hello,0,__VA_ARGS__)+#define pw_core_sync(c,...) pw_core_method(c,sync,0,__VA_ARGS__)+#define pw_core_pong(c,...) pw_core_method(c,pong,0,__VA_ARGS__)+#define pw_core_error(c,...) pw_core_method(c,error,0,__VA_ARGS__)+++static inline+SPA_PRINTF_FUNC(5, 0) int+pw_core_errorv(struct pw_core *core, uint32_t id, int seq,+ int res, const char *message, va_list args)+{+ char buffer[1024];+ vsnprintf(buffer, sizeof(buffer), message, args);+ buffer[1023] = '\0';+ return pw_core_error(core, id, seq, res, buffer);+}++static inline+SPA_PRINTF_FUNC(5, 6) int+pw_core_errorf(struct pw_core *core, uint32_t id, int seq,+ int res, const char *message, ...)+{+ va_list args;+ int r;+ va_start(args, message);+ r = pw_core_errorv(core, id, seq, res, message, args);+ va_end(args);+ return r;+}++static inline struct pw_registry *+pw_core_get_registry(struct pw_core *core, uint32_t version, size_t user_data_size)+{+ struct pw_registry *res = NULL;+ spa_interface_call_res((struct spa_interface*)core,+ struct pw_core_methods, res,+ get_registry, 0, version, user_data_size);+ return res;+}++static inline void *+pw_core_create_object(struct pw_core *core,+ const char *factory_name,+ const char *type,+ uint32_t version,+ const struct spa_dict *props,+ size_t user_data_size)+{+ void *res = NULL;+ spa_interface_call_res((struct spa_interface*)core,+ struct pw_core_methods, res,+ create_object, 0, factory_name,+ type, version, props, user_data_size);+ return res;+}++#define pw_core_destroy(c,...) pw_core_method(c,destroy,0,__VA_ARGS__)++/**+ * \}+ */++/** \defgroup pw_registry Registry+ *+ * The registry object is a singleton object that keeps track of+ * global objects on the PipeWire instance. See also \ref pw_global.+ *+ * Global objects typically represent an actual object in PipeWire+ * (for example, a module or node) or they are singleton+ * objects such as the core.+ *+ * When a client creates a registry object, the registry object+ * will emit a global event for each global currently in the+ * registry. Globals come and go as a result of device hotplugs or+ * reconfiguration or other events, and the registry will send out+ * global and global_remove events to keep the client up to date+ * with the changes. To mark the end of the initial burst of+ * events, the client can use the pw_core.sync methosd immediately+ * after calling pw_core.get_registry.+ *+ * A client can bind to a global object by using the bind+ * request. This creates a client-side proxy that lets the object+ * emit events to the client and lets the client invoke methods on+ * the object. See \ref page_proxy+ *+ * Clients can also change the permissions of the global objects that+ * it can see. This is interesting when you want to configure a+ * pipewire session before handing it to another application. You+ * can, for example, hide certain existing or new objects or limit+ * the access permissions on an object.+ */++/**+ * \addtogroup pw_registry+ * \{+ */++#define PW_REGISTRY_EVENT_GLOBAL 0+#define PW_REGISTRY_EVENT_GLOBAL_REMOVE 1+#define PW_REGISTRY_EVENT_NUM 2++/** Registry events */+struct pw_registry_events {+#define PW_VERSION_REGISTRY_EVENTS 0+ uint32_t version;+ /**+ * Notify of a new global object+ *+ * The registry emits this event when a new global object is+ * available.+ *+ * \param id the global object id+ * \param permissions the permissions of the object+ * \param type the type of the interface+ * \param version the version of the interface+ * \param props extra properties of the global+ */+ void (*global) (void *data, uint32_t id,+ uint32_t permissions, const char *type, uint32_t version,+ const struct spa_dict *props);+ /**+ * Notify of a global object removal+ *+ * Emitted when a global object was removed from the registry.+ * If the client has any bindings to the global, it should destroy+ * those.+ *+ * \param id the id of the global that was removed+ */+ void (*global_remove) (void *data, uint32_t id);+};++#define PW_REGISTRY_METHOD_ADD_LISTENER 0+#define PW_REGISTRY_METHOD_BIND 1+#define PW_REGISTRY_METHOD_DESTROY 2+#define PW_REGISTRY_METHOD_NUM 3++/** Registry methods */+struct pw_registry_methods {+#define PW_VERSION_REGISTRY_METHODS 0+ uint32_t version;++ int (*add_listener) (void *object,+ struct spa_hook *listener,+ const struct pw_registry_events *events,+ void *data);+ /**+ * Bind to a global object+ *+ * Bind to the global object with \a id and use the client proxy+ * with new_id as the proxy. After this call, methods can be+ * send to the remote global object and events can be received+ *+ * \param id the global id to bind to+ * \param type the interface type to bind to+ * \param version the interface version to use+ * \returns the new object+ */+ void * (*bind) (void *object, uint32_t id, const char *type, uint32_t version,+ size_t use_data_size);++ /**+ * Attempt to destroy a global object+ *+ * Try to destroy the global object.+ *+ * \param id the global id to destroy. The client needs X permissions+ * on the global.+ */+ int (*destroy) (void *object, uint32_t id);+};++#define pw_registry_method(o,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ spa_interface_call_res((struct spa_interface*)o, \+ struct pw_registry_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++/** Registry */+#define pw_registry_add_listener(p,...) pw_registry_method(p,add_listener,0,__VA_ARGS__)++static inline void *+pw_registry_bind(struct pw_registry *registry,+ uint32_t id, const char *type, uint32_t version,+ size_t user_data_size)+{+ void *res = NULL;+ spa_interface_call_res((struct spa_interface*)registry,+ struct pw_registry_methods, res,+ bind, 0, id, type, version, user_data_size);+ return res;+}++#define pw_registry_destroy(p,...) pw_registry_method(p,destroy,0,__VA_ARGS__)++/**+ * \}+ */++/**+ * \addtogroup pw_core+ * \{+ */++/** Connect to a PipeWire instance+ *+ * \param context a \ref pw_context+ * \param properties optional properties, ownership of the properties is+ * taken.+ * \param user_data_size extra user data size+ *+ * \return a \ref pw_core on success or NULL with errno set on error. The core+ * will have an id of \ref PW_ID_CORE (0)+ */+struct pw_core *+pw_context_connect(struct pw_context *context,+ struct pw_properties *properties,+ size_t user_data_size);++/** Connect to a PipeWire instance on the given socket+ *+ * \param context a \ref pw_context+ * \param fd the connected socket to use, the socket will be closed+ * automatically on disconnect or error.+ * \param properties optional properties, ownership of the properties is+ * taken.+ * \param user_data_size extra user data size+ *+ * \return a \ref pw_core on success or NULL with errno set on error */+struct pw_core *+pw_context_connect_fd(struct pw_context *context,+ int fd,+ struct pw_properties *properties,+ size_t user_data_size);++/** Connect to a given PipeWire instance+ *+ * \param context a \ref pw_context to connect to+ * \param properties optional properties, ownership of the properties is+ * taken.+ * \param user_data_size extra user data size+ *+ * \return a \ref pw_core on success or NULL with errno set on error */+struct pw_core *+pw_context_connect_self(struct pw_context *context,+ struct pw_properties *properties,+ size_t user_data_size);++/** Steal the fd of the core connection or < 0 on error. The core+ * will be disconnected after this call. */+int pw_core_steal_fd(struct pw_core *core);++/** Pause or resume the core. When the core is paused, no new events+ * will be dispatched until the core is resumed again. */+int pw_core_set_paused(struct pw_core *core, bool paused);++/** disconnect and destroy a core */+int pw_core_disconnect(struct pw_core *core);++/** Get the user_data. It is of the size specified when this object was+ * constructed */+void *pw_core_get_user_data(struct pw_core *core);++/** Get the client proxy of the connected core. This will have the id+ * of PW_ID_CLIENT (1) */+struct pw_client * pw_core_get_client(struct pw_core *core);++/** Get the context object used to created this core */+struct pw_context * pw_core_get_context(struct pw_core *core);++/** Get properties from the core */+const struct pw_properties *pw_core_get_properties(struct pw_core *core);++/** Update the core properties. This updates the properties+ * of the associated client.+ * \return the number of properties that were updated */+int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict);++/** Get the core mempool object */+struct pw_mempool * pw_core_get_mempool(struct pw_core *core);++/** Get the proxy with the given id */+struct pw_proxy *pw_core_find_proxy(struct pw_core *core, uint32_t id);++/** Export an object into the PipeWire instance associated with core */+struct pw_proxy *pw_core_export(struct pw_core *core, /**< the core */+ const char *type, /**< the type of object */+ const struct spa_dict *props, /**< extra properties */+ void *object, /**< object to export */+ size_t user_data_size /**< extra user data */);++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_CORE_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/data-loop.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/data-loop.hnew file mode 100644index 000000000..5ded69028--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/data-loop.h@@ -0,0 +1,93 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_DATA_LOOP_H+#define PIPEWIRE_DATA_LOOP_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/hook.h>+#include <spa/support/thread.h>++/** \defgroup pw_data_loop Data Loop+ *+ * \brief PipeWire rt-loop object+ *+ * This loop starts a new real-time thread that+ * is designed to run the processing graph.+ */++/**+ * \addtogroup pw_data_loop+ * \{+ */+struct pw_data_loop;++#include <pipewire/loop.h>+#include <pipewire/properties.h>++/** Loop events, use \ref pw_data_loop_add_listener to add a listener */+struct pw_data_loop_events {+#define PW_VERSION_DATA_LOOP_EVENTS 0+ uint32_t version;+ /** The loop is destroyed */+ void (*destroy) (void *data);+};++/** Make a new loop. */+struct pw_data_loop *+pw_data_loop_new(const struct spa_dict *props);++/** Add an event listener to loop */+void pw_data_loop_add_listener(struct pw_data_loop *loop,+ struct spa_hook *listener,+ const struct pw_data_loop_events *events,+ void *data);++/** wait for activity on the loop up to \a timeout milliseconds.+ * Should be called from the loop function */+int pw_data_loop_wait(struct pw_data_loop *loop, int timeout);++/** make sure the thread will exit. Can be called from a loop callback */+void pw_data_loop_exit(struct pw_data_loop *loop);++/** Get the loop implementation of this data loop */+struct pw_loop *+pw_data_loop_get_loop(struct pw_data_loop *loop);++/** Destroy the loop */+void pw_data_loop_destroy(struct pw_data_loop *loop);++/** Start the processing thread */+int pw_data_loop_start(struct pw_data_loop *loop);++/** Stop the processing thread */+int pw_data_loop_stop(struct pw_data_loop *loop);++/** Check if the current thread is the processing thread */+bool pw_data_loop_in_thread(struct pw_data_loop *loop);+/** Get the thread object */+struct spa_thread *pw_data_loop_get_thread(struct pw_data_loop *loop);++/** invoke func in the context of the thread or in the caller thread when+ * the loop is not running. Since 0.3.3 */+int pw_data_loop_invoke(struct pw_data_loop *loop,+ spa_invoke_func_t func, uint32_t seq, const void *data, size_t size,+ bool block, void *user_data);++/** Set a custom spa_thread_utils for this loop. Setting NULL restores the+ * system default implementation. Since 0.3.50 */+void pw_data_loop_set_thread_utils(struct pw_data_loop *loop,+ struct spa_thread_utils *impl);+/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_DATA_LOOP_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/device.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/device.hnew file mode 100644index 000000000..4b546b994--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/device.h@@ -0,0 +1,166 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_DEVICE_H+#define PIPEWIRE_DEVICE_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>+#include <spa/utils/hook.h>++#include <pipewire/proxy.h>++/** \defgroup pw_device Device+ * Device interface+ */++/**+ * \addtogroup pw_device+ * \{+ */++#define PW_TYPE_INTERFACE_Device PW_TYPE_INFO_INTERFACE_BASE "Device"++#define PW_DEVICE_PERM_MASK PW_PERM_RWXM++#define PW_VERSION_DEVICE 3+struct pw_device;++/** The device information. Extra information can be added in later versions */+struct pw_device_info {+ uint32_t id; /**< id of the global */+#define PW_DEVICE_CHANGE_MASK_PROPS (1 << 0)+#define PW_DEVICE_CHANGE_MASK_PARAMS (1 << 1)+#define PW_DEVICE_CHANGE_MASK_ALL ((1 << 2)-1)+ uint64_t change_mask; /**< bitfield of changed fields since last call */+ struct spa_dict *props; /**< extra properties */+ struct spa_param_info *params; /**< parameters */+ uint32_t n_params; /**< number of items in \a params */+};++/** Update and existing \ref pw_device_info with \a update and reset */+struct pw_device_info *+pw_device_info_update(struct pw_device_info *info,+ const struct pw_device_info *update);+/** Merge and existing \ref pw_device_info with \a update */+struct pw_device_info *+pw_device_info_merge(struct pw_device_info *info,+ const struct pw_device_info *update, bool reset);+/** Free a \ref pw_device_info */+void pw_device_info_free(struct pw_device_info *info);++#define PW_DEVICE_EVENT_INFO 0+#define PW_DEVICE_EVENT_PARAM 1+#define PW_DEVICE_EVENT_NUM 2++/** Device events */+struct pw_device_events {+#define PW_VERSION_DEVICE_EVENTS 0+ uint32_t version;+ /**+ * Notify device info+ *+ * \param info info about the device+ */+ void (*info) (void *data, const struct pw_device_info *info);+ /**+ * Notify a device param+ *+ * Event emitted as a result of the enum_params method.+ *+ * \param seq the sequence number of the request+ * \param id the param id+ * \param index the param index+ * \param next the param index of the next param+ * \param param the parameter+ */+ void (*param) (void *data, int seq,+ uint32_t id, uint32_t index, uint32_t next,+ const struct spa_pod *param);+};+++#define PW_DEVICE_METHOD_ADD_LISTENER 0+#define PW_DEVICE_METHOD_SUBSCRIBE_PARAMS 1+#define PW_DEVICE_METHOD_ENUM_PARAMS 2+#define PW_DEVICE_METHOD_SET_PARAM 3+#define PW_DEVICE_METHOD_NUM 4++/** Device methods */+struct pw_device_methods {+#define PW_VERSION_DEVICE_METHODS 0+ uint32_t version;++ int (*add_listener) (void *object,+ struct spa_hook *listener,+ const struct pw_device_events *events,+ void *data);+ /**+ * Subscribe to parameter changes+ *+ * Automatically emit param events for the given ids when+ * they are changed.+ *+ * \param ids an array of param ids+ * \param n_ids the number of ids in \a ids+ *+ * This requires X permissions on the device.+ */+ int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);++ /**+ * Enumerate device parameters+ *+ * Start enumeration of device parameters. For each param, a+ * param event will be emitted.+ *+ * \param seq a sequence number to place in the reply+ * \param id the parameter id to enum or PW_ID_ANY for all+ * \param start the start index or 0 for the first param+ * \param num the maximum number of params to retrieve+ * \param filter a param filter or NULL+ *+ * This requires X permissions on the device.+ */+ int (*enum_params) (void *object, int seq, uint32_t id, uint32_t start, uint32_t num,+ const struct spa_pod *filter);+ /**+ * Set a parameter on the device+ *+ * \param id the parameter id to set+ * \param flags extra parameter flags+ * \param param the parameter to set+ *+ * This requires W and X permissions on the device.+ */+ int (*set_param) (void *object, uint32_t id, uint32_t flags,+ const struct spa_pod *param);+};++#define pw_device_method(o,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ spa_interface_call_res((struct spa_interface*)o, \+ struct pw_device_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++#define pw_device_add_listener(c,...) pw_device_method(c,add_listener,0,__VA_ARGS__)+#define pw_device_subscribe_params(c,...) pw_device_method(c,subscribe_params,0,__VA_ARGS__)+#define pw_device_enum_params(c,...) pw_device_method(c,enum_params,0,__VA_ARGS__)+#define pw_device_set_param(c,...) pw_device_method(c,set_param,0,__VA_ARGS__)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* PIPEWIRE_DEVICE_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/factory.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/factory.hnew file mode 100644index 000000000..6eda0420d--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/factory.h@@ -0,0 +1,105 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_FACTORY_H+#define PIPEWIRE_FACTORY_H++#ifdef __cplusplus+extern "C" {+#endif++#include <stdarg.h>+#include <errno.h>++#include <spa/utils/defs.h>+#include <spa/utils/hook.h>++#include <pipewire/proxy.h>++/** \defgroup pw_factory Factory+ * Factory interface+ */++/**+ * \addtogroup pw_factory+ * \{+ */+#define PW_TYPE_INTERFACE_Factory PW_TYPE_INFO_INTERFACE_BASE "Factory"++#define PW_FACTORY_PERM_MASK PW_PERM_R|PW_PERM_M++#define PW_VERSION_FACTORY 3+struct pw_factory;++/** The factory information. Extra information can be added in later versions */+struct pw_factory_info {+ uint32_t id; /**< id of the global */+ const char *name; /**< name the factory */+ const char *type; /**< type of the objects created by this factory */+ uint32_t version; /**< version of the objects */+#define PW_FACTORY_CHANGE_MASK_PROPS (1 << 0)+#define PW_FACTORY_CHANGE_MASK_ALL ((1 << 1)-1)+ uint64_t change_mask; /**< bitfield of changed fields since last call */+ struct spa_dict *props; /**< the properties of the factory */+};++struct pw_factory_info *+pw_factory_info_update(struct pw_factory_info *info,+ const struct pw_factory_info *update);+struct pw_factory_info *+pw_factory_info_merge(struct pw_factory_info *info,+ const struct pw_factory_info *update, bool reset);+void+pw_factory_info_free(struct pw_factory_info *info);+++#define PW_FACTORY_EVENT_INFO 0+#define PW_FACTORY_EVENT_NUM 1++/** Factory events */+struct pw_factory_events {+#define PW_VERSION_FACTORY_EVENTS 0+ uint32_t version;+ /**+ * Notify factory info+ *+ * \param info info about the factory+ */+ void (*info) (void *data, const struct pw_factory_info *info);+};++#define PW_FACTORY_METHOD_ADD_LISTENER 0+#define PW_FACTORY_METHOD_NUM 1++/** Factory methods */+struct pw_factory_methods {+#define PW_VERSION_FACTORY_METHODS 0+ uint32_t version;++ int (*add_listener) (void *object,+ struct spa_hook *listener,+ const struct pw_factory_events *events,+ void *data);+};++#define pw_factory_method(o,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ spa_interface_call_res((struct spa_interface*)o, \+ struct pw_factory_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++#define pw_factory_add_listener(c,...) pw_factory_method(c,add_listener,0,__VA_ARGS__)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* PIPEWIRE_FACTORY_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/filter.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/filter.hnew file mode 100644index 000000000..3a619e80a--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/filter.h@@ -0,0 +1,257 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2019 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_FILTER_H+#define PIPEWIRE_FILTER_H++#ifdef __cplusplus+extern "C" {+#endif++/** \defgroup pw_filter Filter+ *+ * \brief PipeWire filter object class+ *+ * The filter object provides a convenient way to implement+ * processing filters.+ *+ * See also \ref api_pw_core+ */++/**+ * \addtogroup pw_filter+ * \{+ */+struct pw_filter;++#include <spa/buffer/buffer.h>+#include <spa/node/io.h>+#include <spa/param/param.h>+#include <spa/pod/command.h>++#include <pipewire/core.h>+#include <pipewire/stream.h>++/** \enum pw_filter_state The state of a filter */+enum pw_filter_state {+ PW_FILTER_STATE_ERROR = -1, /**< the stream is in error */+ PW_FILTER_STATE_UNCONNECTED = 0, /**< unconnected */+ PW_FILTER_STATE_CONNECTING = 1, /**< connection is in progress */+ PW_FILTER_STATE_PAUSED = 2, /**< filter is connected and paused */+ PW_FILTER_STATE_STREAMING = 3 /**< filter is streaming */+};++#if 0+struct pw_buffer {+ struct spa_buffer *buffer; /**< the spa buffer */+ void *user_data; /**< user data attached to the buffer */+ uint64_t size; /**< For input ports, this field is set by pw_filter+ * with the duration of the buffer in ticks.+ * For output ports, this field is set by the user.+ * This field is added for all queued buffers and+ * returned in the time info. */+};+#endif++/** Events for a filter. These events are always called from the mainloop+ * unless explicitly documented otherwise. */+struct pw_filter_events {+#define PW_VERSION_FILTER_EVENTS 1+ uint32_t version;++ void (*destroy) (void *data);+ /** when the filter state changes */+ void (*state_changed) (void *data, enum pw_filter_state old,+ enum pw_filter_state state, const char *error);++ /** when io changed on a port of the filter (when port_data is NULL). */+ void (*io_changed) (void *data, void *port_data,+ uint32_t id, void *area, uint32_t size);+ /** when a parameter changed on a port of the filter (when port_data is NULL). */+ void (*param_changed) (void *data, void *port_data,+ uint32_t id, const struct spa_pod *param);++ /** when a new buffer was created for a port */+ void (*add_buffer) (void *data, void *port_data, struct pw_buffer *buffer);+ /** when a buffer was destroyed for a port */+ void (*remove_buffer) (void *data, void *port_data, struct pw_buffer *buffer);++ /** do processing. This is normally called from the+ * mainloop but can also be called directly from the realtime data+ * thread if the user is prepared to deal with this. */+ void (*process) (void *data, struct spa_io_position *position);++ /** The filter is drained */+ void (*drained) (void *data);++ /** A command notify, Since 0.3.39:1 */+ void (*command) (void *data, const struct spa_command *command);+};++/** Convert a filter state to a readable string */+const char * pw_filter_state_as_string(enum pw_filter_state state);++/** \enum pw_filter_flags Extra flags that can be used in \ref pw_filter_connect() */+enum pw_filter_flags {+ PW_FILTER_FLAG_NONE = 0, /**< no flags */+ PW_FILTER_FLAG_INACTIVE = (1 << 0), /**< start the filter inactive,+ * pw_filter_set_active() needs to be+ * called explicitly */+ PW_FILTER_FLAG_DRIVER = (1 << 1), /**< be a driver */+ PW_FILTER_FLAG_RT_PROCESS = (1 << 2), /**< call process from the realtime+ * thread */+ PW_FILTER_FLAG_CUSTOM_LATENCY = (1 << 3), /**< don't call the default latency algorithm+ * but emit the param_changed event for the+ * ports when Latency params are received. */+ PW_FILTER_FLAG_TRIGGER = (1 << 4), /**< the filter will not be scheduled+ * automatically but _trigger_process()+ * needs to be called. This can be used+ * when the filter depends on processing+ * of other filters. */+ PW_FILTER_FLAG_ASYNC = (1 << 5), /**< Buffers will not be dequeued/queued from+ * the realtime process() function. This is+ * assumed when RT_PROCESS is unset but can+ * also be the case when the process() function+ * does a trigger_process() that will then+ * dequeue/queue a buffer from another process()+ * function. since 0.3.73 */+};++enum pw_filter_port_flags {+ PW_FILTER_PORT_FLAG_NONE = 0, /**< no flags */+ PW_FILTER_PORT_FLAG_MAP_BUFFERS = (1 << 0), /**< mmap the buffers except DmaBuf that is not+ * explicitly marked as mappable. */+ PW_FILTER_PORT_FLAG_ALLOC_BUFFERS = (1 << 1), /**< the application will allocate buffer+ * memory. In the add_buffer event, the+ * data of the buffer should be set */+};++/** Create a new unconneced \ref pw_filter+ * \return a newly allocated \ref pw_filter */+struct pw_filter *+pw_filter_new(struct pw_core *core, /**< a \ref pw_core */+ const char *name, /**< a filter media name */+ struct pw_properties *props /**< filter properties, ownership is taken */);++struct pw_filter *+pw_filter_new_simple(struct pw_loop *loop, /**< a \ref pw_loop to use */+ const char *name, /**< a filter media name */+ struct pw_properties *props, /**< filter properties, ownership is taken */+ const struct pw_filter_events *events, /**< filter events */+ void *data /**< data passed to events */);++/** Destroy a filter */+void pw_filter_destroy(struct pw_filter *filter);++void pw_filter_add_listener(struct pw_filter *filter,+ struct spa_hook *listener,+ const struct pw_filter_events *events,+ void *data);++enum pw_filter_state pw_filter_get_state(struct pw_filter *filter, const char **error);++const char *pw_filter_get_name(struct pw_filter *filter);++struct pw_core *pw_filter_get_core(struct pw_filter *filter);++/** Connect a filter for processing.+ * \return 0 on success < 0 on error.+ *+ * You should connect to the process event and use pw_filter_dequeue_buffer()+ * to get the latest metadata and data. */+int+pw_filter_connect(struct pw_filter *filter, /**< a \ref pw_filter */+ enum pw_filter_flags flags, /**< filter flags */+ const struct spa_pod **params, /**< an array with params. */+ uint32_t n_params /**< number of items in \a params */);++/** Get the node ID of the filter.+ * \return node ID. */+uint32_t+pw_filter_get_node_id(struct pw_filter *filter);++/** Disconnect \a filter */+int pw_filter_disconnect(struct pw_filter *filter);++/** add a port to the filter, returns user data of port_data_size. */+void *pw_filter_add_port(struct pw_filter *filter, /**< a \ref pw_filter */+ enum pw_direction direction, /**< port direction */+ enum pw_filter_port_flags flags, /**< port flags */+ size_t port_data_size, /**< allocated and given to the user as port_data */+ struct pw_properties *props, /**< port properties, ownership is taken */+ const struct spa_pod **params, /**< an array of params. The params should+ * ideally contain the supported formats */+ uint32_t n_params /**< number of elements in \a params */);++/** remove a port from the filter */+int pw_filter_remove_port(void *port_data /**< data associated with port */);++/** get properties, port_data of NULL will give global properties */+const struct pw_properties *pw_filter_get_properties(struct pw_filter *filter,+ void *port_data);++/** Update properties, use NULL port_data for global filter properties */+int pw_filter_update_properties(struct pw_filter *filter,+ void *port_data, const struct spa_dict *dict);++/** Set the filter in error state */+int pw_filter_set_error(struct pw_filter *filter, /**< a \ref pw_filter */+ int res, /**< a result code */+ const char *error, /**< an error message */+ ...+ ) SPA_PRINTF_FUNC(3, 4);++/** Update params, use NULL port_data for global filter params */+int+pw_filter_update_params(struct pw_filter *filter, /**< a \ref pw_filter */+ void *port_data, /**< data associated with port */+ const struct spa_pod **params, /**< an array of params. */+ uint32_t n_params /**< number of elements in \a params */);+++/** Query the time on the filter, deprecated, use the spa_io_position in the+ * process() method for timing information. */+SPA_DEPRECATED+int pw_filter_get_time(struct pw_filter *filter, struct pw_time *time);++/** Get the current time in nanoseconds. This value can be compared with+ * the nsec value in the spa_io_position. Since 1.0.4 */+uint64_t pw_filter_get_nsec(struct pw_filter *filter);++/** Get a buffer that can be filled for output ports or consumed+ * for input ports. */+struct pw_buffer *pw_filter_dequeue_buffer(void *port_data);++/** Submit a buffer for playback or recycle a buffer for capture. */+int pw_filter_queue_buffer(void *port_data, struct pw_buffer *buffer);++/** Get a data pointer to the buffer data */+void *pw_filter_get_dsp_buffer(void *port_data, uint32_t n_samples);++/** Activate or deactivate the filter */+int pw_filter_set_active(struct pw_filter *filter, bool active);++/** Flush a filter. When \a drain is true, the drained callback will+ * be called when all data is played or recorded */+int pw_filter_flush(struct pw_filter *filter, bool drain);++/** Check if the filter is driving. The filter needs to have the+ * PW_FILTER_FLAG_DRIVER set. When the filter is driving,+ * pw_filter_trigger_process() needs to be called when data is+ * available (output) or needed (input). Since 0.3.66 */+bool pw_filter_is_driving(struct pw_filter *filter);++/** Trigger a push/pull on the filter. One iteration of the graph will+ * be scheduled and process() will be called. Since 0.3.66 */+int pw_filter_trigger_process(struct pw_filter *filter);++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_FILTER_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/keys.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/keys.hnew file mode 100644index 000000000..fe96f10f3--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/keys.h@@ -0,0 +1,354 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2019 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_KEYS_H+#define PIPEWIRE_KEYS_H++#ifdef __cplusplus+extern "C" {+#endif++#include <pipewire/utils.h>+/**+ * \defgroup pw_keys Key Names+ *+ * A collection of keys that are used to add extra information on objects.+ *+ * Keys that start with "pipewire." are in general set-once and then+ * read-only. They are usually used for security sensitive information that+ * needs to be fixed.+ *+ * Properties from other objects can also appear. This usually suggests some+ * sort of parent/child or owner/owned relationship.+ *+ * \addtogroup pw_keys+ * \{+ */+#define PW_KEY_PROTOCOL "pipewire.protocol" /**< protocol used for connection */+#define PW_KEY_ACCESS "pipewire.access" /**< how the client access is controlled */+#define PW_KEY_CLIENT_ACCESS "pipewire.client.access"/**< how the client wants to be access+ * controlled */++/** Various keys related to the identity of a client process and its security.+ * Must be obtained from trusted sources by the protocol and placed as+ * read-only properties. */+#define PW_KEY_SEC_PID "pipewire.sec.pid" /**< Client pid, set by protocol */+#define PW_KEY_SEC_UID "pipewire.sec.uid" /**< Client uid, set by protocol*/+#define PW_KEY_SEC_GID "pipewire.sec.gid" /**< client gid, set by protocol*/+#define PW_KEY_SEC_LABEL "pipewire.sec.label" /**< client security label, set by protocol*/++#define PW_KEY_SEC_SOCKET "pipewire.sec.socket" /**< client socket name, set by protocol */++#define PW_KEY_LIBRARY_NAME_SYSTEM "library.name.system" /**< name of the system library to use */+#define PW_KEY_LIBRARY_NAME_LOOP "library.name.loop" /**< name of the loop library to use */+#define PW_KEY_LIBRARY_NAME_DBUS "library.name.dbus" /**< name of the dbus library to use */++/** object properties */+#define PW_KEY_OBJECT_PATH "object.path" /**< unique path to construct the object */+#define PW_KEY_OBJECT_ID "object.id" /**< a global object id */+#define PW_KEY_OBJECT_SERIAL "object.serial" /**< a 64 bit object serial number. This is a number+ * incremented for each object that is created.+ * The lower 32 bits are guaranteed to never be+ * SPA_ID_INVALID. */+#define PW_KEY_OBJECT_LINGER "object.linger" /**< the object lives on even after the client+ * that created it has been destroyed */+#define PW_KEY_OBJECT_REGISTER "object.register" /**< If the object should be registered. */+#define PW_KEY_OBJECT_EXPORT "object.export" /**< If the object should be exported,+ * since 0.3.72 */++/* config */+#define PW_KEY_CONFIG_PREFIX "config.prefix" /**< a config prefix directory */+#define PW_KEY_CONFIG_NAME "config.name" /**< a config file name */+#define PW_KEY_CONFIG_OVERRIDE_PREFIX "config.override.prefix" /**< a config override prefix directory */+#define PW_KEY_CONFIG_OVERRIDE_NAME "config.override.name" /**< a config override file name */++/* context */+#define PW_KEY_CONTEXT_PROFILE_MODULES "context.profile.modules" /**< a context profile for modules, deprecated */+#define PW_KEY_USER_NAME "context.user-name" /**< The user name that runs pipewire */+#define PW_KEY_HOST_NAME "context.host-name" /**< The host name of the machine */++/* core */+#define PW_KEY_CORE_NAME "core.name" /**< The name of the core. Default is+ * `pipewire-<username>-<pid>`, overwritten+ * by env(PIPEWIRE_CORE) */+#define PW_KEY_CORE_VERSION "core.version" /**< The version of the core. */+#define PW_KEY_CORE_DAEMON "core.daemon" /**< If the core is listening for connections. */++#define PW_KEY_CORE_ID "core.id" /**< the core id */+#define PW_KEY_CORE_MONITORS "core.monitors" /**< the apis monitored by core. */++/* cpu */+#define PW_KEY_CPU_MAX_ALIGN "cpu.max-align" /**< maximum alignment needed to support+ * all CPU optimizations */+#define PW_KEY_CPU_CORES "cpu.cores" /**< number of cores */++/* priorities */+#define PW_KEY_PRIORITY_SESSION "priority.session" /**< priority in session manager */+#define PW_KEY_PRIORITY_DRIVER "priority.driver" /**< priority to be a driver */++/* remote keys */+#define PW_KEY_REMOTE_NAME "remote.name" /**< The name of the remote to connect to,+ * default pipewire-0, overwritten by+ * env(PIPEWIRE_REMOTE). May also be+ * a SPA-JSON array of sockets, to be tried+ * in order. */+#define PW_KEY_REMOTE_INTENTION "remote.intention" /**< The intention of the remote connection,+ * "generic", "screencast" */++/** application keys */+#define PW_KEY_APP_NAME "application.name" /**< application name. Ex: "Totem Music Player" */+#define PW_KEY_APP_ID "application.id" /**< a textual id for identifying an+ * application logically. Ex: "org.gnome.Totem" */+#define PW_KEY_APP_VERSION "application.version" /**< application version. Ex: "1.2.0" */+#define PW_KEY_APP_ICON "application.icon" /**< aa base64 blob with PNG image data */+#define PW_KEY_APP_ICON_NAME "application.icon-name" /**< an XDG icon name for the application.+ * Ex: "totem" */+#define PW_KEY_APP_LANGUAGE "application.language" /**< application language if applicable, in+ * standard POSIX format. Ex: "en_GB" */++#define PW_KEY_APP_PROCESS_ID "application.process.id" /**< process id (pid)*/+#define PW_KEY_APP_PROCESS_BINARY "application.process.binary" /**< binary name */+#define PW_KEY_APP_PROCESS_USER "application.process.user" /**< user name */+#define PW_KEY_APP_PROCESS_HOST "application.process.host" /**< host name */+#define PW_KEY_APP_PROCESS_MACHINE_ID "application.process.machine-id" /**< the D-Bus host id the+ * application runs on */+#define PW_KEY_APP_PROCESS_SESSION_ID "application.process.session-id" /**< login session of the+ * application, on Unix the+ * value of $XDG_SESSION_ID. */+/** window system */+#define PW_KEY_WINDOW_X11_DISPLAY "window.x11.display" /**< the X11 display string. Ex. ":0.0" */++/** Client properties */+#define PW_KEY_CLIENT_ID "client.id" /**< a client id */+#define PW_KEY_CLIENT_NAME "client.name" /**< the client name */+#define PW_KEY_CLIENT_API "client.api" /**< the client api used to access+ * PipeWire */++/** Node keys */+#define PW_KEY_NODE_ID "node.id" /**< node id */+#define PW_KEY_NODE_NAME "node.name" /**< node name */+#define PW_KEY_NODE_NICK "node.nick" /**< short node name */+#define PW_KEY_NODE_DESCRIPTION "node.description" /**< localized human readable node one-line+ * description. Ex. "Foobar USB Headset" */+#define PW_KEY_NODE_PLUGGED "node.plugged" /**< when the node was created. As a uint64 in+ * nanoseconds. */++#define PW_KEY_NODE_SESSION "node.session" /**< the session id this node is part of */+#define PW_KEY_NODE_GROUP "node.group" /**< the group id this node is part of. Nodes+ * in the same group are always scheduled+ * with the same driver. Can be an array of+ * group names. */+#define PW_KEY_NODE_EXCLUSIVE "node.exclusive" /**< node wants exclusive access to resources */+#define PW_KEY_NODE_AUTOCONNECT "node.autoconnect" /**< node wants to be automatically connected+ * to a compatible node */+#define PW_KEY_NODE_LATENCY "node.latency" /**< the requested latency of the node as+ * a fraction. Ex: 128/48000 */+#define PW_KEY_NODE_MAX_LATENCY "node.max-latency" /**< the maximum supported latency of the+ * node as a fraction. Ex: 1024/48000 */+#define PW_KEY_NODE_LOCK_QUANTUM "node.lock-quantum" /**< don't change quantum when this node+ * is active */+#define PW_KEY_NODE_FORCE_QUANTUM "node.force-quantum" /**< force a quantum while the node is+ * active */+#define PW_KEY_NODE_RATE "node.rate" /**< the requested rate of the graph as+ * a fraction. Ex: 1/48000 */+#define PW_KEY_NODE_LOCK_RATE "node.lock-rate" /**< don't change rate when this node+ * is active */+#define PW_KEY_NODE_FORCE_RATE "node.force-rate" /**< force a rate while the node is+ * active. A value of 0 takes the denominator+ * of node.rate */++#define PW_KEY_NODE_DONT_RECONNECT "node.dont-reconnect" /**< don't reconnect this node. The node is+ * initially linked to target.object or the+ * default node. If the target is removed,+ * the node is destroyed */+#define PW_KEY_NODE_ALWAYS_PROCESS "node.always-process" /**< process even when unlinked */+#define PW_KEY_NODE_WANT_DRIVER "node.want-driver" /**< the node wants to be grouped with a driver+ * node in order to schedule the graph. */+#define PW_KEY_NODE_PAUSE_ON_IDLE "node.pause-on-idle" /**< pause the node when idle */+#define PW_KEY_NODE_SUSPEND_ON_IDLE "node.suspend-on-idle" /**< suspend the node when idle */+#define PW_KEY_NODE_CACHE_PARAMS "node.cache-params" /**< cache the node params */+#define PW_KEY_NODE_TRANSPORT_SYNC "node.transport.sync" /**< the node handles transport sync */+#define PW_KEY_NODE_DRIVER "node.driver" /**< node can drive the graph */+#define PW_KEY_NODE_STREAM "node.stream" /**< node is a stream, the server side should+ * add a converter */+#define PW_KEY_NODE_VIRTUAL "node.virtual" /**< the node is some sort of virtual+ * object */+#define PW_KEY_NODE_PASSIVE "node.passive" /**< indicate that a node wants passive links+ * on output/input/all ports when the value is+ * "out"/"in"/"true" respectively */+#define PW_KEY_NODE_LINK_GROUP "node.link-group" /**< the node is internally linked to+ * nodes with the same link-group. Can be an+ * array of group names. */+#define PW_KEY_NODE_NETWORK "node.network" /**< the node is on a network */+#define PW_KEY_NODE_TRIGGER "node.trigger" /**< the node is not scheduled automatically+ * based on the dependencies in the graph+ * but it will be triggered explicitly. */+#define PW_KEY_NODE_CHANNELNAMES "node.channel-names" /**< names of node's+ * channels (unrelated to positions) */+#define PW_KEY_NODE_DEVICE_PORT_NAME_PREFIX "node.device-port-name-prefix" /** override+ * port name prefix for device ports, like capture and playback+ * or disable the prefix completely if an empty string is provided */++/** Port keys */+#define PW_KEY_PORT_ID "port.id" /**< port id */+#define PW_KEY_PORT_NAME "port.name" /**< port name */+#define PW_KEY_PORT_DIRECTION "port.direction" /**< the port direction, one of "in" or "out"+ * or "control" and "notify" for control ports */+#define PW_KEY_PORT_ALIAS "port.alias" /**< port alias */+#define PW_KEY_PORT_PHYSICAL "port.physical" /**< if this is a physical port */+#define PW_KEY_PORT_TERMINAL "port.terminal" /**< if this port consumes the data */+#define PW_KEY_PORT_CONTROL "port.control" /**< if this port is a control port */+#define PW_KEY_PORT_MONITOR "port.monitor" /**< if this port is a monitor port */+#define PW_KEY_PORT_CACHE_PARAMS "port.cache-params" /**< cache the node port params */+#define PW_KEY_PORT_EXTRA "port.extra" /**< api specific extra port info, API name+ * should be prefixed. "jack:flags:56" */+#define PW_KEY_PORT_PASSIVE "port.passive" /**< the ports wants passive links, since 0.3.67 */+#define PW_KEY_PORT_IGNORE_LATENCY "port.ignore-latency" /**< latency ignored by peers, since 0.3.71 */++/** link properties */+#define PW_KEY_LINK_ID "link.id" /**< a link id */+#define PW_KEY_LINK_INPUT_NODE "link.input.node" /**< input node id of a link */+#define PW_KEY_LINK_INPUT_PORT "link.input.port" /**< input port id of a link */+#define PW_KEY_LINK_OUTPUT_NODE "link.output.node" /**< output node id of a link */+#define PW_KEY_LINK_OUTPUT_PORT "link.output.port" /**< output port id of a link */+#define PW_KEY_LINK_PASSIVE "link.passive" /**< indicate that a link is passive and+ * does not cause the graph to be+ * runnable. */+#define PW_KEY_LINK_FEEDBACK "link.feedback" /**< indicate that a link is a feedback+ * link and the target will receive data+ * in the next cycle */++/** device properties */+#define PW_KEY_DEVICE_ID "device.id" /**< device id */+#define PW_KEY_DEVICE_NAME "device.name" /**< device name */+#define PW_KEY_DEVICE_PLUGGED "device.plugged" /**< when the device was created. As a uint64 in+ * nanoseconds. */+#define PW_KEY_DEVICE_NICK "device.nick" /**< a short device nickname */+#define PW_KEY_DEVICE_STRING "device.string" /**< device string in the underlying layer's+ * format. Ex. "surround51:0" */+#define PW_KEY_DEVICE_API "device.api" /**< API this device is accessed with.+ * Ex. "alsa", "v4l2" */+#define PW_KEY_DEVICE_DESCRIPTION "device.description" /**< localized human readable device one-line+ * description. Ex. "Foobar USB Headset" */+#define PW_KEY_DEVICE_BUS_PATH "device.bus-path" /**< bus path to the device in the OS'+ * format. Ex. "pci-0000:00:14.0-usb-0:3.2:1.0" */+#define PW_KEY_DEVICE_SERIAL "device.serial" /**< Serial number if applicable */+#define PW_KEY_DEVICE_VENDOR_ID "device.vendor.id" /**< vendor ID if applicable */+#define PW_KEY_DEVICE_VENDOR_NAME "device.vendor.name" /**< vendor name if applicable */+#define PW_KEY_DEVICE_PRODUCT_ID "device.product.id" /**< product ID if applicable */+#define PW_KEY_DEVICE_PRODUCT_NAME "device.product.name" /**< product name if applicable */+#define PW_KEY_DEVICE_CLASS "device.class" /**< device class */+#define PW_KEY_DEVICE_FORM_FACTOR "device.form-factor" /**< form factor if applicable. One of+ * "internal", "speaker", "handset", "tv",+ * "webcam", "microphone", "headset",+ * "headphone", "hands-free", "car", "hifi",+ * "computer", "portable" */+#define PW_KEY_DEVICE_BUS "device.bus" /**< bus of the device if applicable. One of+ * "isa", "pci", "usb", "firewire",+ * "bluetooth" */+#define PW_KEY_DEVICE_SUBSYSTEM "device.subsystem" /**< device subsystem */+#define PW_KEY_DEVICE_SYSFS_PATH "device.sysfs.path" /**< device sysfs path */+#define PW_KEY_DEVICE_ICON "device.icon" /**< icon for the device. A base64 blob+ * containing PNG image data */+#define PW_KEY_DEVICE_ICON_NAME "device.icon-name" /**< an XDG icon name for the device.+ * Ex. "sound-card-speakers-usb" */+#define PW_KEY_DEVICE_INTENDED_ROLES "device.intended-roles" /**< intended use. A space separated list of+ * roles (see PW_KEY_MEDIA_ROLE) this device+ * is particularly well suited for, due to+ * latency, quality or form factor. */+#define PW_KEY_DEVICE_CACHE_PARAMS "device.cache-params" /**< cache the device spa params */++/** module properties */+#define PW_KEY_MODULE_ID "module.id" /**< the module id */+#define PW_KEY_MODULE_NAME "module.name" /**< the name of the module */+#define PW_KEY_MODULE_AUTHOR "module.author" /**< the author's name */+#define PW_KEY_MODULE_DESCRIPTION "module.description" /**< a human readable one-line description+ * of the module's purpose.*/+#define PW_KEY_MODULE_USAGE "module.usage" /**< a human readable usage description of+ * the module's arguments. */+#define PW_KEY_MODULE_VERSION "module.version" /**< a version string for the module. */++/** Factory properties */+#define PW_KEY_FACTORY_ID "factory.id" /**< the factory id */+#define PW_KEY_FACTORY_NAME "factory.name" /**< the name of the factory */+#define PW_KEY_FACTORY_USAGE "factory.usage" /**< the usage of the factory */+#define PW_KEY_FACTORY_TYPE_NAME "factory.type.name" /**< the name of the type created by a factory */+#define PW_KEY_FACTORY_TYPE_VERSION "factory.type.version" /**< the version of the type created by a factory */++/** Stream properties */+#define PW_KEY_STREAM_IS_LIVE "stream.is-live" /**< Indicates that the stream is live. */+#define PW_KEY_STREAM_LATENCY_MIN "stream.latency.min" /**< The minimum latency of the stream. */+#define PW_KEY_STREAM_LATENCY_MAX "stream.latency.max" /**< The maximum latency of the stream */+#define PW_KEY_STREAM_MONITOR "stream.monitor" /**< Indicates that the stream is monitoring+ * and might select a less accurate but faster+ * conversion algorithm. Monitor streams are also+ * ignored when calculating the latency of their peer+ * ports (since 0.3.71).+ */+#define PW_KEY_STREAM_DONT_REMIX "stream.dont-remix" /**< don't remix channels */+#define PW_KEY_STREAM_CAPTURE_SINK "stream.capture.sink" /**< Try to capture the sink output instead of+ * source output */++/** Media */+#define PW_KEY_MEDIA_TYPE "media.type" /**< Media type, one of+ * Audio, Video, Midi */+#define PW_KEY_MEDIA_CATEGORY "media.category" /**< Media Category:+ * Playback, Capture, Duplex, Monitor, Manager */+#define PW_KEY_MEDIA_ROLE "media.role" /**< Role: Movie, Music, Camera,+ * Screen, Communication, Game,+ * Notification, DSP, Production,+ * Accessibility, Test */+#define PW_KEY_MEDIA_CLASS "media.class" /**< class Ex: "Video/Source" */+#define PW_KEY_MEDIA_NAME "media.name" /**< media name. Ex: "Pink Floyd: Time" */+#define PW_KEY_MEDIA_TITLE "media.title" /**< title. Ex: "Time" */+#define PW_KEY_MEDIA_ARTIST "media.artist" /**< artist. Ex: "Pink Floyd" */+#define PW_KEY_MEDIA_COPYRIGHT "media.copyright" /**< copyright string */+#define PW_KEY_MEDIA_SOFTWARE "media.software" /**< generator software */+#define PW_KEY_MEDIA_LANGUAGE "media.language" /**< language in POSIX format. Ex: en_GB */+#define PW_KEY_MEDIA_FILENAME "media.filename" /**< filename */+#define PW_KEY_MEDIA_ICON "media.icon" /**< icon for the media, a base64 blob with+ * PNG image data */+#define PW_KEY_MEDIA_ICON_NAME "media.icon-name" /**< an XDG icon name for the media.+ * Ex: "audio-x-mp3" */+#define PW_KEY_MEDIA_COMMENT "media.comment" /**< extra comment */+#define PW_KEY_MEDIA_DATE "media.date" /**< date of the media */+#define PW_KEY_MEDIA_FORMAT "media.format" /**< format of the media */++/** format related properties */+#define PW_KEY_FORMAT_DSP "format.dsp" /**< a dsp format.+ * Ex: "32 bit float mono audio" */+/** audio related properties */+#define PW_KEY_AUDIO_CHANNEL "audio.channel" /**< an audio channel. Ex: "FL" */+#define PW_KEY_AUDIO_RATE "audio.rate" /**< an audio samplerate */+#define PW_KEY_AUDIO_CHANNELS "audio.channels" /**< number of audio channels */+#define PW_KEY_AUDIO_FORMAT "audio.format" /**< an audio format. Ex: "S16LE" */+#define PW_KEY_AUDIO_ALLOWED_RATES "audio.allowed-rates" /**< a list of allowed samplerates+ * ex. "[ 44100 48000 ]" */++/** video related properties */+#define PW_KEY_VIDEO_RATE "video.framerate" /**< a video framerate */+#define PW_KEY_VIDEO_FORMAT "video.format" /**< a video format */+#define PW_KEY_VIDEO_SIZE "video.size" /**< a video size as "<width>x<height" */++#define PW_KEY_TARGET_OBJECT "target.object" /**< a target object to link to. This can be+ * and object name or object.serial */++#ifndef PW_REMOVE_DEPRECATED+# ifdef PW_ENABLE_DEPRECATED+# define PW_KEY_PRIORITY_MASTER "priority.master" /**< deprecated, use priority.driver */+# define PW_KEY_NODE_TARGET "node.target" /**< deprecated since 0.3.64, use target.object. */+# else+# define PW_KEY_PRIORITY_MASTER PW_DEPRECATED("priority.master")+# define PW_KEY_NODE_TARGET PW_DEPRECATED("node.target")+# endif /* PW_ENABLE_DEPRECATED */+#endif /* PW_REMOVE_DEPRECATED */++/** \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_KEYS_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/link.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/link.hnew file mode 100644index 000000000..ef96dfe21--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/link.h@@ -0,0 +1,130 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_LINK_H+#define PIPEWIRE_LINK_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>+#include <spa/utils/hook.h>++#include <pipewire/proxy.h>++/** \defgroup pw_link Link+ *+ * A link is the connection between 2 nodes (\ref pw_node). Nodes are+ * linked together on ports.+ *+ * The link is responsible for negotiating the format and buffers for+ * the nodes.+ *+ */++/**+ * \addtogroup pw_link+ * \{+ */++#define PW_TYPE_INTERFACE_Link PW_TYPE_INFO_INTERFACE_BASE "Link"++#define PW_LINK_PERM_MASK PW_PERM_R | PW_PERM_X++#define PW_VERSION_LINK 3+struct pw_link;++/** \enum pw_link_state The different link states */+enum pw_link_state {+ PW_LINK_STATE_ERROR = -2, /**< the link is in error */+ PW_LINK_STATE_UNLINKED = -1, /**< the link is unlinked */+ PW_LINK_STATE_INIT = 0, /**< the link is initialized */+ PW_LINK_STATE_NEGOTIATING = 1, /**< the link is negotiating formats */+ PW_LINK_STATE_ALLOCATING = 2, /**< the link is allocating buffers */+ PW_LINK_STATE_PAUSED = 3, /**< the link is paused */+ PW_LINK_STATE_ACTIVE = 4, /**< the link is active */+};++/** Convert a \ref pw_link_state to a readable string */+const char * pw_link_state_as_string(enum pw_link_state state);+/** The link information. Extra information can be added in later versions */+struct pw_link_info {+ uint32_t id; /**< id of the global */+ uint32_t output_node_id; /**< server side output node id */+ uint32_t output_port_id; /**< output port id */+ uint32_t input_node_id; /**< server side input node id */+ uint32_t input_port_id; /**< input port id */+#define PW_LINK_CHANGE_MASK_STATE (1 << 0)+#define PW_LINK_CHANGE_MASK_FORMAT (1 << 1)+#define PW_LINK_CHANGE_MASK_PROPS (1 << 2)+#define PW_LINK_CHANGE_MASK_ALL ((1 << 3)-1)+ uint64_t change_mask; /**< bitfield of changed fields since last call */+ enum pw_link_state state; /**< the current state of the link */+ const char *error; /**< an error reason if \a state is error */+ struct spa_pod *format; /**< format over link */+ struct spa_dict *props; /**< the properties of the link */+};++struct pw_link_info *+pw_link_info_update(struct pw_link_info *info,+ const struct pw_link_info *update);++struct pw_link_info *+pw_link_info_merge(struct pw_link_info *info,+ const struct pw_link_info *update, bool reset);++void+pw_link_info_free(struct pw_link_info *info);+++#define PW_LINK_EVENT_INFO 0+#define PW_LINK_EVENT_NUM 1++/** Link events */+struct pw_link_events {+#define PW_VERSION_LINK_EVENTS 0+ uint32_t version;+ /**+ * Notify link info+ *+ * \param info info about the link+ */+ void (*info) (void *data, const struct pw_link_info *info);+};++#define PW_LINK_METHOD_ADD_LISTENER 0+#define PW_LINK_METHOD_NUM 1++/** Link methods */+struct pw_link_methods {+#define PW_VERSION_LINK_METHODS 0+ uint32_t version;++ int (*add_listener) (void *object,+ struct spa_hook *listener,+ const struct pw_link_events *events,+ void *data);+};++#define pw_link_method(o,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ spa_interface_call_res((struct spa_interface*)o, \+ struct pw_link_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++#define pw_link_add_listener(c,...) pw_link_method(c,add_listener,0,__VA_ARGS__)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* PIPEWIRE_LINK_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/log.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/log.hnew file mode 100644index 000000000..b1cdc4c52--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/log.h@@ -0,0 +1,151 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_LOG_H+#define PIPEWIRE_LOG_H++#include <spa/support/log.h>++#ifdef __cplusplus+extern "C" {+#endif++/** \defgroup pw_log Logging+ *+ * \brief Logging functions of PipeWire+ *+ * Logging is performed to stdout and stderr. Trace logging is performed+ * in a lockfree ringbuffer and written out from the main thread as to not+ * block the realtime threads.+ */++/**+ * \addtogroup pw_log+ * \{+ */+/** The global log level */+extern enum spa_log_level pw_log_level;++extern struct spa_log_topic *PW_LOG_TOPIC_DEFAULT;++/** Configure a logging module. This is usually done automatically+ * in pw_init() but you can install a custom logger before calling+ * pw_init(). */+void pw_log_set(struct spa_log *log);++/** Get the log interface */+struct spa_log *pw_log_get(void);++/** Configure the logging level */+void pw_log_set_level(enum spa_log_level level);++/** Log a message for a topic */+void+pw_log_logt(enum spa_log_level level,+ const struct spa_log_topic *topic,+ const char *file,+ int line, const char *func,+ const char *fmt, ...) SPA_PRINTF_FUNC(6, 7);++/** Log a message for a topic */+void+pw_log_logtv(enum spa_log_level level,+ const struct spa_log_topic *topic,+ const char *file,+ int line, const char *func,+ const char *fmt, va_list args) SPA_PRINTF_FUNC(6, 0);++++/** Log a message for the default topic */+void+pw_log_log(enum spa_log_level level,+ const char *file,+ int line, const char *func,+ const char *fmt, ...) SPA_PRINTF_FUNC(5, 6);++/** Log a message for the default topic */+void+pw_log_logv(enum spa_log_level level,+ const char *file,+ int line, const char *func,+ const char *fmt, va_list args) SPA_PRINTF_FUNC(5, 0);++/**+ * Declare a static log topic named \a var. The usual usage is:+ * \code+ * PW_LOG_TOPIC_STATIC(my_topic);+ * #define PW_LOG_TOPIC_DEFAULT my_topic+ *+ * void foo() {+ * pw_log_debug("bar");+ * }+ * \endcode+ */+#define PW_LOG_TOPIC_STATIC(var, topic) \+ static struct spa_log_topic var##__LINE__ = SPA_LOG_TOPIC(0, topic); \+ static struct spa_log_topic *var = &(var##__LINE__)++/**+ * Declare a static log topic named \a var.+ * See \ref PW_LOG_TOPIC_STATIC for an example usage.+ */+#define PW_LOG_TOPIC_EXTERN(var) \+ extern struct spa_log_topic *var++/**+ * Declare a static log topic named \a var.+ * See \ref PW_LOG_TOPIC_STATIC for an example usage.+ */+#define PW_LOG_TOPIC(var, topic) \+ struct spa_log_topic var##__LINE__ = SPA_LOG_TOPIC(0, topic); \+ struct spa_log_topic *var = &(var##__LINE__)++#define PW_LOG_TOPIC_INIT(var) \+ spa_log_topic_init(pw_log_get(), var);++/** Check if a loglevel is enabled */+#define pw_log_level_enabled(lev) (pw_log_level >= (lev))+#define pw_log_topic_enabled(lev,t) ((t) && (t)->has_custom_level ? (t)->level >= (lev) : pw_log_level_enabled((lev)))++#define pw_logtv(lev,topic,fmt,ap) \+({ \+ if (SPA_UNLIKELY(pw_log_topic_enabled(lev,topic))) \+ pw_log_logtv(lev,topic,__FILE__,__LINE__,__func__,fmt,ap); \+})++#define pw_logt(lev,topic,...) \+({ \+ if (SPA_UNLIKELY(pw_log_topic_enabled(lev,topic))) \+ pw_log_logt(lev,topic,__FILE__,__LINE__,__func__,__VA_ARGS__); \+})++#define pw_log(lev,...) pw_logt(lev,PW_LOG_TOPIC_DEFAULT,__VA_ARGS__)++#define pw_log_error(...) pw_log(SPA_LOG_LEVEL_ERROR,__VA_ARGS__)+#define pw_log_warn(...) pw_log(SPA_LOG_LEVEL_WARN,__VA_ARGS__)+#define pw_log_info(...) pw_log(SPA_LOG_LEVEL_INFO,__VA_ARGS__)+#define pw_log_debug(...) pw_log(SPA_LOG_LEVEL_DEBUG,__VA_ARGS__)+#define pw_log_trace(...) pw_log(SPA_LOG_LEVEL_TRACE,__VA_ARGS__)++#define pw_logt_error(t,...) pw_logt(SPA_LOG_LEVEL_ERROR,t,__VA_ARGS__)+#define pw_logt_warn(t,...) pw_logt(SPA_LOG_LEVEL_WARN,t,__VA_ARGS__)+#define pw_logt_info(t,...) pw_logt(SPA_LOG_LEVEL_INFO,t,__VA_ARGS__)+#define pw_logt_debug(t,...) pw_logt(SPA_LOG_LEVEL_DEBUG,t,__VA_ARGS__)+#define pw_logt_trace(t,...) pw_logt(SPA_LOG_LEVEL_TRACE,t,__VA_ARGS__)++#ifndef FASTPATH+#define pw_log_trace_fp(...) pw_log(SPA_LOG_LEVEL_TRACE,__VA_ARGS__)+#else+#define pw_log_trace_fp(...)+#endif++/**+ * \}+ */++#ifdef __cplusplus+}+#endif+#endif /* PIPEWIRE_LOG_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/loop.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/loop.hnew file mode 100644index 000000000..25f5cfb22--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/loop.h@@ -0,0 +1,70 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_LOOP_H+#define PIPEWIRE_LOOP_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/support/loop.h>+#include <spa/utils/dict.h>++/** \defgroup pw_loop Loop+ *+ * PipeWire loop object provides an implementation of+ * the spa loop interfaces. It can be used to implement various+ * event loops.+ */++/**+ * \addtogroup pw_loop+ * \{+ */++struct pw_loop {+ struct spa_system *system; /**< system utils */+ struct spa_loop *loop; /**< wrapped loop */+ struct spa_loop_control *control; /**< loop control */+ struct spa_loop_utils *utils; /**< loop utils */+};++struct pw_loop *+pw_loop_new(const struct spa_dict *props);++void+pw_loop_destroy(struct pw_loop *loop);++#define pw_loop_add_source(l,...) spa_loop_add_source((l)->loop,__VA_ARGS__)+#define pw_loop_update_source(l,...) spa_loop_update_source((l)->loop,__VA_ARGS__)+#define pw_loop_remove_source(l,...) spa_loop_remove_source((l)->loop,__VA_ARGS__)+#define pw_loop_invoke(l,...) spa_loop_invoke((l)->loop,__VA_ARGS__)++#define pw_loop_get_fd(l) spa_loop_control_get_fd((l)->control)+#define pw_loop_add_hook(l,...) spa_loop_control_add_hook((l)->control,__VA_ARGS__)+#define pw_loop_enter(l) spa_loop_control_enter((l)->control)+#define pw_loop_leave(l) spa_loop_control_leave((l)->control)+#define pw_loop_iterate(l,...) spa_loop_control_iterate_fast((l)->control,__VA_ARGS__)++#define pw_loop_add_io(l,...) spa_loop_utils_add_io((l)->utils,__VA_ARGS__)+#define pw_loop_update_io(l,...) spa_loop_utils_update_io((l)->utils,__VA_ARGS__)+#define pw_loop_add_idle(l,...) spa_loop_utils_add_idle((l)->utils,__VA_ARGS__)+#define pw_loop_enable_idle(l,...) spa_loop_utils_enable_idle((l)->utils,__VA_ARGS__)+#define pw_loop_add_event(l,...) spa_loop_utils_add_event((l)->utils,__VA_ARGS__)+#define pw_loop_signal_event(l,...) spa_loop_utils_signal_event((l)->utils,__VA_ARGS__)+#define pw_loop_add_timer(l,...) spa_loop_utils_add_timer((l)->utils,__VA_ARGS__)+#define pw_loop_update_timer(l,...) spa_loop_utils_update_timer((l)->utils,__VA_ARGS__)+#define pw_loop_add_signal(l,...) spa_loop_utils_add_signal((l)->utils,__VA_ARGS__)+#define pw_loop_destroy_source(l,...) spa_loop_utils_destroy_source((l)->utils,__VA_ARGS__)++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_LOOP_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/main-loop.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/main-loop.hnew file mode 100644index 000000000..78ab644e6--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/main-loop.h@@ -0,0 +1,66 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_MAIN_LOOP_H+#define PIPEWIRE_MAIN_LOOP_H++#ifdef __cplusplus+extern "C" {+#endif++/** \defgroup pw_main_loop Main Loop+ *+ * A main loop object+ */++/**+ * \addtogroup pw_main_loop+ * \{+ */++/** A main loop object */+struct pw_main_loop;++#include <pipewire/loop.h>++/** Events of the main loop */+struct pw_main_loop_events {+#define PW_VERSION_MAIN_LOOP_EVENTS 0+ uint32_t version;++ /** Emitted when the main loop is destroyed */+ void (*destroy) (void *data);+};++/** Create a new main loop. */+struct pw_main_loop *+pw_main_loop_new(const struct spa_dict *props);++/** Add an event listener */+void pw_main_loop_add_listener(struct pw_main_loop *loop,+ struct spa_hook *listener,+ const struct pw_main_loop_events *events,+ void *data);++/** Get the loop implementation */+struct pw_loop * pw_main_loop_get_loop(struct pw_main_loop *loop);++/** Destroy a loop */+void pw_main_loop_destroy(struct pw_main_loop *loop);++/** Run a main loop. This blocks until \ref pw_main_loop_quit is called */+int pw_main_loop_run(struct pw_main_loop *loop);++/** Quit a main loop */+int pw_main_loop_quit(struct pw_main_loop *loop);++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_MAIN_LOOP_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/map.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/map.hnew file mode 100644index 000000000..39d6d0848--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/map.h@@ -0,0 +1,232 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_MAP_H+#define PIPEWIRE_MAP_H++#ifdef __cplusplus+extern "C" {+#endif++#include <string.h>+#include <errno.h>++#include <spa/utils/defs.h>+#include <pipewire/array.h>++/** \defgroup pw_map Map+ *+ * \brief A map that holds pointers to objects indexed by id+ *+ * The map is a sparse version of the \ref pw_array "pw_array" that manages the+ * indices of elements for the caller. Adding items with+ * pw_map_insert_new() returns the assigned index for that item; if items+ * are removed the map re-uses indices to keep the array at the minimum+ * required size.+ *+ * \code{.c}+ * struct pw_map map = PW_MAP_INIT(4);+ *+ * idx1 = pw_map_insert_new(&map, ptr1);+ * idx2 = pw_map_insert_new(&map, ptr2);+ * // the map is now [ptr1, ptr2], size 2+ * pw_map_remove(&map, idx1);+ * // the map is now [<unused>, ptr2], size 2+ * pw_map_insert_new(&map, ptr3);+ * // the map is now [ptr3, ptr2], size 2+ * \endcode+ */++/**+ * \addtogroup pw_map+ * \{+ */++/** \private+ * An entry in the map. This is used internally only. Each element in the+ * backing pw_array is a union pw_map_item. For real items, the data pointer+ * points to the item. If an element has been removed, pw_map->free_list+ * is the index of the most recently removed item. That item contains+ * the index of the next removed item until item->next is SPA_ID_INVALID.+ *+ * The free list is prepended only, the last item to be removed will be the+ * first item to get re-used on the next insert.+ */+union pw_map_item {+ uintptr_t next; /* next free index */+ void *data; /* data of this item, must be an even address */+};++/** A map. This struct should be treated as opaque by the caller. */+struct pw_map {+ struct pw_array items; /* an array with the map items */+ uint32_t free_list; /* first free index */+};++/** \param extend the amount of bytes to grow the map with when needed */+#define PW_MAP_INIT(extend) ((struct pw_map) { PW_ARRAY_INIT(extend), SPA_ID_INVALID })++/**+ * Get the number of currently allocated elements in the map.+ * \note pw_map_get_size() returns the currently allocated number of+ * elements in the map, not the number of actually set elements.+ * \return the number of available elements before the map needs to grow+ */+#define pw_map_get_size(m) pw_array_get_len(&(m)->items, union pw_map_item)+#define pw_map_get_item(m,id) pw_array_get_unchecked(&(m)->items,id,union pw_map_item)+#define pw_map_item_is_free(item) ((item)->next & 0x1)+#define pw_map_id_is_free(m,id) (pw_map_item_is_free(pw_map_get_item(m,id)))+/** \return true if the id fits within the current map size */+#define pw_map_check_id(m,id) ((id) < pw_map_get_size(m))+/** \return true if there is a valid item at \a id */+#define pw_map_has_item(m,id) (pw_map_check_id(m,id) && !pw_map_id_is_free(m, id))+#define pw_map_lookup_unchecked(m,id) pw_map_get_item(m,id)->data++/** Convert an id to a pointer that can be inserted into the map */+#define PW_MAP_ID_TO_PTR(id) (SPA_UINT32_TO_PTR((id)<<1))+/** Convert a pointer to an id that can be retrieved from the map */+#define PW_MAP_PTR_TO_ID(p) (SPA_PTR_TO_UINT32(p)>>1)++/** Initialize a map+ * \param map the map to initialize+ * \param size the initial size of the map+ * \param extend the amount to bytes to grow the map with when needed+ */+static inline void pw_map_init(struct pw_map *map, size_t size, size_t extend)+{+ pw_array_init(&map->items, extend * sizeof(union pw_map_item));+ pw_array_ensure_size(&map->items, size * sizeof(union pw_map_item));+ map->free_list = SPA_ID_INVALID;+}++/** Clear a map and free the data storage. All previously returned ids+ * must be treated as invalid.+ */+static inline void pw_map_clear(struct pw_map *map)+{+ pw_array_clear(&map->items);+}++/** Reset a map but keep previously allocated storage. All previously+ * returned ids must be treated as invalid.+ */+static inline void pw_map_reset(struct pw_map *map)+{+ pw_array_reset(&map->items);+ map->free_list = SPA_ID_INVALID;+}++/** Insert data in the map. This function causes the map to grow if required.+ * \param map the map to insert into+ * \param data the item to add+ * \return the id where the item was inserted or SPA_ID_INVALID when the+ * item can not be inserted.+ */+static inline uint32_t pw_map_insert_new(struct pw_map *map, void *data)+{+ union pw_map_item *start, *item;+ uint32_t id;++ if (map->free_list != SPA_ID_INVALID) {+ start = (union pw_map_item *) map->items.data;+ item = &start[map->free_list >> 1]; /* lsb always 1, see pw_map_remove */+ map->free_list = item->next;+ } else {+ item = (union pw_map_item *) pw_array_add(&map->items, sizeof(union pw_map_item));+ if (item == NULL)+ return SPA_ID_INVALID;+ start = (union pw_map_item *) map->items.data;+ }+ item->data = data;+ id = (item - start);+ return id;+}++/** Replace the data in the map at an index.+ *+ * \param map the map to insert into+ * \param id the index to insert at, must be less or equal to pw_map_get_size()+ * \param data the data to insert+ * \return 0 on success, -ENOSPC value when the index is invalid or a negative errno+ */+static inline int pw_map_insert_at(struct pw_map *map, uint32_t id, void *data)+{+ size_t size = pw_map_get_size(map);+ union pw_map_item *item;++ if (id > size)+ return -ENOSPC;+ else if (id == size) {+ item = (union pw_map_item *) pw_array_add(&map->items, sizeof(union pw_map_item));+ if (item == NULL)+ return -errno;+ } else {+ item = pw_map_get_item(map, id);+ if (pw_map_item_is_free(item))+ return -EINVAL;+ }+ item->data = data;+ return 0;+}++/** Remove an item at index. The id may get re-used in the future.+ *+ * \param map the map to remove from+ * \param id the index to remove+ */+static inline void pw_map_remove(struct pw_map *map, uint32_t id)+{+ if (pw_map_id_is_free(map, id))+ return;++ pw_map_get_item(map, id)->next = map->free_list;+ map->free_list = (id << 1) | 1;+}++/** Find an item in the map+ * \param map the map to use+ * \param id the index to look at+ * \return the item at \a id or NULL when no such item exists+ */+static inline void *pw_map_lookup(const struct pw_map *map, uint32_t id)+{+ if (SPA_LIKELY(pw_map_check_id(map, id))) {+ union pw_map_item *item = pw_map_get_item(map, id);+ if (!pw_map_item_is_free(item))+ return item->data;+ }+ return NULL;+}++/** Iterate all map items+ * \param map the map to iterate+ * \param func the function to call for each item, the item data and \a data is+ * passed to the function. When \a func returns a non-zero result,+ * iteration ends and the result is returned.+ * \param data data to pass to \a func+ * \return the result of the last call to \a func or 0 when all callbacks returned 0.+ */+static inline int pw_map_for_each(const struct pw_map *map,+ int (*func) (void *item_data, void *data), void *data)+{+ union pw_map_item *item;+ int res = 0;++ pw_array_for_each(item, &map->items) {+ if (!pw_map_item_is_free(item))+ if ((res = func(item->data, data)) != 0)+ break;+ }+ return res;+}++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* PIPEWIRE_MAP_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/mem.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/mem.hnew file mode 100644index 000000000..55e260c22--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/mem.h@@ -0,0 +1,192 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_MEM_H+#define PIPEWIRE_MEM_H++#include <pipewire/properties.h>++#ifdef __cplusplus+extern "C" {+#endif++/** \defgroup pw_memblock Memory Blocks+ * Memory allocation and pools.+ */++/**+ * \addtogroup pw_memblock+ * \{+ */++/** Flags passed to \ref pw_mempool_alloc() */+enum pw_memblock_flags {+ PW_MEMBLOCK_FLAG_NONE = 0,+ PW_MEMBLOCK_FLAG_READABLE = (1 << 0), /**< memory is readable */+ PW_MEMBLOCK_FLAG_WRITABLE = (1 << 1), /**< memory is writable */+ PW_MEMBLOCK_FLAG_SEAL = (1 << 2), /**< seal the fd */+ PW_MEMBLOCK_FLAG_MAP = (1 << 3), /**< mmap the fd */+ PW_MEMBLOCK_FLAG_DONT_CLOSE = (1 << 4), /**< don't close fd */+ PW_MEMBLOCK_FLAG_DONT_NOTIFY = (1 << 5), /**< don't notify events */++ PW_MEMBLOCK_FLAG_READWRITE = PW_MEMBLOCK_FLAG_READABLE | PW_MEMBLOCK_FLAG_WRITABLE,+};++enum pw_memmap_flags {+ PW_MEMMAP_FLAG_NONE = 0,+ PW_MEMMAP_FLAG_READ = (1 << 0), /**< map in read mode */+ PW_MEMMAP_FLAG_WRITE = (1 << 1), /**< map in write mode */+ PW_MEMMAP_FLAG_TWICE = (1 << 2), /**< map the same area twice after each other,+ * creating a circular ringbuffer */+ PW_MEMMAP_FLAG_PRIVATE = (1 << 3), /**< writes will be private */+ PW_MEMMAP_FLAG_LOCKED = (1 << 4), /**< lock the memory into RAM */+ PW_MEMMAP_FLAG_READWRITE = PW_MEMMAP_FLAG_READ | PW_MEMMAP_FLAG_WRITE,+};++struct pw_memchunk;++/**+ *+ * A memory pool is a collection of pw_memblocks */+struct pw_mempool {+ struct pw_properties *props;+};++/**+ * Memory block structure */+struct pw_memblock {+ struct pw_mempool *pool; /**< owner pool */+ uint32_t id; /**< unique id */+ int ref; /**< refcount */+ uint32_t flags; /**< flags for the memory block on of enum pw_memblock_flags */+ uint32_t type; /**< type of the fd, one of enum spa_data_type */+ int fd; /**< fd */+ uint32_t size; /**< size of memory */+ struct pw_memmap *map; /**< optional map when PW_MEMBLOCK_FLAG_MAP was given */+};++/** a mapped region of a pw_memblock */+struct pw_memmap {+ struct pw_memblock *block; /**< owner memblock */+ void *ptr; /**< mapped pointer */+ uint32_t flags; /**< flags for the mapping on of enum pw_memmap_flags */+ uint32_t offset; /**< offset in memblock */+ uint32_t size; /**< size in memblock */+ uint32_t tag[5]; /**< user tag */+};++struct pw_mempool_events {+#define PW_VERSION_MEMPOOL_EVENTS 0+ uint32_t version;++ /** the pool is destroyed */+ void (*destroy) (void *data);++ /** a new memory block is added to the pool */+ void (*added) (void *data, struct pw_memblock *block);++ /** a memory block is removed from the pool */+ void (*removed) (void *data, struct pw_memblock *block);+};++/** Create a new memory pool */+struct pw_mempool *pw_mempool_new(struct pw_properties *props);++/** Listen for events */+void pw_mempool_add_listener(struct pw_mempool *pool,+ struct spa_hook *listener,+ const struct pw_mempool_events *events,+ void *data);++/** Clear a pool */+void pw_mempool_clear(struct pw_mempool *pool);++/** Clear and destroy a pool */+void pw_mempool_destroy(struct pw_mempool *pool);+++/** Allocate a memory block from the pool */+struct pw_memblock * pw_mempool_alloc(struct pw_mempool *pool,+ enum pw_memblock_flags flags, uint32_t type, size_t size);++/** Import a block from another pool */+struct pw_memblock * pw_mempool_import_block(struct pw_mempool *pool,+ struct pw_memblock *mem);++/** Import an fd into the pool */+struct pw_memblock * pw_mempool_import(struct pw_mempool *pool,+ enum pw_memblock_flags flags, uint32_t type, int fd);++/** Free a memblock regardless of the refcount and destroy all mappings */+void pw_memblock_free(struct pw_memblock *mem);++/** Unref a memblock */+static inline void pw_memblock_unref(struct pw_memblock *mem)+{+ if (--mem->ref == 0)+ pw_memblock_free(mem);+}++/** Remove a memblock for given \a id */+int pw_mempool_remove_id(struct pw_mempool *pool, uint32_t id);++/** Find memblock for given \a ptr */+struct pw_memblock * pw_mempool_find_ptr(struct pw_mempool *pool, const void *ptr);++/** Find memblock for given \a id */+struct pw_memblock * pw_mempool_find_id(struct pw_mempool *pool, uint32_t id);++/** Find memblock for given \a fd */+struct pw_memblock * pw_mempool_find_fd(struct pw_mempool *pool, int fd);+++/** Map a region of a memory block */+struct pw_memmap * pw_memblock_map(struct pw_memblock *block,+ enum pw_memmap_flags flags, uint32_t offset, uint32_t size,+ uint32_t tag[5]);++/** Map a region of a memory block with \a id */+struct pw_memmap * pw_mempool_map_id(struct pw_mempool *pool, uint32_t id,+ enum pw_memmap_flags flags, uint32_t offset, uint32_t size,+ uint32_t tag[5]);++struct pw_memmap * pw_mempool_import_map(struct pw_mempool *pool,+ struct pw_mempool *other, void *data, uint32_t size, uint32_t tag[5]);++/** find a map with the given tag */+struct pw_memmap * pw_mempool_find_tag(struct pw_mempool *pool, uint32_t tag[5], size_t size);++/** Unmap a region */+int pw_memmap_free(struct pw_memmap *map);+++/** parameters to map a memory range */+struct pw_map_range {+ uint32_t start; /** offset in first page with start of data */+ uint32_t offset; /** page aligned offset to map */+ uint32_t size; /** size to map */+};++#define PW_MAP_RANGE_INIT (struct pw_map_range){ 0, }++/** Calculate parameters to mmap() memory into \a range so that+ * \a size bytes at \a offset can be mapped with mmap(). */+static inline void pw_map_range_init(struct pw_map_range *range,+ uint32_t offset, uint32_t size,+ uint32_t page_size)+{+ range->offset = SPA_ROUND_DOWN_N(offset, page_size);+ range->start = offset - range->offset;+ range->size = SPA_ROUND_UP_N(range->start + size, page_size);+}++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_MEM_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/module.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/module.hnew file mode 100644index 000000000..bd4eca616--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/module.h@@ -0,0 +1,103 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_MODULE_H+#define PIPEWIRE_MODULE_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>+#include <spa/utils/hook.h>++#include <pipewire/proxy.h>++/** \defgroup pw_module Module+ * Module interface+ */++/**+ * \addtogroup pw_module+ * \{+ */+#define PW_TYPE_INTERFACE_Module PW_TYPE_INFO_INTERFACE_BASE "Module"++#define PW_MODULE_PERM_MASK PW_PERM_R|PW_PERM_M++#define PW_VERSION_MODULE 3+struct pw_module;++/** The module information. Extra information can be added in later versions */+struct pw_module_info {+ uint32_t id; /**< id of the global */+ const char *name; /**< name of the module */+ const char *filename; /**< filename of the module */+ const char *args; /**< arguments passed to the module */+#define PW_MODULE_CHANGE_MASK_PROPS (1 << 0)+#define PW_MODULE_CHANGE_MASK_ALL ((1 << 1)-1)+ uint64_t change_mask; /**< bitfield of changed fields since last call */+ struct spa_dict *props; /**< extra properties */+};++/** Update and existing \ref pw_module_info with \a update with reset */+struct pw_module_info *+pw_module_info_update(struct pw_module_info *info,+ const struct pw_module_info *update);+/** Merge and existing \ref pw_module_info with \a update */+struct pw_module_info *+pw_module_info_merge(struct pw_module_info *info,+ const struct pw_module_info *update, bool reset);+/** Free a \ref pw_module_info */+void pw_module_info_free(struct pw_module_info *info);++#define PW_MODULE_EVENT_INFO 0+#define PW_MODULE_EVENT_NUM 1++/** Module events */+struct pw_module_events {+#define PW_VERSION_MODULE_EVENTS 0+ uint32_t version;+ /**+ * Notify module info+ *+ * \param info info about the module+ */+ void (*info) (void *data, const struct pw_module_info *info);+};++#define PW_MODULE_METHOD_ADD_LISTENER 0+#define PW_MODULE_METHOD_NUM 1++/** Module methods */+struct pw_module_methods {+#define PW_VERSION_MODULE_METHODS 0+ uint32_t version;++ int (*add_listener) (void *object,+ struct spa_hook *listener,+ const struct pw_module_events *events,+ void *data);+};++#define pw_module_method(o,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ spa_interface_call_res((struct spa_interface*)o, \+ struct pw_module_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++#define pw_module_add_listener(c,...) pw_module_method(c,add_listener,0,__VA_ARGS__)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* PIPEWIRE_MODULE_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/node.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/node.hnew file mode 100644index 000000000..87ba1a06e--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/node.h@@ -0,0 +1,206 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_NODE_H+#define PIPEWIRE_NODE_H++#ifdef __cplusplus+extern "C" {+#endif++#include <stdarg.h>+#include <errno.h>++#include <spa/utils/defs.h>+#include <spa/utils/hook.h>+#include <spa/node/command.h>+#include <spa/param/param.h>++#include <pipewire/proxy.h>++/** \defgroup pw_node Node+ * Node interface+ */++/**+ * \addtogroup pw_node+ * \{+ */+#define PW_TYPE_INTERFACE_Node PW_TYPE_INFO_INTERFACE_BASE "Node"++#define PW_NODE_PERM_MASK PW_PERM_RWXML++#define PW_VERSION_NODE 3+struct pw_node;++/** \enum pw_node_state The different node states */+enum pw_node_state {+ PW_NODE_STATE_ERROR = -1, /**< error state */+ PW_NODE_STATE_CREATING = 0, /**< the node is being created */+ PW_NODE_STATE_SUSPENDED = 1, /**< the node is suspended, the device might+ * be closed */+ PW_NODE_STATE_IDLE = 2, /**< the node is running but there is no active+ * port */+ PW_NODE_STATE_RUNNING = 3, /**< the node is running */+};++/** Convert a \ref pw_node_state to a readable string */+const char * pw_node_state_as_string(enum pw_node_state state);++/** The node information. Extra information can be added in later versions */+struct pw_node_info {+ uint32_t id; /**< id of the global */+ uint32_t max_input_ports; /**< maximum number of inputs */+ uint32_t max_output_ports; /**< maximum number of outputs */+#define PW_NODE_CHANGE_MASK_INPUT_PORTS (1 << 0)+#define PW_NODE_CHANGE_MASK_OUTPUT_PORTS (1 << 1)+#define PW_NODE_CHANGE_MASK_STATE (1 << 2)+#define PW_NODE_CHANGE_MASK_PROPS (1 << 3)+#define PW_NODE_CHANGE_MASK_PARAMS (1 << 4)+#define PW_NODE_CHANGE_MASK_ALL ((1 << 5)-1)+ uint64_t change_mask; /**< bitfield of changed fields since last call */+ uint32_t n_input_ports; /**< number of inputs */+ uint32_t n_output_ports; /**< number of outputs */+ enum pw_node_state state; /**< the current state of the node */+ const char *error; /**< an error reason if \a state is error */+ struct spa_dict *props; /**< the properties of the node */+ struct spa_param_info *params; /**< parameters */+ uint32_t n_params; /**< number of items in \a params */+};++struct pw_node_info *+pw_node_info_update(struct pw_node_info *info,+ const struct pw_node_info *update);++struct pw_node_info *+pw_node_info_merge(struct pw_node_info *info,+ const struct pw_node_info *update, bool reset);++void+pw_node_info_free(struct pw_node_info *info);++#define PW_NODE_EVENT_INFO 0+#define PW_NODE_EVENT_PARAM 1+#define PW_NODE_EVENT_NUM 2++/** Node events */+struct pw_node_events {+#define PW_VERSION_NODE_EVENTS 0+ uint32_t version;+ /**+ * Notify node info+ *+ * \param info info about the node+ */+ void (*info) (void *data, const struct pw_node_info *info);+ /**+ * Notify a node param+ *+ * Event emitted as a result of the enum_params method.+ *+ * \param seq the sequence number of the request+ * \param id the param id+ * \param index the param index+ * \param next the param index of the next param+ * \param param the parameter+ */+ void (*param) (void *data, int seq,+ uint32_t id, uint32_t index, uint32_t next,+ const struct spa_pod *param);+};++#define PW_NODE_METHOD_ADD_LISTENER 0+#define PW_NODE_METHOD_SUBSCRIBE_PARAMS 1+#define PW_NODE_METHOD_ENUM_PARAMS 2+#define PW_NODE_METHOD_SET_PARAM 3+#define PW_NODE_METHOD_SEND_COMMAND 4+#define PW_NODE_METHOD_NUM 5++/** Node methods */+struct pw_node_methods {+#define PW_VERSION_NODE_METHODS 0+ uint32_t version;++ int (*add_listener) (void *object,+ struct spa_hook *listener,+ const struct pw_node_events *events,+ void *data);+ /**+ * Subscribe to parameter changes+ *+ * Automatically emit param events for the given ids when+ * they are changed.+ *+ * \param ids an array of param ids+ * \param n_ids the number of ids in \a ids+ *+ * This requires X permissions on the node.+ */+ int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);++ /**+ * Enumerate node parameters+ *+ * Start enumeration of node parameters. For each param, a+ * param event will be emitted.+ *+ * \param seq a sequence number to place in the reply+ * \param id the parameter id to enum or PW_ID_ANY for all+ * \param start the start index or 0 for the first param+ * \param num the maximum number of params to retrieve+ * \param filter a param filter or NULL+ *+ * This requires X permissions on the node.+ */+ int (*enum_params) (void *object, int seq, uint32_t id,+ uint32_t start, uint32_t num,+ const struct spa_pod *filter);++ /**+ * Set a parameter on the node+ *+ * \param id the parameter id to set+ * \param flags extra parameter flags+ * \param param the parameter to set+ *+ * This requires X and W permissions on the node.+ */+ int (*set_param) (void *object, uint32_t id, uint32_t flags,+ const struct spa_pod *param);++ /**+ * Send a command to the node+ *+ * \param command the command to send+ *+ * This requires X and W permissions on the node.+ */+ int (*send_command) (void *object, const struct spa_command *command);+};++#define pw_node_method(o,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ spa_interface_call_res((struct spa_interface*)o, \+ struct pw_node_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++/** Node */+#define pw_node_add_listener(c,...) pw_node_method(c,add_listener,0,__VA_ARGS__)+#define pw_node_subscribe_params(c,...) pw_node_method(c,subscribe_params,0,__VA_ARGS__)+#define pw_node_enum_params(c,...) pw_node_method(c,enum_params,0,__VA_ARGS__)+#define pw_node_set_param(c,...) pw_node_method(c,set_param,0,__VA_ARGS__)+#define pw_node_send_command(c,...) pw_node_method(c,send_command,0,__VA_ARGS__)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* PIPEWIRE_NODE_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/permission.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/permission.hnew file mode 100644index 000000000..22eebdb26--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/permission.h@@ -0,0 +1,72 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_PERMISSION_H+#define PIPEWIRE_PERMISSION_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>++/** \defgroup pw_permission Permission+ *+ * Permissions are kept for a client and describe what the client is+ * allowed to do with an object.+ *+ * See \ref page_core_api+ */++/**+ * \addtogroup pw_permission+ * \{+ */++#define PW_PERM_R 0400 /**< object can be seen and events can be received */+#define PW_PERM_W 0200 /**< methods can be called that modify the object */+#define PW_PERM_X 0100 /**< methods can be called on the object. The W flag must be+ * present in order to call methods that modify the object. */+#define PW_PERM_M 0010 /**< metadata can be set on object, Since 0.3.9 */+#define PW_PERM_L 0020 /**< a link can be made between a node that doesn't have+ * permission to see the other node, Since 0.3.77 */++#define PW_PERM_RW (PW_PERM_R|PW_PERM_W)+#define PW_PERM_RWX (PW_PERM_RW|PW_PERM_X)+#define PW_PERM_RWXM (PW_PERM_RWX|PW_PERM_M)+#define PW_PERM_RWXML (PW_PERM_RWXM|PW_PERM_L)++#define PW_PERM_IS_R(p) (((p)&PW_PERM_R) == PW_PERM_R)+#define PW_PERM_IS_W(p) (((p)&PW_PERM_W) == PW_PERM_W)+#define PW_PERM_IS_X(p) (((p)&PW_PERM_X) == PW_PERM_X)+#define PW_PERM_IS_M(p) (((p)&PW_PERM_M) == PW_PERM_M)+#define PW_PERM_IS_L(p) (((p)&PW_PERM_L) == PW_PERM_L)++#define PW_PERM_ALL PW_PERM_RWXM+#define PW_PERM_INVALID (uint32_t)(0xffffffff)++struct pw_permission {+ uint32_t id; /**< id of object, PW_ID_ANY for default permission */+ uint32_t permissions; /**< bitmask of above permissions */+};++#define PW_PERMISSION_INIT(id,p) ((struct pw_permission){ (id), (p) })++#define PW_PERMISSION_FORMAT "%c%c%c%c%c"+#define PW_PERMISSION_ARGS(permission) \+ (permission) & PW_PERM_R ? 'r' : '-', \+ (permission) & PW_PERM_W ? 'w' : '-', \+ (permission) & PW_PERM_X ? 'x' : '-', \+ (permission) & PW_PERM_M ? 'm' : '-', \+ (permission) & PW_PERM_L ? 'l' : '-'++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_PERMISSION_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/pipewire.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/pipewire.hnew file mode 100644index 000000000..0c495ed39--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/pipewire.h@@ -0,0 +1,101 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_H+#define PIPEWIRE_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/support/plugin.h>++#include <pipewire/array.h>+#include <pipewire/client.h>+#include <pipewire/conf.h>+#include <pipewire/context.h>+#include <pipewire/device.h>+#include <pipewire/buffers.h>+#include <pipewire/core.h>+#include <pipewire/factory.h>+#include <pipewire/keys.h>+#include <pipewire/log.h>+#include <pipewire/loop.h>+#include <pipewire/link.h>+#include <pipewire/main-loop.h>+#include <pipewire/map.h>+#include <pipewire/mem.h>+#include <pipewire/module.h>+#include <pipewire/node.h>+#include <pipewire/properties.h>+#include <pipewire/proxy.h>+#include <pipewire/permission.h>+#include <pipewire/protocol.h>+#include <pipewire/port.h>+#include <pipewire/stream.h>+#include <pipewire/filter.h>+#include <pipewire/thread-loop.h>+#include <pipewire/data-loop.h>+#include <pipewire/type.h>+#include <pipewire/utils.h>+#include <pipewire/version.h>++/** \defgroup pw_pipewire Initialization+ * Initializing PipeWire and loading SPA modules.+ */++/**+ * \addtogroup pw_pipewire+ * \{+ */+void+pw_init(int *argc, char **argv[]);++void pw_deinit(void);++bool+pw_debug_is_category_enabled(const char *name);++const char *+pw_get_application_name(void);++const char *+pw_get_prgname(void);++const char *+pw_get_user_name(void);++const char *+pw_get_host_name(void);++const char *+pw_get_client_name(void);++bool pw_check_option(const char *option, const char *value);++enum pw_direction+pw_direction_reverse(enum pw_direction direction);++int pw_set_domain(const char *domain);+const char *pw_get_domain(void);++uint32_t pw_get_support(struct spa_support *support, uint32_t max_support);++struct spa_handle *pw_load_spa_handle(const char *lib,+ const char *factory_name,+ const struct spa_dict *info,+ uint32_t n_support,+ const struct spa_support support[]);++int pw_unload_spa_handle(struct spa_handle *handle);++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/port.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/port.hnew file mode 100644index 000000000..d0ada8b73--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/port.h@@ -0,0 +1,165 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_PORT_H+#define PIPEWIRE_PORT_H++#ifdef __cplusplus+extern "C" {+#endif++#include <stdarg.h>+#include <errno.h>++#include <spa/utils/defs.h>+#include <spa/utils/hook.h>+#include <spa/param/param.h>++#include <pipewire/proxy.h>++/** \defgroup pw_port Port+ * Port interface+ */++/**+ * \addtogroup pw_port+ * \{+ */++#define PW_TYPE_INTERFACE_Port PW_TYPE_INFO_INTERFACE_BASE "Port"++#define PW_PORT_PERM_MASK PW_PERM_R|PW_PERM_X|PW_PERM_M++#define PW_VERSION_PORT 3+struct pw_port;++/** The direction of a port */+#define pw_direction spa_direction+#define PW_DIRECTION_INPUT SPA_DIRECTION_INPUT+#define PW_DIRECTION_OUTPUT SPA_DIRECTION_OUTPUT++/** Convert a \ref pw_direction to a readable string */+const char * pw_direction_as_string(enum pw_direction direction);++struct pw_port_info {+ uint32_t id; /**< id of the global */+ enum pw_direction direction; /**< port direction */+#define PW_PORT_CHANGE_MASK_PROPS (1 << 0)+#define PW_PORT_CHANGE_MASK_PARAMS (1 << 1)+#define PW_PORT_CHANGE_MASK_ALL ((1 << 2)-1)+ uint64_t change_mask; /**< bitfield of changed fields since last call */+ struct spa_dict *props; /**< the properties of the port */+ struct spa_param_info *params; /**< parameters */+ uint32_t n_params; /**< number of items in \a params */+};++struct pw_port_info *+pw_port_info_update(struct pw_port_info *info,+ const struct pw_port_info *update);++struct pw_port_info *+pw_port_info_merge(struct pw_port_info *info,+ const struct pw_port_info *update, bool reset);++void+pw_port_info_free(struct pw_port_info *info);++#define PW_PORT_EVENT_INFO 0+#define PW_PORT_EVENT_PARAM 1+#define PW_PORT_EVENT_NUM 2++/** Port events */+struct pw_port_events {+#define PW_VERSION_PORT_EVENTS 0+ uint32_t version;+ /**+ * Notify port info+ *+ * \param info info about the port+ */+ void (*info) (void *data, const struct pw_port_info *info);+ /**+ * Notify a port param+ *+ * Event emitted as a result of the enum_params method.+ *+ * \param seq the sequence number of the request+ * \param id the param id+ * \param index the param index+ * \param next the param index of the next param+ * \param param the parameter+ */+ void (*param) (void *data, int seq,+ uint32_t id, uint32_t index, uint32_t next,+ const struct spa_pod *param);+};++#define PW_PORT_METHOD_ADD_LISTENER 0+#define PW_PORT_METHOD_SUBSCRIBE_PARAMS 1+#define PW_PORT_METHOD_ENUM_PARAMS 2+#define PW_PORT_METHOD_NUM 3++/** Port methods */+struct pw_port_methods {+#define PW_VERSION_PORT_METHODS 0+ uint32_t version;++ int (*add_listener) (void *object,+ struct spa_hook *listener,+ const struct pw_port_events *events,+ void *data);+ /**+ * Subscribe to parameter changes+ *+ * Automatically emit param events for the given ids when+ * they are changed.+ *+ * \param ids an array of param ids+ * \param n_ids the number of ids in \a ids+ *+ * This requires X permissions on the port.+ */+ int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);++ /**+ * Enumerate port parameters+ *+ * Start enumeration of port parameters. For each param, a+ * param event will be emitted.+ *+ * \param seq a sequence number returned in the reply+ * \param id the parameter id to enumerate+ * \param start the start index or 0 for the first param+ * \param num the maximum number of params to retrieve+ * \param filter a param filter or NULL+ *+ * This requires X permissions on the port.+ */+ int (*enum_params) (void *object, int seq,+ uint32_t id, uint32_t start, uint32_t num,+ const struct spa_pod *filter);+};++#define pw_port_method(o,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ spa_interface_call_res((struct spa_interface*)o, \+ struct pw_port_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++#define pw_port_add_listener(c,...) pw_port_method(c,add_listener,0,__VA_ARGS__)+#define pw_port_subscribe_params(c,...) pw_port_method(c,subscribe_params,0,__VA_ARGS__)+#define pw_port_enum_params(c,...) pw_port_method(c,enum_params,0,__VA_ARGS__)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* PIPEWIRE_PORT_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/properties.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/properties.hnew file mode 100644index 000000000..13963c1cd--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/properties.h@@ -0,0 +1,183 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_PROPERTIES_H+#define PIPEWIRE_PROPERTIES_H++#ifdef __cplusplus+extern "C" {+#endif++#include <stdarg.h>++#include <spa/utils/dict.h>+#include <spa/utils/string.h>++/** \defgroup pw_properties Properties+ *+ * Properties are used to pass around arbitrary key/value pairs.+ * Both keys and values are strings which keeps things simple.+ * Encoding of arbitrary values should be done by using a string+ * serialization such as base64 for binary blobs.+ */++/**+ * \addtogroup pw_properties+ * \{+ */+struct pw_properties {+ struct spa_dict dict; /**< dictionary of key/values */+ uint32_t flags; /**< extra flags */+};++struct pw_properties *+pw_properties_new(const char *key, ...) SPA_SENTINEL;++struct pw_properties *+pw_properties_new_dict(const struct spa_dict *dict);++struct pw_properties *+pw_properties_new_string(const char *args);++struct pw_properties *+pw_properties_copy(const struct pw_properties *properties);++int pw_properties_update_keys(struct pw_properties *props,+ const struct spa_dict *dict, const char * const keys[]);+int pw_properties_update_ignore(struct pw_properties *props,+ const struct spa_dict *dict, const char * const ignore[]);++/* Update props with all key/value pairs from dict */+int pw_properties_update(struct pw_properties *props,+ const struct spa_dict *dict);+/* Update props with all key/value pairs from str */+int pw_properties_update_string(struct pw_properties *props,+ const char *str, size_t size);++int pw_properties_add(struct pw_properties *oldprops,+ const struct spa_dict *dict);+int pw_properties_add_keys(struct pw_properties *oldprops,+ const struct spa_dict *dict, const char * const keys[]);++void pw_properties_clear(struct pw_properties *properties);++void+pw_properties_free(struct pw_properties *properties);++int+pw_properties_set(struct pw_properties *properties, const char *key, const char *value);++int+pw_properties_setf(struct pw_properties *properties,+ const char *key, const char *format, ...) SPA_PRINTF_FUNC(3, 4);+int+pw_properties_setva(struct pw_properties *properties,+ const char *key, const char *format, va_list args) SPA_PRINTF_FUNC(3,0);+const char *+pw_properties_get(const struct pw_properties *properties, const char *key);++int+pw_properties_fetch_uint32(const struct pw_properties *properties, const char *key, uint32_t *value);++int+pw_properties_fetch_int32(const struct pw_properties *properties, const char *key, int32_t *value);++int+pw_properties_fetch_uint64(const struct pw_properties *properties, const char *key, uint64_t *value);++int+pw_properties_fetch_int64(const struct pw_properties *properties, const char *key, int64_t *value);++int+pw_properties_fetch_bool(const struct pw_properties *properties, const char *key, bool *value);++static inline uint32_t+pw_properties_get_uint32(const struct pw_properties *properties, const char *key, uint32_t deflt)+{+ uint32_t val = deflt;+ pw_properties_fetch_uint32(properties, key, &val);+ return val;+}++static inline int32_t+pw_properties_get_int32(const struct pw_properties *properties, const char *key, int32_t deflt)+{+ int32_t val = deflt;+ pw_properties_fetch_int32(properties, key, &val);+ return val;+}++static inline uint64_t+pw_properties_get_uint64(const struct pw_properties *properties, const char *key, uint64_t deflt)+{+ uint64_t val = deflt;+ pw_properties_fetch_uint64(properties, key, &val);+ return val;+}++static inline int64_t+pw_properties_get_int64(const struct pw_properties *properties, const char *key, int64_t deflt)+{+ int64_t val = deflt;+ pw_properties_fetch_int64(properties, key, &val);+ return val;+}+++static inline bool+pw_properties_get_bool(const struct pw_properties *properties, const char *key, bool deflt)+{+ bool val = deflt;+ pw_properties_fetch_bool(properties, key, &val);+ return val;+}++const char *+pw_properties_iterate(const struct pw_properties *properties, void **state);++#define PW_PROPERTIES_FLAG_NL (1<<0)+#define PW_PROPERTIES_FLAG_RECURSE (1<<1)+#define PW_PROPERTIES_FLAG_ENCLOSE (1<<2)+#define PW_PROPERTIES_FLAG_ARRAY (1<<3)+#define PW_PROPERTIES_FLAG_COLORS (1<<4)+int pw_properties_serialize_dict(FILE *f, const struct spa_dict *dict, uint32_t flags);++static inline bool pw_properties_parse_bool(const char *value) {+ return spa_atob(value);+}++static inline int pw_properties_parse_int(const char *value) {+ int v;+ return spa_atoi32(value, &v, 0) ? v: 0;+}++static inline int64_t pw_properties_parse_int64(const char *value) {+ int64_t v;+ return spa_atoi64(value, &v, 0) ? v : 0;+}++static inline uint64_t pw_properties_parse_uint64(const char *value) {+ uint64_t v;+ return spa_atou64(value, &v, 0) ? v : 0;+}++static inline float pw_properties_parse_float(const char *value) {+ float v;+ return spa_atof(value, &v) ? v : 0.0f;+}++static inline double pw_properties_parse_double(const char *value) {+ double v;+ return spa_atod(value, &v) ? v : 0.0;+}++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_PROPERTIES_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/protocol.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/protocol.hnew file mode 100644index 000000000..8cd9c7bcf--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/protocol.h@@ -0,0 +1,142 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_PROTOCOL_H+#define PIPEWIRE_PROTOCOL_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/list.h>++/** \defgroup pw_protocol Protocol+ *+ * \brief Manages protocols and their implementation+ */++/**+ * \addtogroup pw_protocol+ * \{+ */++struct pw_protocol;++#include <pipewire/context.h>+#include <pipewire/properties.h>+#include <pipewire/utils.h>++#define PW_TYPE_INFO_Protocol "PipeWire:Protocol"+#define PW_TYPE_INFO_PROTOCOL_BASE PW_TYPE_INFO_Protocol ":"++struct pw_protocol_client {+ struct spa_list link; /**< link in protocol client_list */+ struct pw_protocol *protocol; /**< the owner protocol */++ struct pw_core *core;++ int (*connect) (struct pw_protocol_client *client,+ const struct spa_dict *props,+ void (*done_callback) (void *data, int result),+ void *data);+ int (*connect_fd) (struct pw_protocol_client *client, int fd, bool close);+ int (*steal_fd) (struct pw_protocol_client *client);+ void (*disconnect) (struct pw_protocol_client *client);+ void (*destroy) (struct pw_protocol_client *client);+ int (*set_paused) (struct pw_protocol_client *client, bool paused);+};++#define pw_protocol_client_connect(c,p,cb,d) ((c)->connect(c,p,cb,d))+#define pw_protocol_client_connect_fd(c,fd,cl) ((c)->connect_fd(c,fd,cl))+#define pw_protocol_client_steal_fd(c) ((c)->steal_fd(c))+#define pw_protocol_client_disconnect(c) ((c)->disconnect(c))+#define pw_protocol_client_destroy(c) ((c)->destroy(c))+#define pw_protocol_client_set_paused(c,p) ((c)->set_paused(c,p))++struct pw_protocol_server {+ struct spa_list link; /**< link in protocol server_list */+ struct pw_protocol *protocol; /**< the owner protocol */++ struct pw_impl_core *core;++ struct spa_list client_list; /**< list of clients of this protocol */++ void (*destroy) (struct pw_protocol_server *listen);+};++#define pw_protocol_server_destroy(l) ((l)->destroy(l))++struct pw_protocol_marshal {+ const char *type; /**< interface type */+ uint32_t version; /**< version */+#define PW_PROTOCOL_MARSHAL_FLAG_IMPL (1 << 0) /**< marshal for implementations */+ uint32_t flags; /**< version */+ uint32_t n_client_methods; /**< number of client methods */+ uint32_t n_server_methods; /**< number of server methods */+ const void *client_marshal;+ const void *server_demarshal;+ const void *server_marshal;+ const void *client_demarshal;+};++struct pw_protocol_implementation {+#define PW_VERSION_PROTOCOL_IMPLEMENTATION 0+ uint32_t version;++ struct pw_protocol_client * (*new_client) (struct pw_protocol *protocol,+ struct pw_core *core,+ const struct spa_dict *props);+ struct pw_protocol_server * (*add_server) (struct pw_protocol *protocol,+ struct pw_impl_core *core,+ const struct spa_dict *props);+};++struct pw_protocol_events {+#define PW_VERSION_PROTOCOL_EVENTS 0+ uint32_t version;++ void (*destroy) (void *data);+};++#define pw_protocol_new_client(p,...) (pw_protocol_get_implementation(p)->new_client(p,__VA_ARGS__))+#define pw_protocol_add_server(p,...) (pw_protocol_get_implementation(p)->add_server(p,__VA_ARGS__))+#define pw_protocol_ext(p,type,method,...) (((type*)pw_protocol_get_extension(p))->method( __VA_ARGS__))++struct pw_protocol *pw_protocol_new(struct pw_context *context, const char *name, size_t user_data_size);++void pw_protocol_destroy(struct pw_protocol *protocol);++struct pw_context *pw_protocol_get_context(struct pw_protocol *protocol);++void *pw_protocol_get_user_data(struct pw_protocol *protocol);++const struct pw_protocol_implementation *+pw_protocol_get_implementation(struct pw_protocol *protocol);++const void *+pw_protocol_get_extension(struct pw_protocol *protocol);+++void pw_protocol_add_listener(struct pw_protocol *protocol,+ struct spa_hook *listener,+ const struct pw_protocol_events *events,+ void *data);++int pw_protocol_add_marshal(struct pw_protocol *protocol,+ const struct pw_protocol_marshal *marshal);++const struct pw_protocol_marshal *+pw_protocol_get_marshal(struct pw_protocol *protocol, const char *type, uint32_t version, uint32_t flags);++struct pw_protocol * pw_context_find_protocol(struct pw_context *context, const char *name);++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* PIPEWIRE_PROTOCOL_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/proxy.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/proxy.hnew file mode 100644index 000000000..b46c41725--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/proxy.h@@ -0,0 +1,203 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_PROXY_H+#define PIPEWIRE_PROXY_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/hook.h>++/** \page page_proxy Proxy+ *+ * \see \ref pw_proxy+ *+ * \section sec_page_proxy_overview Overview+ *+ * The proxy object is a client side representation of a resource+ * that lives on a remote PipeWire instance.+ *+ * It is used to communicate with the remote object.+ *+ * \section sec_page_proxy_core Core proxy+ *+ * A proxy for a remote core object can be obtained by making+ * a remote connection with \ref pw_context_connect.+ * See \ref pw_proxy+ *+ * Some methods on proxy object allow creation of more proxy objects or+ * create a binding between a local proxy and global resource.+ *+ * \section sec_page_proxy_create Create+ *+ * A client first creates a new proxy object with pw_proxy_new(). A+ * type must be provided for this object.+ *+ * The protocol of the context will usually install an interface to+ * translate method calls and events to the wire format.+ *+ * The creator of the proxy will usually also install an event+ * implementation of the particular object type.+ *+ * \section sec_page_proxy_bind Bind+ *+ * To actually use the proxy object, one needs to create a server+ * side resource for it. This can be done by, for example, binding+ * to a global object or by calling a method that creates and binds+ * to a new remote object. In all cases, the local id is passed to+ * the server and is used to create a resource with the same id.+ *+ * \section sec_page_proxy_methods Methods+ *+ * To call a method on the proxy use the interface methods. Calling+ * any interface method will result in a request to the server to+ * perform the requested action on the corresponding resource.+ *+ * \section sec_page_proxy_events Events+ *+ * Events send from the server to the proxy will be demarshalled by+ * the protocol and will then result in a call to the installed+ * implementation of the proxy.+ *+ * \section sec_page_proxy_destroy Destroy+ *+ * Use pw_proxy_destroy() to destroy the client side object. This+ * is usually done automatically when the server removes the resource+ * associated to the proxy.+ */++/** \defgroup pw_proxy Proxy+ *+ * \brief Represents an object on the client side.+ *+ * A pw_proxy acts as a client side proxy to an object existing in a remote+ * pipewire instance. The proxy is responsible for converting interface functions+ * invoked by the client to PipeWire messages. Events will call the handlers+ * set in listener.+ *+ * \see \ref page_proxy+ */++/**+ * \addtogroup pw_proxy+ * \{+ */+struct pw_proxy;++#include <pipewire/protocol.h>++/** Proxy events, use \ref pw_proxy_add_listener */+struct pw_proxy_events {+#define PW_VERSION_PROXY_EVENTS 1+ uint32_t version;++ /** The proxy is destroyed */+ void (*destroy) (void *data);++ /** a proxy is bound to a global id */+ void (*bound) (void *data, uint32_t global_id);++ /** a proxy is removed from the server. Use pw_proxy_destroy to+ * free the proxy. */+ void (*removed) (void *data);++ /** a reply to a sync method completed */+ void (*done) (void *data, int seq);++ /** an error occurred on the proxy */+ void (*error) (void *data, int seq, int res, const char *message);++ void (*bound_props) (void *data, uint32_t global_id, const struct spa_dict *props);+};++/* Make a new proxy object. The id can be used to bind to a remote object and+ * can be retrieved with \ref pw_proxy_get_id . */+struct pw_proxy *+pw_proxy_new(struct pw_proxy *factory,+ const char *type, /* interface type */+ uint32_t version, /* interface version */+ size_t user_data_size /* size of user data */);++/** Add an event listener to proxy */+void pw_proxy_add_listener(struct pw_proxy *proxy,+ struct spa_hook *listener,+ const struct pw_proxy_events *events,+ void *data);++/** Add a listener for the events received from the remote object. The+ * events depend on the type of the remote object type. */+void pw_proxy_add_object_listener(struct pw_proxy *proxy, /**< the proxy */+ struct spa_hook *listener, /**< listener */+ const void *funcs, /**< proxied functions */+ void *data /**< data passed to events */);++/** destroy a proxy */+void pw_proxy_destroy(struct pw_proxy *proxy);++void pw_proxy_ref(struct pw_proxy *proxy);+void pw_proxy_unref(struct pw_proxy *proxy);++/** Get the user_data. The size was given in \ref pw_proxy_new */+void *pw_proxy_get_user_data(struct pw_proxy *proxy);++/** Get the local id of the proxy */+uint32_t pw_proxy_get_id(struct pw_proxy *proxy);++/** Get the type and version of the proxy */+const char *pw_proxy_get_type(struct pw_proxy *proxy, uint32_t *version);++/** Get the protocol used for the proxy */+struct pw_protocol *pw_proxy_get_protocol(struct pw_proxy *proxy);++/** Generate an sync method for a proxy. This will generate a done event+ * with the same seq number of the reply. */+int pw_proxy_sync(struct pw_proxy *proxy, int seq);++/** Set the global id this proxy is bound to. This is usually used internally+ * and will also emit the bound event */+int pw_proxy_set_bound_id(struct pw_proxy *proxy, uint32_t global_id);+/** Get the global id bound to this proxy of SPA_ID_INVALID when not bound+ * to a global */+uint32_t pw_proxy_get_bound_id(struct pw_proxy *proxy);++/** Generate an error for a proxy */+int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error);+int pw_proxy_errorf(struct pw_proxy *proxy, int res, const char *error, ...) SPA_PRINTF_FUNC(3, 4);++/** Get the listener of proxy */+struct spa_hook_list *pw_proxy_get_object_listeners(struct pw_proxy *proxy);++/** Get the marshal functions for the proxy */+const struct pw_protocol_marshal *pw_proxy_get_marshal(struct pw_proxy *proxy);++/** Install a marshal function on a proxy */+int pw_proxy_install_marshal(struct pw_proxy *proxy, bool implementor);++#define pw_proxy_notify(p,type,event,version,...) \+ spa_hook_list_call(pw_proxy_get_object_listeners(p), \+ type, event, version, ## __VA_ARGS__)++#define pw_proxy_call(p,type,method,version,...) \+ spa_interface_call((struct spa_interface*)p, \+ type, method, version, ##__VA_ARGS__)++#define pw_proxy_call_res(p,type,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ spa_interface_call_res((struct spa_interface*)p, \+ type, _res, method, version, ##__VA_ARGS__); \+ _res; \+})++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_PROXY_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/stream.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/stream.hnew file mode 100644index 000000000..9f44e821a--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/stream.h@@ -0,0 +1,554 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_STREAM_H+#define PIPEWIRE_STREAM_H++#ifdef __cplusplus+extern "C" {+#endif++/** \page page_streams Streams+ *+ * \see \ref pw_stream+ *+ * \section sec_overview Overview+ *+ * \ref pw_stream "Streams" are used to exchange data with the+ * PipeWire server. A stream is a wrapper around a proxy for a pw_client_node+ * with an adapter. This means the stream will automatically do conversion+ * to the type required by the server.+ *+ * Streams can be used to:+ *+ * \li Consume a stream from PipeWire. This is a PW_DIRECTION_INPUT stream.+ * \li Produce a stream to PipeWire. This is a PW_DIRECTION_OUTPUT stream+ *+ * You can connect the stream port to a specific server port or let PipeWire+ * choose a port for you.+ *+ * For more complicated nodes such as filters or ports with multiple+ * inputs and/or outputs you will need to use the pw_filter or make+ * a pw_node yourself and export it with \ref pw_core_export.+ *+ * Streams can also be used to:+ *+ * \li Implement a Sink in PipeWire. This is a PW_DIRECTION_INPUT stream.+ * \li Implement a Source in PipeWire. This is a PW_DIRECTION_OUTPUT stream+ *+ * In this case, the PW_KEY_MEDIA_CLASS property needs to be set to+ * "Audio/Sink" or "Audio/Source" respectively.+ *+ * \section sec_create Create+ *+ * Make a new stream with \ref pw_stream_new(). You will need to specify+ * a name for the stream and extra properties. The basic set of properties+ * each stream must provide is filled in automatically.+ *+ * Once the stream is created, the state_changed event should be used to+ * track the state of the stream.+ *+ * \section sec_connect Connect+ *+ * The stream is initially unconnected. To connect the stream, use+ * \ref pw_stream_connect(). Pass the desired direction as an argument.+ *+ * The direction is:++ * \li PW_DIRECTION_INPUT for a stream that *consumes* data. This can be a+ * stream that captures from a Source or a when the stream is used to+ * implement a Sink.+ *+ * \li PW_DIRECTION_OUTPUT for a stream that *produces* data. This can be a+ * stream that plays to a Sink or when the stream is used to implement+ * a Source.+ *+ * \subsection ssec_stream_target Stream target+ *+ * To make the newly connected stream automatically connect to an existing+ * PipeWire node, use the \ref PW_STREAM_FLAG_AUTOCONNECT and set the+ * PW_KEY_OBJECT_SERIAL or the PW_KEY_NODE_NAME value of the target node+ * in the PW_KEY_TARGET_OBJECT property before connecting.+ *+ * \subsection ssec_stream_formats Stream formats+ *+ * An array of possible formats that this stream can consume or provide+ * must be specified.+ *+ * \section sec_format Format negotiation+ *+ * After connecting the stream, the server will want to configure some+ * parameters on the stream. You will be notified of these changes+ * with the param_changed event.+ *+ * When a format param change is emitted, the client should now prepare+ * itself to deal with the format and complete the negotiation procedure+ * with a call to \ref pw_stream_update_params().+ *+ * As arguments to \ref pw_stream_update_params() an array of spa_param+ * structures must be given. They contain parameters such as buffer size,+ * number of buffers, required metadata and other parameters for the+ * media buffers.+ *+ * \section sec_buffers Buffer negotiation+ *+ * After completing the format negotiation, PipeWire will allocate and+ * notify the stream of the buffers that will be used to exchange data+ * between client and server.+ *+ * With the add_buffer event, a stream will be notified of a new buffer+ * that can be used for data transport. You can attach user_data to these+ * buffers. The buffers can only be used with the stream that emitted+ * the add_buffer event.+ *+ * After the buffers are negotiated, the stream will transition to the+ * \ref PW_STREAM_STATE_PAUSED state.+ *+ * \section sec_streaming Streaming+ *+ * From the \ref PW_STREAM_STATE_PAUSED state, the stream can be set to+ * the \ref PW_STREAM_STATE_STREAMING state by the PipeWire server when+ * data transport is started.+ *+ * Depending on how the stream was connected it will need to Produce or+ * Consume data for/from PipeWire as explained in the following+ * subsections.+ *+ * \subsection ssec_consume Consume data+ *+ * The process event is emitted for each new buffer that can be+ * consumed.+ *+ * \ref pw_stream_dequeue_buffer() should be used to get the data and+ * metadata of the buffer.+ *+ * The buffer is owned by the stream and stays alive until the+ * remove_buffer callback has returned or the stream is destroyed.+ *+ * When the buffer has been processed, call \ref pw_stream_queue_buffer()+ * to let PipeWire reuse the buffer.+ *+ * \subsection ssec_produce Produce data+ *+ * \ref pw_stream_dequeue_buffer() gives an empty buffer that can be filled.+ *+ * The buffer is owned by the stream and stays alive until the+ * remove_buffer event is emitted or the stream is destroyed.+ *+ * Filled buffers should be queued with \ref pw_stream_queue_buffer().+ *+ * The process event is emitted when PipeWire has emptied a buffer that+ * can now be refilled.+ *+ * \section sec_stream_disconnect Disconnect+ *+ * Use \ref pw_stream_disconnect() to disconnect a stream after use.+ *+ * \section sec_stream_configuration Configuration+ *+ * \subsection ssec_config_properties Stream Properties+ *+ * \subsection ssec_config_rules Stream Rules+ *+ * \section sec_stream_environment Environment Variables+ *+ * The environment variable PIPEWIRE_AUTOCONNECT can be used to override the+ * flag and force apps to autoconnect or not.+ *+ */+/** \defgroup pw_stream Stream+ *+ * \brief PipeWire stream objects+ *+ * The stream object provides a convenient way to send and+ * receive data streams from/to PipeWire.+ *+ * \see \ref page_streams, \ref api_pw_core+ */++/**+ * \addtogroup pw_stream+ * \{+ */+struct pw_stream;++#include <spa/buffer/buffer.h>+#include <spa/param/param.h>+#include <spa/pod/command.h>++/** \enum pw_stream_state The state of a stream */+enum pw_stream_state {+ PW_STREAM_STATE_ERROR = -1, /**< the stream is in error */+ PW_STREAM_STATE_UNCONNECTED = 0, /**< unconnected */+ PW_STREAM_STATE_CONNECTING = 1, /**< connection is in progress */+ PW_STREAM_STATE_PAUSED = 2, /**< paused */+ PW_STREAM_STATE_STREAMING = 3 /**< streaming */+};++/** a buffer structure obtained from pw_stream_dequeue_buffer(). The size of this+ * structure can grow as more fields are added in the future */+struct pw_buffer {+ struct spa_buffer *buffer; /**< the spa buffer */+ void *user_data; /**< user data attached to the buffer. The user of+ * the stream can set custom data associated with the+ * buffer, typically in the add_buffer event. Any+ * cleanup should be performed in the remove_buffer+ * event. The user data is returned unmodified each+ * time a buffer is dequeued. */+ uint64_t size; /**< This field is set by the user and the sum of+ * all queued buffers is returned in the time info.+ * For audio, it is advised to use the number of+ * samples in the buffer for this field. */+ uint64_t requested; /**< For playback streams, this field contains the+ * suggested amount of data to provide. For audio+ * streams this will be the amount of samples+ * required by the resampler. This field is 0+ * when no suggestion is provided. Since 0.3.49 */+ uint64_t time; /**< For capture streams, this field contains the+ * cycle time in nanoseconds when this buffer was+ * queued in the stream. It can be compared against+ * the pw_time values or pw_stream_get_nsec()+ * Since 1.0.5 */+};++struct pw_stream_control {+ const char *name; /**< name of the control */+ uint32_t flags; /**< extra flags (unused) */+ float def; /**< default value */+ float min; /**< min value */+ float max; /**< max value */+ float *values; /**< array of values */+ uint32_t n_values; /**< number of values in array */+ uint32_t max_values; /**< max values that can be set on this control */+};++/** A time structure.+ *+ * Use pw_stream_get_time_n() to get an updated time snapshot of the stream.+ * The time snapshot can give information about the time in the driver of the+ * graph, the delay to the edge of the graph and the internal queuing in the+ * stream.+ *+ * pw_time.ticks gives a monotonic increasing counter of the time in the graph+ * driver. I can be used to generate a timetime to schedule samples as well+ * as detect discontinuities in the timeline caused by xruns.+ *+ * pw_time.delay is expressed as pw_time.rate, the time domain of the graph. This+ * value, and pw_time.ticks, were captured at pw_time.now and can be extrapolated+ * to the current time like this:+ *+ *\code{.c}+ * uint64_t now = pw_stream_get_nsec(stream);+ * int64_t diff = now - pw_time.now;+ * int64_t elapsed = (pw_time.rate.denom * diff) / (pw_time.rate.num * SPA_NSEC_PER_SEC);+ *\endcode+ *+ * pw_time.delay contains the total delay that a signal will travel through the+ * graph. This includes the delay caused by filters in the graph as well as delays+ * caused by the hardware. The delay is usually quite stable and should only change when+ * the topology, quantum or samplerate of the graph changes.+ *+ * pw_time.queued and pw_time.buffered is expressed in the time domain of the stream,+ * or the format that is used for the buffers of this stream.+ *+ * pw_time.queued is the sum of all the pw_buffer.size fields of the buffers that are+ * currently queued in the stream but not yet processed. The application can choose+ * the units of this value, for example, time, samples or bytes (below expressed+ * as app.rate).+ *+ * pw_time.buffered is format dependent, for audio/raw it contains the number of samples+ * that are buffered inside the resampler/converter.+ *+ * The total delay of data in a stream is the sum of the queued and buffered data+ * (not yet processed data) and the delay to the edge of the graph, usually a+ * playback or capture device.+ *+ * For an audio playback stream, if you were to queue a buffer, the total delay+ * in milliseconds for the first sample in the newly queued buffer to be played+ * by the hardware can be calculated as:+ *+ *\code{.unparsed}+ * (pw_time.buffered * 1000 / stream.samplerate) ++ * (pw_time.queued * 1000 / app.rate) ++ * ((pw_time.delay - elapsed) * 1000 * pw_time.rate.num / pw_time.rate.denom)+ *\endcode+ *+ * The current extrapolated time (in ms) in the source or sink can be calculated as:+ *+ *\code{.unparsed}+ * (pw_time.ticks + elapsed) * 1000 * pw_time.rate.num / pw_time.rate.denom+ *\endcode+ *+ * Below is an overview of the different timing values:+ *+ *\code{.unparsed}+ * stream time domain graph time domain+ * /-----------------------\/-----------------------------\+ *+ * queue +-+ +-+ +-----------+ +--------++ * ----> | | | |->| converter | -> graph -> | kernel | -> speaker+ * <---- +-+ +-+ +-----------+ +--------++ * dequeue buffers \-------------------/\--------/+ * graph internal+ * latency latency+ * \--------/\-------------/\-----------------------------/+ * queued buffered delay+ *\endcode+ */+struct pw_time {+ int64_t now; /**< the time in nanoseconds. This is the time when this+ * time report was updated. It is usually updated every+ * graph cycle. You can use pw_stream_get_nsec() to+ * calculate the elapsed time between this report and+ * the current time and calculate updated ticks and delay+ * values. */+ struct spa_fraction rate; /**< the rate of \a ticks and delay. This is usually+ * expressed in 1/<samplerate>. */+ uint64_t ticks; /**< the ticks at \a now. This is the current time that+ * the remote end is reading/writing. This is monotonicaly+ * increasing. */+ int64_t delay; /**< delay to device. This is the time it will take for+ * the next output sample of the stream to be presented by+ * the playback device or the time a sample traveled+ * from the capture device. This delay includes the+ * delay introduced by all filters on the path between+ * the stream and the device. The delay is normally+ * constant in a graph and can change when the topology+ * of the graph or the quantum changes. This delay does+ * not include the delay caused by queued buffers. */+ uint64_t queued; /**< data queued in the stream, this is the sum+ * of the size fields in the pw_buffer that are+ * currently queued */+ uint64_t buffered; /**< for audio/raw streams, this contains the extra+ * number of samples buffered in the resampler.+ * Since 0.3.50. */+ uint32_t queued_buffers; /**< the number of buffers that are queued. Since 0.3.50 */+ uint32_t avail_buffers; /**< the number of buffers that can be dequeued. Since 0.3.50 */+ uint64_t size; /**< for audio/raw playback streams, this contains the number of+ * samples requested by the resampler for the current+ * quantum. for audio/raw capture streams this will be the number+ * of samples available for the current quantum. Since 1.0.5 */+};++#include <pipewire/port.h>++/** Events for a stream. These events are always called from the mainloop+ * unless explicitly documented otherwise. */+struct pw_stream_events {+#define PW_VERSION_STREAM_EVENTS 2+ uint32_t version;++ void (*destroy) (void *data);+ /** when the stream state changes */+ void (*state_changed) (void *data, enum pw_stream_state old,+ enum pw_stream_state state, const char *error);++ /** Notify information about a control. */+ void (*control_info) (void *data, uint32_t id, const struct pw_stream_control *control);++ /** when io changed on the stream. */+ void (*io_changed) (void *data, uint32_t id, void *area, uint32_t size);+ /** when a parameter changed */+ void (*param_changed) (void *data, uint32_t id, const struct spa_pod *param);++ /** when a new buffer was created for this stream */+ void (*add_buffer) (void *data, struct pw_buffer *buffer);+ /** when a buffer was destroyed for this stream */+ void (*remove_buffer) (void *data, struct pw_buffer *buffer);++ /** when a buffer can be queued (for playback streams) or+ * dequeued (for capture streams). This is normally called from the+ * mainloop but can also be called directly from the realtime data+ * thread if the user is prepared to deal with this. */+ void (*process) (void *data);++ /** The stream is drained */+ void (*drained) (void *data);++ /** A command notify, Since 0.3.39:1 */+ void (*command) (void *data, const struct spa_command *command);++ /** a trigger_process completed. Since version 0.3.40:2 */+ void (*trigger_done) (void *data);+};++/** Convert a stream state to a readable string */+const char * pw_stream_state_as_string(enum pw_stream_state state);++/** \enum pw_stream_flags Extra flags that can be used in \ref pw_stream_connect() */+enum pw_stream_flags {+ PW_STREAM_FLAG_NONE = 0, /**< no flags */+ PW_STREAM_FLAG_AUTOCONNECT = (1 << 0), /**< try to automatically connect+ * this stream */+ PW_STREAM_FLAG_INACTIVE = (1 << 1), /**< start the stream inactive,+ * pw_stream_set_active() needs to be+ * called explicitly */+ PW_STREAM_FLAG_MAP_BUFFERS = (1 << 2), /**< mmap the buffers except DmaBuf that is not+ * explicitly marked as mappable. */+ PW_STREAM_FLAG_DRIVER = (1 << 3), /**< be a driver */+ PW_STREAM_FLAG_RT_PROCESS = (1 << 4), /**< call process from the realtime+ * thread. You MUST use RT safe functions+ * in the process callback. */+ PW_STREAM_FLAG_NO_CONVERT = (1 << 5), /**< don't convert format */+ PW_STREAM_FLAG_EXCLUSIVE = (1 << 6), /**< require exclusive access to the+ * device */+ PW_STREAM_FLAG_DONT_RECONNECT = (1 << 7), /**< don't try to reconnect this stream+ * when the sink/source is removed */+ PW_STREAM_FLAG_ALLOC_BUFFERS = (1 << 8), /**< the application will allocate buffer+ * memory. In the add_buffer event, the+ * data of the buffer should be set */+ PW_STREAM_FLAG_TRIGGER = (1 << 9), /**< the output stream will not be scheduled+ * automatically but _trigger_process()+ * needs to be called. This can be used+ * when the output of the stream depends+ * on input from other streams. */+ PW_STREAM_FLAG_ASYNC = (1 << 10), /**< Buffers will not be dequeued/queued from+ * the realtime process() function. This is+ * assumed when RT_PROCESS is unset but can+ * also be the case when the process() function+ * does a trigger_process() that will then+ * dequeue/queue a buffer from another process()+ * function. since 0.3.73 */+ PW_STREAM_FLAG_EARLY_PROCESS = (1 << 11), /**< Call process as soon as there is a buffer+ * to dequeue. This is only relevant for+ * playback and when not using RT_PROCESS. It+ * can be used to keep the maximum number of+ * buffers queued. Since 0.3.81 */+};++/** Create a new unconneced \ref pw_stream+ * \return a newly allocated \ref pw_stream */+struct pw_stream *+pw_stream_new(struct pw_core *core, /**< a \ref pw_core */+ const char *name, /**< a stream media name */+ struct pw_properties *props /**< stream properties, ownership is taken */);++struct pw_stream *+pw_stream_new_simple(struct pw_loop *loop, /**< a \ref pw_loop to use */+ const char *name, /**< a stream media name */+ struct pw_properties *props,/**< stream properties, ownership is taken */+ const struct pw_stream_events *events, /**< stream events */+ void *data /**< data passed to events */);++/** Destroy a stream */+void pw_stream_destroy(struct pw_stream *stream);++void pw_stream_add_listener(struct pw_stream *stream,+ struct spa_hook *listener,+ const struct pw_stream_events *events,+ void *data);++enum pw_stream_state pw_stream_get_state(struct pw_stream *stream, const char **error);++const char *pw_stream_get_name(struct pw_stream *stream);++struct pw_core *pw_stream_get_core(struct pw_stream *stream);++const struct pw_properties *pw_stream_get_properties(struct pw_stream *stream);++int pw_stream_update_properties(struct pw_stream *stream, const struct spa_dict *dict);++/** Connect a stream for input or output on \a port_path.+ * \return 0 on success < 0 on error.+ *+ * You should connect to the process event and use pw_stream_dequeue_buffer()+ * to get the latest metadata and data. */+int+pw_stream_connect(struct pw_stream *stream, /**< a \ref pw_stream */+ enum pw_direction direction, /**< the stream direction */+ uint32_t target_id, /**< should have the value PW_ID_ANY.+ * To select a specific target+ * node, specify the+ * PW_KEY_OBJECT_SERIAL or the+ * PW_KEY_NODE_NAME value of the target+ * node in the PW_KEY_TARGET_OBJECT+ * property of the stream.+ * Specifying target nodes by+ * their id is deprecated.+ */+ enum pw_stream_flags flags, /**< stream flags */+ const struct spa_pod **params, /**< an array with params. The params+ * should ideally contain supported+ * formats. */+ uint32_t n_params /**< number of items in \a params */);++/** Get the node ID of the stream.+ * \return node ID. */+uint32_t+pw_stream_get_node_id(struct pw_stream *stream);++/** Disconnect \a stream */+int pw_stream_disconnect(struct pw_stream *stream);++/** Set the stream in error state */+int pw_stream_set_error(struct pw_stream *stream, /**< a \ref pw_stream */+ int res, /**< a result code */+ const char *error, /**< an error message */+ ...) SPA_PRINTF_FUNC(3, 4);++/** Update the param exposed on the stream. */+int+pw_stream_update_params(struct pw_stream *stream, /**< a \ref pw_stream */+ const struct spa_pod **params, /**< an array of params. */+ uint32_t n_params /**< number of elements in \a params */);++/**+ * Set a parameter on the stream. This is like pw_stream_set_control() but with+ * a complete spa_pod param. It can also be called from the param_changed event handler+ * to intercept and modify the param for the adapter. Since 0.3.70 */+int pw_stream_set_param(struct pw_stream *stream, /**< a \ref pw_stream */+ uint32_t id, /**< the id of the param */+ const struct spa_pod *param /**< the params to set */);++/** Get control values */+const struct pw_stream_control *pw_stream_get_control(struct pw_stream *stream, uint32_t id);++/** Set control values */+int pw_stream_set_control(struct pw_stream *stream, uint32_t id, uint32_t n_values, float *values, ...);++/** Query the time on the stream */+int pw_stream_get_time_n(struct pw_stream *stream, struct pw_time *time, size_t size);++/** Get the current time in nanoseconds. This value can be compared with+ * the pw_time_now value. Since 1.0.4 */+uint64_t pw_stream_get_nsec(struct pw_stream *stream);++/** Query the time on the stream, deprecated since 0.3.50,+ * use pw_stream_get_time_n() to get the fields added since 0.3.50. */+SPA_DEPRECATED+int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time);++/** Get a buffer that can be filled for playback streams or consumed+ * for capture streams. */+struct pw_buffer *pw_stream_dequeue_buffer(struct pw_stream *stream);++/** Submit a buffer for playback or recycle a buffer for capture. */+int pw_stream_queue_buffer(struct pw_stream *stream, struct pw_buffer *buffer);++/** Activate or deactivate the stream */+int pw_stream_set_active(struct pw_stream *stream, bool active);++/** Flush a stream. When \a drain is true, the drained callback will+ * be called when all data is played or recorded */+int pw_stream_flush(struct pw_stream *stream, bool drain);++/** Check if the stream is driving. The stream needs to have the+ * PW_STREAM_FLAG_DRIVER set. When the stream is driving,+ * pw_stream_trigger_process() needs to be called when data is+ * available (output) or needed (input). Since 0.3.34 */+bool pw_stream_is_driving(struct pw_stream *stream);++/** Trigger a push/pull on the stream. One iteration of the graph will+ * scheduled and process() will be called. Since 0.3.34 */+int pw_stream_trigger_process(struct pw_stream *stream);++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_STREAM_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/thread-loop.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/thread-loop.hnew file mode 100644index 000000000..f1eb1910e--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/thread-loop.h@@ -0,0 +1,157 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_THREAD_LOOP_H+#define PIPEWIRE_THREAD_LOOP_H++#ifdef __cplusplus+extern "C" {+#endif++#include <pipewire/loop.h>++/** \page page_thread_loop Thread Loop+ *+ * \see \ref pw_thread_loop+ *+ * \section sec_thread_loop_overview Overview+ *+ * The threaded loop implementation is a special wrapper around the+ * regular \ref pw_loop implementation.+ *+ * The added feature in the threaded loop is that it spawns a new thread+ * that runs the wrapped loop. This allows a synchronous application to use+ * the asynchronous API without risking to stall the PipeWire library.+ *+ * \section sec_thread_loop_create Creation+ *+ * A \ref pw_thread_loop object is created using pw_thread_loop_new().+ * The \ref pw_loop to wrap must be given as an argument along with the name+ * for the thread that will be spawned.+ *+ * After allocating the object, the thread must be started with+ * pw_thread_loop_start()+ *+ * \section sec_thread_loop_destruction Destruction+ *+ * When the PipeWire connection has been terminated, the thread must be+ * stopped and the resources freed. Stopping the thread is done using+ * pw_thread_loop_stop(), which must be called without the lock (see+ * below) held. When that function returns, the thread is stopped and the+ * \ref pw_thread_loop object can be freed using pw_thread_loop_destroy().+ *+ * \section sec_thread_loop_locking Locking+ *+ * Since the PipeWire API doesn't allow concurrent accesses to objects,+ * a locking scheme must be used to guarantee safe usage. The threaded+ * loop API provides such a scheme through the functions+ * pw_thread_loop_lock() and pw_thread_loop_unlock().+ *+ * The lock is recursive, so it's safe to use it multiple times from the same+ * thread. Just make sure you call pw_thread_loop_unlock() the same+ * number of times you called pw_thread_loop_lock().+ *+ * The lock needs to be held whenever you call any PipeWire function that+ * uses an object associated with this loop. Make sure you do not hold+ * on to the lock more than necessary though, as the threaded loop stops+ * while the lock is held.+ *+ * \section sec_thread_loop_events Events and Callbacks+ *+ * All events and callbacks are called with the thread lock held.+ *+ */+/** \defgroup pw_thread_loop Thread Loop+ *+ * The threaded loop object runs a \ref pw_loop in a separate thread+ * and ensures proper locking is done.+ *+ * All of the loop callbacks will be executed with the loop+ * lock held.+ *+ * \see \ref page_thread_loop+ */++/**+ * \addtogroup pw_thread_loop+ * \{+ */+struct pw_thread_loop;++/** Thread loop events */+struct pw_thread_loop_events {+#define PW_VERSION_THREAD_LOOP_EVENTS 0+ uint32_t version;++ /** the loop is destroyed */+ void (*destroy) (void *data);+};++/** Make a new thread loop with the given name and optional properties. */+struct pw_thread_loop *+pw_thread_loop_new(const char *name, const struct spa_dict *props);++/** Make a new thread loop with the given loop, name and optional properties.+ * When \a loop is NULL, a new loop will be created. */+struct pw_thread_loop *+pw_thread_loop_new_full(struct pw_loop *loop, const char *name, const struct spa_dict *props);++/** Destroy a thread loop */+void pw_thread_loop_destroy(struct pw_thread_loop *loop);++/** Add an event listener */+void pw_thread_loop_add_listener(struct pw_thread_loop *loop,+ struct spa_hook *listener,+ const struct pw_thread_loop_events *events,+ void *data);++/** Get the loop implementation of the thread loop */+struct pw_loop * pw_thread_loop_get_loop(struct pw_thread_loop *loop);++/** Start the thread loop */+int pw_thread_loop_start(struct pw_thread_loop *loop);++/** Stop the thread loop */+void pw_thread_loop_stop(struct pw_thread_loop *loop);++/** Lock the loop. This ensures exclusive ownership of the loop */+void pw_thread_loop_lock(struct pw_thread_loop *loop);++/** Unlock the loop */+void pw_thread_loop_unlock(struct pw_thread_loop *loop);++/** Release the lock and wait until some thread calls \ref pw_thread_loop_signal */+void pw_thread_loop_wait(struct pw_thread_loop *loop);++/** Release the lock and wait a maximum of 'wait_max_sec' seconds+ * until some thread calls \ref pw_thread_loop_signal or time out */+int pw_thread_loop_timed_wait(struct pw_thread_loop *loop, int wait_max_sec);++/** Get a struct timespec suitable for \ref pw_thread_loop_timed_wait_full.+ * Since: 0.3.7 */+int pw_thread_loop_get_time(struct pw_thread_loop *loop, struct timespec *abstime, int64_t timeout);++/** Release the lock and wait up to \a abstime until some thread calls+ * \ref pw_thread_loop_signal. Use \ref pw_thread_loop_get_time to make a timeout.+ * Since: 0.3.7 */+int pw_thread_loop_timed_wait_full(struct pw_thread_loop *loop, const struct timespec *abstime);++/** Signal all threads waiting with \ref pw_thread_loop_wait */+void pw_thread_loop_signal(struct pw_thread_loop *loop, bool wait_for_accept);++/** Signal all threads executing \ref pw_thread_loop_signal with wait_for_accept */+void pw_thread_loop_accept(struct pw_thread_loop *loop);++/** Check if inside the thread */+bool pw_thread_loop_in_thread(struct pw_thread_loop *loop);++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_THREAD_LOOP_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/type.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/type.hnew file mode 100644index 000000000..a8f982c59--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/type.h@@ -0,0 +1,45 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_TYPE_H+#define PIPEWIRE_TYPE_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/type.h>++/** \defgroup pw_type Type info+ * Type information+ */++/**+ * \addtogroup pw_type+ * \{+ */++enum {+ PW_TYPE_FIRST = SPA_TYPE_VENDOR_PipeWire,+};++#define PW_TYPE_INFO_BASE "PipeWire:"++#define PW_TYPE_INFO_Object PW_TYPE_INFO_BASE "Object"+#define PW_TYPE_INFO_OBJECT_BASE PW_TYPE_INFO_Object ":"++#define PW_TYPE_INFO_Interface PW_TYPE_INFO_BASE "Interface"+#define PW_TYPE_INFO_INTERFACE_BASE PW_TYPE_INFO_Interface ":"++const struct spa_type_info * pw_type_info(void);++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_TYPE_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/utils.hnew file mode 100644index 000000000..9889fd7f5--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/utils.h@@ -0,0 +1,106 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_UTILS_H+#define PIPEWIRE_UTILS_H++#ifdef __cplusplus+extern "C" {+#endif++#include <stdlib.h>+#include <string.h>+#include <sys/un.h>+#ifndef _POSIX_C_SOURCE+# include <sys/mount.h>+#endif+#include <errno.h>++#ifndef ENODATA+#define ENODATA 9919+#endif++#include <spa/utils/defs.h>+#include <spa/pod/pod.h>++/** \defgroup pw_utils Utilities+ *+ * Various utility functions+ */++/**+ * \addtogroup pw_utils+ * \{+ */++/** a function to destroy an item */+typedef void (*pw_destroy_t) (void *object);++const char *+pw_split_walk(const char *str, const char *delimiter, size_t *len, const char **state);++char **+pw_split_strv(const char *str, const char *delimiter, int max_tokens, int *n_tokens);++int+pw_split_ip(char *str, const char *delimiter, int max_tokens, char *tokens[]);++char **pw_strv_parse(const char *val, size_t len, int max_tokens, int *n_tokens);++int pw_strv_find(char **a, const char *b);++int pw_strv_find_common(char **a, char **b);++void+pw_free_strv(char **str);++char *+pw_strip(char *str, const char *whitespace);++#if !defined(strndupa)+# define strndupa(s, n) \+ ({ \+ const char *__old = (s); \+ size_t __len = strnlen(__old, (n)); \+ char *__new = (char *) __builtin_alloca(__len + 1); \+ memcpy(__new, __old, __len); \+ __new[__len] = '\0'; \+ __new; \+ })+#endif++#if !defined(strdupa)+# define strdupa(s) \+ ({ \+ const char *__old = (s); \+ size_t __len = strlen(__old) + 1; \+ char *__new = (char *) alloca(__len); \+ (char *) memcpy(__new, __old, __len); \+ })+#endif++SPA_WARN_UNUSED_RESULT+ssize_t pw_getrandom(void *buf, size_t buflen, unsigned int flags);++void pw_random(void *buf, size_t buflen);++#define pw_rand32() ({ uint32_t val; pw_random(&val, sizeof(val)); val; })++void* pw_reallocarray(void *ptr, size_t nmemb, size_t size);++#ifdef PW_ENABLE_DEPRECATED+#define PW_DEPRECATED(v) (v)+#else+#define PW_DEPRECATED(v) ({ __typeof__(v) _v SPA_DEPRECATED = (v); (void)_v; (v); })+#endif /* PW_ENABLE_DEPRECATED */++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* PIPEWIRE_UTILS_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/version.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/version.hnew file mode 100644index 000000000..142edd44b--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/pipewire/version.h@@ -0,0 +1,54 @@+/* PipeWire */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef PIPEWIRE_VERSION_H+#define PIPEWIRE_VERSION_H++/* WARNING: Make sure to edit the real source file version.h.in! */++#ifdef __cplusplus+extern "C" {+#endif++#include <stdbool.h>++/** Return the version of the header files. Keep in mind that this is+a macro and not a function, so it is impossible to get the pointer of+it. */+#define pw_get_headers_version() ("1.0.5")++/** Return the version of the library the current application is+ * linked to. */+const char* pw_get_library_version(void);++/** Return TRUE if the currently linked PipeWire library version is equal+ * or newer than the specified version. Since 0.3.75 */+bool pw_check_library_version(int major, int minor, int micro);++/** The current API version. Versions prior to 0.2.0 have+ * PW_API_VERSION undefined. Please note that this is only ever+ * increased on incompatible API changes! */+#define PW_API_VERSION "0.3"++/** The major version of PipeWire. \since 0.2.0 */+#define PW_MAJOR 1++/** The minor version of PipeWire. \since 0.2.0 */+#define PW_MINOR 0++/** The micro version of PipeWire. \since 0.2.0 */+#define PW_MICRO 5++/** Evaluates to TRUE if the PipeWire library version is equal or+ * newer than the specified. \since 0.2.0 */+#define PW_CHECK_VERSION(major,minor,micro) \+ ((PW_MAJOR > (major)) || \+ (PW_MAJOR == (major) && PW_MINOR > (minor)) || \+ (PW_MAJOR == (major) && PW_MINOR == (minor) && PW_MICRO >= (micro)))++#ifdef __cplusplus+}+#endif++#endif /* PIPEWIRE_VERSION_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/buffer/buffer.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/buffer/buffer.hnew file mode 100644index 000000000..8c02e9e08--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/buffer/buffer.h@@ -0,0 +1,115 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_BUFFER_H+#define SPA_BUFFER_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>+#include <spa/buffer/meta.h>++/** \defgroup spa_buffer Buffers+ *+ * Buffers describe the data and metadata that is exchanged between+ * ports of a node.+ */++/**+ * \addtogroup spa_buffer+ * \{+ */++enum spa_data_type {+ SPA_DATA_Invalid,+ SPA_DATA_MemPtr, /**< pointer to memory, the data field in+ * struct spa_data is set. */+ SPA_DATA_MemFd, /**< generic fd, mmap to get to memory */+ SPA_DATA_DmaBuf, /**< fd to dmabuf memory */+ SPA_DATA_MemId, /**< memory is identified with an id */++ _SPA_DATA_LAST, /**< not part of ABI */+};++/** Chunk of memory, can change for each buffer */+struct spa_chunk {+ uint32_t offset; /**< offset of valid data. Should be taken+ * modulo the data maxsize to get the offset+ * in the data memory. */+ uint32_t size; /**< size of valid data. Should be clamped to+ * maxsize. */+ int32_t stride; /**< stride of valid data */+#define SPA_CHUNK_FLAG_NONE 0+#define SPA_CHUNK_FLAG_CORRUPTED (1u<<0) /**< chunk data is corrupted in some way */+#define SPA_CHUNK_FLAG_EMPTY (1u<<1) /**< chunk data is empty with media specific+ * neutral data such as silence or black. This+ * could be used to optimize processing. */+ int32_t flags; /**< chunk flags */+};++/** Data for a buffer this stays constant for a buffer */+struct spa_data {+ uint32_t type; /**< memory type, one of enum spa_data_type, when+ * allocating memory, the type contains a bitmask+ * of allowed types. SPA_ID_INVALID is a special+ * value for the allocator to indicate that the+ * other side did not explicitly specify any+ * supported data types. It should probably use+ * a memory type that does not require special+ * handling in addition to simple mmap/munmap. */+#define SPA_DATA_FLAG_NONE 0+#define SPA_DATA_FLAG_READABLE (1u<<0) /**< data is readable */+#define SPA_DATA_FLAG_WRITABLE (1u<<1) /**< data is writable */+#define SPA_DATA_FLAG_DYNAMIC (1u<<2) /**< data pointer can be changed */+#define SPA_DATA_FLAG_READWRITE (SPA_DATA_FLAG_READABLE|SPA_DATA_FLAG_WRITABLE)+#define SPA_DATA_FLAG_MAPPABLE (1u<<3) /**< data is mappable with simple mmap/munmap. Some memory+ * types are not simply mappable (DmaBuf) unless explicitly+ * specified with this flag. */+ uint32_t flags; /**< data flags */+ int64_t fd; /**< optional fd for data */+ uint32_t mapoffset; /**< offset to map fd at */+ uint32_t maxsize; /**< max size of data */+ void *data; /**< optional data pointer */+ struct spa_chunk *chunk; /**< valid chunk of memory */+};++/** A Buffer */+struct spa_buffer {+ uint32_t n_metas; /**< number of metadata */+ uint32_t n_datas; /**< number of data members */+ struct spa_meta *metas; /**< array of metadata */+ struct spa_data *datas; /**< array of data members */+};++/** Find metadata in a buffer */+static inline struct spa_meta *spa_buffer_find_meta(const struct spa_buffer *b, uint32_t type)+{+ uint32_t i;++ for (i = 0; i < b->n_metas; i++)+ if (b->metas[i].type == type)+ return &b->metas[i];++ return NULL;+}++static inline void *spa_buffer_find_meta_data(const struct spa_buffer *b, uint32_t type, size_t size)+{+ struct spa_meta *m;+ if ((m = spa_buffer_find_meta(b, type)) && m->size >= size)+ return m->data;+ return NULL;+}++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_BUFFER_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/buffer/meta.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/buffer/meta.hnew file mode 100644index 000000000..42e6a3fb7--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/buffer/meta.h@@ -0,0 +1,172 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_META_H+#define SPA_META_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>+#include <spa/pod/pod.h>++/**+ * \addtogroup spa_buffer+ * \{+ */++enum spa_meta_type {+ SPA_META_Invalid,+ SPA_META_Header, /**< struct spa_meta_header */+ SPA_META_VideoCrop, /**< struct spa_meta_region with cropping data */+ SPA_META_VideoDamage, /**< array of struct spa_meta_region with damage, where an invalid entry or end-of-array marks the end. */+ SPA_META_Bitmap, /**< struct spa_meta_bitmap */+ SPA_META_Cursor, /**< struct spa_meta_cursor */+ SPA_META_Control, /**< metadata contains a spa_meta_control+ * associated with the data */+ SPA_META_Busy, /**< don't write to buffer when count > 0 */+ SPA_META_VideoTransform, /**< struct spa_meta_transform */++ _SPA_META_LAST, /**< not part of ABI/API */+};++/**+ * A metadata element.+ *+ * This structure is available on the buffer structure and contains+ * the type of the metadata and a pointer/size to the actual metadata+ * itself.+ */+struct spa_meta {+ uint32_t type; /**< metadata type, one of enum spa_meta_type */+ uint32_t size; /**< size of metadata */+ void *data; /**< pointer to metadata */+};++static inline void *spa_meta_first(const struct spa_meta *m) {+ return m->data;+}+#define spa_meta_first spa_meta_first+static inline void *spa_meta_end(const struct spa_meta *m) {+ return SPA_PTROFF(m->data,m->size,void);+}+#define spa_meta_end spa_meta_end+#define spa_meta_check(p,m) (SPA_PTROFF(p,sizeof(*(p)),void) <= spa_meta_end(m))++/**+ * Describes essential buffer header metadata such as flags and+ * timestamps.+ */+struct spa_meta_header {+#define SPA_META_HEADER_FLAG_DISCONT (1 << 0) /**< data is not continuous with previous buffer */+#define SPA_META_HEADER_FLAG_CORRUPTED (1 << 1) /**< data might be corrupted */+#define SPA_META_HEADER_FLAG_MARKER (1 << 2) /**< media specific marker */+#define SPA_META_HEADER_FLAG_HEADER (1 << 3) /**< data contains a codec specific header */+#define SPA_META_HEADER_FLAG_GAP (1 << 4) /**< data contains media neutral data */+#define SPA_META_HEADER_FLAG_DELTA_UNIT (1 << 5) /**< cannot be decoded independently */+ uint32_t flags; /**< flags */+ uint32_t offset; /**< offset in current cycle */+ int64_t pts; /**< presentation timestamp in nanoseconds */+ int64_t dts_offset; /**< decoding timestamp as a difference with pts */+ uint64_t seq; /**< sequence number, increments with a+ * media specific frequency */+};++/** metadata structure for Region or an array of these for RegionArray */+struct spa_meta_region {+ struct spa_region region;+};++static inline bool spa_meta_region_is_valid(const struct spa_meta_region *m) {+ return m->region.size.width != 0 && m->region.size.height != 0;+}+#define spa_meta_region_is_valid spa_meta_region_is_valid++/** iterate all the items in a metadata */+#define spa_meta_for_each(pos,meta) \+ for ((pos) = (__typeof(pos))spa_meta_first(meta); \+ spa_meta_check(pos, meta); \+ (pos)++)++#define spa_meta_bitmap_is_valid(m) ((m)->format != 0)++/**+ * Bitmap information+ *+ * This metadata contains a bitmap image in the given format and size.+ * It is typically used for cursor images or other small images that are+ * better transferred inline.+ */+struct spa_meta_bitmap {+ uint32_t format; /**< bitmap video format, one of enum spa_video_format. 0 is+ * and invalid format and should be handled as if there is+ * no new bitmap information. */+ struct spa_rectangle size; /**< width and height of bitmap */+ int32_t stride; /**< stride of bitmap data */+ uint32_t offset; /**< offset of bitmap data in this structure. An offset of+ * 0 means no image data (invisible), an offset >=+ * sizeof(struct spa_meta_bitmap) contains valid bitmap+ * info. */+};++#define spa_meta_cursor_is_valid(m) ((m)->id != 0)++/**+ * Cursor information+ *+ * Metadata to describe the position and appearance of a pointing device.+ */+struct spa_meta_cursor {+ uint32_t id; /**< cursor id. an id of 0 is an invalid id and means that+ * there is no new cursor data */+ uint32_t flags; /**< extra flags */+ struct spa_point position; /**< position on screen */+ struct spa_point hotspot; /**< offsets for hotspot in bitmap, this field has no meaning+ * when there is no valid bitmap (see below) */+ uint32_t bitmap_offset; /**< offset of bitmap meta in this structure. When the offset+ * is 0, there is no new bitmap information. When the offset is+ * >= sizeof(struct spa_meta_cursor) there is a+ * struct spa_meta_bitmap at the offset. */+};++/** a timed set of events associated with the buffer */+struct spa_meta_control {+ struct spa_pod_sequence sequence;+};++/** a busy counter for the buffer */+struct spa_meta_busy {+ uint32_t flags;+ uint32_t count; /**< number of users busy with the buffer */+};++enum spa_meta_videotransform_value {+ SPA_META_TRANSFORMATION_None = 0, /**< no transform */+ SPA_META_TRANSFORMATION_90, /**< 90 degree counter-clockwise */+ SPA_META_TRANSFORMATION_180, /**< 180 degree counter-clockwise */+ SPA_META_TRANSFORMATION_270, /**< 270 degree counter-clockwise */+ SPA_META_TRANSFORMATION_Flipped, /**< 180 degree flipped around the vertical axis. Equivalent+ * to a reflexion through the vertical line splitting the+ * bufffer in two equal sized parts */+ SPA_META_TRANSFORMATION_Flipped90, /**< flip then rotate around 90 degree counter-clockwise */+ SPA_META_TRANSFORMATION_Flipped180, /**< flip then rotate around 180 degree counter-clockwise */+ SPA_META_TRANSFORMATION_Flipped270, /**< flip then rotate around 270 degree counter-clockwise */+};++/** a transformation of the buffer */+struct spa_meta_videotransform {+ uint32_t transform; /**< orientation transformation that was applied to the buffer,+ * one of enum spa_meta_videotransform_value */+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_META_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/node/command.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/node/command.hnew file mode 100644index 000000000..24c81a53e--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/node/command.h@@ -0,0 +1,53 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_COMMAND_NODE_H+#define SPA_COMMAND_NODE_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_node+ * \{+ */++#include <spa/pod/command.h>++/* object id of SPA_TYPE_COMMAND_Node */+enum spa_node_command {+ SPA_NODE_COMMAND_Suspend, /**< suspend a node, this removes all configured+ * formats and closes any devices */+ SPA_NODE_COMMAND_Pause, /**< pause a node. this makes it stop emitting+ * scheduling events */+ SPA_NODE_COMMAND_Start, /**< start a node, this makes it start emitting+ * scheduling events */+ SPA_NODE_COMMAND_Enable,+ SPA_NODE_COMMAND_Disable,+ SPA_NODE_COMMAND_Flush,+ SPA_NODE_COMMAND_Drain,+ SPA_NODE_COMMAND_Marker,+ SPA_NODE_COMMAND_ParamBegin, /**< begin a set of parameter enumerations or+ * configuration that require the device to+ * remain opened, like query formats and then+ * set a format */+ SPA_NODE_COMMAND_ParamEnd, /**< end a transaction */+ SPA_NODE_COMMAND_RequestProcess,/**< Sent to a driver when some other node emitted+ * the RequestProcess event. */+};++#define SPA_NODE_COMMAND_ID(cmd) SPA_COMMAND_ID(cmd, SPA_TYPE_COMMAND_Node)+#define SPA_NODE_COMMAND_INIT(id) SPA_COMMAND_INIT(SPA_TYPE_COMMAND_Node, id)+++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_COMMAND_NODE_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/node/event.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/node/event.hnew file mode 100644index 000000000..b975a7bfc--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/node/event.h@@ -0,0 +1,44 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_EVENT_NODE_H+#define SPA_EVENT_NODE_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_node+ * \{+ */++#include <spa/pod/event.h>++/* object id of SPA_TYPE_EVENT_Node */+enum spa_node_event {+ SPA_NODE_EVENT_Error,+ SPA_NODE_EVENT_Buffering,+ SPA_NODE_EVENT_RequestRefresh,+ SPA_NODE_EVENT_RequestProcess, /*< Ask the driver to start processing+ * the graph */+};++#define SPA_NODE_EVENT_ID(ev) SPA_EVENT_ID(ev, SPA_TYPE_EVENT_Node)+#define SPA_NODE_EVENT_INIT(id) SPA_EVENT_INIT(SPA_TYPE_EVENT_Node, id)++/* properties for SPA_TYPE_EVENT_Node */+enum spa_event_node {+ SPA_EVENT_NODE_START,+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_EVENT_NODE_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/node/io.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/node/io.hnew file mode 100644index 000000000..20934efd4--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/node/io.h@@ -0,0 +1,290 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_IO_H+#define SPA_IO_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_node+ * \{+ */++#include <spa/utils/defs.h>+#include <spa/pod/pod.h>++/** IO areas+ *+ * IO information for a port on a node. This is allocated+ * by the host and configured on a node or all ports for which+ * IO is requested.+ *+ * The plugin will communicate with the host through the IO+ * areas.+ */++/** Different IO area types */+enum spa_io_type {+ SPA_IO_Invalid,+ SPA_IO_Buffers, /**< area to exchange buffers, struct spa_io_buffers */+ SPA_IO_Range, /**< expected byte range, struct spa_io_range */+ SPA_IO_Clock, /**< area to update clock information, struct spa_io_clock */+ SPA_IO_Latency, /**< latency reporting, struct spa_io_latency */+ SPA_IO_Control, /**< area for control messages, struct spa_io_sequence */+ SPA_IO_Notify, /**< area for notify messages, struct spa_io_sequence */+ SPA_IO_Position, /**< position information in the graph, struct spa_io_position */+ SPA_IO_RateMatch, /**< rate matching between nodes, struct spa_io_rate_match */+ SPA_IO_Memory, /**< memory pointer, struct spa_io_memory */+};++/**+ * IO area to exchange buffers.+ *+ * A set of buffers should first be configured on the node/port.+ * Further references to those buffers will be made by using the+ * id of the buffer.+ *+ * If status is SPA_STATUS_OK, the host should ignore+ * the io area.+ *+ * If status is SPA_STATUS_NEED_DATA, the host should:+ * 1) recycle the buffer in buffer_id, if possible+ * 2) prepare a new buffer and place the id in buffer_id.+ *+ * If status is SPA_STATUS_HAVE_DATA, the host should consume+ * the buffer in buffer_id and set the state to+ * SPA_STATUS_NEED_DATA when new data is requested.+ *+ * If status is SPA_STATUS_STOPPED, some error occurred on the+ * port.+ *+ * If status is SPA_STATUS_DRAINED, data from the io area was+ * used to drain.+ *+ * Status can also be a negative errno value to indicate errors.+ * such as:+ * -EINVAL: buffer_id is invalid+ * -EPIPE: no more buffers available+ */+struct spa_io_buffers {+#define SPA_STATUS_OK 0+#define SPA_STATUS_NEED_DATA (1<<0)+#define SPA_STATUS_HAVE_DATA (1<<1)+#define SPA_STATUS_STOPPED (1<<2)+#define SPA_STATUS_DRAINED (1<<3)+ int32_t status; /**< the status code */+ uint32_t buffer_id; /**< a buffer id */+};++#define SPA_IO_BUFFERS_INIT ((struct spa_io_buffers) { SPA_STATUS_OK, SPA_ID_INVALID, })++/**+ * IO area to exchange a memory region+ */+struct spa_io_memory {+ int32_t status; /**< the status code */+ uint32_t size; /**< the size of \a data */+ void *data; /**< a memory pointer */+};+#define SPA_IO_MEMORY_INIT ((struct spa_io_memory) { SPA_STATUS_OK, 0, NULL, })++/** A range, suitable for input ports that can suggest a range to output ports */+struct spa_io_range {+ uint64_t offset; /**< offset in range */+ uint32_t min_size; /**< minimum size of data */+ uint32_t max_size; /**< maximum size of data */+};++/**+ * Absolute time reporting.+ *+ * Nodes that can report clocking information will receive this io block.+ * The application sets the id. This is usually set as part of the+ * position information but can also be set separately.+ *+ * The clock counts the elapsed time according to the clock provider+ * since the provider was last started.+ */+struct spa_io_clock {+#define SPA_IO_CLOCK_FLAG_FREEWHEEL (1u<<0)+ uint32_t flags; /**< clock flags */+ uint32_t id; /**< unique clock id, set by application */+ char name[64]; /**< clock name prefixed with API, set by node. The clock name+ * is unique per clock and can be used to check if nodes+ * share the same clock. */+ uint64_t nsec; /**< time in nanoseconds against monotonic clock */+ struct spa_fraction rate; /**< rate for position/duration/delay/xrun */+ uint64_t position; /**< current position */+ uint64_t duration; /**< duration of current cycle */+ int64_t delay; /**< delay between position and hardware,+ * positive for capture, negative for playback */+ double rate_diff; /**< rate difference between clock and monotonic time */+ uint64_t next_nsec; /**< estimated next wakeup time in nanoseconds */++ struct spa_fraction target_rate; /**< target rate of next cycle */+ uint64_t target_duration; /**< target duration of next cycle */+ uint32_t target_seq; /**< seq counter. must be equal at start and+ * end of read and lower bit must be 0 */+ uint32_t padding;+ uint64_t xrun; /**< estimated accumulated xrun duration */+};++/* the size of the video in this cycle */+struct spa_io_video_size {+#define SPA_IO_VIDEO_SIZE_VALID (1<<0)+ uint32_t flags; /**< optional flags */+ uint32_t stride; /**< video stride in bytes */+ struct spa_rectangle size; /**< the video size */+ struct spa_fraction framerate; /**< the minimum framerate, the cycle duration is+ * always smaller to ensure there is only one+ * video frame per cycle. */+ uint32_t padding[4];+};++/** latency reporting */+struct spa_io_latency {+ struct spa_fraction rate; /**< rate for min/max */+ uint64_t min; /**< min latency */+ uint64_t max; /**< max latency */+};++/** control stream, io area for SPA_IO_Control and SPA_IO_Notify */+struct spa_io_sequence {+ struct spa_pod_sequence sequence; /**< sequence of timed events */+};++/** bar and beat segment */+struct spa_io_segment_bar {+#define SPA_IO_SEGMENT_BAR_FLAG_VALID (1<<0)+ uint32_t flags; /**< extra flags */+ uint32_t offset; /**< offset in segment of this beat */+ float signature_num; /**< time signature numerator */+ float signature_denom; /**< time signature denominator */+ double bpm; /**< beats per minute */+ double beat; /**< current beat in segment */+ uint32_t padding[8];+};++/** video frame segment */+struct spa_io_segment_video {+#define SPA_IO_SEGMENT_VIDEO_FLAG_VALID (1<<0)+#define SPA_IO_SEGMENT_VIDEO_FLAG_DROP_FRAME (1<<1)+#define SPA_IO_SEGMENT_VIDEO_FLAG_PULL_DOWN (1<<2)+#define SPA_IO_SEGMENT_VIDEO_FLAG_INTERLACED (1<<3)+ uint32_t flags; /**< flags */+ uint32_t offset; /**< offset in segment */+ struct spa_fraction framerate;+ uint32_t hours;+ uint32_t minutes;+ uint32_t seconds;+ uint32_t frames;+ uint32_t field_count; /**< 0 for progressive, 1 and 2 for interlaced */+ uint32_t padding[11];+};++/**+ * A segment converts a running time to a segment (stream) position.+ *+ * The segment position is valid when the current running time is between+ * start and start + duration. The position is then+ * calculated as:+ *+ * (running time - start) * rate + position;+ *+ * Support for looping is done by specifying the LOOPING flags with a+ * non-zero duration. When the running time reaches start + duration,+ * duration is added to start and the loop repeats.+ *+ * Care has to be taken when the running time + clock.duration extends+ * past the start + duration from the segment; the user should correctly+ * wrap around and partially repeat the loop in the current cycle.+ *+ * Extra information can be placed in the segment by setting the valid flags+ * and filling up the corresponding structures.+ */+struct spa_io_segment {+ uint32_t version;+#define SPA_IO_SEGMENT_FLAG_LOOPING (1<<0) /**< after the duration, the segment repeats */+#define SPA_IO_SEGMENT_FLAG_NO_POSITION (1<<1) /**< position is invalid. The position can be invalid+ * after a seek, for example, when the exact mapping+ * of the extra segment info (bar, video, ...) to+ * position has not been determined yet */+ uint32_t flags; /**< extra flags */+ uint64_t start; /**< value of running time when this+ * info is active. Can be in the future for+ * pending changes. It does not have to be in+ * exact multiples of the clock duration. */+ uint64_t duration; /**< duration when this info becomes invalid expressed+ * in running time. If the duration is 0, this+ * segment extends to the next segment. If the+ * segment becomes invalid and the looping flag is+ * set, the segment repeats. */+ double rate; /**< overall rate of the segment, can be negative for+ * backwards time reporting. */+ uint64_t position; /**< The position when the running time == start.+ * can be invalid when the owner of the extra segment+ * information has not yet made the mapping. */++ struct spa_io_segment_bar bar;+ struct spa_io_segment_video video;+};++enum spa_io_position_state {+ SPA_IO_POSITION_STATE_STOPPED,+ SPA_IO_POSITION_STATE_STARTING,+ SPA_IO_POSITION_STATE_RUNNING,+};++/** the maximum number of segments visible in the future */+#define SPA_IO_POSITION_MAX_SEGMENTS 8++/**+ * The position information adds extra meaning to the raw clock times.+ *+ * It is set on all nodes and the clock id will contain the clock of the+ * driving node in the graph.+ *+ * The position information contains 1 or more segments that convert the+ * raw clock times to a stream time. They are sorted based on their+ * start times, and thus the order in which they will activate in+ * the future. This makes it possible to look ahead in the scheduled+ * segments and anticipate the changes in the timeline.+ */+struct spa_io_position {+ struct spa_io_clock clock; /**< clock position of driver, always valid and+ * read only */+ struct spa_io_video_size video; /**< size of the video in the current cycle */+ int64_t offset; /**< an offset to subtract from the clock position+ * to get a running time. This is the time that+ * the state has been in the RUNNING state and the+ * time that should be used to compare the segment+ * start values against. */+ uint32_t state; /**< one of enum spa_io_position_state */++ uint32_t n_segments; /**< number of segments */+ struct spa_io_segment segments[SPA_IO_POSITION_MAX_SEGMENTS]; /**< segments */+};++/** rate matching */+struct spa_io_rate_match {+ uint32_t delay; /**< extra delay in samples for resampler */+ uint32_t size; /**< requested input size for resampler */+ double rate; /**< rate for resampler */+#define SPA_IO_RATE_MATCH_FLAG_ACTIVE (1 << 0)+ uint32_t flags; /**< extra flags */+ uint32_t padding[7];+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_IO_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/node/node.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/node/node.hnew file mode 100644index 000000000..f3eb6c027--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/node/node.h@@ -0,0 +1,680 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_NODE_H+#define SPA_NODE_H++#ifdef __cplusplus+extern "C" {+#endif++/** \defgroup spa_node Node+ *+ * A spa_node is a component that can consume and produce buffers.+ */++/**+ * \addtogroup spa_node+ * \{+ */++#include <errno.h>+#include <spa/utils/defs.h>+#include <spa/utils/type.h>+#include <spa/utils/hook.h>+#include <spa/buffer/buffer.h>+#include <spa/node/event.h>+#include <spa/node/command.h>+++#define SPA_TYPE_INTERFACE_Node SPA_TYPE_INFO_INTERFACE_BASE "Node"++#define SPA_VERSION_NODE 0+struct spa_node { struct spa_interface iface; };++/**+ * Node information structure+ *+ * Contains the basic node information.+ */+struct spa_node_info {+ uint32_t max_input_ports;+ uint32_t max_output_ports;+#define SPA_NODE_CHANGE_MASK_FLAGS (1u<<0)+#define SPA_NODE_CHANGE_MASK_PROPS (1u<<1)+#define SPA_NODE_CHANGE_MASK_PARAMS (1u<<2)+ uint64_t change_mask;++#define SPA_NODE_FLAG_RT (1u<<0) /**< node can do real-time processing */+#define SPA_NODE_FLAG_IN_DYNAMIC_PORTS (1u<<1) /**< input ports can be added/removed */+#define SPA_NODE_FLAG_OUT_DYNAMIC_PORTS (1u<<2) /**< output ports can be added/removed */+#define SPA_NODE_FLAG_IN_PORT_CONFIG (1u<<3) /**< input ports can be reconfigured with+ * PortConfig parameter */+#define SPA_NODE_FLAG_OUT_PORT_CONFIG (1u<<4) /**< output ports can be reconfigured with+ * PortConfig parameter */+#define SPA_NODE_FLAG_NEED_CONFIGURE (1u<<5) /**< node needs configuration before it can+ * be started. */+#define SPA_NODE_FLAG_ASYNC (1u<<6) /**< the process function might not+ * immediately produce or consume data+ * but might offload the work to a worker+ * thread. */+ uint64_t flags;+ struct spa_dict *props; /**< extra node properties */+ struct spa_param_info *params; /**< parameter information */+ uint32_t n_params; /**< number of items in \a params */+};++#define SPA_NODE_INFO_INIT() ((struct spa_node_info) { 0, })++/**+ * Port information structure+ *+ * Contains the basic port information.+ */+struct spa_port_info {+#define SPA_PORT_CHANGE_MASK_FLAGS (1u<<0)+#define SPA_PORT_CHANGE_MASK_RATE (1u<<1)+#define SPA_PORT_CHANGE_MASK_PROPS (1u<<2)+#define SPA_PORT_CHANGE_MASK_PARAMS (1u<<3)+ uint64_t change_mask;++#define SPA_PORT_FLAG_REMOVABLE (1u<<0) /**< port can be removed */+#define SPA_PORT_FLAG_OPTIONAL (1u<<1) /**< processing on port is optional */+#define SPA_PORT_FLAG_CAN_ALLOC_BUFFERS (1u<<2) /**< the port can allocate buffer data */+#define SPA_PORT_FLAG_IN_PLACE (1u<<3) /**< the port can process data in-place and+ * will need a writable input buffer */+#define SPA_PORT_FLAG_NO_REF (1u<<4) /**< the port does not keep a ref on the buffer.+ * This means the node will always completely+ * consume the input buffer and it will be+ * recycled after process. */+#define SPA_PORT_FLAG_LIVE (1u<<5) /**< output buffers from this port are+ * timestamped against a live clock. */+#define SPA_PORT_FLAG_PHYSICAL (1u<<6) /**< connects to some device */+#define SPA_PORT_FLAG_TERMINAL (1u<<7) /**< data was not created from this port+ * or will not be made available on another+ * port */+#define SPA_PORT_FLAG_DYNAMIC_DATA (1u<<8) /**< data pointer on buffers can be changed.+ * Only the buffer data marked as DYNAMIC+ * can be changed. */+ uint64_t flags; /**< port flags */+ struct spa_fraction rate; /**< rate of sequence numbers on port */+ const struct spa_dict *props; /**< extra port properties */+ struct spa_param_info *params; /**< parameter information */+ uint32_t n_params; /**< number of items in \a params */+};++#define SPA_PORT_INFO_INIT() ((struct spa_port_info) { 0, })++#define SPA_RESULT_TYPE_NODE_ERROR 1+#define SPA_RESULT_TYPE_NODE_PARAMS 2++/** an error result */+struct spa_result_node_error {+ const char *message;+};++/** the result of enum_params or port_enum_params. */+struct spa_result_node_params {+ uint32_t id; /**< id of parameter */+ uint32_t index; /**< index of parameter */+ uint32_t next; /**< next index of iteration */+ struct spa_pod *param; /**< the result param */+};++#define SPA_NODE_EVENT_INFO 0+#define SPA_NODE_EVENT_PORT_INFO 1+#define SPA_NODE_EVENT_RESULT 2+#define SPA_NODE_EVENT_EVENT 3+#define SPA_NODE_EVENT_NUM 4++/** events from the spa_node.+ *+ * All event are called from the main thread and multiple+ * listeners can be registered for the events with+ * spa_node_add_listener().+ */+struct spa_node_events {+#define SPA_VERSION_NODE_EVENTS 0+ uint32_t version; /**< version of this structure */++ /** Emitted when info changes */+ void (*info) (void *data, const struct spa_node_info *info);++ /** Emitted when port info changes, NULL when port is removed */+ void (*port_info) (void *data,+ enum spa_direction direction, uint32_t port,+ const struct spa_port_info *info);++ /** notify a result.+ *+ * Some methods will trigger a result event with an optional+ * result of the given type. Look at the documentation of the+ * method to know when to expect a result event.+ *+ * The result event can be called synchronously, as an event+ * called from inside the method itself, in which case the seq+ * number passed to the method will be passed unchanged.+ *+ * The result event will be called asynchronously when the+ * method returned an async return value. In this case, the seq+ * number in the result will match the async return value of+ * the method call. Users should match the seq number from+ * request to the reply.+ */+ void (*result) (void *data, int seq, int res,+ uint32_t type, const void *result);++ /**+ * \param node a spa_node+ * \param event the event that was emitted+ *+ * This will be called when an out-of-bound event is notified+ * on \a node.+ */+ void (*event) (void *data, const struct spa_event *event);+};++#define SPA_NODE_CALLBACK_READY 0+#define SPA_NODE_CALLBACK_REUSE_BUFFER 1+#define SPA_NODE_CALLBACK_XRUN 2+#define SPA_NODE_CALLBACK_NUM 3++/** Node callbacks+ *+ * Callbacks are called from the real-time data thread. Only+ * one callback structure can be set on an spa_node.+ */+struct spa_node_callbacks {+#define SPA_VERSION_NODE_CALLBACKS 0+ uint32_t version;+ /**+ * \param node a spa_node+ *+ * The node is ready for processing.+ *+ * When this function is NULL, synchronous operation is requested+ * on the ports.+ */+ int (*ready) (void *data, int state);++ /**+ * \param node a spa_node+ * \param port_id an input port_id+ * \param buffer_id the buffer id to be reused+ *+ * The node has a buffer that can be reused.+ *+ * When this function is NULL, the buffers to reuse will be set in+ * the io area of the input ports.+ */+ int (*reuse_buffer) (void *data,+ uint32_t port_id,+ uint32_t buffer_id);++ /**+ * \param data user data+ * \param trigger the timestamp in microseconds when the xrun happened+ * \param delay the amount of microseconds of xrun.+ * \param info an object with extra info (NULL for now)+ *+ * The node has encountered an over or underrun+ *+ * The info contains an object with more information+ */+ int (*xrun) (void *data, uint64_t trigger, uint64_t delay,+ struct spa_pod *info);+};+++/** flags that can be passed to set_param and port_set_param functions */+#define SPA_NODE_PARAM_FLAG_TEST_ONLY (1 << 0) /**< Just check if the param is accepted */+#define SPA_NODE_PARAM_FLAG_FIXATE (1 << 1) /**< Fixate the non-optional unset fields */+#define SPA_NODE_PARAM_FLAG_NEAREST (1 << 2) /**< Allow set fields to be rounded to the+ * nearest allowed field value. */++/** flags to pass to the use_buffers functions */+#define SPA_NODE_BUFFERS_FLAG_ALLOC (1 << 0) /**< Allocate memory for the buffers. This flag+ * is ignored when the port does not have the+ * SPA_PORT_FLAG_CAN_ALLOC_BUFFERS set. */+++#define SPA_NODE_METHOD_ADD_LISTENER 0+#define SPA_NODE_METHOD_SET_CALLBACKS 1+#define SPA_NODE_METHOD_SYNC 2+#define SPA_NODE_METHOD_ENUM_PARAMS 3+#define SPA_NODE_METHOD_SET_PARAM 4+#define SPA_NODE_METHOD_SET_IO 5+#define SPA_NODE_METHOD_SEND_COMMAND 6+#define SPA_NODE_METHOD_ADD_PORT 7+#define SPA_NODE_METHOD_REMOVE_PORT 8+#define SPA_NODE_METHOD_PORT_ENUM_PARAMS 9+#define SPA_NODE_METHOD_PORT_SET_PARAM 10+#define SPA_NODE_METHOD_PORT_USE_BUFFERS 11+#define SPA_NODE_METHOD_PORT_SET_IO 12+#define SPA_NODE_METHOD_PORT_REUSE_BUFFER 13+#define SPA_NODE_METHOD_PROCESS 14+#define SPA_NODE_METHOD_NUM 15++/**+ * Node methods+ */+struct spa_node_methods {+ /* the version of the node methods. This can be used to expand this+ * structure in the future */+#define SPA_VERSION_NODE_METHODS 0+ uint32_t version;++ /**+ * Adds an event listener on \a node.+ *+ * Setting the events will trigger the info event and a+ * port_info event for each managed port on the new+ * listener.+ *+ * \param node a #spa_node+ * \param listener a listener+ * \param events a struct \ref spa_node_events+ * \param data data passed as first argument in functions of \a events+ * \return 0 on success+ * < 0 errno on error+ */+ int (*add_listener) (void *object,+ struct spa_hook *listener,+ const struct spa_node_events *events,+ void *data);+ /**+ * Set callbacks to on \a node.+ * if \a callbacks is NULL, the current callbacks are removed.+ *+ * This function must be called from the main thread.+ *+ * All callbacks are called from the data thread.+ *+ * \param node a spa_node+ * \param callbacks callbacks to set+ * \return 0 on success+ * -EINVAL when node is NULL+ */+ int (*set_callbacks) (void *object,+ const struct spa_node_callbacks *callbacks,+ void *data);+ /**+ * Perform a sync operation.+ *+ * This method will emit the result event with the given sequence+ * number synchronously or with the returned async return value+ * asynchronously.+ *+ * Because all methods are serialized in the node, this can be used+ * to wait for completion of all previous method calls.+ *+ * \param seq a sequence number+ * \return 0 on success+ * -EINVAL when node is NULL+ * an async result+ */+ int (*sync) (void *object, int seq);++ /**+ * Enumerate the parameters of a node.+ *+ * Parameters are identified with an \a id. Some parameters can have+ * multiple values, see the documentation of the parameter id.+ *+ * Parameters can be filtered by passing a non-NULL \a filter.+ *+ * The function will emit the result event up to \a max times with+ * the result value. The seq in the result will either be the \a seq+ * number when executed synchronously or the async return value of+ * this function when executed asynchronously.+ *+ * This function must be called from the main thread.+ *+ * \param node a \ref spa_node+ * \param seq a sequence number to pass to the result event when+ * this method is executed synchronously.+ * \param id the param id to enumerate+ * \param start the index of enumeration, pass 0 for the first item+ * \param max the maximum number of parameters to enumerate+ * \param filter and optional filter to use+ *+ * \return 0 when no more items can be iterated.+ * -EINVAL when invalid arguments are given+ * -ENOENT the parameter \a id is unknown+ * -ENOTSUP when there are no parameters+ * implemented on \a node+ * an async return value when the result event will be+ * emitted later.+ */+ int (*enum_params) (void *object, int seq,+ uint32_t id, uint32_t start, uint32_t max,+ const struct spa_pod *filter);++ /**+ * Set the configurable parameter in \a node.+ *+ * Usually, \a param will be obtained from enum_params and then+ * modified but it is also possible to set another spa_pod+ * as long as its keys and types match a supported object.+ *+ * Objects with property keys that are not known are ignored.+ *+ * This function must be called from the main thread.+ *+ * \param node a \ref spa_node+ * \param id the parameter id to configure+ * \param flags additional flags+ * \param param the parameter to configure+ *+ * \return 0 on success+ * -EINVAL when node is NULL+ * -ENOTSUP when there are no parameters implemented on \a node+ * -ENOENT the parameter is unknown+ */+ int (*set_param) (void *object,+ uint32_t id, uint32_t flags,+ const struct spa_pod *param);++ /**+ * Configure the given memory area with \a id on \a node. This+ * structure is allocated by the host and is used to exchange+ * data and parameters with the node.+ *+ * Setting an \a io of NULL will disable the node io.+ *+ * This function must be called from the main thread.+ *+ * \param id the id of the io area, the available ids can be+ * enumerated with the node parameters.+ * \param data a io area memory+ * \param size the size of \a data+ * \return 0 on success+ * -EINVAL when invalid input is given+ * -ENOENT when \a id is unknown+ * -ENOSPC when \a size is too small+ */+ int (*set_io) (void *object,+ uint32_t id, void *data, size_t size);++ /**+ * Send a command to a node.+ *+ * Upon completion, a command might change the state of a node.+ *+ * This function must be called from the main thread.+ *+ * \param node a spa_node+ * \param command a spa_command+ * \return 0 on success+ * -EINVAL when node or command is NULL+ * -ENOTSUP when this node can't process commands+ * -EINVAL \a command is an invalid command+ */+ int (*send_command) (void *object, const struct spa_command *command);++ /**+ * Make a new port with \a port_id. The caller should use the lowest unused+ * port id for the given \a direction.+ *+ * Port ids should be between 0 and max_ports as obtained from the info+ * event.+ *+ * This function must be called from the main thread.+ *+ * \param node a spa_node+ * \param direction a enum \ref spa_direction+ * \param port_id an unused port id+ * \param props extra properties+ * \return 0 on success+ * -EINVAL when node is NULL+ */+ int (*add_port) (void *object,+ enum spa_direction direction, uint32_t port_id,+ const struct spa_dict *props);++ /**+ * Remove a port with \a port_id.+ *+ * \param node a spa_node+ * \param direction a enum \ref spa_direction+ * \param port_id a port id+ * \return 0 on success+ * -EINVAL when node is NULL or when port_id is unknown or+ * when the port can't be removed.+ */+ int (*remove_port) (void *object,+ enum spa_direction direction, uint32_t port_id);++ /**+ * Enumerate all possible parameters of \a id on \a port_id of \a node+ * that are compatible with \a filter.+ *+ * The result parameters can be queried and modified and ultimately be used+ * to call port_set_param.+ *+ * The function will emit the result event up to \a max times with+ * the result value. The seq in the result event will either be the+ * \a seq number when executed synchronously or the async return+ * value of this function when executed asynchronously.+ *+ * This function must be called from the main thread.+ *+ * \param node a spa_node+ * \param seq a sequence number to pass to the result event when+ * this method is executed synchronously.+ * \param direction an spa_direction+ * \param port_id the port to query+ * \param id the parameter id to query+ * \param start the first index to query, 0 to get the first item+ * \param max the maximum number of params to query+ * \param filter a parameter filter or NULL for no filter+ *+ * \return 0 when no more items can be iterated.+ * -EINVAL when invalid parameters are given+ * -ENOENT when \a id is unknown+ * an async return value when the result event will be+ * emitted later.+ */+ int (*port_enum_params) (void *object, int seq,+ enum spa_direction direction, uint32_t port_id,+ uint32_t id, uint32_t start, uint32_t max,+ const struct spa_pod *filter);+ /**+ * Set a parameter on \a port_id of \a node.+ *+ * When \a param is NULL, the parameter will be unset.+ *+ * This function must be called from the main thread. The node muse be paused+ * or the port SPA_IO_Buffers area is NULL when this function is called with+ * a param that changes the processing state (like a format change).+ *+ * \param node a struct \ref spa_node+ * \param direction a enum \ref spa_direction+ * \param port_id the port to configure+ * \param id the parameter id to set+ * \param flags optional flags+ * \param param a struct \ref spa_pod with the parameter to set+ * \return 0 on success+ * 1 on success, the value of \a param might have been+ * changed depending on \a flags and the final value can be found by+ * doing port_enum_params.+ * -EINVAL when node is NULL or invalid arguments are given+ * -ESRCH when one of the mandatory param+ * properties is not specified and SPA_NODE_PARAM_FLAG_FIXATE was+ * not set in \a flags.+ * -ESRCH when the type or size of a property is not correct.+ * -ENOENT when the param id is not found+ */+ int (*port_set_param) (void *object,+ enum spa_direction direction,+ uint32_t port_id,+ uint32_t id, uint32_t flags,+ const struct spa_pod *param);++ /**+ * Tell the port to use the given buffers+ *+ * When \a flags contains SPA_NODE_BUFFERS_FLAG_ALLOC, the data+ * in the buffers should point to an array of at least 1 data entry+ * with the desired supported type that will be filled by this function.+ *+ * The port should also have a spa_io_buffers io area configured to exchange+ * the buffers with the port.+ *+ * For an input port, all the buffers will remain dequeued.+ * Once a buffer has been queued on a port in the spa_io_buffers,+ * it should not be reused until the reuse_buffer callback is notified+ * or when the buffer has been returned in the spa_io_buffers of+ * the port.+ *+ * For output ports, all buffers will be queued in the port. When process+ * returns SPA_STATUS_HAVE_DATA, buffers are available in one or more+ * of the spa_io_buffers areas.+ *+ * When a buffer can be reused, port_reuse_buffer() should be called or the+ * buffer_id should be placed in the spa_io_buffers area before calling+ * process.+ *+ * Passing NULL as \a buffers will remove the reference that the port has+ * on the buffers.+ *+ * When this function returns async, use the spa_node_sync operation to+ * wait for completion.+ *+ * This function must be called from the main thread. The node muse be paused+ * or the port SPA_IO_Buffers area is NULL when this function is called.+ *+ * \param object an object implementing the interface+ * \param direction a port direction+ * \param port_id a port id+ * \param flags extra flags+ * \param buffers an array of buffer pointers+ * \param n_buffers number of elements in \a buffers+ * \return 0 on success+ */+ int (*port_use_buffers) (void *object,+ enum spa_direction direction,+ uint32_t port_id,+ uint32_t flags,+ struct spa_buffer **buffers,+ uint32_t n_buffers);++ /**+ * Configure the given memory area with \a id on \a port_id. This+ * structure is allocated by the host and is used to exchange+ * data and parameters with the port.+ *+ * Setting an \a io of NULL will disable the port io.+ *+ * This function must be called from the main thread.+ *+ * This function can be called when the node is running and the node+ * must be prepared to handle changes in io areas while running. This+ * is normally done by synchronizing the port io updates with the+ * data processing loop.+ *+ * \param direction a spa_direction+ * \param port_id a port id+ * \param id the id of the io area, the available ids can be+ * enumerated with the port parameters.+ * \param data a io area memory+ * \param size the size of \a data+ * \return 0 on success+ * -EINVAL when invalid input is given+ * -ENOENT when \a id is unknown+ * -ENOSPC when \a size is too small+ */+ int (*port_set_io) (void *object,+ enum spa_direction direction,+ uint32_t port_id,+ uint32_t id,+ void *data, size_t size);++ /**+ * Tell an output port to reuse a buffer.+ *+ * This function must be called from the data thread.+ *+ * \param node a spa_node+ * \param port_id a port id+ * \param buffer_id a buffer id to reuse+ * \return 0 on success+ * -EINVAL when node is NULL+ */+ int (*port_reuse_buffer) (void *object, uint32_t port_id, uint32_t buffer_id);++ /**+ * Process the node+ *+ * This function must be called from the data thread.+ *+ * Output io areas with SPA_STATUS_NEED_DATA will recycle the+ * buffers if any.+ *+ * Input areas with SPA_STATUS_HAVE_DATA are consumed if possible+ * and the status is set to SPA_STATUS_NEED_DATA or SPA_STATUS_OK.+ *+ * When the node has new output buffers, the SPA_STATUS_HAVE_DATA+ * bit will be set.+ *+ * When the node can accept new input in the next cycle, the+ * SPA_STATUS_NEED_DATA bit will be set.+ *+ * Note that the node might return SPA_STATUS_NEED_DATA even when+ * no input ports have this status. This means that the amount of+ * data still available on the input ports is likely not going to+ * be enough for the next cycle and the host might need to prefetch+ * data for the next cycle.+ */+ int (*process) (void *object);+};++#define spa_node_method(o,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ struct spa_node *_n = o; \+ spa_interface_call_res(&_n->iface, \+ struct spa_node_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++#define spa_node_method_fast(o,method,version,...) \+({ \+ int _res; \+ struct spa_node *_n = o; \+ spa_interface_call_fast_res(&_n->iface, \+ struct spa_node_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++#define spa_node_add_listener(n,...) spa_node_method(n, add_listener, 0, __VA_ARGS__)+#define spa_node_set_callbacks(n,...) spa_node_method(n, set_callbacks, 0, __VA_ARGS__)+#define spa_node_sync(n,...) spa_node_method(n, sync, 0, __VA_ARGS__)+#define spa_node_enum_params(n,...) spa_node_method(n, enum_params, 0, __VA_ARGS__)+#define spa_node_set_param(n,...) spa_node_method(n, set_param, 0, __VA_ARGS__)+#define spa_node_set_io(n,...) spa_node_method(n, set_io, 0, __VA_ARGS__)+#define spa_node_send_command(n,...) spa_node_method(n, send_command, 0, __VA_ARGS__)+#define spa_node_add_port(n,...) spa_node_method(n, add_port, 0, __VA_ARGS__)+#define spa_node_remove_port(n,...) spa_node_method(n, remove_port, 0, __VA_ARGS__)+#define spa_node_port_enum_params(n,...) spa_node_method(n, port_enum_params, 0, __VA_ARGS__)+#define spa_node_port_set_param(n,...) spa_node_method(n, port_set_param, 0, __VA_ARGS__)+#define spa_node_port_use_buffers(n,...) spa_node_method(n, port_use_buffers, 0, __VA_ARGS__)+#define spa_node_port_set_io(n,...) spa_node_method(n, port_set_io, 0, __VA_ARGS__)++#define spa_node_port_reuse_buffer(n,...) spa_node_method(n, port_reuse_buffer, 0, __VA_ARGS__)+#define spa_node_port_reuse_buffer_fast(n,...) spa_node_method_fast(n, port_reuse_buffer, 0, __VA_ARGS__)+#define spa_node_process(n) spa_node_method(n, process, 0)+#define spa_node_process_fast(n) spa_node_method_fast(n, process, 0)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_NODE_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/buffers.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/buffers.hnew file mode 100644index 000000000..399d3a5f0--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/buffers.h@@ -0,0 +1,52 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_PARAM_BUFFERS_H+#define SPA_PARAM_BUFFERS_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/param/param.h>++/** properties for SPA_TYPE_OBJECT_ParamBuffers */+enum spa_param_buffers {+ SPA_PARAM_BUFFERS_START,+ SPA_PARAM_BUFFERS_buffers, /**< number of buffers (Int) */+ SPA_PARAM_BUFFERS_blocks, /**< number of data blocks per buffer (Int) */+ SPA_PARAM_BUFFERS_size, /**< size of a data block memory (Int)*/+ SPA_PARAM_BUFFERS_stride, /**< stride of data block memory (Int) */+ SPA_PARAM_BUFFERS_align, /**< alignment of data block memory (Int) */+ SPA_PARAM_BUFFERS_dataType, /**< possible memory types (Int, mask of enum spa_data_type) */+};++/** properties for SPA_TYPE_OBJECT_ParamMeta */+enum spa_param_meta {+ SPA_PARAM_META_START,+ SPA_PARAM_META_type, /**< the metadata, one of enum spa_meta_type (Id enum spa_meta_type) */+ SPA_PARAM_META_size, /**< the expected maximum size the meta (Int) */+};++/** properties for SPA_TYPE_OBJECT_ParamIO */+enum spa_param_io {+ SPA_PARAM_IO_START,+ SPA_PARAM_IO_id, /**< type ID, uniquely identifies the io area (Id enum spa_io_type) */+ SPA_PARAM_IO_size, /**< size of the io area (Int) */+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_PARAM_BUFFERS_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/format-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/format-utils.hnew file mode 100644index 000000000..fb5cb39a8--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/format-utils.h@@ -0,0 +1,38 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_PARAM_FORMAT_UTILS_H+#define SPA_PARAM_FORMAT_UTILS_H++#ifdef __cplusplus+extern "C" {+#endif+++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/pod/parser.h>+#include <spa/param/format.h>++static inline int+spa_format_parse(const struct spa_pod *format, uint32_t *media_type, uint32_t *media_subtype)+{+ return spa_pod_parse_object(format,+ SPA_TYPE_OBJECT_Format, NULL,+ SPA_FORMAT_mediaType, SPA_POD_Id(media_type),+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(media_subtype));+}++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_PARAM_FORMAT_UTILS_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/format.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/format.hnew file mode 100644index 000000000..3f075fd36--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/format.h@@ -0,0 +1,157 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_PARAM_FORMAT_H+#define SPA_PARAM_FORMAT_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/param/param.h>++/** media type for SPA_TYPE_OBJECT_Format */+enum spa_media_type {+ SPA_MEDIA_TYPE_unknown,+ SPA_MEDIA_TYPE_audio,+ SPA_MEDIA_TYPE_video,+ SPA_MEDIA_TYPE_image,+ SPA_MEDIA_TYPE_binary,+ SPA_MEDIA_TYPE_stream,+ SPA_MEDIA_TYPE_application,+};++/** media subtype for SPA_TYPE_OBJECT_Format */+enum spa_media_subtype {+ SPA_MEDIA_SUBTYPE_unknown,+ SPA_MEDIA_SUBTYPE_raw,+ SPA_MEDIA_SUBTYPE_dsp,+ SPA_MEDIA_SUBTYPE_iec958, /** S/PDIF */+ SPA_MEDIA_SUBTYPE_dsd,++ SPA_MEDIA_SUBTYPE_START_Audio = 0x10000,+ SPA_MEDIA_SUBTYPE_mp3,+ SPA_MEDIA_SUBTYPE_aac,+ SPA_MEDIA_SUBTYPE_vorbis,+ SPA_MEDIA_SUBTYPE_wma,+ SPA_MEDIA_SUBTYPE_ra,+ SPA_MEDIA_SUBTYPE_sbc,+ SPA_MEDIA_SUBTYPE_adpcm,+ SPA_MEDIA_SUBTYPE_g723,+ SPA_MEDIA_SUBTYPE_g726,+ SPA_MEDIA_SUBTYPE_g729,+ SPA_MEDIA_SUBTYPE_amr,+ SPA_MEDIA_SUBTYPE_gsm,+ SPA_MEDIA_SUBTYPE_alac, /** since 0.3.65 */+ SPA_MEDIA_SUBTYPE_flac, /** since 0.3.65 */+ SPA_MEDIA_SUBTYPE_ape, /** since 0.3.65 */+ SPA_MEDIA_SUBTYPE_opus, /** since 0.3.68 */++ SPA_MEDIA_SUBTYPE_START_Video = 0x20000,+ SPA_MEDIA_SUBTYPE_h264,+ SPA_MEDIA_SUBTYPE_mjpg,+ SPA_MEDIA_SUBTYPE_dv,+ SPA_MEDIA_SUBTYPE_mpegts,+ SPA_MEDIA_SUBTYPE_h263,+ SPA_MEDIA_SUBTYPE_mpeg1,+ SPA_MEDIA_SUBTYPE_mpeg2,+ SPA_MEDIA_SUBTYPE_mpeg4,+ SPA_MEDIA_SUBTYPE_xvid,+ SPA_MEDIA_SUBTYPE_vc1,+ SPA_MEDIA_SUBTYPE_vp8,+ SPA_MEDIA_SUBTYPE_vp9,+ SPA_MEDIA_SUBTYPE_bayer,++ SPA_MEDIA_SUBTYPE_START_Image = 0x30000,+ SPA_MEDIA_SUBTYPE_jpeg,++ SPA_MEDIA_SUBTYPE_START_Binary = 0x40000,++ SPA_MEDIA_SUBTYPE_START_Stream = 0x50000,+ SPA_MEDIA_SUBTYPE_midi,++ SPA_MEDIA_SUBTYPE_START_Application = 0x60000,+ SPA_MEDIA_SUBTYPE_control, /**< control stream, data contains+ * spa_pod_sequence with control info. */+};++/** properties for audio SPA_TYPE_OBJECT_Format */+enum spa_format {+ SPA_FORMAT_START,++ SPA_FORMAT_mediaType, /**< media type (Id enum spa_media_type) */+ SPA_FORMAT_mediaSubtype, /**< media subtype (Id enum spa_media_subtype) */++ /* Audio format keys */+ SPA_FORMAT_START_Audio = 0x10000,+ SPA_FORMAT_AUDIO_format, /**< audio format, (Id enum spa_audio_format) */+ SPA_FORMAT_AUDIO_flags, /**< optional flags (Int) */+ SPA_FORMAT_AUDIO_rate, /**< sample rate (Int) */+ SPA_FORMAT_AUDIO_channels, /**< number of audio channels (Int) */+ SPA_FORMAT_AUDIO_position, /**< channel positions (Id enum spa_audio_position) */++ SPA_FORMAT_AUDIO_iec958Codec, /**< codec used (IEC958) (Id enum spa_audio_iec958_codec) */++ SPA_FORMAT_AUDIO_bitorder, /**< bit order (Id enum spa_param_bitorder) */+ SPA_FORMAT_AUDIO_interleave, /**< Interleave bytes (Int) */+ SPA_FORMAT_AUDIO_bitrate, /**< bit rate (Int) */+ SPA_FORMAT_AUDIO_blockAlign, /**< audio data block alignment (Int) */++ SPA_FORMAT_AUDIO_AAC_streamFormat, /**< AAC stream format, (Id enum spa_audio_aac_stream_format) */++ SPA_FORMAT_AUDIO_WMA_profile, /**< WMA profile (Id enum spa_audio_wma_profile) */++ SPA_FORMAT_AUDIO_AMR_bandMode, /**< AMR band mode (Id enum spa_audio_amr_band_mode) */+++ /* Video Format keys */+ SPA_FORMAT_START_Video = 0x20000,+ SPA_FORMAT_VIDEO_format, /**< video format (Id enum spa_video_format) */+ SPA_FORMAT_VIDEO_modifier, /**< format modifier (Long)+ * use only with DMA-BUF and omit for other buffer types */+ SPA_FORMAT_VIDEO_size, /**< size (Rectangle) */+ SPA_FORMAT_VIDEO_framerate, /**< frame rate (Fraction) */+ SPA_FORMAT_VIDEO_maxFramerate, /**< maximum frame rate (Fraction) */+ SPA_FORMAT_VIDEO_views, /**< number of views (Int) */+ SPA_FORMAT_VIDEO_interlaceMode, /**< (Id enum spa_video_interlace_mode) */+ SPA_FORMAT_VIDEO_pixelAspectRatio, /**< (Rectangle) */+ SPA_FORMAT_VIDEO_multiviewMode, /**< (Id enum spa_video_multiview_mode) */+ SPA_FORMAT_VIDEO_multiviewFlags, /**< (Id enum spa_video_multiview_flags) */+ SPA_FORMAT_VIDEO_chromaSite, /**< /Id enum spa_video_chroma_site) */+ SPA_FORMAT_VIDEO_colorRange, /**< /Id enum spa_video_color_range) */+ SPA_FORMAT_VIDEO_colorMatrix, /**< /Id enum spa_video_color_matrix) */+ SPA_FORMAT_VIDEO_transferFunction, /**< /Id enum spa_video_transfer_function) */+ SPA_FORMAT_VIDEO_colorPrimaries, /**< /Id enum spa_video_color_primaries) */+ SPA_FORMAT_VIDEO_profile, /**< (Int) */+ SPA_FORMAT_VIDEO_level, /**< (Int) */+ SPA_FORMAT_VIDEO_H264_streamFormat, /**< (Id enum spa_h264_stream_format) */+ SPA_FORMAT_VIDEO_H264_alignment, /**< (Id enum spa_h264_alignment) */++ /* Image Format keys */+ SPA_FORMAT_START_Image = 0x30000,+ /* Binary Format keys */+ SPA_FORMAT_START_Binary = 0x40000,+ /* Stream Format keys */+ SPA_FORMAT_START_Stream = 0x50000,+ /* Application Format keys */+ SPA_FORMAT_START_Application = 0x60000,+};++#define SPA_KEY_FORMAT_DSP "format.dsp" /**< a predefined DSP format,+ * Ex. "32 bit float mono audio" */++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_PARAM_FORMAT_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/param.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/param.hnew file mode 100644index 000000000..51c442c35--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/param.h@@ -0,0 +1,88 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_PARAM_H+#define SPA_PARAM_H++#ifdef __cplusplus+extern "C" {+#endif++/** \defgroup spa_param Parameters+ * Parameter value enumerations and type information+ */++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/utils/defs.h>++/** different parameter types that can be queried */+enum spa_param_type {+ SPA_PARAM_Invalid, /**< invalid */+ SPA_PARAM_PropInfo, /**< property information as SPA_TYPE_OBJECT_PropInfo */+ SPA_PARAM_Props, /**< properties as SPA_TYPE_OBJECT_Props */+ SPA_PARAM_EnumFormat, /**< available formats as SPA_TYPE_OBJECT_Format */+ SPA_PARAM_Format, /**< configured format as SPA_TYPE_OBJECT_Format */+ SPA_PARAM_Buffers, /**< buffer configurations as SPA_TYPE_OBJECT_ParamBuffers*/+ SPA_PARAM_Meta, /**< allowed metadata for buffers as SPA_TYPE_OBJECT_ParamMeta*/+ SPA_PARAM_IO, /**< configurable IO areas as SPA_TYPE_OBJECT_ParamIO */+ SPA_PARAM_EnumProfile, /**< profile enumeration as SPA_TYPE_OBJECT_ParamProfile */+ SPA_PARAM_Profile, /**< profile configuration as SPA_TYPE_OBJECT_ParamProfile */+ SPA_PARAM_EnumPortConfig, /**< port configuration enumeration as SPA_TYPE_OBJECT_ParamPortConfig */+ SPA_PARAM_PortConfig, /**< port configuration as SPA_TYPE_OBJECT_ParamPortConfig */+ SPA_PARAM_EnumRoute, /**< routing enumeration as SPA_TYPE_OBJECT_ParamRoute */+ SPA_PARAM_Route, /**< routing configuration as SPA_TYPE_OBJECT_ParamRoute */+ SPA_PARAM_Control, /**< Control parameter, a SPA_TYPE_Sequence */+ SPA_PARAM_Latency, /**< latency reporting, a SPA_TYPE_OBJECT_ParamLatency */+ SPA_PARAM_ProcessLatency, /**< processing latency, a SPA_TYPE_OBJECT_ParamProcessLatency */+ SPA_PARAM_Tag, /**< tag reporting, a SPA_TYPE_OBJECT_ParamTag. Since 0.3.79 */+};++/** information about a parameter */+struct spa_param_info {+ uint32_t id; /**< enum spa_param_type */+#define SPA_PARAM_INFO_SERIAL (1<<0) /**< bit to signal update even when the+ * read/write flags don't change */+#define SPA_PARAM_INFO_READ (1<<1)+#define SPA_PARAM_INFO_WRITE (1<<2)+#define SPA_PARAM_INFO_READWRITE (SPA_PARAM_INFO_WRITE|SPA_PARAM_INFO_READ)+ uint32_t flags;+ uint32_t user; /**< private user field. You can use this to keep+ * state. */+ int32_t seq; /**< private seq field. You can use this to keep+ * state of a pending update. */+ uint32_t padding[4];+};++#define SPA_PARAM_INFO(id,flags) ((struct spa_param_info){ (id), (flags) })++enum spa_param_bitorder {+ SPA_PARAM_BITORDER_unknown, /**< unknown bitorder */+ SPA_PARAM_BITORDER_msb, /**< most significant bit */+ SPA_PARAM_BITORDER_lsb, /**< least significant bit */+};++enum spa_param_availability {+ SPA_PARAM_AVAILABILITY_unknown, /**< unknown availability */+ SPA_PARAM_AVAILABILITY_no, /**< not available */+ SPA_PARAM_AVAILABILITY_yes, /**< available */+};++#include <spa/param/buffers.h>+#include <spa/param/profile.h>+#include <spa/param/port-config.h>+#include <spa/param/route.h>++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_PARAM_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/port-config.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/port-config.hnew file mode 100644index 000000000..7e05eda27--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/port-config.h@@ -0,0 +1,46 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_PARAM_PORT_CONFIG_H+#define SPA_PARAM_PORT_CONFIG_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/param/param.h>++enum spa_param_port_config_mode {+ SPA_PARAM_PORT_CONFIG_MODE_none, /**< no configuration */+ SPA_PARAM_PORT_CONFIG_MODE_passthrough, /**< passthrough configuration */+ SPA_PARAM_PORT_CONFIG_MODE_convert, /**< convert configuration */+ SPA_PARAM_PORT_CONFIG_MODE_dsp, /**< dsp configuration, depending on the external+ * format. For audio, ports will be configured for+ * the given number of channels with F32 format. */+};++/** properties for SPA_TYPE_OBJECT_ParamPortConfig */+enum spa_param_port_config {+ SPA_PARAM_PORT_CONFIG_START,+ SPA_PARAM_PORT_CONFIG_direction, /**< (Id enum spa_direction) direction */+ SPA_PARAM_PORT_CONFIG_mode, /**< (Id enum spa_param_port_config_mode) mode */+ SPA_PARAM_PORT_CONFIG_monitor, /**< (Bool) enable monitor output ports on input ports */+ SPA_PARAM_PORT_CONFIG_control, /**< (Bool) enable control ports */+ SPA_PARAM_PORT_CONFIG_format, /**< (Object) format filter */+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_PARAM_PORT_CONFIG_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/profile.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/profile.hnew file mode 100644index 000000000..00468f36d--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/profile.h@@ -0,0 +1,52 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_PARAM_PROFILE_H+#define SPA_PARAM_PROFILE_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/param/param.h>++/** properties for SPA_TYPE_OBJECT_ParamProfile */+enum spa_param_profile {+ SPA_PARAM_PROFILE_START,+ SPA_PARAM_PROFILE_index, /**< profile index (Int) */+ SPA_PARAM_PROFILE_name, /**< profile name (String) */+ SPA_PARAM_PROFILE_description, /**< profile description (String) */+ SPA_PARAM_PROFILE_priority, /**< profile priority (Int) */+ SPA_PARAM_PROFILE_available, /**< availability of the profile+ * (Id enum spa_param_availability) */+ SPA_PARAM_PROFILE_info, /**< info (Struct(+ * Int : n_items,+ * (String : key,+ * String : value)*)) */+ SPA_PARAM_PROFILE_classes, /**< node classes provided by this profile+ * (Struct(+ * Int : number of items following+ * Struct(+ * String : class name (eg. "Audio/Source"),+ * Int : number of nodes+ * String : property (eg. "card.profile.devices"),+ * Array of Int: device indexes+ * )*)) */+ SPA_PARAM_PROFILE_save, /**< If profile should be saved (Bool) */+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_PARAM_PROFILE_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/props.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/props.hnew file mode 100644index 000000000..a7a2e4c25--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/props.h@@ -0,0 +1,127 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_PARAM_PROPS_H+#define SPA_PARAM_PROPS_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/param/param.h>++/** properties of SPA_TYPE_OBJECT_PropInfo */+enum spa_prop_info {+ SPA_PROP_INFO_START,+ SPA_PROP_INFO_id, /**< associated id of the property */+ SPA_PROP_INFO_name, /**< name of the property */+ SPA_PROP_INFO_type, /**< type and range/enums of property */+ SPA_PROP_INFO_labels, /**< labels of property if any, this is a+ * struct with pairs of values, the first one+ * is of the type of the property, the second+ * one is a string with a user readable label+ * for the value. */+ SPA_PROP_INFO_container, /**< type of container if any (Id) */+ SPA_PROP_INFO_params, /**< is part of params property (Bool) */+ SPA_PROP_INFO_description, /**< User readable description */+};++/** predefined properties for SPA_TYPE_OBJECT_Props */+enum spa_prop {+ SPA_PROP_START,++ SPA_PROP_unknown, /**< an unknown property */++ SPA_PROP_START_Device = 0x100, /**< device related properties */+ SPA_PROP_device,+ SPA_PROP_deviceName,+ SPA_PROP_deviceFd,+ SPA_PROP_card,+ SPA_PROP_cardName,++ SPA_PROP_minLatency,+ SPA_PROP_maxLatency,+ SPA_PROP_periods,+ SPA_PROP_periodSize,+ SPA_PROP_periodEvent,+ SPA_PROP_live,+ SPA_PROP_rate,+ SPA_PROP_quality,+ SPA_PROP_bluetoothAudioCodec,+ SPA_PROP_bluetoothOffloadActive,++ SPA_PROP_START_Audio = 0x10000, /**< audio related properties */+ SPA_PROP_waveType,+ SPA_PROP_frequency,+ SPA_PROP_volume, /**< a volume (Float), 0.0 silence, 1.0 no attenutation */+ SPA_PROP_mute, /**< mute (Bool) */+ SPA_PROP_patternType,+ SPA_PROP_ditherType,+ SPA_PROP_truncate,+ SPA_PROP_channelVolumes, /**< a volume array, one (linear) volume per channel+ * (Array of Float). 0.0 is silence, 1.0 is+ * without attenuation. This is the effective+ * volume that is applied. It can result+ * in a hardware volume and software volume+ * (see softVolumes) */+ SPA_PROP_volumeBase, /**< a volume base (Float) */+ SPA_PROP_volumeStep, /**< a volume step (Float) */+ SPA_PROP_channelMap, /**< a channelmap array+ * (Array (Id enum spa_audio_channel)) */+ SPA_PROP_monitorMute, /**< mute (Bool) */+ SPA_PROP_monitorVolumes, /**< a volume array, one (linear) volume per+ * channel (Array of Float) */+ SPA_PROP_latencyOffsetNsec, /**< delay adjustment */+ SPA_PROP_softMute, /**< mute (Bool) applied in software */+ SPA_PROP_softVolumes, /**< a volume array, one (linear) volume per channel+ * (Array of Float). 0.0 is silence, 1.0 is without+ * attenuation. This is the volume applied in+ * software, there might be a part applied in+ * hardware. */++ SPA_PROP_iec958Codecs, /**< enabled IEC958 (S/PDIF) codecs,+ * (Array (Id enum spa_audio_iec958_codec) */+ SPA_PROP_volumeRampSamples, /**< Samples to ramp the volume over */+ SPA_PROP_volumeRampStepSamples, /**< Step or incremental Samples to ramp+ * the volume over */+ SPA_PROP_volumeRampTime, /**< Time in millisec to ramp the volume over */+ SPA_PROP_volumeRampStepTime, /**< Step or incremental Time in nano seconds+ * to ramp the */+ SPA_PROP_volumeRampScale, /**< the scale or graph to used to ramp the+ * volume */++ SPA_PROP_START_Video = 0x20000, /**< video related properties */+ SPA_PROP_brightness,+ SPA_PROP_contrast,+ SPA_PROP_saturation,+ SPA_PROP_hue,+ SPA_PROP_gamma,+ SPA_PROP_exposure,+ SPA_PROP_gain,+ SPA_PROP_sharpness,++ SPA_PROP_START_Other = 0x80000, /**< other properties */+ SPA_PROP_params, /**< simple control params+ * (Struct(+ * (String : key,+ * Pod : value)*)) */+++ SPA_PROP_START_CUSTOM = 0x1000000,+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_PARAM_PROPS_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/route.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/route.hnew file mode 100644index 000000000..d73880c5a--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/route.h@@ -0,0 +1,49 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_PARAM_ROUTE_H+#define SPA_PARAM_ROUTE_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/param/param.h>++/** properties for SPA_TYPE_OBJECT_ParamRoute */+enum spa_param_route {+ SPA_PARAM_ROUTE_START,+ SPA_PARAM_ROUTE_index, /**< index of the routing destination (Int) */+ SPA_PARAM_ROUTE_direction, /**< direction, input/output (Id enum spa_direction) */+ SPA_PARAM_ROUTE_device, /**< device id (Int) */+ SPA_PARAM_ROUTE_name, /**< name of the routing destination (String) */+ SPA_PARAM_ROUTE_description, /**< description of the destination (String) */+ SPA_PARAM_ROUTE_priority, /**< priority of the destination (Int) */+ SPA_PARAM_ROUTE_available, /**< availability of the destination+ * (Id enum spa_param_availability) */+ SPA_PARAM_ROUTE_info, /**< info (Struct(+ * Int : n_items,+ * (String : key,+ * String : value)*)) */+ SPA_PARAM_ROUTE_profiles, /**< associated profile indexes (Array of Int) */+ SPA_PARAM_ROUTE_props, /**< properties SPA_TYPE_OBJECT_Props */+ SPA_PARAM_ROUTE_devices, /**< associated device indexes (Array of Int) */+ SPA_PARAM_ROUTE_profile, /**< profile id (Int) */+ SPA_PARAM_ROUTE_save, /**< If route should be saved (Bool) */+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_PARAM_ROUTE_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/chroma.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/chroma.hnew file mode 100644index 000000000..0fc8daf52--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/chroma.h@@ -0,0 +1,44 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_VIDEO_CHROMA_H+#define SPA_VIDEO_CHROMA_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++/** Various Chroma settings.+ */+enum spa_video_chroma_site {+ SPA_VIDEO_CHROMA_SITE_UNKNOWN = 0, /**< unknown cositing */+ SPA_VIDEO_CHROMA_SITE_NONE = (1 << 0), /**< no cositing */+ SPA_VIDEO_CHROMA_SITE_H_COSITED = (1 << 1), /**< chroma is horizontally cosited */+ SPA_VIDEO_CHROMA_SITE_V_COSITED = (1 << 2), /**< chroma is vertically cosited */+ SPA_VIDEO_CHROMA_SITE_ALT_LINE = (1 << 3), /**< chroma samples are sited on alternate lines */+ /* some common chroma cositing */+ /** chroma samples cosited with luma samples */+ SPA_VIDEO_CHROMA_SITE_COSITED = (SPA_VIDEO_CHROMA_SITE_H_COSITED | SPA_VIDEO_CHROMA_SITE_V_COSITED),+ /** jpeg style cositing, also for mpeg1 and mjpeg */+ SPA_VIDEO_CHROMA_SITE_JPEG = (SPA_VIDEO_CHROMA_SITE_NONE),+ /** mpeg2 style cositing */+ SPA_VIDEO_CHROMA_SITE_MPEG2 = (SPA_VIDEO_CHROMA_SITE_H_COSITED),+ /**< DV style cositing */+ SPA_VIDEO_CHROMA_SITE_DV = (SPA_VIDEO_CHROMA_SITE_COSITED | SPA_VIDEO_CHROMA_SITE_ALT_LINE),+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_VIDEO_CHROMA_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/color.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/color.hnew file mode 100644index 000000000..9a65bf04a--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/color.h@@ -0,0 +1,105 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_VIDEO_COLOR_H+#define SPA_VIDEO_COLOR_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++/**+ * Possible color range values. These constants are defined for 8 bit color+ * values and can be scaled for other bit depths.+ */+enum spa_video_color_range {+ SPA_VIDEO_COLOR_RANGE_UNKNOWN = 0, /**< unknown range */+ SPA_VIDEO_COLOR_RANGE_0_255, /**< [0..255] for 8 bit components */+ SPA_VIDEO_COLOR_RANGE_16_235 /**< [16..235] for 8 bit components. Chroma has+ [16..240] range. */+};++/**+ * The color matrix is used to convert between Y'PbPr and+ * non-linear RGB (R'G'B')+ */+enum spa_video_color_matrix {+ SPA_VIDEO_COLOR_MATRIX_UNKNOWN = 0, /**< unknown matrix */+ SPA_VIDEO_COLOR_MATRIX_RGB, /**< identity matrix */+ SPA_VIDEO_COLOR_MATRIX_FCC, /**< FCC color matrix */+ SPA_VIDEO_COLOR_MATRIX_BT709, /**< ITU BT.709 color matrix */+ SPA_VIDEO_COLOR_MATRIX_BT601, /**< ITU BT.601 color matrix */+ SPA_VIDEO_COLOR_MATRIX_SMPTE240M, /**< SMTPE 240M color matrix */+ SPA_VIDEO_COLOR_MATRIX_BT2020, /**< ITU-R BT.2020 color matrix. since 1.6. */+};++/**+ * The video transfer function defines the formula for converting between+ * non-linear RGB (R'G'B') and linear RGB+ */+enum spa_video_transfer_function {+ SPA_VIDEO_TRANSFER_UNKNOWN = 0, /**< unknown transfer function */+ SPA_VIDEO_TRANSFER_GAMMA10, /**< linear RGB, gamma 1.0 curve */+ SPA_VIDEO_TRANSFER_GAMMA18, /**< Gamma 1.8 curve */+ SPA_VIDEO_TRANSFER_GAMMA20, /**< Gamma 2.0 curve */+ SPA_VIDEO_TRANSFER_GAMMA22, /**< Gamma 2.2 curve */+ SPA_VIDEO_TRANSFER_BT709, /**< Gamma 2.2 curve with a linear segment in the lower range */+ SPA_VIDEO_TRANSFER_SMPTE240M, /**< Gamma 2.2 curve with a linear segment in the lower range */+ SPA_VIDEO_TRANSFER_SRGB, /**< Gamma 2.4 curve with a linear segment in the lower range */+ SPA_VIDEO_TRANSFER_GAMMA28, /**< Gamma 2.8 curve */+ SPA_VIDEO_TRANSFER_LOG100, /**< Logarithmic transfer characteristic 100:1 range */+ SPA_VIDEO_TRANSFER_LOG316, /**< Logarithmic transfer characteristic 316.22777:1 range */+ SPA_VIDEO_TRANSFER_BT2020_12, /**< Gamma 2.2 curve with a linear segment in the lower+ * range. Used for BT.2020 with 12 bits per+ * component. \since 1.6. */+ SPA_VIDEO_TRANSFER_ADOBERGB, /**< Gamma 2.19921875. \since 1.8 */+};++/**+ * The color primaries define the how to transform linear RGB values to and from+ * the CIE XYZ colorspace.+ */+enum spa_video_color_primaries {+ SPA_VIDEO_COLOR_PRIMARIES_UNKNOWN = 0, /**< unknown color primaries */+ SPA_VIDEO_COLOR_PRIMARIES_BT709, /**< BT709 primaries */+ SPA_VIDEO_COLOR_PRIMARIES_BT470M, /**< BT470M primaries */+ SPA_VIDEO_COLOR_PRIMARIES_BT470BG, /**< BT470BG primaries */+ SPA_VIDEO_COLOR_PRIMARIES_SMPTE170M, /**< SMPTE170M primaries */+ SPA_VIDEO_COLOR_PRIMARIES_SMPTE240M, /**< SMPTE240M primaries */+ SPA_VIDEO_COLOR_PRIMARIES_FILM, /**< Generic film */+ SPA_VIDEO_COLOR_PRIMARIES_BT2020, /**< BT2020 primaries. \since 1.6. */+ SPA_VIDEO_COLOR_PRIMARIES_ADOBERGB, /**< Adobe RGB primaries. \since 1.8 */+};++/**+ * spa_video_colorimetry:+ *+ * Structure describing the color info.+ */+struct spa_video_colorimetry {+ enum spa_video_color_range range; /**< The color range. This is the valid range for the+ * samples. It is used to convert the samples to Y'PbPr+ * values. */+ enum spa_video_color_matrix matrix; /**< the color matrix. Used to convert between Y'PbPr and+ * non-linear RGB (R'G'B') */+ enum spa_video_transfer_function transfer; /**< The transfer function. Used to convert between+ * R'G'B' and RGB */+ enum spa_video_color_primaries primaries; /**< Color primaries. Used to convert between R'G'B'+ * and CIE XYZ */+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_VIDEO_COLOR_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/dsp-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/dsp-utils.hnew file mode 100644index 000000000..8944bf6d9--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/dsp-utils.h@@ -0,0 +1,68 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_VIDEO_DSP_UTILS_H+#define SPA_VIDEO_DSP_UTILS_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/pod/parser.h>+#include <spa/pod/builder.h>+#include <spa/param/video/dsp.h>++static inline int+spa_format_video_dsp_parse(const struct spa_pod *format,+ struct spa_video_info_dsp *info)+{+ info->flags = SPA_VIDEO_FLAG_NONE;+ const struct spa_pod_prop *mod_prop;+ if ((mod_prop = spa_pod_find_prop (format, NULL, SPA_FORMAT_VIDEO_modifier)) != NULL) {+ info->flags |= SPA_VIDEO_FLAG_MODIFIER;+ if ((mod_prop->flags & SPA_POD_PROP_FLAG_DONT_FIXATE) == SPA_POD_PROP_FLAG_DONT_FIXATE)+ info->flags |= SPA_VIDEO_FLAG_MODIFIER_FIXATION_REQUIRED;+ }++ return spa_pod_parse_object(format,+ SPA_TYPE_OBJECT_Format, NULL,+ SPA_FORMAT_VIDEO_format, SPA_POD_OPT_Id(&info->format),+ SPA_FORMAT_VIDEO_modifier, SPA_POD_OPT_Long(&info->modifier));+}++static inline struct spa_pod *+spa_format_video_dsp_build(struct spa_pod_builder *builder, uint32_t id,+ struct spa_video_info_dsp *info)+{+ struct spa_pod_frame f;+ spa_pod_builder_push_object(builder, &f, SPA_TYPE_OBJECT_Format, id);+ spa_pod_builder_add(builder,+ SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video),+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_dsp),+ 0);+ if (info->format != SPA_VIDEO_FORMAT_UNKNOWN)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_format, SPA_POD_Id(info->format), 0);+ if (info->modifier != 0 || info->flags & SPA_VIDEO_FLAG_MODIFIER) {+ spa_pod_builder_prop(builder,+ SPA_FORMAT_VIDEO_modifier, SPA_POD_PROP_FLAG_MANDATORY);+ spa_pod_builder_long(builder, info->modifier);+ }+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);+}++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_VIDEO_DSP_UTILS_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/dsp.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/dsp.hnew file mode 100644index 000000000..3200deab9--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/dsp.h@@ -0,0 +1,35 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_VIDEO_DSP_H+#define SPA_VIDEO_DSP_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/param/video/raw.h>++struct spa_video_info_dsp {+ enum spa_video_format format;+ uint32_t flags;+ uint64_t modifier;+};++#define SPA_VIDEO_INFO_DSP_INIT(...) ((struct spa_video_info_dsp) { __VA_ARGS__ })++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_VIDEO_DSP_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/encoded.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/encoded.hnew file mode 100644index 000000000..670da5af3--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/encoded.h@@ -0,0 +1,11 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_VIDEO_ENCODED_H+#define SPA_VIDEO_ENCODED_H++#include <spa/param/video/h264.h>+#include <spa/param/video/mjpg.h>++#endif /* SPA_VIDEO_ENCODED_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/format-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/format-utils.hnew file mode 100644index 000000000..2bb84c76e--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/format-utils.h@@ -0,0 +1,64 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_PARAM_VIDEO_FORMAT_UTILS_H+#define SPA_PARAM_VIDEO_FORMAT_UTILS_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/param/format-utils.h>+#include <spa/param/video/format.h>+#include <spa/param/video/raw-utils.h>+#include <spa/param/video/dsp-utils.h>+#include <spa/param/video/h264-utils.h>+#include <spa/param/video/mjpg-utils.h>++static inline int+spa_format_video_parse(const struct spa_pod *format, struct spa_video_info *info)+{+ int res;++ if ((res = spa_format_parse(format, &info->media_type, &info->media_subtype)) < 0)+ return res;++ if (info->media_type != SPA_MEDIA_TYPE_video)+ return -EINVAL;++ switch (info->media_subtype) {+ case SPA_MEDIA_SUBTYPE_raw:+ return spa_format_video_raw_parse(format, &info->info.raw);+ case SPA_MEDIA_SUBTYPE_dsp:+ return spa_format_video_dsp_parse(format, &info->info.dsp);+ case SPA_MEDIA_SUBTYPE_h264:+ return spa_format_video_h264_parse(format, &info->info.h264);+ case SPA_MEDIA_SUBTYPE_mjpg:+ return spa_format_video_mjpg_parse(format, &info->info.mjpg);+ }+ return -ENOTSUP;+}++static inline struct spa_pod *+spa_format_video_build(struct spa_pod_builder *builder, uint32_t id, struct spa_video_info *info)+{+ switch (info->media_subtype) {+ case SPA_MEDIA_SUBTYPE_raw:+ return spa_format_video_raw_build(builder, id, &info->info.raw);+ case SPA_MEDIA_SUBTYPE_dsp:+ return spa_format_video_dsp_build(builder, id, &info->info.dsp);+ case SPA_MEDIA_SUBTYPE_h264:+ return spa_format_video_h264_build(builder, id, &info->info.h264);+ case SPA_MEDIA_SUBTYPE_mjpg:+ return spa_format_video_mjpg_build(builder, id, &info->info.mjpg);+ }+ errno = ENOTSUP;+ return NULL;+}++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_PARAM_VIDEO_FORMAT_UTILS_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/format.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/format.hnew file mode 100644index 000000000..7fa992c96--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/format.h@@ -0,0 +1,41 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_PARAM_VIDEO_FORMAT_H+#define SPA_PARAM_VIDEO_FORMAT_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/param/format.h>+#include <spa/param/video/raw.h>+#include <spa/param/video/dsp.h>+#include <spa/param/video/encoded.h>++struct spa_video_info {+ uint32_t media_type;+ uint32_t media_subtype;+ union {+ struct spa_video_info_raw raw;+ struct spa_video_info_dsp dsp;+ struct spa_video_info_h264 h264;+ struct spa_video_info_mjpg mjpg;+ } info;+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_PARAM_VIDEO_FORMAT_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/h264-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/h264-utils.hnew file mode 100644index 000000000..f4b3a5cc3--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/h264-utils.h@@ -0,0 +1,70 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_VIDEO_H264_UTILS_H+#define SPA_VIDEO_H264_UTILS_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/pod/parser.h>+#include <spa/pod/builder.h>+#include <spa/param/video/h264.h>++static inline int+spa_format_video_h264_parse(const struct spa_pod *format,+ struct spa_video_info_h264 *info)+{+ return spa_pod_parse_object(format,+ SPA_TYPE_OBJECT_Format, NULL,+ SPA_FORMAT_VIDEO_size, SPA_POD_OPT_Rectangle(&info->size),+ SPA_FORMAT_VIDEO_framerate, SPA_POD_OPT_Fraction(&info->framerate),+ SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_OPT_Fraction(&info->max_framerate),+ SPA_FORMAT_VIDEO_H264_streamFormat, SPA_POD_OPT_Id(&info->stream_format),+ SPA_FORMAT_VIDEO_H264_alignment, SPA_POD_OPT_Id(&info->alignment));+}++static inline struct spa_pod *+spa_format_video_h264_build(struct spa_pod_builder *builder, uint32_t id,+ struct spa_video_info_h264 *info)+{+ struct spa_pod_frame f;+ spa_pod_builder_push_object(builder, &f, SPA_TYPE_OBJECT_Format, id);+ spa_pod_builder_add(builder,+ SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video),+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_h264),+ 0);+ if (info->size.width != 0 && info->size.height != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle(&info->size), 0);+ if (info->framerate.denom != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction(&info->framerate), 0);+ if (info->max_framerate.denom != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_Fraction(info->max_framerate), 0);+ if (info->stream_format != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_H264_streamFormat, SPA_POD_Id(info->stream_format), 0);+ if (info->alignment != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_H264_alignment, SPA_POD_Id(info->alignment), 0);+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);+}++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_VIDEO_H264_UTILS_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/h264.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/h264.hnew file mode 100644index 000000000..33ddffc4e--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/h264.h@@ -0,0 +1,48 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_VIDEO_H264_H+#define SPA_VIDEO_H264_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/param/format.h>++enum spa_h264_stream_format {+ SPA_H264_STREAM_FORMAT_UNKNOWN = 0,+ SPA_H264_STREAM_FORMAT_AVC,+ SPA_H264_STREAM_FORMAT_AVC3,+ SPA_H264_STREAM_FORMAT_BYTESTREAM+};++enum spa_h264_alignment {+ SPA_H264_ALIGNMENT_UNKNOWN = 0,+ SPA_H264_ALIGNMENT_AU,+ SPA_H264_ALIGNMENT_NAL+};++struct spa_video_info_h264 {+ struct spa_rectangle size;+ struct spa_fraction framerate;+ struct spa_fraction max_framerate;+ enum spa_h264_stream_format stream_format;+ enum spa_h264_alignment alignment;+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_VIDEO_H264_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/mjpg-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/mjpg-utils.hnew file mode 100644index 000000000..e7b104a9a--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/mjpg-utils.h@@ -0,0 +1,62 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_VIDEO_MJPG_UTILS_H+#define SPA_VIDEO_MJPG_UTILS_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/pod/parser.h>+#include <spa/pod/builder.h>+#include <spa/param/video/mjpg.h>++static inline int+spa_format_video_mjpg_parse(const struct spa_pod *format,+ struct spa_video_info_mjpg *info)+{+ return spa_pod_parse_object(format,+ SPA_TYPE_OBJECT_Format, NULL,+ SPA_FORMAT_VIDEO_size, SPA_POD_OPT_Rectangle(&info->size),+ SPA_FORMAT_VIDEO_framerate, SPA_POD_OPT_Fraction(&info->framerate),+ SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_OPT_Fraction(&info->max_framerate));+}++static inline struct spa_pod *+spa_format_video_mjpg_build(struct spa_pod_builder *builder, uint32_t id,+ struct spa_video_info_mjpg *info)+{+ struct spa_pod_frame f;+ spa_pod_builder_push_object(builder, &f, SPA_TYPE_OBJECT_Format, id);+ spa_pod_builder_add(builder,+ SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video),+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_mjpg),+ 0);+ if (info->size.width != 0 && info->size.height != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle(&info->size), 0);+ if (info->framerate.denom != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction(&info->framerate), 0);+ if (info->max_framerate.denom != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_Fraction(info->max_framerate), 0);+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);+}++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_VIDEO_MJPG_UTILS_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/mjpg.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/mjpg.hnew file mode 100644index 000000000..fb85daade--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/mjpg.h@@ -0,0 +1,33 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_VIDEO_MJPG_H+#define SPA_VIDEO_MJPG_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/param/format.h>++struct spa_video_info_mjpg {+ struct spa_rectangle size;+ struct spa_fraction framerate;+ struct spa_fraction max_framerate;+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_VIDEO_MJPG_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/multiview.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/multiview.hnew file mode 100644index 000000000..34d47423f--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/multiview.h@@ -0,0 +1,111 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_VIDEO_MULTIVIEW_H+#define SPA_VIDEO_MULTIVIEW_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++/**+ * All possible stereoscopic 3D and multiview representations.+ * In conjunction with \ref spa_video_multiview_flags, describes how+ * multiview content is being transported in the stream.+ */+enum spa_video_multiview_mode {+ /** A special value indicating no multiview information. Used in spa_video_info and other+ * places to indicate that no specific multiview handling has been requested or provided.+ * This value is never carried on caps. */+ SPA_VIDEO_MULTIVIEW_MODE_NONE = -1,+ SPA_VIDEO_MULTIVIEW_MODE_MONO = 0, /**< All frames are monoscopic */+ /* Single view modes */+ SPA_VIDEO_MULTIVIEW_MODE_LEFT, /**< All frames represent a left-eye view */+ SPA_VIDEO_MULTIVIEW_MODE_RIGHT, /**< All frames represent a right-eye view */+ /* Stereo view modes */+ SPA_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE, /**< Left and right eye views are provided+ * in the left and right half of the frame+ * respectively. */+ SPA_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE_QUINCUNX, /**< Left and right eye views are provided+ * in the left and right half of the+ * frame, but have been sampled using+ * quincunx method, with half-pixel offset+ * between the 2 views. */+ SPA_VIDEO_MULTIVIEW_MODE_COLUMN_INTERLEAVED, /**< Alternating vertical columns of pixels+ * represent the left and right eye view+ * respectively. */+ SPA_VIDEO_MULTIVIEW_MODE_ROW_INTERLEAVED, /**< Alternating horizontal rows of pixels+ * represent the left and right eye view+ * respectively. */+ SPA_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM, /**< The top half of the frame contains the+ * left eye, and the bottom half the right+ * eye. */+ SPA_VIDEO_MULTIVIEW_MODE_CHECKERBOARD, /**< Pixels are arranged with alternating+ * pixels representing left and right eye+ * views in a checkerboard fashion. */+ /* Padding for new frame packing modes */++ SPA_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME = 32, /**< Left and right eye views are provided+ * in separate frames alternately. */+ /* Multiview mode(s) */+ SPA_VIDEO_MULTIVIEW_MODE_MULTIVIEW_FRAME_BY_FRAME, /**< Multipleindependent views are+ * provided in separate frames in+ * sequence. This method only applies to+ * raw video buffers at the moment.+ * Specific view identification is via+ * metadata on raw video buffers. */+ SPA_VIDEO_MULTIVIEW_MODE_SEPARATED, /**< Multiple views are provided as separate+ * \ref spa_data framebuffers attached+ * to each \ref spa_buffer, described+ * by the metadata */+ /* future expansion for annotated modes */+};++/**+ * spa_video_multiview_flags are used to indicate extra properties of a+ * stereo/multiview stream beyond the frame layout and buffer mapping+ * that is conveyed in the \ref spa_video_multiview_mode.+ */+enum spa_video_multiview_flags {+ SPA_VIDEO_MULTIVIEW_FLAGS_NONE = 0, /**< No flags */+ SPA_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST = (1 << 0), /**< For stereo streams, the normal arrangement+ * of left and right views is reversed */+ SPA_VIDEO_MULTIVIEW_FLAGS_LEFT_FLIPPED = (1 << 1), /**< The left view is vertically mirrored */+ SPA_VIDEO_MULTIVIEW_FLAGS_LEFT_FLOPPED = (1 << 2), /**< The left view is horizontally mirrored */+ SPA_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLIPPED = (1 << 3), /**< The right view is vertically mirrored */+ SPA_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLOPPED = (1 << 4), /**< The right view is horizontally mirrored */+ SPA_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT = (1 << 14), /**< For frame-packed multiview+ * modes, indicates that the individual+ * views have been encoded with half the true+ * width or height and should be scaled back+ * up for display. This flag is used for+ * overriding input layout interpretation+ * by adjusting pixel-aspect-ratio.+ * For side-by-side, column interleaved or+ * checkerboard packings, the+ * pixel width will be doubled.+ * For row interleaved and+ * top-bottom encodings, pixel height will+ * be doubled */+ SPA_VIDEO_MULTIVIEW_FLAGS_MIXED_MONO = (1 << 15), /**< The video stream contains both+ * mono and multiview portions,+ * signalled on each buffer by the+ * absence or presence of a buffer flag. */+};+++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_VIDEO_MULTIVIEW_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/raw-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/raw-utils.hnew file mode 100644index 000000000..65c96724f--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/raw-utils.h@@ -0,0 +1,120 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_VIDEO_RAW_UTILS_H+#define SPA_VIDEO_RAW_UTILS_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/pod/parser.h>+#include <spa/pod/builder.h>+#include <spa/param/video/raw.h>++static inline int+spa_format_video_raw_parse(const struct spa_pod *format,+ struct spa_video_info_raw *info)+{+ info->flags = SPA_VIDEO_FLAG_NONE;+ const struct spa_pod_prop *mod_prop;+ if ((mod_prop = spa_pod_find_prop (format, NULL, SPA_FORMAT_VIDEO_modifier)) != NULL) {+ info->flags |= SPA_VIDEO_FLAG_MODIFIER;+ if ((mod_prop->flags & SPA_POD_PROP_FLAG_DONT_FIXATE) == SPA_POD_PROP_FLAG_DONT_FIXATE)+ info->flags |= SPA_VIDEO_FLAG_MODIFIER_FIXATION_REQUIRED;+ }++ return spa_pod_parse_object(format,+ SPA_TYPE_OBJECT_Format, NULL,+ SPA_FORMAT_VIDEO_format, SPA_POD_OPT_Id(&info->format),+ SPA_FORMAT_VIDEO_modifier, SPA_POD_OPT_Long(&info->modifier),+ SPA_FORMAT_VIDEO_size, SPA_POD_OPT_Rectangle(&info->size),+ SPA_FORMAT_VIDEO_framerate, SPA_POD_OPT_Fraction(&info->framerate),+ SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_OPT_Fraction(&info->max_framerate),+ SPA_FORMAT_VIDEO_views, SPA_POD_OPT_Int(&info->views),+ SPA_FORMAT_VIDEO_interlaceMode, SPA_POD_OPT_Id(&info->interlace_mode),+ SPA_FORMAT_VIDEO_pixelAspectRatio, SPA_POD_OPT_Fraction(&info->pixel_aspect_ratio),+ SPA_FORMAT_VIDEO_multiviewMode, SPA_POD_OPT_Id(&info->multiview_mode),+ SPA_FORMAT_VIDEO_multiviewFlags, SPA_POD_OPT_Id(&info->multiview_flags),+ SPA_FORMAT_VIDEO_chromaSite, SPA_POD_OPT_Id(&info->chroma_site),+ SPA_FORMAT_VIDEO_colorRange, SPA_POD_OPT_Id(&info->color_range),+ SPA_FORMAT_VIDEO_colorMatrix, SPA_POD_OPT_Id(&info->color_matrix),+ SPA_FORMAT_VIDEO_transferFunction, SPA_POD_OPT_Id(&info->transfer_function),+ SPA_FORMAT_VIDEO_colorPrimaries, SPA_POD_OPT_Id(&info->color_primaries));+}++static inline struct spa_pod *+spa_format_video_raw_build(struct spa_pod_builder *builder, uint32_t id,+ struct spa_video_info_raw *info)+{+ struct spa_pod_frame f;+ spa_pod_builder_push_object(builder, &f, SPA_TYPE_OBJECT_Format, id);+ spa_pod_builder_add(builder,+ SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video),+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),+ 0);+ if (info->format != SPA_VIDEO_FORMAT_UNKNOWN)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_format, SPA_POD_Id(info->format), 0);+ if (info->size.width != 0 && info->size.height != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle(&info->size), 0);+ if (info->framerate.denom != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction(&info->framerate), 0);+ if (info->modifier != 0 || info->flags & SPA_VIDEO_FLAG_MODIFIER) {+ spa_pod_builder_prop(builder,+ SPA_FORMAT_VIDEO_modifier, SPA_POD_PROP_FLAG_MANDATORY);+ spa_pod_builder_long(builder, info->modifier);+ }+ if (info->max_framerate.denom != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_Fraction(info->max_framerate), 0);+ if (info->views != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_views, SPA_POD_Int(info->views), 0);+ if (info->interlace_mode != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_interlaceMode, SPA_POD_Id(info->interlace_mode), 0);+ if (info->pixel_aspect_ratio.denom != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_pixelAspectRatio,SPA_POD_Fraction(info->pixel_aspect_ratio), 0);+ if (info->multiview_mode != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_multiviewMode, SPA_POD_Id(info->multiview_mode), 0);+ if (info->multiview_flags != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_multiviewFlags,SPA_POD_Id(info->multiview_flags), 0);+ if (info->chroma_site != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_chromaSite, SPA_POD_Id(info->chroma_site), 0);+ if (info->color_range != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_colorRange, SPA_POD_Id(info->color_range), 0);+ if (info->color_matrix != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_colorMatrix, SPA_POD_Id(info->color_matrix), 0);+ if (info->transfer_function != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_transferFunction,SPA_POD_Id(info->transfer_function), 0);+ if (info->color_primaries != 0)+ spa_pod_builder_add(builder,+ SPA_FORMAT_VIDEO_colorPrimaries,SPA_POD_Id(info->color_primaries), 0);+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);+}++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_VIDEO_RAW_UTILS_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/raw.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/raw.hnew file mode 100644index 000000000..84f78ad6a--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/video/raw.h@@ -0,0 +1,202 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_VIDEO_RAW_H+#define SPA_VIDEO_RAW_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \addtogroup spa_param+ * \{+ */++#include <spa/param/format.h>+#include <spa/param/video/chroma.h>+#include <spa/param/video/color.h>+#include <spa/param/video/multiview.h>++#define SPA_VIDEO_MAX_PLANES 4+#define SPA_VIDEO_MAX_COMPONENTS 4++/**+ * Video formats+ *+ * The components are in general described in big-endian order. There are some+ * exceptions (e.g. RGB15 and RGB16) which use the host endianness.+ *+ * Most of the formats are identical to their GStreamer equivalent. See the+ * GStreamer video formats documentation for more details:+ *+ * https://gstreamer.freedesktop.org/documentation/additional/design/mediatype-video-raw.html#formats+ */+enum spa_video_format {+ SPA_VIDEO_FORMAT_UNKNOWN,+ SPA_VIDEO_FORMAT_ENCODED,++ SPA_VIDEO_FORMAT_I420,+ SPA_VIDEO_FORMAT_YV12,+ SPA_VIDEO_FORMAT_YUY2,+ SPA_VIDEO_FORMAT_UYVY,+ SPA_VIDEO_FORMAT_AYUV,+ SPA_VIDEO_FORMAT_RGBx,+ SPA_VIDEO_FORMAT_BGRx,+ SPA_VIDEO_FORMAT_xRGB,+ SPA_VIDEO_FORMAT_xBGR,+ SPA_VIDEO_FORMAT_RGBA,+ SPA_VIDEO_FORMAT_BGRA,+ SPA_VIDEO_FORMAT_ARGB,+ SPA_VIDEO_FORMAT_ABGR,+ SPA_VIDEO_FORMAT_RGB,+ SPA_VIDEO_FORMAT_BGR,+ SPA_VIDEO_FORMAT_Y41B,+ SPA_VIDEO_FORMAT_Y42B,+ SPA_VIDEO_FORMAT_YVYU,+ SPA_VIDEO_FORMAT_Y444,+ SPA_VIDEO_FORMAT_v210,+ SPA_VIDEO_FORMAT_v216,+ SPA_VIDEO_FORMAT_NV12,+ SPA_VIDEO_FORMAT_NV21,+ SPA_VIDEO_FORMAT_GRAY8,+ SPA_VIDEO_FORMAT_GRAY16_BE,+ SPA_VIDEO_FORMAT_GRAY16_LE,+ SPA_VIDEO_FORMAT_v308,+ SPA_VIDEO_FORMAT_RGB16,+ SPA_VIDEO_FORMAT_BGR16,+ SPA_VIDEO_FORMAT_RGB15,+ SPA_VIDEO_FORMAT_BGR15,+ SPA_VIDEO_FORMAT_UYVP,+ SPA_VIDEO_FORMAT_A420,+ SPA_VIDEO_FORMAT_RGB8P,+ SPA_VIDEO_FORMAT_YUV9,+ SPA_VIDEO_FORMAT_YVU9,+ SPA_VIDEO_FORMAT_IYU1,+ SPA_VIDEO_FORMAT_ARGB64,+ SPA_VIDEO_FORMAT_AYUV64,+ SPA_VIDEO_FORMAT_r210,+ SPA_VIDEO_FORMAT_I420_10BE,+ SPA_VIDEO_FORMAT_I420_10LE,+ SPA_VIDEO_FORMAT_I422_10BE,+ SPA_VIDEO_FORMAT_I422_10LE,+ SPA_VIDEO_FORMAT_Y444_10BE,+ SPA_VIDEO_FORMAT_Y444_10LE,+ SPA_VIDEO_FORMAT_GBR,+ SPA_VIDEO_FORMAT_GBR_10BE,+ SPA_VIDEO_FORMAT_GBR_10LE,+ SPA_VIDEO_FORMAT_NV16,+ SPA_VIDEO_FORMAT_NV24,+ SPA_VIDEO_FORMAT_NV12_64Z32,+ SPA_VIDEO_FORMAT_A420_10BE,+ SPA_VIDEO_FORMAT_A420_10LE,+ SPA_VIDEO_FORMAT_A422_10BE,+ SPA_VIDEO_FORMAT_A422_10LE,+ SPA_VIDEO_FORMAT_A444_10BE,+ SPA_VIDEO_FORMAT_A444_10LE,+ SPA_VIDEO_FORMAT_NV61,+ SPA_VIDEO_FORMAT_P010_10BE,+ SPA_VIDEO_FORMAT_P010_10LE,+ SPA_VIDEO_FORMAT_IYU2,+ SPA_VIDEO_FORMAT_VYUY,+ SPA_VIDEO_FORMAT_GBRA,+ SPA_VIDEO_FORMAT_GBRA_10BE,+ SPA_VIDEO_FORMAT_GBRA_10LE,+ SPA_VIDEO_FORMAT_GBR_12BE,+ SPA_VIDEO_FORMAT_GBR_12LE,+ SPA_VIDEO_FORMAT_GBRA_12BE,+ SPA_VIDEO_FORMAT_GBRA_12LE,+ SPA_VIDEO_FORMAT_I420_12BE,+ SPA_VIDEO_FORMAT_I420_12LE,+ SPA_VIDEO_FORMAT_I422_12BE,+ SPA_VIDEO_FORMAT_I422_12LE,+ SPA_VIDEO_FORMAT_Y444_12BE,+ SPA_VIDEO_FORMAT_Y444_12LE,++ SPA_VIDEO_FORMAT_RGBA_F16,+ SPA_VIDEO_FORMAT_RGBA_F32,++ SPA_VIDEO_FORMAT_xRGB_210LE, /**< 32-bit x:R:G:B 2:10:10:10 little endian */+ SPA_VIDEO_FORMAT_xBGR_210LE, /**< 32-bit x:B:G:R 2:10:10:10 little endian */+ SPA_VIDEO_FORMAT_RGBx_102LE, /**< 32-bit R:G:B:x 10:10:10:2 little endian */+ SPA_VIDEO_FORMAT_BGRx_102LE, /**< 32-bit B:G:R:x 10:10:10:2 little endian */+ SPA_VIDEO_FORMAT_ARGB_210LE, /**< 32-bit A:R:G:B 2:10:10:10 little endian */+ SPA_VIDEO_FORMAT_ABGR_210LE, /**< 32-bit A:B:G:R 2:10:10:10 little endian */+ SPA_VIDEO_FORMAT_RGBA_102LE, /**< 32-bit R:G:B:A 10:10:10:2 little endian */+ SPA_VIDEO_FORMAT_BGRA_102LE, /**< 32-bit B:G:R:A 10:10:10:2 little endian */++ /* Aliases */+ SPA_VIDEO_FORMAT_DSP_F32 = SPA_VIDEO_FORMAT_RGBA_F32,+};++/**+ * Extra video flags+ */+enum spa_video_flags {+ SPA_VIDEO_FLAG_NONE = 0, /**< no flags */+ SPA_VIDEO_FLAG_VARIABLE_FPS = (1 << 0), /**< a variable fps is selected, fps_n and fps_d+ * denote the maximum fps of the video */+ SPA_VIDEO_FLAG_PREMULTIPLIED_ALPHA = (1 << 1), /**< Each color has been scaled by the alpha value. */+ SPA_VIDEO_FLAG_MODIFIER = (1 << 2), /**< use the format modifier */+ SPA_VIDEO_FLAG_MODIFIER_FIXATION_REQUIRED = (1 << 3), /**< format modifier was not fixated yet */+};++/**+ * The possible values of the #spa_video_interlace_mode describing the interlace+ * mode of the stream.+ */+enum spa_video_interlace_mode {+ SPA_VIDEO_INTERLACE_MODE_PROGRESSIVE = 0, /**< all frames are progressive */+ SPA_VIDEO_INTERLACE_MODE_INTERLEAVED, /**< 2 fields are interleaved in one video frame.+ * Extra buffer flags describe the field order. */+ SPA_VIDEO_INTERLACE_MODE_MIXED, /**< frames contains both interlaced and progressive+ * video, the buffer flags describe the frame and+ * fields. */+ SPA_VIDEO_INTERLACE_MODE_FIELDS, /**< 2 fields are stored in one buffer, use the+ * frame ID to get access to the required+ * field. For multiview (the 'views'+ * property > 1) the fields of view N can+ * be found at frame ID (N * 2) and (N *+ * 2) + 1. Each field has only half the+ * amount of lines as noted in the height+ * property. This mode requires multiple+ * spa_data to describe the fields. */+};++/**+ */+struct spa_video_info_raw {+ enum spa_video_format format; /**< the format */+ uint32_t flags; /**< extra video flags */+ uint64_t modifier; /**< format modifier+ * only used with DMA-BUF */+ struct spa_rectangle size; /**< the frame size of the video */+ struct spa_fraction framerate; /**< the framerate of the video, 0/1 means variable rate */+ struct spa_fraction max_framerate; /**< the maximum framerate of the video. This is only valid when+ \ref framerate is 0/1 */+ uint32_t views; /**< the number of views in this video */+ enum spa_video_interlace_mode interlace_mode; /**< the interlace mode */+ struct spa_fraction pixel_aspect_ratio; /**< the pixel aspect ratio */+ enum spa_video_multiview_mode multiview_mode; /**< multiview mode */+ enum spa_video_multiview_flags multiview_flags; /**< multiview flags */+ enum spa_video_chroma_site chroma_site; /**< the chroma siting */+ enum spa_video_color_range color_range; /**< the color range. This is the valid range for the samples.+ * It is used to convert the samples to Y'PbPr values. */+ enum spa_video_color_matrix color_matrix; /**< the color matrix. Used to convert between Y'PbPr and+ * non-linear RGB (R'G'B') */+ enum spa_video_transfer_function transfer_function; /**< the transfer function. used to convert between R'G'B' and RGB */+ enum spa_video_color_primaries color_primaries; /**< color primaries. used to convert between R'G'B' and CIE XYZ */+};++#define SPA_VIDEO_INFO_RAW_INIT(...) ((struct spa_video_info_raw) { __VA_ARGS__ })++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_VIDEO_RAW_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/builder.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/builder.hnew file mode 100644index 000000000..fdf9e9368--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/builder.h@@ -0,0 +1,681 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_POD_BUILDER_H+#define SPA_POD_BUILDER_H++#ifdef __cplusplus+extern "C" {+#endif++/** \defgroup spa_pod POD+ * Binary data serialization format+ */++/**+ * \addtogroup spa_pod+ * \{+ */++#include <stdarg.h>++#include <spa/utils/hook.h>+#include <spa/pod/iter.h>+#include <spa/pod/vararg.h>++struct spa_pod_builder_state {+ uint32_t offset;+#define SPA_POD_BUILDER_FLAG_BODY (1<<0)+#define SPA_POD_BUILDER_FLAG_FIRST (1<<1)+ uint32_t flags;+ struct spa_pod_frame *frame;+};++struct spa_pod_builder;++struct spa_pod_builder_callbacks {+#define SPA_VERSION_POD_BUILDER_CALLBACKS 0+ uint32_t version;++ int (*overflow) (void *data, uint32_t size);+};++struct spa_pod_builder {+ void *data;+ uint32_t size;+ uint32_t _padding;+ struct spa_pod_builder_state state;+ struct spa_callbacks callbacks;+};++#define SPA_POD_BUILDER_INIT(buffer,size) ((struct spa_pod_builder){ (buffer), (size), 0, {}, {} })++static inline void+spa_pod_builder_get_state(struct spa_pod_builder *builder, struct spa_pod_builder_state *state)+{+ *state = builder->state;+}++static inline void+spa_pod_builder_set_callbacks(struct spa_pod_builder *builder,+ const struct spa_pod_builder_callbacks *callbacks, void *data)+{+ builder->callbacks = SPA_CALLBACKS_INIT(callbacks, data);+}++static inline void+spa_pod_builder_reset(struct spa_pod_builder *builder, struct spa_pod_builder_state *state)+{+ struct spa_pod_frame *f;+ uint32_t size = builder->state.offset - state->offset;+ builder->state = *state;+ for (f = builder->state.frame; f ; f = f->parent)+ f->pod.size -= size;+}++static inline void spa_pod_builder_init(struct spa_pod_builder *builder, void *data, uint32_t size)+{+ *builder = SPA_POD_BUILDER_INIT(data, size);+}++static inline struct spa_pod *+spa_pod_builder_deref(struct spa_pod_builder *builder, uint32_t offset)+{+ uint32_t size = builder->size;+ if (offset + 8 <= size) {+ struct spa_pod *pod = SPA_PTROFF(builder->data, offset, struct spa_pod);+ if (offset + SPA_POD_SIZE(pod) <= size)+ return pod;+ }+ return NULL;+}++static inline struct spa_pod *+spa_pod_builder_frame(struct spa_pod_builder *builder, struct spa_pod_frame *frame)+{+ if (frame->offset + SPA_POD_SIZE(&frame->pod) <= builder->size)+ return SPA_PTROFF(builder->data, frame->offset, struct spa_pod);+ return NULL;+}++static inline void+spa_pod_builder_push(struct spa_pod_builder *builder,+ struct spa_pod_frame *frame,+ const struct spa_pod *pod,+ uint32_t offset)+{+ frame->pod = *pod;+ frame->offset = offset;+ frame->parent = builder->state.frame;+ frame->flags = builder->state.flags;+ builder->state.frame = frame;++ if (frame->pod.type == SPA_TYPE_Array || frame->pod.type == SPA_TYPE_Choice)+ builder->state.flags = SPA_POD_BUILDER_FLAG_FIRST | SPA_POD_BUILDER_FLAG_BODY;+}++static inline int spa_pod_builder_raw(struct spa_pod_builder *builder, const void *data, uint32_t size)+{+ int res = 0;+ struct spa_pod_frame *f;+ uint32_t offset = builder->state.offset;++ if (offset + size > builder->size) {+ res = -ENOSPC;+ if (offset <= builder->size)+ spa_callbacks_call_res(&builder->callbacks,+ struct spa_pod_builder_callbacks, res,+ overflow, 0, offset + size);+ }+ if (res == 0 && data)+ memcpy(SPA_PTROFF(builder->data, offset, void), data, size);++ builder->state.offset += size;++ for (f = builder->state.frame; f ; f = f->parent)+ f->pod.size += size;++ return res;+}++static inline int spa_pod_builder_pad(struct spa_pod_builder *builder, uint32_t size)+{+ uint64_t zeroes = 0;+ size = SPA_ROUND_UP_N(size, 8) - size;+ return size ? spa_pod_builder_raw(builder, &zeroes, size) : 0;+}++static inline int+spa_pod_builder_raw_padded(struct spa_pod_builder *builder, const void *data, uint32_t size)+{+ int r, res = spa_pod_builder_raw(builder, data, size);+ if ((r = spa_pod_builder_pad(builder, size)) < 0)+ res = r;+ return res;+}++static inline void *spa_pod_builder_pop(struct spa_pod_builder *builder, struct spa_pod_frame *frame)+{+ struct spa_pod *pod;++ if (SPA_FLAG_IS_SET(builder->state.flags, SPA_POD_BUILDER_FLAG_FIRST)) {+ const struct spa_pod p = { 0, SPA_TYPE_None };+ spa_pod_builder_raw(builder, &p, sizeof(p));+ }+ if ((pod = (struct spa_pod*)spa_pod_builder_frame(builder, frame)) != NULL)+ *pod = frame->pod;++ builder->state.frame = frame->parent;+ builder->state.flags = frame->flags;+ spa_pod_builder_pad(builder, builder->state.offset);+ return pod;+}++static inline int+spa_pod_builder_primitive(struct spa_pod_builder *builder, const struct spa_pod *p)+{+ const void *data;+ uint32_t size;+ int r, res;++ if (builder->state.flags == SPA_POD_BUILDER_FLAG_BODY) {+ data = SPA_POD_BODY_CONST(p);+ size = SPA_POD_BODY_SIZE(p);+ } else {+ data = p;+ size = SPA_POD_SIZE(p);+ SPA_FLAG_CLEAR(builder->state.flags, SPA_POD_BUILDER_FLAG_FIRST);+ }+ res = spa_pod_builder_raw(builder, data, size);+ if (builder->state.flags != SPA_POD_BUILDER_FLAG_BODY)+ if ((r = spa_pod_builder_pad(builder, size)) < 0)+ res = r;+ return res;+}++#define SPA_POD_INIT(size,type) ((struct spa_pod) { (size), (type) })++#define SPA_POD_INIT_None() SPA_POD_INIT(0, SPA_TYPE_None)++static inline int spa_pod_builder_none(struct spa_pod_builder *builder)+{+ const struct spa_pod p = SPA_POD_INIT_None();+ return spa_pod_builder_primitive(builder, &p);+}++static inline int spa_pod_builder_child(struct spa_pod_builder *builder, uint32_t size, uint32_t type)+{+ const struct spa_pod p = SPA_POD_INIT(size,type);+ SPA_FLAG_CLEAR(builder->state.flags, SPA_POD_BUILDER_FLAG_FIRST);+ return spa_pod_builder_raw(builder, &p, sizeof(p));+}++#define SPA_POD_INIT_Bool(val) ((struct spa_pod_bool){ { sizeof(uint32_t), SPA_TYPE_Bool }, (val) ? 1 : 0, 0 })++static inline int spa_pod_builder_bool(struct spa_pod_builder *builder, bool val)+{+ const struct spa_pod_bool p = SPA_POD_INIT_Bool(val);+ return spa_pod_builder_primitive(builder, &p.pod);+}++#define SPA_POD_INIT_Id(val) ((struct spa_pod_id){ { sizeof(uint32_t), SPA_TYPE_Id }, (val), 0 })++static inline int spa_pod_builder_id(struct spa_pod_builder *builder, uint32_t val)+{+ const struct spa_pod_id p = SPA_POD_INIT_Id(val);+ return spa_pod_builder_primitive(builder, &p.pod);+}++#define SPA_POD_INIT_Int(val) ((struct spa_pod_int){ { sizeof(int32_t), SPA_TYPE_Int }, (val), 0 })++static inline int spa_pod_builder_int(struct spa_pod_builder *builder, int32_t val)+{+ const struct spa_pod_int p = SPA_POD_INIT_Int(val);+ return spa_pod_builder_primitive(builder, &p.pod);+}++#define SPA_POD_INIT_Long(val) ((struct spa_pod_long){ { sizeof(int64_t), SPA_TYPE_Long }, (val) })++static inline int spa_pod_builder_long(struct spa_pod_builder *builder, int64_t val)+{+ const struct spa_pod_long p = SPA_POD_INIT_Long(val);+ return spa_pod_builder_primitive(builder, &p.pod);+}++#define SPA_POD_INIT_Float(val) ((struct spa_pod_float){ { sizeof(float), SPA_TYPE_Float }, (val), 0 })++static inline int spa_pod_builder_float(struct spa_pod_builder *builder, float val)+{+ const struct spa_pod_float p = SPA_POD_INIT_Float(val);+ return spa_pod_builder_primitive(builder, &p.pod);+}++#define SPA_POD_INIT_Double(val) ((struct spa_pod_double){ { sizeof(double), SPA_TYPE_Double }, (val) })++static inline int spa_pod_builder_double(struct spa_pod_builder *builder, double val)+{+ const struct spa_pod_double p = SPA_POD_INIT_Double(val);+ return spa_pod_builder_primitive(builder, &p.pod);+}++#define SPA_POD_INIT_String(len) ((struct spa_pod_string){ { (len), SPA_TYPE_String } })++static inline int+spa_pod_builder_write_string(struct spa_pod_builder *builder, const char *str, uint32_t len)+{+ int r, res;+ res = spa_pod_builder_raw(builder, str, len);+ if ((r = spa_pod_builder_raw(builder, "", 1)) < 0)+ res = r;+ if ((r = spa_pod_builder_pad(builder, builder->state.offset)) < 0)+ res = r;+ return res;+}++static inline int+spa_pod_builder_string_len(struct spa_pod_builder *builder, const char *str, uint32_t len)+{+ const struct spa_pod_string p = SPA_POD_INIT_String(len+1);+ int r, res = spa_pod_builder_raw(builder, &p, sizeof(p));+ if ((r = spa_pod_builder_write_string(builder, str, len)) < 0)+ res = r;+ return res;+}++static inline int spa_pod_builder_string(struct spa_pod_builder *builder, const char *str)+{+ uint32_t len = str ? strlen(str) : 0;+ return spa_pod_builder_string_len(builder, str ? str : "", len);+}++#define SPA_POD_INIT_Bytes(len) ((struct spa_pod_bytes){ { (len), SPA_TYPE_Bytes } })++static inline int+spa_pod_builder_bytes(struct spa_pod_builder *builder, const void *bytes, uint32_t len)+{+ const struct spa_pod_bytes p = SPA_POD_INIT_Bytes(len);+ int r, res = spa_pod_builder_raw(builder, &p, sizeof(p));+ if ((r = spa_pod_builder_raw_padded(builder, bytes, len)) < 0)+ res = r;+ return res;+}+static inline void *+spa_pod_builder_reserve_bytes(struct spa_pod_builder *builder, uint32_t len)+{+ uint32_t offset = builder->state.offset;+ if (spa_pod_builder_bytes(builder, NULL, len) < 0)+ return NULL;+ return SPA_POD_BODY(spa_pod_builder_deref(builder, offset));+}++#define SPA_POD_INIT_Pointer(type,value) ((struct spa_pod_pointer){ { sizeof(struct spa_pod_pointer_body), SPA_TYPE_Pointer }, { (type), 0, (value) } })++static inline int+spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, const void *val)+{+ const struct spa_pod_pointer p = SPA_POD_INIT_Pointer(type, val);+ return spa_pod_builder_primitive(builder, &p.pod);+}++#define SPA_POD_INIT_Fd(fd) ((struct spa_pod_fd){ { sizeof(int64_t), SPA_TYPE_Fd }, (fd) })++static inline int spa_pod_builder_fd(struct spa_pod_builder *builder, int64_t fd)+{+ const struct spa_pod_fd p = SPA_POD_INIT_Fd(fd);+ return spa_pod_builder_primitive(builder, &p.pod);+}++#define SPA_POD_INIT_Rectangle(val) ((struct spa_pod_rectangle){ { sizeof(struct spa_rectangle), SPA_TYPE_Rectangle }, (val) })++static inline int+spa_pod_builder_rectangle(struct spa_pod_builder *builder, uint32_t width, uint32_t height)+{+ const struct spa_pod_rectangle p = SPA_POD_INIT_Rectangle(SPA_RECTANGLE(width, height));+ return spa_pod_builder_primitive(builder, &p.pod);+}++#define SPA_POD_INIT_Fraction(val) ((struct spa_pod_fraction){ { sizeof(struct spa_fraction), SPA_TYPE_Fraction }, (val) })++static inline int+spa_pod_builder_fraction(struct spa_pod_builder *builder, uint32_t num, uint32_t denom)+{+ const struct spa_pod_fraction p = SPA_POD_INIT_Fraction(SPA_FRACTION(num, denom));+ return spa_pod_builder_primitive(builder, &p.pod);+}++static inline int+spa_pod_builder_push_array(struct spa_pod_builder *builder, struct spa_pod_frame *frame)+{+ const struct spa_pod_array p =+ { {sizeof(struct spa_pod_array_body) - sizeof(struct spa_pod), SPA_TYPE_Array},+ {{0, 0}} };+ uint32_t offset = builder->state.offset;+ int res = spa_pod_builder_raw(builder, &p, sizeof(p) - sizeof(struct spa_pod));+ spa_pod_builder_push(builder, frame, &p.pod, offset);+ return res;+}++static inline int+spa_pod_builder_array(struct spa_pod_builder *builder,+ uint32_t child_size, uint32_t child_type, uint32_t n_elems, const void *elems)+{+ const struct spa_pod_array p = {+ {(uint32_t)(sizeof(struct spa_pod_array_body) + n_elems * child_size), SPA_TYPE_Array},+ {{child_size, child_type}}+ };+ int r, res = spa_pod_builder_raw(builder, &p, sizeof(p));+ if ((r = spa_pod_builder_raw_padded(builder, elems, child_size * n_elems)) < 0)+ res = r;+ return res;+}++#define SPA_POD_INIT_CHOICE_BODY(type, flags, child_size, child_type) \+ ((struct spa_pod_choice_body) { (type), (flags), { (child_size), (child_type) }})++#define SPA_POD_INIT_Choice(type, ctype, child_type, n_vals, ...) \+ ((struct { struct spa_pod_choice choice; ctype vals[(n_vals)];}) \+ { { { (n_vals) * sizeof(ctype) + sizeof(struct spa_pod_choice_body), SPA_TYPE_Choice }, \+ { (type), 0, { sizeof(ctype), (child_type) } } }, { __VA_ARGS__ } })++static inline int+spa_pod_builder_push_choice(struct spa_pod_builder *builder, struct spa_pod_frame *frame,+ uint32_t type, uint32_t flags)+{+ const struct spa_pod_choice p =+ { {sizeof(struct spa_pod_choice_body) - sizeof(struct spa_pod), SPA_TYPE_Choice},+ { type, flags, {0, 0}} };+ uint32_t offset = builder->state.offset;+ int res = spa_pod_builder_raw(builder, &p, sizeof(p) - sizeof(struct spa_pod));+ spa_pod_builder_push(builder, frame, &p.pod, offset);+ return res;+}++#define SPA_POD_INIT_Struct(size) ((struct spa_pod_struct){ { (size), SPA_TYPE_Struct } })++static inline int+spa_pod_builder_push_struct(struct spa_pod_builder *builder, struct spa_pod_frame *frame)+{+ const struct spa_pod_struct p = SPA_POD_INIT_Struct(0);+ uint32_t offset = builder->state.offset;+ int res = spa_pod_builder_raw(builder, &p, sizeof(p));+ spa_pod_builder_push(builder, frame, &p.pod, offset);+ return res;+}++#define SPA_POD_INIT_Object(size,type,id,...) ((struct spa_pod_object){ { (size), SPA_TYPE_Object }, { (type), (id) }, ##__VA_ARGS__ })++static inline int+spa_pod_builder_push_object(struct spa_pod_builder *builder, struct spa_pod_frame *frame,+ uint32_t type, uint32_t id)+{+ const struct spa_pod_object p =+ SPA_POD_INIT_Object(sizeof(struct spa_pod_object_body), type, id);+ uint32_t offset = builder->state.offset;+ int res = spa_pod_builder_raw(builder, &p, sizeof(p));+ spa_pod_builder_push(builder, frame, &p.pod, offset);+ return res;+}++#define SPA_POD_INIT_Prop(key,flags,size,type) \+ ((struct spa_pod_prop){ (key), (flags), { (size), (type) } })++static inline int+spa_pod_builder_prop(struct spa_pod_builder *builder, uint32_t key, uint32_t flags)+{+ const struct { uint32_t key; uint32_t flags; } p = { key, flags };+ return spa_pod_builder_raw(builder, &p, sizeof(p));+}++#define SPA_POD_INIT_Sequence(size,unit) \+ ((struct spa_pod_sequence){ { (size), SPA_TYPE_Sequence}, {(unit), 0 } })++static inline int+spa_pod_builder_push_sequence(struct spa_pod_builder *builder, struct spa_pod_frame *frame, uint32_t unit)+{+ const struct spa_pod_sequence p =+ SPA_POD_INIT_Sequence(sizeof(struct spa_pod_sequence_body), unit);+ uint32_t offset = builder->state.offset;+ int res = spa_pod_builder_raw(builder, &p, sizeof(p));+ spa_pod_builder_push(builder, frame, &p.pod, offset);+ return res;+}++static inline int+spa_pod_builder_control(struct spa_pod_builder *builder, uint32_t offset, uint32_t type)+{+ const struct { uint32_t offset; uint32_t type; } p = { offset, type };+ return spa_pod_builder_raw(builder, &p, sizeof(p));+}++static inline uint32_t spa_choice_from_id(char id)+{+ switch (id) {+ case 'r':+ return SPA_CHOICE_Range;+ case 's':+ return SPA_CHOICE_Step;+ case 'e':+ return SPA_CHOICE_Enum;+ case 'f':+ return SPA_CHOICE_Flags;+ case 'n':+ default:+ return SPA_CHOICE_None;+ }+}++#define SPA_POD_BUILDER_COLLECT(builder,type,args) \+do { \+ switch (type) { \+ case 'b': \+ spa_pod_builder_bool(builder, !!va_arg(args, int)); \+ break; \+ case 'I': \+ spa_pod_builder_id(builder, va_arg(args, uint32_t)); \+ break; \+ case 'i': \+ spa_pod_builder_int(builder, va_arg(args, int)); \+ break; \+ case 'l': \+ spa_pod_builder_long(builder, va_arg(args, int64_t)); \+ break; \+ case 'f': \+ spa_pod_builder_float(builder, va_arg(args, double)); \+ break; \+ case 'd': \+ spa_pod_builder_double(builder, va_arg(args, double)); \+ break; \+ case 's': \+ { \+ char *strval = va_arg(args, char *); \+ if (strval != NULL) { \+ size_t len = strlen(strval); \+ spa_pod_builder_string_len(builder, strval, len); \+ } \+ else \+ spa_pod_builder_none(builder); \+ break; \+ } \+ case 'S': \+ { \+ char *strval = va_arg(args, char *); \+ size_t len = va_arg(args, int); \+ spa_pod_builder_string_len(builder, strval, len); \+ break; \+ } \+ case 'y': \+ { \+ void *ptr = va_arg(args, void *); \+ int len = va_arg(args, int); \+ spa_pod_builder_bytes(builder, ptr, len); \+ break; \+ } \+ case 'R': \+ { \+ struct spa_rectangle *rectval = \+ va_arg(args, struct spa_rectangle *); \+ spa_pod_builder_rectangle(builder, \+ rectval->width, rectval->height); \+ break; \+ } \+ case 'F': \+ { \+ struct spa_fraction *fracval = \+ va_arg(args, struct spa_fraction *); \+ spa_pod_builder_fraction(builder, fracval->num, fracval->denom);\+ break; \+ } \+ case 'a': \+ { \+ int child_size = va_arg(args, int); \+ int child_type = va_arg(args, int); \+ int n_elems = va_arg(args, int); \+ void *elems = va_arg(args, void *); \+ spa_pod_builder_array(builder, child_size, \+ child_type, n_elems, elems); \+ break; \+ } \+ case 'p': \+ { \+ int t = va_arg(args, uint32_t); \+ spa_pod_builder_pointer(builder, t, va_arg(args, void *)); \+ break; \+ } \+ case 'h': \+ spa_pod_builder_fd(builder, va_arg(args, int)); \+ break; \+ case 'P': \+ case 'O': \+ case 'T': \+ case 'V': \+ { \+ struct spa_pod *pod = va_arg(args, struct spa_pod *); \+ if (pod == NULL) \+ spa_pod_builder_none(builder); \+ else \+ spa_pod_builder_primitive(builder, pod); \+ break; \+ } \+ } \+} while(false)++static inline int+spa_pod_builder_addv(struct spa_pod_builder *builder, va_list args)+{+ int res = 0;+ struct spa_pod_frame *frame = builder->state.frame;+ uint32_t ftype = frame ? frame->pod.type : (uint32_t)SPA_TYPE_None;++ do {+ const char *format;+ int n_values = 1;+ struct spa_pod_frame f;+ bool choice;++ switch (ftype) {+ case SPA_TYPE_Object:+ {+ uint32_t key = va_arg(args, uint32_t);+ if (key == 0)+ goto exit;+ spa_pod_builder_prop(builder, key, 0);+ break;+ }+ case SPA_TYPE_Sequence:+ {+ uint32_t offset = va_arg(args, uint32_t);+ uint32_t type = va_arg(args, uint32_t);+ if (type == 0)+ goto exit;+ spa_pod_builder_control(builder, offset, type);+ SPA_FALLTHROUGH+ }+ default:+ break;+ }+ if ((format = va_arg(args, const char *)) == NULL)+ break;++ choice = *format == '?';+ if (choice) {+ uint32_t type = spa_choice_from_id(*++format);+ if (*format != '\0')+ format++;++ spa_pod_builder_push_choice(builder, &f, type, 0);++ n_values = va_arg(args, int);+ }+ while (n_values-- > 0)+ SPA_POD_BUILDER_COLLECT(builder, *format, args);++ if (choice)+ spa_pod_builder_pop(builder, &f);+ } while (true);++ exit:+ return res;+}++static inline int spa_pod_builder_add(struct spa_pod_builder *builder, ...)+{+ int res;+ va_list args;++ va_start(args, builder);+ res = spa_pod_builder_addv(builder, args);+ va_end(args);++ return res;+}++#define spa_pod_builder_add_object(b,type,id,...) \+({ \+ struct spa_pod_builder *_b = (b); \+ struct spa_pod_frame _f; \+ spa_pod_builder_push_object(_b, &_f, type, id); \+ spa_pod_builder_add(_b, ##__VA_ARGS__, 0); \+ spa_pod_builder_pop(_b, &_f); \+})++#define spa_pod_builder_add_struct(b,...) \+({ \+ struct spa_pod_builder *_b = (b); \+ struct spa_pod_frame _f; \+ spa_pod_builder_push_struct(_b, &_f); \+ spa_pod_builder_add(_b, ##__VA_ARGS__, NULL); \+ spa_pod_builder_pop(_b, &_f); \+})++#define spa_pod_builder_add_sequence(b,unit,...) \+({ \+ struct spa_pod_builder *_b = (b); \+ struct spa_pod_frame _f; \+ spa_pod_builder_push_sequence(_b, &_f, unit); \+ spa_pod_builder_add(_b, ##__VA_ARGS__, 0, 0); \+ spa_pod_builder_pop(_b, &_f); \+})++/** Copy a pod structure */+static inline struct spa_pod *+spa_pod_copy(const struct spa_pod *pod)+{+ size_t size;+ struct spa_pod *c;++ size = SPA_POD_SIZE(pod);+ if ((c = (struct spa_pod *) malloc(size)) == NULL)+ return NULL;+ return (struct spa_pod *) memcpy(c, pod, size);+}++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_POD_BUILDER_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/command.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/command.hnew file mode 100644index 000000000..330f56edc--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/command.h@@ -0,0 +1,49 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_COMMAND_H+#define SPA_COMMAND_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>+#include <spa/pod/pod.h>++/**+ * \addtogroup spa_pod+ * \{+ */++struct spa_command_body {+ struct spa_pod_object_body body;+};++struct spa_command {+ struct spa_pod pod;+ struct spa_command_body body;+};++#define SPA_COMMAND_TYPE(cmd) ((cmd)->body.body.type)+#define SPA_COMMAND_ID(cmd,type) (SPA_COMMAND_TYPE(cmd) == (type) ? \+ (cmd)->body.body.id : SPA_ID_INVALID)++#define SPA_COMMAND_INIT_FULL(t,size,type,id,...) ((t) \+ { { (size), SPA_TYPE_Object }, \+ { { (type), (id) }, ##__VA_ARGS__ } })++#define SPA_COMMAND_INIT(type,id) \+ SPA_COMMAND_INIT_FULL(struct spa_command, \+ sizeof(struct spa_command_body), type, id)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_COMMAND_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/compare.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/compare.hnew file mode 100644index 000000000..88b01fbfb--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/compare.h@@ -0,0 +1,170 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_POD_COMPARE_H+#define SPA_POD_COMPARE_H++#ifdef __cplusplus+extern "C" {+#endif++#include <stdarg.h>+#include <errno.h>+#include <stdint.h>+#include <stddef.h>+#include <stdio.h>+#include <string.h>++#include <spa/param/props.h>+#include <spa/pod/iter.h>+#include <spa/pod/builder.h>++/**+ * \addtogroup spa_pod+ * \{+ */++static inline int spa_pod_compare_value(uint32_t type, const void *r1, const void *r2, uint32_t size)+{+ switch (type) {+ case SPA_TYPE_None:+ return 0;+ case SPA_TYPE_Bool:+ case SPA_TYPE_Id:+ return *(uint32_t *) r1 == *(uint32_t *) r2 ? 0 : 1;+ case SPA_TYPE_Int:+ return *(int32_t *) r1 - *(int32_t *) r2;+ case SPA_TYPE_Long:+ return *(int64_t *) r1 - *(int64_t *) r2;+ case SPA_TYPE_Float:+ return *(float *) r1 - *(float *) r2;+ case SPA_TYPE_Double:+ return *(double *) r1 - *(double *) r2;+ case SPA_TYPE_String:+ return strcmp((char *)r1, (char *)r2);+ case SPA_TYPE_Bytes:+ return memcmp((char *)r1, (char *)r2, size);+ case SPA_TYPE_Rectangle:+ {+ const struct spa_rectangle *rec1 = (struct spa_rectangle *) r1,+ *rec2 = (struct spa_rectangle *) r2;+ if (rec1->width == rec2->width && rec1->height == rec2->height)+ return 0;+ else if (rec1->width < rec2->width || rec1->height < rec2->height)+ return -1;+ else+ return 1;+ }+ case SPA_TYPE_Fraction:+ {+ const struct spa_fraction *f1 = (struct spa_fraction *) r1,+ *f2 = (struct spa_fraction *) r2;+ int64_t n1, n2;+ n1 = ((int64_t) f1->num) * f2->denom;+ n2 = ((int64_t) f2->num) * f1->denom;+ if (n1 < n2)+ return -1;+ else if (n1 > n2)+ return 1;+ else+ return 0;+ }+ default:+ break;+ }+ return 0;+}++static inline int spa_pod_compare(const struct spa_pod *pod1,+ const struct spa_pod *pod2)+{+ int res = 0;+ uint32_t n_vals1, n_vals2;+ uint32_t choice1, choice2;++ spa_return_val_if_fail(pod1 != NULL, -EINVAL);+ spa_return_val_if_fail(pod2 != NULL, -EINVAL);++ pod1 = spa_pod_get_values(pod1, &n_vals1, &choice1);+ pod2 = spa_pod_get_values(pod2, &n_vals2, &choice2);++ if (n_vals1 != n_vals2)+ return -EINVAL;++ if (SPA_POD_TYPE(pod1) != SPA_POD_TYPE(pod2))+ return -EINVAL;++ switch (SPA_POD_TYPE(pod1)) {+ case SPA_TYPE_Struct:+ {+ const struct spa_pod *p1, *p2;+ size_t p1s, p2s;++ p1 = (const struct spa_pod*)SPA_POD_BODY_CONST(pod1);+ p1s = SPA_POD_BODY_SIZE(pod1);+ p2 = (const struct spa_pod*)SPA_POD_BODY_CONST(pod2);+ p2s = SPA_POD_BODY_SIZE(pod2);++ while (true) {+ if (!spa_pod_is_inside(pod1, p1s, p1) ||+ !spa_pod_is_inside(pod2, p2s, p2))+ return -EINVAL;++ if ((res = spa_pod_compare(p1, p2)) != 0)+ return res;++ p1 = (const struct spa_pod*)spa_pod_next(p1);+ p2 = (const struct spa_pod*)spa_pod_next(p2);+ }+ break;+ }+ case SPA_TYPE_Object:+ {+ const struct spa_pod_prop *p1, *p2;+ const struct spa_pod_object *o1, *o2;++ o1 = (const struct spa_pod_object*)pod1;+ o2 = (const struct spa_pod_object*)pod2;++ p2 = NULL;+ SPA_POD_OBJECT_FOREACH(o1, p1) {+ if ((p2 = spa_pod_object_find_prop(o2, p2, p1->key)) == NULL)+ return 1;+ if ((res = spa_pod_compare(&p1->value, &p2->value)) != 0)+ return res;+ }+ p1 = NULL;+ SPA_POD_OBJECT_FOREACH(o2, p2) {+ if ((p1 = spa_pod_object_find_prop(o1, p1, p2->key)) == NULL)+ return -1;+ }+ break;+ }+ case SPA_TYPE_Array:+ {+ if (SPA_POD_BODY_SIZE(pod1) != SPA_POD_BODY_SIZE(pod2))+ return -EINVAL;+ res = memcmp(SPA_POD_BODY(pod1), SPA_POD_BODY(pod2), SPA_POD_BODY_SIZE(pod2));+ break;+ }+ default:+ if (SPA_POD_BODY_SIZE(pod1) != SPA_POD_BODY_SIZE(pod2))+ return -EINVAL;+ res = spa_pod_compare_value(SPA_POD_TYPE(pod1),+ SPA_POD_BODY(pod1), SPA_POD_BODY(pod2),+ SPA_POD_BODY_SIZE(pod1));+ break;+ }+ return res;+}++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endifdiff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/event.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/event.hnew file mode 100644index 000000000..b221bc73d--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/event.h@@ -0,0 +1,48 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_EVENT_H+#define SPA_EVENT_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/pod/pod.h>++/**+ * \addtogroup spa_pod+ * \{+ */++struct spa_event_body {+ struct spa_pod_object_body body;+};++struct spa_event {+ struct spa_pod pod;+ struct spa_event_body body;+};++#define SPA_EVENT_TYPE(ev) ((ev)->body.body.type)+#define SPA_EVENT_ID(ev,type) (SPA_EVENT_TYPE(ev) == (type) ? \+ (ev)->body.body.id : SPA_ID_INVALID)++#define SPA_EVENT_INIT_FULL(t,size,type,id,...) ((t) \+ { { (size), SPA_TYPE_OBJECT }, \+ { { (type), (id) }, ##__VA_ARGS__ } }) \++#define SPA_EVENT_INIT(type,id) \+ SPA_EVENT_INIT_FULL(struct spa_event, \+ sizeof(struct spa_event_body), type, id)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_EVENT_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/filter.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/filter.hnew file mode 100644index 000000000..3a682e1ac--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/filter.h@@ -0,0 +1,461 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_POD_FILTER_H+#define SPA_POD_FILTER_H++#ifdef __cplusplus+extern "C" {+#endif++#include <errno.h>+#include <stdint.h>+#include <stddef.h>+#include <stdio.h>+#include <string.h>++#include <spa/param/props.h>+#include <spa/pod/iter.h>+#include <spa/pod/builder.h>+#include <spa/pod/compare.h>++/**+ * \addtogroup spa_pod+ * \{+ */++static inline int spa_pod_choice_fix_default(struct spa_pod_choice *choice)+{+ void *val, *alt;+ int i, nvals;+ uint32_t type, size;++ nvals = SPA_POD_CHOICE_N_VALUES(choice);+ type = SPA_POD_CHOICE_VALUE_TYPE(choice);+ size = SPA_POD_CHOICE_VALUE_SIZE(choice);+ alt = val = SPA_POD_CHOICE_VALUES(choice);++ switch (choice->body.type) {+ case SPA_CHOICE_None:+ break;+ case SPA_CHOICE_Range:+ case SPA_CHOICE_Step:+ if (nvals > 1) {+ alt = SPA_PTROFF(alt, size, void);+ if (spa_pod_compare_value(type, val, alt, size) < 0)+ memcpy(val, alt, size);+ }+ if (nvals > 2) {+ alt = SPA_PTROFF(alt, size, void);+ if (spa_pod_compare_value(type, val, alt, size) > 0)+ memcpy(val, alt, size);+ }+ break;+ case SPA_CHOICE_Flags:+ case SPA_CHOICE_Enum:+ {+ void *best = NULL;++ for (i = 1; i < nvals; i++) {+ alt = SPA_PTROFF(alt, size, void);+ if (spa_pod_compare_value(type, val, alt, size) == 0) {+ best = alt;+ break;+ }+ if (best == NULL)+ best = alt;+ }+ if (best)+ memcpy(val, best, size);++ if (nvals <= 1)+ choice->body.type = SPA_CHOICE_None;+ break;+ }+ }+ return 0;+}++static inline int spa_pod_filter_flags_value(struct spa_pod_builder *b,+ uint32_t type, const void *r1, const void *r2, uint32_t size SPA_UNUSED)+{+ switch (type) {+ case SPA_TYPE_Int:+ {+ int32_t val = (*(int32_t *) r1) & (*(int32_t *) r2);+ if (val == 0)+ return 0;+ spa_pod_builder_int(b, val);+ break;+ }+ case SPA_TYPE_Long:+ {+ int64_t val = (*(int64_t *) r1) & (*(int64_t *) r2);+ if (val == 0)+ return 0;+ spa_pod_builder_long(b, val);+ break;+ }+ default:+ return -ENOTSUP;+ }+ return 1;+}++static inline int spa_pod_filter_is_step_of(uint32_t type, const void *r1,+ const void *r2, uint32_t size SPA_UNUSED)+{+ switch (type) {+ case SPA_TYPE_Int:+ return *(int32_t *) r1 % *(int32_t *) r2 == 0;+ case SPA_TYPE_Long:+ return *(int64_t *) r1 % *(int64_t *) r2 == 0;+ case SPA_TYPE_Rectangle:+ {+ const struct spa_rectangle *rec1 = (struct spa_rectangle *) r1,+ *rec2 = (struct spa_rectangle *) r2;++ return (rec1->width % rec2->width == 0 &&+ rec1->height % rec2->height == 0);+ }+ default:+ return -ENOTSUP;+ }+ return 0;+}++static inline int+spa_pod_filter_prop(struct spa_pod_builder *b,+ const struct spa_pod_prop *p1,+ const struct spa_pod_prop *p2)+{+ const struct spa_pod *v1, *v2;+ struct spa_pod_choice *nc;+ uint32_t j, k, nalt1, nalt2;+ void *alt1, *alt2, *a1, *a2;+ uint32_t type, size, p1c, p2c;+ struct spa_pod_frame f;++ v1 = spa_pod_get_values(&p1->value, &nalt1, &p1c);+ alt1 = SPA_POD_BODY(v1);+ v2 = spa_pod_get_values(&p2->value, &nalt2, &p2c);+ alt2 = SPA_POD_BODY(v2);++ type = v1->type;+ size = v1->size;++ /* incompatible property types */+ if (type != v2->type || size != v2->size || p1->key != p2->key)+ return -EINVAL;++ if (p1c == SPA_CHOICE_None || p1c == SPA_CHOICE_Flags) {+ nalt1 = 1;+ } else {+ alt1 = SPA_PTROFF(alt1, size, void);+ nalt1--;+ }++ if (p2c == SPA_CHOICE_None || p2c == SPA_CHOICE_Flags) {+ nalt2 = 1;+ } else {+ alt2 = SPA_PTROFF(alt2, size, void);+ nalt2--;+ }++ /* start with copying the property */+ spa_pod_builder_prop(b, p1->key, p1->flags & p2->flags);+ spa_pod_builder_push_choice(b, &f, 0, 0);+ nc = (struct spa_pod_choice*)spa_pod_builder_frame(b, &f);++ /* default value */+ spa_pod_builder_primitive(b, v1);++ if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_None) ||+ (p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Enum) ||+ (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_None) ||+ (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Enum)) {+ int n_copied = 0;+ /* copy all equal values but don't copy the default value again */+ for (j = 0, a1 = alt1; j < nalt1; j++, a1 = SPA_PTROFF(a1, size, void)) {+ for (k = 0, a2 = alt2; k < nalt2; k++, a2 = SPA_PTROFF(a2,size,void)) {+ if (spa_pod_compare_value(type, a1, a2, size) == 0) {+ if (p1c == SPA_CHOICE_Enum || j > 0)+ spa_pod_builder_raw(b, a1, size);+ n_copied++;+ }+ }+ }+ if (n_copied == 0)+ return -EINVAL;+ nc->body.type = SPA_CHOICE_Enum;+ }++ if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Range) ||+ (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Range)) {+ int n_copied = 0;+ /* copy all values inside the range */+ for (j = 0, a1 = alt1, a2 = alt2; j < nalt1; j++, a1 = SPA_PTROFF(a1,size,void)) {+ if (spa_pod_compare_value(type, a1, a2, size) < 0)+ continue;+ if (spa_pod_compare_value(type, a1, SPA_PTROFF(a2,size,void), size) > 0)+ continue;+ spa_pod_builder_raw(b, a1, size);+ n_copied++;+ }+ if (n_copied == 0)+ return -EINVAL;+ nc->body.type = SPA_CHOICE_Enum;+ }++ if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Step) ||+ (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Step)) {+ int n_copied = 0;+ for (j = 0, a1 = alt1, a2 = alt2; j < nalt1; j++, a1 = SPA_PTROFF(a1,size,void)) {+ int res;+ if (spa_pod_compare_value(type, a1, a2, size) < 0)+ continue;+ if (spa_pod_compare_value(type, a1, SPA_PTROFF(a2,size,void), size) > 0)+ continue;++ res = spa_pod_filter_is_step_of(type, a1, SPA_PTROFF(a2,size*2,void), size);+ if (res == 0)+ continue;+ if (res == -ENOTSUP)+ return -EINVAL;++ spa_pod_builder_raw(b, a1, size);+ n_copied++;+ }+ if (n_copied == 0)+ return -EINVAL;+ nc->body.type = SPA_CHOICE_Enum;+ }++ if ((p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_None) ||+ (p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_Enum)) {+ int n_copied = 0;+ /* copy all values inside the range */+ for (k = 0, a1 = alt1, a2 = alt2; k < nalt2; k++, a2 = SPA_PTROFF(a2,size,void)) {+ if (spa_pod_compare_value(type, a2, a1, size) < 0)+ continue;+ if (spa_pod_compare_value(type, a2, SPA_PTROFF(a1,size,void), size) > 0)+ continue;+ spa_pod_builder_raw(b, a2, size);+ n_copied++;+ }+ if (n_copied == 0)+ return -EINVAL;+ nc->body.type = SPA_CHOICE_Enum;+ }++ if ((p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_Range) ||+ (p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_Step) ||+ (p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_Range) ||+ (p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_Step)) {+ if (spa_pod_compare_value(type, alt1, alt2, size) < 0)+ spa_pod_builder_raw(b, alt2, size);+ else+ spa_pod_builder_raw(b, alt1, size);++ alt1 = SPA_PTROFF(alt1,size,void);+ alt2 = SPA_PTROFF(alt2,size,void);++ if (spa_pod_compare_value(type, alt1, alt2, size) < 0)+ spa_pod_builder_raw(b, alt1, size);+ else+ spa_pod_builder_raw(b, alt2, size);++ nc->body.type = SPA_CHOICE_Range;+ }++ if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Flags) ||+ (p1c == SPA_CHOICE_Flags && p2c == SPA_CHOICE_None) ||+ (p1c == SPA_CHOICE_Flags && p2c == SPA_CHOICE_Flags)) {+ if (spa_pod_filter_flags_value(b, type, alt1, alt2, size) != 1)+ return -EINVAL;+ nc->body.type = SPA_CHOICE_Flags;+ }++ if (p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_Flags)+ return -ENOTSUP;++ if (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Flags)+ return -ENOTSUP;++ if ((p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_None) ||+ (p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_Enum)) {+ int n_copied = 0;+ for (j = 0, a1 = alt1, a2 = alt2; j < nalt2; j++, a2 = SPA_PTROFF(a1,size,void)) {+ int res;+ if (spa_pod_compare_value(type, a2, a1, size) < 0)+ continue;+ if (spa_pod_compare_value(type, a2, SPA_PTROFF(a1,size,void), size) > 0)+ continue;++ res = spa_pod_filter_is_step_of(type, a2, SPA_PTROFF(a1,size*2,void), size);+ if (res == 0)+ continue;+ if (res == -ENOTSUP)+ return -EINVAL;++ spa_pod_builder_raw(b, a2, size);+ n_copied++;+ }+ if (n_copied == 0)+ return -EINVAL;+ nc->body.type = SPA_CHOICE_Enum;+ }+ if (p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_Flags)+ return -ENOTSUP;++ if (p1c == SPA_CHOICE_Flags && p2c == SPA_CHOICE_Range)+ return -ENOTSUP;+ if (p1c == SPA_CHOICE_Flags && p2c == SPA_CHOICE_Step)+ return -ENOTSUP;+ if (p1c == SPA_CHOICE_Flags && p2c == SPA_CHOICE_Enum)+ return -ENOTSUP;++ spa_pod_builder_pop(b, &f);+ spa_pod_choice_fix_default(nc);++ return 0;+}++static inline int spa_pod_filter_part(struct spa_pod_builder *b,+ const struct spa_pod *pod, uint32_t pod_size,+ const struct spa_pod *filter, uint32_t filter_size)+{+ const struct spa_pod *pp, *pf;+ int res = 0;++ pf = filter;++ SPA_POD_FOREACH(pod, pod_size, pp) {+ bool do_copy = false, do_advance = false;+ uint32_t filter_offset = 0;+ struct spa_pod_frame f;++ switch (SPA_POD_TYPE(pp)) {+ case SPA_TYPE_Object:+ if (pf != NULL) {+ struct spa_pod_object *op = (struct spa_pod_object *) pp;+ struct spa_pod_object *of = (struct spa_pod_object *) pf;+ const struct spa_pod_prop *p1, *p2;++ if (SPA_POD_TYPE(pf) != SPA_POD_TYPE(pp))+ return -EINVAL;++ spa_pod_builder_push_object(b, &f, op->body.type, op->body.id);+ p2 = NULL;+ SPA_POD_OBJECT_FOREACH(op, p1) {+ p2 = spa_pod_object_find_prop(of, p2, p1->key);+ if (p2 != NULL)+ res = spa_pod_filter_prop(b, p1, p2);+ else if ((p1->flags & SPA_POD_PROP_FLAG_MANDATORY) != 0)+ res = -EINVAL;+ else+ spa_pod_builder_raw_padded(b, p1, SPA_POD_PROP_SIZE(p1));+ if (res < 0)+ break;+ }+ if (res >= 0) {+ p1 = NULL;+ SPA_POD_OBJECT_FOREACH(of, p2) {+ p1 = spa_pod_object_find_prop(op, p1, p2->key);+ if (p1 != NULL)+ continue;+ if ((p2->flags & SPA_POD_PROP_FLAG_MANDATORY) != 0)+ res = -EINVAL;+ if (res < 0)+ break;+ spa_pod_builder_raw_padded(b, p2, SPA_POD_PROP_SIZE(p2));+ }+ }+ spa_pod_builder_pop(b, &f);+ do_advance = true;+ }+ else+ do_copy = true;+ break;++ case SPA_TYPE_Struct:+ if (pf != NULL) {+ if (SPA_POD_TYPE(pf) != SPA_POD_TYPE(pp))+ return -EINVAL;++ filter_offset = sizeof(struct spa_pod_struct);+ spa_pod_builder_push_struct(b, &f);+ res = spa_pod_filter_part(b,+ SPA_PTROFF(pp,filter_offset,const struct spa_pod),+ SPA_POD_SIZE(pp) - filter_offset,+ SPA_PTROFF(pf,filter_offset,const struct spa_pod),+ SPA_POD_SIZE(pf) - filter_offset);+ spa_pod_builder_pop(b, &f);+ do_advance = true;+ }+ else+ do_copy = true;+ break;++ default:+ if (pf != NULL) {+ if (SPA_POD_SIZE(pp) != SPA_POD_SIZE(pf))+ return -EINVAL;+ if (memcmp(pp, pf, SPA_POD_SIZE(pp)) != 0)+ return -EINVAL;+ do_advance = true;+ }+ do_copy = true;+ break;+ }+ if (do_copy)+ spa_pod_builder_raw_padded(b, pp, SPA_POD_SIZE(pp));+ if (do_advance) {+ pf = (const struct spa_pod*)spa_pod_next(pf);+ if (!spa_pod_is_inside(filter, filter_size, pf))+ pf = NULL;+ }+ if (res < 0)+ break;+ }+ return res;+}++static inline int+spa_pod_filter(struct spa_pod_builder *b,+ struct spa_pod **result,+ const struct spa_pod *pod,+ const struct spa_pod *filter)+{+ int res;+ struct spa_pod_builder_state state;++ spa_return_val_if_fail(pod != NULL, -EINVAL);+ spa_return_val_if_fail(b != NULL, -EINVAL);++ spa_pod_builder_get_state(b, &state);+ if (filter == NULL)+ res = spa_pod_builder_raw_padded(b, pod, SPA_POD_SIZE(pod));+ else+ res = spa_pod_filter_part(b, pod, SPA_POD_SIZE(pod), filter, SPA_POD_SIZE(filter));++ if (res < 0) {+ spa_pod_builder_reset(b, &state);+ } else if (result) {+ *result = (struct spa_pod*)spa_pod_builder_deref(b, state.offset);+ if (*result == NULL)+ res = -ENOSPC;+ }+ return res;+}++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_POD_FILTER_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/iter.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/iter.hnew file mode 100644index 000000000..05abfc1c9--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/iter.h@@ -0,0 +1,455 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_POD_ITER_H+#define SPA_POD_ITER_H++#ifdef __cplusplus+extern "C" {+#endif++#include <errno.h>+#include <sys/types.h>++#include <spa/pod/pod.h>++/**+ * \addtogroup spa_pod+ * \{+ */++struct spa_pod_frame {+ struct spa_pod pod;+ struct spa_pod_frame *parent;+ uint32_t offset;+ uint32_t flags;+};++static inline bool spa_pod_is_inside(const void *pod, uint32_t size, const void *iter)+{+ return SPA_POD_BODY(iter) <= SPA_PTROFF(pod, size, void) &&+ SPA_PTROFF(iter, SPA_POD_SIZE(iter), void) <= SPA_PTROFF(pod, size, void);+}++static inline void *spa_pod_next(const void *iter)+{+ return SPA_PTROFF(iter, SPA_ROUND_UP_N(SPA_POD_SIZE(iter), 8), void);+}++static inline struct spa_pod_prop *spa_pod_prop_first(const struct spa_pod_object_body *body)+{+ return SPA_PTROFF(body, sizeof(struct spa_pod_object_body), struct spa_pod_prop);+}++static inline bool spa_pod_prop_is_inside(const struct spa_pod_object_body *body,+ uint32_t size, const struct spa_pod_prop *iter)+{+ return SPA_POD_CONTENTS(struct spa_pod_prop, iter) <= SPA_PTROFF(body, size, void) &&+ SPA_PTROFF(iter, SPA_POD_PROP_SIZE(iter), void) <= SPA_PTROFF(body, size, void);+}++static inline struct spa_pod_prop *spa_pod_prop_next(const struct spa_pod_prop *iter)+{+ return SPA_PTROFF(iter, SPA_ROUND_UP_N(SPA_POD_PROP_SIZE(iter), 8), struct spa_pod_prop);+}++static inline struct spa_pod_control *spa_pod_control_first(const struct spa_pod_sequence_body *body)+{+ return SPA_PTROFF(body, sizeof(struct spa_pod_sequence_body), struct spa_pod_control);+}++static inline bool spa_pod_control_is_inside(const struct spa_pod_sequence_body *body,+ uint32_t size, const struct spa_pod_control *iter)+{+ return SPA_POD_CONTENTS(struct spa_pod_control, iter) <= SPA_PTROFF(body, size, void) &&+ SPA_PTROFF(iter, SPA_POD_CONTROL_SIZE(iter), void) <= SPA_PTROFF(body, size, void);+}++static inline struct spa_pod_control *spa_pod_control_next(const struct spa_pod_control *iter)+{+ return SPA_PTROFF(iter, SPA_ROUND_UP_N(SPA_POD_CONTROL_SIZE(iter), 8), struct spa_pod_control);+}++#define SPA_POD_ARRAY_BODY_FOREACH(body, _size, iter) \+ for ((iter) = (__typeof__(iter))SPA_PTROFF((body), sizeof(struct spa_pod_array_body), void); \+ (iter) < (__typeof__(iter))SPA_PTROFF((body), (_size), void); \+ (iter) = (__typeof__(iter))SPA_PTROFF((iter), (body)->child.size, void))++#define SPA_POD_ARRAY_FOREACH(obj, iter) \+ SPA_POD_ARRAY_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter)++#define SPA_POD_CHOICE_BODY_FOREACH(body, _size, iter) \+ for ((iter) = (__typeof__(iter))SPA_PTROFF((body), sizeof(struct spa_pod_choice_body), void); \+ (iter) < (__typeof__(iter))SPA_PTROFF((body), (_size), void); \+ (iter) = (__typeof__(iter))SPA_PTROFF((iter), (body)->child.size, void))++#define SPA_POD_CHOICE_FOREACH(obj, iter) \+ SPA_POD_CHOICE_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter)++#define SPA_POD_FOREACH(pod, size, iter) \+ for ((iter) = (pod); \+ spa_pod_is_inside(pod, size, iter); \+ (iter) = (__typeof__(iter))spa_pod_next(iter))++#define SPA_POD_STRUCT_FOREACH(obj, iter) \+ SPA_POD_FOREACH(SPA_POD_BODY(obj), SPA_POD_BODY_SIZE(obj), iter)++#define SPA_POD_OBJECT_BODY_FOREACH(body, size, iter) \+ for ((iter) = spa_pod_prop_first(body); \+ spa_pod_prop_is_inside(body, size, iter); \+ (iter) = spa_pod_prop_next(iter))++#define SPA_POD_OBJECT_FOREACH(obj, iter) \+ SPA_POD_OBJECT_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter)++#define SPA_POD_SEQUENCE_BODY_FOREACH(body, size, iter) \+ for ((iter) = spa_pod_control_first(body); \+ spa_pod_control_is_inside(body, size, iter); \+ (iter) = spa_pod_control_next(iter))++#define SPA_POD_SEQUENCE_FOREACH(seq, iter) \+ SPA_POD_SEQUENCE_BODY_FOREACH(&(seq)->body, SPA_POD_BODY_SIZE(seq), iter)+++static inline void *spa_pod_from_data(void *data, size_t maxsize, off_t offset, size_t size)+{+ void *pod;+ if (size < sizeof(struct spa_pod) || offset + size > maxsize)+ return NULL;+ pod = SPA_PTROFF(data, offset, void);+ if (SPA_POD_SIZE(pod) > size)+ return NULL;+ return pod;+}++static inline int spa_pod_is_none(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_None);+}++static inline int spa_pod_is_bool(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Bool && SPA_POD_BODY_SIZE(pod) >= sizeof(int32_t));+}++static inline int spa_pod_get_bool(const struct spa_pod *pod, bool *value)+{+ if (!spa_pod_is_bool(pod))+ return -EINVAL;+ *value = !!SPA_POD_VALUE(struct spa_pod_bool, pod);+ return 0;+}++static inline int spa_pod_is_id(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Id && SPA_POD_BODY_SIZE(pod) >= sizeof(uint32_t));+}++static inline int spa_pod_get_id(const struct spa_pod *pod, uint32_t *value)+{+ if (!spa_pod_is_id(pod))+ return -EINVAL;+ *value = SPA_POD_VALUE(struct spa_pod_id, pod);+ return 0;+}++static inline int spa_pod_is_int(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Int && SPA_POD_BODY_SIZE(pod) >= sizeof(int32_t));+}++static inline int spa_pod_get_int(const struct spa_pod *pod, int32_t *value)+{+ if (!spa_pod_is_int(pod))+ return -EINVAL;+ *value = SPA_POD_VALUE(struct spa_pod_int, pod);+ return 0;+}++static inline int spa_pod_is_long(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Long && SPA_POD_BODY_SIZE(pod) >= sizeof(int64_t));+}++static inline int spa_pod_get_long(const struct spa_pod *pod, int64_t *value)+{+ if (!spa_pod_is_long(pod))+ return -EINVAL;+ *value = SPA_POD_VALUE(struct spa_pod_long, pod);+ return 0;+}++static inline int spa_pod_is_float(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Float && SPA_POD_BODY_SIZE(pod) >= sizeof(float));+}++static inline int spa_pod_get_float(const struct spa_pod *pod, float *value)+{+ if (!spa_pod_is_float(pod))+ return -EINVAL;+ *value = SPA_POD_VALUE(struct spa_pod_float, pod);+ return 0;+}++static inline int spa_pod_is_double(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Double && SPA_POD_BODY_SIZE(pod) >= sizeof(double));+}++static inline int spa_pod_get_double(const struct spa_pod *pod, double *value)+{+ if (!spa_pod_is_double(pod))+ return -EINVAL;+ *value = SPA_POD_VALUE(struct spa_pod_double, pod);+ return 0;+}++static inline int spa_pod_is_string(const struct spa_pod *pod)+{+ const char *s = (const char *)SPA_POD_CONTENTS(struct spa_pod_string, pod);+ return (SPA_POD_TYPE(pod) == SPA_TYPE_String &&+ SPA_POD_BODY_SIZE(pod) > 0 &&+ s[SPA_POD_BODY_SIZE(pod)-1] == '\0');+}++static inline int spa_pod_get_string(const struct spa_pod *pod, const char **value)+{+ if (!spa_pod_is_string(pod))+ return -EINVAL;+ *value = (const char *)SPA_POD_CONTENTS(struct spa_pod_string, pod);+ return 0;+}++static inline int spa_pod_copy_string(const struct spa_pod *pod, size_t maxlen, char *dest)+{+ const char *s = (const char *)SPA_POD_CONTENTS(struct spa_pod_string, pod);+ if (!spa_pod_is_string(pod) || maxlen < 1)+ return -EINVAL;+ strncpy(dest, s, maxlen-1);+ dest[maxlen-1]= '\0';+ return 0;+}++static inline int spa_pod_is_bytes(const struct spa_pod *pod)+{+ return SPA_POD_TYPE(pod) == SPA_TYPE_Bytes;+}++static inline int spa_pod_get_bytes(const struct spa_pod *pod, const void **value, uint32_t *len)+{+ if (!spa_pod_is_bytes(pod))+ return -EINVAL;+ *value = (const void *)SPA_POD_CONTENTS(struct spa_pod_bytes, pod);+ *len = SPA_POD_BODY_SIZE(pod);+ return 0;+}++static inline int spa_pod_is_pointer(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Pointer &&+ SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_pointer_body));+}++static inline int spa_pod_get_pointer(const struct spa_pod *pod, uint32_t *type, const void **value)+{+ if (!spa_pod_is_pointer(pod))+ return -EINVAL;+ *type = ((struct spa_pod_pointer*)pod)->body.type;+ *value = ((struct spa_pod_pointer*)pod)->body.value;+ return 0;+}++static inline int spa_pod_is_fd(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Fd &&+ SPA_POD_BODY_SIZE(pod) >= sizeof(int64_t));+}++static inline int spa_pod_get_fd(const struct spa_pod *pod, int64_t *value)+{+ if (!spa_pod_is_fd(pod))+ return -EINVAL;+ *value = SPA_POD_VALUE(struct spa_pod_fd, pod);+ return 0;+}++static inline int spa_pod_is_rectangle(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Rectangle &&+ SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_rectangle));+}++static inline int spa_pod_get_rectangle(const struct spa_pod *pod, struct spa_rectangle *value)+{+ if (!spa_pod_is_rectangle(pod))+ return -EINVAL;+ *value = SPA_POD_VALUE(struct spa_pod_rectangle, pod);+ return 0;+}++static inline int spa_pod_is_fraction(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Fraction &&+ SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_fraction));+}++static inline int spa_pod_get_fraction(const struct spa_pod *pod, struct spa_fraction *value)+{+ spa_return_val_if_fail(spa_pod_is_fraction(pod), -EINVAL);+ *value = SPA_POD_VALUE(struct spa_pod_fraction, pod);+ return 0;+}++static inline int spa_pod_is_bitmap(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Bitmap &&+ SPA_POD_BODY_SIZE(pod) >= sizeof(uint8_t));+}++static inline int spa_pod_is_array(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Array &&+ SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_array_body));+}++static inline void *spa_pod_get_array(const struct spa_pod *pod, uint32_t *n_values)+{+ spa_return_val_if_fail(spa_pod_is_array(pod), NULL);+ *n_values = SPA_POD_ARRAY_N_VALUES(pod);+ return SPA_POD_ARRAY_VALUES(pod);+}++static inline uint32_t spa_pod_copy_array(const struct spa_pod *pod, uint32_t type,+ void *values, uint32_t max_values)+{+ uint32_t n_values;+ void *v = spa_pod_get_array(pod, &n_values);+ if (v == NULL || max_values == 0 || SPA_POD_ARRAY_VALUE_TYPE(pod) != type)+ return 0;+ n_values = SPA_MIN(n_values, max_values);+ memcpy(values, v, SPA_POD_ARRAY_VALUE_SIZE(pod) * n_values);+ return n_values;+}++static inline int spa_pod_is_choice(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Choice &&+ SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_choice_body));+}++static inline struct spa_pod *spa_pod_get_values(const struct spa_pod *pod, uint32_t *n_vals, uint32_t *choice)+{+ if (pod->type == SPA_TYPE_Choice) {+ *n_vals = SPA_POD_CHOICE_N_VALUES(pod);+ if ((*choice = SPA_POD_CHOICE_TYPE(pod)) == SPA_CHOICE_None)+ *n_vals = SPA_MIN(1u, SPA_POD_CHOICE_N_VALUES(pod));+ return (struct spa_pod*)SPA_POD_CHOICE_CHILD(pod);+ } else {+ *n_vals = 1;+ *choice = SPA_CHOICE_None;+ return (struct spa_pod*)pod;+ }+}++static inline int spa_pod_is_struct(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Struct);+}++static inline int spa_pod_is_object(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Object &&+ SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_object_body));+}++static inline bool spa_pod_is_object_type(const struct spa_pod *pod, uint32_t type)+{+ return (pod && spa_pod_is_object(pod) && SPA_POD_OBJECT_TYPE(pod) == type);+}++static inline bool spa_pod_is_object_id(const struct spa_pod *pod, uint32_t id)+{+ return (pod && spa_pod_is_object(pod) && SPA_POD_OBJECT_ID(pod) == id);+}++static inline int spa_pod_is_sequence(const struct spa_pod *pod)+{+ return (SPA_POD_TYPE(pod) == SPA_TYPE_Sequence &&+ SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_sequence_body));+}++static inline const struct spa_pod_prop *spa_pod_object_find_prop(const struct spa_pod_object *pod,+ const struct spa_pod_prop *start, uint32_t key)+{+ const struct spa_pod_prop *first, *res;++ first = spa_pod_prop_first(&pod->body);+ start = start ? spa_pod_prop_next(start) : first;++ for (res = start; spa_pod_prop_is_inside(&pod->body, pod->pod.size, res);+ res = spa_pod_prop_next(res)) {+ if (res->key == key)+ return res;+ }+ for (res = first; res != start; res = spa_pod_prop_next(res)) {+ if (res->key == key)+ return res;+ }+ return NULL;+}++static inline const struct spa_pod_prop *spa_pod_find_prop(const struct spa_pod *pod,+ const struct spa_pod_prop *start, uint32_t key)+{+ if (!spa_pod_is_object(pod))+ return NULL;+ return spa_pod_object_find_prop((const struct spa_pod_object *)pod, start, key);+}++static inline int spa_pod_object_fixate(struct spa_pod_object *pod)+{+ struct spa_pod_prop *res;+ SPA_POD_OBJECT_FOREACH(pod, res) {+ if (res->value.type == SPA_TYPE_Choice &&+ !SPA_FLAG_IS_SET(res->flags, SPA_POD_PROP_FLAG_DONT_FIXATE))+ ((struct spa_pod_choice*)&res->value)->body.type = SPA_CHOICE_None;+ }+ return 0;+}++static inline int spa_pod_fixate(struct spa_pod *pod)+{+ if (!spa_pod_is_object(pod))+ return -EINVAL;+ return spa_pod_object_fixate((struct spa_pod_object *)pod);+}++static inline int spa_pod_object_is_fixated(const struct spa_pod_object *pod)+{+ struct spa_pod_prop *res;+ SPA_POD_OBJECT_FOREACH(pod, res) {+ if (res->value.type == SPA_TYPE_Choice &&+ ((struct spa_pod_choice*)&res->value)->body.type != SPA_CHOICE_None)+ return 0;+ }+ return 1;+}++static inline int spa_pod_is_fixated(const struct spa_pod *pod)+{+ if (!spa_pod_is_object(pod))+ return -EINVAL;+ return spa_pod_object_is_fixated((const struct spa_pod_object *)pod);+}++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_POD_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/parser.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/parser.hnew file mode 100644index 000000000..387298927--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/parser.h@@ -0,0 +1,574 @@+/* Spa */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_POD_PARSER_H+#define SPA_POD_PARSER_H++#ifdef __cplusplus+extern "C" {+#endif++#include <errno.h>+#include <stdarg.h>++#include <spa/pod/iter.h>+#include <spa/pod/vararg.h>++/**+ * \addtogroup spa_pod+ * \{+ */++struct spa_pod_parser_state {+ uint32_t offset;+ uint32_t flags;+ struct spa_pod_frame *frame;+};++struct spa_pod_parser {+ const void *data;+ uint32_t size;+ uint32_t _padding;+ struct spa_pod_parser_state state;+};++#define SPA_POD_PARSER_INIT(buffer,size) ((struct spa_pod_parser){ (buffer), (size), 0, {} })++static inline void spa_pod_parser_init(struct spa_pod_parser *parser,+ const void *data, uint32_t size)+{+ *parser = SPA_POD_PARSER_INIT(data, size);+}++static inline void spa_pod_parser_pod(struct spa_pod_parser *parser,+ const struct spa_pod *pod)+{+ spa_pod_parser_init(parser, pod, SPA_POD_SIZE(pod));+}++static inline void+spa_pod_parser_get_state(struct spa_pod_parser *parser, struct spa_pod_parser_state *state)+{+ *state = parser->state;+}++static inline void+spa_pod_parser_reset(struct spa_pod_parser *parser, struct spa_pod_parser_state *state)+{+ parser->state = *state;+}++static inline struct spa_pod *+spa_pod_parser_deref(struct spa_pod_parser *parser, uint32_t offset, uint32_t size)+{+ /* Cast to uint64_t to avoid wraparound. Add 8 for the pod itself. */+ const uint64_t long_offset = (uint64_t)offset + 8;+ if (long_offset <= size && (offset & 7) == 0) {+ /* Use void* because creating a misaligned pointer is undefined. */+ void *pod = SPA_PTROFF(parser->data, offset, void);+ /*+ * Check that the pointer is aligned and that the size (rounded+ * to the next multiple of 8) is in bounds.+ */+ if (SPA_IS_ALIGNED(pod, __alignof__(struct spa_pod)) &&+ long_offset + SPA_ROUND_UP_N((uint64_t)SPA_POD_BODY_SIZE(pod), 8) <= size)+ return (struct spa_pod *)pod;+ }+ return NULL;+}++static inline struct spa_pod *spa_pod_parser_frame(struct spa_pod_parser *parser, struct spa_pod_frame *frame)+{+ return SPA_PTROFF(parser->data, frame->offset, struct spa_pod);+}++static inline void spa_pod_parser_push(struct spa_pod_parser *parser,+ struct spa_pod_frame *frame, const struct spa_pod *pod, uint32_t offset)+{+ frame->pod = *pod;+ frame->offset = offset;+ frame->parent = parser->state.frame;+ frame->flags = parser->state.flags;+ parser->state.frame = frame;+}++static inline struct spa_pod *spa_pod_parser_current(struct spa_pod_parser *parser)+{+ struct spa_pod_frame *f = parser->state.frame;+ uint32_t size = f ? f->offset + SPA_POD_SIZE(&f->pod) : parser->size;+ return spa_pod_parser_deref(parser, parser->state.offset, size);+}++static inline void spa_pod_parser_advance(struct spa_pod_parser *parser, const struct spa_pod *pod)+{+ parser->state.offset += SPA_ROUND_UP_N(SPA_POD_SIZE(pod), 8);+}++static inline struct spa_pod *spa_pod_parser_next(struct spa_pod_parser *parser)+{+ struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod)+ spa_pod_parser_advance(parser, pod);+ return pod;+}++static inline int spa_pod_parser_pop(struct spa_pod_parser *parser,+ struct spa_pod_frame *frame)+{+ parser->state.frame = frame->parent;+ parser->state.offset = frame->offset + SPA_ROUND_UP_N(SPA_POD_SIZE(&frame->pod), 8);+ return 0;+}++static inline int spa_pod_parser_get_bool(struct spa_pod_parser *parser, bool *value)+{+ int res = -EPIPE;+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod != NULL && (res = spa_pod_get_bool(pod, value)) >= 0)+ spa_pod_parser_advance(parser, pod);+ return res;+}++static inline int spa_pod_parser_get_id(struct spa_pod_parser *parser, uint32_t *value)+{+ int res = -EPIPE;+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod != NULL && (res = spa_pod_get_id(pod, value)) >= 0)+ spa_pod_parser_advance(parser, pod);+ return res;+}++static inline int spa_pod_parser_get_int(struct spa_pod_parser *parser, int32_t *value)+{+ int res = -EPIPE;+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod != NULL && (res = spa_pod_get_int(pod, value)) >= 0)+ spa_pod_parser_advance(parser, pod);+ return res;+}++static inline int spa_pod_parser_get_long(struct spa_pod_parser *parser, int64_t *value)+{+ int res = -EPIPE;+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod != NULL && (res = spa_pod_get_long(pod, value)) >= 0)+ spa_pod_parser_advance(parser, pod);+ return res;+}++static inline int spa_pod_parser_get_float(struct spa_pod_parser *parser, float *value)+{+ int res = -EPIPE;+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod != NULL && (res = spa_pod_get_float(pod, value)) >= 0)+ spa_pod_parser_advance(parser, pod);+ return res;+}++static inline int spa_pod_parser_get_double(struct spa_pod_parser *parser, double *value)+{+ int res = -EPIPE;+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod != NULL && (res = spa_pod_get_double(pod, value)) >= 0)+ spa_pod_parser_advance(parser, pod);+ return res;+}++static inline int spa_pod_parser_get_string(struct spa_pod_parser *parser, const char **value)+{+ int res = -EPIPE;+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod != NULL && (res = spa_pod_get_string(pod, value)) >= 0)+ spa_pod_parser_advance(parser, pod);+ return res;+}++static inline int spa_pod_parser_get_bytes(struct spa_pod_parser *parser, const void **value, uint32_t *len)+{+ int res = -EPIPE;+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod != NULL && (res = spa_pod_get_bytes(pod, value, len)) >= 0)+ spa_pod_parser_advance(parser, pod);+ return res;+}++static inline int spa_pod_parser_get_pointer(struct spa_pod_parser *parser, uint32_t *type, const void **value)+{+ int res = -EPIPE;+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod != NULL && (res = spa_pod_get_pointer(pod, type, value)) >= 0)+ spa_pod_parser_advance(parser, pod);+ return res;+}++static inline int spa_pod_parser_get_fd(struct spa_pod_parser *parser, int64_t *value)+{+ int res = -EPIPE;+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod != NULL && (res = spa_pod_get_fd(pod, value)) >= 0)+ spa_pod_parser_advance(parser, pod);+ return res;+}++static inline int spa_pod_parser_get_rectangle(struct spa_pod_parser *parser, struct spa_rectangle *value)+{+ int res = -EPIPE;+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod != NULL && (res = spa_pod_get_rectangle(pod, value)) >= 0)+ spa_pod_parser_advance(parser, pod);+ return res;+}++static inline int spa_pod_parser_get_fraction(struct spa_pod_parser *parser, struct spa_fraction *value)+{+ int res = -EPIPE;+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod != NULL && (res = spa_pod_get_fraction(pod, value)) >= 0)+ spa_pod_parser_advance(parser, pod);+ return res;+}++static inline int spa_pod_parser_get_pod(struct spa_pod_parser *parser, struct spa_pod **value)+{+ struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod == NULL)+ return -EPIPE;+ *value = pod;+ spa_pod_parser_advance(parser, pod);+ return 0;+}+static inline int spa_pod_parser_push_struct(struct spa_pod_parser *parser,+ struct spa_pod_frame *frame)+{+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod == NULL)+ return -EPIPE;+ if (!spa_pod_is_struct(pod))+ return -EINVAL;+ spa_pod_parser_push(parser, frame, pod, parser->state.offset);+ parser->state.offset += sizeof(struct spa_pod_struct);+ return 0;+}++static inline int spa_pod_parser_push_object(struct spa_pod_parser *parser,+ struct spa_pod_frame *frame, uint32_t type, uint32_t *id)+{+ const struct spa_pod *pod = spa_pod_parser_current(parser);+ if (pod == NULL)+ return -EPIPE;+ if (!spa_pod_is_object(pod))+ return -EINVAL;+ if (type != SPA_POD_OBJECT_TYPE(pod))+ return -EPROTO;+ if (id != NULL)+ *id = SPA_POD_OBJECT_ID(pod);+ spa_pod_parser_push(parser, frame, pod, parser->state.offset);+ parser->state.offset = parser->size;+ return 0;+}++static inline bool spa_pod_parser_can_collect(const struct spa_pod *pod, char type)+{+ if (pod == NULL)+ return false;++ if (SPA_POD_TYPE(pod) == SPA_TYPE_Choice) {+ if (!spa_pod_is_choice(pod))+ return false;+ if (type == 'V')+ return true;+ if (SPA_POD_CHOICE_TYPE(pod) != SPA_CHOICE_None)+ return false;+ pod = SPA_POD_CHOICE_CHILD(pod);+ }++ switch (type) {+ case 'P':+ return true;+ case 'b':+ return spa_pod_is_bool(pod);+ case 'I':+ return spa_pod_is_id(pod);+ case 'i':+ return spa_pod_is_int(pod);+ case 'l':+ return spa_pod_is_long(pod);+ case 'f':+ return spa_pod_is_float(pod);+ case 'd':+ return spa_pod_is_double(pod);+ case 's':+ return spa_pod_is_string(pod) || spa_pod_is_none(pod);+ case 'S':+ return spa_pod_is_string(pod);+ case 'y':+ return spa_pod_is_bytes(pod);+ case 'R':+ return spa_pod_is_rectangle(pod);+ case 'F':+ return spa_pod_is_fraction(pod);+ case 'B':+ return spa_pod_is_bitmap(pod);+ case 'a':+ return spa_pod_is_array(pod);+ case 'p':+ return spa_pod_is_pointer(pod);+ case 'h':+ return spa_pod_is_fd(pod);+ case 'T':+ return spa_pod_is_struct(pod) || spa_pod_is_none(pod);+ case 'O':+ return spa_pod_is_object(pod) || spa_pod_is_none(pod);+ case 'V':+ default:+ return false;+ }+}++#define SPA_POD_PARSER_COLLECT(pod,_type,args) \+do { \+ switch (_type) { \+ case 'b': \+ *va_arg(args, bool*) = SPA_POD_VALUE(struct spa_pod_bool, pod); \+ break; \+ case 'I': \+ case 'i': \+ *va_arg(args, int32_t*) = SPA_POD_VALUE(struct spa_pod_int, pod); \+ break; \+ case 'l': \+ *va_arg(args, int64_t*) = SPA_POD_VALUE(struct spa_pod_long, pod); \+ break; \+ case 'f': \+ *va_arg(args, float*) = SPA_POD_VALUE(struct spa_pod_float, pod); \+ break; \+ case 'd': \+ *va_arg(args, double*) = SPA_POD_VALUE(struct spa_pod_double, pod); \+ break; \+ case 's': \+ *va_arg(args, char**) = \+ ((pod) == NULL || (SPA_POD_TYPE(pod) == SPA_TYPE_None) \+ ? NULL \+ : (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod)); \+ break; \+ case 'S': \+ { \+ char *dest = va_arg(args, char*); \+ uint32_t maxlen = va_arg(args, uint32_t); \+ strncpy(dest, (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod), maxlen-1); \+ dest[maxlen-1] = '\0'; \+ break; \+ } \+ case 'y': \+ *(va_arg(args, void **)) = SPA_POD_CONTENTS(struct spa_pod_bytes, pod); \+ *(va_arg(args, uint32_t *)) = SPA_POD_BODY_SIZE(pod); \+ break; \+ case 'R': \+ *va_arg(args, struct spa_rectangle*) = \+ SPA_POD_VALUE(struct spa_pod_rectangle, pod); \+ break; \+ case 'F': \+ *va_arg(args, struct spa_fraction*) = \+ SPA_POD_VALUE(struct spa_pod_fraction, pod); \+ break; \+ case 'B': \+ *va_arg(args, uint32_t **) = \+ (uint32_t *) SPA_POD_CONTENTS(struct spa_pod_bitmap, pod); \+ break; \+ case 'a': \+ *va_arg(args, uint32_t*) = SPA_POD_ARRAY_VALUE_SIZE(pod); \+ *va_arg(args, uint32_t*) = SPA_POD_ARRAY_VALUE_TYPE(pod); \+ *va_arg(args, uint32_t*) = SPA_POD_ARRAY_N_VALUES(pod); \+ *va_arg(args, void**) = SPA_POD_ARRAY_VALUES(pod); \+ break; \+ case 'p': \+ { \+ struct spa_pod_pointer_body *b = \+ (struct spa_pod_pointer_body *) SPA_POD_BODY(pod); \+ *(va_arg(args, uint32_t *)) = b->type; \+ *(va_arg(args, const void **)) = b->value; \+ break; \+ } \+ case 'h': \+ *va_arg(args, int64_t*) = SPA_POD_VALUE(struct spa_pod_fd, pod); \+ break; \+ case 'P': \+ case 'T': \+ case 'O': \+ case 'V': \+ { \+ const struct spa_pod **d = va_arg(args, const struct spa_pod**); \+ if (d) \+ *d = ((pod) == NULL || (SPA_POD_TYPE(pod) == SPA_TYPE_None) \+ ? NULL : (pod)); \+ break; \+ } \+ default: \+ break; \+ } \+} while(false)++#define SPA_POD_PARSER_SKIP(_type,args) \+do { \+ switch (_type) { \+ case 'S': \+ va_arg(args, char*); \+ va_arg(args, uint32_t); \+ break; \+ case 'a': \+ va_arg(args, void*); \+ va_arg(args, void*); \+ SPA_FALLTHROUGH \+ case 'p': \+ case 'y': \+ va_arg(args, void*); \+ SPA_FALLTHROUGH \+ case 'b': \+ case 'I': \+ case 'i': \+ case 'l': \+ case 'f': \+ case 'd': \+ case 's': \+ case 'R': \+ case 'F': \+ case 'B': \+ case 'h': \+ case 'V': \+ case 'P': \+ case 'T': \+ case 'O': \+ va_arg(args, void*); \+ break; \+ } \+} while(false)++static inline int spa_pod_parser_getv(struct spa_pod_parser *parser, va_list args)+{+ struct spa_pod_frame *f = parser->state.frame;+ uint32_t ftype = f ? f->pod.type : (uint32_t)SPA_TYPE_Struct;+ const struct spa_pod_prop *prop = NULL;+ int count = 0;++ do {+ bool optional;+ const struct spa_pod *pod = NULL;+ const char *format;++ if (f && ftype == SPA_TYPE_Object) {+ uint32_t key = va_arg(args, uint32_t);+ const struct spa_pod_object *object;++ if (key == 0)+ break;++ object = (const struct spa_pod_object *)spa_pod_parser_frame(parser, f);+ prop = spa_pod_object_find_prop(object, prop, key);+ pod = prop ? &prop->value : NULL;+ }++ if ((format = va_arg(args, char *)) == NULL)+ break;++ if (ftype == SPA_TYPE_Struct)+ pod = spa_pod_parser_next(parser);++ if ((optional = (*format == '?')))+ format++;++ if (!spa_pod_parser_can_collect(pod, *format)) {+ if (!optional) {+ if (pod == NULL)+ return -ESRCH;+ else+ return -EPROTO;+ }+ SPA_POD_PARSER_SKIP(*format, args);+ } else {+ if (pod->type == SPA_TYPE_Choice && *format != 'V')+ pod = SPA_POD_CHOICE_CHILD(pod);++ SPA_POD_PARSER_COLLECT(pod, *format, args);+ count++;+ }+ } while (true);++ return count;+}++static inline int spa_pod_parser_get(struct spa_pod_parser *parser, ...)+{+ int res;+ va_list args;++ va_start(args, parser);+ res = spa_pod_parser_getv(parser, args);+ va_end(args);++ return res;+}++#define SPA_POD_OPT_Bool(val) "?" SPA_POD_Bool(val)+#define SPA_POD_OPT_Id(val) "?" SPA_POD_Id(val)+#define SPA_POD_OPT_Int(val) "?" SPA_POD_Int(val)+#define SPA_POD_OPT_Long(val) "?" SPA_POD_Long(val)+#define SPA_POD_OPT_Float(val) "?" SPA_POD_Float(val)+#define SPA_POD_OPT_Double(val) "?" SPA_POD_Double(val)+#define SPA_POD_OPT_String(val) "?" SPA_POD_String(val)+#define SPA_POD_OPT_Stringn(val,len) "?" SPA_POD_Stringn(val,len)+#define SPA_POD_OPT_Bytes(val,len) "?" SPA_POD_Bytes(val,len)+#define SPA_POD_OPT_Rectangle(val) "?" SPA_POD_Rectangle(val)+#define SPA_POD_OPT_Fraction(val) "?" SPA_POD_Fraction(val)+#define SPA_POD_OPT_Array(csize,ctype,n_vals,vals) "?" SPA_POD_Array(csize,ctype,n_vals,vals)+#define SPA_POD_OPT_Pointer(type,val) "?" SPA_POD_Pointer(type,val)+#define SPA_POD_OPT_Fd(val) "?" SPA_POD_Fd(val)+#define SPA_POD_OPT_Pod(val) "?" SPA_POD_Pod(val)+#define SPA_POD_OPT_PodObject(val) "?" SPA_POD_PodObject(val)+#define SPA_POD_OPT_PodStruct(val) "?" SPA_POD_PodStruct(val)+#define SPA_POD_OPT_PodChoice(val) "?" SPA_POD_PodChoice(val)++#define spa_pod_parser_get_object(p,type,id,...) \+({ \+ struct spa_pod_frame _f; \+ int _res; \+ if ((_res = spa_pod_parser_push_object(p, &_f, type, id)) == 0) { \+ _res = spa_pod_parser_get(p,##__VA_ARGS__, 0); \+ spa_pod_parser_pop(p, &_f); \+ } \+ _res; \+})++#define spa_pod_parser_get_struct(p,...) \+({ \+ struct spa_pod_frame _f; \+ int _res; \+ if ((_res = spa_pod_parser_push_struct(p, &_f)) == 0) { \+ _res = spa_pod_parser_get(p,##__VA_ARGS__, NULL); \+ spa_pod_parser_pop(p, &_f); \+ } \+ _res; \+})++#define spa_pod_parse_object(pod,type,id,...) \+({ \+ struct spa_pod_parser _p; \+ spa_pod_parser_pod(&_p, pod); \+ spa_pod_parser_get_object(&_p,type,id,##__VA_ARGS__); \+})++#define spa_pod_parse_struct(pod,...) \+({ \+ struct spa_pod_parser _p; \+ spa_pod_parser_pod(&_p, pod); \+ spa_pod_parser_get_struct(&_p,##__VA_ARGS__); \+})++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_POD_PARSER_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/pod.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/pod.hnew file mode 100644index 000000000..f7627f48e--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/pod.h@@ -0,0 +1,226 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_POD_H+#define SPA_POD_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>+#include <spa/utils/type.h>++/**+ * \addtogroup spa_pod+ * \{+ */++#define SPA_POD_BODY_SIZE(pod) (((struct spa_pod*)(pod))->size)+#define SPA_POD_TYPE(pod) (((struct spa_pod*)(pod))->type)+#define SPA_POD_SIZE(pod) ((uint64_t)sizeof(struct spa_pod) + SPA_POD_BODY_SIZE(pod))+#define SPA_POD_CONTENTS_SIZE(type,pod) (SPA_POD_SIZE(pod)-sizeof(type))++#define SPA_POD_CONTENTS(type,pod) SPA_PTROFF((pod),sizeof(type),void)+#define SPA_POD_CONTENTS_CONST(type,pod) SPA_PTROFF((pod),sizeof(type),const void)+#define SPA_POD_BODY(pod) SPA_PTROFF((pod),sizeof(struct spa_pod),void)+#define SPA_POD_BODY_CONST(pod) SPA_PTROFF((pod),sizeof(struct spa_pod),const void)++struct spa_pod {+ uint32_t size; /* size of the body */+ uint32_t type; /* a basic id of enum spa_type */+};++#define SPA_POD_VALUE(type,pod) (((type*)(pod))->value)++struct spa_pod_bool {+ struct spa_pod pod;+ int32_t value;+ int32_t _padding;+};++struct spa_pod_id {+ struct spa_pod pod;+ uint32_t value;+ int32_t _padding;+};++struct spa_pod_int {+ struct spa_pod pod;+ int32_t value;+ int32_t _padding;+};++struct spa_pod_long {+ struct spa_pod pod;+ int64_t value;+};++struct spa_pod_float {+ struct spa_pod pod;+ float value;+ int32_t _padding;+};++struct spa_pod_double {+ struct spa_pod pod;+ double value;+};++struct spa_pod_string {+ struct spa_pod pod;+ /* value here */+};++struct spa_pod_bytes {+ struct spa_pod pod;+ /* value here */+};++struct spa_pod_rectangle {+ struct spa_pod pod;+ struct spa_rectangle value;+};++struct spa_pod_fraction {+ struct spa_pod pod;+ struct spa_fraction value;+};++struct spa_pod_bitmap {+ struct spa_pod pod;+ /* array of uint8_t follows with the bitmap */+};++#define SPA_POD_ARRAY_CHILD(arr) (&((struct spa_pod_array*)(arr))->body.child)+#define SPA_POD_ARRAY_VALUE_TYPE(arr) (SPA_POD_TYPE(SPA_POD_ARRAY_CHILD(arr)))+#define SPA_POD_ARRAY_VALUE_SIZE(arr) (SPA_POD_BODY_SIZE(SPA_POD_ARRAY_CHILD(arr)))+#define SPA_POD_ARRAY_N_VALUES(arr) (SPA_POD_ARRAY_VALUE_SIZE(arr) ? ((SPA_POD_BODY_SIZE(arr) - sizeof(struct spa_pod_array_body)) / SPA_POD_ARRAY_VALUE_SIZE(arr)) : 0)+#define SPA_POD_ARRAY_VALUES(arr) SPA_POD_CONTENTS(struct spa_pod_array, arr)++struct spa_pod_array_body {+ struct spa_pod child;+ /* array with elements of child.size follows */+};++struct spa_pod_array {+ struct spa_pod pod;+ struct spa_pod_array_body body;+};++#define SPA_POD_CHOICE_CHILD(choice) (&((struct spa_pod_choice*)(choice))->body.child)+#define SPA_POD_CHOICE_TYPE(choice) (((struct spa_pod_choice*)(choice))->body.type)+#define SPA_POD_CHOICE_FLAGS(choice) (((struct spa_pod_choice*)(choice))->body.flags)+#define SPA_POD_CHOICE_VALUE_TYPE(choice) (SPA_POD_TYPE(SPA_POD_CHOICE_CHILD(choice)))+#define SPA_POD_CHOICE_VALUE_SIZE(choice) (SPA_POD_BODY_SIZE(SPA_POD_CHOICE_CHILD(choice)))+#define SPA_POD_CHOICE_N_VALUES(choice) (SPA_POD_CHOICE_VALUE_SIZE(choice) ? ((SPA_POD_BODY_SIZE(choice) - sizeof(struct spa_pod_choice_body)) / SPA_POD_CHOICE_VALUE_SIZE(choice)) : 0)+#define SPA_POD_CHOICE_VALUES(choice) (SPA_POD_CONTENTS(struct spa_pod_choice, choice))++enum spa_choice_type {+ SPA_CHOICE_None, /**< no choice, first value is current */+ SPA_CHOICE_Range, /**< range: default, min, max */+ SPA_CHOICE_Step, /**< range with step: default, min, max, step */+ SPA_CHOICE_Enum, /**< list: default, alternative,... */+ SPA_CHOICE_Flags, /**< flags: default, possible flags,... */+};++struct spa_pod_choice_body {+ uint32_t type; /**< type of choice, one of enum spa_choice_type */+ uint32_t flags; /**< extra flags */+ struct spa_pod child;+ /* array with elements of child.size follows. Note that there might be more+ * elements than required by \a type, which should be ignored. */+};++struct spa_pod_choice {+ struct spa_pod pod;+ struct spa_pod_choice_body body;+};++struct spa_pod_struct {+ struct spa_pod pod;+ /* one or more spa_pod follow */+};++#define SPA_POD_OBJECT_TYPE(obj) (((struct spa_pod_object*)(obj))->body.type)+#define SPA_POD_OBJECT_ID(obj) (((struct spa_pod_object*)(obj))->body.id)++struct spa_pod_object_body {+ uint32_t type; /**< one of enum spa_type */+ uint32_t id; /**< id of the object, depends on the object type */+ /* contents follow, series of spa_pod_prop */+};++struct spa_pod_object {+ struct spa_pod pod;+ struct spa_pod_object_body body;+};++struct spa_pod_pointer_body {+ uint32_t type; /**< pointer id, one of enum spa_type */+ uint32_t _padding;+ const void *value;+};++struct spa_pod_pointer {+ struct spa_pod pod;+ struct spa_pod_pointer_body body;+};++struct spa_pod_fd {+ struct spa_pod pod;+ int64_t value;+};++#define SPA_POD_PROP_SIZE(prop) (sizeof(struct spa_pod_prop) + (prop)->value.size)++/* props can be inside an object */+struct spa_pod_prop {+ uint32_t key; /**< key of property, list of valid keys depends on the+ * object type */+#define SPA_POD_PROP_FLAG_READONLY (1u<<0) /**< is read-only */+#define SPA_POD_PROP_FLAG_HARDWARE (1u<<1) /**< some sort of hardware parameter */+#define SPA_POD_PROP_FLAG_HINT_DICT (1u<<2) /**< contains a dictionary struct as+ * (Struct(+ * Int : n_items,+ * (String : key,+ * String : value)*)) */+#define SPA_POD_PROP_FLAG_MANDATORY (1u<<3) /**< is mandatory */+#define SPA_POD_PROP_FLAG_DONT_FIXATE (1u<<4) /**< choices need no fixation */+ uint32_t flags; /**< flags for property */+ struct spa_pod value;+ /* value follows */+};++#define SPA_POD_CONTROL_SIZE(ev) (sizeof(struct spa_pod_control) + (ev)->value.size)++/* controls can be inside a sequence and mark timed values */+struct spa_pod_control {+ uint32_t offset; /**< media offset */+ uint32_t type; /**< type of control, enum spa_control_type */+ struct spa_pod value; /**< control value, depends on type */+ /* value contents follow */+};++struct spa_pod_sequence_body {+ uint32_t unit;+ uint32_t pad;+ /* series of struct spa_pod_control follows */+};++/** a sequence of timed controls */+struct spa_pod_sequence {+ struct spa_pod pod;+ struct spa_pod_sequence_body body;+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_POD_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/vararg.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/vararg.hnew file mode 100644index 000000000..a30e11479--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/pod/vararg.h@@ -0,0 +1,93 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2019 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_POD_VARARG_H+#define SPA_POD_VARARG_H++#ifdef __cplusplus+extern "C" {+#endif++#include <stdarg.h>++#include <spa/pod/pod.h>++/**+ * \addtogroup spa_pod+ * \{+ */++#define SPA_POD_Prop(key,...) \+ key, ##__VA_ARGS__++#define SPA_POD_Control(offset,type,...) \+ offset, type, ##__VA_ARGS__++#define SPA_CHOICE_RANGE(def,min,max) 3,(def),(min),(max)+#define SPA_CHOICE_STEP(def,min,max,step) 4,(def),(min),(max),(step)+#define SPA_CHOICE_ENUM(n_vals,...) (n_vals),##__VA_ARGS__+#define SPA_CHOICE_FLAGS(flags) 1, (flags)+#define SPA_CHOICE_BOOL(def) 3,(def),(def),!(def)++#define SPA_POD_Bool(val) "b", val+#define SPA_POD_CHOICE_Bool(def) "?eb", SPA_CHOICE_BOOL(def)++#define SPA_POD_Id(val) "I", val+#define SPA_POD_CHOICE_ENUM_Id(n_vals,...) "?eI", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)++#define SPA_POD_Int(val) "i", val+#define SPA_POD_CHOICE_ENUM_Int(n_vals,...) "?ei", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)+#define SPA_POD_CHOICE_RANGE_Int(def,min,max) "?ri", SPA_CHOICE_RANGE(def, min, max)+#define SPA_POD_CHOICE_STEP_Int(def,min,max,step) "?si", SPA_CHOICE_STEP(def, min, max, step)+#define SPA_POD_CHOICE_FLAGS_Int(flags) "?fi", SPA_CHOICE_FLAGS(flags)++#define SPA_POD_Long(val) "l", val+#define SPA_POD_CHOICE_ENUM_Long(n_vals,...) "?el", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)+#define SPA_POD_CHOICE_RANGE_Long(def,min,max) "?rl", SPA_CHOICE_RANGE(def, min, max)+#define SPA_POD_CHOICE_STEP_Long(def,min,max,step) "?sl", SPA_CHOICE_STEP(def, min, max, step)+#define SPA_POD_CHOICE_FLAGS_Long(flags) "?fl", SPA_CHOICE_FLAGS(flags)++#define SPA_POD_Float(val) "f", val+#define SPA_POD_CHOICE_ENUM_Float(n_vals,...) "?ef", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)+#define SPA_POD_CHOICE_RANGE_Float(def,min,max) "?rf", SPA_CHOICE_RANGE(def, min, max)+#define SPA_POD_CHOICE_STEP_Float(def,min,max,step) "?sf", SPA_CHOICE_STEP(def, min, max, step)++#define SPA_POD_Double(val) "d", val+#define SPA_POD_CHOICE_ENUM_Double(n_vals,...) "?ed", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)+#define SPA_POD_CHOICE_RANGE_Double(def,min,max) "?rd", SPA_CHOICE_RANGE(def, min, max)+#define SPA_POD_CHOICE_STEP_Double(def,min,max,step) "?sd", SPA_CHOICE_STEP(def, min, max, step)++#define SPA_POD_String(val) "s",val+#define SPA_POD_Stringn(val,len) "S",val,len++#define SPA_POD_Bytes(val,len) "y",val,len++#define SPA_POD_Rectangle(val) "R",val+#define SPA_POD_CHOICE_ENUM_Rectangle(n_vals,...) "?eR", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)+#define SPA_POD_CHOICE_RANGE_Rectangle(def,min,max) "?rR", SPA_CHOICE_RANGE((def),(min),(max))+#define SPA_POD_CHOICE_STEP_Rectangle(def,min,max,step) "?sR", SPA_CHOICE_STEP((def),(min),(max),(step))++#define SPA_POD_Fraction(val) "F",val+#define SPA_POD_CHOICE_ENUM_Fraction(n_vals,...) "?eF", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)+#define SPA_POD_CHOICE_RANGE_Fraction(def,min,max) "?rF", SPA_CHOICE_RANGE((def),(min),(max))+#define SPA_POD_CHOICE_STEP_Fraction(def,min,max,step) "?sF", SPA_CHOICE_STEP(def, min, max, step)++#define SPA_POD_Array(csize,ctype,n_vals,vals) "a", csize,ctype,n_vals,vals+#define SPA_POD_Pointer(type,val) "p", type,val+#define SPA_POD_Fd(val) "h", val+#define SPA_POD_None() "P", NULL+#define SPA_POD_Pod(val) "P", val+#define SPA_POD_PodObject(val) "O", val+#define SPA_POD_PodStruct(val) "T", val+#define SPA_POD_PodChoice(val) "V", val++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_POD_VARARG_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/log.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/log.hnew file mode 100644index 000000000..450ff2624--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/log.h@@ -0,0 +1,304 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_LOG_H+#define SPA_LOG_H++#ifdef __cplusplus+extern "C" {+#endif++#include <stdarg.h>++#include <spa/utils/type.h>+#include <spa/utils/defs.h>+#include <spa/utils/hook.h>++/** \defgroup spa_log Log+ * Logging interface+ */++/**+ * \addtogroup spa_log+ * \{+ */++/** The default log topic. Redefine this in your code to+ * allow for the spa_log_* macros to work correctly, e.g:+ *+ * \code{.c}+ * struct spa_log_topic *mylogger;+ * #undef SPA_LOG_TOPIC_DEFAULT+ * #define SPA_LOG_TOPIC_DEFAULT mylogger+ * \endcode+ */+#define SPA_LOG_TOPIC_DEFAULT NULL++enum spa_log_level {+ SPA_LOG_LEVEL_NONE = 0,+ SPA_LOG_LEVEL_ERROR,+ SPA_LOG_LEVEL_WARN,+ SPA_LOG_LEVEL_INFO,+ SPA_LOG_LEVEL_DEBUG,+ SPA_LOG_LEVEL_TRACE,+};++/**+ * The Log interface+ */+#define SPA_TYPE_INTERFACE_Log SPA_TYPE_INFO_INTERFACE_BASE "Log"+++struct spa_log {+ /** the version of this log. This can be used to expand this+ * structure in the future */+#define SPA_VERSION_LOG 0+ struct spa_interface iface;+ /**+ * Logging level, everything above this level is not logged+ */+ enum spa_log_level level;+};++/**+ * \struct spa_log_topic+ *+ * Identifier for a topic. Topics are string-based filters that logically+ * group messages together. An implementation may decide to filter different+ * topics on different levels, for example the "protocol" topic may require+ * debug level TRACE while the "core" topic defaults to debug level INFO.+ *+ * spa_log_topics require a spa_log_methods version of 1 or higher.+ */+struct spa_log_topic {+#define SPA_VERSION_LOG_TOPIC 0+ /** the version of this topic. This can be used to expand this+ * structure in the future */+ uint32_t version;+ /** The string identifier for the topic */+ const char *topic;+ /** Logging level set for this topic */+ enum spa_log_level level;+ /** False if this topic follows the \ref spa_log level */+ bool has_custom_level;+};++struct spa_log_methods {+#define SPA_VERSION_LOG_METHODS 1+ uint32_t version;+ /**+ * Log a message with the given log level.+ *+ * \note If compiled with this header, this function is only called+ * for implementations of version 0. For versions 1 and above, see+ * logt() instead.+ *+ * \param log a spa_log+ * \param level a spa_log_level+ * \param file the file name+ * \param line the line number+ * \param func the function name+ * \param fmt printf style format+ * \param ... format arguments+ */+ void (*log) (void *object,+ enum spa_log_level level,+ const char *file,+ int line,+ const char *func,+ const char *fmt, ...) SPA_PRINTF_FUNC(6, 7);++ /**+ * Log a message with the given log level.+ *+ * \note If compiled with this header, this function is only called+ * for implementations of version 0. For versions 1 and above, see+ * logtv() instead.+ *+ * \param log a spa_log+ * \param level a spa_log_level+ * \param file the file name+ * \param line the line number+ * \param func the function name+ * \param fmt printf style format+ * \param args format arguments+ */+ void (*logv) (void *object,+ enum spa_log_level level,+ const char *file,+ int line,+ const char *func,+ const char *fmt,+ va_list args) SPA_PRINTF_FUNC(6, 0);+ /**+ * Log a message with the given log level for the given topic.+ *+ * \note Callers that do not use topic-based logging (version 0), the \a+ * topic is NULL+ *+ * \param log a spa_log+ * \param level a spa_log_level+ * \param topic the topic for this message, may be NULL+ * \param file the file name+ * \param line the line number+ * \param func the function name+ * \param fmt printf style format+ * \param ... format arguments+ *+ * \since 1+ */+ void (*logt) (void *object,+ enum spa_log_level level,+ const struct spa_log_topic *topic,+ const char *file,+ int line,+ const char *func,+ const char *fmt, ...) SPA_PRINTF_FUNC(7, 8);++ /**+ * Log a message with the given log level for the given topic.+ *+ * \note For callers that do not use topic-based logging (version 0),+ * the \a topic is NULL+ *+ * \param log a spa_log+ * \param level a spa_log_level+ * \param topic the topic for this message, may be NULL+ * \param file the file name+ * \param line the line number+ * \param func the function name+ * \param fmt printf style format+ * \param args format arguments+ *+ * \since 1+ */+ void (*logtv) (void *object,+ enum spa_log_level level,+ const struct spa_log_topic *topic,+ const char *file,+ int line,+ const char *func,+ const char *fmt,+ va_list args) SPA_PRINTF_FUNC(7, 0);++ /**+ * Initializes a \ref spa_log_topic to the correct logging level.+ *+ * \since 1+ */+ void (*topic_init) (void *object, struct spa_log_topic *topic);+};+++#define SPA_LOG_TOPIC(v, t) \+ (struct spa_log_topic){ .version = (v), .topic = (t)}++static inline void spa_log_topic_init(struct spa_log *log, struct spa_log_topic *topic)+{+ if (SPA_UNLIKELY(!log))+ return;++ spa_interface_call(&log->iface, struct spa_log_methods, topic_init, 1, topic);+}++static inline bool spa_log_level_topic_enabled(const struct spa_log *log,+ const struct spa_log_topic *topic,+ enum spa_log_level level)+{+ enum spa_log_level max_level;++ if (SPA_UNLIKELY(!log))+ return false;++ if (topic && topic->has_custom_level)+ max_level = topic->level;+ else+ max_level = log->level;++ return level <= max_level;+}++/* Transparently calls to version 0 log if v1 is not supported */+#define spa_log_logt(l,lev,topic,...) \+({ \+ struct spa_log *_l = l; \+ if (SPA_UNLIKELY(spa_log_level_topic_enabled(_l, topic, lev))) { \+ struct spa_interface *_if = &_l->iface; \+ if (!spa_interface_call(_if, \+ struct spa_log_methods, logt, 1, \+ lev, topic, \+ __VA_ARGS__)) \+ spa_interface_call(_if, \+ struct spa_log_methods, log, 0, \+ lev, __VA_ARGS__); \+ } \+})++/* Transparently calls to version 0 logv if v1 is not supported */+#define spa_log_logtv(l,lev,topic,...) \+({ \+ struct spa_log *_l = l; \+ if (SPA_UNLIKELY(spa_log_level_topic_enabled(_l, topic, lev))) { \+ struct spa_interface *_if = &_l->iface; \+ if (!spa_interface_call(_if, \+ struct spa_log_methods, logtv, 1, \+ lev, topic, \+ __VA_ARGS__)) \+ spa_interface_call(_if, \+ struct spa_log_methods, logv, 0, \+ lev, __VA_ARGS__); \+ } \+})++#define spa_logt_lev(l,lev,t,...) \+ spa_log_logt(l,lev,t,__FILE__,__LINE__,__func__,__VA_ARGS__)++#define spa_log_lev(l,lev,...) \+ spa_logt_lev(l,lev,SPA_LOG_TOPIC_DEFAULT,__VA_ARGS__)++#define spa_log_log(l,lev,...) \+ spa_log_logt(l,lev,SPA_LOG_TOPIC_DEFAULT,__VA_ARGS__)++#define spa_log_logv(l,lev,...) \+ spa_log_logtv(l,lev,SPA_LOG_TOPIC_DEFAULT,__VA_ARGS__)++#define spa_log_error(l,...) spa_log_lev(l,SPA_LOG_LEVEL_ERROR,__VA_ARGS__)+#define spa_log_warn(l,...) spa_log_lev(l,SPA_LOG_LEVEL_WARN,__VA_ARGS__)+#define spa_log_info(l,...) spa_log_lev(l,SPA_LOG_LEVEL_INFO,__VA_ARGS__)+#define spa_log_debug(l,...) spa_log_lev(l,SPA_LOG_LEVEL_DEBUG,__VA_ARGS__)+#define spa_log_trace(l,...) spa_log_lev(l,SPA_LOG_LEVEL_TRACE,__VA_ARGS__)++#define spa_logt_error(l,t,...) spa_logt_lev(l,SPA_LOG_LEVEL_ERROR,t,__VA_ARGS__)+#define spa_logt_warn(l,t,...) spa_logt_lev(l,SPA_LOG_LEVEL_WARN,t,__VA_ARGS__)+#define spa_logt_info(l,t,...) spa_logt_lev(l,SPA_LOG_LEVEL_INFO,t,__VA_ARGS__)+#define spa_logt_debug(l,t,...) spa_logt_lev(l,SPA_LOG_LEVEL_DEBUG,t,__VA_ARGS__)+#define spa_logt_trace(l,t,...) spa_logt_lev(l,SPA_LOG_LEVEL_TRACE,t,__VA_ARGS__)++#ifndef FASTPATH+#define spa_log_trace_fp(l,...) spa_log_lev(l,SPA_LOG_LEVEL_TRACE,__VA_ARGS__)+#else+#define spa_log_trace_fp(l,...)+#endif+++/** \fn spa_log_error */++/** keys can be given when initializing the logger handle */+#define SPA_KEY_LOG_LEVEL "log.level" /**< the default log level */+#define SPA_KEY_LOG_COLORS "log.colors" /**< enable colors in the logger, set to "force" to enable+ * colors even when not logging to a terminal */+#define SPA_KEY_LOG_FILE "log.file" /**< log to the specified file instead of+ * stderr. */+#define SPA_KEY_LOG_TIMESTAMP "log.timestamp" /**< log timestamps */+#define SPA_KEY_LOG_LINE "log.line" /**< log file and line numbers */+#define SPA_KEY_LOG_PATTERNS "log.patterns" /**< Spa:String:JSON array of [ {"pattern" : level}, ... ] */++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif+#endif /* SPA_LOG_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/loop.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/loop.hnew file mode 100644index 000000000..01b9abc5b--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/loop.h@@ -0,0 +1,330 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_LOOP_H+#define SPA_LOOP_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>+#include <spa/utils/hook.h>+#include <spa/support/system.h>++/** \defgroup spa_loop Loop+ * Event loop interface+ */++/**+ * \addtogroup spa_loop+ * \{+ */++#define SPA_TYPE_INTERFACE_Loop SPA_TYPE_INFO_INTERFACE_BASE "Loop"+#define SPA_TYPE_INTERFACE_DataLoop SPA_TYPE_INFO_INTERFACE_BASE "DataLoop"+#define SPA_VERSION_LOOP 0+struct spa_loop { struct spa_interface iface; };++#define SPA_TYPE_INTERFACE_LoopControl SPA_TYPE_INFO_INTERFACE_BASE "LoopControl"+#define SPA_VERSION_LOOP_CONTROL 1+struct spa_loop_control { struct spa_interface iface; };++#define SPA_TYPE_INTERFACE_LoopUtils SPA_TYPE_INFO_INTERFACE_BASE "LoopUtils"+#define SPA_VERSION_LOOP_UTILS 0+struct spa_loop_utils { struct spa_interface iface; };++struct spa_source;++typedef void (*spa_source_func_t) (struct spa_source *source);++struct spa_source {+ struct spa_loop *loop;+ spa_source_func_t func;+ void *data;+ int fd;+ uint32_t mask;+ uint32_t rmask;+ /* private data for the loop implementer */+ void *priv;+};++typedef int (*spa_invoke_func_t) (struct spa_loop *loop,+ bool async,+ uint32_t seq,+ const void *data,+ size_t size,+ void *user_data);++/**+ * Register sources and work items to an event loop+ */+struct spa_loop_methods {+ /* the version of this structure. This can be used to expand this+ * structure in the future */+#define SPA_VERSION_LOOP_METHODS 0+ uint32_t version;++ /** add a source to the loop */+ int (*add_source) (void *object,+ struct spa_source *source);++ /** update the source io mask */+ int (*update_source) (void *object,+ struct spa_source *source);++ /** remove a source from the loop */+ int (*remove_source) (void *object,+ struct spa_source *source);++ /** invoke a function in the context of this loop */+ int (*invoke) (void *object,+ spa_invoke_func_t func,+ uint32_t seq,+ const void *data,+ size_t size,+ bool block,+ void *user_data);+};++#define spa_loop_method(o,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ struct spa_loop *_o = o; \+ spa_interface_call_res(&_o->iface, \+ struct spa_loop_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++#define spa_loop_add_source(l,...) spa_loop_method(l,add_source,0,##__VA_ARGS__)+#define spa_loop_update_source(l,...) spa_loop_method(l,update_source,0,##__VA_ARGS__)+#define spa_loop_remove_source(l,...) spa_loop_method(l,remove_source,0,##__VA_ARGS__)+#define spa_loop_invoke(l,...) spa_loop_method(l,invoke,0,##__VA_ARGS__)+++/** Control hooks. These hooks can't be removed from their+ * callbacks and must be removed from a safe place (when the loop+ * is not running or when it is locked). */+struct spa_loop_control_hooks {+#define SPA_VERSION_LOOP_CONTROL_HOOKS 0+ uint32_t version;+ /** Executed right before waiting for events. It is typically used to+ * release locks. */+ void (*before) (void *data);+ /** Executed right after waiting for events. It is typically used to+ * reacquire locks. */+ void (*after) (void *data);+};++#define spa_loop_control_hook_before(l) \+({ \+ struct spa_hook_list *_l = l; \+ struct spa_hook *_h; \+ spa_list_for_each_reverse(_h, &_l->list, link) \+ spa_callbacks_call_fast(&_h->cb, struct spa_loop_control_hooks, before, 0); \+})++#define spa_loop_control_hook_after(l) \+({ \+ struct spa_hook_list *_l = l; \+ struct spa_hook *_h; \+ spa_list_for_each(_h, &_l->list, link) \+ spa_callbacks_call_fast(&_h->cb, struct spa_loop_control_hooks, after, 0); \+})++/**+ * Control an event loop+ */+struct spa_loop_control_methods {+ /* the version of this structure. This can be used to expand this+ * structure in the future */+#define SPA_VERSION_LOOP_CONTROL_METHODS 1+ uint32_t version;++ int (*get_fd) (void *object);++ /** Add a hook+ * \param ctrl the control to change+ * \param hooks the hooks to add+ *+ * Adds hooks to the loop controlled by \a ctrl.+ */+ void (*add_hook) (void *object,+ struct spa_hook *hook,+ const struct spa_loop_control_hooks *hooks,+ void *data);++ /** Enter a loop+ * \param ctrl the control+ *+ * Start an iteration of the loop. This function should be called+ * before calling iterate and is typically used to capture the thread+ * that this loop will run in.+ */+ void (*enter) (void *object);+ /** Leave a loop+ * \param ctrl the control+ *+ * Ends the iteration of a loop. This should be called after calling+ * iterate.+ */+ void (*leave) (void *object);++ /** Perform one iteration of the loop.+ * \param ctrl the control+ * \param timeout an optional timeout in milliseconds.+ * 0 for no timeout, -1 for infinite timeout.+ *+ * This function will block+ * up to \a timeout milliseconds and then dispatch the fds with activity.+ * The number of dispatched fds is returned.+ */+ int (*iterate) (void *object, int timeout);++ /** Check context of the loop+ * \param ctrl the control+ *+ * This function will check if the current thread is currently the+ * one that did the enter call. Since version 1:1.+ *+ * returns 1 on success, 0 or negative errno value on error.+ */+ int (*check) (void *object);+};++#define spa_loop_control_method_v(o,method,version,...) \+({ \+ struct spa_loop_control *_o = o; \+ spa_interface_call(&_o->iface, \+ struct spa_loop_control_methods, \+ method, version, ##__VA_ARGS__); \+})++#define spa_loop_control_method_r(o,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ struct spa_loop_control *_o = o; \+ spa_interface_call_res(&_o->iface, \+ struct spa_loop_control_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++#define spa_loop_control_method_fast_r(o,method,version,...) \+({ \+ int _res; \+ struct spa_loop_control *_o = o; \+ spa_interface_call_fast_res(&_o->iface, \+ struct spa_loop_control_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++#define spa_loop_control_get_fd(l) spa_loop_control_method_r(l,get_fd,0)+#define spa_loop_control_add_hook(l,...) spa_loop_control_method_v(l,add_hook,0,__VA_ARGS__)+#define spa_loop_control_enter(l) spa_loop_control_method_v(l,enter,0)+#define spa_loop_control_leave(l) spa_loop_control_method_v(l,leave,0)+#define spa_loop_control_iterate(l,...) spa_loop_control_method_r(l,iterate,0,__VA_ARGS__)+#define spa_loop_control_check(l) spa_loop_control_method_r(l,check,1)++#define spa_loop_control_iterate_fast(l,...) spa_loop_control_method_fast_r(l,iterate,0,__VA_ARGS__)++typedef void (*spa_source_io_func_t) (void *data, int fd, uint32_t mask);+typedef void (*spa_source_idle_func_t) (void *data);+typedef void (*spa_source_event_func_t) (void *data, uint64_t count);+typedef void (*spa_source_timer_func_t) (void *data, uint64_t expirations);+typedef void (*spa_source_signal_func_t) (void *data, int signal_number);++/**+ * Create sources for an event loop+ */+struct spa_loop_utils_methods {+ /* the version of this structure. This can be used to expand this+ * structure in the future */+#define SPA_VERSION_LOOP_UTILS_METHODS 0+ uint32_t version;++ struct spa_source *(*add_io) (void *object,+ int fd,+ uint32_t mask,+ bool close,+ spa_source_io_func_t func, void *data);++ int (*update_io) (void *object, struct spa_source *source, uint32_t mask);++ struct spa_source *(*add_idle) (void *object,+ bool enabled,+ spa_source_idle_func_t func, void *data);+ int (*enable_idle) (void *object, struct spa_source *source, bool enabled);++ struct spa_source *(*add_event) (void *object,+ spa_source_event_func_t func, void *data);+ int (*signal_event) (void *object, struct spa_source *source);++ struct spa_source *(*add_timer) (void *object,+ spa_source_timer_func_t func, void *data);+ int (*update_timer) (void *object,+ struct spa_source *source,+ struct timespec *value,+ struct timespec *interval,+ bool absolute);+ struct spa_source *(*add_signal) (void *object,+ int signal_number,+ spa_source_signal_func_t func, void *data);++ /** destroy a source allocated with this interface. This function+ * should only be called when the loop is not running or from the+ * context of the running loop */+ void (*destroy_source) (void *object, struct spa_source *source);+};++#define spa_loop_utils_method_v(o,method,version,...) \+({ \+ struct spa_loop_utils *_o = o; \+ spa_interface_call(&_o->iface, \+ struct spa_loop_utils_methods, \+ method, version, ##__VA_ARGS__); \+})++#define spa_loop_utils_method_r(o,method,version,...) \+({ \+ int _res = -ENOTSUP; \+ struct spa_loop_utils *_o = o; \+ spa_interface_call_res(&_o->iface, \+ struct spa_loop_utils_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})+#define spa_loop_utils_method_s(o,method,version,...) \+({ \+ struct spa_source *_res = NULL; \+ struct spa_loop_utils *_o = o; \+ spa_interface_call_res(&_o->iface, \+ struct spa_loop_utils_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})+++#define spa_loop_utils_add_io(l,...) spa_loop_utils_method_s(l,add_io,0,__VA_ARGS__)+#define spa_loop_utils_update_io(l,...) spa_loop_utils_method_r(l,update_io,0,__VA_ARGS__)+#define spa_loop_utils_add_idle(l,...) spa_loop_utils_method_s(l,add_idle,0,__VA_ARGS__)+#define spa_loop_utils_enable_idle(l,...) spa_loop_utils_method_r(l,enable_idle,0,__VA_ARGS__)+#define spa_loop_utils_add_event(l,...) spa_loop_utils_method_s(l,add_event,0,__VA_ARGS__)+#define spa_loop_utils_signal_event(l,...) spa_loop_utils_method_r(l,signal_event,0,__VA_ARGS__)+#define spa_loop_utils_add_timer(l,...) spa_loop_utils_method_s(l,add_timer,0,__VA_ARGS__)+#define spa_loop_utils_update_timer(l,...) spa_loop_utils_method_r(l,update_timer,0,__VA_ARGS__)+#define spa_loop_utils_add_signal(l,...) spa_loop_utils_method_s(l,add_signal,0,__VA_ARGS__)+#define spa_loop_utils_destroy_source(l,...) spa_loop_utils_method_v(l,destroy_source,0,__VA_ARGS__)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_LOOP_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/plugin.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/plugin.hnew file mode 100644index 000000000..e2e6d469c--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/plugin.h@@ -0,0 +1,209 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_PLUGIN_H+#define SPA_PLUGIN_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>+#include <spa/utils/dict.h>++/**+ * \defgroup spa_handle Plugin Handle+ * SPA plugin handle and factory interfaces+ */++/**+ * \addtogroup spa_handle+ * \{+ */++struct spa_handle {+ /** Version of this struct */+#define SPA_VERSION_HANDLE 0+ uint32_t version;++ /**+ * Get the interface provided by \a handle with \a type.+ *+ * \a interface is always a struct spa_interface but depending on+ * \a type, the struct might contain other information.+ *+ * \param handle a spa_handle+ * \param type the interface type+ * \param interface result to hold the interface.+ * \return 0 on success+ * -ENOTSUP when there are no interfaces+ * -EINVAL when handle or info is NULL+ */+ int (*get_interface) (struct spa_handle *handle, const char *type, void **interface);+ /**+ * Clean up the memory of \a handle. After this, \a handle should not be used+ * anymore.+ *+ * \param handle a pointer to memory+ * \return 0 on success+ */+ int (*clear) (struct spa_handle *handle);+};++#define spa_handle_get_interface(h,...) (h)->get_interface((h),__VA_ARGS__)+#define spa_handle_clear(h) (h)->clear((h))++/**+ * This structure lists the information about available interfaces on+ * handles.+ */+struct spa_interface_info {+ const char *type; /*< the type of the interface, can be+ * used to get the interface */+};++/**+ * Extra supporting infrastructure passed to the init() function of+ * a factory. It can be extra information or interfaces such as logging.+ */+struct spa_support {+ const char *type; /*< the type of the support item */+ void *data; /*< specific data for the item */+};++/** Find a support item of the given type */+static inline void *spa_support_find(const struct spa_support *support,+ uint32_t n_support,+ const char *type)+{+ uint32_t i;+ for (i = 0; i < n_support; i++) {+ if (strcmp(support[i].type, type) == 0)+ return support[i].data;+ }+ return NULL;+}++#define SPA_SUPPORT_INIT(type,data) ((struct spa_support) { (type), (data) })++struct spa_handle_factory {+ /** The version of this structure */+#define SPA_VERSION_HANDLE_FACTORY 1+ uint32_t version;+ /**+ * The name of the factory contains a logical name that describes+ * the function of the handle. Other plugins might contain an alternative+ * implementation with the same name.+ *+ * See utils/names.h for the list of standard names.+ *+ * Examples include:+ *+ * api.alsa.pcm.sink: an object to write PCM samples to an alsa PLAYBACK+ * device+ * api.v4l2.source: an object to read from a v4l2 source.+ */+ const char *name;+ /**+ * Extra information about the handles of this factory.+ */+ const struct spa_dict *info;+ /**+ * Get the size of handles from this factory.+ *+ * \param factory a spa_handle_factory+ * \param params extra parameters that determine the size of the+ * handle.+ */+ size_t (*get_size) (const struct spa_handle_factory *factory,+ const struct spa_dict *params);++ /**+ * Initialize an instance of this factory. The caller should allocate+ * memory at least size bytes and pass this as \a handle.+ *+ * \a support can optionally contain extra interfaces or data items that the+ * plugin can use such as a logger.+ *+ * \param factory a spa_handle_factory+ * \param handle a pointer to memory+ * \param info extra handle specific information, usually obtained+ * from a spa_device. This can be used to configure the handle.+ * \param support support items+ * \param n_support number of elements in \a support+ * \return 0 on success+ * < 0 errno type error+ */+ int (*init) (const struct spa_handle_factory *factory,+ struct spa_handle *handle,+ const struct spa_dict *info,+ const struct spa_support *support,+ uint32_t n_support);++ /**+ * spa_handle_factory::enum_interface_info:+ * \param factory: a #spa_handle_factory+ * \param info: result to hold spa_interface_info.+ * \param index: index to keep track of the enumeration, 0 for first item+ *+ * Enumerate the interface information for \a factory.+ *+ * \return 1 when an item is available+ * 0 when no more items are available+ * < 0 errno type error+ */+ int (*enum_interface_info) (const struct spa_handle_factory *factory,+ const struct spa_interface_info **info,+ uint32_t *index);+};++#define spa_handle_factory_get_size(h,...) (h)->get_size((h),__VA_ARGS__)+#define spa_handle_factory_init(h,...) (h)->init((h),__VA_ARGS__)+#define spa_handle_factory_enum_interface_info(h,...) (h)->enum_interface_info((h),__VA_ARGS__)++/**+ * The function signature of the entry point in a plugin.+ *+ * \param factory a location to hold the factory result+ * \param index index to keep track of the enumeration+ * \return 1 on success+ * 0 when there are no more factories+ * -EINVAL when factory is NULL+ */+typedef int (*spa_handle_factory_enum_func_t) (const struct spa_handle_factory **factory,+ uint32_t *index);++#define SPA_HANDLE_FACTORY_ENUM_FUNC_NAME "spa_handle_factory_enum"++/**+ * The entry point in a plugin.+ *+ * \param factory a location to hold the factory result+ * \param index index to keep track of the enumeration+ * \return 1 on success+ * 0 when no more items are available+ * < 0 errno type error+ */+int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index);++++#define SPA_KEY_FACTORY_NAME "factory.name" /**< the name of a factory */+#define SPA_KEY_FACTORY_AUTHOR "factory.author" /**< a comma separated list of factory authors */+#define SPA_KEY_FACTORY_DESCRIPTION "factory.description" /**< description of a factory */+#define SPA_KEY_FACTORY_USAGE "factory.usage" /**< usage of a factory */++#define SPA_KEY_LIBRARY_NAME "library.name" /**< the name of a library. This is usually+ * the filename of the plugin without the+ * path or the plugin extension. */++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_PLUGIN_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/system.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/system.hnew file mode 100644index 000000000..9ea41bce8--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/system.h@@ -0,0 +1,144 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2019 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_SYSTEM_H+#define SPA_SYSTEM_H++#ifdef __cplusplus+extern "C" {+#endif++struct itimerspec;++#include <time.h>+#include <sys/types.h>++#include <spa/utils/defs.h>+#include <spa/utils/hook.h>++/** \defgroup spa_system System+ * I/O, clock, polling, timer, and signal interfaces+ */++/**+ * \addtogroup spa_system+ * \{+ */++/**+ * a collection of core system functions+ */+#define SPA_TYPE_INTERFACE_System SPA_TYPE_INFO_INTERFACE_BASE "System"+#define SPA_TYPE_INTERFACE_DataSystem SPA_TYPE_INFO_INTERFACE_BASE "DataSystem"++#define SPA_VERSION_SYSTEM 0+struct spa_system { struct spa_interface iface; };++/* IO events */+#define SPA_IO_IN (1 << 0)+#define SPA_IO_OUT (1 << 2)+#define SPA_IO_ERR (1 << 3)+#define SPA_IO_HUP (1 << 4)++/* flags */+#define SPA_FD_CLOEXEC (1<<0)+#define SPA_FD_NONBLOCK (1<<1)+#define SPA_FD_EVENT_SEMAPHORE (1<<2)+#define SPA_FD_TIMER_ABSTIME (1<<3)+#define SPA_FD_TIMER_CANCEL_ON_SET (1<<4)++struct spa_poll_event {+ uint32_t events;+ void *data;+};++struct spa_system_methods {+#define SPA_VERSION_SYSTEM_METHODS 0+ uint32_t version;++ /* read/write/ioctl */+ ssize_t (*read) (void *object, int fd, void *buf, size_t count);+ ssize_t (*write) (void *object, int fd, const void *buf, size_t count);+ int (*ioctl) (void *object, int fd, unsigned long request, ...);+ int (*close) (void *object, int fd);++ /* clock */+ int (*clock_gettime) (void *object,+ int clockid, struct timespec *value);+ int (*clock_getres) (void *object,+ int clockid, struct timespec *res);++ /* poll */+ int (*pollfd_create) (void *object, int flags);+ int (*pollfd_add) (void *object, int pfd, int fd, uint32_t events, void *data);+ int (*pollfd_mod) (void *object, int pfd, int fd, uint32_t events, void *data);+ int (*pollfd_del) (void *object, int pfd, int fd);+ int (*pollfd_wait) (void *object, int pfd,+ struct spa_poll_event *ev, int n_ev, int timeout);++ /* timers */+ int (*timerfd_create) (void *object, int clockid, int flags);+ int (*timerfd_settime) (void *object,+ int fd, int flags,+ const struct itimerspec *new_value,+ struct itimerspec *old_value);+ int (*timerfd_gettime) (void *object,+ int fd, struct itimerspec *curr_value);+ int (*timerfd_read) (void *object, int fd, uint64_t *expirations);++ /* events */+ int (*eventfd_create) (void *object, int flags);+ int (*eventfd_write) (void *object, int fd, uint64_t count);+ int (*eventfd_read) (void *object, int fd, uint64_t *count);++ /* signals */+ int (*signalfd_create) (void *object, int signal, int flags);+ int (*signalfd_read) (void *object, int fd, int *signal);+};++#define spa_system_method_r(o,method,version,...) \+({ \+ volatile int _res = -ENOTSUP; \+ struct spa_system *_o = o; \+ spa_interface_call_fast_res(&_o->iface, \+ struct spa_system_methods, _res, \+ method, version, ##__VA_ARGS__); \+ _res; \+})++#define spa_system_read(s,...) spa_system_method_r(s,read,0,__VA_ARGS__)+#define spa_system_write(s,...) spa_system_method_r(s,write,0,__VA_ARGS__)+#define spa_system_ioctl(s,...) spa_system_method_r(s,ioctl,0,__VA_ARGS__)+#define spa_system_close(s,...) spa_system_method_r(s,close,0,__VA_ARGS__)++#define spa_system_clock_gettime(s,...) spa_system_method_r(s,clock_gettime,0,__VA_ARGS__)+#define spa_system_clock_getres(s,...) spa_system_method_r(s,clock_getres,0,__VA_ARGS__)++#define spa_system_pollfd_create(s,...) spa_system_method_r(s,pollfd_create,0,__VA_ARGS__)+#define spa_system_pollfd_add(s,...) spa_system_method_r(s,pollfd_add,0,__VA_ARGS__)+#define spa_system_pollfd_mod(s,...) spa_system_method_r(s,pollfd_mod,0,__VA_ARGS__)+#define spa_system_pollfd_del(s,...) spa_system_method_r(s,pollfd_del,0,__VA_ARGS__)+#define spa_system_pollfd_wait(s,...) spa_system_method_r(s,pollfd_wait,0,__VA_ARGS__)++#define spa_system_timerfd_create(s,...) spa_system_method_r(s,timerfd_create,0,__VA_ARGS__)+#define spa_system_timerfd_settime(s,...) spa_system_method_r(s,timerfd_settime,0,__VA_ARGS__)+#define spa_system_timerfd_gettime(s,...) spa_system_method_r(s,timerfd_gettime,0,__VA_ARGS__)+#define spa_system_timerfd_read(s,...) spa_system_method_r(s,timerfd_read,0,__VA_ARGS__)++#define spa_system_eventfd_create(s,...) spa_system_method_r(s,eventfd_create,0,__VA_ARGS__)+#define spa_system_eventfd_write(s,...) spa_system_method_r(s,eventfd_write,0,__VA_ARGS__)+#define spa_system_eventfd_read(s,...) spa_system_method_r(s,eventfd_read,0,__VA_ARGS__)++#define spa_system_signalfd_create(s,...) spa_system_method_r(s,signalfd_create,0,__VA_ARGS__)+#define spa_system_signalfd_read(s,...) spa_system_method_r(s,signalfd_read,0,__VA_ARGS__)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_SYSTEM_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/thread.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/thread.hnew file mode 100644index 000000000..1e5f837b8--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/support/thread.h@@ -0,0 +1,129 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2021 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_THREAD_H+#define SPA_THREAD_H++#ifdef __cplusplus+extern "C" {+#endif++#include <string.h>+#include <errno.h>++#include <spa/utils/defs.h>+#include <spa/utils/hook.h>+#include <spa/utils/dict.h>++/** \defgroup spa_thread Thread+ * Threading utility interfaces+ */++/**+ * \addtogroup spa_thread+ * \{+ */++/** a thread object.+ * This can be cast to a platform native thread, like pthread on posix systems+ */+#define SPA_TYPE_INFO_Thread SPA_TYPE_INFO_POINTER_BASE "Thread"+struct spa_thread;++#define SPA_TYPE_INTERFACE_ThreadUtils SPA_TYPE_INFO_INTERFACE_BASE "ThreadUtils"+#define SPA_VERSION_THREAD_UTILS 0+struct spa_thread_utils { struct spa_interface iface; };++/** thread utils */+struct spa_thread_utils_methods {+#define SPA_VERSION_THREAD_UTILS_METHODS 0+ uint32_t version;++ /** create a new thread that runs \a start with \a arg */+ struct spa_thread * (*create) (void *object, const struct spa_dict *props,+ void *(*start)(void*), void *arg);+ /** stop and join a thread */+ int (*join)(void *object, struct spa_thread *thread, void **retval);++ /** get realtime priority range for threads created with \a props */+ int (*get_rt_range) (void *object, const struct spa_dict *props, int *min, int *max);+ /** acquire realtime priority, a priority of -1 refers to the priority+ * configured in the realtime module+ */+ int (*acquire_rt) (void *object, struct spa_thread *thread, int priority);+ /** drop realtime priority */+ int (*drop_rt) (void *object, struct spa_thread *thread);+};++/** \copydoc spa_thread_utils_methods.create+ * \sa spa_thread_utils_methods.create */+static inline struct spa_thread *spa_thread_utils_create(struct spa_thread_utils *o,+ const struct spa_dict *props, void *(*start_routine)(void*), void *arg)+{+ struct spa_thread *res = NULL;+ spa_interface_call_res(&o->iface,+ struct spa_thread_utils_methods, res, create, 0,+ props, start_routine, arg);+ return res;+}++/** \copydoc spa_thread_utils_methods.join+ * \sa spa_thread_utils_methods.join */+static inline int spa_thread_utils_join(struct spa_thread_utils *o,+ struct spa_thread *thread, void **retval)+{+ int res = -ENOTSUP;+ spa_interface_call_res(&o->iface,+ struct spa_thread_utils_methods, res, join, 0,+ thread, retval);+ return res;+}++/** \copydoc spa_thread_utils_methods.get_rt_range+ * \sa spa_thread_utils_methods.get_rt_range */+static inline int spa_thread_utils_get_rt_range(struct spa_thread_utils *o,+ const struct spa_dict *props, int *min, int *max)+{+ int res = -ENOTSUP;+ spa_interface_call_res(&o->iface,+ struct spa_thread_utils_methods, res, get_rt_range, 0,+ props, min, max);+ return res;+}++/** \copydoc spa_thread_utils_methods.acquire_rt+ * \sa spa_thread_utils_methods.acquire_rt */+static inline int spa_thread_utils_acquire_rt(struct spa_thread_utils *o,+ struct spa_thread *thread, int priority)+{+ int res = -ENOTSUP;+ spa_interface_call_res(&o->iface,+ struct spa_thread_utils_methods, res, acquire_rt, 0,+ thread, priority);+ return res;+}++/** \copydoc spa_thread_utils_methods.drop_rt+ * \sa spa_thread_utils_methods.drop_rt */+static inline int spa_thread_utils_drop_rt(struct spa_thread_utils *o,+ struct spa_thread *thread)+{+ int res = -ENOTSUP;+ spa_interface_call_res(&o->iface,+ struct spa_thread_utils_methods, res, drop_rt, 0, thread);+ return res;+}++#define SPA_KEY_THREAD_NAME "thread.name" /* the thread name */+#define SPA_KEY_THREAD_STACK_SIZE "thread.stack-size" /* the stack size of the thread */++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_THREAD_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/defs.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/defs.hnew file mode 100644index 000000000..393b1f334--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/defs.h@@ -0,0 +1,386 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_UTILS_DEFS_H+#define SPA_UTILS_DEFS_H++#ifdef __cplusplus+extern "C" {+# if __cplusplus >= 201103L+# define SPA_STATIC_ASSERT_IMPL(expr, msg, ...) static_assert(expr, msg)+# endif+#else+# include <stdbool.h>+# if __STDC_VERSION__ >= 201112L+# define SPA_STATIC_ASSERT_IMPL(expr, msg, ...) _Static_assert(expr, msg)+# endif+#endif+#ifndef SPA_STATIC_ASSERT_IMPL+#define SPA_STATIC_ASSERT_IMPL(expr, ...) \+ ((void)sizeof(struct { int spa_static_assertion_failed : 2 * !!(expr) - 1; }))+#endif++#define SPA_STATIC_ASSERT(expr, ...) SPA_STATIC_ASSERT_IMPL(expr, ## __VA_ARGS__, "`" #expr "` evaluated to false")++#include <inttypes.h>+#include <signal.h>+#include <stdlib.h>+#include <string.h>+#include <stddef.h>+#include <stdio.h>++/**+ * \defgroup spa_utils_defs Miscellaneous+ * Helper macros and functions+ */++/**+ * \addtogroup spa_utils_defs+ * \{+ */++/**+ * SPA_FALLTHROUGH is an annotation to suppress compiler warnings about switch+ * cases that fall through without a break or return statement. SPA_FALLTHROUGH+ * is only needed on cases that have code:+ *+ * switch (foo) {+ * case 1: // These cases have no code. No fallthrough annotations are needed.+ * case 2:+ * case 3:+ * foo = 4; // This case has code, so a fallthrough annotation is needed:+ * SPA_FALLTHROUGH;+ * default:+ * return foo;+ * }+ */+#if defined(__clang__) && defined(__cplusplus) && __cplusplus >= 201103L+ /* clang's fallthrough annotations are only available starting in C++11. */+# define SPA_FALLTHROUGH [[clang::fallthrough]];+#elif __GNUC__ >= 7 || __clang_major__ >= 10+# define SPA_FALLTHROUGH __attribute__ ((fallthrough));+#else+# define SPA_FALLTHROUGH /* FALLTHROUGH */+#endif++#define SPA_FLAG_MASK(field,mask,flag) (((field) & (mask)) == (flag))+#define SPA_FLAG_IS_SET(field,flag) SPA_FLAG_MASK(field, flag, flag)++#define SPA_FLAG_SET(field,flag) ((field) |= (flag))+#define SPA_FLAG_CLEAR(field, flag) \+({ \+ SPA_STATIC_ASSERT(__builtin_constant_p(flag) ? \+ (__typeof__(flag))(__typeof__(field))(__typeof__(flag))(flag) == (flag) : \+ sizeof(field) >= sizeof(flag), \+ "truncation problem when masking " #field \+ " with ~" #flag); \+ ((field) &= ~(__typeof__(field))(flag)); \+})+#define SPA_FLAG_UPDATE(field,flag,val) ((val) ? SPA_FLAG_SET((field),(flag)) : SPA_FLAG_CLEAR((field),(flag)))++enum spa_direction {+ SPA_DIRECTION_INPUT = 0,+ SPA_DIRECTION_OUTPUT = 1,+};++#define SPA_DIRECTION_REVERSE(d) ((d) ^ 1)++#define SPA_RECTANGLE(width,height) ((struct spa_rectangle){ (width), (height) })+struct spa_rectangle {+ uint32_t width;+ uint32_t height;+};++#define SPA_POINT(x,y) ((struct spa_point){ (x), (y) })+struct spa_point {+ int32_t x;+ int32_t y;+};++#define SPA_REGION(x,y,width,height) ((struct spa_region){ SPA_POINT(x,y), SPA_RECTANGLE(width,height) })+struct spa_region {+ struct spa_point position;+ struct spa_rectangle size;+};++#define SPA_FRACTION(num,denom) ((struct spa_fraction){ (num), (denom) })+struct spa_fraction {+ uint32_t num;+ uint32_t denom;+};++#define SPA_N_ELEMENTS(arr) (sizeof(arr) / sizeof((arr)[0]))+/**+ * Array iterator macro. Usage:+ * ```c+ * struct foo array[16];+ * struct foo *f;+ * SPA_FOR_EACH_ELEMENT(array, f) {+ * f->bar = baz;+ * }+ * ```+ */+#define SPA_FOR_EACH_ELEMENT(arr, ptr) \+ for ((ptr) = arr; (void*)(ptr) < SPA_PTROFF(arr, sizeof(arr), void); (ptr)++)++#define SPA_FOR_EACH_ELEMENT_VAR(arr, var) \+ for (__typeof__((arr)[0])* var = arr; (void*)(var) < SPA_PTROFF(arr, sizeof(arr), void); (var)++)++#define SPA_ABS(a) \+({ \+ __typeof__(a) _a = (a); \+ SPA_LIKELY(_a >= 0) ? _a : -_a; \+})+#define SPA_MIN(a,b) \+({ \+ __typeof__(a) _min_a = (a); \+ __typeof__(b) _min_b = (b); \+ SPA_LIKELY(_min_a <= _min_b) ? _min_a : _min_b; \+})+#define SPA_MAX(a,b) \+({ \+ __typeof__(a) _max_a = (a); \+ __typeof__(b) _max_b = (b); \+ SPA_LIKELY(_max_a >= _max_b) ? _max_a : _max_b; \+})+#define SPA_CLAMP(v,low,high) \+({ \+ __typeof__(v) _v = (v); \+ __typeof__(low) _low = (low); \+ __typeof__(high) _high = (high); \+ SPA_MIN(SPA_MAX(_v, _low), _high); \+})++#define SPA_CLAMPF(v,low,high) \+({ \+ fminf(fmaxf(v, low), high); \+})+#define SPA_CLAMPD(v,low,high) \+({ \+ fmin(fmax(v, low), high); \+})+++#define SPA_SWAP(a,b) \+({ \+ __typeof__(a) _t = (a); \+ (a) = b; (b) = _t; \+})++#define SPA_TYPECHECK(type,x) \+({ type _dummy; \+ typeof(x) _dummy2; \+ (void)(&_dummy == &_dummy2); \+ x; \+})++/**+ * Return the address (buffer + offset) as pointer of \a type+ */+#define SPA_PTROFF(ptr_,offset_,type_) ((type_*)((uintptr_t)(ptr_) + (ptrdiff_t)(offset_)))+#define SPA_PTROFF_ALIGN(ptr_,offset_,alignment_,type_) \+ SPA_PTR_ALIGN(SPA_PTROFF(ptr_,offset_,type_),alignment_,type_)+++/**+ * Deprecated, use SPA_PTROFF and SPA_PTROFF_ALIGN instead+ */+#define SPA_MEMBER(b,o,t) SPA_PTROFF(b,o,t)+#define SPA_MEMBER_ALIGN(b,o,a,t) SPA_PTROFF_ALIGN(b,o,a,t)++#define SPA_CONTAINER_OF(p,t,m) ((t*)((uintptr_t)(p) - offsetof(t,m)))++#define SPA_PTRDIFF(p1,p2) ((intptr_t)(p1) - (intptr_t)(p2))++#define SPA_PTR_TO_INT(p) ((int) ((intptr_t) (p)))+#define SPA_INT_TO_PTR(u) ((void*) ((intptr_t) (u)))++#define SPA_PTR_TO_UINT32(p) ((uint32_t) ((uintptr_t) (p)))+#define SPA_UINT32_TO_PTR(u) ((void*) ((uintptr_t) (u)))++#define SPA_TIME_INVALID ((int64_t)INT64_MIN)+#define SPA_IDX_INVALID ((unsigned int)-1)+#define SPA_ID_INVALID ((uint32_t)0xffffffff)++#define SPA_NSEC_PER_SEC (1000000000LL)+#define SPA_NSEC_PER_MSEC (1000000ll)+#define SPA_NSEC_PER_USEC (1000ll)+#define SPA_USEC_PER_SEC (1000000ll)+#define SPA_USEC_PER_MSEC (1000ll)+#define SPA_MSEC_PER_SEC (1000ll)++#define SPA_TIMESPEC_TO_NSEC(ts) ((ts)->tv_sec * SPA_NSEC_PER_SEC + (ts)->tv_nsec)+#define SPA_TIMESPEC_TO_USEC(ts) ((ts)->tv_sec * SPA_USEC_PER_SEC + (ts)->tv_nsec / SPA_NSEC_PER_USEC)+#define SPA_TIMEVAL_TO_NSEC(tv) ((tv)->tv_sec * SPA_NSEC_PER_SEC + (tv)->tv_usec * SPA_NSEC_PER_USEC)+#define SPA_TIMEVAL_TO_USEC(tv) ((tv)->tv_sec * SPA_USEC_PER_SEC + (tv)->tv_usec)++#ifdef __GNUC__+#define SPA_PRINTF_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1)))+#define SPA_FORMAT_ARG_FUNC(arg1) __attribute__((format_arg(arg1)))+#define SPA_ALIGNED(align) __attribute__((aligned(align)))+#define SPA_DEPRECATED __attribute__ ((deprecated))+#define SPA_EXPORT __attribute__((visibility("default")))+#define SPA_SENTINEL __attribute__((__sentinel__))+#define SPA_UNUSED __attribute__ ((unused))+#define SPA_NORETURN __attribute__ ((noreturn))+#define SPA_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))+#else+#define SPA_PRINTF_FUNC(fmt, arg1)+#define SPA_FORMAT_ARG_FUNC(arg1)+#define SPA_ALIGNED(align)+#define SPA_DEPRECATED+#define SPA_EXPORT+#define SPA_SENTINEL+#define SPA_UNUSED+#define SPA_NORETURN+#define SPA_WARN_UNUSED_RESULT+#endif++#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L+#define SPA_RESTRICT restrict+#elif defined(__GNUC__) && __GNUC__ >= 4+#define SPA_RESTRICT __restrict__+#else+#define SPA_RESTRICT+#endif++#define SPA_ROUND_DOWN(num,value) \+({ \+ __typeof__(num) _num = (num); \+ ((_num) - ((_num) % (value))); \+})+#define SPA_ROUND_UP(num,value) \+({ \+ __typeof__(value) _v = (value); \+ ((((num) + (_v) - 1) / (_v)) * (_v)); \+})++#define SPA_ROUND_MASK(num,mask) ((__typeof__(num))((mask)-1))++#define SPA_ROUND_DOWN_N(num,align) ((num) & ~SPA_ROUND_MASK(num, align))+#define SPA_ROUND_UP_N(num,align) ((((num)-1) | SPA_ROUND_MASK(num, align))+1)++#define SPA_SCALE32_UP(val,num,denom) \+({ \+ uint64_t _val = (val); \+ uint64_t _denom = (denom); \+ (uint32_t)(((_val) * (num) + (_denom)-1) / (_denom)); \+})+++#define SPA_PTR_ALIGNMENT(p,align) ((intptr_t)(p) & ((align)-1))+#define SPA_IS_ALIGNED(p,align) (SPA_PTR_ALIGNMENT(p,align) == 0)+#define SPA_PTR_ALIGN(p,align,type) ((type*)SPA_ROUND_UP_N((intptr_t)(p), (intptr_t)(align)))++#ifndef SPA_LIKELY+#ifdef __GNUC__+#define SPA_LIKELY(x) (__builtin_expect(!!(x),1))+#define SPA_UNLIKELY(x) (__builtin_expect(!!(x),0))+#else+#define SPA_LIKELY(x) (x)+#define SPA_UNLIKELY(x) (x)+#endif+#endif++#define SPA_STRINGIFY_1(...) #__VA_ARGS__+#define SPA_STRINGIFY(...) SPA_STRINGIFY_1(__VA_ARGS__)++#define spa_return_if_fail(expr) \+ do { \+ if (SPA_UNLIKELY(!(expr))) { \+ fprintf(stderr, "'%s' failed at %s:%u %s()\n", \+ #expr , __FILE__, __LINE__, __func__); \+ return; \+ } \+ } while(false)++#define spa_return_val_if_fail(expr, val) \+ do { \+ if (SPA_UNLIKELY(!(expr))) { \+ fprintf(stderr, "'%s' failed at %s:%u %s()\n", \+ #expr , __FILE__, __LINE__, __func__); \+ return (val); \+ } \+ } while(false)++/* spa_assert_se() is an assert which guarantees side effects of x,+ * i.e. is never optimized away, regardless of NDEBUG or FASTPATH. */+#ifndef __COVERITY__+#define spa_assert_se(expr) \+ do { \+ if (SPA_UNLIKELY(!(expr))) { \+ fprintf(stderr, "'%s' failed at %s:%u %s()\n", \+ #expr , __FILE__, __LINE__, __func__); \+ abort(); \+ } \+ } while (false)+#else+#define spa_assert_se(expr) \+ do { \+ int _unique_var = (expr); \+ if (!_unique_var) \+ abort(); \+ } while (false)+#endif++/* Does exactly nothing */+#define spa_nop() do {} while (false)++#ifdef NDEBUG+#define spa_assert(expr) spa_nop()+#elif defined (FASTPATH)+#define spa_assert(expr) spa_assert_se(expr)+#else+#define spa_assert(expr) spa_assert_se(expr)+#endif++#ifdef NDEBUG+#define spa_assert_not_reached() abort()+#else+#define spa_assert_not_reached() \+ do { \+ fprintf(stderr, "Code should not be reached at %s:%u %s()\n", \+ __FILE__, __LINE__, __func__); \+ abort(); \+ } while (false)+#endif++#define spa_memzero(x,l) (memset((x), 0, (l)))+#define spa_zero(x) (spa_memzero(&(x), sizeof(x)))++#ifdef SPA_DEBUG_MEMCPY+#define spa_memcpy(d,s,n) \+({ \+ fprintf(stderr, "%s:%u %s() memcpy(%p, %p, %zd)\n", \+ __FILE__, __LINE__, __func__, (d), (s), (size_t)(n)); \+ memcpy(d,s,n); \+})+#define spa_memmove(d,s,n) \+({ \+ fprintf(stderr, "%s:%u %s() memmove(%p, %p, %zd)\n", \+ __FILE__, __LINE__, __func__, (d), (s), (size_t)(n)); \+ memmove(d,s,n); \+})+#else+#define spa_memcpy(d,s,n) memcpy(d,s,n)+#define spa_memmove(d,s,n) memmove(d,s,n)+#endif++#define spa_aprintf(_fmt, ...) \+({ \+ char *_strp; \+ if (asprintf(&(_strp), (_fmt), ## __VA_ARGS__ ) == -1) \+ _strp = NULL; \+ _strp; \+})++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_UTILS_DEFS_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/dict.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/dict.hnew file mode 100644index 000000000..126f469ec--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/dict.h@@ -0,0 +1,100 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_DICT_H+#define SPA_DICT_H++#ifdef __cplusplus+extern "C" {+#endif++#include <string.h>++#include <spa/utils/defs.h>++/**+ * \defgroup spa_dict Dictionary+ * Dictionary data structure+ */++/**+ * \addtogroup spa_dict+ * \{+ */++struct spa_dict_item {+ const char *key;+ const char *value;+};++#define SPA_DICT_ITEM_INIT(key,value) ((struct spa_dict_item) { (key), (value) })++struct spa_dict {+#define SPA_DICT_FLAG_SORTED (1<<0) /**< items are sorted */+ uint32_t flags;+ uint32_t n_items;+ const struct spa_dict_item *items;+};++#define SPA_DICT_INIT(items,n_items) ((struct spa_dict) { 0, (n_items), (items) })+#define SPA_DICT_INIT_ARRAY(items) ((struct spa_dict) { 0, SPA_N_ELEMENTS(items), (items) })++#define spa_dict_for_each(item, dict) \+ for ((item) = (dict)->items; \+ (item) < &(dict)->items[(dict)->n_items]; \+ (item)++)++static inline int spa_dict_item_compare(const void *i1, const void *i2)+{+ const struct spa_dict_item *it1 = (const struct spa_dict_item *)i1,+ *it2 = (const struct spa_dict_item *)i2;+ return strcmp(it1->key, it2->key);+}++static inline void spa_dict_qsort(struct spa_dict *dict)+{+ if (dict->n_items > 0)+ qsort((void*)dict->items, dict->n_items, sizeof(struct spa_dict_item),+ spa_dict_item_compare);+ SPA_FLAG_SET(dict->flags, SPA_DICT_FLAG_SORTED);+}++static inline const struct spa_dict_item *spa_dict_lookup_item(const struct spa_dict *dict,+ const char *key)+{+ const struct spa_dict_item *item;++ if (SPA_FLAG_IS_SET(dict->flags, SPA_DICT_FLAG_SORTED) &&+ dict->n_items > 0) {+ struct spa_dict_item k = SPA_DICT_ITEM_INIT(key, NULL);+ item = (const struct spa_dict_item *)bsearch(&k,+ (const void *) dict->items, dict->n_items,+ sizeof(struct spa_dict_item),+ spa_dict_item_compare);+ if (item != NULL)+ return item;+ } else {+ spa_dict_for_each(item, dict) {+ if (!strcmp(item->key, key))+ return item;+ }+ }+ return NULL;+}++static inline const char *spa_dict_lookup(const struct spa_dict *dict, const char *key)+{+ const struct spa_dict_item *item = spa_dict_lookup_item(dict, key);+ return item ? item->value : NULL;+}++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_DICT_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/hook.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/hook.hnew file mode 100644index 000000000..aea18d28e--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/hook.h@@ -0,0 +1,471 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_HOOK_H+#define SPA_HOOK_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>+#include <spa/utils/list.h>++/** \defgroup spa_interfaces Interfaces+ *+ * \brief Generic implementation of implementation-independent interfaces+ *+ * A SPA Interface is a generic struct that, together with a few macros,+ * provides a generic way of invoking methods on objects without knowing the+ * details of the implementation.+ *+ * The primary interaction with interfaces is through macros that expand into+ * the right method call. For the implementation of an interface, we need two+ * structs and a macro to invoke the `bar` method:+ *+ * \code{.c}+ * // this struct must be public and defines the interface to a+ * // struct foo+ * struct foo_methods {+ * uint32_t version;+ * void (*bar)(void *object, const char *msg);+ * };+ *+ * // this struct does not need to be public+ * struct foo {+ * struct spa_interface iface; // must be first element, see foo_bar()+ * int some_other_field;+ * ...+ * };+ *+ * // if struct foo is private, we need to cast to a+ * // generic spa_interface object+ * #define foo_bar(obj, ...) ({ \+ * struct foo *f = obj;+ * spa_interface_call((struct spa_interface *)f, // pointer to spa_interface in foo+ * struct foo_methods, // type of callbacks+ * bar, // name of methods+ * 0, // hardcoded version to match foo_methods->version+ * __VA_ARGS__ // pass rest of args through+ * );/+ * })+ * \endcode+ *+ * The `struct foo_methods` and the invocation macro `foo_bar()` must be+ * available to the caller. The implementation of `struct foo` can be private.+ *+ * \code{.c}+ * void main(void) {+ * struct foo *myfoo = get_foo_from_somewhere();+ * foo_bar(myfoo, "Invoking bar() on myfoo");+ * }+ * \endcode+ * The expansion of `foo_bar()` resolves roughly into this code:+ * \code{.c}+ * void main(void) {+ * struct foo *myfoo = get_foo_from_somewhere();+ * // foo_bar(myfoo, "Invoking bar() on myfoo");+ * const struct foo_methods *methods = ((struct spa_interface*)myfoo)->cb;+ * if (0 >= methods->version && // version check+ * methods->bar) // compile error if this function does not exist,+ * methods->bar(myfoo, "Invoking bar() on myfoo");+ * }+ * \endcode+ *+ * The typecast used in `foo_bar()` allows `struct foo` to be opaque to the+ * caller. The implementation may assign the callback methods at object+ * instantiation, and the caller will transparently invoke the method on the+ * given object. For example, the following code assigns a different `bar()` method on+ * Mondays - the caller does not need to know this.+ * \code{.c}+ *+ * static void bar_stdout(struct foo *f, const char *msg) {+ * printf(msg);+ * }+ * static void bar_stderr(struct foo *f, const char *msg) {+ * fprintf(stderr, msg);+ * }+ *+ * struct foo* get_foo_from_somewhere() {+ * struct foo *f = calloc(sizeof struct foo);+ * // illustrative only, use SPA_INTERFACE_INIT()+ * f->iface->cb = (struct foo_methods*) { .bar = bar_stdout };+ * if (today_is_monday)+ * f->iface->cb = (struct foo_methods*) { .bar = bar_stderr };+ * return f;+ * }+ * \endcode+ */++/**+ * \addtogroup spa_interfaces+ * \{+ */++/** \struct spa_callbacks+ * Callbacks, contains the structure with functions and the data passed+ * to the functions. The structure should also contain a version field that+ * is checked. */+struct spa_callbacks {+ const void *funcs;+ void *data;+};++/** Check if a callback \a c is of at least version \a v */+#define SPA_CALLBACK_VERSION_MIN(c,v) ((c) && ((v) == 0 || (c)->version > (v)-1))++/** Check if a callback \a c has method \a m of version \a v */+#define SPA_CALLBACK_CHECK(c,m,v) (SPA_CALLBACK_VERSION_MIN(c,v) && (c)->m)++/**+ * Initialize the set of functions \a funcs as a \ref spa_callbacks, together+ * with \a _data.+ */+#define SPA_CALLBACKS_INIT(_funcs,_data) ((struct spa_callbacks){ (_funcs), (_data), })++/** \struct spa_interface+ */+struct spa_interface {+ const char *type;+ uint32_t version;+ struct spa_callbacks cb;+};++/**+ * Initialize a \ref spa_interface.+ *+ * \code{.c}+ * const static struct foo_methods foo_funcs = {+ * .bar = some_bar_implementation,+ * };+ *+ * struct foo *f = malloc(...);+ * f->iface = SPA_INTERFACE_INIT("foo type", 0, foo_funcs, NULL);+ * \endcode+ *+ */+#define SPA_INTERFACE_INIT(_type,_version,_funcs,_data) \+ ((struct spa_interface){ (_type), (_version), SPA_CALLBACKS_INIT(_funcs,_data), })++/**+ * Invoke method named \a method in the \a callbacks.+ * The \a method_type defines the type of the method struct.+ * Returns true if the method could be called, false otherwise.+ */+#define spa_callbacks_call(callbacks,type,method,vers,...) \+({ \+ const type *_f = (const type *) (callbacks)->funcs; \+ bool _res = SPA_CALLBACK_CHECK(_f,method,vers); \+ if (SPA_LIKELY(_res)) \+ _f->method((callbacks)->data, ## __VA_ARGS__); \+ _res; \+})++#define spa_callbacks_call_fast(callbacks,type,method,vers,...) \+({ \+ const type *_f = (const type *) (callbacks)->funcs; \+ _f->method((callbacks)->data, ## __VA_ARGS__); \+ true; \+})+++/**+ * True if the \a callbacks are of version \a vers, false otherwise+ */+#define spa_callback_version_min(callbacks,type,vers) \+({ \+ const type *_f = (const type *) (callbacks)->funcs; \+ SPA_CALLBACK_VERSION_MIN(_f,vers); \+})++/**+ * True if the \a callbacks contains \a method of version+ * \a vers, false otherwise+ */+#define spa_callback_check(callbacks,type,method,vers) \+({ \+ const type *_f = (const type *) (callbacks)->funcs; \+ SPA_CALLBACK_CHECK(_f,method,vers); \+})++/**+ * Invoke method named \a method in the \a callbacks.+ * The \a method_type defines the type of the method struct.+ *+ * The return value is stored in \a res.+ */+#define spa_callbacks_call_res(callbacks,type,res,method,vers,...) \+({ \+ const type *_f = (const type *) (callbacks)->funcs; \+ if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) \+ res = _f->method((callbacks)->data, ## __VA_ARGS__); \+ res; \+})+#define spa_callbacks_call_fast_res(callbacks,type,res,method,vers,...) \+({ \+ const type *_f = (const type *) (callbacks)->funcs; \+ res = _f->method((callbacks)->data, ## __VA_ARGS__); \+})++/**+ * True if the \a iface's callbacks are of version \a vers, false otherwise+ */+#define spa_interface_callback_version_min(iface,method_type,vers) \+ spa_callback_version_min(&(iface)->cb, method_type, vers)++/**+ * True if the \a iface's callback \a method is of version \a vers+ * and exists, false otherwise+ */+#define spa_interface_callback_check(iface,method_type,method,vers) \+ spa_callback_check(&(iface)->cb, method_type, method, vers)++/**+ * Invoke method named \a method in the callbacks on the given interface object.+ * The \a method_type defines the type of the method struct, not the interface+ * itself.+ */+#define spa_interface_call(iface,method_type,method,vers,...) \+ spa_callbacks_call(&(iface)->cb,method_type,method,vers,##__VA_ARGS__)++#define spa_interface_call_fast(iface,method_type,method,vers,...) \+ spa_callbacks_call_fast(&(iface)->cb,method_type,method,vers,##__VA_ARGS__)++/**+ * Invoke method named \a method in the callbacks on the given interface object.+ * The \a method_type defines the type of the method struct, not the interface+ * itself.+ *+ * The return value is stored in \a res.+ */+#define spa_interface_call_res(iface,method_type,res,method,vers,...) \+ spa_callbacks_call_res(&(iface)->cb,method_type,res,method,vers,##__VA_ARGS__)++#define spa_interface_call_fast_res(iface,method_type,res,method,vers,...) \+ spa_callbacks_call_fast_res(&(iface)->cb,method_type,res,method,vers,##__VA_ARGS__)++/**+ * \}+ */++/** \defgroup spa_hooks Hooks+ *+ * A SPA Hook is a data structure to keep track of callbacks. It is similar to+ * the \ref spa_interfaces and typically used where an implementation allows+ * for multiple external callback functions. For example, an implementation may+ * use a hook list to implement signals with each caller using a hook to+ * register callbacks to be invoked on those signals.+ *+ * The below (pseudo)code is a minimal example outlining the use of hooks:+ * \code{.c}+ * // the public interface+ * #define VERSION_BAR_EVENTS 0 // version of the vtable+ * struct bar_events {+ * uint32_t version; // NOTE: an integral member named `version`+ * // must be present in the vtable+ * void (*boom)(void *data, const char *msg);+ * };+ *+ * // private implementation+ * struct party {+ * struct spa_hook_list bar_list;+ * };+ *+ * void party_add_event_listener(struct party *p, struct spa_hook *listener,+ * const struct bar_events *events, void *data)+ * {+ * spa_hook_list_append(&p->bar_list, listener, events, data);+ * }+ *+ * static void party_on(struct party *p)+ * {+ * // NOTE: this is a macro, it evaluates to an integer,+ * // which is the number of hooks called+ * spa_hook_list_call(&p->list,+ * struct bar_events, // vtable type+ * boom, // function name+ * 0, // hardcoded version,+ * // usually the version in which `boom`+ * // has been added to the vtable+ * "party on, wayne" // function argument(s)+ * );+ * }+ * \endcode+ *+ * In the caller, the hooks can be used like this:+ * \code{.c}+ * static void boom_cb(void *data, const char *msg) {+ * // data is userdata from main()+ * printf("%s", msg);+ * }+ *+ * static const struct bar_events events = {+ * .version = VERSION_BAR_EVENTS, // version of the implemented interface+ * .boom = boom_cb,+ * };+ *+ * void main(void) {+ * void *userdata = whatever;+ * struct spa_hook hook;+ * struct party *p = start_the_party();+ *+ * party_add_event_listener(p, &hook, &events, userdata);+ *+ * mainloop();+ * return 0;+ * }+ *+ * \endcode+ */++/**+ * \addtogroup spa_hooks+ * \{+ */++/** \struct spa_hook_list+ * A list of hooks. This struct is primarily used by+ * implementation that use multiple caller-provided \ref spa_hook. */+struct spa_hook_list {+ struct spa_list list;+};+++/** \struct spa_hook+ * A hook, contains the structure with functions and the data passed+ * to the functions.+ *+ * A hook should be treated as opaque by the caller.+ */+struct spa_hook {+ struct spa_list link;+ struct spa_callbacks cb;+ /** callback and data for the hook list, private to the+ * hook_list implementor */+ void (*removed) (struct spa_hook *hook);+ void *priv;+};++/** Initialize a hook list to the empty list*/+static inline void spa_hook_list_init(struct spa_hook_list *list)+{+ spa_list_init(&list->list);+}++static inline bool spa_hook_list_is_empty(struct spa_hook_list *list)+{+ return spa_list_is_empty(&list->list);+}++/** Append a hook. */+static inline void spa_hook_list_append(struct spa_hook_list *list,+ struct spa_hook *hook,+ const void *funcs, void *data)+{+ spa_zero(*hook);+ hook->cb = SPA_CALLBACKS_INIT(funcs, data);+ spa_list_append(&list->list, &hook->link);+}++/** Prepend a hook */+static inline void spa_hook_list_prepend(struct spa_hook_list *list,+ struct spa_hook *hook,+ const void *funcs, void *data)+{+ spa_zero(*hook);+ hook->cb = SPA_CALLBACKS_INIT(funcs, data);+ spa_list_prepend(&list->list, &hook->link);+}++/** Remove a hook */+static inline void spa_hook_remove(struct spa_hook *hook)+{+ if (spa_list_is_initialized(&hook->link))+ spa_list_remove(&hook->link);+ if (hook->removed)+ hook->removed(hook);+}++/** Remove all hooks from the list */+static inline void spa_hook_list_clean(struct spa_hook_list *list)+{+ struct spa_hook *h;+ spa_list_consume(h, &list->list, link)+ spa_hook_remove(h);+}++static inline void+spa_hook_list_isolate(struct spa_hook_list *list,+ struct spa_hook_list *save,+ struct spa_hook *hook,+ const void *funcs, void *data)+{+ /* init save list and move hooks to it */+ spa_hook_list_init(save);+ spa_list_insert_list(&save->list, &list->list);+ /* init hooks and add single hook */+ spa_hook_list_init(list);+ spa_hook_list_append(list, hook, funcs, data);+}++static inline void+spa_hook_list_join(struct spa_hook_list *list,+ struct spa_hook_list *save)+{+ spa_list_insert_list(&list->list, &save->list);+}++#define spa_hook_list_call_simple(l,type,method,vers,...) \+({ \+ struct spa_hook_list *_l = l; \+ struct spa_hook *_h, *_t; \+ spa_list_for_each_safe(_h, _t, &_l->list, link) \+ spa_callbacks_call(&_h->cb,type,method,vers, ## __VA_ARGS__); \+})++/** Call all hooks in a list, starting from the given one and optionally stopping+ * after calling the first non-NULL function, returns the number of methods+ * called */+#define spa_hook_list_do_call(l,start,type,method,vers,once,...) \+({ \+ struct spa_hook_list *_list = l; \+ struct spa_list *_s = start ? (struct spa_list *)start : &_list->list; \+ struct spa_hook _cursor = { 0 }, *_ci; \+ int _count = 0; \+ spa_list_cursor_start(_cursor, _s, link); \+ spa_list_for_each_cursor(_ci, _cursor, &_list->list, link) { \+ if (spa_callbacks_call(&_ci->cb,type,method,vers, ## __VA_ARGS__)) { \+ _count++; \+ if (once) \+ break; \+ } \+ } \+ spa_list_cursor_end(_cursor, link); \+ _count; \+})++/**+ * Call the method named \a m for each element in list \a l.+ * \a t specifies the type of the callback struct.+ */+#define spa_hook_list_call(l,t,m,v,...) spa_hook_list_do_call(l,NULL,t,m,v,false,##__VA_ARGS__)+/**+ * Call the method named \a m for each element in list \a l, stopping after+ * the first invocation.+ * \a t specifies the type of the callback struct.+ */+#define spa_hook_list_call_once(l,t,m,v,...) spa_hook_list_do_call(l,NULL,t,m,v,true,##__VA_ARGS__)++#define spa_hook_list_call_start(l,s,t,m,v,...) spa_hook_list_do_call(l,s,t,m,v,false,##__VA_ARGS__)+#define spa_hook_list_call_once_start(l,s,t,m,v,...) spa_hook_list_do_call(l,s,t,m,v,true,##__VA_ARGS__)++/**+ * \}+ */++#ifdef __cplusplus+}+#endif++#endif /* SPA_HOOK_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/list.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/list.hnew file mode 100644index 000000000..0c03854b5--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/list.h@@ -0,0 +1,146 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_LIST_H+#define SPA_LIST_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \defgroup spa_list List+ * Doubly linked list data structure+ */++/**+ * \addtogroup spa_list List+ * \{+ */++struct spa_list {+ struct spa_list *next;+ struct spa_list *prev;+};++#define SPA_LIST_INIT(list) ((struct spa_list){ (list), (list) })++static inline void spa_list_init(struct spa_list *list)+{+ *list = SPA_LIST_INIT(list);+}++static inline int spa_list_is_initialized(struct spa_list *list)+{+ return !!list->prev;+}++#define spa_list_is_empty(l) ((l)->next == (l))++static inline void spa_list_insert(struct spa_list *list, struct spa_list *elem)+{+ elem->prev = list;+ elem->next = list->next;+ list->next = elem;+ elem->next->prev = elem;+}++static inline void spa_list_insert_list(struct spa_list *list, struct spa_list *other)+{+ if (spa_list_is_empty(other))+ return;+ other->next->prev = list;+ other->prev->next = list->next;+ list->next->prev = other->prev;+ list->next = other->next;+}++static inline void spa_list_remove(struct spa_list *elem)+{+ elem->prev->next = elem->next;+ elem->next->prev = elem->prev;+}++#define spa_list_first(head, type, member) \+ SPA_CONTAINER_OF((head)->next, type, member)++#define spa_list_last(head, type, member) \+ SPA_CONTAINER_OF((head)->prev, type, member)++#define spa_list_append(list, item) \+ spa_list_insert((list)->prev, item)++#define spa_list_prepend(list, item) \+ spa_list_insert(list, item)++#define spa_list_is_end(pos, head, member) \+ (&(pos)->member == (head))++#define spa_list_next(pos, member) \+ SPA_CONTAINER_OF((pos)->member.next, __typeof__(*(pos)), member)++#define spa_list_prev(pos, member) \+ SPA_CONTAINER_OF((pos)->member.prev, __typeof__(*(pos)), member)++#define spa_list_consume(pos, head, member) \+ for ((pos) = spa_list_first(head, __typeof__(*(pos)), member); \+ !spa_list_is_empty(head); \+ (pos) = spa_list_first(head, __typeof__(*(pos)), member))++#define spa_list_for_each_next(pos, head, curr, member) \+ for ((pos) = spa_list_first(curr, __typeof__(*(pos)), member); \+ !spa_list_is_end(pos, head, member); \+ (pos) = spa_list_next(pos, member))++#define spa_list_for_each_prev(pos, head, curr, member) \+ for ((pos) = spa_list_last(curr, __typeof__(*(pos)), member); \+ !spa_list_is_end(pos, head, member); \+ (pos) = spa_list_prev(pos, member))++#define spa_list_for_each(pos, head, member) \+ spa_list_for_each_next(pos, head, head, member)++#define spa_list_for_each_reverse(pos, head, member) \+ spa_list_for_each_prev(pos, head, head, member)++#define spa_list_for_each_safe_next(pos, tmp, head, curr, member) \+ for ((pos) = spa_list_first(curr, __typeof__(*(pos)), member); \+ (tmp) = spa_list_next(pos, member), \+ !spa_list_is_end(pos, head, member); \+ (pos) = (tmp))++#define spa_list_for_each_safe_prev(pos, tmp, head, curr, member) \+ for ((pos) = spa_list_last(curr, __typeof__(*(pos)), member); \+ (tmp) = spa_list_prev(pos, member), \+ !spa_list_is_end(pos, head, member); \+ (pos) = (tmp))++#define spa_list_for_each_safe(pos, tmp, head, member) \+ spa_list_for_each_safe_next(pos, tmp, head, head, member)++#define spa_list_for_each_safe_reverse(pos, tmp, head, member) \+ spa_list_for_each_safe_prev(pos, tmp, head, head, member)++#define spa_list_cursor_start(cursor, head, member) \+ spa_list_prepend(head, &(cursor).member)++#define spa_list_for_each_cursor(pos, cursor, head, member) \+ for((pos) = spa_list_first(&(cursor).member, __typeof__(*(pos)), member); \+ spa_list_remove(&(pos)->member), \+ spa_list_append(&(cursor).member, &(pos)->member), \+ !spa_list_is_end(pos, head, member); \+ (pos) = spa_list_next(&(cursor), member))++#define spa_list_cursor_end(cursor, member) \+ spa_list_remove(&(cursor).member)++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_LIST_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/result.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/result.hnew file mode 100644index 000000000..7f389c2c8--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/result.h@@ -0,0 +1,52 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_UTILS_RESULT_H+#define SPA_UTILS_RESULT_H++#ifdef __cplusplus+extern "C" {+#endif++/**+ * \defgroup spa_result Result handling+ * Asynchronous result utilities+ */++/**+ * \addtogroup spa_result+ * \{+ */++#include <spa/utils/defs.h>+#include <spa/utils/list.h>++#define SPA_ASYNC_BIT (1 << 30)+#define SPA_ASYNC_SEQ_MASK (SPA_ASYNC_BIT - 1)+#define SPA_ASYNC_MASK (~SPA_ASYNC_SEQ_MASK)++#define SPA_RESULT_IS_OK(res) ((res) >= 0)+#define SPA_RESULT_IS_ERROR(res) ((res) < 0)+#define SPA_RESULT_IS_ASYNC(res) (((res) & SPA_ASYNC_MASK) == SPA_ASYNC_BIT)++#define SPA_RESULT_ASYNC_SEQ(res) ((res) & SPA_ASYNC_SEQ_MASK)+#define SPA_RESULT_RETURN_ASYNC(seq) (SPA_ASYNC_BIT | SPA_RESULT_ASYNC_SEQ(seq))++#define spa_strerror(err) \+({ \+ int _err = -(err); \+ if (SPA_RESULT_IS_ASYNC(err)) \+ _err = EINPROGRESS; \+ strerror(_err); \+})++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_UTILS_RESULT_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/string.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/string.hnew file mode 100644index 000000000..cd044998f--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/string.h@@ -0,0 +1,394 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2021 Red Hat, Inc. */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_UTILS_STRING_H+#define SPA_UTILS_STRING_H++#ifdef __cplusplus+extern "C" {+#endif++#include <stdarg.h>+#include <stdbool.h>+#include <errno.h>+#include <stdlib.h>+#include <locale.h>++#include <spa/utils/defs.h>++/**+ * \defgroup spa_string String handling+ * String handling utilities+ */++/**+ * \addtogroup spa_string+ * \{+ */++/**+ * \return true if the two strings are equal, false otherwise+ *+ * If both \a a and \a b are NULL, the two are considered equal.+ *+ */+static inline bool spa_streq(const char *s1, const char *s2)+{+ return SPA_LIKELY(s1 && s2) ? strcmp(s1, s2) == 0 : s1 == s2;+}++/**+ * \return true if the two strings are equal, false otherwise+ *+ * If both \a a and \a b are NULL, the two are considered equal.+ */+static inline bool spa_strneq(const char *s1, const char *s2, size_t len)+{+ return SPA_LIKELY(s1 && s2) ? strncmp(s1, s2, len) == 0 : s1 == s2;+}+++/**+ * \return true if \a s starts with the \a prefix or false otherwise.+ * A \a s is NULL, it never starts with the given \a prefix. A \a prefix of+ * NULL is a bug in the caller.+ */+static inline bool spa_strstartswith(const char *s, const char *prefix)+{+ if (SPA_UNLIKELY(s == NULL))+ return false;++ spa_assert_se(prefix);++ return strncmp(s, prefix, strlen(prefix)) == 0;+}+++/**+ * \return true if \a s ends with the \a suffix or false otherwise.+ * A \a s is NULL, it never ends with the given \a suffix. A \a suffix of+ * NULL is a bug in the caller.+ */+static inline bool spa_strendswith(const char *s, const char *suffix)+{+ size_t l1, l2;++ if (SPA_UNLIKELY(s == NULL))+ return false;++ spa_assert_se(suffix);++ l1 = strlen(s);+ l2 = strlen(suffix);+ return l1 >= l2 && spa_streq(s + l1 - l2, suffix);+}++/**+ * Convert \a str to an int32_t with the given \a base and store the+ * result in \a val.+ *+ * On failure, the value of \a val is unmodified.+ *+ * \return true on success, false otherwise+ */+static inline bool spa_atoi32(const char *str, int32_t *val, int base)+{+ char *endptr;+ long v;++ if (!str || *str =='\0')+ return false;++ errno = 0;+ v = strtol(str, &endptr, base);+ if (errno != 0 || *endptr != '\0')+ return false;++ if (v != (int32_t)v)+ return false;++ *val = v;+ return true;+}++/**+ * Convert \a str to an uint32_t with the given \a base and store the+ * result in \a val.+ *+ * On failure, the value of \a val is unmodified.+ *+ * \return true on success, false otherwise+ */+static inline bool spa_atou32(const char *str, uint32_t *val, int base)+{+ char *endptr;+ unsigned long long v;++ if (!str || *str =='\0')+ return false;++ errno = 0;+ v = strtoull(str, &endptr, base);+ if (errno != 0 || *endptr != '\0')+ return false;++ if (v != (uint32_t)v)+ return false;++ *val = v;+ return true;+}++/**+ * Convert \a str to an int64_t with the given \a base and store the+ * result in \a val.+ *+ * On failure, the value of \a val is unmodified.+ *+ * \return true on success, false otherwise+ */+static inline bool spa_atoi64(const char *str, int64_t *val, int base)+{+ char *endptr;+ long long v;++ if (!str || *str =='\0')+ return false;++ errno = 0;+ v = strtoll(str, &endptr, base);+ if (errno != 0 || *endptr != '\0')+ return false;++ *val = v;+ return true;+}++/**+ * Convert \a str to an uint64_t with the given \a base and store the+ * result in \a val.+ *+ * On failure, the value of \a val is unmodified.+ *+ * \return true on success, false otherwise+ */+static inline bool spa_atou64(const char *str, uint64_t *val, int base)+{+ char *endptr;+ unsigned long long v;++ if (!str || *str =='\0')+ return false;++ errno = 0;+ v = strtoull(str, &endptr, base);+ if (errno != 0 || *endptr != '\0')+ return false;++ *val = v;+ return true;+}++/**+ * Convert \a str to a boolean. Allowed boolean values are "true" and a+ * literal "1", anything else is false.+ *+ * \return true on success, false otherwise+ */+static inline bool spa_atob(const char *str)+{+ return spa_streq(str, "true") || spa_streq(str, "1");+}++/**+ * "Safe" version of vsnprintf. Exactly the same as vsnprintf but the+ * returned value is clipped to `size - 1` and a negative or zero size+ * will abort() the program.+ *+ * \return The number of bytes printed, capped to `size-1`, or a negative+ * number on error.+ */+SPA_PRINTF_FUNC(3, 0)+static inline int spa_vscnprintf(char *buffer, size_t size, const char *format, va_list args)+{+ int r;++ spa_assert_se((ssize_t)size > 0);++ r = vsnprintf(buffer, size, format, args);+ if (SPA_UNLIKELY(r < 0))+ buffer[0] = '\0';+ if (SPA_LIKELY(r < (ssize_t)size))+ return r;+ return size - 1;+}++/**+ * "Safe" version of snprintf. Exactly the same as snprintf but the+ * returned value is clipped to `size - 1` and a negative or zero size+ * will abort() the program.+ *+ * \return The number of bytes printed, capped to `size-1`, or a negative+ * number on error.+ */+SPA_PRINTF_FUNC(3, 4)+static inline int spa_scnprintf(char *buffer, size_t size, const char *format, ...)+{+ int r;+ va_list args;++ va_start(args, format);+ r = spa_vscnprintf(buffer, size, format, args);+ va_end(args);++ return r;+}++/**+ * Convert \a str to a float in the C locale.+ *+ * If \a endptr is not NULL, a pointer to the character after the last character+ * used in the conversion is stored in the location referenced by endptr.+ *+ * \return the result float.+ */+static inline float spa_strtof(const char *str, char **endptr)+{+#ifndef __LOCALE_C_ONLY+ static locale_t locale = NULL;+ locale_t prev;+#endif+ float v;+#ifndef __LOCALE_C_ONLY+ if (SPA_UNLIKELY(locale == NULL))+ locale = newlocale(LC_ALL_MASK, "C", NULL);+ prev = uselocale(locale);+#endif+ v = strtof(str, endptr);+#ifndef __LOCALE_C_ONLY+ uselocale(prev);+#endif+ return v;+}++/**+ * Convert \a str to a float and store the result in \a val.+ *+ * On failure, the value of \a val is unmodified.+ *+ * \return true on success, false otherwise+ */+static inline bool spa_atof(const char *str, float *val)+{+ char *endptr;+ float v;++ if (!str || *str =='\0')+ return false;+ errno = 0;+ v = spa_strtof(str, &endptr);+ if (errno != 0 || *endptr != '\0')+ return false;++ *val = v;+ return true;+}++/**+ * Convert \a str to a double in the C locale.+ *+ * If \a endptr is not NULL, a pointer to the character after the last character+ * used in the conversion is stored in the location referenced by endptr.+ *+ * \return the result float.+ */+static inline double spa_strtod(const char *str, char **endptr)+{+#ifndef __LOCALE_C_ONLY+ static locale_t locale = NULL;+ locale_t prev;+#endif+ double v;+#ifndef __LOCALE_C_ONLY+ if (SPA_UNLIKELY(locale == NULL))+ locale = newlocale(LC_ALL_MASK, "C", NULL);+ prev = uselocale(locale);+#endif+ v = strtod(str, endptr);+#ifndef __LOCALE_C_ONLY+ uselocale(prev);+#endif+ return v;+}++/**+ * Convert \a str to a double and store the result in \a val.+ *+ * On failure, the value of \a val is unmodified.+ *+ * \return true on success, false otherwise+ */+static inline bool spa_atod(const char *str, double *val)+{+ char *endptr;+ double v;++ if (!str || *str =='\0')+ return false;++ errno = 0;+ v = spa_strtod(str, &endptr);+ if (errno != 0 || *endptr != '\0')+ return false;++ *val = v;+ return true;+}++static inline char *spa_dtoa(char *str, size_t size, double val)+{+ int i, l;+ l = spa_scnprintf(str, size, "%f", val);+ for (i = 0; i < l; i++)+ if (str[i] == ',')+ str[i] = '.';+ return str;+}++struct spa_strbuf {+ char *buffer;+ size_t maxsize;+ size_t pos;+};++static inline void spa_strbuf_init(struct spa_strbuf *buf, char *buffer, size_t maxsize)+{+ buf->buffer = buffer;+ buf->maxsize = maxsize;+ buf->pos = 0;+}++SPA_PRINTF_FUNC(2, 3)+static inline int spa_strbuf_append(struct spa_strbuf *buf, const char *fmt, ...)+{+ size_t remain = buf->maxsize - buf->pos;+ ssize_t written;+ va_list args;+ va_start(args, fmt);+ written = vsnprintf(&buf->buffer[buf->pos], remain, fmt, args);+ va_end(args);+ if (written > 0)+ buf->pos += SPA_MIN(remain, (size_t)written);+ return written;+}++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_UTILS_STRING_H */diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/type.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/type.hnew file mode 100644index 000000000..65610c11e--- /dev/null+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/utils/type.h@@ -0,0 +1,134 @@+/* Simple Plugin API */+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */+/* SPDX-License-Identifier: MIT */++#ifndef SPA_TYPE_H+#define SPA_TYPE_H++#ifdef __cplusplus+extern "C" {+#endif++#include <spa/utils/defs.h>++/** \defgroup spa_types Types+ * Data type information enumerations+ */++/**+ * \addtogroup spa_types+ * \{+ */++enum {+ /* Basic types */+ SPA_TYPE_START = 0x00000,+ SPA_TYPE_None,+ SPA_TYPE_Bool,+ SPA_TYPE_Id,+ SPA_TYPE_Int,+ SPA_TYPE_Long,+ SPA_TYPE_Float,+ SPA_TYPE_Double,+ SPA_TYPE_String,+ SPA_TYPE_Bytes,+ SPA_TYPE_Rectangle,+ SPA_TYPE_Fraction,+ SPA_TYPE_Bitmap,+ SPA_TYPE_Array,+ SPA_TYPE_Struct,+ SPA_TYPE_Object,+ SPA_TYPE_Sequence,+ SPA_TYPE_Pointer,+ SPA_TYPE_Fd,+ SPA_TYPE_Choice,+ SPA_TYPE_Pod,+ _SPA_TYPE_LAST, /**< not part of ABI */++ /* Pointers */+ SPA_TYPE_POINTER_START = 0x10000,+ SPA_TYPE_POINTER_Buffer,+ SPA_TYPE_POINTER_Meta,+ SPA_TYPE_POINTER_Dict,+ _SPA_TYPE_POINTER_LAST, /**< not part of ABI */++ /* Events */+ SPA_TYPE_EVENT_START = 0x20000,+ SPA_TYPE_EVENT_Device,+ SPA_TYPE_EVENT_Node,+ _SPA_TYPE_EVENT_LAST, /**< not part of ABI */++ /* Commands */+ SPA_TYPE_COMMAND_START = 0x30000,+ SPA_TYPE_COMMAND_Device,+ SPA_TYPE_COMMAND_Node,+ _SPA_TYPE_COMMAND_LAST, /**< not part of ABI */++ /* Objects */+ SPA_TYPE_OBJECT_START = 0x40000,+ SPA_TYPE_OBJECT_PropInfo,+ SPA_TYPE_OBJECT_Props,+ SPA_TYPE_OBJECT_Format,+ SPA_TYPE_OBJECT_ParamBuffers,+ SPA_TYPE_OBJECT_ParamMeta,+ SPA_TYPE_OBJECT_ParamIO,+ SPA_TYPE_OBJECT_ParamProfile,+ SPA_TYPE_OBJECT_ParamPortConfig,+ SPA_TYPE_OBJECT_ParamRoute,+ SPA_TYPE_OBJECT_Profiler,+ SPA_TYPE_OBJECT_ParamLatency,+ SPA_TYPE_OBJECT_ParamProcessLatency,+ SPA_TYPE_OBJECT_ParamTag,+ _SPA_TYPE_OBJECT_LAST, /**< not part of ABI */++ /* vendor extensions */+ SPA_TYPE_VENDOR_PipeWire = 0x02000000,++ SPA_TYPE_VENDOR_Other = 0x7f000000,+};++#define SPA_TYPE_INFO_BASE "Spa:"++#define SPA_TYPE_INFO_Flags SPA_TYPE_INFO_BASE "Flags"+#define SPA_TYPE_INFO_FLAGS_BASE SPA_TYPE_INFO_Flags ":"++#define SPA_TYPE_INFO_Enum SPA_TYPE_INFO_BASE "Enum"+#define SPA_TYPE_INFO_ENUM_BASE SPA_TYPE_INFO_Enum ":"++#define SPA_TYPE_INFO_Pod SPA_TYPE_INFO_BASE "Pod"+#define SPA_TYPE_INFO_POD_BASE SPA_TYPE_INFO_Pod ":"++#define SPA_TYPE_INFO_Struct SPA_TYPE_INFO_POD_BASE "Struct"+#define SPA_TYPE_INFO_STRUCT_BASE SPA_TYPE_INFO_Struct ":"++#define SPA_TYPE_INFO_Object SPA_TYPE_INFO_POD_BASE "Object"+#define SPA_TYPE_INFO_OBJECT_BASE SPA_TYPE_INFO_Object ":"++#define SPA_TYPE_INFO_Pointer SPA_TYPE_INFO_BASE "Pointer"+#define SPA_TYPE_INFO_POINTER_BASE SPA_TYPE_INFO_Pointer ":"++#define SPA_TYPE_INFO_Interface SPA_TYPE_INFO_POINTER_BASE "Interface"+#define SPA_TYPE_INFO_INTERFACE_BASE SPA_TYPE_INFO_Interface ":"++#define SPA_TYPE_INFO_Event SPA_TYPE_INFO_OBJECT_BASE "Event"+#define SPA_TYPE_INFO_EVENT_BASE SPA_TYPE_INFO_Event ":"++#define SPA_TYPE_INFO_Command SPA_TYPE_INFO_OBJECT_BASE "Command"+#define SPA_TYPE_INFO_COMMAND_BASE SPA_TYPE_INFO_Command ":"++struct spa_type_info {+ uint32_t type;+ uint32_t parent;+ const char *name;+ const struct spa_type_info *values;+};++/**+ * \}+ */++#ifdef __cplusplus+} /* extern "C" */+#endif++#endif /* SPA_TYPE_H */diff --git a/package.json b/package.jsonindex 9a23f353e..079a3aeec 100644--- a/package.json+++ b/package.json@@ -33,9 +33,10 @@"build:native:compositor": "node scripts/build-windows-compositor-addon.mjs","build:native:compositor:mac": "node scripts/build-macos-compositor-addon.mjs","build:native:compositor:linux": "node scripts/build-linux-compositor-addon.mjs",+ "build:native:linux": "node scripts/build-linux-pipewire-helper.mjs","build:win": "npm run build:native:win && npm run fetch:ffmpeg && npm run build:native:compositor && tsc && vite build && electron-builder --win --config.npmRebuild=false","build:win:store": "npm run build:native:win && npm run fetch:ffmpeg && npm run build:native:compositor && tsc && vite build && electron-builder --win appx --config.npmRebuild=false",- "build:linux": "npm run build:native:compositor:linux && tsc && vite build && electron-builder --linux AppImage deb pacman --config.npmRebuild=false",+ "build:linux": "npm run build:native:linux && npm run build:native:compositor:linux && tsc && vite build && electron-builder --linux AppImage deb pacman --config.npmRebuild=false","build:whisper-binaries": "bash scripts/build-whisper-stt.sh","test:whisper-stt": "node scripts/test-whisper-stt.mjs","test": "vitest --run",diff --git a/scripts/build-linux-pipewire-helper.mjs b/scripts/build-linux-pipewire-helper.mjsnew file mode 100644index 000000000..5b39d7c0b--- /dev/null+++ b/scripts/build-linux-pipewire-helper.mjs@@ -0,0 +1,114 @@+// Builds the Linux cursor/capture helper (electron/native/pipewire-capture) and+// vendors it to electron/native/bin/linux-<arch>/, the folder+// pipeWireCursorRecordingSession.ts resolves at runtime.+//+// The Linux counterpart of build-macos-screencapturekit-helper.mjs and+// build-windows-wgc-helper.mjs. Two things are deliberately absent compared to+// the compositor addon's Linux build script:+//+// 1. No pkg-config, no FFMPEG_DIR, no libclang. The helper's C shim compiles+// against headers vendored in the repo and resolves libpipewire with+// dlopen at runtime, so `cargo` and a C compiler are the entire toolchain.+// That is the point: libpipewire-0.3-dev is not installable on every+// contributor's box, and requiring it would gate the Linux build on a+// package Ubuntu does not ship by default.+//+// 2. No RUNPATH surgery. Nothing is dynamically linked beyond libc, so the+// binary is relocatable as-is.+//+// The crate is NOT part of the crates/ workspace (see its Cargo.toml for why),+// so it is built by pointing cargo at its own manifest.++import { spawnSync } from "node:child_process";+import fs from "node:fs";+import path from "node:path";+import process from "node:process";+import { fileURLToPath } from "node:url";++if (process.platform !== "linux") {+ console.log("Skipping Linux PipeWire helper build: host platform is not Linux.");+ process.exit(0);+}++const __dirname = path.dirname(fileURLToPath(import.meta.url));+const root = path.resolve(__dirname, "..");+const helperName = "openscreen-pipewire-helper";+const crateDir = path.join(root, "electron", "native", "pipewire-capture");+const manifest = path.join(crateDir, "Cargo.toml");+// Mirrored into the crate's own build/ folder so `npm run dev` (candidate #2 in+// the session's path list) finds it without a packaging step.+const devDir = path.join(crateDir, "build");+// `linux-x64` / `linux-arm64` — must match platformArchTag() in+// electron/native-bridge/cursor/recording/pipeWireCursorRecordingSession.ts.+const tag = `linux-${process.arch === "arm64" ? "arm64" : "x64"}`;+const outDir = path.join(root, "electron", "native", "bin", tag);++if (!fs.existsSync(manifest)) {+ console.error(`Helper crate not found at ${manifest}.`);+ process.exit(1);+}++const cargoVersion = spawnSync("cargo", ["--version"], { encoding: "utf8" });+if (cargoVersion.status !== 0) {+ console.error(+ [+ "Unable to build the Linux PipeWire helper because cargo is not on PATH.",+ "",+ "Install Rust (https://rustup.rs) and re-run, or source your existing toolchain:",+ " source ~/.cargo/env",+ ].join("\n"),+ );+ process.exit(1);+}++const build = spawnSync("cargo", ["build", "--release", "--manifest-path", manifest], {+ cwd: crateDir,+ stdio: "inherit",+});+if (build.error) {+ console.error(`Failed to start cargo: ${build.error.message}`);+ process.exit(1);+}+if (build.status !== 0) {+ process.exit(build.status ?? 1);+}++const builtBinary = path.join(crateDir, "target", "release", helperName);+if (!fs.existsSync(builtBinary)) {+ console.error(`cargo build succeeded but ${builtBinary} was not found.`);+ process.exit(1);+}++for (const dir of [outDir, devDir]) {+ fs.mkdirSync(dir, { recursive: true });+ const dest = path.join(dir, helperName);+ // Unlink first. Writing over a file that is currently being executed fails+ // with ETXTBSY, and during development there is very often a helper still+ // running — a manual portal session left open, or one Electron did not reap.+ // Removing the directory entry leaves that process on its own inode, happily+ // unaffected, and frees the name for the new build.+ fs.rmSync(dest, { force: true });+ fs.copyFileSync(builtBinary, dest);+ fs.chmodSync(dest, 0o755);+ console.log(`Copied ${dest}`);+}++// A helper that cannot dlopen libpipewire is useless, and the failure is+// otherwise invisible until someone records. `probeOnly` runs the whole+// non-interactive path — dlopen, D-Bus, AvailableCursorModes — and stops short+// of the portal's Start(), which is the only call that raises a picker.+const probe = spawnSync(path.join(outDir, helperName), ['{"probeOnly":true}'], {+ encoding: "utf8",+ timeout: 15_000,+});+if (probe.status === 0) {+ console.log(`Probe: ${probe.stdout.trim()}`);+} else {+ // Not fatal: a build machine legitimately may have no PipeWire or no portal+ // (a container, a CI runner). The binary is still correct.+ console.warn(+ `Probe failed on this machine, which is expected without a desktop session: ${(+ probe.stdout || probe.stderr+ ).trim()}`,+ );+}