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§
Sourcefn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
Sample rate in Hz.
Sourcefn num_channels(&self) -> u32
fn num_channels(&self) -> u32
Number of channels.
Sourcefn num_samples(&self) -> u32
fn num_samples(&self) -> u32
Number of active samples per channel.
Sourcefn format(&self) -> AudioFormat
fn format(&self) -> AudioFormat
Validated planar floating-point audio format.
Sourcefn channel_stride_bytes(&self) -> usize
fn channel_stride_bytes(&self) -> usize
Distance in bytes between consecutive channel starts.
Sourcefn timestamp(&self) -> Option<ReceivedTimestamp>
fn timestamp(&self) -> Option<ReceivedTimestamp>
Source-dependent timestamp supplied by the SDK for a captured frame.
Sourcefn metadata(&self) -> Option<&str>
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.
Sourcefn metadata_status(&self) -> FrameMetadataStatus
fn metadata_status(&self) -> FrameMetadataStatus
Whether per-frame metadata is absent, readable, or withheld as unreadable.
Sourcefn channel_data(&self, channel: usize) -> Option<&[f32]>
fn channel_data(&self, channel: usize) -> Option<&[f32]>
One channel’s initialized samples, excluding any inter-channel padding.
Sourcefn channels(&self) -> AudioChannels<'_> ⓘ
fn channels(&self) -> AudioChannels<'_> ⓘ
Iterate initialized channel samples without allocating or reading padding.
Sourcefn to_owned(&self) -> AudioFrame
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.
Sourcefn copy_into(&self, destination: &mut AudioFrame)
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".