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 NewCmafIngesterMgr(s *Server) *cmafIngesterMgr
- func NewLimiterMiddleware(hdrName string, reqLimiter *IPRequestLimiter) func(next http.Handler) http.Handler
- func NewPrometheusMiddleware() func(next http.Handler) http.Handler
- func Ptr[T any](v T) *T
- type CCPKey
- type CmafIngestCreateResponse
- type CmafIngestDeleteResponse
- type CmafIngestInfoResponse
- type CmafIngestStepResponse
- type CmafIngesterCreateRequest
- type CmafIngesterSetup
- type Config
- type IPRequestLimiter
- type LaURLRequest
- type LaURLResponse
- type LossItvl
- type LossItvls
- type RepData
- type ResponseConfig
- type SegStatusCodes
- type Segment
- type Server
- type ServerConfig
- type StppTimeCue
- type StppTimeData
- type UTCTimingMethod
- type WvttTimeCue
- type WvttTimeData
Constants ¶
const ( UtcTimingDirectScheme = "urn:mpeg:dash:utc:direct:2014" UtcTimingHttpHeadScheme = "urn:mpeg:dash:utc:http-head:2014" UtcTimingHttpISOScheme = "urn:mpeg:dash:utc:http-iso:2014" UtcTimingHttpXSDateScheme = "urn:mpeg:dash:utc:http-xsdate:2014" UtcTimingNtpDateScheme = "urn:mpeg:dash:utc:ntp:2014" UtcTimingSntpDateScheme = "urn:mpeg:dash:utc:sntp:2014" )
const ( UtcTimingNtpServer = "1.de.pool.ntp.org" UtcTimingSntpServer = "time.kfki.hu" // UtcTimingHttpXSDateServer format is xs:date, which is essentially ISO 8601 UtcTimingXSDateHttpServer = "https://time.akamai.com/?iso" UtcTimingXSDateHttpServerMS = "https://time.akamai.com/?iso&ms" //UtcTimingHttpISOHttpServer format is ISO 8601 UtcTimingISOHttpServer = "https://time.akamai.com/?iso" UtcTimingISOHttpServerMS = "https://time.akamai.com/?iso&ms" UtcTimingHeadAsset = "/static/time.txt" )
const ( Number segmentTimelineType = "nr" TimelineTime segmentTimelineType = "tlt" TimelineNumber segmentTimelineType = "tlnr" )
const ( SUBS_STPP_PREFIX = "timestpp" SUBS_WVTT_PREFIX = "timewvtt" SUBS_TIME_INIT = "init.mp4" SUBS_TIME_TIMESCALE = 1000 )
const CMAFIngestVersion = "1.1"
const (
MAX_TIME_SHIFT_BUFFER_DEPTH_S = 48 * 3600
)
Variables ¶
var DefaultConfig = ServerConfig{ LogFormat: "text", LogLevel: "INFO", Port: 8888, LiveWindowS: 300, TimeoutS: 60, MaxRequests: 0, ReqLimitInt: defaultReqIntervalS, VodRoot: "./vod", RepDataRoot: "+", WriteRepData: false, PlayURL: defaultPlayURL, WhiteListBlocks: "", }
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 NewCmafIngesterMgr ¶ added in v1.5.0
func NewCmafIngesterMgr(s *Server) *cmafIngesterMgr
func NewLimiterMiddleware ¶ added in v0.8.0
func NewLimiterMiddleware(hdrName string, reqLimiter *IPRequestLimiter) func(next http.Handler) http.Handler
NewLimiterMiddleware 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 An HTTP header named hdrName is return the number of requests and the maximum number of requests per interval
func NewPrometheusMiddleware ¶
NewPrometheusMiddleware returns a new prometheus Middleware handler.
Types ¶
type CmafIngestCreateResponse ¶ added in v1.5.0
type CmafIngestCreateResponse struct { Body struct { DestRoot string `json:"destRoot" doc:"Destination root URL for the CMAF ingest"` DestName string `json:"destName" doc:"Destination name for the CMAF ingest"` URL string `json:"livesim-url" doc:"livesim2 URL including /livesim2/ prefix"` ID string `json:"id" doc:"Unique ID for the CMAF ingest"` } }
type CmafIngestDeleteResponse ¶ added in v1.5.0
type CmafIngestDeleteResponse struct { Body struct { DestRoot string `json:"destRoot" doc:"Destination root URL for the CMAF ingest"` DestName string `json:"destName" doc:"Destination name for the CMAF ingest"` URL string `json:"livesim-url" doc:"livesim2 URL including /livesim2/ prefix"` ID string `json:"id" doc:"Unique ID for the CMAF ingest"` } }
type CmafIngestInfoResponse ¶ added in v1.5.0
type CmafIngestInfoResponse struct { Body struct { DestRoot string `json:"destRoot" doc:"Destination root URL for the CMAF ingest"` DestName string `json:"destName" doc:"Destination name for the CMAF ingest"` URL string `json:"livesim-url" doc:"livesim2 URL including /livesim2/ prefix"` ID string `json:"id" doc:"Unique ID for the CMAF ingest"` Report string `json:"report" doc:"Report for the CMAF ingest"` } }
type CmafIngestStepResponse ¶ added in v1.5.0
type CmafIngesterCreateRequest ¶ added in v1.5.0
type CmafIngesterCreateRequest struct {
Body CmafIngesterSetup `json:"body"`
}
type CmafIngesterSetup ¶ added in v1.5.0
type CmafIngesterSetup struct { User string `json:"user,omitempty" doc:"User name for basic auth" example:""` PassWord string `json:"password,omitempty" doc:"Password for basic auth" example:""` DestRoot string `json:"destRoot" doc:"Destination URL root for assets" example:"https://server.com/upload"` DestName string `json:"destName" doc:"Destination name for asset" example:"testpic_ingest"` URL string `json:"livesimURL" doc:"Full livesimURL without scheme and host" example:"/livesim2/segtimeline_1/testpic_2s/Manifest.mpd"` TestNowMS *int `json:"testNowMS,omitempty" doc:"Test: start time for step-wise sending"` Duration *int `json:"duration,omitempty" doc:"Duration in seconds for the CMAF ingest session" example:"60"` StreamsURLs bool `` /* 128-byte string literal not displayed */ }
CmafIngesterRequest represents the CMAF ingest start request.
type Config ¶
type Config struct { Konf *koanf.Koanf ServerCfg ServerConfig }
type IPRequestLimiter ¶
type IPRequestLimiter struct { MaxNrRequests int `json:"maxNrRequests"` Interval time.Duration `json:"interval"` ResetTime time.Time `json:"resetTime"` Counters map[string]int `json:"counters"` WhiteListBlocks string `json:"whiteListBlocks"` // contains filtered or unexported fields }
IPRequestLimiter limits the number of requests per interval
func NewIPRequestLimiter ¶
func NewIPRequestLimiter(maxNrRequests int, interval time.Duration, start time.Time, whiteListBlocks string, logFile string) (*IPRequestLimiter, error)
NewIPRequestLimiter returns a new IPRequestLimiter with maxNrRequests per interval starting now. If logFile is not empty, the IPRequestLimiter is dumped to the logFile at the end of each interval.
func (*IPRequestLimiter) Count ¶ added in v0.8.0
func (il *IPRequestLimiter) Count(ip string) int
Count returns the counter value for an IP address
func (*IPRequestLimiter) EndTime ¶ added in v0.8.0
func (il *IPRequestLimiter) EndTime() time.Time
EndTime returns next reset time.
type LaURLRequest ¶ added in v1.2.0
type LaURLRequest struct { // KIDs is a slice of base64-encoded key IDs KIDs []string `json:"kids"` Type string `json:"type"` }
LAURLRequest is the JSON request body for DASH-IF laURL request
type LaURLResponse ¶ added in v1.2.0
type LossItvls ¶ added in v1.0.0
type LossItvls struct {
Itvls []LossItvl
}
LossItvls is loss intervals for one BaseURL
func CreateAllLossItvls ¶ added in v1.0.0
CreateAllLossItvls creates loss intervals for multiple BaseURLs
func CreateLossItvls ¶ added in v1.0.0
CreateLossItvls creates a LossItvls from a pattern like u20d10 (20s up, 10 down)
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"` Segments []Segment `json:"segments"` DefaultSampleDuration uint32 `json:"defaultSampleDuration"` // Read from trex or tfhd ConstantSampleDuration *uint32 `json:"constantSampleDuration,omitempty"` // Non-zero if all samples have the same duration PreEncrypted bool `json:"preEncrypted"` // 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:"-"` 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"` PatchTTL int `json:"Patch,omitempty"` // DashIFECCP is DASH-IF Enhanced Clear Key Content Protection DashIFECCP string `json:"ECCP,omitempty"` SegStatusCodes []SegStatusCodes `json:"SegStatus,omitempty"` Traffic []LossItvls `json:"Traffic,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 SegStatusCodes ¶ added in v1.0.0
type SegStatusCodes struct { // Cycle is cycle length in seconds Cycle int // Rsq is relative sequence number (in cycle) Rsq int // Code is the HTTP response code Code int // Reps is a list of applicable representations (empty means all) Reps []string }
SegStatusCodes configures regular extraordinary segment response codes
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"` ReqLimitLog string `json:"reqlimitlog"` ReqLimitInt int `json:"reqlimitint"` // in seconds Port int `json:"port"` LiveWindowS int `json:"livewindowS"` TimeoutS int `json:"timeoutS"` MaxRequests int `json:"maxrequests"` // WhiteListBlocks is a comma-separated list of CIDR blocks that are not rate limited WhiteListBlocks string `json:"whitelistblocks"` 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 (will override existing metadata) 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:"-"` // KeyPath is a path to a valid private TLS key KeyPath string `json:"-"` // If Host is set, it will be used instead of autodetected value scheme://host. Host string `json:"host"` // PlayURL is a URL template to play asset including player and pattern %s to be replaced by MPD URL // For autoplay, start the player muted. PlayURL string `json:"playurl"` }
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" UtcTimingHttpHead UTCTimingMethod = "head" UtcTimingNtp UTCTimingMethod = "ntp" UtcTimingSntp UTCTimingMethod = "sntp" UtcTimingHttpXSDate UTCTimingMethod = "httpxsdate" UtcTimingHttpXSDateMs UTCTimingMethod = "httpxsdatems" UtcTimingHttpISO UTCTimingMethod = "httpiso" UtcTimingHttpISOMs UTCTimingMethod = "httpisoms" UtcTimingNone UTCTimingMethod = "none" UtcTimingKeep UTCTimingMethod = "keep" )
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.
Source Files
¶
- api.go
- asset.go
- audiosegmentation.go
- cmaf-ingester.go
- config.go
- configurl.go
- content.go
- errors.go
- handler_assets.go
- handler_config.go
- handler_index.go
- handler_laurl.go
- handler_livesim.go
- handler_patch.go
- handler_reqcount.go
- handler_urlgen.go
- handler_vod.go
- ipreqlimit.go
- keys.go
- livempd.go
- livesegment.go
- middleware.go
- prometheus.go
- routes.go
- server.go
- start.go
- strconv.go
- templates.go
- timesubs.go
- timesubs_wvtt.go