diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index fdc99faa7..093c9d5f1 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -158,6 +158,7 @@ type ParticipantParams struct { ForwardStats *sfu.ForwardStats DisableSenderReportPassThrough bool MetricConfig metric.MetricConfig + DropRemoteICECandidates bool } type ParticipantImpl struct { @@ -1448,6 +1449,7 @@ func (p *ParticipantImpl) setupTransportManager() error { PublisherHandler: pth, SubscriberHandler: sth, DataChannelStats: p.dataChannelStats, + DropRemoteICECandidates: p.params.DropRemoteICECandidates, } if p.params.SyncStreams && p.params.PlayoutDelay.GetEnabled() && p.params.ClientInfo.isFirefox() { // we will disable playout delay for Firefox if the user is expecting diff --git a/pkg/rtc/transport.go b/pkg/rtc/transport.go index d23e80c8b..71c8949cc 100644 --- a/pkg/rtc/transport.go +++ b/pkg/rtc/transport.go @@ -248,6 +248,7 @@ type TransportParams struct { IsSendSide bool AllowPlayoutDelay bool DataChannelMaxBufferedAmount uint64 + DropRemoteICECandidates bool } func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimator cc.BandwidthEstimator)) (*webrtc.PeerConnection, *webrtc.MediaEngine, error) { @@ -1400,7 +1401,7 @@ func (t *PCTransport) handleRemoteICECandidate(e event) error { c := e.data.(*webrtc.ICECandidateInit) filtered := false - if t.preferTCP.Load() && !strings.Contains(c.Candidate, "tcp") { + if t.params.DropRemoteICECandidates || (t.preferTCP.Load() && !strings.Contains(c.Candidate, "tcp")) { t.params.Logger.Debugw("filtering out remote candidate", "candidate", c.Candidate) filtered = true } @@ -1454,7 +1455,7 @@ func (t *PCTransport) filterCandidates(sd webrtc.SessionDescription, preferTCP, filteredAttrs = append(filteredAttrs, a) continue } - excluded := preferTCP && !c.NetworkType().IsTCP() + excluded := (!isLocal && t.params.DropRemoteICECandidates) || (preferTCP && !c.NetworkType().IsTCP()) if !excluded { if !t.params.Config.UseMDNS && types.IsICECandidateMDNS(c) { excluded = true diff --git a/pkg/rtc/transportmanager.go b/pkg/rtc/transportmanager.go index f1a24b4fe..40d3f1a4a 100644 --- a/pkg/rtc/transportmanager.go +++ b/pkg/rtc/transportmanager.go @@ -93,6 +93,7 @@ type TransportManagerParams struct { PublisherHandler transport.Handler SubscriberHandler transport.Handler DataChannelStats *telemetry.BytesTrackStats + DropRemoteICECandidates bool } type TransportManager struct { @@ -146,6 +147,7 @@ func NewTransportManager(params TransportManagerParams) (*TransportManager, erro ClientInfo: params.ClientInfo, Transport: livekit.SignalTarget_PUBLISHER, Handler: TransportManagerPublisherTransportHandler{TransportManagerTransportHandler{params.PublisherHandler, t}}, + DropRemoteICECandidates: params.DropRemoteICECandidates, }) if err != nil { return nil, err @@ -168,6 +170,7 @@ func NewTransportManager(params TransportManagerParams) (*TransportManager, erro DataChannelMaxBufferedAmount: params.DataChannelMaxBufferedAmount, Transport: livekit.SignalTarget_SUBSCRIBER, Handler: TransportManagerTransportHandler{params.SubscriberHandler, t}, + DropRemoteICECandidates: params.DropRemoteICECandidates, }) if err != nil { return nil, err