stream.hls: implement media initialization section #3828
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.
Resolves #3328
Resolves #3403
This implements the "Media Initialization Section" of HLS segments (via the
EXT-X-MAP
HLS tag) which is required for streams which use the fragmented MPEG-4 format (or MPEG2-TS with optional initialization sections). Think of it as segment headers which are loaded from an external source.This simply means that if a map exists, we always have to write the map contents (the segment initialization section) to the output stream before writing the actual segment contents, regardless the used format.
Split into two commits:
All namedtuples are now typed, which makes referencing data much easier. What still needs to be done in the future is implementing all missing and new tag attributes from newer HLS versions according to RFC8216.
The map content requests all get cached with a max cache number equal to the number of writer threads, so that it doesn't have to re-request the initialization section(s) every time when downloading a new segment.
The changes should also include a fix for the wonky test coverage results, which were unstable in the SegmentedStreamWriter due to the threading and queue polling. It simply disables coverage on those parts.
Other subclasses of SegmentedStreamWriter should not be affected by these changes unless they override
queue()
orput()
, but that is not the case.