[EPIC] Live streaming
After my last, unfortunate attempt with https://github.com/ant-media/Ant-Media-Server/issues/579, to implement live audio streaming in Funkwhale, I have a better idea of a possible setup that could work.
My idea is to leverage Icecast, to handle the audio streaming part. This software is stable, maintained and exist for years, and trying to reimplement our own streaming system cannot end well.
Icecast support a so-called Yellow Page feature which icecast servers can use to notify arbitrary directories of Stream metadata (name, audio codecs, etc.) and status (up, down, etc.).
The reference implementation of such a directory is open-source and available at https://github.com/xiph/Icecast-directory/.
Based on those asumptions, we can design a rather scalable and simple streaming system.
Icecast configuration
Configuration on Icecast side would be extremely simple. The only step would be to add this snippet to the server configuration:
<directory>
<yp-url>https://funkwhale.domain/api/icecast/yp/unique-token</yp-url>
</directory>
The https://funkwhale.domain/api/icecast/yp/unique-token
url would be user-specific and provided in Funkwhale's UI. Having a unique, per-user URL is useful for anti-abuse / blocking unwanted streams.
Streamer workflow
We assume the streamer has access to an icecast server configured as described previously, and is able to stream on this server.
Nothing Funkwhale-specific happen here, but Icecast is smart enough to notify Funkwhale that the stream exist and it's up thanks to the previous configuration.
User workflow
Since the Funkwhale instance is aware of the existence of the stream, if can display it in the UI. Users can list streams and start them. Technically, an <audio>
tag is enough (example: http://dir.xiph.org/) to load the stream in the user browser.
Considerations
- Funkwhale only stream metadata, and audio content is served from the icecast server. This is more scalable than having Funkwhale serving the content directly, and Icecast support relaying to increase scalability even more
- Funkwhale could federate stream metadata to improve stream discovery
- We can leverage most if not all of Icecast features using this architecture, such as password-protected streams, because there's nothing between the client and the icecast server
- Streamers UX is not as good as on concurrent services, like Twitch, because we assume streamer have access to an Icecast server, which is not trivial to install. However, we could provide documentation for installing one, or redirect people to hosted Icecast providers