Delay adding tracks until connection is complete.
This avoids losing packets at the beginning of a connection.
This commit is contained in:
@@ -520,9 +520,21 @@ func gotAnswer(c *webClient, id string, answer webrtc.SessionDescription) error
|
|||||||
log.Printf("ICE: %v", err)
|
log.Printf("ICE: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add := func() {
|
||||||
|
down.pc.OnConnectionStateChange(nil)
|
||||||
for _, t := range down.tracks {
|
for _, t := range down.tracks {
|
||||||
t.remote.AddLocal(t)
|
t.remote.AddLocal(t)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
down.pc.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
|
||||||
|
if state == webrtc.PeerConnectionStateConnected {
|
||||||
|
add()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if down.pc.ConnectionState() == webrtc.PeerConnectionStateConnected {
|
||||||
|
add()
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user