Home

Awesome

raop-rtsp-server

An attempt to create a RAOP (AirTunes) server in Node.js.

This project is highly work-in-progress - use it at your own risk!

Known compatibility issues:

Build status js-standard-style

Installation

For standalone usage, run:

npm install --global raop-rtsp-server

For programmatic usage, run:

npm install raop-rtsp-server

CLI usage

If the speaker module can compile on your system (comes bundled with this module), you should just be able to start the server without any arguments:

raop-rtsp-server

If you'd rather pipe the PCM audio to another player, you can do so using the --stdout argument:

raop-rtsp-server --stdout | sox -traw -L -c2 -r44100 -b16 -e signed-integer - -tcoreaudio

See the Tips section below on how to install and use sox

Debugging

To run in debug mode, use the DEBUG environment variable:

DEBUG=* raop-rtsp-server

Or the less chatty:

DEBUG=raop-rtsp-server raop-rtsp-server

Programmatic usage

The module can also be access programmatically:

var server = require('raop-rtsp-server')

server.sessions.on('new', function (session) {
  session.on('data', function (chunk) {
    console.log('received %d audio bytes on session %s', chunk.length, session.id)
  })

  session.on('volume', function (volume) {
    console.log('the client changed the volume to %d dB', volume)
  })
})

server.start({ name: 'NodeTunes' })

The server.start() function takes an optional options object:

Session

The session object emitted by the new event is a readable stream and will output raw PCM audio data.

Properties

Events

Besides the normal readable stream API, the session also emits the following events:

volume

Emitted when ever the client changes the volume. The value emitted is the volume as a float value representing the audio attenuation in dB. It ranges from -30 (lowest) to 0 (highest). A special number -144 represents mute.

Tips

If using this module to output raw PCM audio to STDOUT, I've found the following useful:

I've tried quite a few different audio players but I've only managed to get sox to play back to PCM audio.

Install via Homebrew:

brew install sox

For sox to be able to interpret the raw ALAC audio data, you need to help it a little. These are the command line arguments given in the example above:

FFmpeg should also be able to parse PCM audio if you like that program better.

License

MIT