+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
main
| 1 | /* |
| 2 | * SPDX-License-Identifier: AGPL-3.0-or-later WITH Classpath-exception-2.0 |
| 3 | * Copyright (c) 2026 Saif Mukhtar |
| 4 | * |
| 5 | * OpenAVX - Open Audio-Video eXchange |
| 6 | * include/avx_pipewire_sink.h - Native user-space PipeWire virtual camera sink |
| 7 | */ |
| 8 | |
| 9 | #ifndef AVX_PIPEWIRE_SINK_H |
| 10 | #define AVX_PIPEWIRE_SINK_H |
| 11 | |
| 12 | #include <stdint.h> |
| 13 | #include <stdbool.h> |
| 14 | #include <stddef.h> |
| 15 | #include "openavx.h" |
| 16 | |
| 17 | #ifdef __cplusplus |
| 18 | extern "C" { |
| 19 | #endif |
| 20 | |
| 21 | /* Opaque PipeWire virtual camera sink handle */ |
| 22 | typedef struct avx_pipewire_sink_t avx_pipewire_sink_t; |
| 23 | |
| 24 | /* PipeWire sink configuration */ |
| 25 | typedef struct avx_pipewire_sink_config_t { |
| 26 | const char *node_name; /* Node name, e.g. "OpenAVX Virtual Camera" */ |
| 27 | const char *node_description; /* Node human description, e.g. "OpenAVX Virtual Camera Feed" */ |
| 28 | uint32_t width; /* Initial frame width (default: 1920) */ |
| 29 | uint32_t height; /* Initial frame height (default: 1080) */ |
| 30 | uint32_t fps_num; /* Framerate numerator (default: 30) */ |
| 31 | uint32_t fps_den; /* Framerate denominator (default: 1) */ |
| 32 | uint32_t preferred_fourcc; /* Target pixel format: OAVX_FOURCC_VIDEO_TYPE_UYVY or YUYV */ |
| 33 | } avx_pipewire_sink_config_t; |
| 34 | |
| 35 | /** |
| 36 | * Checks if the PipeWire daemon is currently available on the system. |
| 37 | */ |
| 38 | OPENAVX_API bool avx_pipewire_is_available(void); |
| 39 | |
| 40 | /** |
| 41 | * Creates and starts a native PipeWire virtual camera video source (media.class = "Video/Source"). |
| 42 | * The PipeWire event loop runs in a dedicated background worker thread. |
| 43 | * Returns sink handle on success, NULL on failure. |
| 44 | */ |
| 45 | OPENAVX_API avx_pipewire_sink_t *avx_pipewire_sink_create(const avx_pipewire_sink_config_t *config); |
| 46 | |
| 47 | /** |
| 48 | * Stops and destroys the PipeWire virtual camera sink, unregistering the camera node from PipeWire. |
| 49 | */ |
| 50 | OPENAVX_API void avx_pipewire_sink_destroy(avx_pipewire_sink_t *sink); |
| 51 | |
| 52 | /** |
| 53 | * Pushes a video frame into the PipeWire video stream. |
| 54 | * Automatically performs format conversion (e.g. UYVY -> YUY2 / RGBA) if necessary. |
| 55 | * Thread-safe: can be called from any worker thread. |
| 56 | */ |
| 57 | OPENAVX_API bool avx_pipewire_sink_push_frame( |
| 58 | avx_pipewire_sink_t *sink, |
| 59 | const uint8_t *frame_data, |
| 60 | size_t frame_size, |
| 61 | uint32_t width, |
| 62 | uint32_t height, |
| 63 | uint32_t fourcc |
| 64 | ); |
| 65 | |
| 66 | /** |
| 67 | * Returns true if at least one client (e.g. Chrome, Firefox, Discord, Zoom) is currently consuming the stream. |
| 68 | */ |
| 69 | OPENAVX_API bool avx_pipewire_sink_is_active(const avx_pipewire_sink_t *sink); |
| 70 | |
| 71 | #ifdef __cplusplus |
| 72 | } |
| 73 | #endif |
| 74 | |
| 75 | #endif /* AVX_PIPEWIRE_SINK_H */ |