Documentation ¶
Index ¶
- Constants
- Variables
- func NewRWBuffer(capacity int) avpipe.SeekReadWriteCloser
- type HLSReader
- func NewHLSReader(playlistURL *url.URL, xcType avpipe.XcType) *HLSReader
- func NewHLSReaderA(a *m3u8.Alternative, masterPlaylistURL *url.URL) (lhr *HLSReader, err error)
- func NewHLSReaderV(v *m3u8.Variant, masterPlaylistURL *url.URL, xcType avpipe.XcType) (lhr *HLSReader, err error)
- func NewHLSReaders(playlistURL *url.URL, xcType avpipe.XcType) (readers []*HLSReader, err error)
- type LiveSource
- type RWBuffer
- func (rwb *RWBuffer) Close() error
- func (rwb *RWBuffer) CloseSide(state RWBufferCloseState) error
- func (rwb *RWBuffer) Len() int
- func (rwb *RWBuffer) Read(buf []byte) (n int, err error)
- func (rwb *RWBuffer) Seek(offset int64, whence int) (int64, error)
- func (rwb *RWBuffer) Size() int
- func (rwb *RWBuffer) Write(buf []byte) (n int, err error)
- type RWBufferCloseState
- type TsReader
Constants ¶
const RTMP_SOURCE = "rtmp://localhost:%d/rtmp/Doj1Nr3S"
Variables ¶
var TESTSaveToDir string
TESTSaveToDir save manifests and segments to this path if not empty string
Functions ¶
func NewRWBuffer ¶
func NewRWBuffer(capacity int) avpipe.SeekReadWriteCloser
* Creates a RWBuffer which is open for reading/writing. * The writer can write to the buffer until Close(RWBufferWriteClosed) is called. * The reader can read from the buffer until Close(RWBufferReadClosed) is called or * EOF is issued. * An EOF is issued for reader when the writer closed the buffer and there is no data * in the buffer.
Types ¶
type HLSReader ¶
type HLSReader struct { Pipe io.ReadWriteCloser // Type avpipe.XcType // // contains filtered or unexported fields }
HLSReader provides a reader interface to an HLS playlist that serves a live MPEG-TS stream. Close the Pipe to clean up.
An HLS playlist may have zero or more audio and video streams. We choose the highest bitrate stream of each type to record. If the master playlist advertises a muxed stream with both audio and video, choose the muxed stream with the highest bitrate.
func NewHLSReader ¶
NewHLSReader creates and returns a media playlist reader, and starts goroutines to download the segments. Close the Reader to clean up.
func NewHLSReaderA ¶
func NewHLSReaderV ¶
func NewHLSReaders ¶
Determines readers based on the desired stream type and the playlistURL, which can be either a master playlist or media playlist.
Read master playlists only once (section 6.3.4 of the spec only says to reload *media* playlists. Also, some servers will return a new session token with each HTTP request for the master, but the same token must be used to maintain playback state.
TODO Probably should change approach to selecting a variant first, then finding the audio/video streams. Also test against different playlists.
type LiveSource ¶
type LiveSource struct { Port int `json:"port,omitempty"` Pid int `json:"pid,omitempty"` // contains filtered or unexported fields }
func NewLiveSource ¶
func NewLiveSource() *LiveSource
func (*LiveSource) Start ¶
func (l *LiveSource) Start(stream string) (err error)
func (*LiveSource) Stop ¶
func (l *LiveSource) Stop() (err error)
type RWBuffer ¶
type RWBuffer struct {
// contains filtered or unexported fields
}
func (*RWBuffer) CloseSide ¶
func (rwb *RWBuffer) CloseSide(state RWBufferCloseState) error
func (*RWBuffer) Read ¶
* Reads one packet at a time into buf. * It is possible avpipe asks for data even less than a packet size, which can cause a partial read. * RWBuffer can keep track of a partial read and will return the rest of the packet in next Read() call.
type RWBufferCloseState ¶
type RWBufferCloseState int
const ( RWBufferOpen RWBufferCloseState = iota RWBufferReadClosed RWBufferWriteClosed RWBufferClosed )
type TsReader ¶
type TsReader struct { ErrChannel chan error // contains filtered or unexported fields }
func NewTsReaderV2
deprecated
func NewTsReaderV2(addr string) (*TsReader, io.ReadWriteCloser, error)
Deprecated: Reading UDP datagrams are done inside avpipe library and no need to create TsReader anymore (this makes handling different situations like stopping and cancelling a stream extremely difficult). NewTsReaderV2 creates a UDP MPEG-TS reader and returns a TsReader and an io.Reader Starts the necessary goroutines - when the returned reader is closed, it stops all goroutines and cleans up.