bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
10.67k stars 1.39k forks source link

Web socket support for webrtc signaling server #3467

Open TimoKettunen opened 2 weeks ago

TimoKettunen commented 2 weeks ago

Describe the feature

Mediamtx integrates the webrtc signaling server but it supports only HTTP. Some clients work only with web socket interface for signaling server. Mediamtx should support also web socket interface for signaling server.

pikachu937 commented 2 weeks ago

Describe the feature

Mediamtx integrates the webrtc signaling server but it supports only HTTP. Some clients work only with web socket interface for signaling server. Mediamtx should support also web socket interface for signaling server.

it would be great

acris5 commented 1 week ago

I also need it

aler9 commented 1 week ago

Hello, WebSocket is a generic communication protocol like HTTP - in order to perform signaling, there must be a specification that describes how messages are formatted and what's their order.

Is anyone able to provide a document or a reference implementation that describes how to perform "signaling with WebSocket"? otherwise there are 2^N possible implementations, where N is a really big number. That's why WHIP / WHEP was standardized.

pikachu937 commented 1 week ago

Is anyone able to provide a document or a reference implementation that describes how to perform "signaling with WebSocket"?

please explain what does the specification have to do with it? in version 0.21.0 dated December 20, 2022, there was an implementation with websockets; in version 0.21.1 dated January 9, 2023, certain changes were made thanks to which webrtc began to work great. that is, in fact it WORKED

in version 1.0.0 you changed the technology and now there is only whep for watching broadcasts, but not everyone (especially mobile platforms) can work with it normally, but everyone knows how to work with webrtc via websockets perfectly

aler9 commented 1 week ago

@pikachu937 that signaling implementation worked with a non-standardized procedure that was more or less like this:

  1. a client connects through WebSocket to the server, without sending anything other than the initial WebSocket handshake
  2. server sends ICE servers in raw JSON
  3. server sends a SDP offer in raw SDP
  4. client replies with a SDP answer in raw SDP
  5. server sends any asynchronous ICE candidate in a custom JSON format
  6. client sends any asynchronous ICE candidate in a custom JSON format

The order and the format of each step is completely arbitrary and i'm pretty sure that there were no client libraries that worked in the same way. Are you able to provide a list of libraries that support the steps and order described above?

TimoKettunen commented 1 week ago

My original motivation was to have signaling work with Unity Render Streaming. WHEP is great and it is draft standard, unfortunately not supported by Unity. When I studied more, I understood that there is no standard way to do traditional webRTC signaling with HTTP or WebSocket. Unity made it one way and provided sample signaling server that implemented it. But the Chrome web browser was able to use it. Same thing with RTSPtoWebRTC, it implemented signaling bit differently and still browser was able to connect. So even there is no standard, browser code can handle different signaling methods. This feature request could be updated to "support traditional webRTC signaling that is compatible with browsers, Unity and ...(wish list)".

pikachu937 commented 1 week ago

@pikachu937 that signaling implementation worked with a non-standardized procedure that was more or less like this:

  1. a client connects through WebSocket to the server, without sending anything other than the initial WebSocket handshake
  2. server sends ICE servers in raw JSON
  3. server sends a SDP offer in raw SDP
  4. client replies with a SDP answer in raw SDP
  5. server sends any asynchronous ICE candidate in a custom JSON format
  6. client sends any asynchronous ICE candidate in a custom JSON format

The order and the format of each step is completely arbitrary and i'm pretty sure that there were no client libraries that worked in the same way. Are you able to provide a list of libraries that support the steps and order described above?

I can’t provide libraries, but I can check all versions of mediamtx (at that time it was still rtsp-simple-server) in which you had webrtc running via websocket with mobile platforms (ios/android) with their different possible implementations of ws/wss clients to check functionality . If necessary, I can provide logs so that you can use them to understand how the connection from them occurs.