node.js - How to bridge byte array and audio streaming? -
i'm creating relay server streaming app. basically, should work this:
- client streams microphone audio server through sockets
- server gets stream , maybe stores somewhere temporarily?(not sure)
- client b gets stream server , plays it.
basically, have 1st part done(sending mic audio server):
while(isstreaming) { minbufsize = recorder.read(buffer, 0, buffer.length); msocket.emit("stream", arrays.tostring(buffer)); }
and 3rd part done, playing audio:
mediaplayer.reset(); mediaplayer.setdatasource("http://192.168.1.2:1337/stream"); mediaplayer.prepare(); mediaplayer.start();
now i'm not sure how bridge incoming byte array , streaming. here current server code:
var ms = require('mediaserver'); // server client b exports.letsstream = function(req, res, next) { ms.pipe(req, res, "sample_song_music_file.mp3"); }; // client server exports.handlesocketconnection = function(socket) { console.log("connected"); socket.on('stream', function(data) { var bytes = json.parse(data); console.log("getting stream:" + bytes); }); }
any suggestions? how can directly stream byte array?
the mediaserver module supports streaming existing audio, rather "live" stream. won't work.
one way achieve 3 tasks be:
- https://www.npmjs.com/package/microphone read microphone audio byte stream.
- http://binaryjs.com/ handle transmitting byte stream on websockets server , sending client. if have 2 separate paths set up, 1 sending data, 1 receiving. send data 1 stream other.
- use https://github.com/tootallnate/node-speaker play incoming pcm data stream on client b
Comments
Post a Comment