Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileReader ¶
type FileReader struct {
// contains filtered or unexported fields
}
FileReader is a pull source for local media files. It implements TSChunkReader and is intended to wrap with NewTSDemuxPacketReader.
func NewFileReader ¶
func NewFileReader(path string, loop bool) *FileReader
NewFileReader constructs a FileReader without opening the file. path must be a resolved absolute filesystem path. The caller (typically internal/ingestor.NewPacketReader) is responsible for resolving any file:// URL through the VOD registry first.
func (*FileReader) Close ¶
func (r *FileReader) Close() error
Close releases the open file handle. Calling Close before Open, or calling it twice, is safe.
type HLSReader ¶
type HLSReader struct {
// contains filtered or unexported fields
}
HLSReader polls an HLS playlist and emits MPEG-TS segment bytes in order. It implements TSChunkReader and is intended to wrap with NewTSDemuxPacketReader.
Expected URL format: http[s]://host/path/to/playlist.m3u8 Master playlists are transparently resolved to the highest-bandwidth variant.
Open/Close may be called multiple times (runPullWorker reconnects on error). Each Open() creates a fresh output channel so that the previous poll goroutine's deferred close does not affect the new one.
func NewHLSReader ¶
func NewHLSReader(input domain.Input, cfg config.IngestorConfig) *HLSReader
NewHLSReader constructs an HLSReader without opening the connection.
func (*HLSReader) Close ¶
Close stops the poll goroutine. Safe to call before Open or more than once.
type RTMPReader ¶
type RTMPReader struct {
// contains filtered or unexported fields
}
RTMPReader connects to a remote RTMP server in play (pull) mode and emits domain.AVPacket.
Life cycle: NewRTMPReader → Open (blocks on TCP+RTMP handshake) → ReadPackets loop → Close. The underlying read goroutine exits when the server closes the connection or Close is called; both paths close pkts so ReadPackets returns io.EOF.
func NewRTMPReader ¶
func NewRTMPReader(input domain.Input) *RTMPReader
NewRTMPReader constructs an RTMPReader without opening a connection.
func (*RTMPReader) Close ¶
func (r *RTMPReader) Close() error
Close closes the RTMP connection; the readLoop then closes the packet channels.
func (*RTMPReader) Open ¶
func (r *RTMPReader) Open(ctx context.Context) error
Open dials the RTMP source, negotiates codec data, and starts the background read loop. Blocks until the TCP connection + RTMP handshake + codec probing complete.
func (*RTMPReader) ReadPackets ¶
ReadPackets blocks until at least one AVPacket is available or the source ends.
type RTSPReader ¶
type RTSPReader struct {
// contains filtered or unexported fields
}
RTSPReader connects to a remote RTSP server in play (pull) mode and emits domain.AVPacket. It uses gortsplib for proper RTCP-based A/V synchronisation and RTP jitter buffering.
func NewRTSPReader ¶
func NewRTSPReader(input domain.Input) *RTSPReader
NewRTSPReader constructs an RTSPReader without opening a connection.
func (*RTSPReader) Close ¶
func (r *RTSPReader) Close() error
Close closes the RTSP connection and waits for the read loop to stop.
func (*RTSPReader) Open ¶
func (r *RTSPReader) Open(ctx context.Context) error
Open dials the RTSP source, negotiates tracks, and starts the background read loop. It blocks until DESCRIBE + SETUP + PLAY complete.
func (*RTSPReader) ReadPackets ¶
ReadPackets blocks until at least one AVPacket is available or the source ends.
type SRTReader ¶
type SRTReader struct {
// contains filtered or unexported fields
}
SRTReader dials an SRT server in caller mode and emits raw MPEG-TS chunks. It implements TSChunkReader and is intended to wrap with NewTSDemuxPacketReader.
func NewSRTReader ¶
NewSRTReader constructs an SRTReader without opening a connection.
func (*SRTReader) Close ¶
Close stops the context watcher and closes the SRT socket. Safe to call before Open or more than once.
type TSChunkReader ¶
type TSChunkReader interface {
Open(ctx context.Context) error
Read(ctx context.Context) ([]byte, error)
Close() error
}
TSChunkReader is an MPEG-TS byte source (UDP, HLS, file, SRT, …).
type TSDemuxOption ¶
type TSDemuxOption func(*TSDemuxPacketReader)
TSDemuxOption configures a TSDemuxPacketReader at construction time.
func WithRealtimePacing ¶
func WithRealtimePacing() TSDemuxOption
WithRealtimePacing enables DTS-based real-time throttling on AVPacket emission. Use it for chunk-based sources (HLS) that deliver bursts faster than playback rate; do not use it for live transports (UDP, SRT, RTMP) where the source already paces itself.
type TSDemuxPacketReader ¶
type TSDemuxPacketReader struct {
// contains filtered or unexported fields
}
TSDemuxPacketReader wraps a TSChunkReader and emits domain.AVPacket values.
func NewTSDemuxPacketReader ¶
func NewTSDemuxPacketReader(r TSChunkReader, opts ...TSDemuxOption) *TSDemuxPacketReader
NewTSDemuxPacketReader wraps r and emits domain.AVPacket values.
func (*TSDemuxPacketReader) Close ¶
func (d *TSDemuxPacketReader) Close() error
Close tears down both goroutines and the underlying reader. It is safe to call Close concurrently or multiple times.
func (*TSDemuxPacketReader) Open ¶
func (d *TSDemuxPacketReader) Open(ctx context.Context) error
Open starts the pump and demux goroutines.
func (*TSDemuxPacketReader) ReadPackets ¶
ReadPackets blocks until at least one AVPacket is available, then drains as many as are ready (up to 256 at once) to amortise call overhead. Returns (nil, io.EOF) when the source is exhausted.
type UDPReader ¶
type UDPReader struct {
// contains filtered or unexported fields
}
UDPReader listens on a UDP port and emits raw MPEG-TS chunks. It implements TSChunkReader and is intended to be wrapped with NewTSDemuxPacketReader.
func NewUDPReader ¶
NewUDPReader constructs a UDPReader for the given input without opening a connection.
func (*UDPReader) Close ¶
Close stops the pump goroutine, closes the UDP socket, and waits for clean shutdown. Safe to call before Open or multiple times.
func (*UDPReader) LocalAddr ¶
LocalAddr returns the local address the socket is bound to. Returns nil if the socket has not been opened yet.
func (*UDPReader) Open ¶
Open binds the UDP socket, optionally joins a multicast group, and starts the background pump goroutine.
Each Open() call creates a fresh socket so the reader can be reused after Close() by the ingestor reconnection loop.
func (*UDPReader) Read ¶
Read returns the next validated MPEG-TS datagram (with any RTP header stripped).
When the pump goroutine exits due to a real network error, Read returns that error (not io.EOF) so the upstream pumpChunks goroutine can store it in TSDemuxPacketReader.readErr and the worker will reconnect instead of triggering permanent failover.
Returns (nil, io.EOF) only when Close() is called cleanly without a pump error. Returns (nil, ctx.Err()) when the caller's context is cancelled.