Skip to content

Commit 4f2363b

Browse files
authored
feat: debounce negotiation (#258)
1 parent b83f63c commit 4f2363b

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/pion/ion-sfu
33
go 1.13
44

55
require (
6+
github.com/bep/debounce v1.2.0
67
github.com/gammazero/deque v0.0.0-20201010052221-3932da5530cc
78
github.com/golang/protobuf v1.4.3
89
github.com/gorilla/websocket v1.4.2

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV
3030
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
3131
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
3232
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
33+
github.com/bep/debounce v1.2.0 h1:wXds8Kq8qRfwAOpAxHrJDbCXgC5aHSzgQb/0gKsHQqo=
34+
github.com/bep/debounce v1.2.0/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
3335
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
3436
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
3537
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=

pkg/webrtctransport.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"sync"
77
"time"
88

9+
"github.com/bep/debounce"
910
"github.com/lucsky/cuid"
1011
log "github.com/pion/ion-log"
1112
"github.com/pion/rtcp"
@@ -300,7 +301,10 @@ func (p *WebRTCTransport) OnICECandidate(f func(c *webrtc.ICECandidate)) {
300301

301302
// OnNegotiationNeeded handler
302303
func (p *WebRTCTransport) OnNegotiationNeeded(f func()) {
303-
p.pc.OnNegotiationNeeded(f)
304+
debounced := debounce.New(100 * time.Millisecond)
305+
p.pc.OnNegotiationNeeded(func() {
306+
debounced(f)
307+
})
304308
}
305309

306310
// OnTrack handler

0 commit comments

Comments
 (0)