types

package
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 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")
)
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 BucketsManager added in v1.6.4

type BucketsManager interface {
	IDs() []string
	Codec() codec.RTPCodec
	SetReceiver(receiver Receiver) error
	RemoveReceiver(receiver Receiver) error
}

type CaptureManager

type CaptureManager interface {
	Start()
	Shutdown() error

	GetBitrateFromVideoID(videoID string) (int, error)

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

	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(x, y int)
	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() map[int]ScreenConfiguration
	SetScreenSize(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))

	// 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

	// filechooser
	HandleFileChooserDialog(uri string) error
	CloseFileChooserDialog()
	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
	Variant string
}

type KeyboardModifiers

type KeyboardModifiers struct {
	NumLock  *bool
	CapsLock *bool
}

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"`
	CanLogin              bool `json:"can_login"`
	CanConnect            bool `json:"can_connect"`
	CanWatch              bool `json:"can_watch"`
	CanHost               bool `json:"can_host"`
	CanShareMedia         bool `json:"can_share_media"`
	CanAccessClipboard    bool `json:"can_access_clipboard"`
	SendsInactiveCursor   bool `json:"sends_inactive_cursor"`
	CanSeeInactiveCursors bool `json:"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) (string, MemberProfile, error)

	Insert(username string, password string, profile MemberProfile) (string, error)
	Select(id string) (MemberProfile, error)
	SelectAll(limit int, offset int) (map[string]MemberProfile, 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 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 Receiver added in v1.6.4

type Receiver interface {
	SetStream(stream StreamSinkManager) error
	RemoveStream()
	OnBitrateChange(f func(int) error)
}

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
	WithBypass(fn func(next http.Handler) http.Handler) Router
	Use(fn MiddlewareHandler)
	UseBypass(fn func(next http.Handler) http.Handler)
	ServeHTTP(w http.ResponseWriter, req *http.Request)
}

type RouterHandler

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

type Sample

type Sample media.Sample

type ScreenConfiguration

type ScreenConfiguration struct {
	Width  int
	Height int
	Rates  map[int]int16
}

type ScreenSize

type ScreenSize struct {
	Width  int
	Height int
	Rate   int16
}

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
	SetWebSocketPeer(websocketPeer WebSocketPeer)
	SetWebSocketConnected(websocketPeer WebSocketPeer, connected bool, delayed bool)
	GetWebSocketPeer() WebSocketPeer
	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 SessionState

type SessionState struct {
	IsConnected bool `json:"is_connected"`
	IsWatching  bool `json:"is_watching"`
}

type Settings

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

type StreamSinkManager

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

	AddListener(listener *func(sample Sample)) error
	RemoveListener(listener *func(sample Sample)) error
	MoveListenerTo(listener *func(sample Sample), targetStream StreamSinkManager) error

	ListenersCount() int
	Started() bool
}

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) GetBitrateFn added in v1.6.4

func (config *VideoConfig) GetBitrateFn(getScreen func() *ScreenSize) func() (int, error)

func (*VideoConfig) GetPipeline

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

type WebRTCManager

type WebRTCManager interface {
	Start()
	Shutdown() error

	ICEServers() []ICEServer

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

type WebRTCPeer

type WebRTCPeer interface {
	CreateOffer(ICERestart bool) (*webrtc.SessionDescription, error)
	CreateAnswer() (*webrtc.SessionDescription, error)
	SetOffer(sdp string) error
	SetAnswer(sdp string) error
	SetCandidate(candidate webrtc.ICECandidateInit) error

	SetVideoBitrate(bitrate int) error
	GetVideoId() string
	SetPaused(isPaused bool) error

	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