driver

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Camera represents camera devices
	Camera DeviceType = "camera"
	// Microphone represents microphone devices
	Microphone = "microphone"
	// Screen represents screen devices
	Screen = "screen"
)
View Source
const (
	// StateClosed means that the driver has not been opened. In this state,
	// all information related to the hardware are still unknown. For example,
	// if it's a video driver, the pixel format information is still unknown.
	StateClosed State = "closed"
	// StateOpened means that the driver is already opened and information about
	// the hardware are already known and may be extracted from the driver.
	StateOpened = "opened"
	// StateRunning means that the driver has been sending data. The caller
	// who started the driver may start reading data from the hardware.
	StateRunning = "running"
)

Variables

This section is empty.

Functions

func IsAvailable

func IsAvailable(d Driver) (bool, error)

Types

type Adapter

type Adapter interface {
	Open() error
	Close() error
	Properties() []prop.Media
}

type AudioRecorder

type AudioRecorder interface {
	AudioRecord(p prop.Media) (r audio.Reader, err error)
}

type AvailabilityAdapter

type AvailabilityAdapter interface {
	IsAvailable() (bool, error)
}

type DeviceType

type DeviceType string

DeviceType represents human readable device type. DeviceType can be useful to filter the drivers too.

type Driver

type Driver interface {
	Adapter
	ID() string
	Info() Info
	Status() State
}

type FilterFn

type FilterFn func(Driver) bool

FilterFn is being used to decide if a driver should be included in the query result.

func FilterAnd

func FilterAnd(filters ...FilterFn) FilterFn

FilterAnd returns a filter function to take logical conjunction of given filters.

func FilterAudioRecorder

func FilterAudioRecorder() FilterFn

FilterAudioRecorder return a filter function to get a list of registered AudioRecorders

func FilterDeviceType

func FilterDeviceType(t DeviceType) FilterFn

FilterDeviceType returns a filter function to get registered drivers which matches t type

func FilterID

func FilterID(id string) FilterFn

FilterID return a filter function to get registered drivers which have given ID

func FilterNot

func FilterNot(filter FilterFn) FilterFn

FilterNot returns a filter function to take logical inverse of the given filter.

func FilterVideoRecorder

func FilterVideoRecorder() FilterFn

FilterVideoRecorder return a filter function to get a list of registered VideoRecorders

type Info

type Info struct {
	Label      string
	DeviceType DeviceType
	Priority   Priority
	Name       string
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is a singleton to manage multiple drivers and their states

func GetManager

func GetManager() *Manager

GetManager gets manager singleton instance

func (*Manager) Delete

func (m *Manager) Delete(id string)

Delete deletes a driver from manager given its ID

func (*Manager) Query

func (m *Manager) Query(f FilterFn) []Driver

Query queries by using f to filter drivers, and simply return the filtered results.

func (*Manager) Register

func (m *Manager) Register(a Adapter, info Info) error

Register registers adapter to be discoverable by Query

type Priority

type Priority float32

Priority represents device selection priority level

const (
	// PriorityHigh is a value for system default devices
	PriorityHigh Priority = 0.1
	// PriorityNormal is a value for normal devices
	PriorityNormal Priority = 0.0
	// PriorityLow is a value for unrecommended devices
	PriorityLow Priority = -0.1
)

type State

type State string

State represents driver's state

func (*State) Update

func (s *State) Update(next State, f func() error) error

Update updates current state, s, to next. If f fails to execute, s will stay unchanged. Otherwise, s will be updated to next

type VideoRecorder

type VideoRecorder interface {
	VideoRecord(p prop.Media) (r video.Reader, err error)
}

Directories

Path Synopsis
Package audiotest provides dummy audio driver for testing.
Package audiotest provides dummy audio driver for testing.
Package camera provides a video camera driver.
Package camera provides a video camera driver.
Package videotest provides dummy video driver for testing.
Package videotest provides dummy video driver for testing.
Package videotest provides vncDevice video driver for testing.
Package videotest provides vncDevice video driver for testing.
vnc
Package vnc implements a VNC client.
Package vnc implements a VNC client.

Jump to

Keyboard shortcuts

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