openairplay / node_airtunes

node.js AirTunes v2 implementation: stream wirelessly to Apple audio devices.
BSD 2-Clause "Simplified" License
273 stars 84 forks source link

Server? #8

Closed julien51 closed 11 years ago

julien51 commented 11 years ago

Hi!

It looks like this most acts as a client to send stuff to existing Airplay speakers. Any idea if it would be possible to do the other way around?

Create a speaker in node which would then receive data from airplay-ready players?

lperrin commented 11 years ago

Hey there, and sorry about the delay.

Having an AirPlay receiver in node.js would be great, and a lot of the logic of the client would translate on the server, but that was not the purpose of the project. I'll be glad to assist if you want to do it yourself, though.

julien51 commented 11 years ago

Laurent; you offered to assist, so I'm taking that offer :) Where would you start?

lperrin commented 11 years ago

Good to hear, and good luck to you !

First you need to make sure you understand how the protocol works. Then, you can check this project https://github.com/nto/AirSpeaker (Objective-C implementation).

The tricky thing is that the protocol supports synchronized playback to multiple outputs. Even if you don't actually support it (AirSpeaker does not), Apple devices won't speak to you unless you pretend to.

Then, here's your roadmap:

At this point, you'll get raw data that you need to decompress. You can use the ALAC sources included in the project. Use https://github.com/radioline/node_airtunes/blob/master/src/codec.cc as a reference to write the decoder. You don't need AES decryption, as long as you disable encryption.

At this point, you'll have PCM data that you can pipe to a file (to check if everything's ok). You need to write a module to play it on your host. There are already bindings for OSX CoreAudio.