1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 16:45:58 +01:00

Delay adding tracks until connection is complete.

This avoids losing packets at the beginning of a connection.
This commit is contained in:
Juliusz Chroboczek 2020-10-06 02:41:18 +02:00
parent aa65164edd
commit 0eb1593bb8

View file

@ -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
}