pub struct Packet { /* private fields */ }Expand description
A compressed access unit and what the container recorded about it.
Every timing field is optional, and a missing value stays missing:
nothing in this crate derives a timestamp from a nominal frame rate. A
timestamp uses the track’s TimeBase.
Implementations§
Source§impl Packet
impl Packet
Sourcepub fn from_vec(bytes: Vec<u8>) -> Result<Self, PacketError>
pub fn from_vec(bytes: Vec<u8>) -> Result<Self, PacketError>
A packet owning bytes, on track 0 with nothing else recorded.
§Errors
PacketError::Empty for an empty payload.
Sourcepub fn from_accounted(bytes: SharedStorage<u8>) -> Result<Self, PacketError>
pub fn from_accounted(bytes: SharedStorage<u8>) -> Result<Self, PacketError>
A packet over already admitted storage, without copying or releasing
the charge. Packet clones and take() retain the same allocation owner.
A packet over len bytes of bytes from start, without copying.
§Errors
PacketError::Empty for len == 0; PacketError::OutOfRange
when the range leaves the buffer.
Sourcepub fn with_track(self, track: u32) -> Self
pub fn with_track(self, track: u32) -> Self
The track this packet belongs to: an index into the demuxer’s
tracks, or into what a muxer
got at begin.
Sourcepub fn with_dts(self, dts: Timestamp) -> Self
pub fn with_dts(self, dts: Timestamp) -> Self
The decode timestamp, when the container stores one apart from the presentation timestamp.
Sourcepub fn with_duration_ticks(self, ticks: u64) -> Self
pub fn with_duration_ticks(self, ticks: u64) -> Self
The duration, in ticks of the track’s time base, when the container records one.
Sourcepub fn with_random_access(self, ra: RandomAccess) -> Self
pub fn with_random_access(self, ra: RandomAccess) -> Self
The container’s random-access evidence.
Sourcepub fn with_config_epoch(self, epoch: u32) -> Self
pub fn with_config_epoch(self, epoch: u32) -> Self
The codec configuration epoch this packet was coded under.
Sourcepub fn with_ordinal(self, ordinal: u64) -> Self
pub fn with_ordinal(self, ordinal: u64) -> Self
The packet’s position in the track’s packet order.
Sourcepub fn with_input_offset(self, offset: u64) -> Self
pub fn with_input_offset(self, offset: u64) -> Self
Where the payload starts in the container file.
Sourcepub fn with_discard(self, discard: Discard) -> Self
pub fn with_discard(self, discard: Discard) -> Self
Media the decoder adapter drops from this packet’s output.
Sourcepub fn with_addition(self, addition: PacketAddition) -> Self
pub fn with_addition(self, addition: PacketAddition) -> Self
Attach side data.
Sourcepub fn take(&mut self) -> Option<PacketPayload>
pub fn take(&mut self) -> Option<PacketPayload>
Take the payload: what a consumer does when it accepts the packet. The metadata stays readable.
Sourcepub fn dts(&self) -> Option<Timestamp>
pub fn dts(&self) -> Option<Timestamp>
The decode timestamp, if recorded apart from the presentation one.
Sourcepub fn decode_time(&self) -> Option<Timestamp>
pub fn decode_time(&self) -> Option<Timestamp>
Decode-order time: dts when the container stores one, else pts.
Sourcepub fn duration_ticks(&self) -> Option<u64>
pub fn duration_ticks(&self) -> Option<u64>
The recorded duration in ticks of the track’s time base.
Sourcepub fn random_access(&self) -> RandomAccess
pub fn random_access(&self) -> RandomAccess
The container’s random-access evidence.
Sourcepub fn config_epoch(&self) -> u32
pub fn config_epoch(&self) -> u32
The configuration epoch this packet was coded under.
Sourcepub fn input_offset(&self) -> Option<u64>
pub fn input_offset(&self) -> Option<u64>
Where the payload starts in the container file.
Sourcepub fn discard(&self) -> Option<Discard>
pub fn discard(&self) -> Option<Discard>
Media to drop from this packet’s output, as the container recorded it.
Sourcepub fn additions(&self) -> &[PacketAddition]
pub fn additions(&self) -> &[PacketAddition]
Side data carried with the packet.