vod

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetReferenceTime

func GetReferenceTime() (time.Time, error)

GetReferenceTime helper function to get the reference time

Types

type PlaylistBuilder

type PlaylistBuilder interface {
	/*
		GetLiveStreamPlaylist generate a playlist for live stream

			@param ctxt context.Context - execution context
			@param target common.VideoSource - video source to generate the playlist for
			@param timestamp time.Time - current time
			@param addMediaSequence bool - whether to add a media sequence number to the playlist
			@returns the new playlist valid for the given timestamp
	*/
	GetLiveStreamPlaylist(
		ctxt context.Context, target common.VideoSource, timestamp time.Time, addMediaSequence bool,
	) (hls.Playlist, error)

	/*
		GetRecordingStreamPlaylist generate a playlist for a video recording

			@param ctxt context.Context - execution context
			@param recording common.Recording - video recording session
			@returns playlist for the recording session
	*/
	GetRecordingStreamPlaylist(ctxt context.Context, recording common.Recording) (hls.Playlist, error)
}

PlaylistBuilder construct HLS playlist on demand

func NewPlaylistBuilder

func NewPlaylistBuilder(
	ctxt context.Context,
	dbConns db.ConnectionManager,
	liveStreamSegCount int,
	metrics goutils.MetricsCollector,
) (PlaylistBuilder, error)

NewPlaylistBuilder define new playlist builder

@param ctxt context.Context - execution context
@param dbConns db.ConnectionManager - DB connection manager
@param liveStreamSegCount int - number of segments to include when building a live stream playlist
@param metrics goutils.MetricsCollector - metrics framework client
@returns new PlaylistBuilder

type PlaylistManager

type PlaylistManager interface {
	/*
		GetLiveStreamPlaylist generate a playlist for live stream

			@param ctxt context.Context - execution context
			@param target common.VideoSource - video source to generate the playlist for
			@param timestamp time.Time - current time
			@param addMediaSequence bool - whether to add a media sequence number to the playlist
			@returns the new playlist valid for the given timestamp
	*/
	GetLiveStreamPlaylist(
		ctxt context.Context, target common.VideoSource, timestamp time.Time, addMediaSequence bool,
	) (hls.Playlist, error)

	/*
		GetRecordingStreamPlaylist generate a playlist for a video recording

			@param ctxt context.Context - execution context
			@param recording common.Recording - video recording session
			@returns playlist for the recording session
	*/
	GetRecordingStreamPlaylist(ctxt context.Context, recording common.Recording) (hls.Playlist, error)

	/*
		GetSegment fetch video segment from cache. If cache miss, get the segment from source.

			@param ctxt context.Context - execution context
			@param target common.VideoSegment - video segment to fetch
			@returns segment data
	*/
	GetSegment(ctxt context.Context, target common.VideoSegment) ([]byte, error)

	/*
		Stop stops the daemon process

			@param ctxt context.Context - execution context
	*/
	Stop(ctxt context.Context) error
}

PlaylistManager VOD controller, and perform prefetching as needed

func NewPlaylistManager

func NewPlaylistManager(
	parentCtxt context.Context,
	dbConns db.ConnectionManager,
	segPrefetchCount int,
	builder PlaylistBuilder,
	segMgmt SegmentManager,
) (PlaylistManager, error)

NewPlaylistManager define new VOD controller

@param parentCtxt context.Context - parent context
@param dbConns db.ConnectionManager - DB connection manager
@param segPrefetchCount int - max number of recording segment to prefetch in parallel when
    requests a recording playback
@param builder PlaylistBuilder - playlist builder
@param segMgmt SegmentManager - segment manager
@returns new PlaylistManager

type SegmentManager

type SegmentManager interface {
	/*
		GetSegment fetch video segment from cache. If cache miss, get the segment from source.

			@param ctxt context.Context - execution context
			@param target common.VideoSegment - video segment to fetch
			@returns segment data
	*/
	GetSegment(ctxt context.Context, target common.VideoSegment) ([]byte, error)
}

SegmentManager segment cache management which integrates segment cache with segment reader

func NewSegmentManager

func NewSegmentManager(
	ctxt context.Context,
	cache utils.VideoSegmentCache,
	reader utils.SegmentReader,
	cacheTTL time.Duration,
	metrics goutils.MetricsCollector,
) (SegmentManager, error)

NewSegmentManager define new segment manager

@param ctxt context.Context - execution context
@param cache utils.VideoSegmentCache - segment cache
@param reader utils.SegmentReader - segment reader
@param cacheTTL time.Duration - when recording new entries in cache, use this TTL
@param metrics goutils.MetricsCollector - metrics framework client
@returns SegmentManager

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL