Smooth period transition
Created by: aescarcha
This PR introduces buffer reuse for compatible codecs and preload of next periods to avoid jumps and freezes when switching periods.
It also introduces some changes to the SourceBufferSink to handle the appends and removes with a queue.
It's the same as #2575 but with clearer commit history. Closes #1708 (closed)