Commit 0eb1593b authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Delay adding tracks until connection is complete.

This avoids losing packets at the beginning of a connection.
parent aa65164e
......@@ -520,9 +520,21 @@ func gotAnswer(c *webClient, id string, answer webrtc.SessionDescription) error
log.Printf("ICE: %v", err)
}
for _, t := range down.tracks {
t.remote.AddLocal(t)
add := func() {
down.pc.OnConnectionStateChange(nil)
for _, t := range down.tracks {
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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment