Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

feat(capture): record system audio and the microphone alongside the video

Etienne Lescot4d49f67ec264
diff --git a/electron/native/pipewire-capture/build.rs b/electron/native/pipewire-capture/build.rs
index 30f572aa6..a3a78d204 100644
--- a/electron/native/pipewire-capture/build.rs
+++ b/electron/native/pipewire-capture/build.rs
@@ -24,7 +24,7 @@ fn main() {
fn build_pipewire_shim(root: &Path) {
let vendor = root.join("vendor/pipewire-1.0.5/include");
- let shim = root.join("csrc/pw_shim.c");
+ let sources = ["csrc/pw_shim.c", "csrc/pw_audio.c"];
assert!(
vendor.join("pipewire/pipewire.h").is_file(),
@@ -32,16 +32,22 @@ fn build_pipewire_shim(root: &Path) {
vendor.display()
);
- cc::Build::new()
- .file(&shim)
+ let mut build = cc::Build::new();
+ for source in sources {
+ build.file(root.join(source));
+ }
+ build
.include(&vendor)
.include(root.join("csrc"))
.flag_if_supported("-std=gnu11")
.warnings(true)
.compile("openscreen_pw_shim");
- println!("cargo:rerun-if-changed={}", shim.display());
+ for source in sources {
+ println!("cargo:rerun-if-changed={}", root.join(source).display());
+ }
println!("cargo:rerun-if-changed={}", root.join("csrc/pw_shim.h").display());
+ println!("cargo:rerun-if-changed={}", root.join("csrc/pw_internal.h").display());
println!("cargo:rerun-if-changed={}", vendor.display());
// dlopen/dlsym.
diff --git a/electron/native/pipewire-capture/csrc/pw_audio.c b/electron/native/pipewire-capture/csrc/pw_audio.c
new file mode 100644
index 000000000..6c3531599
--- /dev/null
+++ b/electron/native/pipewire-capture/csrc/pw_audio.c
@@ -0,0 +1,263 @@
+/*
+ * PipeWire audio capture: the system mix and the microphone.
+ *
+ * WHY THIS IS A SEPARATE CONNECTION FROM THE VIDEO.
+ *
+ * The screen arrives over the fd the portal handed us from OpenPipeWireRemote.
+ * That remote is deliberately restricted: it exposes the one screencast node the
+ * user approved and nothing else. There is no audio on it, and there is no
+ * portal that grants audio the way ScreenCast grants pixels — the ScreenCast
+ * interface has no audio option at all.
+ *
+ * So audio comes from the session's own PipeWire daemon, over the ordinary
+ * socket, with pw_context_connect rather than pw_context_connect_fd. That works
+ * for a .deb/AppImage build, which runs unsandboxed. Inside a Flatpak it would
+ * need the `--socket=pipewire` permission; there is no way to ask for it at
+ * runtime, so a sandboxed build simply gets no audio and says so rather than
+ * recording silence.
+ *
+ * SYSTEM AUDIO IS A SINK MONITOR. `PW_KEY_STREAM_CAPTURE_SINK=true` turns a
+ * capture stream into one that links to a SINK's monitor ports instead of a
+ * source — that is, to what is being played rather than to a microphone. It is
+ * the same mechanism `pw-record --target` uses and what OBS's audio capture
+ * does; without it the stream links to the default source and records the
+ * microphone twice.
+ */
+
+#include "pw_shim.h"
+
+#include "pw_internal.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <spa/param/audio/format-utils.h>
+#include <spa/pod/builder.h>
+#include <spa/utils/result.h>
+
+struct osc_pw_audio {
+ 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_audio_callbacks callbacks;
+ uint32_t channels;
+};
+
+static void osc_audio_on_state_changed(void *userdata, enum pw_stream_state old,
+ enum pw_stream_state state, const char *error)
+{
+ struct osc_pw_audio *audio = userdata;
+
+ (void)old;
+ if (audio->callbacks.on_state != NULL) {
+ audio->callbacks.on_state(audio->callbacks.user,
+ osc_audio_api.stream_state_as_string(state), error);
+ }
+}
+
+static void osc_audio_on_param_changed(void *userdata, uint32_t id, const struct spa_pod *param)
+{
+ struct osc_pw_audio *audio = userdata;
+ struct spa_audio_info_raw info;
+
+ if (param == NULL || id != SPA_PARAM_Format) {
+ return;
+ }
+ memset(&info, 0, sizeof(info));
+ if (spa_format_audio_raw_parse(param, &info) < 0) {
+ return;
+ }
+ /*
+ * Recorded so osc_audio_on_process knows how many floats make one frame.
+ * The stream adapter honours what we asked for, but reading back what was
+ * actually negotiated is what keeps a mono device from being interpreted as
+ * interleaved stereo and played back at double speed.
+ */
+ audio->channels = info.channels;
+}
+
+static void osc_audio_on_process(void *userdata)
+{
+ struct osc_pw_audio *audio = userdata;
+ struct pw_buffer *b;
+
+ while ((b = osc_audio_api.stream_dequeue_buffer(audio->stream)) != NULL) {
+ struct spa_data *data = &b->buffer->datas[0];
+
+ if (b->buffer->n_datas > 0 && data->data != NULL && data->chunk != NULL &&
+ audio->callbacks.on_samples != NULL) {
+ uint32_t offset;
+ uint32_t size;
+
+ /* Same untrusted-producer clamping as the video path: `chunk` lives
+ * in memory another process writes. */
+ offset = SPA_MIN(data->chunk->offset, data->maxsize);
+ size = SPA_MIN(data->chunk->size, data->maxsize - offset);
+ if (size >= sizeof(float)) {
+ const float *samples = SPA_PTROFF(data->data, offset, const float);
+
+ audio->callbacks.on_samples(audio->callbacks.user, samples,
+ size / (uint32_t)sizeof(float));
+ }
+ }
+ osc_audio_api.stream_queue_buffer(audio->stream, b);
+ }
+}
+
+static const struct pw_stream_events osc_audio_stream_events = {
+ PW_VERSION_STREAM_EVENTS,
+ .state_changed = osc_audio_on_state_changed,
+ .param_changed = osc_audio_on_param_changed,
+ .process = osc_audio_on_process,
+};
+
+struct osc_pw_audio *osc_pw_audio_start(const char *target_object, int capture_sink,
+ uint32_t rate, uint32_t channels,
+ const struct osc_pw_audio_callbacks *callbacks, char *err,
+ size_t err_len)
+{
+ struct osc_pw_audio *audio;
+ struct pw_properties *props;
+ uint8_t storage[1024];
+ struct spa_pod_builder builder = SPA_POD_BUILDER_INIT(storage, sizeof(storage));
+ const struct spa_pod *params[1];
+ struct spa_audio_info_raw info;
+ int result;
+
+ if (osc_audio_api.stream_new == NULL) {
+ osc_pw_set_error(err, err_len, "osc_pw_audio_start called before osc_pw_load");
+ return NULL;
+ }
+
+ audio = calloc(1, sizeof(*audio));
+ if (audio == NULL) {
+ osc_pw_set_error(err, err_len, "out of memory");
+ return NULL;
+ }
+ audio->callbacks = *callbacks;
+ audio->channels = channels;
+
+ audio->loop = osc_audio_api.thread_loop_new("openscreen-audio", NULL);
+ if (audio->loop == NULL) {
+ osc_pw_set_error(err, err_len, "pw_thread_loop_new failed");
+ free(audio);
+ return NULL;
+ }
+
+ osc_audio_api.thread_loop_lock(audio->loop);
+
+ audio->context =
+ osc_audio_api.context_new(osc_audio_api.thread_loop_get_loop(audio->loop), NULL, 0);
+ if (audio->context == NULL) {
+ osc_pw_set_error(err, err_len, "pw_context_new failed");
+ goto fail;
+ }
+
+ /* The session's own daemon, not the portal's restricted remote. */
+ audio->core = osc_audio_api.context_connect(audio->context, NULL, 0);
+ if (audio->core == NULL) {
+ osc_pw_set_error(err, err_len,
+ "pw_context_connect failed: no PipeWire session is reachable "
+ "(in a sandbox this needs the pipewire socket permission)");
+ goto fail;
+ }
+
+ props = osc_audio_api.properties_new(PW_KEY_MEDIA_TYPE, "Audio", PW_KEY_MEDIA_CATEGORY,
+ "Capture", PW_KEY_MEDIA_ROLE, "Production", NULL);
+ if (props == NULL) {
+ osc_pw_set_error(err, err_len, "pw_properties_new failed");
+ goto fail;
+ }
+ if (capture_sink) {
+ /* Link to a SINK's monitor ports — what is being played — rather than
+ * to a source. Without this the stream records the microphone. */
+ osc_audio_api.properties_set(props, PW_KEY_STREAM_CAPTURE_SINK, "true");
+ }
+ if (target_object != NULL && target_object[0] != '\0') {
+ osc_audio_api.properties_set(props, PW_KEY_TARGET_OBJECT, target_object);
+ }
+
+ audio->stream = osc_audio_api.stream_new(audio->core, "openscreen-audio", props);
+ if (audio->stream == NULL) {
+ osc_pw_set_error(err, err_len, "pw_stream_new failed");
+ goto fail;
+ }
+
+ osc_audio_api.stream_add_listener(audio->stream, &audio->stream_listener,
+ &osc_audio_stream_events, audio);
+
+ /*
+ * A single fixed format, not a choice. pw_stream inserts an adapter node
+ * that resamples and remixes whatever the device runs at, so asking for
+ * exactly what the AAC encoder wants costs nothing and removes every
+ * conversion from this process.
+ */
+ memset(&info, 0, sizeof(info));
+ info.format = SPA_AUDIO_FORMAT_F32;
+ info.rate = rate;
+ info.channels = channels;
+ params[0] = spa_format_audio_raw_build(&builder, SPA_PARAM_EnumFormat, &info);
+ if (params[0] == NULL) {
+ osc_pw_set_error(err, err_len, "the audio EnumFormat POD did not fit its builder");
+ goto fail;
+ }
+
+ /* No PW_STREAM_FLAG_RT_PROCESS: osc_audio_on_process takes a mutex on the
+ * Rust side, which is not allowed on PipeWire's realtime thread. */
+ result = osc_audio_api.stream_connect(audio->stream, PW_DIRECTION_INPUT, PW_ID_ANY,
+ PW_STREAM_FLAG_AUTOCONNECT |
+ PW_STREAM_FLAG_MAP_BUFFERS,
+ params, 1);
+ if (result < 0) {
+ osc_pw_set_error(err, err_len, "pw_stream_connect failed: %s", spa_strerror(result));
+ goto fail;
+ }
+
+ osc_audio_api.thread_loop_unlock(audio->loop);
+
+ if (osc_audio_api.thread_loop_start(audio->loop) < 0) {
+ osc_pw_set_error(err, err_len, "pw_thread_loop_start failed");
+ osc_audio_api.thread_loop_lock(audio->loop);
+ goto fail;
+ }
+
+ return audio;
+
+fail:
+ osc_audio_api.thread_loop_unlock(audio->loop);
+ if (audio->stream != NULL) {
+ osc_audio_api.stream_destroy(audio->stream);
+ }
+ if (audio->core != NULL) {
+ osc_audio_api.core_disconnect(audio->core);
+ }
+ if (audio->context != NULL) {
+ osc_audio_api.context_destroy(audio->context);
+ }
+ osc_audio_api.thread_loop_destroy(audio->loop);
+ free(audio);
+ return NULL;
+}
+
+void osc_pw_audio_stop(struct osc_pw_audio *audio)
+{
+ if (audio == NULL) {
+ return;
+ }
+ /* Stop the loop BEFORE destroying anything it might still be running a
+ * callback against; this joins the thread. */
+ osc_audio_api.thread_loop_stop(audio->loop);
+ if (audio->stream != NULL) {
+ osc_audio_api.stream_destroy(audio->stream);
+ }
+ if (audio->core != NULL) {
+ osc_audio_api.core_disconnect(audio->core);
+ }
+ if (audio->context != NULL) {
+ osc_audio_api.context_destroy(audio->context);
+ }
+ osc_audio_api.thread_loop_destroy(audio->loop);
+ free(audio);
+}
diff --git a/electron/native/pipewire-capture/csrc/pw_internal.h b/electron/native/pipewire-capture/csrc/pw_internal.h
new file mode 100644
index 000000000..e9bc02c49
--- /dev/null
+++ b/electron/native/pipewire-capture/csrc/pw_internal.h
@@ -0,0 +1,58 @@
+/*
+ * Shared between pw_shim.c and pw_audio.c. NOT part of the Rust-facing ABI.
+ *
+ * pw_shim.h is deliberately free of PipeWire and SPA types — that is what lets
+ * src/shim.rs mirror it by hand without restating a single upstream struct
+ * layout. This header is the opposite: it is full of them, and no Rust ever
+ * sees it.
+ */
+
+#ifndef OPENSCREEN_PW_INTERNAL_H
+#define OPENSCREEN_PW_INTERNAL_H
+
+#include <stdarg.h>
+#include <stddef.h>
+
+#include <pipewire/pipewire.h>
+
+/*
+ * The subset of libpipewire that pw_audio.c calls, resolved once by
+ * osc_pw_load alongside the video half's table. One dlopen and one symbol
+ * table for the whole helper means a missing symbol is reported at load, not
+ * at the first audio stream — by which time the user is already recording.
+ */
+struct osc_pw_audio_api {
+ 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)(struct pw_context *context, struct pw_properties *props,
+ size_t user_data_size);
+ int (*core_disconnect)(struct pw_core *core);
+ struct pw_properties *(*properties_new)(const char *key, ...);
+ int (*properties_set)(struct pw_properties *props, const char *key, const char *value);
+ 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);
+ struct pw_buffer *(*stream_dequeue_buffer)(struct pw_stream *stream);
+ int (*stream_queue_buffer)(struct pw_stream *stream, struct pw_buffer *buffer);
+ const char *(*stream_state_as_string)(enum pw_stream_state state);
+};
+
+extern struct osc_pw_audio_api osc_audio_api;
+
+/* Shared so both files report failures in the same shape. */
+void osc_pw_set_error(char *err, size_t err_len, const char *format, ...);
+
+#endif /* OPENSCREEN_PW_INTERNAL_H */
diff --git a/electron/native/pipewire-capture/csrc/pw_shim.c b/electron/native/pipewire-capture/csrc/pw_shim.c
index 1d6470152..b96cdb5ff 100644
--- a/electron/native/pipewire-capture/csrc/pw_shim.c
+++ b/electron/native/pipewire-capture/csrc/pw_shim.c
@@ -43,6 +43,8 @@
#include "pw_shim.h"
+#include "pw_internal.h"
+
#define OSC_PW_SONAME "libpipewire-0.3.so.0"
/*
@@ -134,6 +136,23 @@ struct osc_pw_session {
int want_video;
};
+struct osc_pw_audio_api osc_audio_api;
+
+/* The shared spelling pw_audio.c uses; `osc_set_error` below is the local
+ * alias this file has always called. */
+void osc_pw_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);
+ err[err_len - 1] = '\0';
+}
+
static void osc_set_error(char *err, size_t err_len, const char *format, ...)
{
va_list args;
@@ -196,6 +215,43 @@ int osc_pw_load(char *err, size_t err_len)
OSC_LOAD(stream_update_params, "pw_stream_update_params");
OSC_LOAD(stream_state_as_string, "pw_stream_state_as_string");
+/* The audio half's table. Same dlopen, same failure path: a libpipewire too old
+ * to have one of these should be reported here, at load, and not halfway into a
+ * recording. */
+#define OSC_LOAD_AUDIO(field, symbol) \
+ do { \
+ *(void **)(&osc_audio_api.field) = dlsym(api_handle, symbol); \
+ if (osc_audio_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_AUDIO(thread_loop_new, "pw_thread_loop_new");
+ OSC_LOAD_AUDIO(thread_loop_destroy, "pw_thread_loop_destroy");
+ OSC_LOAD_AUDIO(thread_loop_get_loop, "pw_thread_loop_get_loop");
+ OSC_LOAD_AUDIO(thread_loop_start, "pw_thread_loop_start");
+ OSC_LOAD_AUDIO(thread_loop_stop, "pw_thread_loop_stop");
+ OSC_LOAD_AUDIO(thread_loop_lock, "pw_thread_loop_lock");
+ OSC_LOAD_AUDIO(thread_loop_unlock, "pw_thread_loop_unlock");
+ OSC_LOAD_AUDIO(context_new, "pw_context_new");
+ OSC_LOAD_AUDIO(context_destroy, "pw_context_destroy");
+ OSC_LOAD_AUDIO(context_connect, "pw_context_connect");
+ OSC_LOAD_AUDIO(core_disconnect, "pw_core_disconnect");
+ OSC_LOAD_AUDIO(properties_new, "pw_properties_new");
+ OSC_LOAD_AUDIO(properties_set, "pw_properties_set");
+ OSC_LOAD_AUDIO(stream_new, "pw_stream_new");
+ OSC_LOAD_AUDIO(stream_destroy, "pw_stream_destroy");
+ OSC_LOAD_AUDIO(stream_add_listener, "pw_stream_add_listener");
+ OSC_LOAD_AUDIO(stream_connect, "pw_stream_connect");
+ OSC_LOAD_AUDIO(stream_dequeue_buffer, "pw_stream_dequeue_buffer");
+ OSC_LOAD_AUDIO(stream_queue_buffer, "pw_stream_queue_buffer");
+ OSC_LOAD_AUDIO(stream_state_as_string, "pw_stream_state_as_string");
+
+#undef OSC_LOAD_AUDIO
#undef OSC_LOAD
api.init(NULL, NULL);
diff --git a/electron/native/pipewire-capture/csrc/pw_shim.h b/electron/native/pipewire-capture/csrc/pw_shim.h
index 63a2f5d3d..ad12b81d3 100644
--- a/electron/native/pipewire-capture/csrc/pw_shim.h
+++ b/electron/native/pipewire-capture/csrc/pw_shim.h
@@ -166,6 +166,42 @@ struct osc_pw_session *osc_pw_start(int fd, uint32_t node_id, int want_video,
/* Stops the thread loop, joins it, and frees everything. Safe with NULL. */
void osc_pw_stop(struct osc_pw_session *session);
+/* ---------------------------------------------------------------------------
+ * Audio (csrc/pw_audio.c)
+ *
+ * A second, independent PipeWire connection — to the session's own daemon, not
+ * to the portal's restricted remote, which carries no audio. See the header of
+ * pw_audio.c for why that is the only option.
+ * ------------------------------------------------------------------------- */
+
+struct osc_pw_audio;
+
+struct osc_pw_audio_callbacks {
+ void *user;
+ /* `interleaved` holds `n_samples` floats — that is n_samples/channels frames
+ * — and is borrowed for the duration of the call. */
+ void (*on_samples)(void *user, const float *interleaved, uint32_t n_samples);
+ void (*on_state)(void *user, const char *state, const char *error);
+};
+
+/*
+ * Opens one capture stream.
+ *
+ * `capture_sink` non-zero links to a SINK's monitor ports (what is being played)
+ * rather than to a source; that is the difference between recording the system
+ * mix and recording the microphone. `target_object` names a specific node, or is
+ * NULL/"" for the session default.
+ *
+ * Returns NULL on failure with a message in `err`.
+ */
+struct osc_pw_audio *osc_pw_audio_start(const char *target_object, int capture_sink,
+ uint32_t rate, uint32_t channels,
+ const struct osc_pw_audio_callbacks *callbacks, char *err,
+ size_t err_len);
+
+/* Stops the thread loop, joins it, and frees everything. Safe with NULL. */
+void osc_pw_audio_stop(struct osc_pw_audio *audio);
+
#ifdef __cplusplus
}
#endif
diff --git a/electron/native/pipewire-capture/src/capture.rs b/electron/native/pipewire-capture/src/capture.rs
index 8746ee476..95e1f23ce 100644
--- a/electron/native/pipewire-capture/src/capture.rs
+++ b/electron/native/pipewire-capture/src/capture.rs
@@ -20,11 +20,36 @@
//! makes the difference between the two immaterial.
use std::path::{Path, PathBuf};
+use std::sync::Arc;
use std::time::{Duration, Instant};
-use crate::encoder::{Backend, EncodeStats, Muxer, VideoEncoder, VideoParams};
+use crate::encoder::{
+ AudioEncoder, Backend, EncodeStats, Muxer, TrackId, VideoEncoder, VideoParams,
+ AUDIO_CHANNELS, AUDIO_SAMPLE_RATE,
+};
use crate::ffmpeg as ff;
-use crate::shim;
+use crate::shim::{self, AudioRing};
+
+/// An audio capture to mux alongside the video.
+pub struct AudioSource {
+ /// "system" or "microphone" — the label a warning names.
+ pub label: &'static str,
+ pub ring: Arc<AudioRing>,
+ /// Linear multiplier applied before encoding. 1.0 for the system mix; the
+ /// microphone carries the UI's boost.
+ pub gain: f32,
+ pub bitrate: i64,
+}
+
+struct AudioTrack {
+ label: &'static str,
+ ring: Arc<AudioRing>,
+ gain: f32,
+ encoder: AudioEncoder,
+ track: TrackId,
+ /// Reused across drains so the steady state allocates nothing.
+ scratch: Vec<f32>,
+}
/// Frames encoded in one `advance` before returning to the event loop.
///
@@ -49,6 +74,8 @@ pub struct Summary {
pub struct Capture {
encoder: VideoEncoder,
+ video_track: TrackId,
+ audio: Vec<AudioTrack>,
/// `None` only between [`Self::finish`] taking it and the struct dropping.
muxer: Option<Muxer>,
path: PathBuf,
@@ -76,6 +103,7 @@ impl Capture {
fps: i32,
bitrate: i64,
forced: Option<Backend>,
+ audio_sources: Vec<AudioSource>,
) -> Result<(Self, Selection), String> {
let mut rejected = Vec::new();
let encoder = VideoEncoder::open(
@@ -84,11 +112,31 @@ impl Capture {
|backend, error| rejected.push(format!("{}: {error}", backend.as_str())),
)?;
let selection = Selection { backend: encoder.backend(), rejected };
- let muxer = Muxer::create(path, &encoder)?;
+
+ // Every track must exist before the header: MP4 fixes its track list
+ // there, so an audio stream opened later could not be added at all.
+ let mut muxer = Muxer::create(path)?;
+ let video_track = muxer.add_stream(encoder.codec_context())?;
+ let mut audio = Vec::with_capacity(audio_sources.len());
+ for source in audio_sources {
+ let encoder = AudioEncoder::open(source.bitrate)?;
+ let track = muxer.add_stream(encoder.codec_context())?;
+ audio.push(AudioTrack {
+ label: source.label,
+ ring: source.ring,
+ gain: source.gain,
+ encoder,
+ track,
+ scratch: Vec::new(),
+ });
+ }
+ muxer.write_header()?;
Ok((
Self {
encoder,
+ video_track,
+ audio,
muxer: Some(muxer),
path: path.to_path_buf(),
fps,
@@ -109,6 +157,14 @@ impl Capture {
self.encoder.stage(&frame.pixels, frame.stride, format)?;
if self.epoch.is_none() {
self.epoch = Some(Instant::now());
+ // Audio has been accumulating since the process started, while the
+ // portal picker was up and the format was being negotiated. None of
+ // it belongs to the recording: video frame 0 is now, so audio
+ // sample 0 is now too. Keeping the backlog would shift the whole
+ // track earlier by however long the user took to click.
+ for track in &self.audio {
+ track.ring.clear();
+ }
}
Ok(())
}
@@ -131,12 +187,37 @@ impl Capture {
return Ok(0);
};
while self.next_index <= target && written < MAX_CATCHUP_FRAMES {
+ let track = self.video_track;
self.encoder
- .encode_staged(self.next_index, |packet| muxer.write(packet))?;
+ .encode_staged(self.next_index, |packet| muxer.write(track, packet))?;
self.next_index += 1;
self.frames_written += 1;
written += 1;
}
+
+ // Audio is NOT bounded the way video is. A held video frame can be
+ // recreated at any time; a missed audio sample cannot, and the ring
+ // drops the oldest once it fills. Draining every wakeup keeps it far
+ // from that cap — at 48 kHz a 16 ms tick carries about 768 samples.
+ for track in &mut self.audio {
+ track.scratch.clear();
+ track.ring.drain_into(&mut track.scratch);
+ if track.scratch.is_empty() {
+ continue;
+ }
+ if track.gain != 1.0 {
+ for sample in &mut track.scratch {
+ // Clamped: a boosted microphone that clips should clip
+ // flat, not wrap around to the opposite polarity, which is
+ // what an out-of-range float does once AAC quantises it.
+ *sample = (*sample * track.gain).clamp(-1.0, 1.0);
+ }
+ }
+ let id = track.track;
+ track
+ .encoder
+ .push(&track.scratch, |packet| muxer.write(id, packet))?;
+ }
Ok(written)
}
@@ -149,9 +230,26 @@ impl Capture {
pub fn resume(&mut self) {
if let Some(since) = self.paused_at.take() {
self.paused_total += since.elapsed();
+ // Whatever arrived while paused is thrown away rather than encoded:
+ // the video timeline did not advance across the pause, so keeping
+ // the audio would push every later sample out of sync by the length
+ // of the pause.
+ for track in &self.audio {
+ track.ring.clear();
+ }
}
}
+ /// Samples the rings had to discard because the encoder fell behind, per
+ /// track. Audible if non-zero, unlike a dropped video frame.
+ pub fn dropped_audio(&self) -> Vec<(&'static str, u64)> {
+ self.audio
+ .iter()
+ .map(|track| (track.label, track.ring.dropped_samples()))
+ .filter(|(_, dropped)| *dropped > 0)
+ .collect()
+ }
+
pub fn is_paused(&self) -> bool {
self.paused_at.is_some()
}
@@ -162,7 +260,28 @@ impl Capture {
.muxer
.take()
.ok_or_else(|| "capture was already finished".to_owned())?;
- self.encoder.finish(|packet| muxer.write(packet))?;
+
+ // Audio first: whatever is still in the rings is real recorded sound,
+ // and draining it after the video flush keeps both tracks ending at
+ // roughly the same timestamp.
+ for track in &mut self.audio {
+ track.scratch.clear();
+ track.ring.drain_into(&mut track.scratch);
+ if track.gain != 1.0 {
+ for sample in &mut track.scratch {
+ *sample = (*sample * track.gain).clamp(-1.0, 1.0);
+ }
+ }
+ let id = track.track;
+ track
+ .encoder
+ .push(&track.scratch, |packet| muxer.write(id, packet))?;
+ track.encoder.finish(|packet| muxer.write(id, packet))?;
+ }
+
+ let video_track = self.video_track;
+ self.encoder
+ .finish(|packet| muxer.write(video_track, packet))?;
muxer.finish()?;
Ok(Summary {
@@ -264,7 +383,7 @@ mod tests {
fn the_timeline_does_not_start_until_the_first_frame_is_staged() {
let output = std::env::temp_dir().join("openscreen-capture-epoch.mp4");
let (mut capture, _) =
- Capture::start(&output, 320, 240, 30, 1_000_000, Some(Backend::Software))
+ Capture::start(&output, 320, 240, 30, 1_000_000, Some(Backend::Software), Vec::new())
.expect("start");
assert!(!capture.started());
// Nothing staged: advance must not write a frame of uninitialised memory.
@@ -283,7 +402,7 @@ mod tests {
// further arrivals, and the file must still fill with frames.
let output = std::env::temp_dir().join("openscreen-capture-static.mp4");
let (mut capture, _) =
- Capture::start(&output, 320, 240, 30, 1_000_000, Some(Backend::Software))
+ Capture::start(&output, 320, 240, 30, 1_000_000, Some(Backend::Software), Vec::new())
.expect("start");
capture
.stage(&frame(320, 240, shim::constants().video_format_bgrx))
@@ -302,7 +421,7 @@ mod tests {
fn paused_time_does_not_advance_the_timeline() {
let output = std::env::temp_dir().join("openscreen-capture-pause.mp4");
let (mut capture, _) =
- Capture::start(&output, 320, 240, 30, 1_000_000, Some(Backend::Software))
+ Capture::start(&output, 320, 240, 30, 1_000_000, Some(Backend::Software), Vec::new())
.expect("start");
capture
.stage(&frame(320, 240, shim::constants().video_format_bgrx))
@@ -320,11 +439,84 @@ mod tests {
let _ = std::fs::remove_file(&output);
}
+ #[test]
+ fn audio_captured_before_the_first_frame_is_discarded_without_being_called_a_drop() {
+ // Regression: the audio stream opens before the portal picker is
+ // raised, so it records for as long as the user takes to click — easily
+ // past the ring's cap. Those samples are deliberately thrown away when
+ // the video epoch is set. Counting them as overflow made every single
+ // recording report "the encoder could not keep up", which was measured
+ // on a real 29-second capture: 78336 samples, all of them pre-roll.
+ let ring = Arc::new(AudioRing::new(1, 8, AUDIO_CHANNELS));
+ let capacity = 1 * 8 * AUDIO_CHANNELS;
+ ring.push_for_test(&vec![0.5; capacity * 3]);
+ assert!(ring.dropped_samples() > 0, "the ring must have overflowed for this test to mean anything");
+
+ let output = std::env::temp_dir().join("openscreen-capture-audio-preroll.mp4");
+ let (mut capture, _) = Capture::start(
+ &output,
+ 320,
+ 240,
+ 30,
+ 1_000_000,
+ Some(Backend::Software),
+ vec![AudioSource { label: "system", ring: ring.clone(), gain: 1.0, bitrate: 128_000 }],
+ )
+ .expect("start");
+
+ capture
+ .stage(&frame(320, 240, shim::constants().video_format_bgrx))
+ .expect("stage");
+
+ assert_eq!(
+ ring.dropped_samples(),
+ 0,
+ "pre-roll overflow must not be reported as the encoder falling behind"
+ );
+ assert!(capture.dropped_audio().is_empty());
+ let _ = std::fs::remove_file(&output);
+ }
+
+ #[test]
+ fn microphone_gain_clamps_instead_of_wrapping() {
+ // A boosted microphone that clips must clip flat. An out-of-range float
+ // survives until AAC quantises it, and then wraps to the opposite
+ // polarity — which sounds like a burst of noise, not like clipping.
+ let ring = Arc::new(AudioRing::new(1, AUDIO_SAMPLE_RATE as usize, AUDIO_CHANNELS));
+ ring.push_for_test(&[0.9, -0.9, 0.4, -0.4]);
+
+ let output = std::env::temp_dir().join("openscreen-capture-gain.mp4");
+ let (mut capture, _) = Capture::start(
+ &output,
+ 320,
+ 240,
+ 30,
+ 1_000_000,
+ Some(Backend::Software),
+ vec![AudioSource { label: "microphone", ring, gain: 4.0, bitrate: 128_000 }],
+ )
+ .expect("start");
+ capture
+ .stage(&frame(320, 240, shim::constants().video_format_bgrx))
+ .expect("stage");
+
+ // stage() cleared the pre-roll, so feed the samples the run will see.
+ capture.audio[0].ring.push_for_test(&[0.9, -0.9, 0.4, -0.4]);
+ capture.advance().expect("advance");
+ for sample in &capture.audio[0].scratch {
+ assert!(
+ (-1.0..=1.0).contains(sample),
+ "gain produced {sample}, which is outside the representable range"
+ );
+ }
+ let _ = std::fs::remove_file(&output);
+ }
+
#[test]
fn catch_up_is_bounded_so_a_stall_cannot_block_stop() {
let output = std::env::temp_dir().join("openscreen-capture-catchup.mp4");
let (mut capture, _) =
- Capture::start(&output, 320, 240, 60, 1_000_000, Some(Backend::Software))
+ Capture::start(&output, 320, 240, 60, 1_000_000, Some(Backend::Software), Vec::new())
.expect("start");
capture
.stage(&frame(320, 240, shim::constants().video_format_bgrx))
diff --git a/electron/native/pipewire-capture/src/encoder.rs b/electron/native/pipewire-capture/src/encoder.rs
index 47a17aead..58202f6aa 100644
--- a/electron/native/pipewire-capture/src/encoder.rs
+++ b/electron/native/pipewire-capture/src/encoder.rs
@@ -695,7 +695,225 @@ impl Drop for VideoEncoder {
}
}
-/// A single-video-stream MP4 writer.
+/// Sample rate every audio track is captured and encoded at. PipeWire's stream
+/// adapter converts whatever the device runs at, so this is a free choice, and
+/// 48 kHz is what the rest of the pipeline (and MP4) expects.
+pub const AUDIO_SAMPLE_RATE: i32 = 48_000;
+pub const AUDIO_CHANNELS: usize = 2;
+
+/// One AAC track, fed interleaved stereo f32.
+///
+/// AAC encodes in fixed blocks (1024 samples per channel), but PipeWire delivers
+/// whatever quantum the graph is running — 512, 1024, 2048, and it changes at
+/// runtime. So samples accumulate here until a full block exists rather than the
+/// caller having to buffer.
+pub struct AudioEncoder {
+ codec_ctx: *mut ff::AVCodecContext,
+ frame: *mut ff::AVFrame,
+ packet: *mut ff::AVPacket,
+ /// Interleaved samples not yet forming a whole AAC block.
+ pending: Vec<f32>,
+ /// Samples per channel in one block.
+ block: usize,
+ /// Presentation time of the next block, counted in samples — which is
+ /// exactly the codec's time base, so no rounding accumulates.
+ next_pts: i64,
+}
+
+impl AudioEncoder {
+ pub fn open(bitrate: i64) -> Result<Self, String> {
+ // SAFETY: an ffmpeg setup sequence; every allocation is stored in
+ // `encoder` as soon as it succeeds so Drop can free it.
+ unsafe {
+ let codec = ff::avcodec_find_encoder_by_name(c"aac".as_ptr());
+ if codec.is_null() {
+ return Err("the vendored ffmpeg has no AAC encoder".to_owned());
+ }
+ let codec_ctx = ff::avcodec_alloc_context3(codec);
+ if codec_ctx.is_null() {
+ return Err("avcodec_alloc_context3 returned null".to_owned());
+ }
+ let mut encoder = Self {
+ codec_ctx,
+ frame: ptr::null_mut(),
+ packet: ptr::null_mut(),
+ pending: Vec::new(),
+ block: 0,
+ next_pts: 0,
+ };
+
+ (*codec_ctx).sample_rate = AUDIO_SAMPLE_RATE;
+ // The native AAC encoder takes PLANAR float; interleaved is rejected
+ // outright by avcodec_open2, which is why `push` deinterleaves.
+ (*codec_ctx).sample_fmt = ff::AV_SAMPLE_FMT_FLTP;
+ (*codec_ctx).bit_rate = bitrate;
+ (*codec_ctx).time_base = ff::AVRational { num: 1, den: AUDIO_SAMPLE_RATE };
+ ff::av_channel_layout_default(&mut (*codec_ctx).ch_layout, AUDIO_CHANNELS as i32);
+ (*codec_ctx).flags |= ff::AV_CODEC_FLAG_GLOBAL_HEADER as i32;
+
+ let opened = ff::avcodec_open2(codec_ctx, codec, ptr::null_mut());
+ if opened < 0 {
+ return Err(format!("aac avcodec_open2: {}", ff::err_to_string(opened)));
+ }
+ // Only valid after open: the encoder decides its own block size.
+ encoder.block = match (*codec_ctx).frame_size {
+ size if size > 0 => size as usize,
+ _ => 1024,
+ };
+
+ encoder.packet = ff::av_packet_alloc();
+ encoder.frame = ff::av_frame_alloc();
+ if encoder.packet.is_null() || encoder.frame.is_null() {
+ return Err("av_packet_alloc/av_frame_alloc returned null".to_owned());
+ }
+ (*encoder.frame).format = ff::AV_SAMPLE_FMT_FLTP as i32;
+ (*encoder.frame).nb_samples = encoder.block as i32;
+ (*encoder.frame).sample_rate = AUDIO_SAMPLE_RATE;
+ ff::av_channel_layout_default(
+ &mut (*encoder.frame).ch_layout,
+ AUDIO_CHANNELS as i32,
+ );
+ let allocated = ff::av_frame_get_buffer(encoder.frame, 0);
+ if allocated < 0 {
+ return Err(format!(
+ "audio av_frame_get_buffer: {}",
+ ff::err_to_string(allocated)
+ ));
+ }
+
+ Ok(encoder)
+ }
+ }
+
+ pub fn codec_context(&self) -> *mut ff::AVCodecContext {
+ self.codec_ctx
+ }
+
+ /// Feeds interleaved stereo samples, encoding every whole block they complete.
+ pub fn push(
+ &mut self,
+ interleaved: &[f32],
+ mut on_packet: impl FnMut(*mut ff::AVPacket) -> Result<(), String>,
+ ) -> Result<(), String> {
+ self.pending.extend_from_slice(interleaved);
+ let per_block = self.block * AUDIO_CHANNELS;
+ while self.pending.len() >= per_block {
+ // SAFETY: the frame was allocated for exactly `block` samples per
+ // channel, and `pending` has been checked to hold a whole block.
+ unsafe { self.encode_block(per_block, &mut on_packet)? };
+ }
+ Ok(())
+ }
+
+ /// SAFETY: `self.pending` must hold at least `per_block` samples.
+ unsafe fn encode_block(
+ &mut self,
+ per_block: usize,
+ on_packet: &mut impl FnMut(*mut ff::AVPacket) -> Result<(), String>,
+ ) -> Result<(), String> {
+ let writable = ff::av_frame_make_writable(self.frame);
+ if writable < 0 {
+ return Err(format!(
+ "audio av_frame_make_writable: {}",
+ ff::err_to_string(writable)
+ ));
+ }
+ // Interleaved LRLRLR… in, one contiguous plane per channel out.
+ for channel in 0..AUDIO_CHANNELS {
+ let plane = (*self.frame).data[channel] as *mut f32;
+ for sample in 0..self.block {
+ *plane.add(sample) = self.pending[sample * AUDIO_CHANNELS + channel];
+ }
+ }
+ (*self.frame).pts = self.next_pts;
+ self.next_pts += self.block as i64;
+ self.pending.drain(..per_block);
+
+ self.send_and_drain(self.frame, on_packet)
+ }
+
+ /// Pads any partial block with silence, encodes it, and flushes.
+ pub fn finish(
+ &mut self,
+ mut on_packet: impl FnMut(*mut ff::AVPacket) -> Result<(), String>,
+ ) -> Result<(), String> {
+ // SAFETY: padding only grows `pending` to exactly one block, which is
+ // what encode_block requires; a null frame is how ffmpeg is drained.
+ unsafe {
+ if !self.pending.is_empty() {
+ let per_block = self.block * AUDIO_CHANNELS;
+ self.pending.resize(per_block, 0.0);
+ self.encode_block(per_block, &mut on_packet)?;
+ }
+ self.send_and_drain(ptr::null_mut(), &mut on_packet)
+ }
+ }
+
+ /// SAFETY: `frame` is either null (drain) or the frame this encoder owns.
+ unsafe fn send_and_drain(
+ &mut self,
+ frame: *mut ff::AVFrame,
+ on_packet: &mut impl FnMut(*mut ff::AVPacket) -> Result<(), String>,
+ ) -> Result<(), String> {
+ let sent = ff::avcodec_send_frame(self.codec_ctx, frame);
+ if sent < 0 && sent != ff::AVERROR_EOF {
+ return Err(format!("aac avcodec_send_frame: {}", ff::err_to_string(sent)));
+ }
+ loop {
+ let received = ff::avcodec_receive_packet(self.codec_ctx, self.packet);
+ if received == ff::AVERROR_EAGAIN || received == ff::AVERROR_EOF {
+ return Ok(());
+ }
+ if received < 0 {
+ return Err(format!(
+ "aac avcodec_receive_packet: {}",
+ ff::err_to_string(received)
+ ));
+ }
+ let result = on_packet(self.packet);
+ ff::av_packet_unref(self.packet);
+ result?;
+ }
+ }
+}
+
+impl Drop for AudioEncoder {
+ fn drop(&mut self) {
+ // SAFETY: every pointer is either null or owned here.
+ unsafe {
+ if !self.packet.is_null() {
+ ff::av_packet_free(&mut self.packet);
+ }
+ if !self.frame.is_null() {
+ ff::av_frame_free(&mut self.frame);
+ }
+ if !self.codec_ctx.is_null() {
+ ff::avcodec_free_context(&mut self.codec_ctx);
+ }
+ }
+ }
+}
+
+/// Identifies a track added with [`Muxer::add_stream`].
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct TrackId(usize);
+
+struct MuxTrack {
+ /// libavformat's own stream index, which need not equal our `TrackId`.
+ index: i32,
+ /// The time base packets arrive in.
+ source_time_base: ff::AVRational,
+ /// The time base libavformat CHOSE, which is what they must be rescaled to.
+ stream_time_base: ff::AVRational,
+}
+
+/// A multi-track MP4 writer: one video stream plus however many audio tracks.
+///
+/// Audio is written as separate tracks rather than pre-mixed, matching the macOS
+/// helper — see the note in crates/compositor/src/audio.rs, which decodes and
+/// mixes every audio track it finds on export. Keeping them apart means the two
+/// captures never have to be resampled onto a common clock here: each carries
+/// its own timestamps and the container reconciles them.
///
/// `+faststart` is not used: it rewrites the whole file on close, which on a
/// long recording means copying gigabytes. The moov atom is written at the end
@@ -704,14 +922,14 @@ impl Drop for VideoEncoder {
/// and could not be seeked even locally (see electron/recording/webm-seek-index.ts).
pub struct Muxer {
fmt: *mut ff::AVFormatContext,
- stream_index: i32,
- stream_time_base: ff::AVRational,
- encoder_time_base: ff::AVRational,
+ tracks: Vec<MuxTrack>,
header_written: bool,
}
impl Muxer {
- pub fn create(path: &Path, encoder: &VideoEncoder) -> Result<Self, String> {
+ /// Allocates the output and opens the file. No stream exists yet: add them
+ /// all with [`Self::add_stream`], then call [`Self::write_header`].
+ pub fn create(path: &Path) -> Result<Self, String> {
let path_c = CString::new(path.as_os_str().as_encoded_bytes())
.map_err(|_| "output path contains a NUL byte".to_owned())?;
@@ -732,64 +950,90 @@ impl Muxer {
));
}
- let mut muxer = Self {
- fmt,
- stream_index: -1,
- stream_time_base: ff::AVRational { num: 0, den: 1 },
- encoder_time_base: (*encoder.codec_context()).time_base,
- header_written: false,
- };
+ let muxer = Self { fmt, tracks: Vec::new(), header_written: false };
+
+ let opened = ff::avio_open(&mut (*fmt).pb, path_c.as_ptr(), ff::AVIO_FLAG_WRITE as i32);
+ if opened < 0 {
+ return Err(format!(
+ "avio_open({}): {}",
+ path.display(),
+ ff::err_to_string(opened)
+ ));
+ }
- let stream = ff::avformat_new_stream(fmt, ptr::null());
+ Ok(muxer)
+ }
+ }
+
+ /// Adds a track fed by `codec_ctx`. Every track must be added before
+ /// [`Self::write_header`]: MP4 fixes its track list in the header.
+ pub fn add_stream(&mut self, codec_ctx: *mut ff::AVCodecContext) -> Result<TrackId, String> {
+ if self.header_written {
+ return Err("a stream cannot be added after the header is written".to_owned());
+ }
+ // SAFETY: `codec_ctx` is an opened context owned by the caller, and
+ // `fmt` is ours.
+ unsafe {
+ let stream = ff::avformat_new_stream(self.fmt, ptr::null());
if stream.is_null() {
return Err("avformat_new_stream returned null".to_owned());
}
- (*stream).time_base = muxer.encoder_time_base;
- let copied =
- ff::avcodec_parameters_from_context((*stream).codecpar, encoder.codec_context());
+ let source_time_base = (*codec_ctx).time_base;
+ (*stream).time_base = source_time_base;
+ let copied = ff::avcodec_parameters_from_context((*stream).codecpar, codec_ctx);
if copied < 0 {
return Err(format!(
"avcodec_parameters_from_context: {}",
ff::err_to_string(copied)
));
}
- muxer.stream_index = (*stream).index;
-
- let opened = ff::avio_open(&mut (*fmt).pb, path_c.as_ptr(), ff::AVIO_FLAG_WRITE as i32);
- if opened < 0 {
- return Err(format!(
- "avio_open({}): {}",
- path.display(),
- ff::err_to_string(opened)
- ));
- }
+ self.tracks.push(MuxTrack {
+ index: (*stream).index,
+ source_time_base,
+ // Filled in by write_header, which is free to change it.
+ stream_time_base: source_time_base,
+ });
+ Ok(TrackId(self.tracks.len() - 1))
+ }
+ }
- let header = ff::avformat_write_header(fmt, ptr::null_mut());
+ pub fn write_header(&mut self) -> Result<(), String> {
+ if self.tracks.is_empty() {
+ return Err("the output has no streams".to_owned());
+ }
+ // SAFETY: `fmt` is ours and every stream was added through add_stream.
+ unsafe {
+ let header = ff::avformat_write_header(self.fmt, ptr::null_mut());
if header < 0 {
return Err(format!(
"avformat_write_header: {}",
ff::err_to_string(header)
));
}
- muxer.header_written = true;
- // libavformat may have rewritten the stream's time base while
- // writing the header (MP4 prefers 1/90000-style bases). Everything
- // after this must rescale into the value it CHOSE, not the value we
- // asked for — using ours produces a file whose duration is wrong by
- // the ratio between them.
- muxer.stream_time_base = (*stream).time_base;
-
- Ok(muxer)
+ self.header_written = true;
+ // libavformat may have rewritten a stream's time base while writing
+ // the header (MP4 prefers 1/90000-style bases for video and the
+ // sample rate for audio). Everything after this must rescale into
+ // the value it CHOSE, not the value we asked for — using ours
+ // produces a file whose duration is wrong by the ratio between them.
+ for track in &mut self.tracks {
+ let stream = *(*self.fmt).streams.add(track.index as usize);
+ track.stream_time_base = (*stream).time_base;
+ }
}
+ Ok(())
}
- /// Writes one encoded packet, rescaling it out of the encoder's time base.
- pub fn write(&mut self, packet: *mut ff::AVPacket) -> Result<(), String> {
- // SAFETY: `packet` comes from the encoder that this muxer was created
- // for, and is valid until the caller unrefs it.
+ /// Writes one encoded packet, rescaling it out of its encoder's time base.
+ pub fn write(&mut self, track: TrackId, packet: *mut ff::AVPacket) -> Result<(), String> {
+ let Some(track) = self.tracks.get(track.0) else {
+ return Err("packet written to a track that was never added".to_owned());
+ };
+ // SAFETY: `packet` comes from the encoder this track was added for, and
+ // is valid until the caller unrefs it.
unsafe {
- (*packet).stream_index = self.stream_index;
- ff::av_packet_rescale_ts(packet, self.encoder_time_base, self.stream_time_base);
+ (*packet).stream_index = track.index;
+ ff::av_packet_rescale_ts(packet, track.source_time_base, track.stream_time_base);
let written = ff::av_interleaved_write_frame(self.fmt, packet);
if written < 0 {
return Err(format!(
@@ -989,7 +1233,9 @@ mod tests {
.expect("some backend must open");
eprintln!("selected backend: {}", encoder.backend().as_str());
- let mut muxer = Muxer::create(&output, &encoder).expect("muxer");
+ let mut muxer = Muxer::create(&output).expect("muxer");
+ let track = muxer.add_stream(encoder.codec_context()).expect("video track");
+ muxer.write_header().expect("header");
let stride = width as usize * 4;
let mut frame = vec![0u8; stride * height as usize];
let started = std::time::Instant::now();
@@ -1002,10 +1248,10 @@ mod tests {
*byte = ((index as i64 + pts * 7919) % 251) as u8;
}
encoder
- .submit(&frame, stride, ff::AV_PIX_FMT_BGRA, pts, |packet| muxer.write(packet))
+ .submit(&frame, stride, ff::AV_PIX_FMT_BGRA, pts, |packet| muxer.write(track, packet))
.expect("submit");
}
- encoder.finish(|packet| muxer.write(packet)).expect("finish");
+ encoder.finish(|packet| muxer.write(track, packet)).expect("finish");
let elapsed = started.elapsed();
muxer.finish().expect("trailer");
diff --git a/electron/native/pipewire-capture/src/main.rs b/electron/native/pipewire-capture/src/main.rs
index a57ad6f4f..8ec72db3e 100644
--- a/electron/native/pipewire-capture/src/main.rs
+++ b/electron/native/pipewire-capture/src/main.rs
@@ -59,6 +59,39 @@ struct VideoRequest {
bitrate: Option<i64>,
}
+/// Mirrors the `audio` block of `NativeWindowsRecordingRequest`
+/// (src/lib/nativeWindowsRecording.ts) so the three platforms take the same
+/// request shape.
+#[derive(Debug, Default, Deserialize)]
+#[serde(rename_all = "camelCase", default)]
+struct AudioRequest {
+ system: SystemAudioRequest,
+ microphone: MicrophoneRequest,
+}
+
+#[derive(Debug, Default, Deserialize)]
+#[serde(rename_all = "camelCase", default)]
+struct SystemAudioRequest {
+ enabled: bool,
+}
+
+#[derive(Debug, Default, Deserialize)]
+#[serde(rename_all = "camelCase", default)]
+struct MicrophoneRequest {
+ enabled: bool,
+ /// A PipeWire node name (`node.name`), not the browser device id the UI
+ /// carries: the two namespaces are unrelated and there is no mapping
+ /// between them. Absent means the session default source.
+ device_name: Option<String>,
+ /// Linear multiplier the UI applies to microphone level.
+ gain: Option<f32>,
+}
+
+const DEFAULT_AUDIO_BITRATE: i64 = 128_000;
+/// How much audio may queue before the oldest is discarded. Generous: the drain
+/// runs every loop tick, so reaching this means the encoder stopped entirely.
+const AUDIO_RING_SECONDS: usize = 2;
+
#[derive(Debug, Default, Deserialize)]
#[serde(rename_all = "camelCase", default)]
struct Request {
@@ -74,6 +107,7 @@ struct Request {
/// are the two halves of the HUD's cursor-mode toggle.
cursor_mode: Option<String>,
video: Option<VideoRequest>,
+ audio: Option<AudioRequest>,
/// Emit `ready` and exit, without ever calling the portal's `Start()`.
///
/// Everything up to that point is non-interactive; `Start()` is the single
@@ -110,6 +144,50 @@ impl Request {
.filter(|bitrate| *bitrate > 0)
.unwrap_or(DEFAULT_BITRATE)
}
+
+ /// The audio streams to open, in the order they become MP4 tracks.
+ ///
+ /// Empty when no output file was requested: a cursor-only session has
+ /// nothing to mux audio into, and opening a capture stream would show the
+ /// user a recording indicator for a recording that is not happening.
+ fn audio_sources(&self) -> Vec<AudioSourceConfig> {
+ if self.output_path.is_none() {
+ return Vec::new();
+ }
+ let Some(audio) = self.audio.as_ref() else {
+ return Vec::new();
+ };
+ let mut sources = Vec::new();
+ if audio.system.enabled {
+ sources.push(AudioSourceConfig {
+ label: "system",
+ target: None,
+ // The default SINK's monitor: what is being played, not what a
+ // microphone hears.
+ capture_sink: true,
+ gain: 1.0,
+ bitrate: DEFAULT_AUDIO_BITRATE,
+ });
+ }
+ if audio.microphone.enabled {
+ sources.push(AudioSourceConfig {
+ label: "microphone",
+ target: audio.microphone.device_name.clone(),
+ capture_sink: false,
+ gain: audio.microphone.gain.filter(|gain| *gain > 0.0).unwrap_or(1.0),
+ bitrate: DEFAULT_AUDIO_BITRATE,
+ });
+ }
+ sources
+ }
+}
+
+struct AudioSourceConfig {
+ label: &'static str,
+ target: Option<String>,
+ capture_sink: bool,
+ gain: f32,
+ bitrate: i64,
}
enum Message {
@@ -197,6 +275,7 @@ fn main() {
bitrate: request.bitrate(),
forced_encoder,
cursor_mode,
+ audio: request.audio_sources(),
};
let exit_code = run(&mut emitter, receiver, sender, session);
std::process::exit(exit_code);
@@ -213,6 +292,64 @@ struct RunConfig {
bitrate: i64,
forced_encoder: Option<encoder::Backend>,
cursor_mode: portal::CursorMode,
+ audio: Vec<AudioSourceConfig>,
+}
+
+/// Opens every requested audio stream, returning the live sessions (which must
+/// outlive the loop) and the sources to hand to the muxer.
+///
+/// A stream that fails to open is a warning, not a failure: a recording with
+/// picture and no system audio is worth far more to the user than no recording
+/// at all, and the most likely cause — a sandbox without the PipeWire socket —
+/// is not something the helper can fix.
+fn start_audio<W: Write>(
+ emitter: &mut Emitter<W>,
+ configs: &[AudioSourceConfig],
+) -> (Vec<shim::AudioSession>, Vec<capture::AudioSource>) {
+ let mut sessions = Vec::new();
+ let mut sources = Vec::new();
+ for config in configs {
+ let ring = Arc::new(shim::AudioRing::new(
+ AUDIO_RING_SECONDS,
+ encoder::AUDIO_SAMPLE_RATE as usize,
+ encoder::AUDIO_CHANNELS,
+ ));
+ let label = config.label;
+ let session = shim::AudioSession::start(
+ config.target.as_deref(),
+ config.capture_sink,
+ encoder::AUDIO_SAMPLE_RATE as u32,
+ encoder::AUDIO_CHANNELS as u32,
+ ring.clone(),
+ Box::new(move |state, error| {
+ if let Some(error) = error {
+ eprintln!("[audio:{label}] stream error in state {state}: {error}");
+ }
+ }),
+ );
+ match session {
+ Ok(session) => {
+ sessions.push(session);
+ sources.push(capture::AudioSource {
+ label: config.label,
+ ring,
+ gain: config.gain,
+ bitrate: config.bitrate,
+ });
+ }
+ Err(message) => {
+ let _ = emitter.emit(&Event::Warning {
+ code: "audio-unavailable".to_owned(),
+ message: format!(
+ "the {} audio stream could not be opened, so the recording will \
+ have no {} track: {message}",
+ config.label, config.label
+ ),
+ });
+ }
+ }
+ }
+ (sessions, sources)
}
fn parse_request() -> Result<Request, String> {
@@ -314,6 +451,11 @@ fn run<W: Write>(
.as_ref()
.map(|_| Arc::new(FrameMailbox::default()));
let mut capture: Option<Capture> = None;
+ // Started before the portal picker so the streams are warm and the graph
+ // has settled by the time the first video frame arrives. Everything they
+ // record before that first frame is discarded — see `Capture::stage`.
+ // `_audio_sessions` is bound, not dropped: dropping one stops its thread.
+ let (_audio_sessions, mut audio_sources) = start_audio(emitter, &config.audio);
// Buffered until the format is negotiated: the encoder cannot be opened
// before the frame size is known, and `pause` can arrive first.
let mut paused = false;
@@ -484,6 +626,7 @@ fn run<W: Write>(
config.fps,
config.bitrate,
config.forced_encoder,
+ std::mem::take(&mut audio_sources),
) {
Ok((started, selection)) => {
let _ = emitter.emit(&Event::EncoderSelection {
@@ -709,6 +852,16 @@ fn finish_capture<W: Write>(
frames: Option<&FrameMailbox>,
exit_code: &mut i32,
) {
+ for (label, samples) in capture.dropped_audio() {
+ let _ = emitter.emit(&Event::Warning {
+ code: "audio-dropped".to_owned(),
+ message: format!(
+ "{samples} {label} sample(s) were discarded because the encoder could not \
+ keep up. Unlike a dropped video frame, this is audible."
+ ),
+ });
+ }
+
match capture.finish() {
Ok(summary) => {
let dropped = frames.map(FrameMailbox::dropped).unwrap_or(0);
diff --git a/electron/native/pipewire-capture/src/shim.rs b/electron/native/pipewire-capture/src/shim.rs
index 00a8645fd..e7751f38a 100644
--- a/electron/native/pipewire-capture/src/shim.rs
+++ b/electron/native/pipewire-capture/src/shim.rs
@@ -254,6 +254,226 @@ impl FrameMailbox {
}
}
+/// Interleaved samples waiting to be encoded.
+///
+/// UNLIKE THE VIDEO MAILBOX, THIS IS A QUEUE. A dropped video frame costs one
+/// duplicated picture that nobody notices; a dropped audio buffer is an audible
+/// click. So samples accumulate rather than being replaced, and the cap exists
+/// only as a backstop against a consumer that has stopped consuming entirely —
+/// 48 kHz stereo f32 is 384 KB/s, so two seconds is under a megabyte.
+///
+/// Overflow drops the OLDEST samples. If the encoder is that far behind, the
+/// recent audio is the part still worth keeping, and the alternative — refusing
+/// new samples — would freeze the track at the moment of the stall and leave
+/// everything after it misaligned.
+#[derive(Debug)]
+pub struct AudioRing {
+ inner: std::sync::Mutex<std::collections::VecDeque<f32>>,
+ capacity: usize,
+ dropped: std::sync::atomic::AtomicU64,
+}
+
+impl AudioRing {
+ pub fn new(seconds: usize, sample_rate: usize, channels: usize) -> Self {
+ Self {
+ inner: std::sync::Mutex::new(std::collections::VecDeque::new()),
+ capacity: seconds * sample_rate * channels,
+ dropped: std::sync::atomic::AtomicU64::new(0),
+ }
+ }
+
+ fn push(&self, samples: &[f32]) {
+ use std::sync::atomic::Ordering;
+
+ let Ok(mut queue) = self.inner.lock() else {
+ self.dropped.fetch_add(samples.len() as u64, Ordering::Relaxed);
+ return;
+ };
+ queue.extend(samples.iter().copied());
+ if queue.len() > self.capacity {
+ let excess = queue.len() - self.capacity;
+ queue.drain(..excess);
+ self.dropped.fetch_add(excess as u64, Ordering::Relaxed);
+ }
+ }
+
+ /// Moves everything queued into `out`, appending.
+ pub fn drain_into(&self, out: &mut Vec<f32>) {
+ let Ok(mut queue) = self.inner.lock() else {
+ return;
+ };
+ out.reserve(queue.len());
+ out.extend(queue.drain(..));
+ }
+
+ /// Discards everything queued, and forgets any overflow so far.
+ ///
+ /// Called when the video epoch is set and on resume: audio captured before
+ /// the first frame, or during a pause, belongs to no part of the recording,
+ /// and keeping it would offset the whole track.
+ ///
+ /// Resetting `dropped` is the point, not an afterthought. The stream is
+ /// opened before the portal picker is raised, so it records for however long
+ /// the user takes to click — easily past the ring's two-second cap. Counting
+ /// that overflow would report "the encoder could not keep up" on every
+ /// single recording, for audio that was always going to be thrown away.
+ pub fn clear(&self) {
+ if let Ok(mut queue) = self.inner.lock() {
+ queue.clear();
+ }
+ self.dropped.store(0, std::sync::atomic::Ordering::Relaxed);
+ }
+
+ pub fn dropped_samples(&self) -> u64 {
+ self.dropped.load(std::sync::atomic::Ordering::Relaxed)
+ }
+
+ /// Feeds samples as the PipeWire callback would. Test-only: in the shipped
+ /// binary the only writer is `on_audio_samples`.
+ #[cfg(test)]
+ pub fn push_for_test(&self, samples: &[f32]) {
+ self.push(samples);
+ }
+}
+
+#[repr(C)]
+struct RawAudioCallbacks {
+ user: *mut c_void,
+ on_samples: extern "C" fn(*mut c_void, *const f32, u32),
+ on_state: extern "C" fn(*mut c_void, *const c_char, *const c_char),
+}
+
+#[repr(C)]
+struct RawAudioSession {
+ _private: [u8; 0],
+}
+
+extern "C" {
+ fn osc_pw_audio_start(
+ target_object: *const c_char,
+ capture_sink: i32,
+ rate: u32,
+ channels: u32,
+ callbacks: *const RawAudioCallbacks,
+ err: *mut c_char,
+ err_len: usize,
+ ) -> *mut RawAudioSession;
+ fn osc_pw_audio_stop(session: *mut RawAudioSession);
+}
+
+/// What an audio stream reports besides samples.
+pub type AudioStateSink = Box<dyn Fn(String, Option<String>) + Send>;
+
+struct AudioCallbackState {
+ ring: std::sync::Arc<AudioRing>,
+ on_state: AudioStateSink,
+}
+
+/// One running audio capture stream. Dropping it joins its PipeWire thread.
+pub struct AudioSession {
+ raw: *mut RawAudioSession,
+ _state: Box<AudioCallbackState>,
+}
+
+impl AudioSession {
+ /// `target` names a specific PipeWire node, or `None` for the session
+ /// default. `capture_sink` selects a sink's monitor (the system mix) rather
+ /// than a source (a microphone).
+ pub fn start(
+ target: Option<&str>,
+ capture_sink: bool,
+ rate: u32,
+ channels: u32,
+ ring: std::sync::Arc<AudioRing>,
+ on_state: AudioStateSink,
+ ) -> Result<Self, String> {
+ let target_c = match target.filter(|name| !name.is_empty()) {
+ Some(name) => Some(
+ std::ffi::CString::new(name)
+ .map_err(|_| "the audio target name contains a NUL byte".to_owned())?,
+ ),
+ None => None,
+ };
+ let state = Box::new(AudioCallbackState { ring, on_state });
+ let callbacks = RawAudioCallbacks {
+ user: &*state as *const AudioCallbackState as *mut c_void,
+ on_samples: on_audio_samples,
+ on_state: on_audio_state,
+ };
+
+ let mut err = [0 as c_char; ERR_LEN];
+ // SAFETY: `callbacks`, `target_c` and `err` all outlive the call, and
+ // `state` outlives the returned session, which keeps `user` valid for
+ // every callback.
+ let raw = unsafe {
+ osc_pw_audio_start(
+ target_c.as_ref().map_or(std::ptr::null(), |name| name.as_ptr()),
+ i32::from(capture_sink),
+ rate,
+ channels,
+ &callbacks,
+ err.as_mut_ptr(),
+ ERR_LEN,
+ )
+ };
+ if raw.is_null() {
+ return Err(take_error(&err));
+ }
+ Ok(Self { raw, _state: state })
+ }
+}
+
+impl Drop for AudioSession {
+ fn drop(&mut self) {
+ // SAFETY: `raw` came from osc_pw_audio_start and is stopped exactly once.
+ unsafe { osc_pw_audio_stop(self.raw) };
+ }
+}
+
+fn with_audio_state<F>(user: *mut c_void, body: F)
+where
+ F: FnOnce(&AudioCallbackState),
+{
+ if user.is_null() {
+ return;
+ }
+ // SAFETY: `user` points at state owned by a live AudioSession;
+ // osc_pw_audio_stop joins the loop thread before the box is dropped.
+ let state = unsafe { &*(user as *const AudioCallbackState) };
+ let _ = catch_unwind(AssertUnwindSafe(|| body(state)));
+}
+
+extern "C" fn on_audio_samples(user: *mut c_void, samples: *const f32, count: u32) {
+ with_audio_state(user, |state| {
+ if samples.is_null() || count == 0 {
+ return;
+ }
+ // SAFETY: the shim clamped `count` against the buffer's mapped size
+ // before the call, and the mapping outlives it.
+ let slice = unsafe { std::slice::from_raw_parts(samples, count as usize) };
+ state.ring.push(slice);
+ });
+}
+
+extern "C" fn on_audio_state(user: *mut c_void, state_name: *const c_char, error: *const c_char) {
+ with_audio_state(user, |state| {
+ let name = if state_name.is_null() {
+ String::new()
+ } else {
+ // SAFETY: libpipewire's pw_stream_state_as_string returns a static
+ // NUL-terminated string.
+ unsafe { CStr::from_ptr(state_name) }.to_string_lossy().into_owned()
+ };
+ let error = if error.is_null() {
+ None
+ } else {
+ // SAFETY: non-NULL implies a NUL-terminated string that outlives the call.
+ Some(unsafe { CStr::from_ptr(error) }.to_string_lossy().into_owned())
+ };
+ (state.on_state)(name, error);
+ });
+}
+
const ERR_LEN: usize = 256;
fn take_error(buffer: &[c_char; ERR_LEN]) -> String {
diff --git a/electron/native/pipewire-capture/vendor/README.md b/electron/native/pipewire-capture/vendor/README.md
index 377df3ab8..2b6d9f819 100644
--- a/electron/native/pipewire-capture/vendor/README.md
+++ b/electron/native/pipewire-capture/vendor/README.md
@@ -19,19 +19,26 @@ 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.
+Exactly the transitive closure of what `csrc/pw_shim.c` and `csrc/pw_audio.c`
+include — 108 files, computed with `gcc -MM` — not the whole upstream tree.
+Adding a new `#include` to either may therefore need another header vendored.
-To re-vendor after changing the shim's includes, or to move to a newer PipeWire:
+The audio half accounts for 29 of those: `spa/param/audio/` arrived with
+`pw_audio.c`, and `format-utils.h` drags in every codec-specific header in that
+directory (`aac.h`, `flac.h`, `wma.h` …) even though the helper only ever builds
+a raw F32 format. That is upstream's include graph, not a mistake here — the
+closure is copied as computed rather than pruned by hand, so re-running the
+command below reproduces it exactly.
+
+To re-vendor after changing the shims' 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 \
+# 3. List what the shims actually need and copy just those:
+gcc -std=gnu11 -MM csrc/pw_shim.c csrc/pw_audio.c -I"$STAGE" -Icsrc \
| tr ' ' '\n' | grep "^$STAGE" | sort -u
```
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/aac-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/aac-utils.h
new file mode 100644
index 000000000..d15d15271
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/aac-utils.h
@@ -0,0 +1,69 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_AAC_UTILS_H
+#define SPA_AUDIO_AAC_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/audio/format.h>
+#include <spa/param/format-utils.h>
+
+static inline int
+spa_format_audio_aac_parse(const struct spa_pod *format, struct spa_audio_info_aac *info)
+{
+ int res;
+ res = spa_pod_parse_object(format,
+ SPA_TYPE_OBJECT_Format, NULL,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
+ SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels),
+ SPA_FORMAT_AUDIO_bitrate, SPA_POD_OPT_Int(&info->bitrate),
+ SPA_FORMAT_AUDIO_AAC_streamFormat, SPA_POD_OPT_Id(&info->stream_format));
+
+ return res;
+}
+
+static inline struct spa_pod *
+spa_format_audio_aac_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_aac *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_audio),
+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_aac),
+ SPA_FORMAT_AUDIO_format, SPA_POD_Id(SPA_AUDIO_FORMAT_ENCODED),
+ 0);
+ if (info->rate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
+ if (info->channels != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
+ if (info->bitrate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_bitrate, SPA_POD_Int(info->bitrate), 0);
+ if (info->stream_format != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_AAC_streamFormat, SPA_POD_Id(info->stream_format), 0);
+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
+}
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_AAC_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/aac.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/aac.h
new file mode 100644
index 000000000..b44274154
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/aac.h
@@ -0,0 +1,51 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_AAC_H
+#define SPA_AUDIO_AAC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <spa/param/audio/raw.h>
+
+enum spa_audio_aac_stream_format {
+ SPA_AUDIO_AAC_STREAM_FORMAT_UNKNOWN,
+ /* Raw AAC frames */
+ SPA_AUDIO_AAC_STREAM_FORMAT_RAW,
+ /* ISO/IEC 13818-7 MPEG-2 Audio Data Transport Stream (ADTS) */
+ SPA_AUDIO_AAC_STREAM_FORMAT_MP2ADTS,
+ /* ISO/IEC 14496-3 MPEG-4 Audio Data Transport Stream (ADTS) */
+ SPA_AUDIO_AAC_STREAM_FORMAT_MP4ADTS,
+ /* ISO/IEC 14496-3 Low Overhead Audio Stream (LOAS) */
+ SPA_AUDIO_AAC_STREAM_FORMAT_MP4LOAS,
+ /* ISO/IEC 14496-3 Low Overhead Audio Transport Multiplex (LATM) */
+ SPA_AUDIO_AAC_STREAM_FORMAT_MP4LATM,
+ /* ISO/IEC 14496-3 Audio Data Interchange Format (ADIF) */
+ SPA_AUDIO_AAC_STREAM_FORMAT_ADIF,
+ /* ISO/IEC 14496-12 MPEG-4 file format */
+ SPA_AUDIO_AAC_STREAM_FORMAT_MP4FF,
+
+ SPA_AUDIO_AAC_STREAM_FORMAT_CUSTOM = 0x10000,
+};
+
+struct spa_audio_info_aac {
+ uint32_t rate; /*< sample rate */
+ uint32_t channels; /*< number of channels */
+ uint32_t bitrate; /*< stream bitrate */
+ enum spa_audio_aac_stream_format stream_format; /*< AAC audio stream format */
+};
+
+#define SPA_AUDIO_INFO_AAC_INIT(...) ((struct spa_audio_info_aac) { __VA_ARGS__ })
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_AAC_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/alac-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/alac-utils.h
new file mode 100644
index 000000000..6d34d79d5
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/alac-utils.h
@@ -0,0 +1,60 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_ALAC_UTILS_H
+#define SPA_AUDIO_ALAC_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/audio/format.h>
+#include <spa/param/format-utils.h>
+
+static inline int
+spa_format_audio_alac_parse(const struct spa_pod *format, struct spa_audio_info_alac *info)
+{
+ int res;
+ res = spa_pod_parse_object(format,
+ SPA_TYPE_OBJECT_Format, NULL,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
+ SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels));
+ return res;
+}
+
+static inline struct spa_pod *
+spa_format_audio_alac_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_alac *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_audio),
+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_alac),
+ SPA_FORMAT_AUDIO_format, SPA_POD_Id(SPA_AUDIO_FORMAT_ENCODED),
+ 0);
+ if (info->rate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
+ if (info->channels != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
+}
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_ALAC_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/alac.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/alac.h
new file mode 100644
index 000000000..2f70222de
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/alac.h
@@ -0,0 +1,29 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_ALAC_H
+#define SPA_AUDIO_ALAC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <spa/param/audio/raw.h>
+
+struct spa_audio_info_alac {
+ uint32_t rate; /*< sample rate */
+ uint32_t channels; /*< number of channels */
+};
+
+#define SPA_AUDIO_INFO_ALAC_INIT(...) ((struct spa_audio_info_alac) { __VA_ARGS__ })
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_ALAC_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/amr-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/amr-utils.h
new file mode 100644
index 000000000..1f100559f
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/amr-utils.h
@@ -0,0 +1,64 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_AMR_UTILS_H
+#define SPA_AUDIO_AMR_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/audio/format.h>
+#include <spa/param/format-utils.h>
+
+static inline int
+spa_format_audio_amr_parse(const struct spa_pod *format, struct spa_audio_info_amr *info)
+{
+ int res;
+ res = spa_pod_parse_object(format,
+ SPA_TYPE_OBJECT_Format, NULL,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
+ SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels),
+ SPA_FORMAT_AUDIO_AMR_bandMode, SPA_POD_OPT_Id(&info->band_mode));
+ return res;
+}
+
+static inline struct spa_pod *
+spa_format_audio_amr_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_amr *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_audio),
+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_amr),
+ SPA_FORMAT_AUDIO_format, SPA_POD_Id(SPA_AUDIO_FORMAT_ENCODED),
+ 0);
+ if (info->rate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
+ if (info->channels != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
+ if (info->band_mode != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_AMR_bandMode, SPA_POD_Id(info->band_mode), 0);
+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
+}
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_AMR_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/amr.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/amr.h
new file mode 100644
index 000000000..f0329471d
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/amr.h
@@ -0,0 +1,36 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_AMR_H
+#define SPA_AUDIO_AMR_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <spa/param/audio/raw.h>
+
+enum spa_audio_amr_band_mode {
+ SPA_AUDIO_AMR_BAND_MODE_UNKNOWN,
+ SPA_AUDIO_AMR_BAND_MODE_NB,
+ SPA_AUDIO_AMR_BAND_MODE_WB,
+};
+
+struct spa_audio_info_amr {
+ uint32_t rate; /*< sample rate */
+ uint32_t channels; /*< number of channels */
+ enum spa_audio_amr_band_mode band_mode;
+};
+
+#define SPA_AUDIO_INFO_AMR_INIT(...) ((struct spa_audio_info_amr) { __VA_ARGS__ })
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_AMR_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/ape-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/ape-utils.h
new file mode 100644
index 000000000..c36ada21c
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/ape-utils.h
@@ -0,0 +1,60 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_APE_UTILS_H
+#define SPA_AUDIO_APE_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/audio/format.h>
+#include <spa/param/format-utils.h>
+
+static inline int
+spa_format_audio_ape_parse(const struct spa_pod *format, struct spa_audio_info_ape *info)
+{
+ int res;
+ res = spa_pod_parse_object(format,
+ SPA_TYPE_OBJECT_Format, NULL,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
+ SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels));
+ return res;
+}
+
+static inline struct spa_pod *
+spa_format_audio_ape_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_ape *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_audio),
+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_ape),
+ SPA_FORMAT_AUDIO_format, SPA_POD_Id(SPA_AUDIO_FORMAT_ENCODED),
+ 0);
+ if (info->rate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
+ if (info->channels != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
+}
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_APE_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/ape.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/ape.h
new file mode 100644
index 000000000..2ea5c2ef8
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/ape.h
@@ -0,0 +1,29 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_APE_H
+#define SPA_AUDIO_APE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <spa/param/audio/raw.h>
+
+struct spa_audio_info_ape {
+ uint32_t rate; /*< sample rate */
+ uint32_t channels; /*< number of channels */
+};
+
+#define SPA_AUDIO_INFO_APE_INIT(...) ((struct spa_audio_info_ape) { __VA_ARGS__ })
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_APE_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/dsd-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/dsd-utils.h
new file mode 100644
index 000000000..a4637ef0f
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/dsd-utils.h
@@ -0,0 +1,80 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_DSD_UTILS_H
+#define SPA_AUDIO_DSD_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/format-utils.h>
+#include <spa/param/audio/format.h>
+
+static inline int
+spa_format_audio_dsd_parse(const struct spa_pod *format, struct spa_audio_info_dsd *info)
+{
+ struct spa_pod *position = NULL;
+ int res;
+ info->flags = 0;
+ res = spa_pod_parse_object(format,
+ SPA_TYPE_OBJECT_Format, NULL,
+ SPA_FORMAT_AUDIO_bitorder, SPA_POD_OPT_Id(&info->bitorder),
+ SPA_FORMAT_AUDIO_interleave, SPA_POD_OPT_Int(&info->interleave),
+ SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
+ SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels),
+ SPA_FORMAT_AUDIO_position, SPA_POD_OPT_Pod(&position));
+ if (position == NULL ||
+ !spa_pod_copy_array(position, SPA_TYPE_Id, info->position, SPA_AUDIO_MAX_CHANNELS))
+ SPA_FLAG_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED);
+
+ return res;
+}
+
+static inline struct spa_pod *
+spa_format_audio_dsd_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_dsd *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_audio),
+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_dsd),
+ 0);
+ if (info->bitorder != SPA_PARAM_BITORDER_unknown)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_bitorder, SPA_POD_Id(info->bitorder), 0);
+ if (info->interleave != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_interleave, SPA_POD_Int(info->interleave), 0);
+ if (info->rate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
+ if (info->channels != 0) {
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
+ if (!SPA_FLAG_IS_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED)) {
+ spa_pod_builder_add(builder, SPA_FORMAT_AUDIO_position,
+ SPA_POD_Array(sizeof(uint32_t), SPA_TYPE_Id,
+ info->channels, info->position), 0);
+ }
+ }
+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
+}
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_DSD_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/dsd.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/dsd.h
new file mode 100644
index 000000000..53678d4c5
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/dsd.h
@@ -0,0 +1,61 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2021 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_DSD_H
+#define SPA_AUDIO_DSD_H
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <spa/param/param.h>
+#include <spa/param/audio/raw.h>
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+/** Extra DSD audio flags */
+#define SPA_AUDIO_DSD_FLAG_NONE (0) /*< no valid flag */
+
+/* DSD bits are transferred in a buffer grouped in bytes with the bitorder
+ * defined by \a bitorder.
+ *
+ * Channels are placed in separate planes (interleave = 0) or interleaved
+ * using the interleave value. A negative interleave value means that the
+ * bytes need to be reversed in the group.
+ *
+ * Planar (interleave = 0):
+ * plane1: l1 l2 l3 l4 l5 ...
+ * plane2: r1 r2 r3 r4 r5 ...
+ *
+ * Interleaved 4:
+ * plane1: l1 l2 l3 l4 r1 r2 r3 r4 l5 l6 l7 l8 r5 r6 r7 r8 l9 ...
+ *
+ * Interleaved 2:
+ * plane1: l1 l2 r1 r2 l3 l4 r3 r4 ...
+ */
+struct spa_audio_info_dsd {
+ enum spa_param_bitorder bitorder; /*< the order of the bits */
+ uint32_t flags; /*< extra flags */
+ int32_t interleave; /*< interleave bytes */
+ uint32_t rate; /*< sample rate (in bytes per second) */
+ uint32_t channels; /*< channels */
+ uint32_t position[SPA_AUDIO_MAX_CHANNELS]; /*< channel position from enum spa_audio_channel */
+};
+
+#define SPA_AUDIO_INFO_DSD_INIT(...) ((struct spa_audio_info_dsd) { __VA_ARGS__ })
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_DSD_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/dsp-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/dsp-utils.h
new file mode 100644
index 000000000..47eeea5e8
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/dsp-utils.h
@@ -0,0 +1,55 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_DSP_UTILS_H
+#define SPA_AUDIO_DSP_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/audio/format.h>
+#include <spa/param/format-utils.h>
+
+static inline int
+spa_format_audio_dsp_parse(const struct spa_pod *format, struct spa_audio_info_dsp *info)
+{
+ int res;
+ res = spa_pod_parse_object(format,
+ SPA_TYPE_OBJECT_Format, NULL,
+ SPA_FORMAT_AUDIO_format, SPA_POD_OPT_Id(&info->format));
+ return res;
+}
+
+static inline struct spa_pod *
+spa_format_audio_dsp_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_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_audio),
+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_dsp),
+ 0);
+ if (info->format != SPA_AUDIO_FORMAT_UNKNOWN)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_format, SPA_POD_Id(info->format), 0);
+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
+}
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_DSP_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/dsp.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/dsp.h
new file mode 100644
index 000000000..f33c266ae
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/dsp.h
@@ -0,0 +1,28 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_DSP_H
+#define SPA_AUDIO_DSP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <spa/param/audio/raw.h>
+
+struct spa_audio_info_dsp {
+ enum spa_audio_format format; /*< format, one of the DSP formats in enum spa_audio_format */
+};
+
+#define SPA_AUDIO_INFO_DSP_INIT(...) ((struct spa_audio_info_dsp) { __VA_ARGS__ })
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_DSP_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/flac-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/flac-utils.h
new file mode 100644
index 000000000..f59788dd4
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/flac-utils.h
@@ -0,0 +1,60 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_FLAC_UTILS_H
+#define SPA_AUDIO_FLAC_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/audio/format.h>
+#include <spa/param/format-utils.h>
+
+static inline int
+spa_format_audio_flac_parse(const struct spa_pod *format, struct spa_audio_info_flac *info)
+{
+ int res;
+ res = spa_pod_parse_object(format,
+ SPA_TYPE_OBJECT_Format, NULL,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
+ SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels));
+ return res;
+}
+
+static inline struct spa_pod *
+spa_format_audio_flac_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_flac *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_audio),
+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_flac),
+ SPA_FORMAT_AUDIO_format, SPA_POD_Id(SPA_AUDIO_FORMAT_ENCODED),
+ 0);
+ if (info->rate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
+ if (info->channels != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
+}
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_FLAC_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/flac.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/flac.h
new file mode 100644
index 000000000..e45745838
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/flac.h
@@ -0,0 +1,29 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_FLAC_H
+#define SPA_AUDIO_FLAC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <spa/param/audio/raw.h>
+
+struct spa_audio_info_flac {
+ uint32_t rate; /*< sample rate */
+ uint32_t channels; /*< number of channels */
+};
+
+#define SPA_AUDIO_INFO_FLAC_INIT(...) ((struct spa_audio_info_flac) { __VA_ARGS__ })
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_FLAC_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/format-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/format-utils.h
new file mode 100644
index 000000000..3acf2043f
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/format-utils.h
@@ -0,0 +1,121 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_PARAM_AUDIO_FORMAT_UTILS_H
+#define SPA_PARAM_AUDIO_FORMAT_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/audio/format.h>
+#include <spa/param/format-utils.h>
+
+#include <spa/param/audio/raw-utils.h>
+#include <spa/param/audio/dsp-utils.h>
+#include <spa/param/audio/iec958-utils.h>
+#include <spa/param/audio/dsd-utils.h>
+#include <spa/param/audio/mp3-utils.h>
+#include <spa/param/audio/aac-utils.h>
+#include <spa/param/audio/vorbis-utils.h>
+#include <spa/param/audio/wma-utils.h>
+#include <spa/param/audio/ra-utils.h>
+#include <spa/param/audio/amr-utils.h>
+#include <spa/param/audio/alac-utils.h>
+#include <spa/param/audio/flac-utils.h>
+#include <spa/param/audio/ape-utils.h>
+
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+static inline int
+spa_format_audio_parse(const struct spa_pod *format, struct spa_audio_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_audio)
+ return -EINVAL;
+
+ switch (info->media_subtype) {
+ case SPA_MEDIA_SUBTYPE_raw:
+ return spa_format_audio_raw_parse(format, &info->info.raw);
+ case SPA_MEDIA_SUBTYPE_dsp:
+ return spa_format_audio_dsp_parse(format, &info->info.dsp);
+ case SPA_MEDIA_SUBTYPE_iec958:
+ return spa_format_audio_iec958_parse(format, &info->info.iec958);
+ case SPA_MEDIA_SUBTYPE_dsd:
+ return spa_format_audio_dsd_parse(format, &info->info.dsd);
+ case SPA_MEDIA_SUBTYPE_mp3:
+ return spa_format_audio_mp3_parse(format, &info->info.mp3);
+ case SPA_MEDIA_SUBTYPE_aac:
+ return spa_format_audio_aac_parse(format, &info->info.aac);
+ case SPA_MEDIA_SUBTYPE_vorbis:
+ return spa_format_audio_vorbis_parse(format, &info->info.vorbis);
+ case SPA_MEDIA_SUBTYPE_wma:
+ return spa_format_audio_wma_parse(format, &info->info.wma);
+ case SPA_MEDIA_SUBTYPE_ra:
+ return spa_format_audio_ra_parse(format, &info->info.ra);
+ case SPA_MEDIA_SUBTYPE_amr:
+ return spa_format_audio_amr_parse(format, &info->info.amr);
+ case SPA_MEDIA_SUBTYPE_alac:
+ return spa_format_audio_alac_parse(format, &info->info.alac);
+ case SPA_MEDIA_SUBTYPE_flac:
+ return spa_format_audio_flac_parse(format, &info->info.flac);
+ case SPA_MEDIA_SUBTYPE_ape:
+ return spa_format_audio_ape_parse(format, &info->info.ape);
+ }
+ return -ENOTSUP;
+}
+
+static inline struct spa_pod *
+spa_format_audio_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info *info)
+{
+ switch (info->media_subtype) {
+ case SPA_MEDIA_SUBTYPE_raw:
+ return spa_format_audio_raw_build(builder, id, &info->info.raw);
+ case SPA_MEDIA_SUBTYPE_dsp:
+ return spa_format_audio_dsp_build(builder, id, &info->info.dsp);
+ case SPA_MEDIA_SUBTYPE_iec958:
+ return spa_format_audio_iec958_build(builder, id, &info->info.iec958);
+ case SPA_MEDIA_SUBTYPE_dsd:
+ return spa_format_audio_dsd_build(builder, id, &info->info.dsd);
+ case SPA_MEDIA_SUBTYPE_mp3:
+ return spa_format_audio_mp3_build(builder, id, &info->info.mp3);
+ case SPA_MEDIA_SUBTYPE_aac:
+ return spa_format_audio_aac_build(builder, id, &info->info.aac);
+ case SPA_MEDIA_SUBTYPE_vorbis:
+ return spa_format_audio_vorbis_build(builder, id, &info->info.vorbis);
+ case SPA_MEDIA_SUBTYPE_wma:
+ return spa_format_audio_wma_build(builder, id, &info->info.wma);
+ case SPA_MEDIA_SUBTYPE_ra:
+ return spa_format_audio_ra_build(builder, id, &info->info.ra);
+ case SPA_MEDIA_SUBTYPE_amr:
+ return spa_format_audio_amr_build(builder, id, &info->info.amr);
+ case SPA_MEDIA_SUBTYPE_alac:
+ return spa_format_audio_alac_build(builder, id, &info->info.alac);
+ case SPA_MEDIA_SUBTYPE_flac:
+ return spa_format_audio_flac_build(builder, id, &info->info.flac);
+ case SPA_MEDIA_SUBTYPE_ape:
+ return spa_format_audio_ape_build(builder, id, &info->info.ape);
+ }
+ errno = ENOTSUP;
+ return NULL;
+}
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_PARAM_AUDIO_FORMAT_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/format.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/format.h
new file mode 100644
index 000000000..0619de394
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/format.h
@@ -0,0 +1,62 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_PARAM_AUDIO_FORMAT_H
+#define SPA_PARAM_AUDIO_FORMAT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/param/format.h>
+#include <spa/param/audio/raw.h>
+#include <spa/param/audio/dsp.h>
+#include <spa/param/audio/iec958.h>
+#include <spa/param/audio/dsd.h>
+#include <spa/param/audio/mp3.h>
+#include <spa/param/audio/aac.h>
+#include <spa/param/audio/vorbis.h>
+#include <spa/param/audio/wma.h>
+#include <spa/param/audio/ra.h>
+#include <spa/param/audio/amr.h>
+#include <spa/param/audio/alac.h>
+#include <spa/param/audio/flac.h>
+#include <spa/param/audio/ape.h>
+#include <spa/param/audio/opus.h>
+
+struct spa_audio_info {
+ uint32_t media_type;
+ uint32_t media_subtype;
+ union {
+ struct spa_audio_info_raw raw;
+ struct spa_audio_info_dsp dsp;
+ struct spa_audio_info_iec958 iec958;
+ struct spa_audio_info_dsd dsd;
+ struct spa_audio_info_mp3 mp3;
+ struct spa_audio_info_aac aac;
+ struct spa_audio_info_vorbis vorbis;
+ struct spa_audio_info_wma wma;
+ struct spa_audio_info_ra ra;
+ struct spa_audio_info_amr amr;
+ struct spa_audio_info_alac alac;
+ struct spa_audio_info_flac flac;
+ struct spa_audio_info_ape ape;
+ struct spa_audio_info_ape opus;
+ } info;
+};
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_PARAM_AUDIO_FORMAT_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/iec958-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/iec958-utils.h
new file mode 100644
index 000000000..7bebe57d8
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/iec958-utils.h
@@ -0,0 +1,59 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_IEC958_UTILS_H
+#define SPA_AUDIO_IEC958_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/audio/format.h>
+#include <spa/param/format-utils.h>
+
+static inline int
+spa_format_audio_iec958_parse(const struct spa_pod *format, struct spa_audio_info_iec958 *info)
+{
+ int res;
+ res = spa_pod_parse_object(format,
+ SPA_TYPE_OBJECT_Format, NULL,
+ SPA_FORMAT_AUDIO_iec958Codec, SPA_POD_OPT_Id(&info->codec),
+ SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate));
+ return res;
+}
+
+static inline struct spa_pod *
+spa_format_audio_iec958_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_iec958 *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_audio),
+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_iec958),
+ 0);
+ if (info->codec != SPA_AUDIO_IEC958_CODEC_UNKNOWN)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_iec958Codec, SPA_POD_Id(info->codec), 0);
+ if (info->rate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
+}
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_IEC958_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/iec958.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/iec958.h
new file mode 100644
index 000000000..05475188e
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/iec958.h
@@ -0,0 +1,49 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2021 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_IEC958_H
+#define SPA_AUDIO_IEC958_H
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+enum spa_audio_iec958_codec {
+ SPA_AUDIO_IEC958_CODEC_UNKNOWN,
+
+ SPA_AUDIO_IEC958_CODEC_PCM,
+ SPA_AUDIO_IEC958_CODEC_DTS,
+ SPA_AUDIO_IEC958_CODEC_AC3,
+ SPA_AUDIO_IEC958_CODEC_MPEG, /**< MPEG-1 or MPEG-2 (Part 3, not AAC) */
+ SPA_AUDIO_IEC958_CODEC_MPEG2_AAC, /**< MPEG-2 AAC */
+
+ SPA_AUDIO_IEC958_CODEC_EAC3,
+
+ SPA_AUDIO_IEC958_CODEC_TRUEHD, /**< Dolby TrueHD */
+ SPA_AUDIO_IEC958_CODEC_DTSHD, /**< DTS-HD Master Audio */
+};
+
+struct spa_audio_info_iec958 {
+ enum spa_audio_iec958_codec codec; /*< format, one of the DSP formats in enum spa_audio_format_dsp */
+ uint32_t flags; /*< extra flags */
+ uint32_t rate; /*< sample rate */
+};
+
+#define SPA_AUDIO_INFO_IEC958_INIT(...) ((struct spa_audio_info_iec958) { __VA_ARGS__ })
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_IEC958_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/mp3-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/mp3-utils.h
new file mode 100644
index 000000000..b0fd5b7a8
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/mp3-utils.h
@@ -0,0 +1,60 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_MP3_UTILS_H
+#define SPA_AUDIO_MP3_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/audio/format.h>
+#include <spa/param/format-utils.h>
+
+static inline int
+spa_format_audio_mp3_parse(const struct spa_pod *format, struct spa_audio_info_mp3 *info)
+{
+ int res;
+ res = spa_pod_parse_object(format,
+ SPA_TYPE_OBJECT_Format, NULL,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
+ SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels));
+ return res;
+}
+
+static inline struct spa_pod *
+spa_format_audio_mp3_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_mp3 *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_audio),
+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_mp3),
+ SPA_FORMAT_AUDIO_format, SPA_POD_Id(SPA_AUDIO_FORMAT_ENCODED),
+ 0);
+ if (info->rate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
+ if (info->channels != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
+}
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_MP3_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/mp3.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/mp3.h
new file mode 100644
index 000000000..6543819a8
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/mp3.h
@@ -0,0 +1,37 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_MP3_H
+#define SPA_AUDIO_MP3_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <spa/param/audio/raw.h>
+
+enum spa_audio_mp3_channel_mode {
+ SPA_AUDIO_MP3_CHANNEL_MODE_UNKNOWN,
+ SPA_AUDIO_MP3_CHANNEL_MODE_MONO,
+ SPA_AUDIO_MP3_CHANNEL_MODE_STEREO,
+ SPA_AUDIO_MP3_CHANNEL_MODE_JOINTSTEREO,
+ SPA_AUDIO_MP3_CHANNEL_MODE_DUAL,
+};
+
+struct spa_audio_info_mp3 {
+ uint32_t rate; /*< sample rate */
+ uint32_t channels; /*< number of channels */
+};
+
+#define SPA_AUDIO_INFO_MP3_INIT(...) ((struct spa_audio_info_mp3) { __VA_ARGS__ })
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_MP3_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/opus.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/opus.h
new file mode 100644
index 000000000..f27dc6306
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/opus.h
@@ -0,0 +1,29 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_OPUS_H
+#define SPA_AUDIO_OPUS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <spa/param/audio/raw.h>
+
+struct spa_audio_info_opus {
+ uint32_t rate; /*< sample rate */
+ uint32_t channels; /*< number of channels */
+};
+
+#define SPA_AUDIO_INFO_OPUS_INIT(...) ((struct spa_audio_info_opus) { __VA_ARGS__ })
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_OPUS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/ra-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/ra-utils.h
new file mode 100644
index 000000000..c2efd26dc
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/ra-utils.h
@@ -0,0 +1,60 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_RA_UTILS_H
+#define SPA_AUDIO_RA_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/audio/format.h>
+#include <spa/param/format-utils.h>
+
+static inline int
+spa_format_audio_ra_parse(const struct spa_pod *format, struct spa_audio_info_ra *info)
+{
+ int res;
+ res = spa_pod_parse_object(format,
+ SPA_TYPE_OBJECT_Format, NULL,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
+ SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels));
+ return res;
+}
+
+static inline struct spa_pod *
+spa_format_audio_ra_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_ra *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_audio),
+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_ra),
+ SPA_FORMAT_AUDIO_format, SPA_POD_Id(SPA_AUDIO_FORMAT_ENCODED),
+ 0);
+ if (info->rate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
+ if (info->channels != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
+}
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_RA_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/ra.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/ra.h
new file mode 100644
index 000000000..3dba2919f
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/ra.h
@@ -0,0 +1,29 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_RA_H
+#define SPA_AUDIO_RA_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <spa/param/audio/raw.h>
+
+struct spa_audio_info_ra {
+ uint32_t rate; /*< sample rate */
+ uint32_t channels; /*< number of channels */
+};
+
+#define SPA_AUDIO_INFO_RA_INIT(...) ((struct spa_audio_info_ra) { __VA_ARGS__ })
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_RA_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/raw-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/raw-utils.h
new file mode 100644
index 000000000..e24ec84b0
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/raw-utils.h
@@ -0,0 +1,76 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_RAW_UTILS_H
+#define SPA_AUDIO_RAW_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/audio/format.h>
+#include <spa/param/format-utils.h>
+
+static inline int
+spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_raw *info)
+{
+ struct spa_pod *position = NULL;
+ int res;
+ info->flags = 0;
+ res = spa_pod_parse_object(format,
+ SPA_TYPE_OBJECT_Format, NULL,
+ SPA_FORMAT_AUDIO_format, SPA_POD_OPT_Id(&info->format),
+ SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
+ SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels),
+ SPA_FORMAT_AUDIO_position, SPA_POD_OPT_Pod(&position));
+ if (position == NULL ||
+ !spa_pod_copy_array(position, SPA_TYPE_Id, info->position, SPA_AUDIO_MAX_CHANNELS))
+ SPA_FLAG_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED);
+
+ return res;
+}
+
+static inline struct spa_pod *
+spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_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_audio),
+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
+ 0);
+ if (info->format != SPA_AUDIO_FORMAT_UNKNOWN)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_format, SPA_POD_Id(info->format), 0);
+ if (info->rate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
+ if (info->channels != 0) {
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
+ if (!SPA_FLAG_IS_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED)) {
+ spa_pod_builder_add(builder, SPA_FORMAT_AUDIO_position,
+ SPA_POD_Array(sizeof(uint32_t), SPA_TYPE_Id,
+ info->channels, info->position), 0);
+ }
+ }
+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
+}
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_RAW_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/raw.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/raw.h
new file mode 100644
index 000000000..a357d5597
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/raw.h
@@ -0,0 +1,303 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_RAW_H
+#define SPA_AUDIO_RAW_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+#if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
+#include <endian.h>
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#define SPA_AUDIO_MAX_CHANNELS 64u
+
+enum spa_audio_format {
+ SPA_AUDIO_FORMAT_UNKNOWN,
+ SPA_AUDIO_FORMAT_ENCODED,
+
+ /* interleaved formats */
+ SPA_AUDIO_FORMAT_START_Interleaved = 0x100,
+ SPA_AUDIO_FORMAT_S8,
+ SPA_AUDIO_FORMAT_U8,
+ SPA_AUDIO_FORMAT_S16_LE,
+ SPA_AUDIO_FORMAT_S16_BE,
+ SPA_AUDIO_FORMAT_U16_LE,
+ SPA_AUDIO_FORMAT_U16_BE,
+ SPA_AUDIO_FORMAT_S24_32_LE,
+ SPA_AUDIO_FORMAT_S24_32_BE,
+ SPA_AUDIO_FORMAT_U24_32_LE,
+ SPA_AUDIO_FORMAT_U24_32_BE,
+ SPA_AUDIO_FORMAT_S32_LE,
+ SPA_AUDIO_FORMAT_S32_BE,
+ SPA_AUDIO_FORMAT_U32_LE,
+ SPA_AUDIO_FORMAT_U32_BE,
+ SPA_AUDIO_FORMAT_S24_LE,
+ SPA_AUDIO_FORMAT_S24_BE,
+ SPA_AUDIO_FORMAT_U24_LE,
+ SPA_AUDIO_FORMAT_U24_BE,
+ SPA_AUDIO_FORMAT_S20_LE,
+ SPA_AUDIO_FORMAT_S20_BE,
+ SPA_AUDIO_FORMAT_U20_LE,
+ SPA_AUDIO_FORMAT_U20_BE,
+ SPA_AUDIO_FORMAT_S18_LE,
+ SPA_AUDIO_FORMAT_S18_BE,
+ SPA_AUDIO_FORMAT_U18_LE,
+ SPA_AUDIO_FORMAT_U18_BE,
+ SPA_AUDIO_FORMAT_F32_LE,
+ SPA_AUDIO_FORMAT_F32_BE,
+ SPA_AUDIO_FORMAT_F64_LE,
+ SPA_AUDIO_FORMAT_F64_BE,
+
+ SPA_AUDIO_FORMAT_ULAW,
+ SPA_AUDIO_FORMAT_ALAW,
+
+ /* planar formats */
+ SPA_AUDIO_FORMAT_START_Planar = 0x200,
+ SPA_AUDIO_FORMAT_U8P,
+ SPA_AUDIO_FORMAT_S16P,
+ SPA_AUDIO_FORMAT_S24_32P,
+ SPA_AUDIO_FORMAT_S32P,
+ SPA_AUDIO_FORMAT_S24P,
+ SPA_AUDIO_FORMAT_F32P,
+ SPA_AUDIO_FORMAT_F64P,
+ SPA_AUDIO_FORMAT_S8P,
+
+ /* other formats start here */
+ SPA_AUDIO_FORMAT_START_Other = 0x400,
+
+ /* Aliases */
+
+ /* DSP formats */
+ SPA_AUDIO_FORMAT_DSP_S32 = SPA_AUDIO_FORMAT_S24_32P,
+ SPA_AUDIO_FORMAT_DSP_F32 = SPA_AUDIO_FORMAT_F32P,
+ SPA_AUDIO_FORMAT_DSP_F64 = SPA_AUDIO_FORMAT_F64P,
+
+ /* native endian */
+#if __BYTE_ORDER == __BIG_ENDIAN
+ SPA_AUDIO_FORMAT_S16 = SPA_AUDIO_FORMAT_S16_BE,
+ SPA_AUDIO_FORMAT_U16 = SPA_AUDIO_FORMAT_U16_BE,
+ SPA_AUDIO_FORMAT_S24_32 = SPA_AUDIO_FORMAT_S24_32_BE,
+ SPA_AUDIO_FORMAT_U24_32 = SPA_AUDIO_FORMAT_U24_32_BE,
+ SPA_AUDIO_FORMAT_S32 = SPA_AUDIO_FORMAT_S32_BE,
+ SPA_AUDIO_FORMAT_U32 = SPA_AUDIO_FORMAT_U32_BE,
+ SPA_AUDIO_FORMAT_S24 = SPA_AUDIO_FORMAT_S24_BE,
+ SPA_AUDIO_FORMAT_U24 = SPA_AUDIO_FORMAT_U24_BE,
+ SPA_AUDIO_FORMAT_S20 = SPA_AUDIO_FORMAT_S20_BE,
+ SPA_AUDIO_FORMAT_U20 = SPA_AUDIO_FORMAT_U20_BE,
+ SPA_AUDIO_FORMAT_S18 = SPA_AUDIO_FORMAT_S18_BE,
+ SPA_AUDIO_FORMAT_U18 = SPA_AUDIO_FORMAT_U18_BE,
+ SPA_AUDIO_FORMAT_F32 = SPA_AUDIO_FORMAT_F32_BE,
+ SPA_AUDIO_FORMAT_F64 = SPA_AUDIO_FORMAT_F64_BE,
+ SPA_AUDIO_FORMAT_S16_OE = SPA_AUDIO_FORMAT_S16_LE,
+ SPA_AUDIO_FORMAT_U16_OE = SPA_AUDIO_FORMAT_U16_LE,
+ SPA_AUDIO_FORMAT_S24_32_OE = SPA_AUDIO_FORMAT_S24_32_LE,
+ SPA_AUDIO_FORMAT_U24_32_OE = SPA_AUDIO_FORMAT_U24_32_LE,
+ SPA_AUDIO_FORMAT_S32_OE = SPA_AUDIO_FORMAT_S32_LE,
+ SPA_AUDIO_FORMAT_U32_OE = SPA_AUDIO_FORMAT_U32_LE,
+ SPA_AUDIO_FORMAT_S24_OE = SPA_AUDIO_FORMAT_S24_LE,
+ SPA_AUDIO_FORMAT_U24_OE = SPA_AUDIO_FORMAT_U24_LE,
+ SPA_AUDIO_FORMAT_S20_OE = SPA_AUDIO_FORMAT_S20_LE,
+ SPA_AUDIO_FORMAT_U20_OE = SPA_AUDIO_FORMAT_U20_LE,
+ SPA_AUDIO_FORMAT_S18_OE = SPA_AUDIO_FORMAT_S18_LE,
+ SPA_AUDIO_FORMAT_U18_OE = SPA_AUDIO_FORMAT_U18_LE,
+ SPA_AUDIO_FORMAT_F32_OE = SPA_AUDIO_FORMAT_F32_LE,
+ SPA_AUDIO_FORMAT_F64_OE = SPA_AUDIO_FORMAT_F64_LE,
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+ SPA_AUDIO_FORMAT_S16 = SPA_AUDIO_FORMAT_S16_LE,
+ SPA_AUDIO_FORMAT_U16 = SPA_AUDIO_FORMAT_U16_LE,
+ SPA_AUDIO_FORMAT_S24_32 = SPA_AUDIO_FORMAT_S24_32_LE,
+ SPA_AUDIO_FORMAT_U24_32 = SPA_AUDIO_FORMAT_U24_32_LE,
+ SPA_AUDIO_FORMAT_S32 = SPA_AUDIO_FORMAT_S32_LE,
+ SPA_AUDIO_FORMAT_U32 = SPA_AUDIO_FORMAT_U32_LE,
+ SPA_AUDIO_FORMAT_S24 = SPA_AUDIO_FORMAT_S24_LE,
+ SPA_AUDIO_FORMAT_U24 = SPA_AUDIO_FORMAT_U24_LE,
+ SPA_AUDIO_FORMAT_S20 = SPA_AUDIO_FORMAT_S20_LE,
+ SPA_AUDIO_FORMAT_U20 = SPA_AUDIO_FORMAT_U20_LE,
+ SPA_AUDIO_FORMAT_S18 = SPA_AUDIO_FORMAT_S18_LE,
+ SPA_AUDIO_FORMAT_U18 = SPA_AUDIO_FORMAT_U18_LE,
+ SPA_AUDIO_FORMAT_F32 = SPA_AUDIO_FORMAT_F32_LE,
+ SPA_AUDIO_FORMAT_F64 = SPA_AUDIO_FORMAT_F64_LE,
+ SPA_AUDIO_FORMAT_S16_OE = SPA_AUDIO_FORMAT_S16_BE,
+ SPA_AUDIO_FORMAT_U16_OE = SPA_AUDIO_FORMAT_U16_BE,
+ SPA_AUDIO_FORMAT_S24_32_OE = SPA_AUDIO_FORMAT_S24_32_BE,
+ SPA_AUDIO_FORMAT_U24_32_OE = SPA_AUDIO_FORMAT_U24_32_BE,
+ SPA_AUDIO_FORMAT_S32_OE = SPA_AUDIO_FORMAT_S32_BE,
+ SPA_AUDIO_FORMAT_U32_OE = SPA_AUDIO_FORMAT_U32_BE,
+ SPA_AUDIO_FORMAT_S24_OE = SPA_AUDIO_FORMAT_S24_BE,
+ SPA_AUDIO_FORMAT_U24_OE = SPA_AUDIO_FORMAT_U24_BE,
+ SPA_AUDIO_FORMAT_S20_OE = SPA_AUDIO_FORMAT_S20_BE,
+ SPA_AUDIO_FORMAT_U20_OE = SPA_AUDIO_FORMAT_U20_BE,
+ SPA_AUDIO_FORMAT_S18_OE = SPA_AUDIO_FORMAT_S18_BE,
+ SPA_AUDIO_FORMAT_U18_OE = SPA_AUDIO_FORMAT_U18_BE,
+ SPA_AUDIO_FORMAT_F32_OE = SPA_AUDIO_FORMAT_F32_BE,
+ SPA_AUDIO_FORMAT_F64_OE = SPA_AUDIO_FORMAT_F64_BE,
+#endif
+};
+
+#define SPA_AUDIO_FORMAT_IS_INTERLEAVED(fmt) ((fmt) > SPA_AUDIO_FORMAT_START_Interleaved && (fmt) < SPA_AUDIO_FORMAT_START_Planar)
+#define SPA_AUDIO_FORMAT_IS_PLANAR(fmt) ((fmt) > SPA_AUDIO_FORMAT_START_Planar && (fmt) < SPA_AUDIO_FORMAT_START_Other)
+
+enum spa_audio_channel {
+ SPA_AUDIO_CHANNEL_UNKNOWN, /**< unspecified */
+ SPA_AUDIO_CHANNEL_NA, /**< N/A, silent */
+
+ SPA_AUDIO_CHANNEL_MONO, /**< mono stream */
+
+ SPA_AUDIO_CHANNEL_FL, /**< front left */
+ SPA_AUDIO_CHANNEL_FR, /**< front right */
+ SPA_AUDIO_CHANNEL_FC, /**< front center */
+ SPA_AUDIO_CHANNEL_LFE, /**< LFE */
+ SPA_AUDIO_CHANNEL_SL, /**< side left */
+ SPA_AUDIO_CHANNEL_SR, /**< side right */
+ SPA_AUDIO_CHANNEL_FLC, /**< front left center */
+ SPA_AUDIO_CHANNEL_FRC, /**< front right center */
+ SPA_AUDIO_CHANNEL_RC, /**< rear center */
+ SPA_AUDIO_CHANNEL_RL, /**< rear left */
+ SPA_AUDIO_CHANNEL_RR, /**< rear right */
+ SPA_AUDIO_CHANNEL_TC, /**< top center */
+ SPA_AUDIO_CHANNEL_TFL, /**< top front left */
+ SPA_AUDIO_CHANNEL_TFC, /**< top front center */
+ SPA_AUDIO_CHANNEL_TFR, /**< top front right */
+ SPA_AUDIO_CHANNEL_TRL, /**< top rear left */
+ SPA_AUDIO_CHANNEL_TRC, /**< top rear center */
+ SPA_AUDIO_CHANNEL_TRR, /**< top rear right */
+ SPA_AUDIO_CHANNEL_RLC, /**< rear left center */
+ SPA_AUDIO_CHANNEL_RRC, /**< rear right center */
+ SPA_AUDIO_CHANNEL_FLW, /**< front left wide */
+ SPA_AUDIO_CHANNEL_FRW, /**< front right wide */
+ SPA_AUDIO_CHANNEL_LFE2, /**< LFE 2 */
+ SPA_AUDIO_CHANNEL_FLH, /**< front left high */
+ SPA_AUDIO_CHANNEL_FCH, /**< front center high */
+ SPA_AUDIO_CHANNEL_FRH, /**< front right high */
+ SPA_AUDIO_CHANNEL_TFLC, /**< top front left center */
+ SPA_AUDIO_CHANNEL_TFRC, /**< top front right center */
+ SPA_AUDIO_CHANNEL_TSL, /**< top side left */
+ SPA_AUDIO_CHANNEL_TSR, /**< top side right */
+ SPA_AUDIO_CHANNEL_LLFE, /**< left LFE */
+ SPA_AUDIO_CHANNEL_RLFE, /**< right LFE */
+ SPA_AUDIO_CHANNEL_BC, /**< bottom center */
+ SPA_AUDIO_CHANNEL_BLC, /**< bottom left center */
+ SPA_AUDIO_CHANNEL_BRC, /**< bottom right center */
+
+ SPA_AUDIO_CHANNEL_START_Aux = 0x1000, /**< aux channels */
+ SPA_AUDIO_CHANNEL_AUX0 = SPA_AUDIO_CHANNEL_START_Aux,
+ SPA_AUDIO_CHANNEL_AUX1,
+ SPA_AUDIO_CHANNEL_AUX2,
+ SPA_AUDIO_CHANNEL_AUX3,
+ SPA_AUDIO_CHANNEL_AUX4,
+ SPA_AUDIO_CHANNEL_AUX5,
+ SPA_AUDIO_CHANNEL_AUX6,
+ SPA_AUDIO_CHANNEL_AUX7,
+ SPA_AUDIO_CHANNEL_AUX8,
+ SPA_AUDIO_CHANNEL_AUX9,
+ SPA_AUDIO_CHANNEL_AUX10,
+ SPA_AUDIO_CHANNEL_AUX11,
+ SPA_AUDIO_CHANNEL_AUX12,
+ SPA_AUDIO_CHANNEL_AUX13,
+ SPA_AUDIO_CHANNEL_AUX14,
+ SPA_AUDIO_CHANNEL_AUX15,
+ SPA_AUDIO_CHANNEL_AUX16,
+ SPA_AUDIO_CHANNEL_AUX17,
+ SPA_AUDIO_CHANNEL_AUX18,
+ SPA_AUDIO_CHANNEL_AUX19,
+ SPA_AUDIO_CHANNEL_AUX20,
+ SPA_AUDIO_CHANNEL_AUX21,
+ SPA_AUDIO_CHANNEL_AUX22,
+ SPA_AUDIO_CHANNEL_AUX23,
+ SPA_AUDIO_CHANNEL_AUX24,
+ SPA_AUDIO_CHANNEL_AUX25,
+ SPA_AUDIO_CHANNEL_AUX26,
+ SPA_AUDIO_CHANNEL_AUX27,
+ SPA_AUDIO_CHANNEL_AUX28,
+ SPA_AUDIO_CHANNEL_AUX29,
+ SPA_AUDIO_CHANNEL_AUX30,
+ SPA_AUDIO_CHANNEL_AUX31,
+ SPA_AUDIO_CHANNEL_AUX32,
+ SPA_AUDIO_CHANNEL_AUX33,
+ SPA_AUDIO_CHANNEL_AUX34,
+ SPA_AUDIO_CHANNEL_AUX35,
+ SPA_AUDIO_CHANNEL_AUX36,
+ SPA_AUDIO_CHANNEL_AUX37,
+ SPA_AUDIO_CHANNEL_AUX38,
+ SPA_AUDIO_CHANNEL_AUX39,
+ SPA_AUDIO_CHANNEL_AUX40,
+ SPA_AUDIO_CHANNEL_AUX41,
+ SPA_AUDIO_CHANNEL_AUX42,
+ SPA_AUDIO_CHANNEL_AUX43,
+ SPA_AUDIO_CHANNEL_AUX44,
+ SPA_AUDIO_CHANNEL_AUX45,
+ SPA_AUDIO_CHANNEL_AUX46,
+ SPA_AUDIO_CHANNEL_AUX47,
+ SPA_AUDIO_CHANNEL_AUX48,
+ SPA_AUDIO_CHANNEL_AUX49,
+ SPA_AUDIO_CHANNEL_AUX50,
+ SPA_AUDIO_CHANNEL_AUX51,
+ SPA_AUDIO_CHANNEL_AUX52,
+ SPA_AUDIO_CHANNEL_AUX53,
+ SPA_AUDIO_CHANNEL_AUX54,
+ SPA_AUDIO_CHANNEL_AUX55,
+ SPA_AUDIO_CHANNEL_AUX56,
+ SPA_AUDIO_CHANNEL_AUX57,
+ SPA_AUDIO_CHANNEL_AUX58,
+ SPA_AUDIO_CHANNEL_AUX59,
+ SPA_AUDIO_CHANNEL_AUX60,
+ SPA_AUDIO_CHANNEL_AUX61,
+ SPA_AUDIO_CHANNEL_AUX62,
+ SPA_AUDIO_CHANNEL_AUX63,
+
+ SPA_AUDIO_CHANNEL_LAST_Aux = 0x1fff, /**< aux channels */
+
+ SPA_AUDIO_CHANNEL_START_Custom = 0x10000,
+};
+
+enum spa_audio_volume_ramp_scale {
+ SPA_AUDIO_VOLUME_RAMP_INVALID,
+ SPA_AUDIO_VOLUME_RAMP_LINEAR,
+ SPA_AUDIO_VOLUME_RAMP_CUBIC,
+};
+
+/** Extra audio flags */
+#define SPA_AUDIO_FLAG_NONE (0) /*< no valid flag */
+#define SPA_AUDIO_FLAG_UNPOSITIONED (1 << 0) /*< the position array explicitly
+ * contains unpositioned channels. */
+/** Audio information description */
+struct spa_audio_info_raw {
+ enum spa_audio_format format; /*< format, one of enum spa_audio_format */
+ uint32_t flags; /*< extra flags */
+ uint32_t rate; /*< sample rate */
+ uint32_t channels; /*< number of channels */
+ uint32_t position[SPA_AUDIO_MAX_CHANNELS]; /*< channel position from enum spa_audio_channel */
+};
+
+#define SPA_AUDIO_INFO_RAW_INIT(...) ((struct spa_audio_info_raw) { __VA_ARGS__ })
+
+#define SPA_KEY_AUDIO_FORMAT "audio.format" /**< an audio format as string,
+ * Ex. "S16LE" */
+#define SPA_KEY_AUDIO_CHANNEL "audio.channel" /**< an audio channel as string,
+ * Ex. "FL" */
+#define SPA_KEY_AUDIO_CHANNELS "audio.channels" /**< an audio channel count as int */
+#define SPA_KEY_AUDIO_RATE "audio.rate" /**< an audio sample rate as int */
+#define SPA_KEY_AUDIO_POSITION "audio.position" /**< channel positions as comma separated list
+ * of channels ex. "FL,FR" */
+#define SPA_KEY_AUDIO_ALLOWED_RATES "audio.allowed-rates" /**< a list of allowed samplerates
+ * ex. "[ 44100 48000 ]" */
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_RAW_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/vorbis-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/vorbis-utils.h
new file mode 100644
index 000000000..68db24e22
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/vorbis-utils.h
@@ -0,0 +1,60 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_VORBIS_UTILS_H
+#define SPA_AUDIO_VORBIS_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/audio/format.h>
+#include <spa/param/format-utils.h>
+
+static inline int
+spa_format_audio_vorbis_parse(const struct spa_pod *format, struct spa_audio_info_vorbis *info)
+{
+ int res;
+ res = spa_pod_parse_object(format,
+ SPA_TYPE_OBJECT_Format, NULL,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
+ SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels));
+ return res;
+}
+
+static inline struct spa_pod *
+spa_format_audio_vorbis_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_vorbis *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_audio),
+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_vorbis),
+ SPA_FORMAT_AUDIO_format, SPA_POD_Id(SPA_AUDIO_FORMAT_ENCODED),
+ 0);
+ if (info->rate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
+ if (info->channels != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
+}
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_VORBIS_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/vorbis.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/vorbis.h
new file mode 100644
index 000000000..c18f7eefa
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/vorbis.h
@@ -0,0 +1,29 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_VORBIS_H
+#define SPA_AUDIO_VORBIS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <spa/param/audio/raw.h>
+
+struct spa_audio_info_vorbis {
+ uint32_t rate; /*< sample rate */
+ uint32_t channels; /*< number of channels */
+};
+
+#define SPA_AUDIO_INFO_VORBIS_INIT(...) ((struct spa_audio_info_vorbis) { __VA_ARGS__ })
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_VORBIS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/wma-utils.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/wma-utils.h
new file mode 100644
index 000000000..d80c9a3b9
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/wma-utils.h
@@ -0,0 +1,73 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_WMA_UTILS_H
+#define SPA_AUDIO_WMA_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup spa_param
+ * \{
+ */
+
+#include <spa/pod/parser.h>
+#include <spa/pod/builder.h>
+#include <spa/param/audio/format.h>
+#include <spa/param/format-utils.h>
+
+static inline int
+spa_format_audio_wma_parse(const struct spa_pod *format, struct spa_audio_info_wma *info)
+{
+ int res;
+ res = spa_pod_parse_object(format,
+ SPA_TYPE_OBJECT_Format, NULL,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
+ SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels),
+ SPA_FORMAT_AUDIO_bitrate, SPA_POD_OPT_Int(&info->bitrate),
+ SPA_FORMAT_AUDIO_blockAlign, SPA_POD_OPT_Int(&info->block_align),
+ SPA_FORMAT_AUDIO_WMA_profile, SPA_POD_OPT_Id(&info->profile));
+ return res;
+}
+
+static inline struct spa_pod *
+spa_format_audio_wma_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_wma *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_audio),
+ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_wma),
+ SPA_FORMAT_AUDIO_format, SPA_POD_Id(SPA_AUDIO_FORMAT_ENCODED),
+ 0);
+ if (info->rate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
+ if (info->channels != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
+ if (info->bitrate != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_bitrate, SPA_POD_Int(info->bitrate), 0);
+ if (info->block_align != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_blockAlign, SPA_POD_Int(info->block_align), 0);
+ if (info->profile != 0)
+ spa_pod_builder_add(builder,
+ SPA_FORMAT_AUDIO_WMA_profile, SPA_POD_Id(info->profile), 0);
+
+ return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
+}
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_WMA_UTILS_H */
diff --git a/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/wma.h b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/wma.h
new file mode 100644
index 000000000..1bbcafe02
--- /dev/null
+++ b/electron/native/pipewire-capture/vendor/pipewire-1.0.5/include/spa/param/audio/wma.h
@@ -0,0 +1,47 @@
+/* Simple Plugin API */
+/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
+/* SPDX-License-Identifier: MIT */
+
+#ifndef SPA_AUDIO_WMA_H
+#define SPA_AUDIO_WMA_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <spa/param/audio/raw.h>
+
+enum spa_audio_wma_profile {
+ SPA_AUDIO_WMA_PROFILE_UNKNOWN,
+
+ SPA_AUDIO_WMA_PROFILE_WMA7,
+ SPA_AUDIO_WMA_PROFILE_WMA8,
+ SPA_AUDIO_WMA_PROFILE_WMA9,
+ SPA_AUDIO_WMA_PROFILE_WMA10,
+ SPA_AUDIO_WMA_PROFILE_WMA9_PRO,
+ SPA_AUDIO_WMA_PROFILE_WMA9_LOSSLESS,
+ SPA_AUDIO_WMA_PROFILE_WMA10_LOSSLESS,
+
+ SPA_AUDIO_WMA_PROFILE_CUSTOM = 0x10000,
+};
+
+struct spa_audio_info_wma {
+ uint32_t rate; /*< sample rate */
+ uint32_t channels; /*< number of channels */
+ uint32_t bitrate; /*< stream bitrate */
+ uint32_t block_align; /*< block alignment */
+ enum spa_audio_wma_profile profile; /*< WMA profile */
+
+};
+
+#define SPA_AUDIO_INFO_WMA_INIT(...) ((struct spa_audio_info_wma) { __VA_ARGS__ })
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* SPA_AUDIO_WMA_H */