Fix filtering candidates (#901)
* Filter candidate after setting description * comment * Fix filtering candidates - For offer/answer from remote, do filtering before setting remote description so that Pion does not see filtered candidates - For offer/answer originating from server, do filtering after setting local description (comments in code) so that remote side does not see filtered candidates. - Make logging a little consistent and use right context. * Comment * TCP fallback config and UT (broken now) * log SDP only when preferring TCP * Remove TCP fallback test attempt
This commit is contained in:
+22
-6
@@ -37,7 +37,7 @@ const (
|
||||
iceFailedTimeout = 25 * time.Second // pion's default
|
||||
iceKeepaliveInterval = 2 * time.Second // pion's default
|
||||
|
||||
shortConnectionThreshold = 2 * time.Minute
|
||||
shortConnectionThreshold = 90 * time.Second
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -228,7 +228,13 @@ func (t *PCTransport) Logger() logger.Logger {
|
||||
|
||||
func (t *PCTransport) SetICEConnectedAt(at time.Time) {
|
||||
t.lock.Lock()
|
||||
t.iceConnectedAt = at
|
||||
if t.iceConnectedAt.IsZero() {
|
||||
//
|
||||
// Record initial connection time.
|
||||
// This prevents reset of connected at time if ICE goes `Connected` -> `Disconnected` -> `Connected`.
|
||||
//
|
||||
t.iceConnectedAt = at
|
||||
}
|
||||
t.lock.Unlock()
|
||||
}
|
||||
|
||||
@@ -563,10 +569,9 @@ func (t *PCTransport) createAndSendOffer(options *webrtc.OfferOptions) error {
|
||||
return err
|
||||
}
|
||||
|
||||
t.params.Logger.Infow("local offer (unfiltered)", "sdp", offer.SDP)
|
||||
offer = t.filterCandidates(offer)
|
||||
t.params.Logger.Infow("local offer (filtered)", "sdp", offer.SDP)
|
||||
|
||||
if t.preferTCP {
|
||||
t.params.Logger.Infow("local offer (unfiltered)", "sdp", offer.SDP)
|
||||
}
|
||||
err = t.pc.SetLocalDescription(offer)
|
||||
if err != nil {
|
||||
prometheus.ServiceOperationCounter.WithLabelValues("offer", "error", "local_description").Add(1)
|
||||
@@ -574,6 +579,17 @@ func (t *PCTransport) createAndSendOffer(options *webrtc.OfferOptions) error {
|
||||
return err
|
||||
}
|
||||
|
||||
//
|
||||
// Filter after setting local description as pion expects the offer
|
||||
// to match between CreateOffer and SetLocalDescription.
|
||||
// Filtered offer is sent to remote so that remote does not
|
||||
// see filtered candidates.
|
||||
//
|
||||
offer = t.filterCandidates(offer)
|
||||
if t.preferTCP {
|
||||
t.params.Logger.Infow("local offer (filtered)", "sdp", offer.SDP)
|
||||
}
|
||||
|
||||
// indicate waiting for client
|
||||
t.negotiationState = negotiationStateClient
|
||||
t.restartAfterGathering = false
|
||||
|
||||
Reference in New Issue
Block a user