#[non_exhaustive]pub struct Catalog<E = ()> {
pub video: Video,
pub audio: Audio,
pub sync: Timeline,
pub text: Text,
pub json: Json,
pub binary: Binary,
pub stats: Option<Stats>,
pub echo: Option<Echo>,
pub include: BTreeMap<String, Include>,
pub ext: E,
pub skipped: Skipped,
}Expand description
A catalog track, created by a broadcaster to describe the tracks available in a broadcast.
The base catalog carries the media sections (video, audio, text), the optional sync
section (the broadcast’s one wall-clock mapping and join interval), the data sections
(json, binary) for application tracks that aren’t media, plus stats naming the
publisher’s media snapshot track, echo soliciting viewer feedback under a relative broadcast
prefix, and include naming whole broadcasts for explicit selection.
Applications extend it with their own root sections (e.g. com.example.scte35, or moq-mux’s
mpegts) through E. The catalog
does not deny unknown fields, so a base consumer ignores the extra sections and an extended
catalog stays wire-compatible. See the extension_roundtrip test.
Every section this crate defines must have its shape when present, or decoding refuses the
whole catalog: a section that silently read as empty would hide a publisher bug. An
application’s own root data goes under a namespaced key (com.example.telemetry) instead.
Marked #[non_exhaustive] so a future base section can be added without bumping the major
version. External callers start from Catalog::default and fill in the sections they
publish; struct-literal construction (with or without ..base) is not available outside
this crate.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.video: VideoVideo track information with multiple renditions.
Contains a map of video track renditions that the viewer can choose from based on their preferences (resolution, bitrate, codec, etc). Omitted from the wire when it has no renditions.
audio: AudioAudio track information with multiple renditions.
Contains a map of audio track renditions that the viewer can choose from based on their preferences (codec, bitrate, language, etc). Omitted from the wire when it has no renditions.
sync: TimelineThe broadcast’s timeline: its clock and join interval.
Omitted from the wire when it holds nothing. See Timeline.
text: TextText (caption/subtitle) track information with multiple renditions.
Contains a map of text track renditions that the viewer can choose from based on their preferences (language, role). Omitted from the wire when empty, so a broadcast without captions stays byte-identical to before this section existed.
json: JsonJSON tracks: application data published as live JSON documents or logs.
Omitted from the wire when empty, so a media-only catalog is unchanged.
binary: BinaryBinary tracks: application data published as opaque payloads.
Omitted from the wire when empty, so a media-only catalog is unchanged.
stats: Option<Stats>The publisher’s optional media snapshot track.
echo: Option<Echo>The optional prefix soliciting viewer feedback broadcasts.
include: BTreeMap<String, Include>Whole broadcasts listed for explicit, lazy selection, keyed by include ID.
Each shares this catalog’s PTS timeline and root settings, including sync.clock and
sync.interval; its own settings are ignored. Listing one subscribes to nothing;
see Include. Omitted from the wire when empty.
ext: EApplication-defined root sections, flattened alongside the base catalog sections.
The root version and every section name are reserved: serializing fails if the extension
names one.
skipped: SkippedThe entries decoding skipped because a newer moq-hang draft defines them.
Filled when a catalog is decoded and never written.
Implementations§
Source§impl Catalog<()>
impl Catalog<()>
Sourcepub const DEFAULT_NAME: &str = "catalog.json"
pub const DEFAULT_NAME: &str = "catalog.json"
The default name for the catalog track.
Sourcepub fn default_track_info() -> Info
pub fn default_track_info() -> Info
Track properties for creating the catalog track via
create_track at
DEFAULT_NAME.
Timed in milliseconds, so snapshots share the broadcast clock with media, fresh for the media’s
MAX_AGE, so a reader playing behind the live edge still
receives each update it holds until its timestamp, and
compressed, since catalog JSON is small and repetitive.
Sourcepub fn default_subscription() -> Subscription
pub fn default_subscription() -> Subscription
The subscription preferences used for the catalog track (high priority so it preempts media tracks).
Source§impl<E> Catalog<E>
impl<E> Catalog<E>
Sourcepub fn check_renditions(&self) -> Result<()>
pub fn check_renditions(&self) -> Result<()>
Refuse a catalog with an ID naming both a video and an audio rendition, or with a rendition field out of range, such as a zero sample rate or a projection out of bounds.
Decoding already refuses an out-of-range rendition, so this catches a catalog built by hand.
Sourcepub fn without_ext(&self) -> Catalog<()>
pub fn without_ext(&self) -> Catalog<()>
Copy every section into a catalog with no application extension.
Source§impl<E: DeserializeOwned + Default> Catalog<E>
impl<E: DeserializeOwned + Default> Catalog<E>
Sourcepub fn from_slice(v: &[u8]) -> Result<Self>
pub fn from_slice(v: &[u8]) -> Result<Self>
Parse a catalog from a slice of bytes.
Fails with Error::UnsupportedVersion if the catalog
needs a newer moq-hang draft than this crate reads.
Sourcepub fn from_reader(reader: impl Read) -> Result<Self>
pub fn from_reader(reader: impl Read) -> Result<Self>
Parse a catalog from a reader.
Fails with Error::UnsupportedVersion if the catalog
needs a newer moq-hang draft than this crate reads.
Trait Implementations§
Source§impl<'de, E: DeserializeOwned + Default> Deserialize<'de> for Catalog<E>
impl<'de, E: DeserializeOwned + Default> Deserialize<'de> for Catalog<E>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Buffered, so every version is read before any section, which a newer draft may have
reshaped. An entry needing a newer draft is skipped and listed in skipped.