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///
12/// `#[non_exhaustive]`: construct packets with [`Encoded::new`] so the record
13/// can gain metadata without breaking callers.
14#[derive(Clone, Debug)]
15#[non_exhaustive]
16pub struct Encoded {
17	/// The packet, in the framing the matching catalog importer expects.
18	pub payload: Bytes,
19	/// Whether this packet codes audio, or withholds it because the input was
20	/// silent. Always [`Activity::Active`] for codecs without a discontinuous
21	/// mode, and for the coded frames that punctuate a silent run.
22	pub activity: Activity,
23}
24
25impl Encoded {
26	/// A packet carrying real audio.
27	pub fn new(payload: Bytes) -> Self {
28		Self {
29			payload,
30			activity: Activity::Active,
31		}
32	}
33}