Skip to main content

PacketView

Struct PacketView 

Source
#[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>

Source

pub fn stream_index(&self) -> usize

Output stream index (matches the on_stream_info entries).

Source

pub fn pts(&self) -> i64

Presentation timestamp in time_base units, on the shared zero-based timeline (see applied_offset).

Source

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.

Source

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.

Source

pub fn time_base(&self) -> AVRational

Time base of this stream (identical to the stream’s PacketStreamInfo::time_base).

Source

pub fn pts_us(&self) -> i64

pts in microseconds (exact rescale of the ticks).

Source

pub fn dts_us(&self) -> i64

dts in microseconds.

Source

pub fn duration_us(&self) -> i64

duration in microseconds.

Source

pub fn applied_offset_us(&self) -> i64

applied_offset in microseconds.

Source

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.

Source

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

Source

pub fn data(&self) -> &'a [u8]

The packet payload. H.264: one complete access unit, 4-byte length-prefixed (AVCC), parameter sets carried out-of-band in the stream configuration. AAC: one raw AAC frame.

Trait Implementations§

Source§

impl<'a> Debug for PacketView<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for PacketView<'a>

§

impl<'a> RefUnwindSafe for PacketView<'a>

§

impl<'a> Send for PacketView<'a>

§

impl<'a> Sync for PacketView<'a>

§

impl<'a> Unpin for PacketView<'a>

§

impl<'a> UnsafeUnpin for PacketView<'a>

§

impl<'a> UnwindSafe for PacketView<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,