Skip to main content

Catalog

Struct Catalog 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§video: Video

Video 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: Audio

Audio 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: Timeline

The broadcast’s timeline: its clock and join interval.

Omitted from the wire when it holds nothing. See Timeline.

§text: Text

Text (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: Json

JSON tracks: application data published as live JSON documents or logs.

Omitted from the wire when empty, so a media-only catalog is unchanged.

§binary: Binary

Binary 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: E

Application-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: Skipped

The entries decoding skipped because a newer moq-hang draft defines them.

Filled when a catalog is decoded and never written.

Implementations§

Source§

impl Catalog

Source

pub const DEFAULT_NAME: &'static str = "catalog.json"

The default name for the catalog track.

Source

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.

Source

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>

Source

pub fn check_renditions(&self) -> Result<(), Error>

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.

Source

pub fn without_ext(&self) -> Catalog

Copy every section into a catalog with no application extension.

Source§

impl<E> Catalog<E>

Source

pub fn from_slice(v: &[u8]) -> Result<Catalog<E>, Error>

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.

Source

pub fn from_reader(reader: impl Read) -> Result<Catalog<E>, Error>

Parse a catalog from a reader.

Fails with Error::UnsupportedVersion if the catalog needs a newer moq-hang draft than this crate reads.

Source§

impl<E> Catalog<E>
where E: Serialize,

Source

pub fn to_json(&self) -> Result<String, Error>

Serialize the catalog to a JSON string.

Source

pub fn to_vec(&self) -> Result<Vec<u8>, Error>

Serialize the catalog to a vector of bytes.

Source

pub fn to_writer(&self, writer: impl Write) -> Result<(), Error>

Serialize the catalog to a writer.

Trait Implementations§

Source§

impl<E> Clone for Catalog<E>
where E: Clone,

Source§

fn clone(&self) -> Catalog<E>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E> Debug for Catalog<E>
where E: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<E> Default for Catalog<E>
where E: Default,

Source§

fn default() -> Catalog<E>

Returns the “default value” for a type. Read more
Source§

impl<'de, E> Deserialize<'de> for Catalog<E>

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Catalog<E>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

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.

Source§

impl<E> From<Wire<E>> for Catalog<E>

Source§

fn from(wire: Wire<E>) -> Catalog<E>

Converts to this type from the input type.
Source§

impl<E> FromStr for Catalog<E>

Source§

fn from_str(s: &str) -> Result<Catalog<E>, Error>

Parse a catalog from a string.

Fails with Error::UnsupportedVersion if the catalog needs a newer moq-hang draft than this crate reads.

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

impl<E> PartialEq for Catalog<E>
where E: PartialEq,

Source§

fn eq(&self, other: &Catalog<E>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<E> Serialize for Catalog<E>
where E: Serialize,

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<E> StructuralPartialEq for Catalog<E>
where E: PartialEq,

Auto Trait Implementations§

§

impl<E> Freeze for Catalog<E>
where E: Freeze,

§

impl<E> RefUnwindSafe for Catalog<E>
where E: RefUnwindSafe,

§

impl<E> Send for Catalog<E>
where E: Send,

§

impl<E> Sync for Catalog<E>
where E: Sync,

§

impl<E> Unpin for Catalog<E>
where E: Unpin,

§

impl<E> UnsafeUnpin for Catalog<E>
where E: UnsafeUnpin,

§

impl<E> UnwindSafe for Catalog<E>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> CatalogExt for T
where T: Serialize + DeserializeOwned + Default + Clone + Send + Unpin + 'static,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more