neko/internal/webrtc/peer.go
Miroslav Šedivý 5d906e0a8b major refactor.
2020-11-01 16:09:48 +01:00

29 lines
627 B
Go

package webrtc
import (
"github.com/pion/webrtc/v2"
)
type PeerCtx struct {
api *webrtc.API
engine *webrtc.MediaEngine
settings *webrtc.SettingEngine
connection *webrtc.PeerConnection
configuration *webrtc.Configuration
}
func (peer *PeerCtx) SignalAnswer(sdp string) error {
return peer.connection.SetRemoteDescription(webrtc.SessionDescription{
SDP: sdp,
Type: webrtc.SDPTypeAnswer,
})
}
func (peer *PeerCtx) Destroy() error {
if peer.connection == nil || peer.connection.ConnectionState() != webrtc.PeerConnectionStateConnected {
return nil
}
return peer.connection.Close()
}