@@ -15,8 +15,6 @@ import (
15
15
"sync/atomic"
16
16
"time"
17
17
18
- atomicx "github.com/pion/ice/v3/internal/atomic"
19
- stunx "github.com/pion/ice/v3/internal/stun"
20
18
"github.com/pion/logging"
21
19
"github.com/pion/mdns"
22
20
"github.com/pion/stun/v2"
@@ -25,6 +23,9 @@ import (
25
23
"github.com/pion/transport/v3/stdnet"
26
24
"github.com/pion/transport/v3/vnet"
27
25
"golang.org/x/net/proxy"
26
+
27
+ atomicx "github.com/pion/ice/v3/internal/atomic"
28
+ stunx "github.com/pion/ice/v3/internal/stun"
28
29
)
29
30
30
31
type bindingRequest struct {
@@ -40,9 +41,10 @@ type Agent struct {
40
41
afterRunFn []func (ctx context.Context )
41
42
muAfterRun sync.Mutex
42
43
43
- onConnectionStateChangeHdlr atomic.Value // func(ConnectionState)
44
- onSelectedCandidatePairChangeHdlr atomic.Value // func(Candidate, Candidate)
45
- onCandidateHdlr atomic.Value // func(Candidate)
44
+ onConnectionStateChangeHdlr atomic.Value // func(ConnectionState)
45
+ onSelectedCandidatePairChangeHdlr atomic.Value // func(Candidate, Candidate)
46
+ onCandidateHdlr atomic.Value // func(Candidate)
47
+ onSuccessfulSelectedPairBindingResponseHdlr atomic.Value // func(*Candidate)
46
48
47
49
// State owned by the taskLoop
48
50
onConnected chan struct {}
@@ -648,7 +650,8 @@ func (a *Agent) checkKeepalive() {
648
650
649
651
if (a .keepaliveInterval != 0 ) &&
650
652
((time .Since (selectedPair .Local .LastSent ()) > a .keepaliveInterval ) ||
651
- (time .Since (selectedPair .Remote .LastReceived ()) > a .keepaliveInterval )) {
653
+ (time .Since (selectedPair .Remote .LastReceived ()) > a .keepaliveInterval ) ||
654
+ (time .Since (selectedPair .lastBindingRequest ) > a .keepaliveInterval )) {
652
655
// We use binding request instead of indication to support refresh consent schemas
653
656
// see https://tools.ietf.org/html/rfc7675
654
657
a .selector .PingCandidate (selectedPair .Local , selectedPair .Remote )
@@ -991,6 +994,9 @@ func (a *Agent) sendBindingRequest(m *stun.Message, local, remote Candidate) {
991
994
isUseCandidate : m .Contains (stun .AttrUseCandidate ),
992
995
})
993
996
997
+ p := a .findPair (local , remote )
998
+ p .markBindingRequest (m .TransactionID )
999
+
994
1000
a .sendSTUN (m , local , remote )
995
1001
}
996
1002
@@ -1174,7 +1180,7 @@ func (a *Agent) GetSelectedCandidatePair() (*CandidatePair, error) {
1174
1180
return nil , err
1175
1181
}
1176
1182
1177
- return & CandidatePair {Local : local , Remote : remote }, nil
1183
+ return & CandidatePair {Local : local , Remote : remote , latency : selectedPair . Latency () }, nil
1178
1184
}
1179
1185
1180
1186
func (a * Agent ) getSelectedPair () * CandidatePair {
0 commit comments