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)]
18#[non_exhaustive]
19pub struct Encoded {
20 /// Presentation timestamp, from the raw frame this was encoded from.
21 pub timestamp: Timestamp,
22 /// The access unit, in the framing the matching catalog importer expects.
23 pub payload: Bytes,
24}
25
26impl Encoded {
27 /// An encoded access unit shown at `timestamp`.
28 pub fn new(payload: Bytes, timestamp: Timestamp) -> Self {
29 Self { timestamp, payload }
30 }
31}