From 988858a98a5c8cd337a1548d7b3b7c15aea8a182 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 26 Dec 2022 22:29:13 -0800 Subject: [PATCH] Update dependencies to generic versions (#1259) --- go.mod | 9 +++++---- go.sum | 18 ++++++++++-------- pkg/rtc/participant.go | 8 ++++---- pkg/rtc/participant_signal.go | 17 ++++++++--------- pkg/service/egress.go | 1 - pkg/service/server.go | 2 +- pkg/sfu/vp8munger.go | 18 ++++++------------ 7 files changed, 34 insertions(+), 39 deletions(-) diff --git a/go.mod b/go.mod index 6f1235f32..14d8a1f78 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/bep/debounce v1.2.1 github.com/d5/tengo/v2 v2.13.0 github.com/dustin/go-humanize v1.0.0 - github.com/elliotchance/orderedmap v1.5.0 + github.com/elliotchance/orderedmap/v2 v2.2.0 github.com/florianl/go-tc v0.4.2 github.com/gammazero/deque v0.1.0 github.com/gammazero/workerpool v1.1.2 @@ -14,11 +14,11 @@ require ( github.com/google/wire v0.5.0 github.com/gorilla/websocket v1.5.0 github.com/hashicorp/go-version v1.6.0 - github.com/hashicorp/golang-lru v0.6.0 + github.com/hashicorp/golang-lru/v2 v2.0.1 github.com/jxskiss/base62 v1.1.0 github.com/livekit/mageutil v0.0.0-20221221221243-f361fbe40290 github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b - github.com/livekit/protocol v1.3.1-0.20221219041553-fc943512b0fb + github.com/livekit/protocol v1.3.1 github.com/livekit/psrpc v0.2.0 github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995 github.com/mackerelio/go-osstat v0.2.3 @@ -45,7 +45,7 @@ require ( github.com/twitchtv/twirp v8.1.3+incompatible github.com/ua-parser/uap-go v0.0.0-20211112212520-00c877edfe0f github.com/urfave/cli/v2 v2.23.7 - github.com/urfave/negroni v1.0.0 + github.com/urfave/negroni/v3 v3.0.0 go.uber.org/atomic v1.10.0 go.uber.org/zap v1.24.0 golang.org/x/sync v0.1.0 @@ -70,6 +70,7 @@ require ( github.com/josharian/native v1.1.0 // indirect github.com/klauspost/compress v1.15.13 // indirect github.com/lithammer/shortuuid/v3 v3.0.7 // indirect + github.com/lithammer/shortuuid/v4 v4.0.0 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mdlayher/netlink v1.6.0 // indirect diff --git a/go.sum b/go.sum index e925257f3..71971cc32 100644 --- a/go.sum +++ b/go.sum @@ -74,8 +74,8 @@ github.com/eapache/channels v1.1.0 h1:F1taHcn7/F0i8DYqKXJnyhJcVpp2kgFcNePxXtnyu4 github.com/eapache/channels v1.1.0/go.mod h1:jMm2qB5Ubtg9zLd+inMZd2/NUvXgzmWXsDaLyQIGfH0= github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/elliotchance/orderedmap v1.5.0 h1:1IsExUsjv5XNBD3ZdC7jkAAqLWOOKdbPTmkHx63OsBg= -github.com/elliotchance/orderedmap v1.5.0/go.mod h1:wsDwEaX5jEoyhbs7x93zk2H/qv0zwuhg4inXhDkYqys= +github.com/elliotchance/orderedmap/v2 v2.2.0 h1:7/2iwO98kYT4XkOjA9mBEIwvi4KpGB4cyHeOFOnj4Vk= +github.com/elliotchance/orderedmap/v2 v2.2.0/go.mod h1:85lZyVbpGaGvHvnKa7Qhx7zncAdBIBq6u56Hb1PRU5Q= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -182,8 +182,8 @@ github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mO github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.6.0 h1:uL2shRDx7RTrOrTCUZEGP/wJUFiUI8QT6E7z5o8jga4= -github.com/hashicorp/golang-lru v0.6.0/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru/v2 v2.0.1 h1:5pv5N1lT1fjLg2VQ5KWc7kmucp2x/kvFOnxuVTqZ6x4= +github.com/hashicorp/golang-lru/v2 v2.0.1/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/josharian/native v0.0.0-20200817173448-b6b71def0850/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= @@ -227,12 +227,14 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lithammer/shortuuid/v3 v3.0.7 h1:trX0KTHy4Pbwo/6ia8fscyHoGA+mf1jWbPJVuvyJQQ8= github.com/lithammer/shortuuid/v3 v3.0.7/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts= +github.com/lithammer/shortuuid/v4 v4.0.0 h1:QRbbVkfgNippHOS8PXDkti4NaWeyYfcBTHtw7k08o4c= +github.com/lithammer/shortuuid/v4 v4.0.0/go.mod h1:Zs8puNcrvf2rV9rTH51ZLLcj7ZXqQI3lv67aw4KiB1Y= github.com/livekit/mageutil v0.0.0-20221221221243-f361fbe40290 h1:ZVsQUuUOM9G7O3qfDSSUd1d+KlE5EVzHKylMkMkRhYg= github.com/livekit/mageutil v0.0.0-20221221221243-f361fbe40290/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ= github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b h1:RBNV8TckETSkIkKxcD12d8nZKVkB9GSY/sQlMoaruP4= github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b/go.mod h1:1Dlx20JPoIKGP45eo+yuj0HjeE25zmyeX/EWHiPCjFw= -github.com/livekit/protocol v1.3.1-0.20221219041553-fc943512b0fb h1:Kt92FupD3q4GzAlabx7bxUZAz+MOPgBnsUnTDU3EuWo= -github.com/livekit/protocol v1.3.1-0.20221219041553-fc943512b0fb/go.mod h1:lTX4zmLbKoeDWHjBJEzo5wYNcFb8MaJFlc5gUnFbHTc= +github.com/livekit/protocol v1.3.1 h1:LunQgRkEbUTvXhtP7Q509CvWlfQqSTwZ/aEb9bWdKi4= +github.com/livekit/protocol v1.3.1/go.mod h1:gwCG03nKlHlC9hTjL4pXQpn783ALhmbyhq65UZxqbb8= github.com/livekit/psrpc v0.2.0 h1:hthI/waSlkERmYfHx+xwhqvBngfbigxq9DKnkX99woA= github.com/livekit/psrpc v0.2.0/go.mod h1:MCe0xLdFPXmzogPiLrM94JIJbctb9+fAv5qYPkY2DXw= github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995 h1:vOaY2qvfLihDyeZtnGGN1Law9wRrw8BMGCr1TygTvMw= @@ -406,8 +408,8 @@ github.com/ua-parser/uap-go v0.0.0-20211112212520-00c877edfe0f h1:A+MmlgpvrHLeUP github.com/ua-parser/uap-go v0.0.0-20211112212520-00c877edfe0f/go.mod h1:OBcG9bn7sHtXgarhUEb3OfCnNsgtGnkVf41ilSZ3K3E= github.com/urfave/cli/v2 v2.23.7 h1:YHDQ46s3VghFHFf1DdF+Sh7H4RqhcM+t0TmZRJx4oJY= github.com/urfave/cli/v2 v2.23.7/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= -github.com/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc= -github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= +github.com/urfave/negroni/v3 v3.0.0 h1:Vo8CeZfu1lFR9gW8GnAb6dOGCJyijfil9j/jKKc/JhU= +github.com/urfave/negroni/v3 v3.0.0/go.mod h1:jWvnX03kcSjDBl/ShB0iHvx5uOs7mAzZXW+JvJ5XYAs= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 49ac95540..2af6dd9cd 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -8,7 +8,7 @@ import ( "sync" "time" - lru "github.com/hashicorp/golang-lru" + lru "github.com/hashicorp/golang-lru/v2" "github.com/pion/rtcp" "github.com/pion/sdp/v3" "github.com/pion/webrtc/v3" @@ -97,7 +97,7 @@ type ParticipantImpl struct { isClosed atomic.Bool state atomic.Value // livekit.ParticipantInfo_State - updateCache *lru.Cache + updateCache *lru.Cache[livekit.ParticipantID, uint32] resSink atomic.Value // routing.MessageSink resSinkValid atomic.Bool grants *auth.ClaimGrants @@ -207,7 +207,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) { var err error // keep last participants and when updates were sent - if p.updateCache, err = lru.New(128); err != nil { + if p.updateCache, err = lru.New[livekit.ParticipantID, uint32](128); err != nil { return nil, err } @@ -909,7 +909,7 @@ func (p *ParticipantImpl) UpdateSubscribedTrackSettings(trackID livekit.TrackID, } func (p *ParticipantImpl) VerifySubscribeParticipantInfo(pID livekit.ParticipantID, version uint32) { - if v, ok := p.updateCache.Get(pID); ok && v.(uint32) >= version { + if v, ok := p.updateCache.Get(pID); ok && v >= version { return } diff --git a/pkg/rtc/participant_signal.go b/pkg/rtc/participant_signal.go index 0d45517f1..dc960e45f 100644 --- a/pkg/rtc/participant_signal.go +++ b/pkg/rtc/participant_signal.go @@ -47,18 +47,17 @@ func (p *ParticipantImpl) SendParticipantUpdate(participantsToUpdate []*livekit. validUpdates := make([]*livekit.ParticipantInfo, 0, len(participantsToUpdate)) for _, pi := range participantsToUpdate { isValid := true - if val, ok := p.updateCache.Get(pi.Sid); ok { - if lastVersion, ok := val.(uint32); ok { - // this is a message delivered out of order, a more recent version of the message had already been - // sent. - if pi.Version < lastVersion { - p.params.Logger.Debugw("skipping outdated participant update", "version", pi.Version, "lastVersion", lastVersion) - isValid = false - } + pID := livekit.ParticipantID(pi.Sid) + if lastVersion, ok := p.updateCache.Get(pID); ok { + // this is a message delivered out of order, a more recent version of the message had already been + // sent. + if pi.Version < lastVersion { + p.params.Logger.Debugw("skipping outdated participant update", "version", pi.Version, "lastVersion", lastVersion) + isValid = false } } if isValid { - p.updateCache.Add(pi.Sid, pi.Version) + p.updateCache.Add(pID, pi.Version) validUpdates = append(validUpdates, pi) } } diff --git a/pkg/service/egress.go b/pkg/service/egress.go index 906ec6338..e04debd73 100644 --- a/pkg/service/egress.go +++ b/pkg/service/egress.go @@ -368,7 +368,6 @@ func (s *EgressService) startWorker() error { s.handleUpdate(info) case <-s.shutdown: _ = sub.Close() - rs.Stop() return } } diff --git a/pkg/service/server.go b/pkg/service/server.go index bc5667503..3dcd775fe 100644 --- a/pkg/service/server.go +++ b/pkg/service/server.go @@ -14,7 +14,7 @@ import ( "github.com/pion/turn/v2" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/rs/cors" - "github.com/urfave/negroni" + "github.com/urfave/negroni/v3" "go.uber.org/atomic" "golang.org/x/sync/errgroup" diff --git a/pkg/sfu/vp8munger.go b/pkg/sfu/vp8munger.go index 01c6b879c..1dfa24d12 100644 --- a/pkg/sfu/vp8munger.go +++ b/pkg/sfu/vp8munger.go @@ -3,16 +3,14 @@ package sfu import ( "fmt" - "github.com/elliotchance/orderedmap" + "github.com/elliotchance/orderedmap/v2" "github.com/livekit/protocol/logger" "github.com/livekit/livekit-server/pkg/sfu/buffer" ) -// // VP8 munger -// type TranslationParamsVP8 struct { Header *buffer.VP8 } @@ -49,7 +47,7 @@ type VP8MungerParams struct { keyIdxOffset uint8 keyIdxUsed int - missingPictureIds *orderedmap.OrderedMap + missingPictureIds *orderedmap.OrderedMap[int32, int32] lastDroppedPictureId int32 } @@ -63,7 +61,7 @@ func NewVP8Munger(logger logger.Logger) *VP8Munger { return &VP8Munger{ logger: logger, VP8MungerParams: VP8MungerParams{ - missingPictureIds: orderedmap.NewOrderedMap(), + missingPictureIds: orderedmap.NewOrderedMap[int32, int32](), lastDroppedPictureId: -1, }, } @@ -138,7 +136,7 @@ func (v *VP8Munger) UpdateOffsets(extPkt *buffer.ExtPacket) { } // clear missing picture ids on layer switch - v.missingPictureIds = orderedmap.NewOrderedMap() + v.missingPictureIds = orderedmap.NewOrderedMap[int32, int32]() v.lastDroppedPictureId = -1 } @@ -153,11 +151,10 @@ func (v *VP8Munger) UpdateAndGet(extPkt *buffer.ExtPacket, ordering SequenceNumb // if out-of-order, look up missing picture id cache if ordering == SequenceNumberOrderingOutOfOrder { - value, ok := v.missingPictureIds.Get(extPictureId) + pictureIdOffset, ok := v.missingPictureIds.Get(extPictureId) if !ok { return nil, ErrOutOfOrderVP8PictureIdCacheMiss } - pictureIdOffset := value.(int32) // the out-of-order picture id cannot be deleted from the cache // as there could more than one packet in a picture and more @@ -332,15 +329,12 @@ func (v *VP8Munger) UpdateAndGetPadding(newPicture bool) *buffer.VP8 { // for testing only func (v *VP8Munger) PictureIdOffset(extPictureId int32) (int32, bool) { - value, ok := v.missingPictureIds.Get(extPictureId) - return value.(int32), ok + return v.missingPictureIds.Get(extPictureId) } // ----------------------------- -// // VP8PictureIdWrapHandler -// func isWrapping7Bit(val1 int32, val2 int32) bool { return val2 < val1 && (val1-val2) > (1<<6) }