matrix-org / waterfall

A cascading stream forwarding unit for scalable, distributed voice and video conferencing over Matrix
Apache License 2.0
97 stars 5 forks source link

Make switching between layers seamless (without any freezes or artifacts) #100

Open daniel-abramov opened 1 year ago

daniel-abramov commented 1 year ago

Sometimes when we switch between layers, there is a freeze of up to 2 seconds. Sometimes instead of a frozen picture, one can observe a short glitch for half a second. This happens because when we switch between the layers, we must get a keyframe to ensure smooth playback. We do request a new keyframe, but it may take some time until we get one (2 RTT + processing).

We do not store the previous keyframes (and should not), however, what we could do is implement a logic where when we switch the layer, we continue to send frames on a previously selected layer (as if the layer was not switched) up until we get the new keyframe on a layer that we wanted to switch to. Once the keyframe is received, we switch to the newest layer.

That way there won't be any glitches observed during the switch.

I.e. when switching simulcast layers, we must make sure that the first packet after switch is a key frame