4

I am a newbie to WebRtc. I would like to send the media stream from client ( java script) to my server (via websockets). In my server I will be doing some processing on those media content.

Could you please show me a client code snippet on sending media stream to Server via websocket.

Thanks Ganesh.R

Ganesh R
  • 123
  • 2
  • 10

1 Answers1

3

Nobody can show you this, because you cannot send the stream via Websockets. You need to read a little more about WebRTC.

WebRTC give you the possibility to request access to media devices from Javascript, and allows you to create a PeerConnection that will establish a connection to another endpoint to send the streams captured from the devices or some raw data (using DataChannel). You won't have access to the streams data to send via WebSockets. Instead, the browser will send it over UDP or TCP using the SRTP protocol. If you want to get media streams on server side, you will need to implement this protocol and some negotiation to establish the connection.

HTML5Rocks have a great introduction with code snippets to start.

nakib
  • 4,304
  • 2
  • 28
  • 39
  • Thanks for your response , you mean to say the server should send back the IceCandidate Message containing the SERVER IP and PORT No. So the packets will be streamed to server. Or in other words it has to act as another peer in between. – Ganesh R Aug 22 '13 at 07:15
  • Yes, the server needs to be aware of the client candidates and try them all, and in it needs to send a new SDP, with its own candidates for the browser. – nakib Aug 22 '13 at 08:54
  • 1
    To say that nobody can show this is incorrect, here is an example how this is done over WebSocket without the need of adding TURN/STUN servers https://www.mux.com/blog/the-state-of-going-live-from-a-browser – Awad Jun 04 '22 at 16:04