pub struct AvSyncAudioRef<'a> { /* private fields */ }Expand description
Audio borrowed from an AvSync synchronizer.
The samples and metadata remain in the SDK until this reference is dropped.
It implements crate::AudioSource and can be sent or converted in place;
to_owned retains a copy and copy_into reuses owned storage. Like
FrameSync audio references, it stays on its capture thread (!Send, !Sync).
Several references may be retained across later synchronizations and freed
in any order. The synchronizer remains borrowed until all are released.
Implementations§
Source§impl<'a> AvSyncAudioRef<'a>
impl<'a> AvSyncAudioRef<'a>
Sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
Get the sample rate in Hz.
Sourcepub fn num_channels(&self) -> u32
pub fn num_channels(&self) -> u32
Get the number of audio channels.
Sourcepub fn num_samples(&self) -> u32
pub fn num_samples(&self) -> u32
Get the number of samples per channel.
Sourcepub fn timecode(&self) -> Timecode
pub fn timecode(&self) -> Timecode
Get the timecode.
FrameSync output without a source timecode carries
Timecode::SYNTHESIZE.
Sourcepub fn timestamp(&self) -> Option<ReceivedTimestamp>
pub fn timestamp(&self) -> Option<ReceivedTimestamp>
The source-dependent timestamp of the received frame.
It is None when the SDK does not know it. FrameSync and
AV-sync audio also treat their zero marker as unknown; that
marker alone does not identify synthesized silence.
Sourcepub fn format(&self) -> AudioFormat
pub fn format(&self) -> AudioFormat
Get the audio format.
It is a supported format, validated when the frame was constructed.
Sourcepub fn channel_stride_bytes(&self) -> usize
pub fn channel_stride_bytes(&self) -> usize
Get the distance between the starts of consecutive channels in bytes.
It includes any padding between channels.
Sourcepub fn metadata(&self) -> Option<&str>
pub fn metadata(&self) -> Option<&str>
Get frame metadata as UTF-8 text, if present.
Empty metadata, Some(""), is distinct from none, None.
Unreadable received text returns None; use
Self::metadata_status to distinguish it from absent text.
Sourcepub fn metadata_status(&self) -> FrameMetadataStatus
pub fn metadata_status(&self) -> FrameMetadataStatus
The metadata’s presence or the reason unreadable received text was withheld. Querying the cached status allocates nothing.
Sourcepub fn channel_data(&self, channel: usize) -> Option<&[f32]>
pub fn channel_data(&self, channel: usize) -> Option<&[f32]>
Get one channel’s samples, or None for an invalid channel.
The slice borrows the frame’s samples without copying and excludes any padding between channels.
Sourcepub fn channels(&self) -> AudioChannels<'_> ⓘ
pub fn channels(&self) -> AudioChannels<'_> ⓘ
Iterate over the channels’ samples, in channel order, without copying or reading padding between channels.
Sourcepub fn data(&self) -> Option<&[f32]>
pub fn data(&self) -> Option<&[f32]>
Get a zero-copy slice when channels are tightly packed.
Returns None for multi-channel buffers with padding between channels.
Use channel_data or channels
for those buffers.
Sourcepub fn to_owned(&self) -> AudioFrame
pub fn to_owned(&self) -> AudioFrame
Copy this borrowed frame into an owned AudioFrame.
Copies channel samples into tightly packed planar storage and copies
metadata, allowing the frame to outlive the SDK buffer. Padding is omitted.
Allocates one sample buffer, and one metadata string when present.
Withheld metadata keeps its status without retaining its text.
Self::copy_into makes the same copy into an existing frame,
reusing its allocations.
The copy cannot fail: capture validated everything it relies on.
Sourcepub fn copy_into(&self, destination: &mut AudioFrame)
pub fn copy_into(&self, destination: &mut AudioFrame)
Copy this borrowed frame into destination, reusing its allocations.
destination ends up exactly as Self::to_owned would have
returned it, whatever it held before: the channels’ samples packed
back to back without inter-channel padding, format, sample rate,
channel and sample counts, timecode, timestamp and metadata.
Its sample buffer is reused when its capacity holds the packed samples, and otherwise replaced by one allocation of exactly that size. Its metadata string is reused when its capacity holds the new text and its terminator; otherwise it grows once. With sufficient sample and metadata capacity, subsequent copies allocate nothing, including when sources alternate between absent and present metadata. A copy without text retains its allocation.
The copy makes no SDK call. It runs wherever this reference may be used: a receiver frame can be copied on a scoped worker thread, while a synchronizer frame stays on its capture thread. The destination is an ordinary owned frame either way.
Trait Implementations§
Source§impl<'a> AudioSource for AvSyncAudioRef<'a>
impl<'a> AudioSource for AvSyncAudioRef<'a>
Source§fn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
Source§fn num_channels(&self) -> u32
fn num_channels(&self) -> u32
Source§fn num_samples(&self) -> u32
fn num_samples(&self) -> u32
Source§fn timestamp(&self) -> Option<ReceivedTimestamp>
fn timestamp(&self) -> Option<ReceivedTimestamp>
Source§fn format(&self) -> AudioFormat
fn format(&self) -> AudioFormat
Source§fn channel_stride_bytes(&self) -> usize
fn channel_stride_bytes(&self) -> usize
Source§fn metadata(&self) -> Option<&str>
fn metadata(&self) -> Option<&str>
Self::metadata_status.