Update dependencies to generic versions (#1259)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,7 +368,6 @@ func (s *EgressService) startWorker() error {
|
||||
s.handleUpdate(info)
|
||||
case <-s.shutdown:
|
||||
_ = sub.Close()
|
||||
rs.Stop()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
+6
-12
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user