Skip to content

Commit b98ec3b

Browse files
committed
Force VP8/Opus in sfu-ws
Chrome is generate answers that then fail with SetLocalDescription. Haven't been able to find the issue yet
1 parent d9ca384 commit b98ec3b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

sfu-ws/main.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,26 @@ func websocketHandler(w http.ResponseWriter, r *http.Request) {
229229
// When this frame returns close the Websocket
230230
defer c.Close() //nolint
231231

232+
// Create a MediaEngine object to configure the supported codec
233+
m := &webrtc.MediaEngine{}
234+
235+
// Setup the codecs you want to use.
236+
// We'll use a VP8 and Opus but you can also define your own
237+
if err := m.RegisterCodec(webrtc.RTPCodecParameters{
238+
RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeVP8, ClockRate: 90000, Channels: 0, SDPFmtpLine: "", RTCPFeedback: nil},
239+
PayloadType: 96,
240+
}, webrtc.RTPCodecTypeVideo); err != nil {
241+
panic(err)
242+
}
243+
if err := m.RegisterCodec(webrtc.RTPCodecParameters{
244+
RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeOpus, ClockRate: 48000, Channels: 2, SDPFmtpLine: "minptime=10; useinbandfec=1", RTCPFeedback: nil},
245+
PayloadType: 111,
246+
}, webrtc.RTPCodecTypeAudio); err != nil {
247+
panic(err)
248+
}
249+
232250
// Create new PeerConnection
233-
peerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})
251+
peerConnection, err := webrtc.NewAPI(webrtc.WithMediaEngine(m)).NewPeerConnection(webrtc.Configuration{})
234252
if err != nil {
235253
log.Print(err)
236254
return

0 commit comments

Comments
 (0)