types

package
v1.6.18 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMemberAlreadyExists   = errors.New("member already exists")
	ErrMemberDoesNotExist    = errors.New("member does not exist")
	ErrMemberInvalidPassword = errors.New("invalid password")
)
View Source
var (
	ErrSessionNotFound         = errors.New("session not found")
	ErrSessionAlreadyExists    = errors.New("session already exists")
	ErrSessionAlreadyConnected = errors.New("session is already connected")
	ErrSessionLoginDisabled    = errors.New("session login disabled")
)
View Source
var (
	ErrWebRTCDataChannelNotFound = errors.New("webrtc data channel not found")
	ErrWebRTCConnectionNotFound  = errors.New("webrtc connection not found")
	ErrWebRTCStreamNotFound      = errors.New("webrtc stream not found")
)
View Source
var (
	ErrCapturePipelineAlreadyExists = errors.New("capture pipeline already exists")
)

Functions

This section is empty.

Types

type ApiManager

type ApiManager interface {
	Route(r Router)
	AddRouter(path string, router func(Router))
}

type BroadcastManager

type BroadcastManager interface {
	Start(url string) error
	Stop()
	Started() bool
	Url() string
}

type CaptureManager

type CaptureManager interface {
	Start()
	Shutdown() error

	Broadcast() BroadcastManager
	Screencast() ScreencastManager
	Audio() StreamSinkManager
	Video() StreamSelectorManager

	Webcam() StreamSrcManager
	Microphone() StreamSrcManager
}

type CheckOrigin

type CheckOrigin func(r *http.Request) bool

type ClipboardText

type ClipboardText struct {
	Text string
	HTML string
}

type Cursor

type Cursor struct {
	X int `json:"x"`
	Y int `json:"y"`
}

type CursorImage

type CursorImage struct {
	Width  uint16
	Height uint16
	Xhot   uint16
	Yhot   uint16
	Serial uint64
	Image  *image.RGBA
}

type DependablePlugin

type DependablePlugin interface {
	Plugin
	DependsOn() []string
}

type DesktopManager

type DesktopManager interface {
	Start()
	Shutdown() error
	OnBeforeScreenSizeChange(listener func())
	OnAfterScreenSizeChange(listener func())

	// xorg
	Move(x, y int)
	GetCursorPosition() (int, int)
	Scroll(deltaX, deltaY int, controlKey bool)
	ButtonDown(code uint32) error
	KeyDown(code uint32) error
	ButtonUp(code uint32) error
	KeyUp(code uint32) error
	ButtonPress(code uint32) error
	KeyPress(codes ...uint32) error
	ResetKeys()
	ScreenConfigurations() []ScreenSize
	SetScreenSize(ScreenSize) (ScreenSize, error)
	GetScreenSize() ScreenSize
	SetKeyboardMap(KeyboardMap) error
	GetKeyboardMap() (*KeyboardMap, error)
	SetKeyboardModifiers(mod KeyboardModifiers)
	GetKeyboardModifiers() KeyboardModifiers
	GetCursorImage() *CursorImage
	GetScreenshotImage() *image.RGBA

	// xevent
	OnCursorChanged(listener func(serial uint64))
	OnClipboardUpdated(listener func())
	OnFileChooserDialogOpened(listener func())
	OnFileChooserDialogClosed(listener func())
	OnEventError(listener func(error_code uint8, message string, request_code uint8, minor_code uint8))

	// input driver
	HasTouchSupport() bool
	TouchBegin(touchId uint32, x, y int, pressure uint8) error
	TouchUpdate(touchId uint32, x, y int, pressure uint8) error
	TouchEnd(touchId uint32, x, y int, pressure uint8) error

	// clipboard
	ClipboardGetText() (*ClipboardText, error)
	ClipboardSetText(data ClipboardText) error
	ClipboardGetBinary(mime string) ([]byte, error)
	ClipboardSetBinary(mime string, data []byte) error
	ClipboardGetTargets() ([]string, error)

	// drop
	DropFiles(x int, y int, files []string) bool
	IsUploadDropEnabled() bool

	// filechooser
	HandleFileChooserDialog(uri string) error
	CloseFileChooserDialog()
	IsFileChooserDialogEnabled() bool
	IsFileChooserDialogOpened() bool
}

type ExposablePlugin

type ExposablePlugin interface {
	Plugin
	ExposeService() any
}

type HttpManager

type HttpManager interface {
	Start()
	Shutdown() error
}

type ICEServer

type ICEServer struct {
	URLs       []string `mapstructure:"urls"       json:"urls"`
	Username   string   `mapstructure:"username"   json:"username,omitempty"`
	Credential string   `mapstructure:"credential" json:"credential,omitempty"`
}

type KeyboardMap

type KeyboardMap struct {
	Layout  string `json:"layout"`
	Variant string `json:"variant"`
}

type KeyboardModifiers

type KeyboardModifiers struct {
	Shift    *bool `json:"shift"`
	CapsLock *bool `json:"capslock"`
	Control  *bool `json:"control"`
	Alt      *bool `json:"alt"`
	NumLock  *bool `json:"numlock"`
	Meta     *bool `json:"meta"`
	Super    *bool `json:"super"`
	AltGr    *bool `json:"altgr"`
}

type MemberManager

type MemberManager interface {
	MemberProvider

	Login(username string, password string) (Session, string, error)
	Logout(id string) error
}

type MemberProfile

type MemberProfile struct {
	Name string `json:"name"`

	// permissions
	IsAdmin               bool `json:"is_admin"                 mapstructure:"is_admin"`
	CanLogin              bool `json:"can_login"                mapstructure:"can_login"`
	CanConnect            bool `json:"can_connect"              mapstructure:"can_connect"`
	CanWatch              bool `json:"can_watch"                mapstructure:"can_watch"`
	CanHost               bool `json:"can_host"                 mapstructure:"can_host"`
	CanShareMedia         bool `json:"can_share_media"          mapstructure:"can_share_media"`
	CanAccessClipboard    bool `json:"can_access_clipboard"     mapstructure:"can_access_clipboard"`
	SendsInactiveCursor   bool `json:"sends_inactive_cursor"    mapstructure:"sends_inactive_cursor"`
	CanSeeInactiveCursors bool `json:"can_see_inactive_cursors" mapstructure:"can_see_inactive_cursors"`

	// plugin scope
	Plugins map[string]any `json:"plugins"`
}

type MemberProvider

type MemberProvider interface {
	Connect() error
	Disconnect() error

	Authenticate(username string, password string) (id string, profile MemberProfile, err error)

	Insert(username string, password string, profile MemberProfile) (id string, err error)
	Select(id string) (profile MemberProfile, err error)
	SelectAll(limit int, offset int) (profiles map[string]MemberProfile, err error)
	UpdateProfile(id string, profile MemberProfile) error
	UpdatePassword(id string, password string) error
	Delete(id string) error
}

type MiddlewareHandler

type MiddlewareHandler func(w http.ResponseWriter, r *http.Request) (context.Context, error)

type PeerAudio added in v1.6.13

type PeerAudio struct {
	Disabled bool `json:"disabled"`
}

type PeerAudioRequest added in v1.6.13

type PeerAudioRequest struct {
	Disabled *bool `json:"disabled,omitempty"`
}

type PeerVideo added in v1.6.13

type PeerVideo struct {
	Disabled bool   `json:"disabled"`
	ID       string `json:"id"`
	Video    string `json:"video"` // TODO: Remove this, used for compatibility with old clients.
	Auto     bool   `json:"auto"`
}

type PeerVideoRequest added in v1.6.13

type PeerVideoRequest struct {
	Disabled *bool           `json:"disabled,omitempty"`
	Selector *StreamSelector `json:"selector,omitempty"`
	Auto     *bool           `json:"auto,omitempty"`
}

type Plugin

type Plugin interface {
	Name() string
	Config() PluginConfig
	Start(PluginManagers) error
	Shutdown() error
}

type PluginConfig

type PluginConfig interface {
	Init(cmd *cobra.Command) error
	Set()
}

type PluginManagers

type PluginManagers struct {
	SessionManager        SessionManager
	WebSocketManager      WebSocketManager
	ApiManager            ApiManager
	LoadServiceFromPlugin func(string) (any, error)
}

func (*PluginManagers) Validate

func (p *PluginManagers) Validate() error

type PluginMetadata added in v1.6.10

type PluginMetadata struct {
	Name         string
	IsDependable bool
	IsExposable  bool
	DependsOn    []string `json:",omitempty"`
}

type Router

type Router interface {
	Group(fn func(Router))
	Route(pattern string, fn func(Router))
	Get(pattern string, fn RouterHandler)
	Post(pattern string, fn RouterHandler)
	Put(pattern string, fn RouterHandler)
	Patch(pattern string, fn RouterHandler)
	Delete(pattern string, fn RouterHandler)
	With(fn MiddlewareHandler) Router
	Use(fn MiddlewareHandler)
	ServeHTTP(w http.ResponseWriter, req *http.Request)
}

type RouterHandler

type RouterHandler func(w http.ResponseWriter, r *http.Request) error

type Sample

type Sample struct {
	// buffer with encoded media
	Data   []byte
	Length int
	// timing information
	Timestamp time.Time
	Duration  time.Duration
	// metadata
	DeltaUnit bool // this unit cannot be decoded independently.
}

type SampleListener added in v1.6.9

type SampleListener interface {
	WriteSample(Sample)
}

type ScreenSize

type ScreenSize struct {
	Width  int
	Height int
	Rate   int16
}

func (ScreenSize) String added in v1.6.14

func (s ScreenSize) String() string

type ScreencastManager

type ScreencastManager interface {
	Enabled() bool
	Started() bool
	Image() ([]byte, error)
}

type Session

type Session interface {
	ID() string
	Profile() MemberProfile
	State() SessionState
	IsHost() bool
	PrivateModeEnabled() bool

	// cursor
	SetCursor(cursor Cursor)

	// websocket
	ConnectWebSocketPeer(websocketPeer WebSocketPeer)
	DisconnectWebSocketPeer(websocketPeer WebSocketPeer, delayed bool)
	DestroyWebSocketPeer(reason string)
	Send(event string, payload any)

	// webrtc
	SetWebRTCPeer(webrtcPeer WebRTCPeer)
	SetWebRTCConnected(webrtcPeer WebRTCPeer, connected bool)
	GetWebRTCPeer() WebRTCPeer
}

type SessionManager

type SessionManager interface {
	Create(id string, profile MemberProfile) (Session, string, error)
	Update(id string, profile MemberProfile) error
	Delete(id string) error
	Get(id string) (Session, bool)
	GetByToken(token string) (Session, bool)
	List() []Session

	SetHost(host Session)
	GetHost() (Session, bool)
	ClearHost()

	SetCursor(cursor Cursor, session Session)
	PopCursors() map[Session][]Cursor

	Broadcast(event string, payload any, exclude ...string)
	AdminBroadcast(event string, payload any, exclude ...string)
	InactiveCursorsBroadcast(event string, payload any, exclude ...string)

	OnCreated(listener func(session Session))
	OnDeleted(listener func(session Session))
	OnConnected(listener func(session Session))
	OnDisconnected(listener func(session Session))
	OnProfileChanged(listener func(session Session))
	OnStateChanged(listener func(session Session))
	OnHostChanged(listener func(session Session))
	OnSettingsChanged(listener func(new Settings, old Settings))

	UpdateSettings(Settings)
	Settings() Settings
	CookieEnabled() bool

	CookieSetToken(w http.ResponseWriter, token string)
	CookieClearToken(w http.ResponseWriter, r *http.Request)
	Authenticate(r *http.Request) (Session, error)
}

type SessionProfile added in v1.6.9

type SessionProfile struct {
	Id      string
	Token   string
	Profile MemberProfile
}

type SessionState

type SessionState struct {
	IsConnected bool `json:"is_connected"`
	// when the session was last connected
	ConnectedSince *time.Time `json:"connected_since,omitempty"`
	// when the session was last not connected
	NotConnectedSince *time.Time `json:"not_connected_since,omitempty"`

	IsWatching bool `json:"is_watching"`
	// when the session was last watching
	WatchingSince *time.Time `json:"watching_since,omitempty"`
	// when the session was last not watching
	NotWatchingSince *time.Time `json:"not_watching_since,omitempty"`
}

type Settings

type Settings struct {
	PrivateMode       bool `json:"private_mode"`
	LockedControls    bool `json:"locked_controls"`
	ImplicitHosting   bool `json:"implicit_hosting"`
	InactiveCursors   bool `json:"inactive_cursors"`
	MercifulReconnect bool `json:"merciful_reconnect"`

	// plugin scope
	Plugins map[string]any `json:"plugins"`
}

type StreamSelector added in v1.6.12

type StreamSelector struct {
	// type of stream selector
	Type StreamSelectorType `json:"type"`
	// select stream by its ID
	ID string `json:"id"`
	// select stream by its bitrate
	Bitrate uint64 `json:"bitrate"`
}

type StreamSelectorManager added in v1.6.12

type StreamSelectorManager interface {
	IDs() []string
	Codec() codec.RTPCodec

	GetStream(selector StreamSelector) (StreamSinkManager, bool)
}

type StreamSelectorType added in v1.6.12

type StreamSelectorType int
const (
	// select exact stream
	StreamSelectorTypeExact StreamSelectorType = iota
	// select nearest stream (in either direction) if exact stream is not available
	StreamSelectorTypeNearest
	// if exact stream is found select the next lower stream, otherwise select the nearest lower stream
	StreamSelectorTypeLower
	// if exact stream is found select the next higher stream, otherwise select the nearest higher stream
	StreamSelectorTypeHigher
)

func (StreamSelectorType) MarshalText added in v1.6.12

func (s StreamSelectorType) MarshalText() ([]byte, error)

func (StreamSelectorType) String added in v1.6.12

func (s StreamSelectorType) String() string

func (*StreamSelectorType) UnmarshalText added in v1.6.12

func (s *StreamSelectorType) UnmarshalText(text []byte) error

type StreamSinkManager

type StreamSinkManager interface {
	ID() string
	Codec() codec.RTPCodec
	Bitrate() uint64

	AddListener(listener SampleListener) error
	RemoveListener(listener SampleListener) error
	MoveListenerTo(listener SampleListener, targetStream StreamSinkManager) error

	ListenersCount() int
	Started() bool

	CreatePipeline() error
	DestroyPipeline()
}

type StreamSrcManager

type StreamSrcManager interface {
	Codec() codec.RTPCodec

	Start(codec codec.RTPCodec) error
	Stop()
	Push(bytes []byte)

	Started() bool
}

type VideoConfig

type VideoConfig struct {
	Width       string            `mapstructure:"width"`        // expression
	Height      string            `mapstructure:"height"`       // expression
	Fps         string            `mapstructure:"fps"`          // expression
	Bitrate     int               `mapstructure:"bitrate"`      // pipeline bitrate
	GstPrefix   string            `mapstructure:"gst_prefix"`   // pipeline prefix, starts with !
	GstEncoder  string            `mapstructure:"gst_encoder"`  // gst encoder name
	GstParams   map[string]string `mapstructure:"gst_params"`   // map of expressions
	GstSuffix   string            `mapstructure:"gst_suffix"`   // pipeline suffix, starts with !
	GstPipeline string            `mapstructure:"gst_pipeline"` // whole pipeline as a string
}

func (*VideoConfig) GetPipeline

func (config *VideoConfig) GetPipeline(screen ScreenSize) (string, error)

type WebRTCManager

type WebRTCManager interface {
	Start()
	Shutdown() error

	ICEServers() []ICEServer

	CreatePeer(session Session) (*webrtc.SessionDescription, WebRTCPeer, error)
	SetCursorPosition(x, y int)
}

type WebRTCPeer

type WebRTCPeer interface {
	CreateOffer(ICERestart bool) (*webrtc.SessionDescription, error)
	CreateAnswer() (*webrtc.SessionDescription, error)
	SetRemoteDescription(webrtc.SessionDescription) error
	SetCandidate(webrtc.ICECandidateInit) error

	SetPaused(isPaused bool) error
	Paused() bool

	SetVideo(PeerVideoRequest) error
	Video() PeerVideo
	SetAudio(PeerAudioRequest) error
	Audio() PeerAudio

	SendCursorPosition(x, y int) error
	SendCursorImage(cur *CursorImage, img []byte) error

	Destroy()
}

type WebSocketHandler

type WebSocketHandler func(Session, WebSocketMessage) bool

type WebSocketManager

type WebSocketManager interface {
	Start()
	Shutdown() error
	AddHandler(handler WebSocketHandler)
	Upgrade(checkOrigin CheckOrigin) RouterHandler
}

type WebSocketMessage

type WebSocketMessage struct {
	Event   string          `json:"event"`
	Payload json.RawMessage `json:"payload,omitempty"`
}

type WebSocketPeer

type WebSocketPeer interface {
	Send(event string, payload any)
	Ping() error
	Destroy(reason string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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