core

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveTemplate

func ResolveTemplate(format string, params TemplateParams) string

Types

type Config

type Config struct {
	URL                         string
	DefaultInterval             time.Duration
	PrioritizeSuggestedInterval bool
	HTTPClient                  *http.Client
	RequestHeader               http.Header
	NoRedirectCache             bool
	ManifestTimeout             time.Duration
	ManifestBackoff             backoff.BackOff
	SegmentTimeout              time.Duration
	SegmentBackoff              backoff.BackOff
	SegmentMaxConcurrency       int
	SegmentFilter               SegmentFilter
	StreamType                  StreamType
	TerminateIfVOD              bool
	HLS                         *HLSConfig
	DASH                        *DASHConfig
	// OnDownload will be called when HTTP GET method succeeds.
	// This function must be thread-safe.
	OnDownload  OnDownloadHandler
	OnReport    OnReportHandler
	OnTerminate OnTerminateHandler
}

func NewConfig

func NewConfig(url string, streamType StreamType) *Config

type DASHConfig

type DASHConfig struct {
	Inspectors []DASHInspector
}

type DASHInspector

type DASHInspector interface {
	Inspect(manifest *Manifest, segments SegmentStore) *Report
}

type DASHSegment

type DASHSegment struct {
	URL             string
	Initialization  bool
	Time            uint64
	Duration        uint64
	Period          *mpd.Period
	AdaptationSet   *mpd.AdaptationSet
	SegmentTemplate *mpd.SegmentTemplate
	Representation  *mpd.Representation
}

type File

type File struct {
	Meta
	Body []byte
}

type FilterResult

type FilterResult int
const (
	Pass FilterResult = iota
	Reject
)

type HLSConfig

type HLSConfig struct {
	Inspectors []HLSInspector
}

type HLSInspector

type HLSInspector interface {
	Inspect(playlists *Playlists, segments SegmentStore) *Report
}

type HLSSegment

type HLSSegment struct {
	URL string
	// VariantParams is reference to related VariantParams object in MasterPlaylist.
	// This property is nullable.
	VariantParams *m3u8.VariantParams
	// Alternative is reference to related Alternative object in MasterPlaylist.
	// This property is nullable.
	Alternative *m3u8.Alternative
}

type Manifest

type Manifest struct {
	URL  string
	Raw  []byte
	Time time.Time
	*mpd.MPD
}

func (*Manifest) BaseURL

func (m *Manifest) BaseURL() (string, error)

func (*Manifest) EachSegments

func (m *Manifest) EachSegments(handle func(*DASHSegment) (cont bool)) error

func (*Manifest) Segments

func (m *Manifest) Segments() ([]*DASHSegment, error)

type MasterPlaylist

type MasterPlaylist struct {
	URL  string
	Raw  []byte
	Time time.Time
	*m3u8.MasterPlaylist
}

type MediaPlaylist

type MediaPlaylist struct {
	URL  string
	Raw  []byte
	Time time.Time
	*m3u8.MediaPlaylist
	VariantParams *m3u8.VariantParams
	Alternative   *m3u8.Alternative
}

func (*MediaPlaylist) SegmentURLs

func (p *MediaPlaylist) SegmentURLs() ([]string, error)

type Meta

type Meta struct {
	URL              string        `json:"url"`
	Via              string        `json:"via"`
	RequestHeader    http.Header   `json:"requestHeader"`
	ResponseHeader   http.Header   `json:"responseHeader"`
	Status           string        `json:"status"`     // e.g. "200 OK"
	StatusCode       int           `json:"statusCode"` // e.g. 200
	Proto            string        `json:"proto"`      // e.g. "HTTP/1.0"
	ProtoMajor       int           `json:"protoMajor"` // e.g. 1
	ProtoMinor       int           `json:"protoMinor"` // e.g. 0
	ContentLength    int64         `json:"contentLength"`
	TransferEncoding []string      `json:"transferEncoding"`
	Uncompressed     bool          `json:"uncompressed"`
	RequestTimestamp time.Time     `json:"requestTimestamp"`
	DownloadTime     time.Duration `json:"downloadTime"`
}

type Monitor

type Monitor interface {
	Terminate()
}

func NewMonitor

func NewMonitor(config *Config) Monitor

type OnDownloadHandler

type OnDownloadHandler func(file *File)

func MergeOnDownloadHandlers

func MergeOnDownloadHandlers(handlers ...OnDownloadHandler) OnDownloadHandler

type OnReportHandler

type OnReportHandler func(reports Reports)

func MergeOnReportHandlers

func MergeOnReportHandlers(handlers ...OnReportHandler) OnReportHandler

type OnTerminateHandler

type OnTerminateHandler func()

type Playlists

type Playlists struct {
	MasterPlaylist *MasterPlaylist
	MediaPlaylists map[string]*MediaPlaylist
}

func (*Playlists) IsVOD

func (p *Playlists) IsVOD() bool

func (*Playlists) MaxTargetDuration

func (p *Playlists) MaxTargetDuration() float64

func (*Playlists) Segments

func (p *Playlists) Segments() ([]*HLSSegment, error)

type Report

type Report struct {
	Name     string   `json:"name"`
	Severity Severity `json:"severity"`
	Message  string   `json:"message"`
	Values   Values   `json:"values"`
}

type Reports

type Reports []*Report

func (Reports) Errors

func (reports Reports) Errors() Reports

func (Reports) Infos

func (reports Reports) Infos() Reports

func (Reports) Warns

func (reports Reports) Warns() Reports

func (Reports) WorstSeverity

func (reports Reports) WorstSeverity() Severity

type SegmentFilter

type SegmentFilter interface {
	CheckHLS(segment *HLSSegment) FilterResult
	CheckDASH(segment *DASHSegment) FilterResult
}

func AllSegmentRejectionFilter

func AllSegmentRejectionFilter() SegmentFilter

func HashSamplingSegmentFilter

func HashSamplingSegmentFilter(rate float64) SegmentFilter

func MaxBandwidthSegmentFilter

func MaxBandwidthSegmentFilter(bandwidth int64) SegmentFilter

func MinBandwidthSegmentFilter

func MinBandwidthSegmentFilter(bandwidth int64) SegmentFilter

func SegmentFilterAnd

func SegmentFilterAnd(filters ...SegmentFilter) SegmentFilter

func SegmentFilterOr

func SegmentFilterOr(filters ...SegmentFilter) SegmentFilter

type SegmentStore

type SegmentStore interface {
	Exists(url string) bool
	Load(url string) ([]byte, bool)
}

type Severity

type Severity int
const (
	Info Severity = iota
	Warn
	Error
)

func BestSeverity

func BestSeverity(ss ...Severity) Severity

func WorstSeverity

func WorstSeverity(ss ...Severity) Severity

func (Severity) BetterThan

func (s Severity) BetterThan(o Severity) bool

func (Severity) BetterThanOrEqual

func (s Severity) BetterThanOrEqual(o Severity) bool

func (Severity) MarshalText

func (s Severity) MarshalText() ([]byte, error)

func (Severity) String

func (s Severity) String() string

func (*Severity) UnmarshalText

func (s *Severity) UnmarshalText(text []byte) error

func (Severity) WorseThan

func (s Severity) WorseThan(o Severity) bool

func (Severity) WorseThanOrEqual

func (s Severity) WorseThanOrEqual(o Severity) bool

type StreamType

type StreamType int
const (
	StreamTypeHLS StreamType = iota
	StreamTypeDASH
)

func (StreamType) String

func (t StreamType) String() string

type TemplateParams

type TemplateParams struct {
	RepresentationID string
	Number           int64
	Bandwidth        int64
	Time             uint64
}

type Values

type Values map[string]interface{}

func (Values) Keys

func (values Values) Keys() []string

func (Values) String

func (values Values) String() string

Jump to

Keyboard shortcuts

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