untangledco / streaming

Media streaming and broadcast systems in Go
https://twitch.tv/untangledco
ISC License
82 stars 5 forks source link

m3u8: Encode() is really big, could extract Playlist.Variants logic #9

Closed ollytom closed 3 months ago

ollytom commented 3 months ago

The same idea as #7. Say we have a Variant:

v := Variant{
    Bandwidth: 1280000,
    Video: "low",
    URI: "low/main/audio-video.m3u8"
}

we want a function that can take that structure and return a string that would be inserted into a playlist, like:

#EXT-X-STREAM-INF:BANDWIDTH=1280000,VIDEO="low"
low/main/audio-video.m3u8

I think we have most of that implemented but we aren't testing it in isolation. Some function like

TestWriteVariant(t *testing.T) {}

will make it much easier to add test cases: both ones that are valid EXT-X-STREAM-INF tags, and invalid ones too.

For more examples, see m3u8/testdata/master.m3u8