Documentation
¶
Overview ¶
Package msf implements the MOQT Streaming Format (MSF) draft-ietf-moq-msf-02.
The package provides a self-contained representation of MSF catalog objects and timeline records, along with validation and delta-application logic. Independent catalog snapshots are modeled by Catalog, while incremental updates are modeled by CatalogDelta. Delta operations that have a narrower JSON shape than a full track entry are represented by TrackRef, TrackClone and TrackUpdate.
Naming fields map to MOQT bytes as their UTF-8 encoding, compared byte for byte with no normalization (draft-ietf-moq-msf-02 §11.2). Terminology follows draft-ietf-moq-transport-23: object properties (formerly header extensions) and PUBLISH_DONE (formerly SUBSCRIBE_DONE). The MSF properties of §12 (MSF_COMPRESSION, VIDEO_CONFIG, AUDIO_CONFIG, MSF_EVENT_TIMELINE_HEADER) are transport-layer concerns and are not modeled here.
Most of the package is transport-agnostic and can be used in pure data-processing tools or tests. The optional Broadcast helper integrates an MSF catalog with moqt.TrackHandler routing for publishers that want a small in-memory track registry, and sends each catalog change to its subscribers.
Most optional catalog fields use pointer types so that the distinction between "field absent" and "field present with zero value" is preserved after decoding. That choice supports both the `omitempty` JSON behavior and the delta/clone algorithms which need to know exactly which values were supplied by the sender.
Example:
catalog, err := msf.ParseCatalog(raw)
if err != nil {
// handle parse error
}
if err := catalog.Validate(); err != nil {
// input was syntactically correct but violated MSF rules
}
Networking primitives themselves still live in the github.com/qumo-dev/gomoqt/moqt package.
Index ¶
- Constants
- Variables
- func ParseFragmentVariables(fragment string) map[string]string
- func ResolveVariables(s string, vars map[string]string) (string, bool)
- func SplitNamespace(namespace string) ([]string, error)
- func ValidateMediaTimeline(entries []MediaTimelineEntry) error
- func ValidateVariableSyntax(s string) error
- func WalkCatalogRefs(ctx context.Context, root TrackID, limits CatalogWalkLimits, ...) error
- type AccessibilityDescriptor
- type Broadcast
- func (b *Broadcast) Catalog() Catalog
- func (b *Broadcast) CatalogBytes() ([]byte, error)
- func (b *Broadcast) CatalogTrackName() moqt.TrackName
- func (b *Broadcast) Close()
- func (b *Broadcast) Handler(name moqt.TrackName) moqt.TrackHandler
- func (b *Broadcast) RegisterTrack(track Track, handler moqt.TrackHandler) error
- func (b *Broadcast) RemoveTrack(name moqt.TrackName) error
- func (b *Broadcast) ServeTrack(tw *moqt.TrackWriter)
- func (b *Broadcast) SetCatalog(catalog Catalog) error
- type Buffers
- type Catalog
- func (c Catalog) ApplyDelta(delta CatalogDelta) (Catalog, error)
- func (c Catalog) CatalogRefs() []TrackID
- func (c Catalog) Clone() Catalog
- func (c Catalog) MarshalJSON() ([]byte, error)
- func (c Catalog) ResolveVariables(vars map[string]string) (Catalog, error)
- func (c *Catalog) UnmarshalJSON(data []byte) error
- func (c Catalog) Validate() error
- type CatalogDelta
- type CatalogWalkLimits
- type Dependency
- type EventTimelineRecord
- type InitDataRef
- type Location
- type MediaTimelineEntry
- type Packaging
- type Role
- type StreamMapping
- type Template
- type Track
- type TrackClone
- type TrackID
- type TrackRef
- type TrackUpdate
- type ValidationError
Examples ¶
Constants ¶
const ( // InitDataTypeInline marks Initialization Data List data as base64 // encoded initialization data. InitDataTypeInline = "inline" // InitDataTypeTrackProperty marks Initialization Data List data as the // hex type of the Track property that carries the initialization data. InitDataTypeTrackProperty = "track-property" // InitDataTypeObjectProperty marks Initialization Data List data as the // hex type of the Object property that carries the initialization data. InitDataTypeObjectProperty = "object-property" )
const ( // DefaultMaxCatalogDepth is the default longest chain of catalog // references followed from the root. DefaultMaxCatalogDepth = 8 // DefaultMaxCatalogs is the default number of distinct catalogs loaded // in one walk, the root included. DefaultMaxCatalogs = 64 // DefaultMaxCatalogRefs is the default number of catalog references a // single catalog may hold. DefaultMaxCatalogRefs = 32 )
Default limits WalkCatalogRefs applies to a CatalogWalkLimits field left at zero or below.
const CurrentVersion = "draft-02"
CurrentVersion is the MSF version string of the catalogs this package produces and accepts (draft-ietf-moq-msf-02 §5.1.1).
const DefaultCatalogTrackName moqt.TrackName = "catalog"
DefaultCatalogTrackName is the Track Name the top-level MSF catalog track MUST have (draft-ietf-moq-msf-02 §5). Catalogs referenced from it through packaging "catalog" tracks may use other names.
const EncryptionSchemeMoQSecureObjects = "moq-secure-objects"
EncryptionSchemeMoQSecureObjects is the encryptionScheme value for MoQ Secure Objects, the scheme for which cipherSuite is required (draft-ietf-moq-msf-02 §5.2.38, §5.2.39).
Variables ¶
var ( // ErrCatalogCycle reports a catalog that references itself, directly or // through other catalogs (draft-ietf-moq-msf-02 §13.7). ErrCatalogCycle = errors.New("msf: catalog reference cycle") // ErrCatalogDepth reports a chain of catalog references deeper than // CatalogWalkLimits.MaxDepth. ErrCatalogDepth = errors.New("msf: catalog reference depth exceeded") // ErrTooManyCatalogs reports a walk that would load more distinct // catalogs than CatalogWalkLimits.MaxCatalogs. ErrTooManyCatalogs = errors.New("msf: too many referenced catalogs") // ErrTooManyCatalogRefs reports a catalog holding more catalog references // than CatalogWalkLimits.MaxRefsPerCatalog. ErrTooManyCatalogRefs = errors.New("msf: too many catalog references in one catalog") )
var ErrCatalogComplete = errors.New("msf: cannot apply a delta to a complete catalog")
ErrCatalogComplete reports a delta applied to a catalog marked isComplete.
var ErrTrackNotFound = errors.New("msf: track not found")
ErrTrackNotFound reports that Broadcast.RemoveTrack found no track or handler with the given name.
Functions ¶
func ParseFragmentVariables ¶ added in v0.30.0
ParseFragmentVariables parses the variables of a catalog URI fragment (draft-ietf-moq-msf-02 §5.4.2). The fragment, with or without its leading '#', is split at each '&' into pairs, and each pair is split at its first '=' into a variable name and value, so values may themselves contain '='. Pairs without '=', such as the "msf:namespace--name" track locator, carry no variable and are skipped, as are pairs with an empty name. When a name repeats, the first value is kept. Values are not percent-decoded: '%' is not a legal variable value.
func ResolveVariables ¶ added in v0.18.0
ResolveVariables substitutes %name% tokens in s using the provided variables. It returns the resolved string and ok=true on success. It returns ok=false (and the partially processed input up to the failure) when:
- a percent character appears outside a %name% reference,
- a referenced variable is missing from vars, or
- a substituted value contains characters disallowed by the spec.
vars is typically the result of ParseFragmentVariables.
func SplitNamespace ¶ added in v0.30.0
SplitNamespace splits a catalog namespace string into the Track Namespace Fields it denotes (draft-ietf-moq-msf-02 §5.2.2). Every U+002F SOLIDUS is a field boundary. The string must yield between 1 and 32 fields, every field must be non-empty, and every field must satisfy the naming rules of §11.2 (valid UTF-8, no NUL). The returned fields are the exact bytes of the MOQT Track Namespace Fields: no normalization or case folding is applied.
func ValidateMediaTimeline ¶ added in v0.30.0
func ValidateMediaTimeline(entries []MediaTimelineEntry) error
ValidateMediaTimeline checks that the entries of an explicit-format media timeline are ordered by media time (draft-ietf-moq-msf-02 §7.1.1). Group IDs are not checked: they need not be sequential or monotonically increasing (§7.1).
func ValidateVariableSyntax ¶ added in v0.18.0
ValidateVariableSyntax checks that every percent character in a string occurs as part of a well-formed, non-empty %name% reference (draft-ietf-moq-msf-02 §5.4.1). It does not check that the referenced variable exists; use ResolveVariables for that. This is opt-in and is not called by Catalog.Validate.
func WalkCatalogRefs ¶ added in v0.30.0
func WalkCatalogRefs(ctx context.Context, root TrackID, limits CatalogWalkLimits, load func(context.Context, TrackID) (Catalog, error), visit func(TrackID, Catalog) error) error
WalkCatalogRefs visits the catalog root and, depth first, every catalog it references through packaging "catalog" tracks. load fetches the catalog published on a track; the walk sets the loaded catalog's DefaultNamespace to the namespace of the track it was loaded from when the catalog does not set one, so its tracks inherit that namespace. visit is called once per distinct catalog, before its references are followed.
Each distinct catalog is loaded at most once: a catalog reached again through a different path (a diamond) is skipped. A reference back to a catalog on the current path is a cycle and stops the walk with ErrCatalogCycle, as subscribers MUST detect cycles (draft-ietf-moq-msf-02 §13.7). Exceeding limits stops the walk with ErrCatalogDepth, ErrTooManyCatalogs or ErrTooManyCatalogRefs. Errors from load and visit are returned wrapped.
Types ¶
type AccessibilityDescriptor ¶ added in v0.18.0
type AccessibilityDescriptor struct {
// Scheme identifies the accessibility scheme (e.g. a URN).
Scheme string `json:"-"`
// Value specifies the accessibility channels or features available.
Value string `json:"-"`
// ExtraFields stores unknown JSON properties for round-tripping.
ExtraFields map[string]json.RawMessage `json:"-"`
}
AccessibilityDescriptor describes an embedded accessibility feature of a track (draft-ietf-moq-msf-02 §5.2.44), such as CEA-608/CEA-708 captions.
func (AccessibilityDescriptor) Clone ¶ added in v0.18.0
func (a AccessibilityDescriptor) Clone() AccessibilityDescriptor
Clone returns a deep copy of the accessibility descriptor.
func (AccessibilityDescriptor) MarshalJSON ¶ added in v0.18.0
func (a AccessibilityDescriptor) MarshalJSON() ([]byte, error)
MarshalJSON encodes the accessibility descriptor, preserving unknown keys.
func (*AccessibilityDescriptor) UnmarshalJSON ¶ added in v0.18.0
func (a *AccessibilityDescriptor) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the accessibility descriptor, preserving unknown keys.
type Broadcast ¶
type Broadcast struct {
// contains filtered or unexported fields
}
Broadcast is an MSF-aware moqt.TrackHandler that serves the catalog track and routes other track subscriptions to registered per-track handlers.
It keeps the current catalog snapshot and handler table together so callers can manage a broadcast through a single object. Track replacement and removal close any active TrackWriter values for that track; handlers are expected to return once their writer is closed.
A catalog subscription stays open for the life of the broadcast: the subscriber receives the current catalog as its first group, and a new group with the whole catalog each time SetCatalog, RegisterTrack or RemoveTrack changes it. Changes made while a group is being written are combined into the next one, so a slow subscriber skips intermediate catalogs rather than holding up the broadcast. Close ends every catalog subscription.
Because the underlying moqt routing key is a single TrackName, Broadcast requires track names to be unique across namespaces within the current catalog snapshot. This is a routing constraint of Broadcast, stricter than the MSF rule that only Full Track Names (namespace and name) be unique, which Catalog.Validate enforces. Catalogs that contain the same track name in multiple namespaces are rejected rather than being mapped to synthetic routing names, and no catalog track may use the catalog track's own name.
func NewBroadcast ¶
NewBroadcast constructs a Broadcast using an initial independent catalog. The catalog is validated before the broadcast is returned; an error is returned if validation fails.
Clients may also declare a zero-value Broadcast and call SetCatalog later; NewBroadcast is provided as a convenience initializer.
Example ¶
package main
import (
"fmt"
"github.com/qumo-dev/gomoqt/msf"
)
func main() {
catalog := msf.Catalog{
Version: msf.CurrentVersion,
Tracks: []msf.Track{
{
Name: "video", Packaging: msf.PackagingLOC, Role: msf.RoleVideo, IsLive: new(true),
Codec: "av01.0.08M.10.0.110.09", Bitrate: new(int64(5000000)), Framerate: new(int64(30)),
},
{
Name: "audio", Packaging: msf.PackagingLOC, Role: msf.RoleAudio, IsLive: new(true),
Codec: "opus", Bitrate: new(int64(32000)), SampleRate: new(int64(48000)), ChannelConfig: "2",
},
},
}
broadcast, err := msf.NewBroadcast(catalog)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(broadcast.CatalogTrackName(), len(broadcast.Catalog().Tracks))
}
Output: catalog 2
func (*Broadcast) CatalogBytes ¶
CatalogBytes returns the current catalog snapshot encoded as JSON. The result is a deep copy, so callers may modify the returned bytes without affecting the broadcast state. If the receiver is nil an error is returned.
func (*Broadcast) CatalogTrackName ¶
CatalogTrackName returns the reserved track name used for catalog delivery.
func (*Broadcast) Close ¶ added in v0.26.0
func (b *Broadcast) Close()
Close ends every catalog subscription and closes the TrackWriter values the registered track handlers are serving. The catalog is kept, but later catalog subscriptions end after their first group. Close is idempotent.
func (*Broadcast) Handler ¶
func (b *Broadcast) Handler(name moqt.TrackName) moqt.TrackHandler
Handler returns the TrackHandler responsible for serving the named track. The special catalog track name is handled by an internal method that serializes the current catalog. If no handler is registered for the name, NotFoundTrackHandler is returned. A nil Broadcast also yields the not-found handler.
func (*Broadcast) RegisterTrack ¶
func (b *Broadcast) RegisterTrack(track Track, handler moqt.TrackHandler) error
RegisterTrack adds a new track definition to the catalog and associates a handler with it. If a track with the same name already exists it is replaced. The catalog is validated after modification; the update is rejected if validation fails. The reserved catalog track name may not be used, and handler must be non-nil.
Because the catalog must be valid after every change, tracks register in dependency order: a track whose depends names another track or a render group, or whose initRef names an initDataList entry, registers after what it references exists (initDataList entries come from SetCatalog). To add tracks that reference each other at once, use SetCatalog.
Example ¶
package main
import (
"fmt"
"github.com/qumo-dev/gomoqt/moqt"
"github.com/qumo-dev/gomoqt/msf"
)
func main() {
broadcast, err := msf.NewBroadcast(msf.Catalog{Version: msf.CurrentVersion})
if err != nil {
fmt.Println(err)
return
}
serveVideo := moqt.TrackHandlerFunc(func(tw *moqt.TrackWriter) { /* write groups to tw */ })
// Register a track before any track that depends on it.
err = broadcast.RegisterTrack(msf.Track{
Name: "video", Packaging: msf.PackagingLOC, Role: msf.RoleVideo, IsLive: new(true),
Codec: "av01.0.08M.10.0.110.09", Bitrate: new(int64(5000000)), Framerate: new(int64(30)),
}, serveVideo)
if err != nil {
fmt.Println(err)
return
}
err = broadcast.RegisterTrack(msf.Track{
Name: "timeline", Packaging: msf.PackagingMediaTimeline, IsLive: new(true),
Depends: []msf.Dependency{msf.DependsOnTrack("video")},
}, serveVideo)
fmt.Println(err, len(broadcast.Catalog().Tracks))
}
Output: <nil> 2
func (*Broadcast) RemoveTrack ¶
RemoveTrack removes the named track and its handler from the broadcast.
The broadcast's catalog stays valid: if another track still references the track (a depends entry naming it, or the last track of a render group that a depends entry names), RemoveTrack returns the *ValidationError and changes nothing, track and handler included. Remove the dependent tracks first, or replace the catalog with SetCatalog.
It returns ErrTrackNotFound when neither the catalog nor the handler table holds the name, and an error for an empty name or the catalog track's name.
Example ¶
package main
import (
"errors"
"fmt"
"github.com/qumo-dev/gomoqt/msf"
)
func main() {
broadcast, err := msf.NewBroadcast(msf.Catalog{
Version: msf.CurrentVersion,
Tracks: []msf.Track{
{Name: "video", Packaging: msf.PackagingLOC, IsLive: new(true)},
{Name: "timeline", Packaging: msf.PackagingMediaTimeline, IsLive: new(true),
Depends: []msf.Dependency{msf.DependsOnTrack("video")}},
},
})
if err != nil {
fmt.Println(err)
return
}
// "timeline" depends on "video", so removing "video" first is refused
// and the catalog stays as it was.
err = broadcast.RemoveTrack("video")
var validationErr *msf.ValidationError
fmt.Println(errors.As(err, &validationErr), len(broadcast.Catalog().Tracks))
fmt.Println(broadcast.RemoveTrack("timeline"), broadcast.RemoveTrack("video"))
fmt.Println(errors.Is(broadcast.RemoveTrack("video"), msf.ErrTrackNotFound))
}
Output: true 2 <nil> <nil> true
func (*Broadcast) ServeTrack ¶
func (b *Broadcast) ServeTrack(tw *moqt.TrackWriter)
ServeTrack implements the moqt.TrackHandler interface by dispatching the incoming TrackWriter to the handler determined by Handler(). This allows a Broadcast value to be published directly without additional wrappers.
func (*Broadcast) SetCatalog ¶
SetCatalog replaces the current independent catalog snapshot. The provided catalog is cloned and validated before being stored. Concurrent readers of Catalog() will see either the old or new snapshot, but not a partially applied state.
type Buffers ¶ added in v0.18.0
type Buffers struct {
// Target is the target buffer in milliseconds.
Target *int64 `json:"-"`
// Min is the minimum buffer in milliseconds.
Min *int64 `json:"-"`
// Max is the maximum buffer in milliseconds.
Max *int64 `json:"-"`
// ExtraFields stores unknown JSON properties for round-tripping.
ExtraFields map[string]json.RawMessage `json:"-"`
}
Buffers represents a track's target jitter-buffer configuration (draft-ietf-moq-msf-02 §5.2.10) in integer milliseconds. Keys are optional; unknown keys are preserved in ExtraFields per the spec's "MUST be ignored".
func (*Buffers) Clone ¶ added in v0.18.0
Clone returns a deep copy of the buffers configuration. Safe on a nil receiver.
func (Buffers) MarshalJSON ¶ added in v0.18.0
MarshalJSON encodes the buffers object, preserving unknown keys.
func (*Buffers) UnmarshalJSON ¶ added in v0.18.0
UnmarshalJSON decodes the buffers object, preserving unknown keys.
type Catalog ¶
type Catalog struct {
DefaultNamespace string `json:"-"`
// Version is the MSF version string, CurrentVersion for catalogs this
// package accepts (draft-ietf-moq-msf-02 §5.1.1).
Version string `json:"-"`
// GeneratedAt, if non-nil, records the catalog's generatedAt timestamp.
GeneratedAt *int64 `json:"-"`
// IsComplete reports whether the catalog has been explicitly marked as complete.
IsComplete bool `json:"-"`
// Tracks holds the complete set of track descriptions in the catalog.
Tracks []Track `json:"-"`
// PublishTracks holds tracks to which subscribers may publish data, such as
// logs or metrics (draft-ietf-moq-msf-02 §5.1.5).
PublishTracks []Track `json:"-"`
// InitDataList holds referenced initialization data entries; tracks point
// at an entry by ID via the initRef attribute (draft-ietf-moq-msf-02 §5.1.7).
InitDataList []InitDataRef `json:"-"`
// ExtraFields stores any JSON properties that don't correspond to the
// explicit fields above; they are preserved when re-encoding the catalog.
ExtraFields map[string]json.RawMessage `json:"-"`
}
Catalog represents an independent MSF catalog object as defined in draft-ietf-moq-msf-02.
Delta updates are modeled separately by CatalogDelta so that the type system can distinguish a complete catalog snapshot from a set of incremental catalog operations. DefaultNamespace is not serialized; it represents the namespace implied by the catalog track itself (the Track Namespace under which the catalog was subscribed) and is used to resolve track namespace inheritance. A track that declares a namespace replaces, rather than extends, DefaultNamespace.
func ParseCatalog ¶
ParseCatalog decodes an independent MSF catalog from JSON bytes. It rejects the delta-only deltaUpdate field, and documents that begin with a byte order mark, are not UTF-8, or contain an unpaired surrogate escape (draft-ietf-moq-msf-02 §11.2.1). Validation must be performed separately if desired.
Example ¶
package main
import (
"fmt"
"github.com/qumo-dev/gomoqt/msf"
)
func main() {
raw := []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)
}
}
Output: video video av01.0.08M.10.0.110.09 audio audio opus
func ParseCatalogString ¶
ParseCatalogString is like ParseCatalog but accepts a string input. It is provided for convenience when the catalog is already available as a string.
func (Catalog) ApplyDelta ¶
func (c Catalog) ApplyDelta(delta CatalogDelta) (Catalog, error)
ApplyDelta applies a catalog delta to the receiver and returns the updated catalog (draft-ietf-moq-msf-02 §5.3). Operations apply in order, each to the result of the previous one. An illogical operation (adding or cloning to an existing Full Track Name, removing or updating an unknown track) rejects the whole delta, as does a result that fails Validate.
A catalog with IsComplete set rejects every delta with ErrCatalogComplete: isComplete commits that no tracks will be added and no content published (§5.1.3), a delta cannot carry isComplete itself (§5.3), so a delta after it could only change a finished broadcast.
Example ¶
package main
import (
"fmt"
"github.com/qumo-dev/gomoqt/msf"
)
func main() {
base := msf.Catalog{
Version: msf.CurrentVersion,
Tracks: []msf.Track{
{Name: "video", Packaging: msf.PackagingLOC, IsLive: new(true), Bitrate: new(int64(5000000))},
{Name: "old-audio", Packaging: msf.PackagingLOC, IsLive: new(true)},
},
}
delta, err := msf.ParseCatalogDelta([]byte(`{
"generatedAt": 1746104606044,
"deltaUpdate": [
{"op": "update", "tracks": [{"parentName": "video", "bitrate": 4000000}]},
{"op": "add", "tracks": [{"name": "subtitle", "packaging": "loc", "isLive": true, "role": "subtitle"}]},
{"op": "remove", "tracks": [{"name": "old-audio"}]}
]
}`))
if err != nil {
fmt.Println(err)
return
}
updated, err := base.ApplyDelta(delta)
if err != nil {
fmt.Println(err)
return
}
for _, track := range updated.Tracks {
fmt.Println(track.Name)
}
fmt.Println("video bitrate:", *updated.Tracks[0].Bitrate)
}
Output: video subtitle video bitrate: 4000000
func (Catalog) CatalogRefs ¶ added in v0.30.0
CatalogRefs returns the Full Track Names of the tracks in c that reference other catalogs (packaging "catalog", draft-ietf-moq-msf-02 §5), in catalog order. A track without a namespace inherits c.DefaultNamespace.
func (Catalog) MarshalJSON ¶
MarshalJSON encodes the independent catalog in the draft-02 JSON shape. initDataList is emitted last, after tracks, as §5.1.7 recommends.
func (Catalog) ResolveVariables ¶ added in v0.18.0
ResolveVariables substitutes variables in every string value of the catalog, including nested objects such as authInfo and unknown extension fields, then validates the result, since a catalog MUST be validated after substitution (draft-ietf-moq-msf-02 §5.4.1, §13.5). Object keys and non-string values are left as they are. The name mapping rules of §11.2 apply to the substituted names, which Validate checks.
Following the §13.5 advice that substitution SHOULD NOT reach fields that determine a network endpoint, connectionURI values are not substituted; a connectionURI that still holds a variable reference is reported as an error. A caller that trusts the URI source can resolve such a value itself with the string form of ResolveVariables.
On error the returned catalog is the zero value.
Example ¶
package main
import (
"fmt"
"github.com/qumo-dev/gomoqt/msf"
)
func main() {
catalog := 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)
}
Output: advertising/xyz tracking-c3e5s7w
func (*Catalog) UnmarshalJSON ¶
UnmarshalJSON decodes the independent catalog shape and rejects delta-only fields.
func (Catalog) Validate ¶
Validate checks whether the catalog satisfies the package's MSF draft-02 rules: the version, the per-track rules including the required fields per (packaging, role) of §5.2.4.1, unique Full Track Names, the Initialization Data List, that every depends entry resolves (§5.2.15), and that tracks of an alternate group share accessibleWindowTime (§5.2.45).
A catalog that uses variable substitution must be validated after substitution (§5.4.1, §13.5); Catalog.ResolveVariables does so.
type CatalogDelta ¶
type CatalogDelta struct {
// DefaultNamespace, if set, replaces the base catalog namespace used for
// resolving tracks whose namespace field is omitted. It is not serialized.
DefaultNamespace string `json:"-"`
// GeneratedAt records the delta's generatedAt timestamp; it is required.
GeneratedAt *int64 `json:"-"`
// AddTracks lists new track entries to append to the base catalog.
AddTracks []Track `json:"-"`
// RemoveTracks identifies tracks to remove from the base catalog.
RemoveTracks []TrackRef `json:"-"`
// CloneTracks lists clone operations derived from an existing parent track.
CloneTracks []TrackClone `json:"-"`
// UpdateTracks lists update operations that override fields of an
// existing track.
UpdateTracks []TrackUpdate `json:"-"`
// ExtraFields stores unknown JSON properties for round-tripping.
ExtraFields map[string]json.RawMessage `json:"-"`
// contains filtered or unexported fields
}
CatalogDelta represents a delta update for an existing MSF catalog (draft-ietf-moq-msf-02 §5.1.6, §5.3).
A delta catalog never carries a complete track list. Instead it contains one or more add/remove/clone/update operations and the generatedAt timestamp, which a delta MUST carry; it MUST NOT carry any other root catalog field. The JSON form is a "deltaUpdate" array of operation objects, each shaped as {"op": "add"|"remove"|"clone"|"update", "tracks": [...]}.
The in-memory model keeps one grouped slice per operation kind (AddTracks, RemoveTracks, CloneTracks, UpdateTracks). A decoded delta also records each wire operation in order, so interleaved operations (e.g. remove,add,remove of the same track) apply and re-encode in their declared order. Tracks a delta built or extended in code holds beyond the recorded operations follow as one operation per kind, in add, remove, clone, update order, so an update can target a track the same delta adds or clones.
func ParseCatalogDelta ¶
func ParseCatalogDelta(data []byte) (CatalogDelta, error)
ParseCatalogDelta decodes an MSF catalog delta from JSON bytes. Like ParseCatalog it rejects documents that begin with a byte order mark, are not UTF-8, or contain an unpaired surrogate escape.
func ParseCatalogDeltaString ¶
func ParseCatalogDeltaString(s string) (CatalogDelta, error)
ParseCatalogDeltaString is like ParseCatalogDelta but accepts a string.
func (CatalogDelta) Clone ¶
func (d CatalogDelta) Clone() CatalogDelta
Clone returns a deep copy of the delta catalog.
func (CatalogDelta) MarshalJSON ¶
func (d CatalogDelta) MarshalJSON() ([]byte, error)
MarshalJSON encodes the delta in the draft-02 JSON form: a "deltaUpdate" array of {"op", "tracks"} objects in declared operation order, plus generatedAt.
func (*CatalogDelta) UnmarshalJSON ¶
func (d *CatalogDelta) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes a delta catalog and rejects the root catalog fields a delta must not carry (version, isComplete, tracks, publishTracks, initDataList). A missing generatedAt is reported by Validate.
func (CatalogDelta) Validate ¶
func (d CatalogDelta) Validate() error
Validate checks whether the delta satisfies the package's MSF draft-02 rules: generatedAt is present, at least one operation carries a track, and each operation's tracks are well formed. Whether the operations are logical for a given catalog is checked by Catalog.ApplyDelta.
type CatalogWalkLimits ¶ added in v0.30.0
type CatalogWalkLimits struct {
// MaxDepth is the longest chain of references followed from the root
// (DefaultMaxCatalogDepth).
MaxDepth int
// MaxCatalogs is the number of distinct catalogs loaded, the root
// included (DefaultMaxCatalogs). It bounds wide fan-out, which a depth
// limit alone lets grow exponentially.
MaxCatalogs int
// MaxRefsPerCatalog is the number of catalog references one catalog may
// hold (DefaultMaxCatalogRefs).
MaxRefsPerCatalog int
}
CatalogWalkLimits bounds the resources WalkCatalogRefs spends, since subscribers SHOULD bound the catalog references they follow (draft-ietf-moq-msf-02 §13.7). A field at zero or below takes its default.
type Dependency ¶ added in v0.30.0
type Dependency struct {
// TrackName is the Track Name of the track depended upon, for a JSON
// String entry.
TrackName string
// RenderGroup is the renderGroup depended upon, for a JSON Number entry.
RenderGroup *int64
}
Dependency is one entry of a track's depends array (draft-ietf-moq-msf-02 §5.2.15). An entry references either another track by its Track Name (a JSON String) or a render group by its renderGroup number (a JSON Number). Exactly one of TrackName and RenderGroup is set.
func DependsOnRenderGroup ¶ added in v0.30.0
func DependsOnRenderGroup(group int64) Dependency
DependsOnRenderGroup returns a dependency on the render group group.
func DependsOnTrack ¶ added in v0.30.0
func DependsOnTrack(name string) Dependency
DependsOnTrack returns a dependency on the track named name.
func (Dependency) MarshalJSON ¶ added in v0.30.0
func (d Dependency) MarshalJSON() ([]byte, error)
MarshalJSON encodes a track-name dependency as a JSON String and a render-group dependency as a JSON Number.
func (Dependency) String ¶ added in v0.30.0
func (d Dependency) String() string
String returns the track name, or "renderGroup N" for a render-group dependency.
func (*Dependency) UnmarshalJSON ¶ added in v0.30.0
func (d *Dependency) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes a depends entry: a JSON String is a track name and a JSON Number is a renderGroup. Any other JSON type is rejected.
type EventTimelineRecord ¶
type EventTimelineRecord struct {
// one of the following three pointers is set to select the index type
Wallclock *int64 `json:"-"`
Location *Location `json:"-"`
MediaTime *int64 `json:"-"`
// Data is the event payload: any JSON value, including null, whose
// structure is defined by the track's eventType. It must be present.
Data json.RawMessage `json:"-"`
// ExtraFields holds unknown JSON properties for round-tripping.
ExtraFields map[string]json.RawMessage `json:"-"`
}
EventTimelineRecord represents a single event in an event-timeline track. Exactly one of Wallclock, Location or MediaTime must be non‑nil, indicating which index is used for the record. The Data field contains the event payload as raw JSON. Any additional properties are preserved in ExtraFields. The JSON encoding (draft-ietf-moq-msf-02 §8.2) is an object with the uppercase index keys "T" (wallclock), "L" (location) or "M" (mediaTime), "data" and optionally others.
Example ¶
package main
import (
"encoding/json"
"fmt"
"github.com/qumo-dev/gomoqt/msf"
)
func main() {
record := msf.EventTimelineRecord{
Wallclock: new(int64(1756885678361)),
Data: json.RawMessage(`{"homeScore":2,"awayScore":0}`),
}
if err := record.Validate(); err != nil {
fmt.Println(err)
return
}
data, err := json.Marshal(record)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(data))
}
Output: {"T":1756885678361,"data":{"homeScore":2,"awayScore":0}}
func (EventTimelineRecord) MarshalJSON ¶
func (r EventTimelineRecord) MarshalJSON() ([]byte, error)
MarshalJSON encodes the event timeline record using the draft-02 JSON shape.
func (*EventTimelineRecord) UnmarshalJSON ¶
func (r *EventTimelineRecord) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the event timeline record using the draft-02 JSON shape.
func (EventTimelineRecord) Validate ¶
func (r EventTimelineRecord) Validate() error
Validate checks whether the event timeline record contains exactly one index selector (wallclock, location, or mediaTime) and a non-empty data payload. It is used by callers that need to ensure a record meets the MSF draft’s integrity constraints before serializing or applying it.
type InitDataRef ¶ added in v0.18.0
type InitDataRef struct {
// ID is the unique-within-catalog reference for this init data.
ID string `json:"-"`
// Type identifies how Data is interpreted.
Type string `json:"-"`
// Data holds the init payload as defined by Type.
Data string `json:"-"`
// ExtraFields stores unknown JSON properties for round-tripping.
ExtraFields map[string]json.RawMessage `json:"-"`
}
InitDataRef represents a single entry in the catalog's Initialization Data List (draft-ietf-moq-msf-02 §5.1.7). Tracks reference an entry by its ID via the initRef track attribute. Type is InitDataTypeInline (Data is base64 encoded init data), InitDataTypeTrackProperty or InitDataTypeObjectProperty (Data is the hex type of the property that carries the init data as raw bytes, §12.2).
func (InitDataRef) Clone ¶ added in v0.18.0
func (r InitDataRef) Clone() InitDataRef
Clone returns a deep copy of the init-data reference.
func (InitDataRef) MarshalJSON ¶ added in v0.18.0
func (r InitDataRef) MarshalJSON() ([]byte, error)
MarshalJSON encodes the init-data reference as the draft-02 object form.
func (InitDataRef) PropertyType ¶ added in v0.30.0
func (r InitDataRef) PropertyType() (uint64, error)
PropertyType returns the property type named by Data for the InitDataTypeTrackProperty and InitDataTypeObjectProperty types. Data is hex notation, with or without a "0x" prefix.
func (*InitDataRef) UnmarshalJSON ¶ added in v0.18.0
func (r *InitDataRef) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the init-data reference, preserving unknown keys.
type Location ¶
Location identifies the precise position of an object within an MSF broadcast. It consists of the group sequence number and the object ID inside that group. The JSON representation is a two-element array [groupID, objectID].
func (Location) MarshalJSON ¶
MarshalJSON encodes the location as [groupID, objectID]. It is used by the default json package when a Location is serialized. The reverse operation is implemented by UnmarshalJSON.
func (*Location) UnmarshalJSON ¶
UnmarshalJSON decodes the location from [groupID, objectID]. This method ensures that the compact array format in the MSF specification is accepted when reading JSON.
type MediaTimelineEntry ¶
MediaTimelineEntry represents a single record in a media timeline track. It maps a media timestamp to an object location and the corresponding wallclock time. When encoded in JSON the structure is a three-element array [mediaTime, [groupID, objectID], wallclock].
func (MediaTimelineEntry) MarshalJSON ¶
func (e MediaTimelineEntry) MarshalJSON() ([]byte, error)
MarshalJSON encodes the media timeline entry as [mediaTime, [groupID, objectID], wallclock].
func (*MediaTimelineEntry) UnmarshalJSON ¶
func (e *MediaTimelineEntry) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the media timeline entry from [mediaTime, [groupID, objectID], wallclock].
type Packaging ¶
type Packaging string
Packaging identifies the JSON packaging string for an MSF track.
const ( // PackagingLOC identifies LOC-packaged media content. PackagingLOC Packaging = "loc" // PackagingMediaTimeline identifies a media timeline track. PackagingMediaTimeline Packaging = "mediatimeline" // PackagingEventTimeline identifies an event timeline track. PackagingEventTimeline Packaging = "eventtimeline" // PackagingMoqLog identifies a MoQ log publish track ([MOQLOG]). PackagingMoqLog Packaging = "moqlog" // PackagingMoqMetrics identifies a MoQ metrics publish track ([MOQMETRICS]). PackagingMoqMetrics Packaging = "moqmetrics" // PackagingCatalog identifies a track that is itself an MSF catalog, // referenced from another catalog (draft-ietf-moq-msf-02 §5). PackagingCatalog Packaging = "catalog" // PackagingCMAF identifies CMAF-packaged media content. // Non-spec extension retained for backward compatibility. PackagingCMAF Packaging = "cmaf" // PackagingLegacy identifies legacy timestamp+payload packaging. // Non-spec extension retained for backward compatibility. PackagingLegacy Packaging = "legacy" )
type Role ¶
type Role string
Role identifies the optional content role string for an MSF track.
const ( // RoleVideo identifies a video track. RoleVideo Role = "video" // RoleAudio identifies an audio track. RoleAudio Role = "audio" // RoleAudioDescription identifies an audio-description track. RoleAudioDescription Role = "audiodescription" // RoleCaption identifies a caption track. RoleCaption Role = "caption" // RoleSubtitle identifies a subtitle track. RoleSubtitle Role = "subtitle" // RoleSignLanguage identifies a sign-language video track. RoleSignLanguage Role = "signlanguage" // RoleMediaTimeline identifies an MSF media timeline track. RoleMediaTimeline Role = "mediatimeline" // RoleEventTimeline identifies an MSF event timeline track. RoleEventTimeline Role = "eventtimeline" // RoleLog identifies a log publishing track ([MOQLOG]). RoleLog Role = "log" // RoleMetrics identifies a metrics publishing track ([MOQMETRICS]). RoleMetrics Role = "metrics" // RoleData identifies a track carrying application-defined data // (draft-ietf-moq-msf-02 §5.2.7). RoleData Role = "data" )
type StreamMapping ¶ added in v0.30.0
type StreamMapping string
StreamMapping is the LOC to MOQT Stream mapping mode signaled by the streamMapping key of a loc track's packagingMetadata (draft-ietf-moq-msf-02 §4.1.1).
const ( // StreamMappingGroup sends all Objects of a Group in a single Subgroup, // in Object ID order. It is the default. StreamMappingGroup StreamMapping = "group" // StreamMappingObject sends each Object in its own Subgroup. StreamMappingObject StreamMapping = "object" )
type Template ¶ added in v0.18.0
type Template struct {
// StartMediaTime is the media presentation timestamp of the first entry.
StartMediaTime int64
// DeltaMediaTime is the constant interval between media timestamps (ms).
DeltaMediaTime int64
// StartLocation is the MOQT Location of the first entry.
StartLocation Location
// DeltaLocation is the constant interval between MOQT Locations.
DeltaLocation Location
// StartWallclock is the wallclock time of the first entry; 0 for VOD.
StartWallclock int64
// DeltaWallclock is the constant interval between wallclock times (ms).
DeltaWallclock int64
}
Template describes a media-timeline template for tracks with fixed-duration segments (draft-ietf-moq-msf-02 §5.2.16 / §7.4). The JSON form is a six-element array:
[startMediaTime, deltaMediaTime, [groupID, objectID], [deltaGroup, deltaObject], startWallclock, deltaWallclock]
where deltaMediaTime and deltaWallclock are expressed in milliseconds.
func (*Template) Clone ¶ added in v0.18.0
Clone returns a deep copy of the template. Safe on a nil receiver.
func (Template) Entry ¶ added in v0.18.0
func (t Template) Entry(n int64) MediaTimelineEntry
Entry returns the n-th (zero-based) timeline entry computed from the template per the formulas in draft-ietf-moq-msf-02 §7.4.1.
n MUST be non-negative; the template formulas are defined only for n >= 0 and the location computation uses unsigned arithmetic.
Example ¶
package main
import (
"fmt"
"github.com/qumo-dev/gomoqt/msf"
)
func main() {
template := msf.Template{
DeltaMediaTime: 2002,
DeltaLocation: msf.Location{GroupID: 1},
StartWallclock: 1759924158381,
DeltaWallclock: 2002,
}
entry := template.Entry(3)
fmt.Println(entry.MediaTime, entry.Location.GroupID, entry.Wallclock)
}
Output: 6006 3 1759924164387
func (Template) MarshalJSON ¶ added in v0.18.0
MarshalJSON encodes the template as the draft-02 six-element array form.
func (*Template) UnmarshalJSON ¶ added in v0.18.0
UnmarshalJSON decodes the template from the draft-02 six-element array form.
type Track ¶
type Track struct {
// Namespace of the track as a '/'-delimited string of 1 to 32 non-empty
// Track Namespace Fields (see SplitNamespace). If empty, the catalog's
// DefaultNamespace is inherited; a declared namespace replaces it.
Namespace string `json:"-"`
// Name of the track; non-empty, and the Full Track Name (namespace and
// name) is unique within the catalog.
Name string `json:"-"`
// Packaging mode string such as "loc" or "mediatimeline".
Packaging Packaging `json:"-"`
// PackagingMetadata holds additional parameters for the packaging as a
// semicolon-separated list of key=value pairs (draft-ietf-moq-msf-02
// §5.2.5). See PackagingMetadataValue and StreamMapping.
PackagingMetadata string `json:"-"`
// For eventtimeline tracks, the event type identifier.
EventType string `json:"-"`
// Optional content role ("video", "audio", etc.).
Role Role `json:"-"`
// IsLive indicates whether the track is live. Pointer form allows knowing
// if the field was omitted vs explicitly set to false.
IsLive *bool `json:"-"`
// Target latency in milliseconds; nil means unspecified.
TargetLatency *int64 `json:"-"`
// Human-readable label.
Label string `json:"-"`
// Render group number for synchronized playback.
RenderGroup *int64 `json:"-"`
// Alternate group for quality switching.
AltGroup *int64 `json:"-"`
// InitRef points at the id of an entry in the catalog InitDataList
// (draft-ietf-moq-msf-02 §5.2.14).
InitRef string `json:"-"`
// Buffers is the optional target jitter-buffer configuration.
Buffers *Buffers `json:"-"`
// Template is the optional media-timeline template for fixed-duration
// segments (draft-ietf-moq-msf-02 §5.2.16 / §7.4).
Template *Template `json:"-"`
// Depends lists the track names and render groups this track depends on
// (draft-ietf-moq-msf-02 §5.2.15). Every entry must resolve within the
// catalog.
Depends []Dependency `json:"-"`
// Temporal and spatial identifiers for H.264/AV1 layers, optional.
TemporalID *int64 `json:"-"`
SpatialID *int64 `json:"-"`
// Codec string, may be empty.
Codec string `json:"-"`
// MIME type for the track's data payload.
MimeType string `json:"-"`
// Frame rate, timescale, and bitrate all optional and pointer-typed.
Framerate *int64 `json:"-"`
Timescale *int64 `json:"-"`
// Bitrate is the maximum bitrate in bits per second (draft-ietf-moq-msf-02 §5.2.23).
Bitrate *int64 `json:"-"`
// AvgBitrate is the average bitrate over the track lifetime (§5.2.24).
AvgBitrate *int64 `json:"-"`
// MaxGopDuration is the maximum duration between random access points, in ms (§5.2.25).
MaxGopDuration *int64 `json:"-"`
// MaxGroupDuration is the maximum duration of any MOQT Group, in ms (§5.2.26).
MaxGroupDuration *int64 `json:"-"`
// Spatial dimensions; pointers so zero width/height can be distinguished
// from the field being absent.
Width *int64 `json:"-"`
Height *int64 `json:"-"`
// Audio sample rate and channel configuration.
SampleRate *int64 `json:"-"`
ChannelConfig string `json:"-"`
// Display size for crop/letterbox.
DisplayWidth *int64 `json:"-"`
DisplayHeight *int64 `json:"-"`
// Language tag, optional.
Language string `json:"-"`
// TrackDuration in milliseconds; must not be set when IsLive is true.
TrackDuration *int64 `json:"-"`
// ConnectionURI is the MOQT endpoint URI for a publish track (§5.2.37),
// encoded under the JSON key "connectionURI".
ConnectionURI string `json:"-"`
// EncryptionScheme identifies the encryption scheme protecting the track (§5.2.38).
EncryptionScheme string `json:"-"`
// CipherSuite identifies the AEAD cipher suite; required when
// EncryptionScheme is EncryptionSchemeMoQSecureObjects (§5.2.39).
CipherSuite string `json:"-"`
// KeyID identifies the key material used for encryption (§5.2.40).
KeyID string `json:"-"`
// TrackBaseKey is the base64-encoded base key material for the track (§5.2.41).
TrackBaseKey string `json:"-"`
// AuthInfo signals that authorization is required, keyed by scheme
// (§5.2.42). Publish tracks also use it for publish authorization.
AuthInfo map[string]json.RawMessage `json:"-"`
// Accessibility lists embedded accessibility features (§5.2.44).
Accessibility []AccessibilityDescriptor `json:"-"`
// AccessibleWindowTime is how far behind the live edge, in wallclock
// milliseconds, the track's content remains accessible (§5.2.45).
AccessibleWindowTime *int64 `json:"-"`
// KeyframeSpacing is the number of objects per keyframe interval (§5.2.46).
KeyframeSpacing *int64 `json:"-"`
// ExtraFields stores unknown JSON key/values for round-tripping.
ExtraFields map[string]json.RawMessage `json:"-"`
}
Track represents a catalog track description. Numeric and boolean fields are pointers so that an absent field (nil) differs from one set to zero or false.
A field is present exactly when it holds a value: a non-nil pointer, slice or map, or a non-empty string. Validation, encoding and the clone and update overrides all read presence from the values themselves, so code that clears a decoded field (sets Namespace to "" to inherit, Bitrate to nil) makes it absent everywhere. Decoding follows the same rule: a JSON null for a known field leaves it absent, and an explicitly empty namespace or parentNamespace, which draft-ietf-moq-msf-02 §5.2.2 makes the catalog invalid, is a decoding error. As a consequence a clone or update entry cannot set a string field to empty or a pointer field to absent.
Naming fields (Namespace, Name, Depends track names, and the parent fields of clone and update operations) map to MOQT bytes as the UTF-8 encoding of the string, with no normalization or case folding, and compare byte for byte (draft-ietf-moq-msf-02 §11.2).
ExtraFields round-trips unknown keys through the custom JSON marshaling.
func (Track) ID ¶
ID returns the resolved identity of the track.
If Namespace is omitted, defaultNamespace is used to model catalog namespace inheritance from the MSF specification.
func (Track) MarshalJSON ¶
MarshalJSON encodes the track using the draft-02 object form.
func (Track) PackagingMetadataValue ¶ added in v0.30.0
PackagingMetadataValue returns the value of key in the track's packagingMetadata (draft-ietf-moq-msf-02 §5.2.5), a semicolon-separated list of key=value pairs. If key appears more than once the first occurrence is used. Keys are case-sensitive.
func (Track) StreamMapping ¶ added in v0.30.0
func (t Track) StreamMapping() StreamMapping
StreamMapping returns the track's LOC stream mapping mode from the streamMapping key of its packagingMetadata, or StreamMappingGroup when the key is absent (draft-ietf-moq-msf-02 §4.1.1).
func (*Track) UnmarshalJSON ¶
UnmarshalJSON decodes the track JSON object and preserves unknown fields.
type TrackClone ¶
TrackClone describes a "clone" operation in a catalog delta.
The embedded Track provides the override values to apply to the cloned track, including its new Name. ParentName identifies the source track from which values are inherited and ParentNamespace (optional) identifies the namespace of that source track; without it the catalog namespace is assumed.
func (TrackClone) Clone ¶
func (c TrackClone) Clone() TrackClone
Clone returns a deep copy of the clone operation.
func (TrackClone) MarshalJSON ¶
func (c TrackClone) MarshalJSON() ([]byte, error)
MarshalJSON encodes the clone entry as a JSON object with parentName and optional parentNamespace.
func (*TrackClone) UnmarshalJSON ¶
func (c *TrackClone) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes a "clone" track entry.
func (TrackClone) Validate ¶
func (c TrackClone) Validate(path string) []string
Validate checks whether the "clone" track entry is valid: it needs the new track name and the parent name.
type TrackRef ¶
type TrackRef struct {
Namespace string `json:"-"`
Name string `json:"-"`
ExtraFields map[string]json.RawMessage `json:"-"`
}
TrackRef identifies a track by namespace and name.
It is used where only the identity of a track is required, such as the tracks of a "remove" operation inside a catalog delta.
func (TrackRef) MarshalJSON ¶
MarshalJSON encodes the reference as a JSON object.
func (*TrackRef) UnmarshalJSON ¶
UnmarshalJSON decodes the "remove" track JSON shape.
type TrackUpdate ¶ added in v0.30.0
TrackUpdate describes an "update" operation in a catalog delta (draft-ietf-moq-msf-02 §5.1.6).
ParentName and ParentNamespace (optional) identify the existing track to update. The fields declared in the embedded Track override that track's values; fields not declared keep their values. Declaring name or namespace renames the track, which must not collide with another track.
func (TrackUpdate) Clone ¶ added in v0.30.0
func (u TrackUpdate) Clone() TrackUpdate
Clone returns a deep copy of the update operation.
func (TrackUpdate) MarshalJSON ¶ added in v0.30.0
func (u TrackUpdate) MarshalJSON() ([]byte, error)
MarshalJSON encodes the update entry as a JSON object with parentName and optional parentNamespace.
func (*TrackUpdate) UnmarshalJSON ¶ added in v0.30.0
func (u *TrackUpdate) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes an "update" track entry.
func (TrackUpdate) Validate ¶ added in v0.30.0
func (u TrackUpdate) Validate(path string) []string
Validate checks whether the "update" track entry is valid: it needs the name of the track to update.
type ValidationError ¶
type ValidationError struct {
Problems []string
}
ValidationError contains one or more validation problems.
Example ¶
package main
import (
"errors"
"fmt"
"github.com/qumo-dev/gomoqt/msf"
)
func main() {
catalog := msf.Catalog{
Version: msf.CurrentVersion,
Tracks: []msf.Track{
{Name: "video", Packaging: msf.PackagingLOC, Role: msf.RoleVideo, IsLive: new(true)},
},
}
var validationErr *msf.ValidationError
if errors.As(catalog.Validate(), &validationErr) {
for _, problem := range validationErr.Problems {
fmt.Println(problem)
}
}
}
Output: tracks[0]: codec is required for loc tracks with role video tracks[0]: bitrate is required for loc tracks with role video tracks[0]: framerate is required for loc tracks with role video
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error returns the aggregated validation problems as a single error string.