How to bridge byte array and audio streaming?

43 views
Skip to first unread message

Gintas Z

unread,
Jun 3, 2015, 11:35:11 AM6/3/15
to nod...@googlegroups.com
I'm creating a relay server for my streaming app. Basically, it should work like this:
 
   1. Client A streams microphone audio to server through sockets
   2. Server a gets stream and maybe stores it somewhere temporarily?(not sure)
   3. Client B gets a stream from server and plays it.

Basically, I have 1st part done(sending mic audio to server):

    while(isStreaming)
    {
        minBufSize = recorder.read(buffer, 0, buffer.length);
        mSocket.emit("stream", Arrays.toString(buffer));
    }

And 3rd part done, simply playing audio:

    mediaplayer.reset();
mediaplayer.setDataSource("http://192.168.1.2:1337/stream");
mediaplayer.prepare();
mediaplayer.start();

Now I'm not sure how to bridge incoming byte array and streaming. Here is my current server code:

    var ms = require('mediaserver');
    // from server to Client B
exports.letsStream = function(req, res, next) {
ms.pipe(req, res, "sample_song_music_file.mp3");
};

    // from Client A to 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 I directly stream that byte array?
Reply all
Reply to author
Forward
0 new messages