Skip to main content

Container

Trait Container 

Source
pub trait Container {
    type Error: Error + Send + Sync + Unpin + From<Error> + From<MissingKeyframe> + From<InvalidEnd> + From<TimestampRewind>;

    // Required methods
    fn write(
        &self,
        group: &mut Writer<'_>,
        frames: &[Frame],
    ) -> Result<(), Self::Error>;
    fn decode(&self, frame: Frame) -> Result<Vec<Frame>, Self::Error>;

    // Provided methods
    fn end(&self, _frame: &Frame) -> Option<Timestamp> { ... }
    fn kind(&self) -> Kind { ... }
    fn decode_order(&self) -> bool { ... }
    fn writable(&self) -> Result<(), Self::Error> { ... }
    fn check(&self, _frame: &Frame) -> Result<(), Self::Error> { ... }
    fn finish_group(
        &self,
        _group: &mut Writer<'_>,
        _end: Option<Timestamp>,
    ) -> Result<(), Self::Error> { ... }
}
Expand description

Encode and decode media frames over a moq-lite group.

Implementors decide how many Frames map onto one moq-lite frame: Legacy and LOC write one media frame per moq-lite frame; CMAF can pack many samples into a single moof+mdat fragment.

Required Associated Types§

Source

type Error: Error + Send + Sync + Unpin + From<Error> + From<MissingKeyframe> + From<InvalidEnd> + From<TimestampRewind>

Container-specific error. Must be convertible from [moq_net::Error] (so IO errors propagate), MissingKeyframe, InvalidEnd, and TimestampRewind (so the producer can reject invalid group boundaries).

Required Methods§

Source

fn write( &self, group: &mut Writer<'_>, frames: &[Frame], ) -> Result<(), Self::Error>

Encode one or more frames into moq-lite frames written to group, whose first frame creates it on the track.

Source

fn decode(&self, frame: Frame) -> Result<Vec<Frame>, Self::Error>

Decode one moq-lite frame read from a group into media frames.

A single moq-lite frame may carry several media frames (e.g. all samples in a CMAF fragment), or none (a CMAF fragment with zero samples), which is not the end of the group.

On a data track an empty batch is the discontinuity marker, so a data container returns one only for an object with no bytes, and refuses any other object that decodes to no frames.

Provided Methods§

Source

fn end(&self, _frame: &Frame) -> Option<Timestamp>

Return the endpoint timestamp when frame carries empty-payload metadata.

For video this bounds the preceding frame; for audio it bounds source samples before terminal codec packets. A consumer never submits the marker to a decoder. Formats without endpoint metadata use the default.

Source

fn kind(&self) -> Kind

The media role, when this format represents an audio or video track.

Source

fn decode_order(&self) -> bool

Whether the transport carries each frame’s decode time, so a Producer groups frames by it. Otherwise the producer ignores decode times and the payload carries each frame’s presentation time.

Source

fn writable(&self) -> Result<(), Self::Error>

Refuse a format this build can read but not write, before a producer is built for it.

A catalog checks this before advertising a rendition, so a consumer never sees one whose first write would fail.

Source

fn check(&self, _frame: &Frame) -> Result<(), Self::Error>

Refuse a frame this format has no encoding for, by default any frame of an unwritable format.

A Producer checks each frame on entry, before it cuts a group or buffers anything, so a refused frame leaves the open group and the buffered frames as they were.

Source

fn finish_group( &self, _group: &mut Writer<'_>, _end: Option<Timestamp>, ) -> Result<(), Self::Error>

Write any format-specific endpoint before the producer closes the group.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Container for moq_mux::catalog::hang::Wire

Source§

impl Container for moq_mux::container::cts::Wire

Source§

impl Container for moq_mux::container::fmp4::Wire

Source§

impl Container for moq_mux::container::legacy::Wire

Source§

impl Container for moq_mux::container::loc::Wire

Source§

impl Container for moq_mux::container::raw::Wire