playlist

package
v0.0.0-...-2bed79d Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package playlist contains a M3U8 playlist decoder and encoder.

Index

Constants

View Source
const (
	MediaPlaylistTypeEvent = "EVENT"
	MediaPlaylistTypeVOD   = "VOD"
)

standard values

View Source
const (
	MultivariantRenditionTypeAudio          = "AUDIO"
	MultivariantRenditionTypeVideo          = "VIDEO"
	MultivariantRenditionTypeSubtitles      = "SUBTITLES"
	MultivariantRenditionTypeClosedCaptions = "CLOSED-CAPTIONS"
)

standard rendition types.

Variables

This section is empty.

Functions

This section is empty.

Types

type Media

type Media struct {
	// #EXT-X-VERSION
	// required
	Version int

	// #EXT-X-INDEPENDENT-SEGMENTS
	IndependentSegments bool

	// #EXT-X-START
	Start *MediaStart

	// #EXT-X-ALLOWCACHE
	// removed since v7
	AllowCache *bool

	// #EXT-X-TARGETDURATION
	// required
	TargetDuration int

	// #EXT-X-SERVER-CONTROL
	ServerControl *MediaServerControl

	// #EXT-X-PART-INF
	PartInf *MediaPartInf

	// #EXT-X-MEDIA-SEQUENCE
	// required
	MediaSequence int

	// #EXT-X-DISCONTINUITY-SEQUENCE
	DiscontinuitySequence *int

	// #EXT-X-PLAYLIST-TYPE
	PlaylistType *MediaPlaylistType

	// #EXT-X-MAP
	Map *MediaMap

	// #EXT-X-SKIP
	Skip *MediaSkip

	// segments
	// at least one is required
	Segments []*MediaSegment

	// #EXT-X-PART
	Parts []*MediaPart

	// #EXT-X-PRELOAD-HINT
	PreloadHint *MediaPreloadHint

	// #EXT-X-ENDLIST
	Endlist bool
}

Media is a media playlist.

func (Media) Marshal

func (m Media) Marshal() ([]byte, error)

Marshal encodes the playlist.

func (*Media) Unmarshal

func (m *Media) Unmarshal(buf []byte) error

Unmarshal decodes the playlist.

type MediaMap

type MediaMap struct {
	// URI
	// required
	URI string

	// BYTERANGE
	ByteRangeLength *uint64
	ByteRangeStart  *uint64
}

MediaMap is a EXT-X-MAP tag.

type MediaPart

type MediaPart struct {
	// DURATION
	// required
	Duration time.Duration

	// URI
	// required
	URI string

	// INDEPENDENT
	Independent bool

	// BYTERANGE
	ByteRangeLength *uint64
	ByteRangeStart  *uint64

	// GAP
	Gap bool
}

MediaPart is a EXT-X-PART tag.

type MediaPartInf

type MediaPartInf struct {
	// PART-TARGET
	// required
	PartTarget time.Duration
}

MediaPartInf is a EXT-X-PART-INF tag.

type MediaPlaylistType

type MediaPlaylistType string

MediaPlaylistType is a EXT-X-PLAYLIST-TYPE value.

type MediaPreloadHint

type MediaPreloadHint struct {
	// URI
	// required
	URI string

	// BYTERANGE-START
	ByteRangeStart uint64

	// BYTERANGE-LENGTH
	ByteRangeLength *uint64
}

MediaPreloadHint sia EXT-X-PRELOAD-HINT tag.

type MediaSegment

type MediaSegment struct {
	// #EXTINF
	// required
	Duration time.Duration
	Title    string

	// segment URI.
	// required
	URI string

	// #EXT-X-PROGRAM-DATE-TIME
	DateTime *time.Time // optional

	// #EXT-X-GAP
	Gap bool // optional

	// #EXT-X-BITRATE
	Bitrate *int

	// #EXT-X-BYTERANGE
	ByteRangeLength *uint64
	ByteRangeStart  *uint64

	// #EXT-X-PART
	Parts []*MediaPart
}

MediaSegment is a segment of a media playlist.

type MediaServerControl

type MediaServerControl struct {
	// CAN-BLOCK-RELOAD
	CanBlockReload bool

	// PART-HOLD-BACK
	// The value is a decimal-floating-point number of seconds that
	// indicates the server-recommended minimum distance from the end of
	// the Playlist at which clients should begin to play or to which
	// they should seek when playing in Low-Latency Mode.  Its value MUST
	// be at least twice the Part Target Duration.  Its value SHOULD be
	// at least three times the Part Target Duration.
	PartHoldBack *time.Duration

	// CAN-SKIP-UNTIL
	// Indicates that the Server can produce Playlist Delta Updates in
	// response to the _HLS_skip Delivery Directive.  Its value is the
	// Skip Boundary, a decimal-floating-point number of seconds.  The
	// Skip Boundary MUST be at least six times the Target Duration.
	CanSkipUntil *time.Duration
}

MediaServerControl is a EXT-X-SERVER-CONTROL tag.

type MediaSkip

type MediaSkip struct {
	// SKIPPED-SEGMENTS
	// required
	SkippedSegments int
}

MediaSkip is a EXT-X-SKIP tag.

type MediaStart

type MediaStart = MultivariantStart

MediaStart is a EXT-X-START tag.

type Multivariant

type Multivariant struct {
	// #EXT-X-VERSION
	// required
	Version int

	// #EXT-X-INDEPENDENT-SEGMENTS
	IndependentSegments bool

	// #EXT-X-START
	Start *MultivariantStart

	// #EXT-X-STREAM-INF
	// at least one is required
	Variants []*MultivariantVariant

	// #EXT-X-MEDIA
	Renditions []*MultivariantRendition
}

Multivariant is a multivariant playlist.

func (Multivariant) Marshal

func (m Multivariant) Marshal() ([]byte, error)

Marshal encodes the playlist.

func (*Multivariant) Unmarshal

func (m *Multivariant) Unmarshal(buf []byte) error

Unmarshal decodes the playlist.

type MultivariantRendition

type MultivariantRendition struct {
	// TYPE
	// required
	Type MultivariantRenditionType

	// GROUP-ID
	// required
	GroupID string

	// URI
	// required for all types except CLOSED-CAPTIONS
	URI string

	// INSTREAM-ID
	// required for CLOSED-CAPTIONS
	InstreamID string

	// NAME
	// required
	Name string

	// LANGUAGE
	Language string

	// DEFAULT
	Default bool

	// AUTOSELECT
	Autoselect bool

	// FORCED
	Forced *bool

	// CHANNELS
	Channels string
}

MultivariantRendition is a EXT-X-MEDIA tag.

type MultivariantRenditionType

type MultivariantRenditionType string

MultivariantRenditionType is a rendition type.

type MultivariantStart

type MultivariantStart struct {
	// TIME-OFFSET
	// required
	TimeOffset time.Duration
}

MultivariantStart is a EXT-X-START tag.

type MultivariantVariant

type MultivariantVariant struct {
	// BANDWIDTH
	// required
	Bandwidth int

	// CODECS
	// required
	Codecs []string

	// URL
	// required
	URI string

	// AVERAGE-BANDWIDTH
	AverageBandwidth *int

	// RESOLUTION
	Resolution string

	// FRAME-RATE
	FrameRate *float64

	// VIDEO
	Video string

	// AUDIO
	Audio string

	// SUBTITLES
	Subtitles string

	// CLOSED-CAPTIONS
	ClosedCaptions string
}

MultivariantVariant is a EXT-X-STREAM-INF tag.

type Playlist

type Playlist interface {
	Unmarshal([]byte) error
	// contains filtered or unexported methods
}

Playlist is either Media or Multivariant.

func Unmarshal

func Unmarshal(byts []byte) (Playlist, error)

Unmarshal decodes a playlist.

Directories

Path Synopsis
Package primitives contains playlist primitives.
Package primitives contains playlist primitives.

Jump to

Keyboard shortcuts

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