hls

package
v1.8.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package hls provides functions to download HLS streams.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrHLSForbidden is returned when the HLS download is stopped with a forbidden error.
	ErrHLSForbidden = errors.New("hls download stopped with forbidden error")
)

Functions

This section is empty.

Types

type Checkpoint added in v1.7.0

type Checkpoint struct {
	LastFragmentName    string
	LastFragmentTime    time.Time
	UseTimeBasedSorting bool
}

Checkpoint is used to resume the download from the last fragment.

func DefaultCheckpoint added in v1.7.0

func DefaultCheckpoint() Checkpoint

DefaultCheckpoint returns a default checkpoint.

type Downloader

type Downloader struct {
	*http.Client
	// contains filtered or unexported fields
}

Downloader is used to download HLS streams.

func NewDownloader

func NewDownloader(
	client *http.Client,
	log *zerolog.Logger,
	packetLossMax int,
	url string,
) *Downloader

NewDownloader creates a new HLS downloader.

func (*Downloader) GetFragmentURLs

func (hls *Downloader) GetFragmentURLs(ctx context.Context) ([]string, error)

GetFragmentURLs fetches the fragment URLs from the HLS manifest.

func (*Downloader) Probe added in v1.7.0

func (hls *Downloader) Probe(ctx context.Context) (bool, error)

Probe checks if the stream is ready to be downloaded.

func (*Downloader) Read

func (hls *Downloader) Read(
	ctx context.Context,
	out chan<- []byte,
	checkpoint Checkpoint,
) (newCheckpoint Checkpoint, err error)

Read reads the HLS stream and sends the data to the output channel.

The function will return when the context is canceled or when the stream ends.

Jump to

Keyboard shortcuts

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