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
impl Packet
sourcepub fn new_from_slice(track_id: u32, ts: u64, dur: u64, buf: &[u8]) -> Self
pub fn new_from_slice(track_id: u32, ts: u64, dur: u64, buf: &[u8]) -> Self
Create a new Packet
from a slice.
sourcepub fn new_from_boxed_slice(
track_id: u32,
ts: u64,
dur: u64,
data: Box<[u8]>
) -> Self
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.
sourcepub fn new_trimmed_from_slice(
track_id: u32,
ts: u64,
dur: u64,
trim_start: u32,
trim_end: u32,
buf: &[u8]
) -> Self
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.
sourcepub fn new_trimmed_from_boxed_slice(
track_id: u32,
ts: u64,
dur: u64,
trim_start: u32,
trim_end: u32,
data: Box<[u8]>
) -> Self
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.
sourcepub fn ts(&self) -> u64
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.
sourcepub fn dur(&self) -> u64
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.
sourcepub fn block_dur(&self) -> u64
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.
sourcepub fn trim_start(&self) -> u32
pub fn trim_start(&self) -> u32
Get the number of frames to trim from the start of the decoded packet.
sourcepub fn trim_end(&self) -> u32
pub fn trim_end(&self) -> u32
Get the number of frames to trim from the end of the decoded packet.
sourcepub fn as_buf_reader(&self) -> BufReader<'_>
pub fn as_buf_reader(&self) -> BufReader<'_>
Get a BufStream
to read the packet data buffer sequentially.