resolve

package
v1.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RankStreams

func RankStreams(ctx context.Context, cfg Config, streams []*media.Stream) (*media.Stream, error)

RankStreams probes every candidate in parallel and returns the highest- bandwidth playable one. A stream that probes cleanly but carries no castable video+audio, or is too short to be anything but a spliced-in ad, is dropped hard so it can't win when the real sources are unreachable. A stream whose probe fails (403/timeout/reset) is kept at zero bandwidth as a last resort, since the puller reconnects differently and may still succeed. If every candidate is a decoy, ranking fails cleanly.

func Resolve

func Resolve(ctx context.Context, cfg Config, stream *media.Stream) (*media.Stream, error)

Resolve determines the final URL and content type for a stream. When the source is an HLS playlist with multiple variants, it picks the highest- bandwidth one no taller than cfg.MaxHeight. Only the fields resolution establishes are rewritten; everything else is preserved.

Types

type Config

type Config struct {
	HLSTimeout          time.Duration `yaml:"hls_timeout" validate:"required"`
	FFprobePath         string        `yaml:"ffprobe_path" validate:"required"`
	ProbeTimeout        time.Duration `yaml:"probe_timeout" validate:"required"`
	ProbeMaxConcurrency int           `yaml:"probe_max_concurrency" validate:"required,min=1"`

	// MaxHeight is the tallest video the user wants cast: source selection
	// prefers the largest HLS variant no taller than this, and the encoder
	// scales its output down to it. Set it to your renderer's native height
	// (e.g. 2160 for a 4K TV). Required, so it is always an explicit ceiling.
	MaxHeight int `yaml:"max_height" validate:"required,min=1"`
}

type StreamDetail

type StreamDetail struct {
	URL     string
	BitRate int64
}

StreamDetail holds a stream URL and its probed bit rate, for display.

func ListStreams

func ListStreams(ctx context.Context, cfg Config, streams []*media.Stream) []StreamDetail

ListStreams expands HLS variants and probes each, returning details for display. Failures are logged and skipped.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL