Skip to main content

Packet

Struct Packet 

Source
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

Source

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.

Source

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.

Source

pub fn from_shared( bytes: Arc<[u8]>, start: usize, len: usize, ) -> Result<Self, PacketError>

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.

Source

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.

Source

pub fn with_pts(self, pts: Timestamp) -> Self

The presentation timestamp.

Source

pub fn with_dts(self, dts: Timestamp) -> Self

The decode timestamp, when the container stores one apart from the presentation timestamp.

Source

pub fn with_duration_ticks(self, ticks: u64) -> Self

The duration, in ticks of the track’s time base, when the container records one.

Source

pub fn with_random_access(self, ra: RandomAccess) -> Self

The container’s random-access evidence.

Source

pub fn with_config_epoch(self, epoch: u32) -> Self

The codec configuration epoch this packet was coded under.

Source

pub fn with_ordinal(self, ordinal: u64) -> Self

The packet’s position in the track’s packet order.

Source

pub fn with_input_offset(self, offset: u64) -> Self

Where the payload starts in the container file.

Source

pub fn with_discard(self, discard: Discard) -> Self

Media the decoder adapter drops from this packet’s output.

Source

pub fn with_addition(self, addition: PacketAddition) -> Self

Attach side data.

Source

pub fn bytes(&self) -> &[u8] ⓘ

Payload bytes; empty once an accepting consumer took them.

Source

pub fn len(&self) -> usize

Payload length; zero once taken.

Source

pub fn is_empty(&self) -> bool

Whether no payload bytes are left (empty only once taken).

Source

pub fn is_taken(&self) -> bool

Whether an accepting consumer took the payload.

Source

pub fn take(&mut self) -> Option<PacketPayload>

Take the payload: what a consumer does when it accepts the packet. The metadata stays readable.

Source

pub fn track(&self) -> u32

The track this packet belongs to.

Source

pub fn pts(&self) -> Option<Timestamp>

The presentation timestamp, if recorded.

Source

pub fn dts(&self) -> Option<Timestamp>

The decode timestamp, if recorded apart from the presentation one.

Source

pub fn decode_time(&self) -> Option<Timestamp>

Decode-order time: dts when the container stores one, else pts.

Source

pub fn duration_ticks(&self) -> Option<u64>

The recorded duration in ticks of the track’s time base.

Source

pub fn random_access(&self) -> RandomAccess

The container’s random-access evidence.

Source

pub fn config_epoch(&self) -> u32

The configuration epoch this packet was coded under.

Source

pub fn ordinal(&self) -> Option<u64>

The packet’s position in its track’s packet order.

Source

pub fn input_offset(&self) -> Option<u64>

Where the payload starts in the container file.

Source

pub fn discard(&self) -> Option<Discard>

Media to drop from this packet’s output, as the container recorded it.

Source

pub fn additions(&self) -> &[PacketAddition]

Side data carried with the packet.

Trait Implementations§

Source§

impl Clone for Packet

Source§

fn clone(&self) -> Packet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Packet

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<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.