Documentation
¶
Overview ¶
Package dvr implements the DVR (Digital Video Recorder).
Storage layout per stream:
./dvr/{streamCode}/
index.json — lightweight metadata: stream info, segment count, gaps
playlist.m3u8 — HLS EVENT/VOD playlist with EXT-X-PROGRAM-DATE-TIME
000000.ts
000001.ts
...
index.json is intentionally lean — no per-segment details. Per-segment timeline (wall time, duration, discontinuity) lives in playlist.m3u8.
On server restart: index.json + playlist.m3u8 are read to resume state. The first new segment after resume is tagged #EXT-X-DISCONTINUITY.
On signal loss (gap > 2× segment duration): partial segment is flushed, TS muxer is reset, gap is recorded in index.json, next segment tagged #EXT-X-DISCONTINUITY with updated #EXT-X-PROGRAM-DATE-TIME.
Index ¶
- type SegmentMeta
- type Service
- func (s *Service) IsRecording(streamID domain.StreamCode) bool
- func (s *Service) LoadIndex(segDir string) (*domain.DVRIndex, error)
- func (s *Service) ParsePlaylist(segDir string) ([]SegmentMeta, error)
- func (s *Service) StartRecording(ctx context.Context, streamID domain.StreamCode, ...) (*domain.Recording, error)
- func (s *Service) StopRecording(ctx context.Context, streamID domain.StreamCode) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SegmentMeta ¶
SegmentMeta is the exported view of a parsed playlist segment.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages DVR recording sessions.
func (*Service) IsRecording ¶
func (s *Service) IsRecording(streamID domain.StreamCode) bool
IsRecording reports whether there is an active recording session for streamID.
func (*Service) LoadIndex ¶
LoadIndex reads index.json for a stream's recording directory. Exported for the API info handler.
func (*Service) ParsePlaylist ¶
func (s *Service) ParsePlaylist(segDir string) ([]SegmentMeta, error)
ParsePlaylist reads playlist.m3u8 and returns the ordered segment metadata. Exported for the timeshift handler.
func (*Service) StartRecording ¶
func (s *Service) StartRecording(ctx context.Context, streamID domain.StreamCode, mediaBufferID domain.StreamCode, dvrCfg *domain.StreamDVRConfig) (*domain.Recording, error)
StartRecording begins (or resumes) recording for the given stream.
func (*Service) StopRecording ¶
StopRecording stops the active recording and writes a final VOD playlist.