Catalog
A Catalog represents an independent MSF catalog snapshot — the complete description of all tracks available in a broadcast.
Parse and Validate
Section titled “Parse and Validate”// Example: ExampleParseCatalograw := []byte(`{ "version": "draft-02", "generatedAt": 1746104606044, "tracks": [ {"name": "video", "packaging": "loc", "isLive": true, "role": "video", "codec": "av01.0.08M.10.0.110.09", "bitrate": 5000000, "framerate": 30, "width": 1920, "height": 1080, "renderGroup": 1}, {"name": "audio", "packaging": "loc", "isLive": true, "role": "audio", "codec": "opus", "bitrate": 32000, "samplerate": 48000, "channelConfig": "2", "renderGroup": 1} ]}`)
catalog, err := msf.ParseCatalog(raw)if err != nil { fmt.Println("invalid JSON or catalog shape:", err) return}if err := catalog.Validate(); err != nil { fmt.Println("violates MSF rules:", err) return}for _, track := range catalog.Tracks { fmt.Println(track.Name, track.Role, track.Codec)}ParseCatalog decodes an independent MSF catalog from JSON. It rejects a document that begins with a byte order mark, is not UTF-8, or contains an unpaired \u surrogate escape, and an explicitly empty namespace.
Validate checks the draft-02 rules:
versionis"draft-02"(msf.CurrentVersion).- Every track has a non-empty
name, apackagingandisLive. - The fields each (packaging, role) pair requires are present (see below).
- A
namespaceis a/-separated string of 1 to 32 non-empty fields; names are UTF-8 without NUL. - Full Track Names (namespace and name) are unique across
tracksandpublishTracks. - Every
dependsentry resolves: a track name to exactly one other track, a number to a track’srenderGroup. - Every
initRefnames aninitDataListentry. cipherSuiteis present whenencryptionSchemeis"moq-secure-objects".moqlogandmoqmetricstracks are publish tracks with rolelogormetricsand a level"0"to"7"as name.
A field is present when it holds a value: a non-nil pointer, slice or map, or a non-empty string. A JSON null counts as absent.
msf.Catalog
Section titled “msf.Catalog”type Catalog struct { DefaultNamespace string Version string GeneratedAt *int64 IsComplete bool Tracks []Track PublishTracks []Track InitDataList []InitDataRef ExtraFields map[string]json.RawMessage}
func ParseCatalog(data []byte) (Catalog, error)func ParseCatalogString(s string) (Catalog, error)func (c Catalog) Validate() errorfunc (c Catalog) Clone() Catalogfunc (c Catalog) ApplyDelta(delta CatalogDelta) (Catalog, error)func (c Catalog) ResolveVariables(vars map[string]string) (Catalog, error)func (c Catalog) CatalogRefs() []TrackID| Field | Type | Description |
|---|---|---|
DefaultNamespace |
string |
Namespace the catalog track was subscribed under (not serialized) |
Version |
string |
MSF version, "draft-02" |
GeneratedAt |
*int64 |
Wallclock time the catalog was generated (optional) |
IsComplete |
bool |
The broadcast is complete; no delta applies afterwards |
Tracks |
[]Track |
Complete set of track descriptions |
PublishTracks |
[]Track |
Tracks the subscriber publishes to, such as logs and metrics |
InitDataList |
[]InitDataRef |
Initialization data referenced by track initRef |
Track Description
Section titled “Track Description”Each track in the catalog is described by an msf.Track. The most used fields:
| Field | Type | Description |
|---|---|---|
Namespace |
string |
/-separated namespace; empty inherits the catalog’s |
Name |
string |
Track name, non-empty |
Packaging |
Packaging |
Packaging mode (see below) |
PackagingMetadata |
string |
key=value;... parameters, e.g. streamMapping=object for LOC |
Role |
Role |
Content role: video, audio, caption, data, etc. |
IsLive |
*bool |
Whether new objects will be added (required) |
Codec |
string |
Codec string (e.g. "av01.0.08M.10.0.110.09") |
Bitrate |
*int64 |
Maximum bitrate in bps |
Framerate |
*int64 |
Frames per second |
SampleRate |
*int64 |
Audio sample rate |
ChannelConfig |
string |
Audio channel configuration |
Language |
string |
Language tag |
Depends |
[]Dependency |
Track names or render groups this track depends on |
RenderGroup |
*int64 |
Render group for synchronized playback |
AltGroup |
*int64 |
Alternate group for quality switching |
InitRef |
string |
Id of an InitDataList entry |
AccessibleWindowTime |
*int64 |
DVR window behind the live edge, in milliseconds |
KeyframeSpacing |
*int64 |
Objects per keyframe interval |
AuthInfo |
map[string]json.RawMessage |
Authorization schemes, e.g. cat, privacy-pass |
Required fields per packaging and role
Section titled “Required fields per packaging and role”| Packaging | Role | Also required |
|---|---|---|
loc |
audio |
codec, bitrate, samplerate, channelConfig |
loc |
video |
codec, bitrate, framerate |
loc |
audiodescription |
codec, samplerate, channelConfig, lang |
loc |
signlanguage |
codec, framerate |
eventtimeline |
any | eventType |
mediatimeline |
any | depends |
Packaging Modes
Section titled “Packaging Modes”| Constant | Value | Description |
|---|---|---|
msf.PackagingLOC |
"loc" |
LOC-packaged media content |
msf.PackagingMediaTimeline |
"mediatimeline" |
Media timeline track |
msf.PackagingEventTimeline |
"eventtimeline" |
Event timeline track |
msf.PackagingMoqLog |
"moqlog" |
Log publish track |
msf.PackagingMoqMetrics |
"moqmetrics" |
Metrics publish track |
msf.PackagingCatalog |
"catalog" |
A reference to another catalog |
msf.PackagingCMAF |
"cmaf" |
CMAF-packaged media content (non-spec) |
msf.PackagingLegacy |
"legacy" |
Legacy timestamp+payload packaging (non-spec) |
msf.RoleVideo, RoleAudio, RoleAudioDescription, RoleCaption, RoleSubtitle, RoleSignLanguage, RoleMediaTimeline, RoleEventTimeline, RoleLog, RoleMetrics and RoleData. Custom roles may be used.
A complete catalog
Section titled “A complete catalog”{ "version": "draft-02", "generatedAt": 1746104606044, "tracks": [ {"name": "video", "packaging": "loc", "isLive": true, "role": "video", "codec": "av01.0.08M.10.0.110.09", "bitrate": 5000000, "framerate": 30, "renderGroup": 1, "initRef": "video-init", "packagingMetadata": "streamMapping=group"}, {"name": "timeline", "packaging": "mediatimeline", "isLive": true, "depends": [1]} ], "publishTracks": [ {"name": "6", "namespace": "moq-syslog.arpa/logs-v1/r1", "packaging": "moqlog", "role": "log", "isLive": true} ], "initDataList": [ {"id": "video-init", "type": "inline", "data": "AAAAIGZ0eXBpc29t"} ]}Validation
Section titled “Validation”Validate() returns *msf.ValidationError containing a list of problems:
// Example: ExampleValidationErrorcatalog := msf.Catalog{ Version: msf.CurrentVersion, Tracks: []msf.Track{ {Name: "video", Packaging: msf.PackagingLOC, Role: msf.RoleVideo, IsLive: new(true)}, },}
var validationErr *msf.ValidationErrorif errors.As(catalog.Validate(), &validationErr) { for _, problem := range validationErr.Problems { fmt.Println(problem) }}Variable Substitution
Section titled “Variable Substitution”Catalog values may hold %name% variables, resolved from the fragment of the catalog URI. ResolveVariables substitutes every string value except connectionURI, then validates the result:
// Example: ExampleCatalog_ResolveVariablescatalog := msf.Catalog{ Version: msf.CurrentVersion, Tracks: []msf.Track{{ Name: "tracking-%id%", Namespace: "advertising/%event%", Packaging: msf.PackagingEventTimeline, EventType: "com.example.iab.vast", IsLive: new(true), }},}
vars := msf.ParseFragmentVariables("msf:live-demo--catalog&id=c3e5s7w&event=xyz")resolved, err := catalog.ResolveVariables(vars)if err != nil { fmt.Println(err) return}fmt.Println(resolved.Tracks[0].Namespace, resolved.Tracks[0].Name)Catalog References
Section titled “Catalog References”A track with packaging "catalog" references another catalog. msf.WalkCatalogRefs loads and visits a catalog and every catalog it references, each once, and stops with msf.ErrCatalogCycle on a cycle, or with msf.ErrCatalogDepth, msf.ErrTooManyCatalogs or msf.ErrTooManyCatalogRefs past the msf.CatalogWalkLimits (8 levels, 64 catalogs and 32 references per catalog by default).