@@ -14,7 +14,7 @@ import (
14
14
"github.com/kr/pty"
15
15
"github.com/maxmcd/webtty/pkg/sd"
16
16
"github.com/mitchellh/colorstring"
17
- "github.com/pion/webrtc/v2 "
17
+ "github.com/pion/webrtc/v3 "
18
18
)
19
19
20
20
type hostSession struct {
@@ -180,21 +180,34 @@ func (hs *hostSession) mustReadStdin() (string, error) {
180
180
func (hs * hostSession ) createOffer () (err error ) {
181
181
hs .pc .OnDataChannel (hs .onDataChannel ())
182
182
183
+ // Create unused DataChannel, the offer doesn't implictly have
184
+ // any media sections otherwise
185
+ if _ , err = hs .pc .CreateDataChannel ("offerer-channel" , nil ); err != nil {
186
+ log .Println (err )
187
+ return
188
+ }
189
+
183
190
// Create an offer to send to the browser
184
191
offer , err := hs .pc .CreateOffer (nil )
185
192
if err != nil {
186
193
log .Println (err )
187
194
return
188
195
}
189
196
197
+ // Create channel that is blocked until ICE Gathering is complete
198
+ gatherComplete := webrtc .GatheringCompletePromise (hs .pc )
199
+
190
200
err = hs .pc .SetLocalDescription (offer )
191
201
if err != nil {
192
202
log .Println (err )
193
203
return
194
204
}
195
205
206
+ // Block until ICE Gathering is complete
207
+ <- gatherComplete
208
+
196
209
hs .offer = sd.SessionDescription {
197
- Sdp : offer .SDP ,
210
+ Sdp : hs . pc . LocalDescription () .SDP ,
198
211
}
199
212
if hs .oneWay {
200
213
hs .offer .GenKeys ()
0 commit comments