[HLSTree] New hls_ignore_endlist, hls_fix_mediasequence, hls_fix_discsequence params to fix faulty live services #1532
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.
Description
Plutotv its a good example of faulty live service that violates the HLS specifications in different ways (not all specified here)
by providing malformed data on variant child manifests:
EXT-X-DISCONTINUITY-SEQUENCE: has inconsistent number between manifest updates, for example on first downloaded manifest could be of value 2, on the next update become 0 or 1. A decreasing number is not allowed on sane HLS.
EXT-X-MEDIA-SEQUENCE: has inconsistent number between manifest updates, that cause impossibility to keep track of the sequence of segments between updates, i couldn't figure out if there is a logical pattern, because the numbers seem pretty random...
EXT-X-ENDLIST: make a wrong use of EXT-X-ENDLIST tag, sometimes the service send a manifest update without segments, and specifying this tag although the live stream is not ended, thereby forcing the stop of playback
EXT-X-PROGRAM-DATE-TIME: sometime there is not a precise value, so on first downloaded manifest there is X PTS value, on next manifest update X varies by some seconds, or also they replace the original value with others, this leads to any kind of side effect since the fixes are based on this
To "fix" this bad situation i have add these new parameters to
inputstream.adaptive.manifest_config
property:hls_ignore_endlist
: allow to ignore EXT-X-ENDLIST, there are two situationsfor the case 2, to mitigate buffering problems the time to perform the next manifest update is temporarily halved
hls_fix_mediasequence
: allow to try correct a malformed EXT-X-MEDIA-SEQUENCE value, the corrected value is determined by finding the corresponding segment in the updated playlist referring to the PTS value of the segment provided by the EXT-X-PROGRAM-DATE-TIME tag. so to use this paramenter it is strictly required that the manifest provides EXT-X-PROGRAM-DATE-TIME taghls_fix_discsequence
: allow to try correct a malformed EXT-X-DISCONTINUITY-SEQUENCE value, the corrected value is determined by checking whether a segment falls within an existing period if found use that sequence number to fix EXT-X-DISCONTINUITY-SEQUENCE in order to work EXT-X-PROGRAM-DATE-TIME tag is needed.However malformed manifest update can lead to any kind of playback oddities, such as segments played multiple times, or periods switched before the end of their playback, due to the impossibility of determining the right sequence number and segment to be played. In the worst case it will cause unexpected problems with Kodi VideoPlayer by freezing the playback either temporarily (a few seconds) or permanently.
Motivation and context
fix #1507
How has this been tested?
https://r.mjh.nz/PlutoTV/64b67f0424ade50008a3be17-alt.m3u8
played for more times until to catch ADS discontinuities
Screenshots (if appropriate):
Types of change
Checklist: