m3u8
m3u8 copied to clipboard
add segments cap dynamic increase
Code works ok, but I prefer to keep ring-buffer based logic for playlist buffers. As we explored and used in software for my employer the ring-buffer convenient for live broadcasting. And the library works ok for that purpose. But the patch breaks this logic. Run this unit test for example:
func TestSlideOverflow(t *testing.T) {
p, e := NewMediaPlaylist(7, 8)
if e != nil {
panic(fmt.Sprintf("Create media playlist failed: %s", e))
}
for i := 0; i < 20; i++ {
p.Slide(fmt.Sprintf("test%d.ts", i), 5.1, "")
println(len(p.Segments)) // see current length here
}
p.DurationAsInt(true)
fmt.Println(p.Encode().String())
}
You will extend slice more and more though segments deleted on each Slide call. Then I prefer to have explicit call for selecting ring-buffer vs autoextended buffer.
I will accept your pull request and will adapt my code to accomplish it to keep both logic ring-buffer and autoextended buffer but please resend your patch to branch draft. So I'll include it to release 0.2.