user2487382
user2487382

Reputation:

How ogg radio streaming works?

Recently I tried to understand how ogg vorbis works inside, so I wrote simple encoder/decoder for ogg vorbis. And now I'm trying to understand how all internet ogg radiostations work. And the thing I do not understand: if you need to process all 3 vorbis headers to know how to decode audio (channels, rate etc), how can they permanently stream audio and stream it from the random position of the track?

Upvotes: 4

Views: 1961

Answers (1)

Brad
Brad

Reputation: 163478

Ogg (Vorbis or otherwise) streams don't work by streaming from random positions in the track. This makes it a wrapper that is more difficult for internet radio servers, and why Ogg doesn't work on SHOUTcast servers.

To stream Ogg, the server must parse the initial Ogg frame headers from the source stream. When a new client connects, these frame headers are sent to the client before any new audio data. After this, the server begins sending frames for the current position in the stream, but it doesn't start randomly. It begins on a proper frame boundary.

You can see this behavior yourself. Start up an Icecast server with a source stream using Ogg with Vorbis or FLAC. Use Wireshark to capture packets from two different client connections started at different times. Then, compare the initial Ogg frames you get from the server. You will see two frames that set things up, followed by the frames in the middle of the stream.

Upvotes: 3

Related Questions