I want to implement a simple server (C++) that generates (captures) video stream and sends it to a browser.
The question is: how should the server interact with a browser ?
I am considering a "HTTP Live Streaming (HLS)" technology as the simplest, because I have mastered of network/http interaction is work.
If I understood correctly:
I see I have lost logic here …
How to force the browser to get video chunks continuously ?
Maybe I am wrong about something above ? Could you explain me the basic steps ?
I am considering a "HTTP Live Streaming (HLS)" technology as the simplest, because I have mastered of network/http interaction is work.
It definitely isn't the simplest, in most cases. Handling a simple HTTP request and streaming a continuous stream is far easier. And then, the client side is just a <video>
element.
- the browser send GET request (?) to receive M3U8, gets a list of the chunks,
Correct.
- the next step is unclear - in stream (live) video is continuing - how the browser can know - which names of the next chunks ?
It downloads a fresh copy of the M3U8 playlist to figure out what's next.
How to force the browser to get video chunks continuously ?
HLS clients know to refresh the playlist. It's also possible to build a client to just "know" what segments will be next. For instance, if you had a sequential list, there's no reason for the client to keep requesting the playlist over and over again.
Sequential playlists have some gotchas though, around negative caching. If you use a CDN, turn off caching for any non-ok response because someone might hit your segment URLs before they are ready, causing your CDN to assume they will never exist.