Documentation
¶
Index ¶
- Constants
- Variables
- func CheckTimeValidity(availTimeS, nowS, timeShiftBufferDepthS, availabilityTimeOffsetS float64) error
- func LiveMPD(a *asset, mpdName string, cfg *ResponseConfig, nowMS int) (*m.MPD, error)
- func NewIPRequestLimiter(hdrName string, maxNrRequests int, interval time.Duration) func(next http.Handler) http.Handler
- func NewPrometheusMiddleware() func(next http.Handler) http.Handler
- func Ptr[T any](v T) *T
- type AssetInfo
- type AssetsInfo
- type Config
- type IPRequestLimiter
- type MPDInfo
- type RepData
- type ResponseConfig
- type Segment
- type Server
- type ServerConfig
- type StppTimeCue
- type StppTimeData
- type UTCTimingMethod
- type WvttTimeCue
- type WvttTimeData
Constants ¶
const ( UtcTimingNtpServer = "1.de.pool.ntp.org" UtcTimingSntpServer = "time.kfki.hu" UtcTimingHttpServer = "http://time.akamai.com/?iso" UtcTimingHttpServerMS = "http://time.akamai.com/?isoms" UtcTimingHeadAsset = "/static/time.txt" )
const ( SUBS_STPP_PREFIX = "timestpp" SUBS_WVTT_PREFIX = "timewvtt" SUBS_TIME_INIT = "init.mp4" SUBS_TIME_TIMESCALE = 1000 )
const (
MAX_TIME_SHIFT_BUFFER_DEPTH_S = 48 * 3600
)
Variables ¶
var DefaultConfig = ServerConfig{ LogFormat: "consolepretty", LogLevel: "info", Port: 8888, LiveWindowS: 300, TimeoutS: 60, MaxRequests: 0, VodRoot: "./vod", RepDataRoot: "+", WriteRepData: false, }
var (
ErrAtoInfTimeline = errors.New("infinite availabilityTimeOffset for SegmentTimeline")
)
Functions ¶
func CheckTimeValidity ¶ added in v0.5.1
func CheckTimeValidity(availTimeS, nowS, timeShiftBufferDepthS, availabilityTimeOffsetS float64) error
CheckTimeValidity checks if availTimeS is a valid time given current time and parameters. Returns errors if too early, or too late. availabilityTimeOffset < 0 signals always available.
func NewIPRequestLimiter ¶
func NewIPRequestLimiter(hdrName string, maxNrRequests int, interval time.Duration) func(next http.Handler) http.Handler
NewIPRequestLimiter returns a middleware that limits the number of requests per IP address per interval
An HTTP response 429 Too Many Requests is generated if there are too many requests A header with the
func NewPrometheusMiddleware ¶
NewPrometheusMiddleware returns a new prometheus Middleware handler.
Types ¶
type AssetsInfo ¶ added in v0.7.0
type Config ¶
type Config struct { Konf *koanf.Koanf ServerCfg ServerConfig }
type IPRequestLimiter ¶
type IPRequestLimiter struct {
// contains filtered or unexported fields
}
IPRequestLimiter limits the number of requests per interval
type RepData ¶
type RepData struct { ID string `json:"id"` ContentType string `json:"contentType"` Codecs string `json:"codecs"` MpdTimescale int `json:"mpdTimescale"` MediaTimescale int `json:"mediaTimescale"` // Used in the segments InitURI string `json:"initURI"` MediaURI string `json:"mediaURI"` DefaultSampleDuration uint32 `json:"defaultSampleDuration"` Segments []Segment `json:"segments"` // contains filtered or unexported fields }
RepData provides information about a representation
func (RepData) SegmentType ¶
SegmentType returns MIME type for MP4 segment.
type ResponseConfig ¶
type ResponseConfig struct { URLParts []string `json:"-"` URLContentIdx int `json:"-"` BaseURLs []string `json:"BaseURLs,omitempty"` UTCTimingMethods []UTCTimingMethod `json:"UTCTimingMethods,omitempty"` PeriodDurations []int `json:"PeriodDurations,omitempty"` StartTimeS int `json:"StartTimeS"` StopTimeS *int `json:"StopTimeS,omitempty"` TimeOffsetS *float64 `json:"TimeOffsetS,omitempty"` InitSegAvailOffsetS *int `json:"InitSegAvailOffsetS,omitempty"` TimeShiftBufferDepthS *int `json:"TimeShiftBufferDepthS,omitempty"` MinimumUpdatePeriodS *int `json:"MinimumUpdatePeriodS,omitempty"` PeriodsPerHour *int `json:"PeriodsPerHour,omitempty"` XlinkPeriodsPerHour *int `json:"XlinkPeriodsPerHour,omitempty"` EtpPeriodsPerHour *int `json:"EtpPeriodsPerHour,omitempty"` EtpDuration *int `json:"EtpDuration,omitempty"` PeriodOffset *int `json:"PeriodOffset,omitempty"` SCTE35PerMinute *int `json:"SCTE35PerMinute,omitempty"` StartNr *int `json:"StartNr,omitempty"` SuggestedPresentationDelayS *int `json:"SuggestedPresentationDelayS,omitempty"` AvailabilityTimeOffsetS float64 `json:"AvailabilityTimeOffsetS,omitempty"` ChunkDurS *float64 `json:"ChunkDurS,omitempty"` LatencyTargetMS *int `json:"LatencyTargetMS,omitempty"` AddLocationFlag bool `json:"AddLocationFlag,omitempty"` Tfdt32Flag bool `json:"Tfdt32Flag,omitempty"` ContUpdateFlag bool `json:"ContUpdateFlag,omitempty"` InsertAdFlag bool `json:"InsertAdFlag,omitempty"` ContMultiPeriodFlag bool `json:"ContMultiPeriodFlag,omitempty"` SegTimelineFlag bool `json:"SegTimelineFlag,omitempty"` SegTimelineNrFlag bool `json:"SegTimelineNrFlag,omitempty"` SidxFlag bool `json:"SidxFlag,omitempty"` SegTimelineLossFlag bool `json:"SegTimelineLossFlag,omitempty"` AvailabilityTimeCompleteFlag bool `json:"AvailabilityTimeCompleteFlag,omitempty"` TimeSubsStpp []string `json:"TimeSubsStppLanguages,omitempty"` TimeSubsWvtt []string `json:"TimeSubsWvttLanguages,omitempty"` TimeSubsDurMS int `json:"TimeSubsDurMS,omitempty"` TimeSubsRegion int `json:"TimeSubsRegion,omitempty"` Host string `json:"Host,omitempty"` }
func NewResponseConfig ¶
func NewResponseConfig() *ResponseConfig
NewResponseConfig returns a new ResponseConfig with default values.
func (*ResponseConfig) SetHost ¶ added in v0.6.0
func (c *ResponseConfig) SetHost(cfgValue string, r *http.Request)
SetHost sets scheme://host to non-trivial cfgValue or tries to detect from request.
func (*ResponseConfig) URLContentPart ¶ added in v0.6.0
func (c *ResponseConfig) URLContentPart() string
type Server ¶
type Server struct { Router *chi.Mux LiveRouter *chi.Mux VodRouter *chi.Mux Cfg *ServerConfig // contains filtered or unexported fields }
func SetupServer ¶
func SetupServer(ctx context.Context, cfg *ServerConfig) (*Server, error)
SetupServer sets up router, middleware, and server, given koanf configuration.
type ServerConfig ¶
type ServerConfig struct { LogFormat string `json:"logformat"` LogLevel string `json:"loglevel"` Port int `json:"port"` LiveWindowS int `json:"livewindowS"` TimeoutS int `json:"timeoutS"` MaxRequests int `json:"maxrequests"` VodRoot string `json:"vodroot"` // RepDataRoot is the root directory for representation metadata RepDataRoot string `json:"repdataroot"` // WriteRepData is true if representation metadata should be written if not present WriteRepData bool `json:"writerepdata"` // Domains is a comma-separated list of domains for Let's Encrypt Domains string `json:"domains"` // CertPath is a path to a valid TLS certificate CertPath string `json:"certpath"` // KeyPath is a path to a valid private TLS key KeyPath string `json:"keypath"` // If Host is set, it will be used instead of autodetected value scheme://host. Host string `json:"host"` }
func LoadConfig ¶
func LoadConfig(args []string, cwd string) (*ServerConfig, error)
LoadConfig loads defaults, config file, command line, and finally applies environment variables
VodRoot is set to cwd/root by default.
type StppTimeCue ¶
StppTimeCue is cue information to put in template.
type StppTimeData ¶
type StppTimeData struct { Lang string Region int Cues []StppTimeCue }
StppTimeData is information for creating an stpp media segment.
type UTCTimingMethod ¶ added in v0.6.0
type UTCTimingMethod string
const ( UtcTimingDirect UTCTimingMethod = "direct" UtcTimingHead UTCTimingMethod = "head" UtcTimingNtp UTCTimingMethod = "ntp" UtcTimingSntp UTCTimingMethod = "sntp" UtcTimingHttpXSDate UTCTimingMethod = "httpxsdate" UtcTimingHttpISO UTCTimingMethod = "httpiso" UtcTimingNone UTCTimingMethod = "none" )
type WvttTimeCue ¶ added in v0.7.0
WvttTimeCue is cue information to put in template.
type WvttTimeData ¶ added in v0.7.0
type WvttTimeData struct { Lang string Region int Cues []WvttTimeCue }
WvttTimeData is information for creating a wvtt media segment.