hls

package
v0.0.0-...-051c27d Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SegmentTypeMPEGTS identifies segment contents as MPEG-2 Transport Stream
	SegmentTypeMPEGTS = iota
	// SegmentTypeFMP4 identifies segment contents as Fragmented MPEG-4
	SegmentTypeFMP4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Playlist

type Playlist struct {
	Version  int       // Protocol version.  We need at least 4 for EXT-X-BYTERANGE.
	FileName string    // Stream source: either MPEG-TS or FMP4.
	URI      string    // URI at which media file is served.
	Segments []Segment // Acts as a ring of segments with wrap over.
	SegSize  float64   // Desired segment size.
	First    int       // First segment in the ring.
	Last     int       // Last segment in the ring.
}

Playlist encapsulates HLS playlist.

The underlying media source is created by other code. It is just a file for the playlist. A configurable number of segments is organized into a ring and constitutes a series of byte ranges in the file.

func NewPlaylist

func NewPlaylist(uri string, name string, nseg int, size float64) (*Playlist, error)

NewPlaylist verifies that file exists and accessible for reading then instantiates Playlist.

func (*Playlist) AddSegment

func (pl *Playlist) AddSegment(duration float64, length int64)

AddSegment advances to next position in the ring and populates segment structure. Position is calculates from previous segment or is 0 at the start.

func (Playlist) String

func (pl Playlist) String() string

String renders current state of Playlist as M3U8.

type Segment

type Segment struct {
	Duration float64
	Position int64
	Length   int64
}

Segment describes a chunk of streaming media.

Jump to

Keyboard shortcuts

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