Fix multiperiod
Created by: dsilhavy
This PR aims to fix multiple issues with multiperiod streams. The changes are mainly based on test content specified in #2946 (closed). #2946 (closed) also contains comments on the changes included in this PR. To summarize:
- Prebuffering of the new period now starts when audio and video of the previous period are finished buffering
- dash.js now prebuffers multiple upcoming periods. The problem before was that dash.js was only prebuffering a single period which lead to problems and playback stalling for short periods
- While prebuffering the new period the Sourcebuffer.timestampOffset was overwritten by the current period. This is fixed now.
- Use appendWindowStart and appendWindowEnd to set buffer ranges according to Period@start and period durations.
- Improve gap handling: Do not wait for playback to stall but instead actively jump over gaps in the timeline prior to reaching them
- Adjusted the InsufficientBufferRule in order to set the same buffer target for audio and video. This enables us to prebuffer multiple periods as we wait for all buffers to be filled before starting the prebuffering.
- Added support for period switch when the upcoming periods can not be prebuffered. In this case stream will stall and the gap handler will jump to the end of the current period, initiating a period switch to the upcoming period. Transition will not be as smooth as when the content is prebuffered
- Added gap jump at playback start
- Avoid endless loop if no live edge could be calculated because of a missing DVR window for ad periods.
- Fixed various minor issues for instance related to rounding of values