mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
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:
@ -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 {
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user