neko/pkg/types/webrtc.go

71 lines
1.7 KiB
Go
Raw Normal View History

package types
2021-08-29 17:09:13 +02:00
import (
"errors"
"github.com/pion/webrtc/v3"
)
var (
ErrWebRTCDataChannelNotFound = errors.New("webrtc data channel not found")
2022-02-10 00:12:30 +01:00
ErrWebRTCConnectionNotFound = errors.New("webrtc connection not found")
ErrWebRTCStreamNotFound = errors.New("webrtc stream not found")
2021-08-29 17:09:13 +02:00
)
2021-02-02 19:21:48 +01:00
2021-03-17 15:47:49 +01:00
type ICEServer struct {
URLs []string `mapstructure:"urls" json:"urls"`
2021-03-19 11:28:06 +01:00
Username string `mapstructure:"username" json:"username,omitempty"`
Credential string `mapstructure:"credential" json:"credential,omitempty"`
2021-03-17 15:47:49 +01:00
}
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 struct {
Disabled *bool `json:"disabled,omitempty"`
Selector *StreamSelector `json:"selector,omitempty"`
Auto *bool `json:"auto,omitempty"`
}
type PeerAudio struct {
Disabled bool `json:"disabled"`
}
type PeerAudioRequest struct {
Disabled *bool `json:"disabled,omitempty"`
}
2020-11-25 18:41:40 +01:00
type WebRTCPeer interface {
CreateOffer(ICERestart bool) (*webrtc.SessionDescription, error)
2021-11-28 18:36:47 +01:00
CreateAnswer() (*webrtc.SessionDescription, error)
2023-04-16 23:34:02 +02:00
SetRemoteDescription(webrtc.SessionDescription) error
SetCandidate(webrtc.ICECandidateInit) error
2021-02-12 22:13:55 +01:00
2022-03-26 23:20:38 +01:00
SetPaused(isPaused bool) error
Paused() bool
SetVideo(PeerVideoRequest) error
Video() PeerVideo
SetAudio(PeerAudioRequest) error
Audio() PeerAudio
2022-03-26 23:20:38 +01:00
2021-02-12 22:13:55 +01:00
SendCursorPosition(x, y int) error
SendCursorImage(cur *CursorImage, img []byte) error
2021-02-02 20:43:33 +01:00
2021-08-29 19:17:10 +02:00
Destroy()
2020-11-25 18:41:40 +01:00
}
type WebRTCManager interface {
Start()
Shutdown() error
2021-02-02 19:21:48 +01:00
2021-03-17 15:47:49 +01:00
ICEServers() []ICEServer
2021-02-02 19:21:48 +01:00
CreatePeer(session Session) (*webrtc.SessionDescription, WebRTCPeer, error)
2022-07-21 18:28:51 +02:00
SetCursorPosition(x, y int)
}