Comcast / mamba

Mamba is a Swift iOS, tvOS and macOS framework to parse, validate and write HTTP Live Streaming (HLS) data.
Apache License 2.0
182 stars 40 forks source link

Playlists should be "Master" and "Variant" flavored #5

Closed dcoufal closed 5 years ago

dcoufal commented 6 years ago

Description

Right now, all HLS playlists are HLSPlaylist type. You can tell if a playlist is master or variant by inspecting the type.

However, there are weak typing issues in HLSPlaylist. The mediaSegmentGroups and all the HLSPlaylistTimelineTranslator don't really make sense unless the playlist is a Variant. Also, this situation leads to a lot of:

guard playlist.type == .master else {
    // exit with an error, exception and possibly an assert
}

which could be avoided with strong typing.

Tasks

It's not 100% clear what the correct solution is. Perhaps the HLSParser could have two success callbacks, one for master and one for variant playlists.

Most functionality should be shared between HLSMasterPlaylist and HLSVariantPlaylist. It's only mediaSegmentGroups and HLSPlaylistTimelineTranslator that are specific to HLSVariantPlaylist. I would imagine that HLSMasterPlaylist could have some specific functionality to deal with #EXT-X-STREAM-INF tags paired with variant urls (similar to mediaSegmentGroups).

We should have an agreement about architecture before going forward.

This will be a large architectural change.