stream.hls: reload playlist in strict intervals #5321
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make
HLSStreamWorker
reload the playlist in strict time intervals instead of just queuing the next playlist reload.Previously, playlist fetch time and segment processing time always added to the overall reload time, resulting in an eventual shift of the expected reload time, which could lead to an empty segment queue in certain scenarios (live-edge=1 or Twitch low latency streaming).
When the reload time exceeds the expected reload interval, continue with the shifted interval, which matches the old behavior.
Resolves #4646
That could be changed, so that if a playlist reload takes too long, the next one could start immediately. I am not sure though if that's a good idea, because depending on the response data and the timing of when the data was generated by the server, no new segments could be included in the next response. And if one request takes more than two intervals, then the next x playlist reloads will be done immediately one after another, and that doesn't sound right.
Opening this as a draft for now, because I want to test this a bit first...
Tests are a bit complicated, but that's because of the playlist reload iteration with the timing involved, and that's always messy. I tried to write this as comprehensible as possible.
The timestamps of the playlist reloads now don't get shifted (example with playlist reload time of 2s):
master: