Documentation
¶
Overview ¶
Package releasepolicy evaluates the same bounded, declarative rules for playback, release search and unsaved previews. No client or UI dependencies.
Index ¶
- Constants
- func Better(a, b Result) bool
- func ChannelSourceAllowed(r core.Release, duration time.Duration, renditionKbps int) bool
- func Conflict(rules []core.ReleaseRule) string
- func ConflictWith(rules []core.ReleaseRule, lookup FieldLookup) string
- func Equivalent(a, b Result) bool
- func IsExternalFieldID(id string) bool
- func PositiveLanguageTargets(rules []core.ReleaseRule) []string
- func ProbedAudioLanguages(streams []core.StreamInfo) []string
- func UsesOriginalAudio(rules []core.ReleaseRule) bool
- type Context
- type Explanation
- type FieldLookup
- type FieldSpec
- type Policy
- func (p *Policy) AudioExclusion(rel core.Release, ctx Context) (ruleName, outcome string, needed []string, ok bool)
- func (p *Policy) Evaluate(rel core.Release, ctx Context) Result
- func (p *Policy) RequiredAudioMissing(rel core.Release, ctx Context, streams []core.StreamInfo, estimated bool) (missing string, ok bool)
- func (p *Policy) UnverifiedAudioLanguages(rel core.Release, ctx Context) (required []string, unverified bool)
- type Result
- type State
Constants ¶
const MaxUnknownAudioProbes = 4
MaxUnknownAudioProbes bounds how many unknown-audio-language candidates a single resolve or playback failover sequence will probe to verify required audio tracks.
Variables ¶
This section is empty.
Functions ¶
func Better ¶
Better gives explicit fallback tiers precedence, then ordered preferences. Equal policy results leave TRaSH, health and source routing order untouched.
func ChannelSourceAllowed ¶
ChannelSourceAllowed is the owner's hard source envelope for virtual TV. Network headroom never admits 4K, remuxes or disc images. Ordinary encodes reserve 25% of the rendition budget for variable bitrate and cheap playout. Unknown individual file size is checked again after opening a pack/link.
func Conflict ¶
func Conflict(rules []core.ReleaseRule) string
Conflict describes required rules that cannot be true of one release. Empty means no such conflict. Disabled rules, exceptions and fallbacks are left alone: those can still be satisfied.
func ConflictWith ¶ added in v0.3.3
func ConflictWith(rules []core.ReleaseRule, lookup FieldLookup) string
ConflictWith is Conflict with a caller-supplied field table; it is what the console-served descriptors declare as single-value that decides a conflict, so plugin single-value fields conflict the same way.
func Equivalent ¶
Equivalent reports the same fallback tier and the same ordered preference vector. Health racing may overtake only an equivalent candidate; a fallback must not pass a still-valid primary.
func IsExternalFieldID ¶ added in v0.3.3
IsExternalFieldID reports whether id is plugin-namespaced ("plugin:<id>/<key>"), the shape every plugin rule field takes.
func PositiveLanguageTargets ¶
func PositiveLanguageTargets(rules []core.ReleaseRule) []string
PositiveLanguageTargets returns normalized language names explicitly asked for by non-disabled "require" or "prefer" rules (and "require" fallbacks).
func ProbedAudioLanguages ¶
func ProbedAudioLanguages(streams []core.StreamInfo) []string
ProbedAudioLanguages extracts concrete audio track language tags from probed media streams using container language codes and stream titles.
func UsesOriginalAudio ¶
func UsesOriginalAudio(rules []core.ReleaseRule) bool
UsesOriginalAudio reports whether evaluation of these rules needs the catalogue original language. Disabled rules do not.
Types ¶
type Context ¶
type Context struct {
OriginalLanguage string
ExternalMatch func(core.Release, core.ReleaseCondition) (bool, bool)
}
Context is evidence that belongs to the title, not the release. OriginalLanguage is the catalogue title's original language (Title.Language) when the caller has that title. An empty value means the comparison is unavailable. It is never a guessed language, and it is not part of the profile selection hash or the search cache key.
type Explanation ¶
type FieldLookup ¶ added in v0.3.3
FieldLookup resolves a condition field id to its spec. The resolver builds one from the descriptor registry; nil means the built-in table.
type FieldSpec ¶ added in v0.3.3
type FieldSpec struct {
ID string
// ValueClass: text, choice, language, number or none
// (extend.RuleValue* values, kept as strings to avoid a cycle).
ValueClass string
Operators []string
DefaultOperator string
SingleValue bool
// External marks a plugin-contributed field: it compiles when its
// descriptor is registered and evaluates Unknown until the plugin
// hot path (WS9h) supplies matches.
External bool
}
FieldSpec describes one rule field for validation and for the extend descriptor registry (WS1a). The console renders its condition picker from descriptors built on these specs, so this table is the one Go source for which fields exist and how their values validate.
func BuiltinFields ¶ added in v0.3.3
func BuiltinFields() []FieldSpec
BuiltinFields returns the built-in rule fields in console picker order.
func LookupBuiltinField ¶ added in v0.3.3
LookupBuiltinField is the default FieldLookup.
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
func Compile ¶
func Compile(rules []core.ReleaseRule) (*Policy, error)
Compile validates rules against the built-in field table. Plugin-namespaced fields compile structurally (operator and value shape) and evaluate Unknown; see CompileWith for registry-checked compilation.
func CompileWith ¶ added in v0.3.3
func CompileWith(rules []core.ReleaseRule, lookup FieldLookup) (*Policy, error)
CompileWith is Compile with a caller-supplied field table, built by the resolver from the descriptor registry so registered plugin fields compile under their declared operators and value class. A nil lookup uses the built-in table. Behaviour for built-in fields is identical either way.
func (*Policy) AudioExclusion ¶
func (p *Policy) AudioExclusion(rel core.Release, ctx Context) (ruleName, outcome string, needed []string, ok bool)
AudioExclusion reports whether p.Evaluate(rel, ctx) rejected rel because a declared audio language contradicted an audio rule (rather than a non-audio preference), returning that rule's name and the language(s) that would pass when it is a "require" rule.
func (*Policy) RequiredAudioMissing ¶
func (p *Policy) RequiredAudioMissing(rel core.Release, ctx Context, streams []core.StreamInfo, estimated bool) (missing string, ok bool)
RequiredAudioMissing evaluates p against concrete probed audio streams from media probing (replacing name-declared audio languages with probed stream languages). When the probed audio fails an audio-language requirement in p, it returns the missing language name (for example "english") and ok=false.
func (*Policy) UnverifiedAudioLanguages ¶
func (p *Policy) UnverifiedAudioLanguages(rel core.Release, ctx Context) (required []string, unverified bool)
UnverifiedAudioLanguages inspects a release rejected by p.Evaluate(rel, ctx) and reports whether every rejecting rule is a "require" rule that failed solely because one or more audio-language conditions ("language" or "audio_matches_original") evaluated Unknown from the release name.
When unverified is true, required lists the normalized language names that a media probe must confirm before the release may be played.
type Result ¶
type Result struct {
Rejected bool `json:"rejected"`
Unknown bool `json:"unknown"`
Fallback int `json:"fallback"`
Preferences []int `json:"preferences"`
Explanations []Explanation `json:"explanations"`
}
func (Result) PreferRule ¶ added in v0.3.0
PreferRule returns 1 when the prefer rule with id matched, 0 otherwise.