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.
Our support for the HLS spec is incomplete: it's based on which parts of the spec I saw >1 year ago when connected to a mediamtx endpoint. For instance, we do not support multi-index playlists yet, just single index / single playlist streams.
Another part of the spec we didn't support was BYTERANGEs - i.e. instead of each segment being different files, they can be byte ranges in a single file. Or different ranges in multiple files, or whatever.
I'm not sure if a mediamtx endpoint will ever use this, but it's possible and maybe even likely if they use a memory cache instead of a disk cache. However, it is used by most of the HLS samples I've been trying to test with, so supporting it is both future-proofing and making it easier to test.
The amount of change is large, but boils down to these things:
Full disclosure: this still doesn't totally work for samples because our cache tries to pre-load all segments, and samples tend to list all of them - potentially hours of video. For now I've put a TODO and some code in the parser that only loads at most 10 segments per index. We should never hit this in streaming, and for large samples it just means there's a temporary delay and only ~1 minute of video before it crashes. In the future we should preload a couple, then do the rest in the background or on demand.