control

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EdgeRequestClient

type EdgeRequestClient interface {
	/*
		InstallReferenceToManager used by a SystemManager to add a reference of itself into the client

			@param newManager SystemManager - reference to the manager
	*/
	InstallReferenceToManager(newManager SystemManager)

	/*
		ChangeVideoStreamingState change a video source's streaming state

			@param ctxt context.Context - execution context
			@param source common.VideoSource - video source entry
			@param newState int - new streaming state
	*/
	ChangeVideoStreamingState(ctxt context.Context, source common.VideoSource, newState int) error

	/*
		StartRecordingSession start a new recording session on a edge node

			@param ctxt context.Context - execution context
			@param source common.VideoSource - video source entry
			@param recording common.Recording - video recording session
	*/
	StartRecordingSession(
		ctxt context.Context, source common.VideoSource, recording common.Recording,
	) error

	/*
		StopRecordingSession stop a recording session on a edge node

			@param ctxt context.Context - execution context
			@param source common.VideoSource - video source entry
			@param recordingID string - video recording session ID
	*/
	StopRecordingSession(
		ctxt context.Context, source common.VideoSource, recordingID string, endTime time.Time,
	) error
}

EdgeRequestClient request-response client for control to call edge

func NewEdgeRequestClient

func NewEdgeRequestClient(
	ctxt context.Context,
	clientName string,
	coreClient goutils.RequestResponseClient,
	requestTimeout time.Duration,
) (EdgeRequestClient, error)

NewEdgeRequestClient define a new control to edge request-response client

@param ctxt context.Context - execution context
@param clientName string - name of this client instance
@param coreClient goutils.RequestResponseClient - core request-response client
@param requestTimeout time.Duration - request-response request timeout
@returns new client

type LiveStreamSegmentManager

type LiveStreamSegmentManager interface {
	/*
		Ready check whether the manager is ready

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

	/*
		RegisterLiveStreamSegment record a new segment with a source

			@param ctxt context.Context - execution context
			@param sourceID string - video source ID
			@param segment hls.Segment - video segment parameters
	*/
	RegisterLiveStreamSegment(
		ctxt context.Context, sourceID string, segment hls.Segment, content []byte,
	) error

	/*
		Stop stop all background operations

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

LiveStreamSegmentManager central video segment manager which operates within the system control node

func NewLiveStreamSegmentManager

func NewLiveStreamSegmentManager(
	parentCtxt context.Context,
	dbConns db.ConnectionManager,
	cache utils.VideoSegmentCache,
	trackingWindow time.Duration,
	metrics goutils.MetricsCollector,
) (LiveStreamSegmentManager, error)

NewLiveStreamSegmentManager define a new live stream segment manager

@param parentCtxt context.Context - parent context
@param dbConns db.ConnectionManager - DB connection manager
@param cache utils.VideoSegmentCache - video segment cache
@param trackingWindow time.Duration - tracking window is the duration in time a video
    segment is tracked. Recorded segments are forgotten after this tracking window.
@param metrics goutils.MetricsCollector - metrics framework client
@returns new manager

type SystemManager

type SystemManager interface {
	/*
		Ready check whether the manager is ready

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

	/*
		Stop stop any support background tasks which were started

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

	/*
		DefineVideoSource create new video source

			@param ctxt context.Context - execution context
			@param name string - source name
			@param segmentLen int - target segment length in secs
			@param playlistURI *string - video source playlist URI
			@param description *string - optionally, source description
			@returns new source entry ID
	*/
	DefineVideoSource(
		ctxt context.Context, name string, segmentLen int, playlistURI, description *string,
	) (string, error)

	/*
		GetVideoSource retrieve a video source

			@param ctxt context.Context - execution context
			@param id string - source entry ID
			@returns video source entry
	*/
	GetVideoSource(ctxt context.Context, id string) (common.VideoSource, error)

	/*
		GetVideoSourceByName retrieve a video source by name

			@param ctxt context.Context - execution context
			@param name string - source name
			@returns video source entry
	*/
	GetVideoSourceByName(ctxt context.Context, name string) (common.VideoSource, error)

	/*
		ListVideoSources list all video sources

			@param ctxt context.Context - execution context
			@returns all video source entries
	*/
	ListVideoSources(ctxt context.Context) ([]common.VideoSource, error)

	/*
		UpdateVideoSource update properties of a video source.

		Only the following can be updated:
		  * Name
		  * Description
		  * Playlist URI

			@param ctxt context.Context - execution context
			@param newSetting common.VideoSource - new properties
	*/
	UpdateVideoSource(ctxt context.Context, newSetting common.VideoSource) error

	/*
		ChangeVideoSourceStreamState change the streaming state for a video source

			@param ctxt context.Context - execution context
			@param id string - source ID
			@param streaming int - new streaming state
	*/
	ChangeVideoSourceStreamState(ctxt context.Context, id string, streaming int) error

	/*
		DeleteVideoSource delete a video source

			@param ctxt context.Context - execution context
			@param id string - source entry ID
	*/
	DeleteVideoSource(ctxt context.Context, id string) error

	/*
		DefineRecordingSession create new video recording session

			@param ctxt context.Context - execution context
			@param sourceID string - the video source ID
			@param alias *string - an optional alias name for the recording session
			@param description *string - an optional description of the recording session
			@param startTime time.Time - when the recording session started
			@returns new recording session ID
	*/
	DefineRecordingSession(
		ctxt context.Context, sourceID string, alias, description *string, startTime time.Time,
	) (string, error)

	/*
		GetRecordingSession retrieve a video recording session

			@param ctxt context.Context - execution context
			@param id string - session entry ID
			@returns video recording entry
	*/
	GetRecordingSession(ctxt context.Context, id string) (common.Recording, error)

	/*
		GetRecordingSessionByAlias retrieve a video recording session by alias

			@param ctxt context.Context - execution context
			@param alias string - session entry alias
			@returns video recording entry
	*/
	GetRecordingSessionByAlias(ctxt context.Context, alias string) (common.Recording, error)

	/*
		ListRecordingSessions list all video recording sessions

			@param ctxt context.Context - execution context
			@returns all recording sessions
	*/
	ListRecordingSessions(ctxt context.Context) ([]common.Recording, error)

	/*
		ListRecordingSessionsOfSource list all video recording sessions of a video source

			@param ctxt context.Context - execution context
			@param sourceID string - the video source ID
			@param active bool - if 1, select only the active recording sessions; else return all.
			@returns all recording sessions of a video source source
	*/
	ListRecordingSessionsOfSource(
		ctxt context.Context, sourceID string, active bool,
	) ([]common.Recording, error)

	/*
		MarkEndOfRecordingSession mark a video recording session as complete.

			@param ctxt context.Context - execution context
			@param id string - session entry ID
			@param endTime time.Time - when the recording session ended
			@param force bool - force through the change regardless whether the video source
			    is accepting inbound requests.
	*/
	MarkEndOfRecordingSession(ctxt context.Context, id string, endTime time.Time, force bool) error

	/*
		UpdateRecordingSession update properties of a video recording session.

		Only the following can be updated:
		  * Alias
		  * Description

			@param ctxt context.Context - execution context
			@param newSetting common.Recording - new properties
	*/
	UpdateRecordingSession(ctxt context.Context, newSetting common.Recording) error

	/*
		DeleteRecordingSession delete a video recording session

			@param ctxt context.Context - execution context
			@param id string - session entry ID
			@param force bool - force through the change regardless whether the video source
			    is accepting inbound requests.
	*/
	DeleteRecordingSession(ctxt context.Context, id string, force bool) error

	/*
		StopAllActiveRecordingOfSource stop any active recording sessions associated with a source

			@param ctxt context.Context - execution context
			@param id string - source entry ID
			@param currentTime time.Time - current timestamp
	*/
	StopAllActiveRecordingOfSource(ctxt context.Context, id string, currentTime time.Time) error

	/*
		ListAllSegmentsOfRecording fetch all video segments belonging to one recording session

			@param ctxt context.Context - execution context
			@param recordingID string - video recording session ID
			@returns set of video segments
	*/
	ListAllSegmentsOfRecording(
		ctxt context.Context, recordingID string,
	) ([]common.VideoSegment, error)

	/*
		ProcessBroadcastMsgs process received broadcast messages

			@param ctxt context.Context - execution context
			@param pubTimestamp time.Time - timestamp when the message was published
			@param msg []byte - broadcast message payload
			@param metadata map[string]string - broadcast message metadata
	*/
	ProcessBroadcastMsgs(
		ctxt context.Context, pubTimestamp time.Time, msg []byte, metadata map[string]string,
	) error

	/*
		DeleteUnassociatedRecordingSegments trigger to purge recording segments unassociated
		with any recordings from storage
	*/
	DeleteUnassociatedRecordingSegments() error
}

SystemManager system operations manager

func NewManager

func NewManager(
	parentCtxt context.Context,
	dbConns db.ConnectionManager,
	rrClient EdgeRequestClient,
	s3 utils.S3Client,
	maxAgeForSourceStatusReport time.Duration,
	segmentCleanupInt time.Duration,
	metrics goutils.MetricsCollector,
) (SystemManager, error)

NewManager define a new system manager

@param parentCtxt context.Context - parent execution context
@param dbConns db.ConnectionManager - DB connection manager
@param rrClient EdgeRequestClient - request-response client
@param s3 utils.S3Client - S3 operation client
@param maxAgeForSourceStatusReport time.Duration - for the system to send a requests to a
    particular video source, this source must have sent out a video source status report
    within this time window before a request is made. If not, the video source is treated as
    connected.
@param segmentCleanupInt time.Duration - time interval between segment cleanup runs
@param metrics goutils.MetricsCollector - metrics framework client
@returns new manager

Jump to

Keyboard shortcuts

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