Files
plugin-webrtc/io.go
langhuihui f238d63dd3 feat: add screenshare
feat: add camera selector

desc: 增加屏幕分享和摄像头选择功能
2023-06-16 22:43:10 +08:00

30 lines
621 B
Go

package webrtc
import (
. "github.com/pion/webrtc/v3"
)
type WebRTCIO struct {
*PeerConnection
SDP string
// LocalSDP *sdp.SessionDescription
}
func (IO *WebRTCIO) GetAnswer() (string, error) {
// Sets the LocalDescription, and starts our UDP listeners
answer, err := IO.CreateAnswer(nil)
if err != nil {
return "", err
}
// IO.LocalSDP, err = answer.Unmarshal()
// if err != nil {
// return "", err
// }
gatherComplete := GatheringCompletePromise(IO.PeerConnection)
if err := IO.SetLocalDescription(answer); err != nil {
return "", err
}
<-gatherComplete
return IO.LocalDescription().SDP, nil
}