Skip to main content

moq_audio/encode/
encoded.rs

1//! [`Encoded`]: one encoded packet on its way to a track.
2
3use bytes::Bytes;
4
5use crate::Activity;
6
7/// One encoded audio packet, plus what the codec was doing when it produced it.
8///
9/// Named for what it holds rather than mirroring [`Frame`](crate::Frame), so the
10/// two never read alike at a call site that handles both.
11#[derive(Clone, Debug)]
12pub struct Encoded {
13	/// The packet, in the framing the matching catalog importer expects.
14	pub payload: Bytes,
15	/// Whether this packet codes audio, or withholds it because the input was
16	/// silent. Always [`Activity::Active`] for codecs without a discontinuous
17	/// mode, and for the coded frames that punctuate a silent run.
18	pub activity: Activity,
19}
20
21impl Encoded {
22	/// A packet carrying real audio.
23	pub fn new(payload: Bytes) -> Self {
24		Self {
25			payload,
26			activity: Activity::Active,
27		}
28	}
29}