diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -9,6 +9,7 @@ import ( "strconv" "github.com/gorilla/websocket" + "github.com/pion/logging" "github.com/pion/rtwatch/gst" "github.com/pion/webrtc/v2" ) @@ -21,6 +22,7 @@ var ( } peerConnectionConfig = webrtc.Configuration{} + webrtcApi = &webrtc.API{} audioTrack = &webrtc.Track{} videoTrack = &webrtc.Track{} @@ -46,7 +48,19 @@ func main() { } log.Println("Initializing WebRTC PeerConnection") - pc, err := webrtc.NewPeerConnection(webrtc.Configuration{ + + lf := logging.NewDefaultLoggerFactory() + lf.DefaultLogLevel = logging.LogLevelDebug + + se := webrtc.SettingEngine{ + LoggerFactory: lf, + } + me := webrtc.MediaEngine{} + me.RegisterDefaultCodecs() + + webrtcApi = webrtc.NewAPI(webrtc.WithMediaEngine(me),webrtc.WithSettingEngine(se)) + + pc, err := webrtcApi.NewPeerConnection(webrtc.Configuration{ ICEServers: []webrtc.ICEServer{ { URLs: []string{"stun:stun.l.google.com:19302"}, @@ -118,7 +132,7 @@ func serveWs(w http.ResponseWriter, r *http.Request) { defer ws.Close() - peerConnection, err := webrtc.NewPeerConnection(peerConnectionConfig) + peerConnection, err := webrtcApi.NewPeerConnection(peerConnectionConfig) if err != nil { log.Print(err) return |