3

Can I use Websocket to send RTP over?

I assume Websocket is just a way to establish permanent TCP connection to another point and avoid message overhead. So, it seems I can use whatever it was possible to use over TCP. Is that sounds correct?

Misha Slyusarev
  • 1,353
  • 2
  • 18
  • 45

1 Answers1

4

Yes and no.

You can send any data over a websocket connection, but it will not be just like a TCP connection, as the other endpoint (i.e. server) needs to have logic to process the initial request and use the headers to establish the channel. Websockets use TCP, they are not like TCP.

Regarding the part about RTP packets and seeing that you added the tag webrtc, WebRTC can be used to create and send RTP packets, but the RTP packets and the connection is made by the browser itself. You cannot use WebRTC to pick the RTP packets and send them over a protocol of your choice, like WebSockets. You can refer to this other answer about this.

UPDATE

If you have an RTP packet in your Javascript code, you can send it over WebSocket (e.g. Base64 encoded). But the real problem is that you will not have RTP packets neither data to build them if you use WebRTC, as everything is inside the browser code and not accessible via JavaScript.

Community
  • 1
  • 1
nakib
  • 4,304
  • 2
  • 28
  • 39
  • Thanks, I understand it's not precisely the same as TCP. And I realize that it's possible to use WebRTC to send data out. But the question was more about do I really have to use WebRTC for media transport, or I can send data (RTP) over Websocket as well as, for example, SIP signalling? – Misha Slyusarev Sep 18 '13 at 07:48
  • As I said, you can send whatever you want via WebSockets. If you have an RTP packet in your Javascript code, you can send it over WebSocket (e.g. Base64 encoded). But the real problem is that you will not have RTP packets neither data to build them if you use WebRTC, as everything is inside the browser code and not accessible via JavaScript. – nakib Sep 18 '13 at 08:03
  • Yeah, I know I can't get data from WebRTC implementation to use in my JS, that understood too. You answered the question anyway. I will update your message to put there the sentence that answers my question. – Misha Slyusarev Sep 18 '13 at 08:21