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§
Sourcetype Error: Error + Send + Sync + Unpin + From<Error> + From<MissingKeyframe> + From<InvalidEnd> + From<TimestampRewind>
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§
Sourcefn write(
&self,
group: &mut Writer<'_>,
frames: &[Frame],
) -> Result<(), Self::Error>
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.
Sourcefn decode(&self, frame: Frame) -> Result<Vec<Frame>, Self::Error>
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§
Sourcefn end(&self, _frame: &Frame) -> Option<Timestamp>
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.
Sourcefn decode_order(&self) -> bool
fn decode_order(&self) -> bool
Sourcefn writable(&self) -> Result<(), Self::Error>
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.
Sourcefn check(&self, _frame: &Frame) -> Result<(), Self::Error>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".