[opus] Opus Radio Stream

Ralph Giles giles at thaumas.net
Thu Dec 26 17:43:23 UTC 2019


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


More information about the opus mailing list