node.js - How to bridge byte array and audio streaming? -


i'm creating relay server streaming app. basically, should work this:

  1. client streams microphone audio server through sockets
  2. server gets stream , maybe stores somewhere temporarily?(not sure)
  3. 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:

  1. https://www.npmjs.com/package/microphone read microphone audio byte stream.
  2. 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.
  3. use https://github.com/tootallnate/node-speaker play incoming pcm data stream on client b

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -