#[non_exhaustive]pub struct PacketView<'a> { /* private fields */ }Expand description
Borrowed view of one delivered packet (strict tier).
The view — including data — is valid only during the
on_packet callback; the underlying packet is recycled as soon as the
callback returns. Copy out what you keep.
Implementations§
Source§impl<'a> PacketView<'a>
impl<'a> PacketView<'a>
Sourcepub fn stream_index(&self) -> usize
pub fn stream_index(&self) -> usize
Output stream index (matches the on_stream_info entries).
Sourcepub fn pts(&self) -> i64
pub fn pts(&self) -> i64
Presentation timestamp in time_base units, on the
shared zero-based timeline (see
applied_offset).
Sourcepub fn dts(&self) -> i64
pub fn dts(&self) -> i64
Decode timestamp in time_base units, strictly
increasing per stream. May be negative on non-anchor streams (a stream
whose timeline starts earlier than the anchor stream keeps its true
relative offset) and, with B-frames, ahead of pts reordering.
Sourcepub fn duration(&self) -> i64
pub fn duration(&self) -> i64
Packet duration in time_base units. Always
positive in the strict tier: the encoder’s duration is passed through;
when absent it is derived (video: one CFR frame interval; audio: the
codec frame size). A packet whose duration cannot be derived fails the
job before delivery — this field is never a guess of zero.
Sourcepub fn time_base(&self) -> AVRational
pub fn time_base(&self) -> AVRational
Time base of this stream (identical to the stream’s
PacketStreamInfo::time_base).
Sourcepub fn duration_us(&self) -> i64
pub fn duration_us(&self) -> i64
duration in microseconds.
Sourcepub fn applied_offset_us(&self) -> i64
pub fn applied_offset_us(&self) -> i64
applied_offset in microseconds.
Sourcepub fn is_key(&self) -> bool
pub fn is_key(&self) -> bool
Whether this packet is a fresh-decoder-safe random access point.
For H.264 this is true iff the access unit contains an IDR NAL
unit — deliberately not the encoder’s raw AV_PKT_FLAG_KEY: with
open-GOP encoding, encoders flag non-IDR recovery points as key
frames, and feeding such a packet to a fresh decoder (the WebCodecs
"key" contract) is not safe. Audio packets are always key.
Sourcepub fn applied_offset(&self) -> i64
pub fn applied_offset(&self) -> i64
The per-stream offset that was subtracted from pts/dts to move
this stream onto the shared zero-based timeline, in this stream’s
time_base units.
All streams share a single origin: the (dts, time_base) of the first
delivered packet of the job. The anchor stream therefore starts at
dts 0; other streams keep their true audio/video offset (which may be
negative). original_ts = delivered_ts + applied_offset recovers the
encoder timeline exactly (cross-time-base rounding is at most one tick
per stream).