Eyevinn / srt-whep

SRT to WHEP (WebRTC)
Apache License 2.0
80 stars 10 forks source link

Remove WebRTC bin from pipeline when users close/refresh player #38

Closed Wkkkkk closed 1 year ago

Wkkkkk commented 1 year ago

When the user disconnects, we need to remove that branch from the pipeline (instead of solely relying on users sending DELETE). This can be observed from the connection-state change in the WebRTC bin.

Wkkkkk commented 1 year ago

Hi @sdroege, wish you are doing well.

I'm writing to you in hope to get some help/advice about how to monitor connection-state change in the WebRTC bin. This is necessary for a pipeline to remove a WebRTC bin when the client disconnects.

There are two problems:

  1. How to react to the signal of a child object? Like in the example whipsink, we could connect to the connection-state signal of webrtcbin element and handle the state changes in the callback. However, for elements like whipsink (which wraps a webrtcbin itself), this approach seems not to work.
  2. How to handle disconnections from client? When a client disconnects, we could see that the connection-state of TransportSendbin in GstWebRTCBin becomes 'closed' (from 'connected'). However, the same property in GstWebRTCBin is still 'connected', which can be observed in this figure. This seems to be a bit confusing and tricky to handle.

Hope it does not bother you too much if I reach out like this. Any suggestion would be appreciated.

Wkkkkk commented 1 year ago

Based on the answer from Mathieu Duponchelle, as I quote here:

Hey, whipsink from webrtchttp has now been deprecated, you should use the whip element from net/webrtc (based on webrtcsink). There, you would access webrtcbin for a given consumer through the consumer-added signal, then connect to the relevant signal. As for your second question I am not sure, I think you would want to wait for at least 30 seconds for an ice timeout perhaps?

It is not recommended to use Whipsink and we shall replace it with WhipWebRTCSink instead so that we can monitor connections. As for disconnections, a periodical check on the state might be worth a try.

Wkkkkk commented 1 year ago

After replacing Whipsink with WhipWebRTCSink, this problem is solved. Therefore we close this issue.