pub struct Decoder { /* private fields */ }Expand description
Decodes container payloads (the codec bitstream) into raw Frames.
The bring-your-own-payload layer under Consumer: use it
when the frames don’t come from a plain track subscription, e.g. a transcoder
serving individually fetched groups. Feed it the payload of each container
frame in decode order; it converts length-prefixed H.264 / H.265 to Annex-B,
passes AV1 OBU temporal units through, and gates output until the first
keyframe.
A decoder is bound to the thread that opens it. Use Sink
when the owner can move between threads.
fn move_to_another_thread(decoder: moq_video::decode::Decoder) {
std::thread::spawn(move || drop(decoder));
}Implementations§
Source§impl Decoder
impl Decoder
Sourcepub fn new(catalog: &VideoConfig, config: &Config) -> Result<Self, Error>
pub fn new(catalog: &VideoConfig, config: &Config) -> Result<Self, Error>
Build a decoder for the catalog’s video config.
A codec or description this build cannot decode is
Error::UnsupportedCodec, and so is a stream every decoder for its codec
refused because its device cannot decode it. When any of them failed to open
for another reason, such as a missing driver, the result is
Error::NoDecoder, a fault rather than a property of the track.
Sourcepub fn decode(
&mut self,
payload: &Bytes,
timestamp: Timestamp,
keyframe: bool,
) -> Result<(), Error>
pub fn decode( &mut self, payload: &Bytes, timestamp: Timestamp, keyframe: bool, ) -> Result<(), Error>
Submit one container frame, whose raw frames come out of
receive. timestamp is this frame’s presentation time;
it rides through the decoder and comes back on each output frame, so a
reordering decoder (B-frames) stamps every picture with its own
presentation time rather than this access unit’s. With no reordering the
two coincide.
Sourcepub fn flush(&mut self) -> Result<(), Error>
pub fn flush(&mut self) -> Result<(), Error>
Mark the end of input, so receive returns the frames
the backend still holds once the stream has ended.
Call this after the last access unit, and receive, before dropping the decoder. The decoder remains reusable and waits for a keyframe before accepting the next stream.