Add option to drop remote ICE candidates. (#3118)

Defaults to OFF.
This commit is contained in:
Raja Subramanian
2024-10-19 10:30:22 +05:30
committed by GitHub
parent c04c703125
commit a564f7fbe6
3 changed files with 8 additions and 2 deletions
+2
View File
@@ -158,6 +158,7 @@ type ParticipantParams struct {
ForwardStats *sfu.ForwardStats ForwardStats *sfu.ForwardStats
DisableSenderReportPassThrough bool DisableSenderReportPassThrough bool
MetricConfig metric.MetricConfig MetricConfig metric.MetricConfig
DropRemoteICECandidates bool
} }
type ParticipantImpl struct { type ParticipantImpl struct {
@@ -1448,6 +1449,7 @@ func (p *ParticipantImpl) setupTransportManager() error {
PublisherHandler: pth, PublisherHandler: pth,
SubscriberHandler: sth, SubscriberHandler: sth,
DataChannelStats: p.dataChannelStats, DataChannelStats: p.dataChannelStats,
DropRemoteICECandidates: p.params.DropRemoteICECandidates,
} }
if p.params.SyncStreams && p.params.PlayoutDelay.GetEnabled() && p.params.ClientInfo.isFirefox() { if p.params.SyncStreams && p.params.PlayoutDelay.GetEnabled() && p.params.ClientInfo.isFirefox() {
// we will disable playout delay for Firefox if the user is expecting // we will disable playout delay for Firefox if the user is expecting
+3 -2
View File
@@ -248,6 +248,7 @@ type TransportParams struct {
IsSendSide bool IsSendSide bool
AllowPlayoutDelay bool AllowPlayoutDelay bool
DataChannelMaxBufferedAmount uint64 DataChannelMaxBufferedAmount uint64
DropRemoteICECandidates bool
} }
func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimator cc.BandwidthEstimator)) (*webrtc.PeerConnection, *webrtc.MediaEngine, error) { 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) c := e.data.(*webrtc.ICECandidateInit)
filtered := false 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) t.params.Logger.Debugw("filtering out remote candidate", "candidate", c.Candidate)
filtered = true filtered = true
} }
@@ -1454,7 +1455,7 @@ func (t *PCTransport) filterCandidates(sd webrtc.SessionDescription, preferTCP,
filteredAttrs = append(filteredAttrs, a) filteredAttrs = append(filteredAttrs, a)
continue continue
} }
excluded := preferTCP && !c.NetworkType().IsTCP() excluded := (!isLocal && t.params.DropRemoteICECandidates) || (preferTCP && !c.NetworkType().IsTCP())
if !excluded { if !excluded {
if !t.params.Config.UseMDNS && types.IsICECandidateMDNS(c) { if !t.params.Config.UseMDNS && types.IsICECandidateMDNS(c) {
excluded = true excluded = true
+3
View File
@@ -93,6 +93,7 @@ type TransportManagerParams struct {
PublisherHandler transport.Handler PublisherHandler transport.Handler
SubscriberHandler transport.Handler SubscriberHandler transport.Handler
DataChannelStats *telemetry.BytesTrackStats DataChannelStats *telemetry.BytesTrackStats
DropRemoteICECandidates bool
} }
type TransportManager struct { type TransportManager struct {
@@ -146,6 +147,7 @@ func NewTransportManager(params TransportManagerParams) (*TransportManager, erro
ClientInfo: params.ClientInfo, ClientInfo: params.ClientInfo,
Transport: livekit.SignalTarget_PUBLISHER, Transport: livekit.SignalTarget_PUBLISHER,
Handler: TransportManagerPublisherTransportHandler{TransportManagerTransportHandler{params.PublisherHandler, t}}, Handler: TransportManagerPublisherTransportHandler{TransportManagerTransportHandler{params.PublisherHandler, t}},
DropRemoteICECandidates: params.DropRemoteICECandidates,
}) })
if err != nil { if err != nil {
return nil, err return nil, err
@@ -168,6 +170,7 @@ func NewTransportManager(params TransportManagerParams) (*TransportManager, erro
DataChannelMaxBufferedAmount: params.DataChannelMaxBufferedAmount, DataChannelMaxBufferedAmount: params.DataChannelMaxBufferedAmount,
Transport: livekit.SignalTarget_SUBSCRIBER, Transport: livekit.SignalTarget_SUBSCRIBER,
Handler: TransportManagerTransportHandler{params.SubscriberHandler, t}, Handler: TransportManagerTransportHandler{params.SubscriberHandler, t},
DropRemoteICECandidates: params.DropRemoteICECandidates,
}) })
if err != nil { if err != nil {
return nil, err return nil, err