recorder

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 24 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package recorder is the screen recorder service (wayle-shell-core services/recorder and the wayle-recorder engine): the lifecycle state machine (idle, starting, recording, stopping), the elapsed timer, options from the [modules.recorder] config, and an engine that negotiates the ScreenCast portal and records through GStreamer.

Index

Constants

View Source
const (
	ServiceName = "dev.stubbe.lys.Recorder1"
	ServicePath = "/dev/stubbe/lys/Recorder"
)

D-Bus identity (the Rust RecorderService's registration).

Variables

This section is empty.

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

func FormatElapsed(totalSecs uint32) string

FormatElapsed is format_elapsed: H:MM:SS above the hour, M:SS within.

func OutputPath

func OutputPath(configuredDir string, format Format, now time.Time) string

OutputPath is output_path: lys-shell-<local timestamp>.<ext> in the configured directory, else the videos directory.

func VideosDir

func VideosDir() string

VideosDir is videos_dir: $XDG_VIDEOS_DIR, else $HOME/Videos.

func WebcamMargin

func WebcamMargin(w, h int32) int32

WebcamMargin is webcam_margin: the uniform inset, a percentage of the shorter side. The dropdown's position preview uses it too.

Types

type Built

type Built struct {
	Description string
	Hardware    bool
}

Built is a pipeline description and whether its video encoder is hardware (pipeline.rs's Built).

func BuildPipeline

func BuildPipeline(opts Options, cast Cast, allowHardware bool, threads int, hasFactory func(string) bool) Built

BuildPipeline is pipeline.rs's build_with: the portal's pipewiresrc, optionally composited with a letterboxed webcam, encoded and muxed, with system audio and the microphone mixed into one track. A hardware H.264 encoder is used when allowHardware and hasFactory reports its element; threads is the encoder thread count.

type Cast

type Cast struct {
	FD            uintptr
	Node          uint32
	Width, Height int32
}

Cast is the negotiated screen: the PipeWire remote fd, the node, and the size (zero when unknown).

type Change

type Change struct {
	Status      Status
	Active      bool
	Paused      bool
	Preparing   bool
	ElapsedSecs uint32
	OutputPath  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).

func NewDaemon

func NewDaemon(state *State) *Daemon

NewDaemon wraps the state for export.

func (*Daemon) Export

func (d *Daemon) Export(conn *dbus.Conn) (func(), error)

Export serves the interface under its well-known name; the returned release drops the name.

func (*Daemon) Pause

func (d *Daemon) Pause() *dbus.Error

Pause pauses the recording.

func (*Daemon) Resume

func (d *Daemon) Resume() *dbus.Error

Resume resumes a paused recording.

func (*Daemon) Start

func (d *Daemon) Start() *dbus.Error

Start begins a recording.

func (*Daemon) Stop

func (d *Daemon) Stop() *dbus.Error

Stop finalizes the recording.

func (*Daemon) Toggle

func (d *Daemon) Toggle() *dbus.Error

Toggle starts or stops.

type DeviceChoice

type DeviceChoice struct {
	ID, Label string
}

DeviceChoice is DeviceChoice: ID is what the pipeline 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
	// grant is cached; ctx cancels it.
	OpenSession(ctx context.Context, showCursor bool) (Session, error)
	// Start records session with opts; term reports an unexpected end
	// (a source disconnect, a full disk), never a requested Stop.
	Start(session Session, opts Options, term func(reason string)) (Recording, error)
}

Engine opens capture sessions and records them (wayle-recorder's Recorder: open_session, start).

type Format

type Format int

Format is the container/codec preset (options.rs's OutputFormat).

const (
	FormatMP4 Format = iota
	FormatMKV
	FormatWebM
)

Formats.

func (Format) Extension

func (f Format) Extension() string

Extension is the file extension.

type GstEngine

type GstEngine struct {
	// Conn is the session bus the portal is reached on.
	Conn *dbus.Conn
}

GstEngine is the production Engine: the ScreenCast portal on the session bus and an in-process GStreamer pipeline.

func (GstEngine) OpenSession

func (e GstEngine) OpenSession(ctx context.Context, showCursor bool) (Session, error)

OpenSession implements Engine: one monitor through the portal, the restore token in lys-shell's state dir.

func (GstEngine) Start

func (e GstEngine) Start(session Session, opts Options, term func(reason string)) (Recording, error)

Start implements Engine (Recorder::start): the hardware-preferring pipeline, retried once on the software encoder when a detected hardware encoder fails to reach PLAYING.

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 Options

type Options struct {
	OutputPath string
	Format     Format
	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 (RecordOptions).

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 Recording

type Recording interface {
	// SetPaused pauses or resumes the capture.
	SetPaused(paused bool) error
	// Stop finalizes the file, blocking until the muxer is done.
	Stop()
}

Recording is one running capture.

type Session

type Session interface {
	Cast() Cast
	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

func (s *State) Changes() (<-chan Change, func())

Changes delivers a snapshot on every change and elapsed second to every subscriber; stop ends the feed.

func (*State) SetPaused

func (s *State) SetPaused(paused bool)

SetPaused pauses or resumes an active recording; an engine failure leaves the state as it was.

func (*State) Snapshot

func (s *State) Snapshot() Change

Snapshot reads the current state.

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 (portal, delay, pipeline) runs off the caller.

func (*State) Stop

func (s *State) Stop()

Stop stops the recording, or cancels one still starting. Only the first call from Starting or Recording does work. From Recording the UI flips to stopped at once, the blocking finalize runs off the caller, and the status settles to Idle after it.

func (*State) Toggle

func (s *State) Toggle()

Toggle keys off the lifecycle, not active: during the start delay a toggle cancels the pending start (state.rs's toggle).

type Status

type Status int

Status is the lifecycle gate (state.rs's Status), updated synchronously so rapid clicks never double-start.

const (
	StatusIdle Status = iota
	StatusStarting
	StatusRecording
	StatusStopping
)

Statuses.

func (Status) String

func (s Status) String() string

String names the status.

type Webcam

type Webcam struct {
	// Device is the V4L2 node; "" auto-selects.
	Device string
	// X and Y place the frame in the free space, 0-100.
	X, Y uint32
	// Size is the frame width as a percentage of the recording, 1-100.
	Size uint32
}

Webcam is the picture-in-picture overlay (WebcamOptions).

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 portal picker), and a hook that ends a recording as a failed pipeline 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 portal picker), and a hook that ends a recording as a failed pipeline would.

Jump to

Keyboard shortcuts

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