From 0cd50878dd1814bb2b1c6f97fe9f94fc20b92ab7 Mon Sep 17 00:00:00 2001 From: Garrett Graves Date: Sat, 15 Apr 2023 13:59:53 -0700 Subject: [PATCH] fix case when peer is sub or pub only --- pkg/sfu/peer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/sfu/peer.go b/pkg/sfu/peer.go index 7fa2432a1..5bf7ac3f2 100644 --- a/pkg/sfu/peer.go +++ b/pkg/sfu/peer.go @@ -237,16 +237,22 @@ func (p *PeerLocal) SetRemoteDescription(sdp webrtc.SessionDescription) error { // Trickle candidates available for this peer func (p *PeerLocal) Trickle(candidate webrtc.ICECandidateInit, target int) error { - if p.subscriber == nil || p.publisher == nil { + if p.subscriber == nil && p.publisher == nil { return ErrNoTransportEstablished } Logger.V(0).Info("PeerLocal trickle", "peer_id", p.id) switch target { case publisher: + if p.publisher == nil { + return ErrNoTransportEstablished + } if err := p.publisher.AddICECandidate(candidate); err != nil { return fmt.Errorf("setting ice candidate: %w", err) } case subscriber: + if p.subscriber == nil { + return ErrNoTransportEstablished + } if err := p.subscriber.AddICECandidate(candidate); err != nil { return fmt.Errorf("setting ice candidate: %w", err) }