Refactor signaling for video and audio (#51)

* add audio and signal request.

* disable audio by default.

* fix SignalProvide.

* disable estimator when track disabled.
This commit is contained in:
Miroslav Šedivý
2023-06-26 21:27:14 +02:00
committed by GitHub
parent cf17f4f503
commit e3e9d1606d
9 changed files with 253 additions and 106 deletions

View File

@ -94,11 +94,11 @@ func (s StreamSelectorType) MarshalText() ([]byte, error) {
type StreamSelector struct {
// type of stream selector
Type StreamSelectorType
Type StreamSelectorType `json:"type"`
// select stream by its ID
ID string
ID string `json:"id"`
// select stream by its bitrate
Bitrate uint64
Bitrate uint64 `json:"bitrate"`
}
type StreamSelectorManager interface {

View File

@ -17,6 +17,7 @@ const (
SIGNAL_PROVIDE = "signal/provide"
SIGNAL_CANDIDATE = "signal/candidate"
SIGNAL_VIDEO = "signal/video"
SIGNAL_AUDIO = "signal/audio"
SIGNAL_CLOSE = "signal/close"
)

View File

@ -45,9 +45,19 @@ type SystemDisconnect struct {
// Signal
/////////////////////////////
type SignalRequest struct {
Video types.PeerVideoRequest `json:"video"`
Audio types.PeerAudioRequest `json:"audio"`
Auto bool `json:"auto"` // TODO: Remove this
}
type SignalProvide struct {
SDP string `json:"sdp"`
ICEServers []types.ICEServer `json:"iceservers"`
Video types.PeerVideo `json:"video"`
Audio types.PeerAudio `json:"audio"`
}
type SignalCandidate struct {
@ -59,8 +69,11 @@ type SignalDescription struct {
}
type SignalVideo struct {
Video string `json:"video"`
Auto bool `json:"auto"`
types.PeerVideoRequest
}
type SignalAudio struct {
types.PeerAudioRequest
}
/////////////////////////////

View File

@ -18,18 +18,40 @@ type ICEServer struct {
Credential string `mapstructure:"credential" json:"credential,omitempty"`
}
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"`
}
type WebRTCPeer interface {
CreateOffer(ICERestart bool) (*webrtc.SessionDescription, error)
CreateAnswer() (*webrtc.SessionDescription, error)
SetRemoteDescription(webrtc.SessionDescription) error
SetCandidate(webrtc.ICECandidateInit) error
SetVideo(StreamSelector) error
VideoID() (string, bool)
SetPaused(isPaused bool) error
Paused() bool
SetVideoAuto(auto bool)
VideoAuto() bool
SetVideo(PeerVideoRequest) error
Video() PeerVideo
SetAudio(PeerAudioRequest) error
Audio() PeerAudio
SendCursorPosition(x, y int) error
SendCursorImage(cur *CursorImage, img []byte) error