I am trying to get the audio through getUserMedia() using webrtc and using socket.io to send it to server(socket.io support audio , video , binarydata) and then server will broadcast it to all connected clients. The problem is when stream reaches connected clients it is converted into JSON object not media stream object. So I am unable to send audio I have also tried socket.io-stream module but I it was not succesfull. Can you please help me to capture audio stream properly and sending it to all connected clients.
Here is code of client who sends data
navigator.getUserMedia({audio: true, video: false}, function(stream) {
video.src = window.URL.createObjectURL(stream);
webcamstream = stream;
media = stream; /// here the datatype of media is mediaStream object
socket.emit("sendaudio", media);
}, function(e){
console.log(error);
});
While on receiving client the code is as follows
socket.on('receiveaudio' , function(media)
{
console.log(media); //but here i am receiving it as a simple object
other.src= media;
});
Buffer
orBlob
objects. Socket.io supports binary data since 1.0. Try to convert you mediaStream object to a buffer and then send it. On the other side, recreate the object based on the buffer. – Maxime Piraux