Skip to content
Eric Richardson edited this page Jul 6, 2013 · 2 revisions

StreamMachine Components

The blue dotted line shows the approximate path of audio through StreamMachine. Master and slave could be running in one process when StreamMachine is running in standalone mode, or in different processes in a master-slave setup.

StreamMachine is divided into two major areas of functionality: Master and Slave.

Master

StreamMachine Master is in charge of coordinating the system as a whole, taking in source audio, handling configuration and hosting the admin interface.

Master.Stream

Master's Stream is primarily concerned with source management. It maintains a RewindBuffer that can be used for bringing new slaves up to speed.

StreamProxy

StreamProxy takes the master stream's "data" events and broadcasts them to all connected slaves.

StreamTransport

StreamTransport is an Express endpoint that allows slaves to load in a full RewindBuffer at startup.

SourceIn

The SourceIn module is the point-of-entry for new Icecast-compatible sources. It implements a basic parser that understands the "ICE/1.0" protocol that sources send, and understands how to validate the basic authorization header against the stream's password. Once a new source connection is validated, it sets up a new IcecastSource object and connects it to the stream.

IcecastSource

Despite the name, there's nothing especially Icecast about the handling of source audio. A parser is loaded, either MP3 or AAC depending on the stream's format setting. The incoming source audio is passed through the parser to break the stream into audio frames. Those frames are then queued into chunks of approximately the same duration (half a second, in the stock configuration) before being emitted as data events.

ProxyRoomSource

This is more of a development feature, but could be used in certain production setups. ProxyRoom is a source that connects to an existing Icecast stream, making the StreamMachine system into a proxy / multiplier. A ProxyRoom instance is created if a URL is filled in to the stream's "Fallback Source" setting.

RedisConfig

Currently, configuration information is persisted JSON-encoded into a single key in Redis. This will likely change in future versions of StreamMachine.

Logger

StreamMachine's Logger wraps the functionality of Winston, the logging framework from Flatiron. We implement some custom logging levels, a method for creating "child" logger instances that add parameters to the log message, and a few custom outputs. See the Logging page for full information.

Admin

The admin provides a basic UI and API for managing stream information. It also implements a simple user system for authentication.

Slave

StreamMachine Slave is the user-facing side of the system, handling all aspects of user connections and output.

Slave.Stream

Slave's Stream extends the RewindBuffer and adds functionality for tracking listener connections, disconnecting slow listeners and aggregating stats.

Slave.Server

Server is an Express endpoint that handles the gruntwork of taking listener connections and determining what output to route them to. See the Outputs page for discussion of the different output options.

Preroller

It is common in radio contexts to want to play a preroll clip to new listeners, often either an ad or a stream identifier. The Preroller module proxies a connection to an instance of StreamMachine's accompanying Preroller project, delivering the preroll audio before passing the user on to the output handling.