neko/pkg/types/webrtc.go
Miroslav Šedivý 6067367acd
Capture bandwidth switch (#14)
* Handle bitrate change by finding the stream with closest bitrate as peer

* Convert video id into bitrate when creating peer or changing bitrate

* Try to fix prometheus panic

* Revert metrics label name change

* minor fixes.

* bitrate selector.

* skip if moving to the same stream.

* no closure for getting target bitrate.

* fix: high res switch to lo video, stream bitrate out of range

* revert dev config change.

* white space.

Co-authored-by: Aleksandar Sukovic <aleksandar.sukovic@gmail.com>
2022-10-25 20:25:00 +02:00

46 lines
1.1 KiB
Go

package types
import (
"errors"
"github.com/pion/webrtc/v3"
)
var (
ErrWebRTCDataChannelNotFound = errors.New("webrtc data channel not found")
ErrWebRTCConnectionNotFound = errors.New("webrtc connection not found")
)
type ICEServer struct {
URLs []string `mapstructure:"urls" json:"urls"`
Username string `mapstructure:"username" json:"username,omitempty"`
Credential string `mapstructure:"credential" json:"credential,omitempty"`
}
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 WebRTCManager interface {
Start()
Shutdown() error
ICEServers() []ICEServer
CreatePeer(session Session, bitrate int) (*webrtc.SessionDescription, error)
SetCursorPosition(x, y int)
}