Fixes for pre-added recvonly transceivers

Which were previously unable to:

1. have a sending track set to them, or
2. receive a track after renegotiation.

I'm not 100% sure if this covers all cases where a track is added and
removed and then added again. BUT IIRC there was a change that did not
allow transceiver reuse after a track was removed from it. Again, not
100% sure.

Fixes #1722.
This commit is contained in:
Jerko Steiner
2021-03-20 08:51:14 +01:00
parent 07d7403cca
commit 6465248f1e
3 changed files with 92 additions and 2 deletions

View File

@@ -115,6 +115,12 @@ func (t *RTPTransceiver) setSendingTrack(track TrackLocal) error {
t.setDirection(RTPTransceiverDirectionSendonly)
case track == nil && t.Direction() == RTPTransceiverDirectionSendrecv:
t.setDirection(RTPTransceiverDirectionRecvonly)
case track != nil && t.Direction() == RTPTransceiverDirectionSendonly:
// Handle the case where a sendonly transceiver was added by a negotiation
// initiated by remote peer. For example a remote peer added a transceiver
// with direction recvonly.
case track != nil && t.Direction() == RTPTransceiverDirectionSendrecv:
// Similar to above, but for sendrecv transceiver.
case track == nil && t.Direction() == RTPTransceiverDirectionSendonly:
t.setDirection(RTPTransceiverDirectionInactive)
default: