Skip to main content

Frame

Struct Frame 

Source
pub struct Frame {
    pub timestamp: Timestamp,
    pub decode: Option<Timestamp>,
    pub duration: Option<Timestamp>,
    pub payload: Bytes,
    pub keyframe: bool,
}
Expand description

A decoded media frame: timestamp, payload bytes, keyframe flag.

payload is the raw codec bitstream that gets handed to the decoder. The exact shape depends on the codec (Annex B for H.264/H.265, OBU for AV1, and so on).

Fields§

§timestamp: Timestamp

Presentation timestamp.

Each container picks its own native scale: fmp4 uses the source mdhd.timescale, mkv uses nanoseconds, legacy is fixed at microseconds. LOC defaults to microseconds but a decoded frame keeps whatever per-frame timescale the wire carried, so an exporter can re-emit without forcing micros. Frames within a track must be in decode order, not display order. B-frames may have non-monotonic presentation timestamps.

§decode: Option<Timestamp>

Decode timestamp, when it differs from timestamp, or None when the frame decodes at its presentation time.

A decode-order container writes each frame to the transport at its decode time and groups by it: raw, which therefore refuses a reordered frame, and cts, which this build still only reads (a decoded cts frame reports it). Other containers ignore it: they carry the presentation time in the payload and stamp the transport with the newest one so far in the group, since a group’s timestamps never decrease.

§duration: Option<Timestamp>

Sample duration in the frame’s own scale, when the container reports it.

CMAF carries a per-sample duration (trun sample-duration). Legacy and LOC can fill it from a duration marker that has already landed when a GroupConsumer reads the frame, as in a fetched group. Streaming muxers receive the later endpoint separately, so media stays immediately available. The Consumer adds it to timestamp to learn how far a group has presented, so it can advance to a newer group as soon as the gap is covered instead of waiting out the max delay budget.

§payload: Bytes

Encoded codec payload.

§keyframe: bool

Whether this frame opens a group, or is a video keyframe.

Containers that carry the bit on the wire (CMAF reads it from trun sample-flags) set it for video; containers that don’t (Legacy, LOC) leave it false. The wrapping Consumer still asserts “first frame in a group is a keyframe” as a fallback, so the Legacy/LOC case lands correctly without anyone having to know. For audio, whose samples are all independently decodable, that fallback is the only source: the bit marks the group boundary the publisher drew, never a per-sample sync flag.

Trait Implementations§

Source§

impl Clone for Frame

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 Frame

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Frame

§

impl RefUnwindSafe for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnsafeUnpin for Frame

§

impl UnwindSafe for Frame

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more