Documentation
¶
Overview ¶
Package gohlslib is a HLS client and muxer library for the Go programming language.
Examples are available at https://github.com/bluenviron/gohlslib/tree/main/examples
Index ¶
- Variables
- type Client
- func (c *Client) AbsoluteTime(track *Track) (time.Time, bool)
- func (c *Client) Close()
- func (c *Client) OnDataAV1(track *Track, cb ClientOnDataAV1Func)
- func (c *Client) OnDataH26x(track *Track, cb ClientOnDataH26xFunc)
- func (c *Client) OnDataMPEG4Audio(track *Track, cb ClientOnDataMPEG4AudioFunc)
- func (c *Client) OnDataOpus(track *Track, cb ClientOnDataOpusFunc)
- func (c *Client) OnDataVP9(track *Track, cb ClientOnDataVP9Func)
- func (c *Client) Start() error
- func (c *Client) Wait() chan error
- type ClientOnDataAV1Func
- type ClientOnDataH26xFunc
- type ClientOnDataMPEG4AudioFunc
- type ClientOnDataOpusFunc
- type ClientOnDataVP9Func
- type ClientOnDecodeErrorFunc
- type ClientOnDownloadPartFunc
- type ClientOnDownloadPrimaryPlaylistFunc
- type ClientOnDownloadSegmentFunc
- type ClientOnDownloadStreamPlaylistFunc
- type ClientOnRequestFunc
- type ClientOnTracksFunc
- type Muxer
- func (m *Muxer) Close()
- func (m *Muxer) Handle(w http.ResponseWriter, r *http.Request)
- func (m *Muxer) Start() error
- func (m *Muxer) WriteAV1(track *Track, ntp time.Time, pts int64, tu [][]byte) error
- func (m *Muxer) WriteH264(track *Track, ntp time.Time, pts int64, au [][]byte) error
- func (m *Muxer) WriteH265(track *Track, ntp time.Time, pts int64, au [][]byte) error
- func (m *Muxer) WriteMPEG4Audio(track *Track, ntp time.Time, pts int64, aus [][]byte) error
- func (m *Muxer) WriteOpus(track *Track, ntp time.Time, pts int64, packets [][]byte) error
- func (m *Muxer) WriteVP9(track *Track, ntp time.Time, pts int64, frame []byte) error
- type MuxerOnEncodeErrorFunc
- type MuxerVariant
- type Track
Constants ¶
This section is empty.
Variables ¶
var ErrClientEOS = errors.New("end of stream")
ErrClientEOS is returned by Wait() when the stream has ended.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
//
// parameters (all optional except URI)
//
// URI of the playlist.
URI string
// HTTP client.
// It defaults to http.DefaultClient.
HTTPClient *http.Client
//
// callbacks (all optional)
//
// called when sending a request to the server.
OnRequest ClientOnRequestFunc
// called when tracks are available.
OnTracks ClientOnTracksFunc
// called before downloading a primary playlist.
OnDownloadPrimaryPlaylist ClientOnDownloadPrimaryPlaylistFunc
// called before downloading a stream playlist.
OnDownloadStreamPlaylist ClientOnDownloadStreamPlaylistFunc
// called before downloading a segment.
OnDownloadSegment ClientOnDownloadSegmentFunc
// called before downloading a part.
OnDownloadPart ClientOnDownloadPartFunc
// called when a non-fatal decode error occurs.
OnDecodeError ClientOnDecodeErrorFunc
// contains filtered or unexported fields
}
Client is a HLS client.
func (*Client) AbsoluteTime ¶
AbsoluteTime returns the absolute timestamp of the last sample.
func (*Client) OnDataAV1 ¶
func (c *Client) OnDataAV1(track *Track, cb ClientOnDataAV1Func)
OnDataAV1 sets a callback that is called when data from an AV1 track is received.
func (*Client) OnDataH26x ¶
func (c *Client) OnDataH26x(track *Track, cb ClientOnDataH26xFunc)
OnDataH26x sets a callback that is called when data from an H26x track is received.
func (*Client) OnDataMPEG4Audio ¶
func (c *Client) OnDataMPEG4Audio(track *Track, cb ClientOnDataMPEG4AudioFunc)
OnDataMPEG4Audio sets a callback that is called when data from a MPEG-4 Audio track is received.
func (*Client) OnDataOpus ¶
func (c *Client) OnDataOpus(track *Track, cb ClientOnDataOpusFunc)
OnDataOpus sets a callback that is called when data from an Opus track is received.
func (*Client) OnDataVP9 ¶
func (c *Client) OnDataVP9(track *Track, cb ClientOnDataVP9Func)
OnDataVP9 sets a callback that is called when data from a VP9 track is received.
type ClientOnDataAV1Func ¶
ClientOnDataAV1Func is the prototype of the function passed to OnDataAV1().
type ClientOnDataH26xFunc ¶
ClientOnDataH26xFunc is the prototype of the function passed to OnDataH26x().
type ClientOnDataMPEG4AudioFunc ¶
ClientOnDataMPEG4AudioFunc is the prototype of the function passed to OnDataMPEG4Audio().
type ClientOnDataOpusFunc ¶
ClientOnDataOpusFunc is the prototype of the function passed to OnDataOpus().
type ClientOnDataVP9Func ¶
ClientOnDataVP9Func is the prototype of the function passed to OnDataVP9().
type ClientOnDecodeErrorFunc ¶
type ClientOnDecodeErrorFunc func(err error)
ClientOnDecodeErrorFunc is the prototype of Client.OnDecodeError.
type ClientOnDownloadPartFunc ¶
type ClientOnDownloadPartFunc func(url string)
ClientOnDownloadPartFunc is the prototype of Client.OnDownloadPart.
type ClientOnDownloadPrimaryPlaylistFunc ¶
type ClientOnDownloadPrimaryPlaylistFunc func(url string)
ClientOnDownloadPrimaryPlaylistFunc is the prototype of Client.OnDownloadPrimaryPlaylist.
type ClientOnDownloadSegmentFunc ¶
type ClientOnDownloadSegmentFunc func(url string)
ClientOnDownloadSegmentFunc is the prototype of Client.OnDownloadSegment.
type ClientOnDownloadStreamPlaylistFunc ¶
type ClientOnDownloadStreamPlaylistFunc func(url string)
ClientOnDownloadStreamPlaylistFunc is the prototype of Client.OnDownloadStreamPlaylist.
type ClientOnRequestFunc ¶
ClientOnRequestFunc is the prototype of the function passed to OnRequest().
type ClientOnTracksFunc ¶
ClientOnTracksFunc is the prototype of the function passed to OnTracks().
type Muxer ¶
type Muxer struct {
Tracks []*Track
Variant MuxerVariant
SegmentCount int
SegmentMinDuration time.Duration
PartMinDuration time.Duration
SegmentMaxSize uint64
Directory string
OnEncodeError MuxerOnEncodeErrorFunc
// contains filtered or unexported fields
}
func (*Muxer) Handle ¶
func (m *Muxer) Handle(w http.ResponseWriter, r *http.Request)
Handle handles a HTTP request.
func (*Muxer) WriteMPEG4Audio ¶
WriteMPEG4Audio writes MPEG-4 Audio access units.
type MuxerOnEncodeErrorFunc ¶
type MuxerOnEncodeErrorFunc func(err error)
type MuxerVariant ¶
type MuxerVariant int
MuxerVariant is a muxer variant.
const ( MuxerVariantMPEGTS MuxerVariant = iota + 1 MuxerVariantFMP4 MuxerVariantLowLatency )
supported variants.
type Track ¶
type Track struct {
// Codec
Codec codecs.Codec
// Clock rate
ClockRate int
// Name
// For audio renditions only.
Name string
// Language
// For audio renditions only.
Language string
// whether this is the default track.
// For audio renditions only.
IsDefault bool
}
Track is a HLS track.
Source Files
¶
- client.go
- client_primary_downloader.go
- client_routine_pool.go
- client_segment_queue.go
- client_stream_downloader.go
- client_stream_processor_fmp4.go
- client_stream_processor_mpegts.go
- client_time_conv.go
- client_time_conv_fmp4.go
- client_time_conv_mpegts.go
- client_track.go
- client_track_processor_fmp4.go
- client_track_processor_mpegts.go
- muxer.go
- muxer_part.go
- muxer_segment.go
- muxer_segment_fmp4.go
- muxer_segment_mpegts.go
- muxer_segmenter.go
- muxer_server.go
- muxer_stream.go
- muxer_track.go
- muxer_variant.go
- track.go
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
client
command
|
|
|
client-absolute-timestamp
command
|
|
|
client-codec-h264-save-to-disk
command
|
|
|
muxer
command
|
|
|
playlist-parser
command
|
|
|
pkg
|
|
|
codecparams
Package codecparams contains utilities to deal with codec parameters.
|
Package codecparams contains utilities to deal with codec parameters. |
|
codecs
Package codecs contains codec definitions.
|
Package codecs contains codec definitions. |
|
playlist
Package playlist contains a M3U8 playlist decoder and encoder.
|
Package playlist contains a M3U8 playlist decoder and encoder. |
|
playlist/primitives
Package primitives contains playlist primitives.
|
Package primitives contains playlist primitives. |
|
storage
Package storage contains the storage mechanism of segments and parts.
|
Package storage contains the storage mechanism of segments and parts. |