-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inactive tracks should not be stopped #2226
Comments
@k0nserv - if it's correct that changing the direction to inactive on the Pion side shouldn't stop the track (and this sounds quite plausible, but I haven't checked the RFC) then I think removing L1058-1061 in We would also need to introduce the concept, I suppose, of a 'paused' track, whereby received RTP (but not RTCP?) data is discarded, and sending RTP (but not RTCP?) fails. We'd also need some way of aborting an in-progress ReadRTP and WriteRTP in that track if it enters the pause state while in the middle of those calls. I don't quite have the right mental model yet of the cleanest way to do that. Thoughts from some experts on this? @davidzhao maybe? |
Far from being an expert on this, but I think the current behavior is actually correct. RTPTransceiver.Stop() in Pion doesn't work exactly the same as the browser. The current implementation of Stop is more like a paused state. According to the specs, once a transceiver is paused, it cannot be restarted. In Pion, it'd happily re-use the same transceiver in order to send other tracks. |
I posted a suggestion for a paused state, for the sender, in the webrtc-rs issue. I've not got a sophisticated test bed for Pion, but in webrtc-rs if an
For example, does this mean you've experienced the transition from I also noticed that the It's also worth noting that the doc comment for
(Emphasis mine) |
@k0nserv I believe you are right. I got a bit confused because the behavior is different depending on if it's sending or receiving. When sending, Pion handles transceiver re-use correctly. RemoveTrack puts the transceiver into an inactive state, until another Track is attached to it. When receiving, Pion would stop the transceiver if a remote offerer has set the transceiver to inactive. Once stopped, a transceiver cannot be reused again (the comment is correct, even though we seemed to missed setting stopped flag). I think all we need to do here is to remove that Stop and instead set transceiver direction to inactive. PeerConnection.configureRTPReceivers should stop and reset the receiver. |
Which Lines 1058 to 1061 in ea7964c
This only gets called if In summary, I think my question is: do you think removing L1058-L1061 is a necessary and sufficient change to fix this? |
I tested this in |
Yes, I'm referring to the same Stop
That's the direction as specified in the offer, not what the local Transceiver indicates. I'm saying in this case, we need to match the local Transceiver's direction to inactive as well. It'll then trigger a receiver reset in
|
@davidzhao - so something like this?
|
Yeah, I think that should be sufficient.. but this chain of events is sort of complex.. wdyt @Sean-Der ? |
I've been experimenting with this in However, this might be different for Pion due to the changes from #2087. Another question on my mind is: How should it be detected when a transceiver transitions from .e.g. @Sean-Der Do you have peer-to-peer playgrounds for testing with Chrome that you could share as starting point to explore this behaviour? |
I've been playing around a bit with this in Chrome using the following playgrounds: When the transceiver transitions from |
In Pion, when |
Should that happen though? My understanding is that, just as the transceiver shouldn't be stopped when direction becomes
From RFC3264 Section 5.1
I'm also curious about how you handle this in LiveKit, i.e. when a camera track is removed how is that handled? |
You are right. though I'm not sure what type of RTCP it would still make sense to send. The receiving end would have marked this track as completed. When the sender wishes to send another track, it would trigger the receiver to fire
Within LiveKit, the behavior differs depending on the platform. When a receiving browser sees a transceiver go from recvonly to inactive, the On mobile platforms, it would notify us that RTPReceiver had been removed. here's how we handle it. The behavior on mobile seem to indicate that the RTPReceiver should be removed/stopped entirely. |
Hmm, right I suppose the receiver can be removed and re-created entirely instead of entering some paused state and then resuming. However, since the specification says that RTCP should continue to flow that seems to indicate that it's decoupled from the RTCPReceiver in libWebrtc then. |
FWIW there's this test in libWebrtc that asserts that the transceivers are not stopped in the case of an m= section becoming inactive. |
Details from the spec in https://w3c.github.io/webrtc-pc/#set-the-session-description in step 7.9.1.7.2. Implementation in libWebRTC |
so how can I do to receive data on the server side when inactive back to sendrecv on the browser side ? |
Your environment.
What did you do?
removeTrack
What did you expect?
For Pion to change the direction of the transceiver in question to
inactive
and not stop it.What happened?
Pion changes the direction of the transceiver in question to
inactive
and stops it:webrtc/peerconnection.go
Lines 1058 to 1061 in ea7964c
This relates to the issue webrtc-rs/webrtc#192 which in turns is related to webrtc-rs/webrtc#191 not sure if this happens in Pion too). I think it might also be related to #1843
My understanding of the specification is that the transceiver shouldn't be stopped when this happens.
The text was updated successfully, but these errors were encountered: