playlist

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 7 Imported by: 6

Documentation

Overview

Package playlist contains a M3U8 playlist decoder and encoder.

Index

Constants

This section is empty.

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-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-START
	Start *MediaStart

	// 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-RENDITION-REPORT
	RenditionReport []*MediaRenditionReport

	// 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 MediaKey added in v2.1.1

type MediaKey struct {
	// METHOD
	// required
	Method MediaKeyMethod

	// URI is required unless METHOD is NONE
	URI string

	// IV
	IV string

	// KEYFORMAT
	KeyFormat string

	// KEYFORMATVERSIONS
	KeyFormatVersions string
}

MediaKey is a EXT-X-KEY tag.

func (*MediaKey) Equal added in v2.1.1

func (t *MediaKey) Equal(key *MediaKey) bool

Equal checks if two MediaKey objects are equal.

type MediaKeyMethod added in v2.1.1

type MediaKeyMethod string

MediaKeyMethod is the encryption method used for the media segments.

const (
	MediaKeyMethodNone      MediaKeyMethod = "NONE"
	MediaKeyMethodAES128    MediaKeyMethod = "AES-128"
	MediaKeyMethodSampleAES MediaKeyMethod = "SAMPLE-AES"
)

standard encryption methods

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.

const (
	MediaPlaylistTypeEvent MediaPlaylistType = "EVENT"
	MediaPlaylistTypeVOD   MediaPlaylistType = "VOD"
)

standard values

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 MediaRenditionReport added in v2.2.3

type MediaRenditionReport struct {
	// URI (required)
	URI string

	// LAST-MSN (required)
	LastMSN int

	// LAST-PART
	LastPart *int
}

MediaRenditionReport is a EXT-X-RENDITION-REPORT tag.

type MediaSegment

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

	// URI.
	// required
	URI string

	// EXT-X-DISCONTINUITY
	Discontinuity bool

	// EXT-X-GAP
	Gap bool

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

	// EXT-X-BITRATE
	Bitrate *int

	// EXT-X-KEY
	Key *MediaKey

	// 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

	// NAME
	// required
	Name string

	// LANGUAGE
	Language string

	// AUTOSELECT
	Autoselect bool

	// DEFAULT
	Default bool

	// FORCED
	Forced bool

	// CHANNELS
	// for AUDIO only
	Channels *string

	// URI
	// must not be present for CLOSED-CAPTIONS
	URI *string

	// INSTREAM-ID
	// for CLOSED-CAPTIONS only
	InStreamID *string
}

MultivariantRendition is a EXT-X-MEDIA tag.

type MultivariantRenditionType

type MultivariantRenditionType string

MultivariantRenditionType is a rendition type.

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

standard rendition types.

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
	Marshal() ([]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