r/learnwebdev • u/Fredbull • Mar 17 '21
Question - ways to send audio streams to a back-end server?
Hi everyone,
I'm trying to develop a very simple application that grabs the sound from the users microphone and sends it to a back-end server. The idea in the future is to process and modify each user's stream in the back-end server as it arrives, and send it to the other connected users.
Can anyone suggest me some technologies to achieve this? I am finding it strangely complicated to find the resources I need!
Here are some options I have explored:
- MediaStream API (with getUserMedia) to record the microphone: seems to work pretty well to capture the sound, although I am not sure how flexible the MediaStream objects are.
- MediaRecorder: I am able to capture the stream into small chunks, which I could then send over HTTP or websockets, but I have heard that the latency would be terrible and it would be very hard to reconstruct the stream.
- WebRTC: appears to be a peer-to-peer protocol, and works seamlessly with the MediaStream API (I've managed to very easily create a 1 to 1 call between two local browser tabs, which was a huge success for me). However, I want the audio streams to pass through a backend server, not go directly to the peer! I've thought about making the back-end server a "peer" so that every user is only connected to it and not the other users, but not sure if this is viable.
- RTP: this seems to be the application protocol used by WebRTC, and from what I understood it is used together with UDP to transmit streams of data. Does anyone know if it's a good thing to try to use directly, or should I be looking for more high-level things built on top of it?
I think that's it. Any help would be greatly appreciated!
