Documentation
¶
Overview ¶
Package recorder is the screen recorder service: the lifecycle state machine (idle, starting, recording, stopping), the elapsed timer, options from the modules.recorder config, and the engine. The engine asks the share picker for an output, has the compositor copy its frames into a buffer on the GPU behind it, encodes them to H.264 on that GPU's video encoder with an optional webcam overlay, mixes the microphone and the desktop's audio into Opus, and muxes both into MP4 or Matroska.
Index ¶
- Constants
- Variables
- func ChoiceIndex(choices []DeviceChoice, id string) int
- func ChoiceLabels(choices []DeviceChoice) []string
- func FormatElapsed(totalSecs uint32) string
- func OutputPath(configuredDir string, format config.RecorderFormat, now time.Time) string
- func VideosDir() string
- func WebcamMargin(w, h int32) int32
- type Change
- type Daemon
- type DeviceChoice
- type Engine
- type GPUEngine
- type Hooks
- type LogicalSize
- type Options
- type Picker
- type Recording
- type Session
- type Source
- type State
- type Status
- type Webcam
Constants ¶
const ( ServiceName = "dev.stubbe.lys.Recorder1" ServicePath = "/dev/stubbe/lys/Recorder" )
D-Bus identity (the Rust RecorderService's registration).
Variables ¶
var ErrNoVideoEncoder = gpu.ErrNoVideoEncoder
ErrNoVideoEncoder is a GPU that cannot encode H.264: the recorder has no other encoder.
var ErrPickerCancelled = errors.New("recorder: nothing was picked to record")
ErrPickerCancelled is a start the user dismissed at the picker.
Functions ¶
func ChoiceIndex ¶
func ChoiceIndex(choices []DeviceChoice, id string) int
ChoiceIndex is index_of: the saved id's index, else the default 0.
func ChoiceLabels ¶
func ChoiceLabels(choices []DeviceChoice) []string
ChoiceLabels are the picker rows.
func FormatElapsed ¶
FormatElapsed is format_elapsed: H:MM:SS above the hour, M:SS within.
func OutputPath ¶
OutputPath is output_path: lys-shell-<local timestamp>.<format> in the configured directory, else the videos directory; a format's name is its extension.
func VideosDir ¶
func VideosDir() string
VideosDir is videos_dir: $XDG_VIDEOS_DIR, else $HOME/Videos.
func WebcamMargin ¶
WebcamMargin is the uniform inset, a percentage of the shorter side. The dropdown's position preview uses it too.
Types ¶
type Change ¶
type Change struct {
Status Status
Active bool
Paused bool
Preparing bool
ElapsedSecs uint32
OutputPath string
// Error is why the last recording failed to start or ended on its
// own, "" once a new one starts.
Error string
}
Change is the state the bar module, the dropdown, and the daemon read.
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon is the dev.stubbe.lys.Recorder1 object (wayle-shell-core/src/services/recorder/dbus.rs).
type DeviceChoice ¶
type DeviceChoice struct {
ID, Label string
}
DeviceChoice is DeviceChoice: ID is what the recorder consumes ("" is the default or automatic entry), Label what a picker shows.
func Cameras ¶
func Cameras() []DeviceChoice
Cameras is cameras(): "Automatic", then one entry per distinct card name at its lowest capture node.
func MicrophoneChoices ¶
func MicrophoneChoices(sources []Source) []DeviceChoice
MicrophoneChoices is microphone_sources: "Default", then every named non-monitor source by description (else name).
func WithSaved ¶
func WithSaved(choices []DeviceChoice, id string) []DeviceChoice
WithSaved keeps a saved device the list does not offer (unplugged, or not enumerated yet) selectable: it is appended, labelled by its id. The default "" needs no entry.
type Engine ¶
type Engine interface {
// OpenSession negotiates the source, showing the picker when no
// choice is remembered; ctx cancels it.
OpenSession(ctx context.Context, showCursor bool) (Session, error)
}
Engine opens capture sessions.
type GPUEngine ¶ added in v0.2.0
type GPUEngine struct {
// contains filtered or unexported fields
}
GPUEngine is the production Engine: the share picker for an output or a region of one, screencopy into a buffer on the GPU behind it, the GPU's H.264 encoder, and the audio service for the microphone and the desktop.
func NewGPUEngine ¶ added in v0.2.0
func NewGPUEngine(picker Picker, audio *pulse.Service, logical LogicalSize, stateDir string) *GPUEngine
NewGPUEngine records through picker, with audio from audio (nil when there is no audio server, which fails a recording that asks for sound), regions measured by logical, remembering the pick in stateDir ("" remembers nothing).
type Hooks ¶
type Hooks struct {
Toast func(label, icon string, durationMS uint32)
Notify func(appName, summary, body, icon string)
}
Hooks are the user-facing reports: an OSD toast and a desktop notification. Nil hooks are skipped.
type LogicalSize ¶ added in v0.2.0
LogicalSize is an output's size in the compositor's logical space, false when the output is not known: what a region is measured in.
type Options ¶
type Options struct {
OutputPath string
Format config.RecorderFormat
Framerate uint32
ShowCursor bool
// Microphone captures MicrophoneDevice ("" the default source);
// SystemAudio the default sink's monitor.
Microphone bool
MicrophoneDevice string
SystemAudio bool
// Webcam is the overlay, nil for none.
Webcam *Webcam
}
Options is one recording's settings.
func BuildOptions ¶
func BuildOptions(cfg config.RecorderConfig, now time.Time) Options
BuildOptions is build_options: the recording's options from the config, the output named for now.
type Picker ¶ added in v0.2.0
type Picker interface {
Pick(ctx context.Context, caller portaldialogs.Caller, r sharepicker.Request) (string, error)
Dismiss(ctx context.Context, handle string) error
}
Picker shows the share picker: sharepicker.Client.
type Recording ¶
type Recording interface {
// SetPaused pauses or resumes the capture: paused time is cut from
// the file.
SetPaused(paused bool)
// Stop drains the encoders and finalizes the file, blocking until
// it is written; the error says what of it could not be.
Stop() error
}
Recording is one running capture.
type Session ¶
type Session interface {
// Start records the source with opts; term reports an unexpected
// end (a source disconnect, a full disk), never a requested Stop.
Start(opts Options, term func(reason string)) (Recording, error)
Close()
}
Session is a negotiated capture source, held across the start delay and closed when the recording ends.
type Source ¶
type Source struct {
Name, Description string
// Monitor is a sink's monitor, never a microphone.
Monitor bool
}
Source is an audio input as the microphone pickers see it.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is the recorder service. Safe for concurrent use.
func NewState ¶
func NewState(engine Engine, cfg func() config.RecorderConfig, hooks Hooks) *State
NewState builds the service over an engine, reading options from cfg at each start.
func (*State) Changes ¶
Changes delivers a snapshot on every change and elapsed second to every subscriber; stop ends the feed.
func (*State) Start ¶
func (s *State) Start()
Start begins a recording with the current config. The Idle→Starting claim is synchronous, so a second call while one is in flight is a no-op; the rest (picker, delay, recording) runs off the caller.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package recordertest is the scripted recorder.Engine every recorder test drives: sessions and recordings that record their calls, an optional gate that holds OpenSession (the output picker), and a hook that ends a recording as a failed capture would.
|
Package recordertest is the scripted recorder.Engine every recorder test drives: sessions and recordings that record their calls, an optional gate that holds OpenSession (the output picker), and a hook that ends a recording as a failed capture would. |