Documentation ¶
Index ¶
- Constants
- Variables
- func FormatTime(time time.Time) string
- func ParseAttributes(text string) map[string]string
- func ParseTime(value string) (time.Time, error)
- func Write(pl *Playlist) (string, error)
- type ByteRange
- type DateRangeItem
- type DiscontinuityItem
- type Encryptable
- type Item
- type KeyItem
- type MapItem
- type MediaItem
- type PlaybackStart
- type Playlist
- func (pl *Playlist) AppendItem(item Item)
- func (pl *Playlist) Duration() float64
- func (pl *Playlist) IsLive() bool
- func (pl *Playlist) IsMaster() bool
- func (pl *Playlist) IsValid() bool
- func (pl *Playlist) ItemSize() int
- func (pl *Playlist) PlaylistSize() int
- func (pl *Playlist) SegmentSize() int
- func (pl *Playlist) String() string
- type PlaylistItem
- type Resolution
- type SegmentItem
- type SessionDataItem
- type SessionKeyItem
- type TimeItem
Constants ¶
const ( // Item tags SessionKeyItemTag = `#EXT-X-SESSION-KEY` KeyItemTag = `#EXT-X-KEY` DiscontinuityItemTag = `#EXT-X-DISCONTINUITY` TimeItemTag = `#EXT-X-PROGRAM-DATE-TIME` DateRangeItemTag = `#EXT-X-DATERANGE` MapItemTag = `#EXT-X-MAP` SessionDataItemTag = `#EXT-X-SESSION-DATA` SegmentItemTag = `#EXTINF` ByteRangeItemTag = `#EXT-X-BYTERANGE` PlaybackStartTag = `#EXT-X-START` MediaItemTag = `#EXT-X-MEDIA` PlaylistItemTag = `#EXT-X-STREAM-INF` PlaylistIframeTag = `#EXT-X-I-FRAME-STREAM-INF` // Playlist tags HeaderTag = `#EXTM3U` TargetDurationTag = `#EXT-X-TARGETDURATION` CacheTag = `#EXT-X-ALLOW-CACHE` DiscontinuitySequenceTag = `#EXT-X-DISCONTINUITY-SEQUENCE` IndependentSegmentsTag = `#EXT-X-INDEPENDENT-SEGMENTS` PlaylistTypeTag = `#EXT-X-PLAYLIST-TYPE` IFramesOnlyTag = `#EXT-X-I-FRAMES-ONLY` MediaSequenceTag = `#EXT-X-MEDIA-SEQUENCE` VersionTag = `#EXT-X-VERSION` // ByteRange tags ByteRangeTag = "BYTERANGE" // Encryptable tags MethodTag = "METHOD" URITag = "URI" IVTag = "IV" KeyFormatTag = "KEYFORMAT" KeyFormatVersionsTag = "KEYFORMATVERSIONS" // DateRangeItem tags IDTag = "ID" ClassTag = "CLASS" StartDateTag = "START-DATE" EndDateTag = "END-DATE" DurationTag = "DURATION" PlannedDurationTag = "PLANNED-DURATION" Scte35CmdTag = "SCTE35-CMD" Scte35OutTag = "SCTE35-OUT" Scte35InTag = "SCTE35-IN" EndOnNextTag = "END-ON-NEXT" // PlaybackStart tags TimeOffsetTag = "TIME-OFFSET" PreciseTag = "PRECISE" // SessionDataItem tags DataIDTag = "DATA-ID" ValueTag = "VALUE" LanguageTag = "LANGUAGE" // MediaItem tags TypeTag = "TYPE" GroupIDTag = "GROUP-ID" AssocLanguageTag = "ASSOC-LANGUAGE" NameTag = "NAME" AutoSelectTag = "AUTOSELECT" DefaultTag = "DEFAULT" ForcedTag = "FORCED" InStreamIDTag = "INSTREAM-ID" CharacteristicsTag = "CHARACTERISTICS" ChannelsTag = "CHANNELS" /// PlaylistItem tags ResolutionTag = "RESOLUTION" ProgramIDTag = "PROGRAM-ID" CodecsTag = "CODECS" BandwidthTag = "BANDWIDTH" AverageBandwidthTag = "AVERAGE-BANDWIDTH" FrameRateTag = "FRAME-RATE" VideoTag = "VIDEO" AudioTag = "AUDIO" SubtitlesTag = "SUBTITLES" ClosedCaptionsTag = "CLOSED-CAPTIONS" HDCPLevelTag = "HDCP-LEVEL" // Values NoneValue = "NONE" YesValue = "YES" NoValue = "NO" )
Variables ¶
var ( AudioCodecMap = map[string]string{ "aac-lc": "mp4a.40.2", "he-aac": "mp4a.40.5", "mp3": "mp4a.40.34", } BaselineCodecMap = map[string]string{ "3.0": "avc1.66.30", "3.1": "avc1.42001f", } MainCodecMap = map[string]string{ "3.0": "avc1.77.30", "3.1": "avc1.4d001f", "4.0": "avc1.4d0028", "4.1": "avc1.4d0029", } HighCodecMap = map[string]string{ "3.0": "avc1.64001e", "3.1": "avc1.64001f", "3.2": "avc1.640020", "4.0": "avc1.640028", "4.1": "avc1.640029", "4.2": "avc1.64002a", "5.0": "avc1.640032", "5.1": "avc1.640033", "5.2": "avc1.640034", } )
var ( ErrPlaylistInvalid = errors.New("invalid playlist, must start with #EXTM3U") ErrPlaylistInvalidType = errors.New("invalid playlist, mixed master and media") ErrResolutionInvalid = errors.New("invalid resolution") ErrBandwidthMissing = errors.New("missing bandwidth") ErrBandwidthInvalid = errors.New("invalid bandwidth") ErrSegmentItemInvalid = errors.New("invalid segment item") ErrPlaylistItemInvalid = errors.New("invalid playlist item") )
Functions ¶
func FormatTime ¶
func ParseAttributes ¶
Types ¶
type DateRangeItem ¶
type DateRangeItem struct { ID string Class *string StartDate string EndDate *string Duration *float64 PlannedDuration *float64 Scte35Cmd *string Scte35Out *string Scte35In *string EndOnNext bool ClientAttributes map[string]string }
DateRangeItem represents a #EXT-X-DATERANGE tag
func NewDateRangeItem ¶
func NewDateRangeItem(text string) (*DateRangeItem, error)
func (*DateRangeItem) String ¶
func (dri *DateRangeItem) String() string
type DiscontinuityItem ¶
type DiscontinuityItem struct{}
DiscontinuityItem represents a EXT-X-DISCONTINUITY tag to indicate a discontinuity between the SegmentItems that proceed and follow it.
func NewDiscontinuityItem ¶
func NewDiscontinuityItem() (*DiscontinuityItem, error)
func (*DiscontinuityItem) String ¶
func (di *DiscontinuityItem) String() string
type Encryptable ¶
type Encryptable struct { Method string URI *string IV *string KeyFormat *string KeyFormatVersions *string }
func NewEncryptable ¶
func NewEncryptable(attributes map[string]string) *Encryptable
func (*Encryptable) String ¶
func (e *Encryptable) String() string
type KeyItem ¶
type KeyItem struct {
Encryptable *Encryptable
}
KeyItem represents a set of EXT-X-KEY attributes
func NewKeyItem ¶
type MapItem ¶
MapItem represents a EXT-X-MAP tag which specifies how to obtain the Media Initialization Section
func NewMapItem ¶
type MediaItem ¶
type MediaItem struct { Type string GroupID string Name string Language *string AssocLanguage *string AutoSelect *bool Default *bool Forced *bool URI *string InStreamID *string Characteristics *string Channels *string }
MediaItem represents a set of EXT-X-MEDIA attributes
func NewMediaItem ¶
type PlaybackStart ¶
PlaybackStart represents a #EXT-X-START tag and attributes
func NewPlaybackStart ¶
func NewPlaybackStart(text string) (*PlaybackStart, error)
func (*PlaybackStart) String ¶
func (ps *PlaybackStart) String() string
type Playlist ¶
type Playlist struct { Items []Item Version *int Cache *bool Target int Sequence int DiscontinuitySequence *int Type *string IFramesOnly bool IndependentSegments bool Live bool Master *bool }
Playlist represents an m3u8 playlist, it can be a master playlist or a set of media segments
func NewPlaylist ¶
func NewPlaylist() *Playlist
func NewPlaylistWithItems ¶
func ReadString ¶
func (*Playlist) AppendItem ¶
func (*Playlist) PlaylistSize ¶
func (*Playlist) SegmentSize ¶
type PlaylistItem ¶
type PlaylistItem struct { Bandwidth int URI string IFrame bool Name *string Width *int Height *int AverageBandwidth *int ProgramID *string Codecs *string AudioCodec *string Profile *string Level *string Video *string Audio *string Subtitles *string ClosedCaptions *string FrameRate *float64 HDCPLevel *string Resolution *Resolution }
PlaylistItem represents a set of EXT-X-STREAM-INF or EXT-X-I-FRAME-STREAM-INF attributes
func NewPlaylistItem ¶
func NewPlaylistItem(text string) (*PlaylistItem, error)
func (*PlaylistItem) CodecsString ¶
func (pi *PlaylistItem) CodecsString() string
func (*PlaylistItem) String ¶
func (pi *PlaylistItem) String() string
type Resolution ¶
func NewResolution ¶
func NewResolution(text string) (*Resolution, error)
func (*Resolution) String ¶
func (r *Resolution) String() string
type SegmentItem ¶
type SegmentItem struct { Duration float64 Segment string Comment *string ProgramDateTime *TimeItem ByteRange *ByteRange }
SegmentItem represents EXTINF attributes with the URI that follows, optionally allowing an EXT-X-BYTERANGE tag to be set.
func NewSegmentItem ¶
func NewSegmentItem(text string) (*SegmentItem, error)
func (*SegmentItem) String ¶
func (si *SegmentItem) String() string
type SessionDataItem ¶
SessionDataItem represents a set of EXT-X-SESSION-DATA attributes
func NewSessionDataItem ¶
func NewSessionDataItem(text string) (*SessionDataItem, error)
func (*SessionDataItem) String ¶
func (sdi *SessionDataItem) String() string
type SessionKeyItem ¶
type SessionKeyItem struct {
Encryptable *Encryptable
}
SessionKeyItem represents a set of EXT-X-SESSION-KEY attributes
func NewSessionKeyItem ¶
func NewSessionKeyItem(text string) (*SessionKeyItem, error)
func (*SessionKeyItem) String ¶
func (ski *SessionKeyItem) String() string