Documentation
¶
Index ¶
- type DASHManager
- func (d *DASHManager) GenerateMPD() string
- func (d *DASHManager) GetAudioInitSegment() ([]byte, bool)
- func (d *DASHManager) GetAudioSegment(seqNum int) ([]byte, bool)
- func (d *DASHManager) GetInitSegment() ([]byte, bool)
- func (d *DASHManager) GetSegment(seqNum int) ([]byte, bool)
- func (d *DASHManager) InitFromStream(stream *core.Stream)
- func (d *DASHManager) Run(stream *core.Stream)
- func (d *DASHManager) SegmentCount() int
- func (d *DASHManager) SegmentRange() (lo, hi int)
- func (d *DASHManager) Stop()
- type DASHSegment
- type HLSManager
- type HLSSegment
- type LLHLSManager
- func (m *LLHLSManager) GeneratePlaylist(ctx context.Context, targetMSN, targetPart int, skip bool) (string, error)
- func (m *LLHLSManager) GetFullSegment(msn int) ([]byte, bool)
- func (m *LLHLSManager) GetInitSegment() ([]byte, bool)
- func (m *LLHLSManager) GetInitSegmentVersion(version string) ([]byte, bool)
- func (m *LLHLSManager) GetPartialSegment(msn, partIdx int) ([]byte, bool)
- func (m *LLHLSManager) Run(stream *core.Stream)
- func (m *LLHLSManager) SegmentCount() int
- func (m *LLHLSManager) Stop()
- func (m *LLHLSManager) WaitForCompletedSegment(ctx context.Context, maxWait time.Duration) bool
- type LLHLSPart
- type LLHLSPlaylist
- type LLHLSSegment
- type LLHLSSegmenter
- type LLHLSSegmenterCallbacks
- type Module
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DASHManager ¶
type DASHManager struct {
// contains filtered or unexported fields
}
DASHManager accumulates separate video-only and audio-only fMP4 segments from a stream and serves an MPD manifest with two AdaptationSets.
func NewDASHManager ¶
func NewDASHManager(streamKey, basePath string, targetDur float64, maxSegments int) *DASHManager
NewDASHManager creates a new DASH manager for a stream.
func (*DASHManager) GenerateMPD ¶
func (d *DASHManager) GenerateMPD() string
GenerateMPD generates a DASH MPD manifest for the current segment state.
func (*DASHManager) GetAudioInitSegment ¶
func (d *DASHManager) GetAudioInitSegment() ([]byte, bool)
GetAudioInitSegment returns the audio init segment (ftyp+moov).
func (*DASHManager) GetAudioSegment ¶
func (d *DASHManager) GetAudioSegment(seqNum int) ([]byte, bool)
GetAudioSegment returns the audio media segment by sequence number.
func (*DASHManager) GetInitSegment ¶
func (d *DASHManager) GetInitSegment() ([]byte, bool)
GetInitSegment returns the video init segment (ftyp+moov).
func (*DASHManager) GetSegment ¶
func (d *DASHManager) GetSegment(seqNum int) ([]byte, bool)
GetSegment returns the video media segment by sequence number.
func (*DASHManager) InitFromStream ¶
func (d *DASHManager) InitFromStream(stream *core.Stream)
InitFromStream computes the fMP4 init segments from the stream's current startup snapshot. Run uses the same operation after waiting for startup, so a caller cannot publish an init segment built from an incomplete track.
func (*DASHManager) Run ¶
func (d *DASHManager) Run(stream *core.Stream)
Run starts the segment accumulation loop. It reads frames from the stream's RingBuffer, groups them keyframe-to-keyframe, and produces separate video and audio fMP4 segments.
func (*DASHManager) SegmentCount ¶
func (d *DASHManager) SegmentCount() int
SegmentCount returns the number of timeline segments currently available.
func (*DASHManager) SegmentRange ¶
func (d *DASHManager) SegmentRange() (lo, hi int)
SegmentRange returns the SeqNum range [lo, hi] of timeline segments in memory.
type DASHSegment ¶
type DASHSegment struct {
SeqNum int // sequential segment number (0-based)
Duration float64 // seconds
Data []byte
}
DASHSegment holds a single fMP4 media segment (moof+mdat).
type HLSManager ¶
type HLSManager struct {
// contains filtered or unexported fields
}
HLSManager accumulates TS segments from a stream and serves m3u8 playlists.
func NewHLSManager ¶
func NewHLSManager(streamKey, basePath string, targetDur float64, maxSegments int) *HLSManager
NewHLSManager creates a new HLS manager for a stream.
func (*HLSManager) GenerateM3U8 ¶
func (h *HLSManager) GenerateM3U8() string
GenerateM3U8 returns the current live m3u8 playlist.
func (*HLSManager) GetSegment ¶
func (h *HLSManager) GetSegment(seqNum int) ([]byte, bool)
GetSegment returns the segment data for a given sequence number.
func (*HLSManager) Run ¶
func (h *HLSManager) Run(stream *core.Stream)
Run starts the segment accumulation loop. It reads frames from the stream's RingBuffer, muxes them into TS segments split on video keyframes, and maintains a sliding window of recent segments.
func (*HLSManager) SegmentCount ¶
func (h *HLSManager) SegmentCount() int
SegmentCount returns the number of segments currently available.
type HLSSegment ¶
type HLSSegment struct {
SeqNum int
Duration float64 // seconds
Data []byte // complete TS segment bytes
Discontinuity bool
}
HLSSegment holds a single TS segment with metadata.
type LLHLSManager ¶
type LLHLSManager struct {
// contains filtered or unexported fields
}
LLHLSManager orchestrates LL-HLS segment production and playlist serving.
func NewLLHLSManager ¶
func NewLLHLSManager(streamKey, basePath string, partDuration, segmentDuration float64, segmentCount int, container string) *LLHLSManager
NewLLHLSManager creates a new LL-HLS manager.
func (*LLHLSManager) GeneratePlaylist ¶
func (m *LLHLSManager) GeneratePlaylist(ctx context.Context, targetMSN, targetPart int, skip bool) (string, error)
GeneratePlaylist returns the m3u8 playlist. If targetMSN >= 0, blocks until the requested MSN/part is available (blocking playlist reload).
func (*LLHLSManager) GetFullSegment ¶
func (m *LLHLSManager) GetFullSegment(msn int) ([]byte, bool)
GetFullSegment returns a full segment by MSN (concatenated partial data).
func (*LLHLSManager) GetInitSegment ¶
func (m *LLHLSManager) GetInitSegment() ([]byte, bool)
GetInitSegment returns the fMP4 init segment.
func (*LLHLSManager) GetInitSegmentVersion ¶
func (m *LLHLSManager) GetInitSegmentVersion(version string) ([]byte, bool)
GetInitSegmentVersion returns immutable fMP4 initialization bytes for a retained content-derived version. An empty version selects the current init.
func (*LLHLSManager) GetPartialSegment ¶
func (m *LLHLSManager) GetPartialSegment(msn, partIdx int) ([]byte, bool)
GetPartialSegment returns a partial segment by MSN and part index.
func (*LLHLSManager) Run ¶
func (m *LLHLSManager) Run(stream *core.Stream)
Run starts the segmenter loop. Blocks until stream ends or Stop() is called.
func (*LLHLSManager) SegmentCount ¶
func (m *LLHLSManager) SegmentCount() int
SegmentCount returns the number of completed segments.
func (*LLHLSManager) WaitForCompletedSegment ¶
WaitForCompletedSegment blocks until the playlist contains one complete segment. The bundled Hls.js treats a part-only initial manifest as an empty level, even though it consumes low-latency parts after startup.
type LLHLSPart ¶
type LLHLSPart struct {
Index int // part index within parent segment
Duration float64 // actual duration in seconds
Independent bool // starts with keyframe (IDR)
Data []byte // muxed bytes
Discontinuity bool
// contains filtered or unexported fields
}
LLHLSPart represents a partial segment.
type LLHLSPlaylist ¶
type LLHLSPlaylist struct {
// contains filtered or unexported fields
}
LLHLSPlaylist generates m3u8 playlists with LL-HLS tags.
func NewLLHLSPlaylist ¶
func NewLLHLSPlaylist(partTarget, segmentTarget float64, basePath, container string) *LLHLSPlaylist
NewLLHLSPlaylist creates a new playlist generator.
func (*LLHLSPlaylist) Generate ¶
func (p *LLHLSPlaylist) Generate(segments []*LLHLSSegment, currentParts []*LLHLSPart, currentMSN int, skip, includeLatestCompletedParts bool) string
Generate produces the m3u8 playlist text.
Parameters:
- segments: completed segments in the sliding window
- currentParts: partial segments of the in-progress segment
- currentMSN: MSN of the in-progress segment
- skip: if true, emit EXT-X-SKIP for delta updates (client sent _HLS_skip=YES)
type LLHLSSegment ¶
type LLHLSSegment struct {
MSN int // media sequence number
Duration float64 // total duration in seconds
Parts []*LLHLSPart // partial segments
Discontinuity bool
// contains filtered or unexported fields
}
LLHLSSegment represents a completed full segment.
type LLHLSSegmenter ¶
type LLHLSSegmenter struct {
// contains filtered or unexported fields
}
LLHLSSegmenter reads AVFrames from a stream and produces LL-HLS segments.
func NewLLHLSSegmenter ¶
func NewLLHLSSegmenter(partDuration, segmentDuration float64, container string, cb LLHLSSegmenterCallbacks) *LLHLSSegmenter
NewLLHLSSegmenter creates a new segmenter.
func (*LLHLSSegmenter) Run ¶
func (s *LLHLSSegmenter) Run(stream *core.Stream, identity ...any)
Run starts the segmenter loop. Blocks until stream ends or Stop() is called.
func (*LLHLSSegmenter) Stop ¶
func (s *LLHLSSegmenter) Stop()
Stop signals the segmenter to shut down.
type LLHLSSegmenterCallbacks ¶
type LLHLSSegmenterCallbacks struct {
OnInit func(data []byte)
OnPart func(part *LLHLSPart)
OnSegment func(seg *LLHLSSegment)
OnDiscontinuity func()
}
LLHLSSegmenterCallbacks are invoked when segments are produced.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module implements the HTTP streaming module for FLV, TS, FMP4, HLS, and DASH.
func (*Module) Hooks ¶
func (m *Module) Hooks() []core.HookRegistration
Hooks returns the module's event hooks. We listen for publish stop and stream destroy events to clean up HLS/DASH managers.