hls

package module
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExtendedPacket

type ExtendedPacket struct {
	av.Packet
	// ProgramTime indicates the wall-clock time of a keyframe packet
	ProgramTime time.Time
}

ExtendedPacket holds a packet with additional metadata for the HLS playlist

type Mode

type Mode int

Mode defines the operating mode of the publisher

const (
	// ModeSingleTrack uses a single HLS playlist and track. DASH is not available. This is the default.
	ModeSingleTrack Mode = iota
	// ModeSeparateTracks puts audio and video in separate tracks for both HLS
	// and DASH. HLS uses a master playlist and may not be compatible with some
	// devices.
	ModeSeparateTracks
	// ModeSingleAndSeparate uses a single track for HLS and separate tracks for
	// DASH. This requires twice as much memory. The HLS track will use a
	// simpler format compatible with certain mobile devices.
	ModeSingleAndSeparate
)

type Publisher

type Publisher struct {
	// Mode defines the operating mode of the publisher
	Mode Mode
	// InitialDuration is a guess for the TARGETDURATION field in the playlist,
	// used until the first segment is complete. Defaults to 5s.
	InitialDuration time.Duration
	// BufferLength is the approximate duration spanned by all the segments in the playlist. Old segments are removed until the playlist length is less than this value.
	BufferLength time.Duration
	// FragmentLength is the size of MP4 fragments to break each segment into. Defaults to 500ms.
	FragmentLength time.Duration
	// WorkDir is a temporary storage location for segments. Can be empty, in which case the default system temp dir is used.
	WorkDir string
	// Prefetch reveals upcoming segments before they begin so the client can initiate the download early
	Prefetch bool

	KeepSegments int // pointer to allow 0, number of segments to keep in the playlist. Defaults to 3.

	// Precreate is deprecated and no longer used
	Precreate int

	Closed bool
	// contains filtered or unexported fields
}

Publisher implements a live HLS stream server

func (*Publisher) Close

func (p *Publisher) Close()

Close frees resources associated with the publisher

func (*Publisher) Discontinuity

func (p *Publisher) Discontinuity()

Discontinuity inserts a marker into the playlist before the next segment indicating that the decoder should be reset

func (*Publisher) MPD

func (p *Publisher) MPD() string

MPD returns the filename of the DASH MPD or "" if it is unavailable

func (*Publisher) Playlist

func (p *Publisher) Playlist() string

Playlist returns the filename of the HLS main playlist

func (*Publisher) ServeHTTP

func (p *Publisher) ServeHTTP(rw http.ResponseWriter, req *http.Request)

serve the HLS playlist and segments

func (*Publisher) WriteExtendedPacket

func (p *Publisher) WriteExtendedPacket(pkt ExtendedPacket) error

WriteExtendedPacket publishes a packet with additional metadata

func (*Publisher) WriteHeader

func (p *Publisher) WriteHeader(streams []av.CodecData) error

WriteHeader initializes the streams' codec data and must be called before the first WritePacket

func (*Publisher) WritePacket

func (p *Publisher) WritePacket(pkt av.Packet) error

WritePacket publishes a single packet

func (*Publisher) WriteTrailer

func (p *Publisher) WriteTrailer() error

WriteTrailer does nothing, but fulfills av.Muxer

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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