grafov / m3u8

Parser and generator of M3U8-playlists for Apple HLS. Library for Go language. :cinema:
http://tools.ietf.org/html/draft-pantos-http-live-streaming
BSD 3-Clause "New" or "Revised" License
1.22k stars 312 forks source link

Doesn't handle "Alternatives" correctly inside a master playlist's "variants" #191

Open sjpotter opened 1 year ago

sjpotter commented 1 year ago

From a few cursory tests, it seems it doesn't handle variants correctly in 2 ways..

1) it only adds the Alternatives to the first media playlist it fills in as a variant. 2) If the alternatives are at the end of the m3u8, none of them get it.

It would seem the fix would be to only accuulate "alternatives" until the file has been fully parsed, and then to use the accuulated alternatives to each Variant.

Another possible fix would be to simply not include the Alternatives in the Variant, but have them at the same level in the struct as the Variants array.

This assume that "EXT-X-MEDIA" can be really anywhere in the file, its possible that they should always be before the the media playlist reference, but in practce I have seen files that have them at the top and at the bottom. The first issue I saw with the file at the top, while the second issue with them at the bottom)).