moq_video/encode/encoded.rs
1//! [`Encoded`]: one encoded access unit on its way to a track.
2
3use bytes::Bytes;
4use moq_net::Timestamp;
5
6/// One encoded video frame: a whole access unit in the codec's wire framing
7/// (Annex-B with in-band parameter sets), plus the presentation time of the raw
8/// [`Frame`](crate::Frame) it came from.
9///
10/// Named for what it holds rather than mirroring [`Frame`](crate::Frame), so the
11/// two never read alike at a call site that handles both.
12///
13/// The encoder carries the timestamp through the codec rather than leaving the
14/// caller to guess one at publish time, so a backend that buffers a frame or
15/// drains a tail from [`Encoder::finish`](super::Encoder::finish) still stamps
16/// each access unit with the time of the picture it encoded.
17#[derive(Clone, Debug)]
18pub struct Encoded {
19 /// Presentation timestamp, from the raw frame this was encoded from.
20 pub timestamp: Timestamp,
21 /// The access unit, in the framing the matching catalog importer expects.
22 pub payload: Bytes,
23}
24
25impl Encoded {
26 /// An encoded access unit shown at `timestamp`.
27 pub fn new(payload: Bytes, timestamp: Timestamp) -> Self {
28 Self { timestamp, payload }
29 }
30}