Documentation ¶
Overview ¶
Package hls implement an HLS codec for Master and Media files in m3u format At this time, the codec only supports decoding
Index ¶
Constants ¶
const ( Vod = "VOD" // immutable Event = "EVENT" // append-only Live = "" // sliding-window )
Media playlist types
Variables ¶
Functions ¶
Types ¶
type File ¶
type File struct { Discontinuous bool `hls:"EXT-X-DISCONTINUITY,omitempty"` Time time.Time `hls:"EXT-X-PROGRAM-DATE-TIME,omitempty"` Range Range `hls:"EXT-X-BYTERANGE,omitempty"` Map Map `hls:"EXT-X-MAP,omitempty"` Key Key `hls:"EXT-X-KEY,omitempty"` Inf Inf `hls:"EXTINF"` }
func (File) Duration ¶ added in v0.0.4
Duration returns the segment duration. An optional target can be provided as a fallback in case the duration was not set.
func (File) Init ¶ added in v0.1.1
Init returns the initialization segment for fragmented mp4 files as an absolute url relative to base. If there is no initialization segment it returns an empty URL.
type Master ¶
type Master struct { M3U bool `hls:"EXTM3U"` Version int `hls:"EXT-X-VERSION"` Independent bool `hls:"EXT-X-INDEPENDENT-SEGMENTS"` Media []MediaInfo `hls:"EXT-X-MEDIA"` Stream []StreamInfo `hls:"EXT-X-STREAM-INF"` }
Master is a master playlist. It contains a list of streams (variants) and media information associated by group id. By convention, the master playlist is immutable.
type Media ¶
type Media struct { MediaHeader File []File `hls:""` }
Media is a media playlist. It consists of a header and one or more files. A file is EXTINF and the content of any additional tags that apply to that EXTINF tag.
func (*Media) Decode ¶ added in v0.1.0
Decode decodes the playlist in r and stores the result in m. It returns ErrEmpty if the playlist is well-formed, but contains no variant streams.
type MediaHeader ¶
type MediaHeader struct { M3U bool `hls:"EXTM3U"` Version int `hls:"EXT-X-VERSION"` Independent bool `hls:"EXT-X-INDEPENDENT-SEGMENTS"` Type string `hls:"EXT-X-PLAYLIST-TYPE"` Target time.Duration `hls:"EXT-X-TARGETDURATION"` Start Start `hls:"EXT-X-START"` Sequence int `hls:"EXT-X-MEDIA-SEQUENCE"` Discontinuity int `hls:"EXT-X-DISCONTINUITY-SEQUENCE"` End bool `hls:"EXT-X-ENDLIST"` }
type StreamInfo ¶
type StreamInfo struct { URL string `hls:"$file"` Index int `hls:"PROGRAM-ID"` Framerate float64 `hls:"FRAME-RATE"` Bandwidth int `hls:"BANDWIDTH"` BandwidthAvg int `hls:"AVERAGE-BANDWIDTH"` Codecs []string `hls:"CODECS"` Resolution image.Point `hls:"RESOLUTION"` VideoRange string `hls:"VIDEO-RANGE"` HDCP string `hls:"HDCP-LEVEL"` Audio string `hls:"AUDIO"` Video string `hls:"VIDEO"` Subtitle string `hls:"SUBTITLES"` Caption string `hls:"CLOSED-CAPTIONS"` }
func (StreamInfo) Location ¶
func (s StreamInfo) Location(base *url.URL) *url.URL
Location returns the stream URL relative to base. It conditionally applies the base URL in cases where the stream URL is a relative path. Base may be nil. This function never returns nil, but may return an empty URL. For error handling, process s.URLmanually.