This is more a conceptual question rather than a direct "how to do this".
Is it generally possible to implement a flash-like solution to stream the audio (independent of where we get the stream data from, e.g. webRTC or other) in HTML5 and nodeJS/binaryJS. If so, how would you go about this?
There has been only one inquire on stackoverflow found here and its from 2010. NodeJS and HTML5 have grown and matured since then.
What people usually do: When using multimedia streaming (i.e. video or audio) to a server, there is definitely nothing that beats Flash at the current point in time till the full arrival of getUserMedia() - which quite honestly might take a while till 99% of the browser users will get to use it at all.
General practice to stream data to the server is by using a client Flash or Flex application which is then connecting to a RTMP protocol powered media server like RED5, FMS or Wowza. For example, the client app sending the microphone input over RTMP could look like (simplified version)
import flash.net.NetStream;
private var myMic:Microphone;
private var nc:NetConnection;
private var ns:NetStream
nc = new NetConnection();
ns = new NetStream(nc);
nc.connect(rtmp://localhost/serverApp);
myMic = Microphone.getMicrophone();
ns.attachAudio(myMic);
Together with a server application one is easibly able to stream data to the server.
What I would like to do: Have an app server running on nodeJS (possibly implementing socketIO and binaryJS) that catches the incoming RTMP stream. Something like
//require
var rtmp = require('node-rtmp'),
var fs = require('fs');
//rtmp server address
var rtmpServer = 'rtmp://localhost';
//create a binary server listening that receives stream data
var RTMPServer = rtmp.RTMPServer();
var server = RTMPServer ({port: 1935});
server.on('connection', function(client){
//check if user is allowed to do so
rtmp.newStream(client.stream);
});
Possibly it might be better to use socketIO to differentiate between user interactions via eventEmitters.
What might be the advantages: Generally speaking it seems like a bit overhead to make this kind of approach, but for me there might be advantages and I'd also like you to comment on this.
- easy validation of user interaction by running e.g. express and socketIO
- hybrid implementation of a flash (via RTMP) and getUserMedia() (via binary transport mechanisms by adding binaryJS and the Mozilla AudioAPI)
- if getUserMedia() gets fully supported, flash implementations can be dropped easily
- more control over the rtmp followup and user interaction in general
- easier implementation into server frameworks
UPDATE: I've talked to Mr. Malcontenti-Wilson who is responsible for the only node-rtmp package that was written but discontinued 8 months ago as it was poorly written and he hit a roadblock. Anyone who used this or was able to check the code?
UPDATE 2: Mr. Malcontenti-Wilson just send me a mail to get my attention to node-mtrude (kind of an odd name) which is doing kind of what we would probably want. Has anyone work with this kind of package?