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, dts time.Duration) (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 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(ntp time.Time, pts time.Duration, tu [][]byte) error
- func (m *Muxer) WriteH26x(ntp time.Time, pts time.Duration, au [][]byte) error
- func (m *Muxer) WriteMPEG4Audio(ntp time.Time, pts time.Duration, aus [][]byte) error
- func (m *Muxer) WriteOpus(ntp time.Time, pts time.Duration, packets [][]byte) error
- func (m *Muxer) WriteVP9(ntp time.Time, pts time.Duration, frame []byte) error
- 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 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 a packet with given track and DTS.
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 ClientOnTracksFunc ¶
ClientOnTracksFunc is the prototype of the function passed to OnTracks().
type Muxer ¶
type Muxer struct { // // parameters (all optional except VideoTrack or AudioTrack). // // video track. VideoTrack *Track // audio track. AudioTrack *Track // Variant to use. // It defaults to MuxerVariantLowLatency Variant MuxerVariant // Number of HLS segments to keep on the server. // Segments allow to seek through the stream. // Their number doesn't influence latency. // It defaults to 7. SegmentCount int // Minimum duration of each segment. // This is adjusted in order to include at least one IDR frame in each segment. // A player usually puts 3 segments in a buffer before reproducing the stream. // It defaults to 1sec. SegmentMinDuration time.Duration // Minimum duration of each part. // Parts are used in Low-Latency HLS in place of segments. // This is adjusted in order to produce segments with a similar duration. // A player usually puts 3 parts in a buffer before reproducing the stream. // It defaults to 200ms. PartMinDuration time.Duration // Minimum required part count to be able to determine first segment duration in Low-Latency variant // It defaults to 5 parts DurationRequiredPartCount uint64 // Maximum size of each segment. // This prevents RAM exhaustion. // It defaults to 50MB. SegmentMaxSize uint64 // Directory in which to save segments. // This decreases performance, since saving segments on disk is less performant // than saving them on RAM, but allows to preserve RAM. Directory string // Deprecated: replaced with SegmentMinDuration SegmentDuration time.Duration // Deprecated: replaced with PartMinDUratino PartDuration time.Duration // contains filtered or unexported fields }
Muxer is a HLS muxer.
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 MuxerVariant ¶
type MuxerVariant int
MuxerVariant is a muxer variant.
const ( MuxerVariantMPEGTS MuxerVariant = iota + 1 MuxerVariantFMP4 MuxerVariantLowLatency )
supported variants.
Source Files ¶
- client.go
- client_primary_downloader.go
- client_routine_pool.go
- client_segment_queue.go
- client_stream_downloader.go
- client_stream_processor.go
- client_stream_processor_fmp4.go
- client_stream_processor_mpegts.go
- client_timesync.go
- client_timesync_fmp4.go
- client_timesync_mpegts.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_segmenter_fmp4.go
- muxer_segmenter_mpegts.go
- muxer_server.go
- track.go
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
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. |