Skip to main content

Packet

Struct Packet 

Source
pub struct Packet {
    pub stream_index: usize,
    pub pts: Option<i64>,
    pub dts: Option<i64>,
    pub duration: i64,
    pub end_position: Option<i64>,
    pub discard_padding: u32,
    pub time_base: Rational,
    pub data: Vec<u8>,
    pub flags: PacketFlags,
}
Expand description

A compressed packet belonging to a single stream.

Fields§

§stream_index: usize

Index of the stream this packet belongs to within its container.

§pts: Option<i64>

Presentation timestamp, in the stream’s time_base units. None if unset.

§dts: Option<i64>

Decode timestamp, in the stream’s time_base units. None if unset.

§duration: i64

Duration of this packet, in time_base units (0 if unknown).

§end_position: Option<i64>

Where the stream’s decoded output ENDS once this packet is decoded, in time_base units, when the container records it — Ogg’s granule position, which sits on the last packet completing each page (None on the others, and in containers without one). Unlike pts it marks an end, not a start: decoders count samples from it to trim end padding off the end_of_stream packet.

§discard_padding: u32

Samples (per channel, at the stream’s sample rate) to drop from the END of this packet’s decoded output; 0 = none. The container’s record of the encoder’s end padding on a stream’s last packet — Matroska’s DiscardPadding, FFmpeg’s AV_PKT_DATA_SKIP_SAMPLES end field — for containers whose timestamps are too coarse to carry it as an end_position. As in FFmpeg, audio decoders drop that many samples when it fits in what the packet decodes to and ignore it otherwise.

§time_base: Rational

The stream time base these timestamps are expressed in.

§data: Vec<u8>

The compressed payload.

§flags: PacketFlags

Packet flags (keyframe, …).

Implementations§

Source§

impl Packet

Source

pub fn new(stream_index: usize) -> Packet

Construct an empty packet for the given stream.

Source

pub fn from_data(stream_index: usize, data: Vec<u8>) -> Packet

Construct a packet wrapping an existing payload.

Source

pub fn is_keyframe(&self) -> bool

Trait Implementations§

Source§

impl Clone for Packet

Source§

fn clone(&self) -> Self

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
Source§

impl Default for Packet

Source§

fn default() -> Self

Returns the “default value” for a type. 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.