Documentation
¶
Index ¶
- Variables
- type FFmpegManager
- func (fm *FFmpegManager) DeregisterRecorder(ctx context.Context, recorder Recorder) error
- func (fm *FFmpegManager) GetRecorder(id string) (Recorder, bool)
- func (fm *FFmpegManager) ListActiveRecorders(ctx context.Context) []Recorder
- func (fm *FFmpegManager) RegisterRecorder(ctx context.Context, recorder Recorder) error
- func (fm *FFmpegManager) StopAll(ctx context.Context) error
- type FFmpegRecorder
- func (fr *FFmpegRecorder) Delete(ctx context.Context) error
- func (fr *FFmpegRecorder) ForceStop(ctx context.Context) error
- func (fr *FFmpegRecorder) ID() string
- func (fr *FFmpegRecorder) IsDeleted(ctx context.Context) bool
- func (fr *FFmpegRecorder) IsRecording(ctx context.Context) bool
- func (fr *FFmpegRecorder) Metadata() *RecordingMetadata
- func (fr *FFmpegRecorder) Recording(ctx context.Context) (io.ReadCloser, *RecordingMetadata, error)
- func (fr *FFmpegRecorder) Start(ctx context.Context) error
- func (fr *FFmpegRecorder) Stop(ctx context.Context) error
- func (fr *FFmpegRecorder) WaitForFinalization(ctx context.Context) error
- type FFmpegRecorderFactory
- type FFmpegRecordingParams
- type RecordManager
- type Recorder
- type RecordingMetadata
Constants ¶
This section is empty.
Variables ¶
var ErrRecordingFinalizing = errors.New("recording is being finalized")
ErrRecordingFinalizing is returned when attempting to access a recording that is currently being finalized (remuxed to add duration metadata).
Functions ¶
This section is empty.
Types ¶
type FFmpegManager ¶
type FFmpegManager struct {
// contains filtered or unexported fields
}
func NewFFmpegManager ¶
func NewFFmpegManager() *FFmpegManager
func (*FFmpegManager) DeregisterRecorder ¶
func (fm *FFmpegManager) DeregisterRecorder(ctx context.Context, recorder Recorder) error
func (*FFmpegManager) GetRecorder ¶
func (fm *FFmpegManager) GetRecorder(id string) (Recorder, bool)
func (*FFmpegManager) ListActiveRecorders ¶
func (fm *FFmpegManager) ListActiveRecorders(ctx context.Context) []Recorder
func (*FFmpegManager) RegisterRecorder ¶
func (fm *FFmpegManager) RegisterRecorder(ctx context.Context, recorder Recorder) error
type FFmpegRecorder ¶
type FFmpegRecorder struct {
// contains filtered or unexported fields
}
FFmpegRecorder encapsulates an FFmpeg recording session with platform-specific screen capture. It manages the lifecycle of a single FFmpeg process and provides thread-safe operations.
func (*FFmpegRecorder) Delete ¶
func (fr *FFmpegRecorder) Delete(ctx context.Context) error
Delete removes the recording file from disk. Returns ErrRecordingFinalizing if the recording is currently being finalized.
func (*FFmpegRecorder) ForceStop ¶
func (fr *FFmpegRecorder) ForceStop(ctx context.Context) error
ForceStop immediately terminates the recording process.
func (*FFmpegRecorder) ID ¶
func (fr *FFmpegRecorder) ID() string
ID returns the unique identifier for this recorder.
func (*FFmpegRecorder) IsRecording ¶
func (fr *FFmpegRecorder) IsRecording(ctx context.Context) bool
IsRecording returns true if a recording is currently in progress.
func (*FFmpegRecorder) Metadata ¶
func (fr *FFmpegRecorder) Metadata() *RecordingMetadata
Metadata is an incomplete snapshot of the recording metadata.
func (*FFmpegRecorder) Recording ¶
func (fr *FFmpegRecorder) Recording(ctx context.Context) (io.ReadCloser, *RecordingMetadata, error)
Recording returns the recording file as an io.ReadCloser. Returns ErrRecordingFinalizing if the recording is currently being finalized.
func (*FFmpegRecorder) Start ¶
func (fr *FFmpegRecorder) Start(ctx context.Context) error
Start begins the recording process by launching ffmpeg with the configured parameters.
func (*FFmpegRecorder) Stop ¶
func (fr *FFmpegRecorder) Stop(ctx context.Context) error
Stop gracefully stops the recording using a multi-phase shutdown process.
func (*FFmpegRecorder) WaitForFinalization ¶
func (fr *FFmpegRecorder) WaitForFinalization(ctx context.Context) error
WaitForFinalization blocks until finalization completes and returns the result. If finalization hasn't started, it will be triggered. If already complete, returns the cached result immediately. This is useful for callers like the download handler that need to wait for finalization before accessing the recording.
type FFmpegRecorderFactory ¶
type FFmpegRecorderFactory func(id string, overrides FFmpegRecordingParams) (Recorder, error)
func NewFFmpegRecorderFactory ¶
func NewFFmpegRecorderFactory(pathToFFmpeg string, config FFmpegRecordingParams, ctrl scaletozero.Controller) FFmpegRecorderFactory
NewFFmpegRecorderFactory returns a factory that creates new recorders. The provided pathToFFmpeg is used as the binary to execute; if empty it defaults to "ffmpeg" which is expected to be discoverable on the host's PATH.
type FFmpegRecordingParams ¶
type FFmpegRecordingParams struct {
FrameRate *int
DisplayNum *int
MaxSizeInMB *int
// MaxDurationInSeconds optionally limits the total recording time. If nil there is no duration limit.
MaxDurationInSeconds *int
OutputDir *string
}
func (FFmpegRecordingParams) Validate ¶
func (p FFmpegRecordingParams) Validate() error
type RecordManager ¶
type RecordManager interface {
// GetRecorder retrieves a recorder by its ID.
// Returns the recorder and true if found, nil and false otherwise.
GetRecorder(id string) (Recorder, bool)
// ListActiveRecorders returns a list of IDs for all registered recorders
ListActiveRecorders(ctx context.Context) []Recorder
// DeregisterRecorder removes a recorder from the manager.
DeregisterRecorder(ctx context.Context, recorder Recorder) error
// RegisterRecorder registers a recorder with the given ID.
// Returns an error if a recorder with the same ID already exists.
RegisterRecorder(ctx context.Context, recorder Recorder) error
// StopAll stops all active recorders.
StopAll(ctx context.Context) error
}
RecordManager defines the interface for managing multiple recorder instances. Implementations should be thread-safe for concurrent access.
type Recorder ¶
type Recorder interface {
ID() string
Start(ctx context.Context) error
Stop(ctx context.Context) error
ForceStop(ctx context.Context) error
IsRecording(ctx context.Context) bool
Metadata() *RecordingMetadata
Recording(ctx context.Context) (io.ReadCloser, *RecordingMetadata, error)
Delete(ctx context.Context) error
IsDeleted(ctx context.Context) bool
}
Recorder defines the interface for recording functionality.