<div>Hello,</div><div> </div><div>I'm looking to implement an internet radio server that would serve up something similar to <a href="http://dir.xiph.org/by_format/Opus">http://dir.xiph.org/by_format/Opus</a> using the C libraries for working with opus. I tried looking at the Icecast source code, with no luck - it doesn't seem to depend on any of the opus libraries, but implements it itself (Although, I might be wrong). I'm not entirely sure of the format which is an opus stream that can be parsed by a web browser, because I tried a few things and none of them played. If there's a C example of something like this working, it would be very helpful. I just haven't found one yet.</div><div> </div><div>Thanks,</div><div> </div><div>-- Jeron A. Lau</div>
On 2019-12-26 9:07 a.m., Jeron Lau wrote:> I tried looking at the Icecast source > code, with no luck - it doesn't seem to depend on any of the opus > libraries, but implements it itself (Although, I might be wrong).IIRC icecast reimplements the few packet inspection functions it needs to avoid adding libopus as a dependency. It doesn't need to actually encode or decode so it saves a lot of unnecessary code in the deployed application. You can of course use the `opus_packet_*` functions from libopus instead. Icecast-style streaming encapsulates Opus packets in a Ogg container stream (like .opus files) according to https://tools.ietf.org/html/rfc7845.html which is then streamed over http. Some browsers can play .opus streams directly in an HTML Audio element. Others only support mp4 or webm encapsulation through the MediaSourceExtensions API; for those you can fetch the stream manually and re-mux in javascript. For browsers which don't support native Opus decoding you'll also have to decode in js. But if you've tried the dir.xiph.org streams, presumedly you have that part working ok. Icecast treats .opus streams pretty much the same as .ogg streams, copying out the most recent encapsulation pages it has received to connected clients. You can see some optimizations for better buffering in the libshout client library for uploading streams to the icecast server. https://gitlab.xiph.org/xiph/icecast-libshout/blob/master/src/codec_opus.c#L248 A simpler C client is available at https://r-w-x.org/r/oggfwd.git Hope that helps, -r