Struct symphonia_core::formats::Packet

source ·
pub struct Packet {
    pub ts: u64,
    pub dur: u64,
    pub trim_start: u32,
    pub trim_end: u32,
    pub data: Box<[u8]>,
    /* private fields */
}
Expand description

A Packet contains a discrete amount of encoded data for a single codec bitstream. The exact amount of data is bounded, but not defined, and is dependant on the container and/or the encapsulated codec.

Fields§

§ts: u64

The timestamp of the packet. When gapless support is enabled, this timestamp is relative to the end of the encoder delay.

This timestamp is in TimeBase units.

§dur: u64

The duration of the packet. When gapless support is enabled, the duration does not include the encoder delay or padding.

The duration is in TimeBase units.

§trim_start: u32

When gapless support is enabled, this is the number of decoded frames that should be trimmed from the start of the packet to remove the encoder delay. Must be 0 in all other cases.

§trim_end: u32

When gapless support is enabled, this is the number of decoded frames that should be trimmed from the end of the packet to remove the encoder padding. Must be 0 in all other cases.

§data: Box<[u8]>

The packet buffer.

Implementations§

source§

impl Packet

source

pub fn new_from_slice(track_id: u32, ts: u64, dur: u64, buf: &[u8]) -> Self

Create a new Packet from a slice.

source

pub fn new_from_boxed_slice( track_id: u32, ts: u64, dur: u64, data: Box<[u8]>, ) -> Self

Create a new Packet from a boxed slice.

source

pub fn new_trimmed_from_slice( track_id: u32, ts: u64, dur: u64, trim_start: u32, trim_end: u32, buf: &[u8], ) -> Self

Create a new Packet with trimming information from a slice.

source

pub fn new_trimmed_from_boxed_slice( track_id: u32, ts: u64, dur: u64, trim_start: u32, trim_end: u32, data: Box<[u8]>, ) -> Self

Create a new Packet with trimming information from a boxed slice.

source

pub fn track_id(&self) -> u32

The track identifier of the track this packet belongs to.

source

pub fn ts(&self) -> u64

Get the timestamp of the packet in TimeBase units.

If gapless support is enabled, then this timestamp is relative to the end of the encoder delay.

source

pub fn dur(&self) -> u64

Get the duration of the packet in TimeBase units.

If gapless support is enabled, then this is the duration after the encoder delay and padding is trimmed.

source

pub fn block_dur(&self) -> u64

Get the duration of the packet in TimeBase units if no decoded frames are trimmed.

If gapless support is disabled, then this is the same as the duration.

source

pub fn trim_start(&self) -> u32

Get the number of frames to trim from the start of the decoded packet.

source

pub fn trim_end(&self) -> u32

Get the number of frames to trim from the end of the decoded packet.

source

pub fn buf(&self) -> &[u8]

Get an immutable slice to the packet buffer.

source

pub fn as_buf_reader(&self) -> BufReader<'_>

Get a BufStream to read the packet data buffer sequentially.

Trait Implementations§

source§

impl Clone for Packet

source§

fn clone(&self) -> Packet

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Packet

§

impl RefUnwindSafe for Packet

§

impl Send for Packet

§

impl Sync for Packet

§

impl Unpin for Packet

§

impl UnwindSafe for Packet

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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<F, T> IntoSample<T> for F
where T: FromSample<F>,

source§

fn into_sample(self) -> T

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.