Skip to main content

AudioSource

Trait AudioSource 

Source
pub trait AudioSource: AudioParts {
Show 14 methods // Required methods fn sample_rate(&self) -> u32; fn num_channels(&self) -> u32; fn num_samples(&self) -> u32; fn format(&self) -> AudioFormat; fn channel_stride_bytes(&self) -> usize; fn timecode(&self) -> Timecode; fn timestamp(&self) -> Option<ReceivedTimestamp>; fn metadata(&self) -> Option<&str>; fn metadata_status(&self) -> FrameMetadataStatus; fn channel_data(&self, channel: usize) -> Option<&[f32]>; fn channels(&self) -> AudioChannels<'_> ⓘ; fn data(&self) -> Option<&[f32]>; fn to_owned(&self) -> AudioFrame; fn copy_into(&self, destination: &mut AudioFrame);
}
Expand description

A validated planar audio input for synchronous sending and conversion.

Implemented by AudioFrame, BorrowedAudioFrame, AudioFrameRef and FrameSyncAudioRef, and Advanced AV-sync audio references. Generic and dyn AudioSource consumers can inspect validated layouts and channel samples without allocating. This sealed trait prevents unchecked sample pointers or channel layouts. Native operations borrow the original samples and channel stride directly, with no intermediate owned planar copy or wrapper allocation. The input’s lifetime and thread restrictions still apply.

Required Methods§

Source

fn sample_rate(&self) -> u32

Sample rate in Hz.

Source

fn num_channels(&self) -> u32

Number of channels.

Source

fn num_samples(&self) -> u32

Number of active samples per channel.

Source

fn format(&self) -> AudioFormat

Validated planar floating-point audio format.

Source

fn channel_stride_bytes(&self) -> usize

Distance in bytes between consecutive channel starts.

Source

fn timecode(&self) -> Timecode

Frame timecode, or the sender’s synthesis sentinel.

Source

fn timestamp(&self) -> Option<ReceivedTimestamp>

Source-dependent timestamp supplied by the SDK for a captured frame.

Source

fn metadata(&self) -> Option<&str>

UTF-8 metadata; an explicit empty string differs from no metadata. Unreadable received text is withheld; inspect Self::metadata_status.

Source

fn metadata_status(&self) -> FrameMetadataStatus

Whether per-frame metadata is absent, readable, or withheld as unreadable.

Source

fn channel_data(&self, channel: usize) -> Option<&[f32]>

One channel’s initialized samples, excluding any inter-channel padding.

Source

fn channels(&self) -> AudioChannels<'_> ⓘ

Iterate initialized channel samples without allocating or reading padding.

Source

fn data(&self) -> Option<&[f32]>

Contiguous samples, or None when padding separates channels.

Source

fn to_owned(&self) -> AudioFrame

Copy samples and readable metadata into a new owned, tightly packed planar frame. Withheld metadata keeps its status without its text. Allocates sample storage and, when present, readable metadata storage.

Source

fn copy_into(&self, destination: &mut AudioFrame)

Copy into an owned destination, reusing sample and metadata allocations when their capacities permit. Padding is omitted. Absent source metadata clears the destination text while retaining its allocation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§