Skip to main content

AudioFrame

Struct AudioFrame 

Source
pub struct AudioFrame {
    pub(crate) data: Vec<u8>,
    pub(crate) pts: u64,
    pub(crate) channels: u8,
    pub(crate) pool: Option<Arc<BufferPool>>,
}
Expand description

One encoded frame as the capture delivers it: the two-byte header and RED framing followed by the Opus packet, or the raw packet on a capture that omits the header, with the pts it starts at and the channels its Opus carries.

Owns its buffer; when the frame is dropped, a pooled buffer is recycled back to the capture thread (see the Drop impl), keeping the steady-state emit path allocation-free, so a consumer that must keep the bytes copies them out.

Fields§

§data: Vec<u8>§pts: u64§channels: u8

Channels the frame’s Opus carries: the capture’s own, or 2 for its stereo companion.

§pool: Option<Arc<BufferPool>>

Set when the buffer came from a capture’s BufferPool; recycled to it on drop.

Implementations§

Source§

impl AudioFrame

Source

pub fn as_bytes(&self) -> &[u8] ⓘ

The frame’s bytes.

Source

pub fn len(&self) -> usize

The frame’s length in bytes.

Source

pub fn is_empty(&self) -> bool

Whether the frame carries no bytes.

Source

pub fn pts(&self) -> u64

Presentation timestamp in input samples: the capture’s running sample count before this frame.

Source

pub fn channels(&self) -> u8

Channels the frame’s Opus carries: the capture’s own count, or 2 for a frame of the stereo companion (AudioCapture::set_stereo_companion), which shares its pts.

Trait Implementations§

Source§

impl Debug for AudioFrame

Source§

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

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

impl Drop for AudioFrame

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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> 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, 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.