Skip to main content

AudioCaptureSettings

Struct AudioCaptureSettings 

Source
pub struct AudioCaptureSettings {
Show 13 fields pub device_name: Option<String>, pub sample_rate: u32, pub channels: i32, pub opus_bitrate: i32, pub frame_duration_ms: f64, pub use_vbr: bool, pub opus_complexity: Option<i32>, pub use_silence_gate: bool, pub debug_logging: bool, pub latency_ms: i32, pub omit_audio_header: bool, pub red_distance: i32, pub output_socket: String,
}
Expand description

Capture/encode configuration, read once by AudioCapture::start. Default is the configuration the Python AudioCaptureSettings starts with: the system default source, 48 kHz stereo at 128 kbps VBR in 20 ms frames, the silence gate on, the audio header emitted, no RED, no output socket.

Fields§

§device_name: Option<String>

The PulseAudio source to record; None or empty for the system default.

§sample_rate: u32

8000, 12000, 16000, 24000, or 48000.

§channels: i32

1, 2, 6 (5.1), or 8 (7.1).

§opus_bitrate: i32

Opus target bitrate in bits/s, clamped into the encoder’s range at start.

§frame_duration_ms: f64

2.5, 5, 10, 20, 40, or 60.

§use_vbr: bool§opus_complexity: Option<i32>

Opus encoder complexity, 0 (cheapest) to 10; None leaves libopus’s default. Applied when the encoder is created, so it does not change during a running capture.

§use_silence_gate: bool

Drop frames of digital silence before encoding them.

§debug_logging: bool

Print a status line every two seconds.

§latency_ms: i32

The record stream’s fragment size in milliseconds; 0 selects the default.

§omit_audio_header: bool

Deliver raw Opus packets instead of the two-byte header and RED framing.

§red_distance: i32

Redundant copies of recent frames each frame carries, 0 to RED_MAX_DISTANCE.

§output_socket: String

Unix socket path on which the capture serves its packets as an Ogg Opus stream to every consumer that connects; empty serves none. A path that cannot be bound fails the start like any other startup error.

Implementations§

Source§

impl AudioCaptureSettings

Source

pub fn validate(&self) -> Result<AudioCaptureSettings, Error>

The settings a run snapshots, or why they are refused: what the worker could only fail on later is rejected here, before a thread is spawned.

opus_bitrate is clamped into the Opus range exactly as update_audio_bitrate clamps a live update; red_distance into [0, RED_MAX_DISTANCE] — it selects how many redundant Opus copies each frame carries, and cannot exceed the RFC 2198 history depth. An empty device_name becomes None, the system default, and one with an interior NUL is refused: the name becomes a C string for libpulse on the worker thread, where it could only surface as a panic. latency_ms == 0 selects the default fragment size.

Trait Implementations§

Source§

impl Clone for AudioCaptureSettings

Source§

fn clone(&self) -> AudioCaptureSettings

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AudioCaptureSettings

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AudioCaptureSettings

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for AudioCaptureSettings

Source§

fn eq(&self, other: &AudioCaptureSettings) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AudioCaptureSettings

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.