Documentation
¶
Overview ¶
Package dp1 implements parsing, validation, and helpers for the DP-1 protocol (playlists, playlist-groups, ref manifests, and registered extensions).
Entrypoints use JSON Schema (draft 2020-12) embedded from the specification: use ParseAndValidate* functions to obtain typed values that are known to match the schema.
Index ¶
- Variables
- func CodeFromChannelValidation(err error) error
- func CodeFromPlaylistGroupValidation(err error) error
- func CodeFromPlaylistValidation(err error) error
- func CodeFromRefManifestValidation(err error) error
- func ParseAndValidateChannel(data []byte) (*channels.Channel, error)
- func ParseAndValidatePlaylist(data []byte) (*playlist.Playlist, error)
- func ParseAndValidatePlaylistGroup(data []byte) (*playlistgroup.Group, error)
- func ParseAndValidatePlaylistWithContentRatingExtension(data []byte) (*playlist.Playlist, error)
- func ParseAndValidatePlaylistWithPlaylistsAndContentRatingExtensions(data []byte) (*playlist.Playlist, error)
- func ParseAndValidatePlaylistWithPlaylistsExtension(data []byte) (*playlist.Playlist, error)
- func ParseAndValidateRefManifest(data []byte) (*refmanifest.Manifest, error)
- func ParseDPVersion(s string) (*semver.Version, error)
- func ValidateContentRatingExtension(data []byte) error
- func WarnMajorMismatch(document *semver.Version, wantMajor uint64) error
- func WithCode(code ErrorCode, err error) error
- type CodedError
- type ErrorCode
Constants ¶
This section is empty.
Variables ¶
var ( ErrValidation = validate.ErrValidation ErrSigInvalid = sign.ErrSigInvalid ErrUnsupportedAlg = sign.ErrUnsupportedAlg ErrNoSignatures = sign.ErrNoSignatures )
Sentinel errors re-exported so applications can use a single import path with errors.Is / errors.As (e.g. signature verification vs JSON Schema validation).
var ( PlaylistCoreSchemaValidate = validate.Playlist PlaylistWithPlaylistsExtensionSchemaValidate = validate.PlaylistWithPlaylistsExtension PlaylistWithContentRatingExtensionSchemaValidate = validate.PlaylistWithContentRatingExtension PlaylistWithPlaylistsAndContentRatingExtensionsSchemaValidate = validate.PlaylistWithPlaylistsAndContentRatingExtensions PlaylistGroupSchemaValidate = validate.PlaylistGroup RefManifestSchemaValidate = validate.RefManifest ChannelExtensionSchemaValidate = validate.ChannelsExtension )
The following hooks default to the real JSON Schema validators. Tests may replace them briefly to exercise JSON decode error paths. Do not reassign concurrently in production.
Functions ¶
func CodeFromChannelValidation ¶
CodeFromChannelValidation maps JSON Schema validation failures to CodeChannelInvalid.
func CodeFromPlaylistGroupValidation ¶
CodeFromPlaylistGroupValidation maps JSON Schema validation failures to CodePlaylistGroupInvalid.
func CodeFromPlaylistValidation ¶
CodeFromPlaylistValidation maps JSON Schema validation failures to CodePlaylistInvalid (playlist core or playlist + playlists extension schemas). The wrapped error still satisfies errors.Is(err, ErrValidation) for the underlying failure.
func CodeFromRefManifestValidation ¶
CodeFromRefManifestValidation maps JSON Schema validation failures to CodeRefManifestInvalid.
func ParseAndValidateChannel ¶
ParseAndValidateChannel validates the channels extension document.
func ParseAndValidatePlaylist ¶
ParseAndValidatePlaylist validates against the core playlist schema and decodes into playlist.Playlist.
Only core fields are guaranteed schema-valid: the core schema describes no registry-extension field, so an inlineManifest present in the document decodes without ever being checked, and the merge package feeds its controls straight into display preferences. Callers that act on it should parse with ParseAndValidatePlaylistWithPlaylistsExtension instead.
func ParseAndValidatePlaylistGroup ¶
func ParseAndValidatePlaylistGroup(data []byte) (*playlistgroup.Group, error)
ParseAndValidatePlaylistGroup validates a playlist-group (exhibition) document.
func ParseAndValidatePlaylistWithContentRatingExtension ¶ added in v0.6.2
ParseAndValidatePlaylistWithContentRatingExtension validates core plus the draft content-rating extension.
func ParseAndValidatePlaylistWithPlaylistsAndContentRatingExtensions ¶ added in v0.6.2
func ParseAndValidatePlaylistWithPlaylistsAndContentRatingExtensions(data []byte) (*playlist.Playlist, error)
ParseAndValidatePlaylistWithPlaylistsAndContentRatingExtensions validates both draft overlays.
func ParseAndValidatePlaylistWithPlaylistsExtension ¶
ParseAndValidatePlaylistWithPlaylistsExtension validates against the composed playlists extension schema (core bundle + extension fragment).
func ParseAndValidateRefManifest ¶
func ParseAndValidateRefManifest(data []byte) (*refmanifest.Manifest, error)
ParseAndValidateRefManifest validates a ref manifest document.
func ParseDPVersion ¶
ParseDPVersion parses a document dpVersion field (SemVer), per DP-1 §12. Typical use: after decoding a playlist, compare or log against the player’s supported spec version.
func ValidateContentRatingExtension ¶ added in v0.6.2
ValidateContentRatingExtension validates only the draft content-rating overlay. It accepts a partial/full playlist without requiring core fields or signatures, making it suitable for legacy ingestion boundaries that cannot yet require a signed DP-1 document.
func WarnMajorMismatch ¶
WarnMajorMismatch is an optional policy helper for §12 (“players warn on major mismatch”). Pass the parsed dpVersion and the major version your player implements (e.g. 1 for DP-1 v1.x). Nil document is a no-op so callers can skip parsing when the field is absent.
Types ¶
type CodedError ¶
CodedError wraps an error with ErrorCode for UI or telemetry.
func (*CodedError) Error ¶
func (e *CodedError) Error() string
func (*CodedError) Unwrap ¶
func (e *CodedError) Unwrap() error
type ErrorCode ¶
type ErrorCode string
ErrorCode is a stable string for DP-1 §14 (player → UI) mapping where applicable, plus SDK-specific codes for document types not named in §14.
const ( // CodePlaylistInvalid is the §14 code for playlist schema / structural failure (“Playlist malformed.”). // Use with ParseAndValidatePlaylist and ParseAndValidatePlaylistWithPlaylistsExtension only. CodePlaylistInvalid ErrorCode = "playlistInvalid" // CodePlaylistGroupInvalid is used when a playlist-group (exhibition) document fails JSON Schema validation or decode. CodePlaylistGroupInvalid ErrorCode = "playlistGroupInvalid" // CodeRefManifestInvalid is used when a ref manifest document fails JSON Schema validation or decode. CodeRefManifestInvalid ErrorCode = "refManifestInvalid" // CodeChannelInvalid is used when a channel extension document fails JSON Schema validation or decode. CodeChannelInvalid ErrorCode = "channelInvalid" // CodeSigInvalid is the §14 code for signature verification failure (“Invalid feed signature.”). // Returned by the sign package; not emitted from ParseAndValidate* helpers. CodeSigInvalid ErrorCode = "sigInvalid" // The following §14 codes are reserved for player/runtime behavior (auth, hash drift, network). // This parsing/signing SDK does not emit them; clients may use them when implementing a full player. CodeLicenseDenied ErrorCode = "licenseDenied" CodeReproMismatch ErrorCode = "reproMismatch" CodeSourceUnreachable ErrorCode = "sourceUnreachable" // CodeContentBlocked reports that a structurally valid item was excluded by consumer policy. // Invalid content-rating metadata remains CodePlaylistInvalid. CodeContentBlocked ErrorCode = "contentBlocked" )
Directories
¶
| Path | Synopsis |
|---|---|
|
Package displayat provides parsing and scheduling helpers for the DP-1 Playlist Extension displayAt field.
|
Package displayat provides parsing and scheduling helpers for the DP-1 Playlist Extension displayAt field. |
|
extension
|
|
|
channels
Package channels contains types for the DP-1 "channels" extension (playlist-group evolution).
|
Package channels contains types for the DP-1 "channels" extension (playlist-group evolution). |
|
contentrating
Package contentrating defines the draft DP-1 content-rating extension types.
|
Package contentrating defines the draft DP-1 content-rating extension types. |
|
identity
Package identity holds shared types used by multiple DP-1 registry extensions.
|
Package identity holds shared types used by multiple DP-1 registry extensions. |
|
playlists
Package playlists contains types for the DP-1 "playlists" extension (draft): optional fields on a playlist document.
|
Package playlists contains types for the DP-1 "playlists" extension (draft): optional fields on a playlist document. |
|
internal
|
|
|
validate
Package validate loads embedded JSON Schema (draft 2020-12) documents and validates raw JSON payloads.
|
Package validate loads embedded JSON Schema (draft 2020-12) documents and validates raw JSON payloads. |
|
Package jcs exposes RFC 8785 JSON Canonicalization for DP-1 signing payloads.
|
Package jcs exposes RFC 8785 JSON Canonicalization for DP-1 signing payloads. |
|
Package merge applies DP-1 resolution order for display (and related) fields on an item: defaults → item inlineManifest → ref manifest → item override (JSON) → item-local fields (last wins for the same path).
|
Package merge applies DP-1 resolution order for display (and related) fields on an item: defaults → item inlineManifest → ref manifest → item override (JSON) → item-local fields (last wins for the same path). |
|
Package playlist defines DP-1 major-1 playlist document types (core wire format).
|
Package playlist defines DP-1 major-1 playlist document types (core wire format). |
|
Package playlistgroup defines DP-1 playlist-group (exhibition) documents.
|
Package playlistgroup defines DP-1 playlist-group (exhibition) documents. |
|
Package refmanifest defines the optional ref manifest envelope (metadata + controls).
|
Package refmanifest defines the optional ref manifest envelope (metadata + controls). |
|
Package sign implements DP-1 signing payload construction (JCS, UTF-8, LF-terminated octets) and signature verification.
|
Package sign implements DP-1 signing payload construction (JCS, UTF-8, LF-terminated octets) and signature verification. |