agent: release JobTerminate handler when job ends before registration (#4908)
* agent: release JobTerminate handler when job ends before registration JobRequest registered the job's JobTerminate handler after AssignJob returned, so an ended UpdateJobStatus or worker disconnect handled in between deregistered nothing and the handler leaked. AssignJob also sent the assignment before recording the job as running, so an immediate ended update was dropped. Record the job before sending the assignment, and after registering the handler recheck under h.mu that the job is still running and its worker still registered, deregistering otherwise. Fixes #4901 * replace utils.CloneProto with proto.CloneOf * agent: wait on worker readiness and poll for released handlers in test
This commit is contained in:
@@ -20,13 +20,13 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/frostbyte73/core"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
sfuutils "github.com/livekit/livekit-server/pkg/sfu/utils"
|
||||
"github.com/livekit/protocol/datatrack"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/livekit/protocol/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -98,7 +98,7 @@ func (d *DataTrack) PublisherIdentity() livekit.ParticipantIdentity {
|
||||
}
|
||||
|
||||
func (d *DataTrack) ToProto() *livekit.DataTrackInfo {
|
||||
return utils.CloneProto(d.dti)
|
||||
return proto.CloneOf(d.dti)
|
||||
}
|
||||
|
||||
func (d *DataTrack) PubHandle() uint16 {
|
||||
|
||||
@@ -30,7 +30,6 @@ import (
|
||||
"github.com/livekit/protocol/codecs/mime"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/livekit/protocol/utils"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
"github.com/livekit/livekit-server/pkg/sfu"
|
||||
@@ -154,7 +153,7 @@ func NewMediaTrackReceiver(params MediaTrackReceiverParams, ti *livekit.TrackInf
|
||||
params: params,
|
||||
state: mediaTrackReceiverStateOpen,
|
||||
}
|
||||
t.trackInfo.Store(utils.CloneProto(ti))
|
||||
t.trackInfo.Store(proto.CloneOf(ti))
|
||||
|
||||
t.MediaTrackSubscriptions = NewMediaTrackSubscriptions(MediaTrackSubscriptionsParams{
|
||||
MediaTrack: params.MediaTrack,
|
||||
@@ -812,7 +811,7 @@ func (t *MediaTrackReceiver) UpdateCodecInfo(codecs []*livekit.SimulcastCodec) {
|
||||
if len(c.Layers) != 0 {
|
||||
clonedLayers := make([]*livekit.VideoLayer, 0, len(c.Layers))
|
||||
for _, l := range c.Layers {
|
||||
clonedLayers = append(clonedLayers, utils.CloneProto(l))
|
||||
clonedLayers = append(clonedLayers, proto.CloneOf(l))
|
||||
}
|
||||
origin.Layers = clonedLayers
|
||||
|
||||
@@ -871,7 +870,7 @@ func (t *MediaTrackReceiver) UpdateCodecRids(mimeType mime.MimeType, rids buffer
|
||||
}
|
||||
|
||||
func (t *MediaTrackReceiver) UpdateTrackInfo(ti *livekit.TrackInfo) {
|
||||
clonedInfo := utils.CloneProto(ti)
|
||||
clonedInfo := proto.CloneOf(ti)
|
||||
|
||||
t.lock.Lock()
|
||||
trackInfo := t.TrackInfo()
|
||||
@@ -924,7 +923,7 @@ func (t *MediaTrackReceiver) UpdateAudioTrack(update *livekit.UpdateLocalAudioTr
|
||||
|
||||
t.lock.Lock()
|
||||
trackInfo := t.TrackInfo()
|
||||
clonedInfo := utils.CloneProto(trackInfo)
|
||||
clonedInfo := proto.CloneOf(trackInfo)
|
||||
|
||||
clonedInfo.AudioFeatures = sutils.DedupeSlice(update.Features)
|
||||
|
||||
@@ -960,7 +959,7 @@ func (t *MediaTrackReceiver) UpdateVideoTrack(update *livekit.UpdateLocalVideoTr
|
||||
|
||||
t.lock.Lock()
|
||||
trackInfo := t.TrackInfo()
|
||||
clonedInfo := utils.CloneProto(trackInfo)
|
||||
clonedInfo := proto.CloneOf(trackInfo)
|
||||
clonedInfo.Width = update.Width
|
||||
clonedInfo.Height = update.Height
|
||||
if proto.Equal(trackInfo, clonedInfo) {
|
||||
@@ -981,7 +980,7 @@ func (t *MediaTrackReceiver) UpdateVideoSize(mimeType mime.MimeType, sizes []cod
|
||||
var changed bool
|
||||
t.lock.Lock()
|
||||
trackInfo := t.TrackInfo()
|
||||
clonedInfo := utils.CloneProto(trackInfo)
|
||||
clonedInfo := proto.CloneOf(trackInfo)
|
||||
var maxWidth, maxHeight uint32
|
||||
for _, size := range sizes {
|
||||
if size.Width > maxWidth {
|
||||
@@ -1028,7 +1027,7 @@ func (t *MediaTrackReceiver) TrackInfo() *livekit.TrackInfo {
|
||||
}
|
||||
|
||||
func (t *MediaTrackReceiver) TrackInfoClone() *livekit.TrackInfo {
|
||||
return utils.CloneProto(t.TrackInfo())
|
||||
return proto.CloneOf(t.TrackInfo())
|
||||
}
|
||||
|
||||
func (t *MediaTrackReceiver) NotifyMaxLayerChange(mimeType mime.MimeType, maxLayer int32) {
|
||||
|
||||
+18
-18
@@ -667,7 +667,7 @@ func (p *ParticipantImpl) GetClientInfo() *livekit.ClientInfo {
|
||||
func (p *ParticipantImpl) GetClientConfiguration() *livekit.ClientConfiguration {
|
||||
p.lock.RLock()
|
||||
defer p.lock.RUnlock()
|
||||
return utils.CloneProto(p.params.ClientConf)
|
||||
return proto.CloneOf(p.params.ClientConf)
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) GetBufferFactory() *buffer.Factory {
|
||||
@@ -709,7 +709,7 @@ func (p *ParticipantImpl) UpdateMetadata(update *livekit.UpdateParticipantMetada
|
||||
sendRequestResponse := func() error {
|
||||
if !fromAdmin || (update.RequestId != 0 || err != nil) {
|
||||
requestResponse.Request = &livekit.RequestResponse_UpdateMetadata{
|
||||
UpdateMetadata: utils.CloneProto(update),
|
||||
UpdateMetadata: proto.CloneOf(update),
|
||||
}
|
||||
p.sendRequestResponse(requestResponse)
|
||||
}
|
||||
@@ -985,7 +985,7 @@ func (p *ParticipantImpl) ToProtoWithVersion() (*livekit.ParticipantInfo, utils.
|
||||
}
|
||||
|
||||
if !found {
|
||||
pi.Tracks = append(pi.Tracks, utils.CloneProto(pti.trackInfos[0]))
|
||||
pi.Tracks = append(pi.Tracks, proto.CloneOf(pti.trackInfos[0]))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1195,7 +1195,7 @@ func (p *ParticipantImpl) HandleICETrickle(trickleRequest *livekit.TrickleReques
|
||||
Reason: livekit.RequestResponse_UNCLASSIFIED_ERROR,
|
||||
Message: err.Error(),
|
||||
Request: &livekit.RequestResponse_Trickle{
|
||||
Trickle: utils.CloneProto(trickleRequest),
|
||||
Trickle: proto.CloneOf(trickleRequest),
|
||||
},
|
||||
})
|
||||
return
|
||||
@@ -1361,7 +1361,7 @@ func (p *ParticipantImpl) AddTrack(req *livekit.AddTrackRequest) {
|
||||
p.sendRequestResponse(&livekit.RequestResponse{
|
||||
Reason: livekit.RequestResponse_NOT_ALLOWED,
|
||||
Request: &livekit.RequestResponse_AddTrack{
|
||||
AddTrack: utils.CloneProto(req),
|
||||
AddTrack: proto.CloneOf(req),
|
||||
},
|
||||
})
|
||||
return
|
||||
@@ -1372,7 +1372,7 @@ func (p *ParticipantImpl) AddTrack(req *livekit.AddTrackRequest) {
|
||||
p.sendRequestResponse(&livekit.RequestResponse{
|
||||
Reason: livekit.RequestResponse_UNSUPPORTED_TYPE,
|
||||
Request: &livekit.RequestResponse_AddTrack{
|
||||
AddTrack: utils.CloneProto(req),
|
||||
AddTrack: proto.CloneOf(req),
|
||||
},
|
||||
})
|
||||
return
|
||||
@@ -2948,7 +2948,7 @@ func (p *ParticipantImpl) addPendingTrack(req *livekit.AddTrackRequest) *livekit
|
||||
p.sendRequestResponse(&livekit.RequestResponse{
|
||||
Reason: livekit.RequestResponse_NOT_FOUND,
|
||||
Request: &livekit.RequestResponse_AddTrack{
|
||||
AddTrack: utils.CloneProto(req),
|
||||
AddTrack: proto.CloneOf(req),
|
||||
},
|
||||
})
|
||||
p.pendingTracksLock.Unlock()
|
||||
@@ -2967,7 +2967,7 @@ func (p *ParticipantImpl) addPendingTrack(req *livekit.AddTrackRequest) *livekit
|
||||
Reason: livekit.RequestResponse_LIMIT_EXCEEDED,
|
||||
Message: fmt.Sprintf("too many pending tracks, rejecting new track, numPendingTracks: %d", len(p.pendingTracks)),
|
||||
Request: &livekit.RequestResponse_AddTrack{
|
||||
AddTrack: utils.CloneProto(req),
|
||||
AddTrack: proto.CloneOf(req),
|
||||
},
|
||||
})
|
||||
p.pendingTracksLock.Unlock()
|
||||
@@ -2989,7 +2989,7 @@ func (p *ParticipantImpl) addPendingTrack(req *livekit.AddTrackRequest) *livekit
|
||||
|
||||
clonedLayers := make([]*livekit.VideoLayer, 0, len(layers))
|
||||
for _, l := range layers {
|
||||
clonedLayers = append(clonedLayers, utils.CloneProto(l))
|
||||
clonedLayers = append(clonedLayers, proto.CloneOf(l))
|
||||
}
|
||||
slices.SortFunc(clonedLayers, func(i, j *livekit.VideoLayer) int {
|
||||
return int(i.Quality) - int(j.Quality)
|
||||
@@ -3157,7 +3157,7 @@ func (p *ParticipantImpl) addPendingTrack(req *livekit.AddTrackRequest) *livekit
|
||||
Reason: livekit.RequestResponse_LIMIT_EXCEEDED,
|
||||
Message: fmt.Sprintf("too many pending queued tracks, rejecting new track, numPendingTracksQueued: %d", len(p.pendingTracks[req.Cid].trackInfos)),
|
||||
Request: &livekit.RequestResponse_AddTrack{
|
||||
AddTrack: utils.CloneProto(req),
|
||||
AddTrack: proto.CloneOf(req),
|
||||
},
|
||||
})
|
||||
p.pendingTracksLock.Unlock()
|
||||
@@ -3175,7 +3175,7 @@ func (p *ParticipantImpl) addPendingTrack(req *livekit.AddTrackRequest) *livekit
|
||||
p.sendRequestResponse(&livekit.RequestResponse{
|
||||
Reason: livekit.RequestResponse_QUEUED,
|
||||
Request: &livekit.RequestResponse_AddTrack{
|
||||
AddTrack: utils.CloneProto(req),
|
||||
AddTrack: proto.CloneOf(req),
|
||||
},
|
||||
})
|
||||
|
||||
@@ -3185,7 +3185,7 @@ func (p *ParticipantImpl) addPendingTrack(req *livekit.AddTrackRequest) *livekit
|
||||
}
|
||||
p.pendingTracksLock.Unlock()
|
||||
|
||||
p.GetTelemetryListener().OnTrackPublishRequested(p.ID(), p.Identity(), utils.CloneProto(ti), true)
|
||||
p.GetTelemetryListener().OnTrackPublishRequested(p.ID(), p.Identity(), proto.CloneOf(ti), true)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3210,7 +3210,7 @@ func (p *ParticipantImpl) addPendingTrack(req *livekit.AddTrackRequest) *livekit
|
||||
}
|
||||
p.pendingTracksLock.Unlock()
|
||||
|
||||
p.GetTelemetryListener().OnTrackPublishRequested(p.ID(), p.Identity(), utils.CloneProto(ti), true)
|
||||
p.GetTelemetryListener().OnTrackPublishRequested(p.ID(), p.Identity(), proto.CloneOf(ti), true)
|
||||
return ti
|
||||
}
|
||||
|
||||
@@ -3262,7 +3262,7 @@ func (p *ParticipantImpl) setTrackMuted(mute *livekit.MuteTrackRequest, fromAdmi
|
||||
for _, pti := range p.pendingTracks {
|
||||
for i, ti := range pti.trackInfos {
|
||||
if livekit.TrackID(ti.Sid) == trackID {
|
||||
ti = utils.CloneProto(ti)
|
||||
ti = proto.CloneOf(ti)
|
||||
changed = changed || ti.Muted != mute.Muted
|
||||
ti.Muted = mute.Muted
|
||||
pti.trackInfos[i] = ti
|
||||
@@ -3286,7 +3286,7 @@ func (p *ParticipantImpl) setTrackMuted(mute *livekit.MuteTrackRequest, fromAdmi
|
||||
p.sendRequestResponse(&livekit.RequestResponse{
|
||||
Reason: livekit.RequestResponse_NOT_FOUND,
|
||||
Request: &livekit.RequestResponse_Mute{
|
||||
Mute: utils.CloneProto(mute),
|
||||
Mute: proto.CloneOf(mute),
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -3714,7 +3714,7 @@ func (p *ParticipantImpl) getPendingTrack(clientId string, kind livekit.TrackTyp
|
||||
return signalCid, nil, buffer.VideoLayersRid{}, false, time.Time{}
|
||||
}
|
||||
|
||||
return signalCid, utils.CloneProto(pendingInfo.trackInfos[0]), pendingInfo.sdpRids, pendingInfo.migrated, pendingInfo.createdAt
|
||||
return signalCid, proto.CloneOf(pendingInfo.trackInfos[0]), pendingInfo.sdpRids, pendingInfo.migrated, pendingInfo.createdAt
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) getPendingTrackPrimaryBySdpCid(sdpCid string) *pendingTrackInfo {
|
||||
@@ -4231,7 +4231,7 @@ func (p *ParticipantImpl) UpdateAudioTrack(update *livekit.UpdateLocalAudioTrack
|
||||
p.sendRequestResponse(&livekit.RequestResponse{
|
||||
Reason: livekit.RequestResponse_NOT_FOUND,
|
||||
Request: &livekit.RequestResponse_UpdateAudioTrack{
|
||||
UpdateAudioTrack: utils.CloneProto(update),
|
||||
UpdateAudioTrack: proto.CloneOf(update),
|
||||
},
|
||||
})
|
||||
return errors.New("could not find track")
|
||||
@@ -4263,7 +4263,7 @@ func (p *ParticipantImpl) UpdateVideoTrack(update *livekit.UpdateLocalVideoTrack
|
||||
p.sendRequestResponse(&livekit.RequestResponse{
|
||||
Reason: livekit.RequestResponse_NOT_FOUND,
|
||||
Request: &livekit.RequestResponse_UpdateVideoTrack{
|
||||
UpdateVideoTrack: utils.CloneProto(update),
|
||||
UpdateVideoTrack: proto.CloneOf(update),
|
||||
},
|
||||
})
|
||||
return errors.New("could not find track")
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package rtc
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
"github.com/livekit/protocol/datatrack"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
@@ -30,7 +32,7 @@ func (p *ParticipantImpl) HandlePublishDataTrackRequest(req *livekit.PublishData
|
||||
Reason: livekit.RequestResponse_NOT_ALLOWED,
|
||||
Message: "does not have permission to publish data",
|
||||
Request: &livekit.RequestResponse_PublishDataTrack{
|
||||
PublishDataTrack: utils.CloneProto(req),
|
||||
PublishDataTrack: proto.CloneOf(req),
|
||||
},
|
||||
})
|
||||
return
|
||||
@@ -42,7 +44,7 @@ func (p *ParticipantImpl) HandlePublishDataTrackRequest(req *livekit.PublishData
|
||||
Reason: livekit.RequestResponse_INVALID_HANDLE,
|
||||
Message: "handle should be > 0 AND < 65536",
|
||||
Request: &livekit.RequestResponse_PublishDataTrack{
|
||||
PublishDataTrack: utils.CloneProto(req),
|
||||
PublishDataTrack: proto.CloneOf(req),
|
||||
},
|
||||
})
|
||||
return
|
||||
@@ -54,7 +56,7 @@ func (p *ParticipantImpl) HandlePublishDataTrackRequest(req *livekit.PublishData
|
||||
Reason: livekit.RequestResponse_INVALID_NAME,
|
||||
Message: "name should not be empty and should not exceed 256 characters",
|
||||
Request: &livekit.RequestResponse_PublishDataTrack{
|
||||
PublishDataTrack: utils.CloneProto(req),
|
||||
PublishDataTrack: proto.CloneOf(req),
|
||||
},
|
||||
})
|
||||
return
|
||||
@@ -67,7 +69,7 @@ func (p *ParticipantImpl) HandlePublishDataTrackRequest(req *livekit.PublishData
|
||||
Reason: livekit.RequestResponse_INVALID_REQUEST,
|
||||
Message: "encoding identifier is empty or exceeds the maximum length",
|
||||
Request: &livekit.RequestResponse_PublishDataTrack{
|
||||
PublishDataTrack: utils.CloneProto(req),
|
||||
PublishDataTrack: proto.CloneOf(req),
|
||||
},
|
||||
})
|
||||
return
|
||||
@@ -95,7 +97,7 @@ func (p *ParticipantImpl) HandlePublishDataTrackRequest(req *livekit.PublishData
|
||||
Reason: reason,
|
||||
Message: message,
|
||||
Request: &livekit.RequestResponse_PublishDataTrack{
|
||||
PublishDataTrack: utils.CloneProto(req),
|
||||
PublishDataTrack: proto.CloneOf(req),
|
||||
},
|
||||
})
|
||||
return
|
||||
@@ -108,8 +110,8 @@ func (p *ParticipantImpl) HandlePublishDataTrackRequest(req *livekit.PublishData
|
||||
Name: req.Name,
|
||||
Encryption: req.Encryption,
|
||||
}
|
||||
dti.FrameEncoding = utils.CloneProto(req.GetFrameEncoding())
|
||||
dti.Schema = utils.CloneProto(req.GetSchema())
|
||||
dti.FrameEncoding = proto.CloneOf(req.GetFrameEncoding())
|
||||
dti.Schema = proto.CloneOf(req.GetSchema())
|
||||
dt := NewDataTrack(
|
||||
DataTrackParams{
|
||||
Logger: p.params.Logger.WithValues("trackID", dti.Sid),
|
||||
@@ -143,7 +145,7 @@ func (p *ParticipantImpl) HandleUnpublishDataTrackRequest(req *livekit.Unpublish
|
||||
p.sendRequestResponse(&livekit.RequestResponse{
|
||||
Reason: livekit.RequestResponse_NOT_FOUND,
|
||||
Request: &livekit.RequestResponse_UnpublishDataTrack{
|
||||
UnpublishDataTrack: utils.CloneProto(req),
|
||||
UnpublishDataTrack: proto.CloneOf(req),
|
||||
},
|
||||
})
|
||||
return
|
||||
|
||||
@@ -560,7 +560,7 @@ func TestPreferMediaCodecForPublisher(t *testing.T) {
|
||||
for i := 0; i < 2; i++ {
|
||||
// publish preferred track without client using setCodecPreferences()
|
||||
trackCid := fmt.Sprintf("%s-%d", tc.trackBaseCid, i)
|
||||
req := utils.CloneProto(tc.addTrack)
|
||||
req := proto.CloneOf(tc.addTrack)
|
||||
req.SimulcastCodecs = []*livekit.SimulcastCodec{
|
||||
{
|
||||
Codec: tc.preferredCodec,
|
||||
|
||||
@@ -22,13 +22,13 @@ import (
|
||||
|
||||
"github.com/pion/sdp/v3"
|
||||
"github.com/pion/webrtc/v4"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
"github.com/livekit/protocol/codecs/mime"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
lksdp "github.com/livekit/protocol/sdp"
|
||||
"github.com/livekit/protocol/utils"
|
||||
)
|
||||
|
||||
func (p *ParticipantImpl) populateSdpCid(parsedOffer *sdp.SessionDescription) ([]*sdp.MediaDescription, []*sdp.MediaDescription) {
|
||||
@@ -143,7 +143,7 @@ func (p *ParticipantImpl) populateSdpCid(parsedOffer *sdp.SessionDescription) ([
|
||||
}
|
||||
|
||||
if updated {
|
||||
p.pendingTracks[signalCid].trackInfos[0] = utils.CloneProto(info)
|
||||
p.pendingTracks[signalCid].trackInfos[0] = proto.CloneOf(info)
|
||||
p.pubLogger.Debugw(
|
||||
"pending track SDP cid updated",
|
||||
"signalCid", signalCid,
|
||||
|
||||
+4
-4
@@ -254,7 +254,7 @@ func NewRoom(
|
||||
egressLauncher EgressLauncher,
|
||||
) *Room {
|
||||
r := &Room{
|
||||
protoRoom: utils.CloneProto(room),
|
||||
protoRoom: proto.CloneOf(room),
|
||||
internal: internal,
|
||||
logger: LoggerWithRoom(
|
||||
logger.GetLogger().WithComponent(sutils.ComponentRoom),
|
||||
@@ -874,7 +874,7 @@ func (r *Room) GetAgentDispatches(dispatchID string) ([]*livekit.AgentDispatch,
|
||||
|
||||
for _, ad := range r.agentDispatches {
|
||||
if dispatchID == "" || ad.Id == dispatchID {
|
||||
ret = append(ret, utils.CloneProto(ad.AgentDispatch))
|
||||
ret = append(ret, proto.CloneOf(ad.AgentDispatch))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1587,7 +1587,7 @@ func (r *Room) sendSpeakerChanges(speakers []*livekit.SpeakerInfo) {
|
||||
|
||||
func (r *Room) updateProto() *livekit.Room {
|
||||
r.lock.RLock()
|
||||
room := utils.CloneProto(r.protoRoom)
|
||||
room := proto.CloneOf(r.protoRoom)
|
||||
r.lock.RUnlock()
|
||||
|
||||
room.NumPublishers = 0
|
||||
@@ -1658,7 +1658,7 @@ func (r *Room) audioUpdateWorker() {
|
||||
// changedSpeakers need to include previous speakers that are no longer speaking
|
||||
for sid, speaker := range lastActiveMap {
|
||||
if nextActiveMap[sid] == nil {
|
||||
inactiveSpeaker := utils.CloneProto(speaker)
|
||||
inactiveSpeaker := proto.CloneOf(speaker)
|
||||
inactiveSpeaker.Level = 0
|
||||
inactiveSpeaker.Active = false
|
||||
changedSpeakers = append(changedSpeakers, inactiveSpeaker)
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
|
||||
"github.com/livekit/protocol/auth/authfakes"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/utils"
|
||||
"github.com/livekit/protocol/webhook"
|
||||
|
||||
"github.com/livekit/livekit-server/version"
|
||||
@@ -291,7 +290,7 @@ func TestPushAndDequeueUpdates(t *testing.T) {
|
||||
{
|
||||
name: "last version is enqueued",
|
||||
pi: subscriber1v2,
|
||||
existing: &ParticipantUpdate{ParticipantInfo: utils.CloneProto(subscriber1v1)}, // clone the existing value since it can be modified when setting to disconnected
|
||||
existing: &ParticipantUpdate{ParticipantInfo: proto.CloneOf(subscriber1v1)}, // clone the existing value since it can be modified when setting to disconnected
|
||||
validate: func(t *testing.T, rm *Room, _ []*ParticipantUpdate) {
|
||||
queued := rm.batchedUpdates[livekit.ParticipantIdentity(identity)]
|
||||
require.NotNil(t, queued)
|
||||
@@ -301,7 +300,7 @@ func TestPushAndDequeueUpdates(t *testing.T) {
|
||||
{
|
||||
name: "latest version when immediate",
|
||||
pi: subscriber1v2,
|
||||
existing: &ParticipantUpdate{ParticipantInfo: utils.CloneProto(subscriber1v1)},
|
||||
existing: &ParticipantUpdate{ParticipantInfo: proto.CloneOf(subscriber1v1)},
|
||||
immediate: true,
|
||||
expected: []*ParticipantUpdate{{ParticipantInfo: subscriber1v2}},
|
||||
validate: func(t *testing.T, rm *Room, _ []*ParticipantUpdate) {
|
||||
@@ -312,7 +311,7 @@ func TestPushAndDequeueUpdates(t *testing.T) {
|
||||
{
|
||||
name: "out of order updates are rejected",
|
||||
pi: subscriber1v1,
|
||||
existing: &ParticipantUpdate{ParticipantInfo: utils.CloneProto(subscriber1v2)},
|
||||
existing: &ParticipantUpdate{ParticipantInfo: proto.CloneOf(subscriber1v2)},
|
||||
validate: func(t *testing.T, rm *Room, updates []*ParticipantUpdate) {
|
||||
queued := rm.batchedUpdates[livekit.ParticipantIdentity(identity)]
|
||||
requirePIEquals(t, subscriber1v2, queued.ParticipantInfo)
|
||||
@@ -322,7 +321,7 @@ func TestPushAndDequeueUpdates(t *testing.T) {
|
||||
name: "sid change is broadcasted immediately with synthsized disconnect",
|
||||
pi: publisher2,
|
||||
closeReason: types.ParticipantCloseReasonServiceRequestRemoveParticipant, // just to test if update contain the close reason
|
||||
existing: &ParticipantUpdate{ParticipantInfo: utils.CloneProto(subscriber1v2), CloseReason: types.ParticipantCloseReasonStale},
|
||||
existing: &ParticipantUpdate{ParticipantInfo: proto.CloneOf(subscriber1v2), CloseReason: types.ParticipantCloseReasonStale},
|
||||
expected: []*ParticipantUpdate{
|
||||
{
|
||||
ParticipantInfo: &livekit.ParticipantInfo{
|
||||
@@ -340,7 +339,7 @@ func TestPushAndDequeueUpdates(t *testing.T) {
|
||||
{
|
||||
name: "when switching to publisher, queue is cleared",
|
||||
pi: publisher1v2,
|
||||
existing: &ParticipantUpdate{ParticipantInfo: utils.CloneProto(subscriber1v1)},
|
||||
existing: &ParticipantUpdate{ParticipantInfo: proto.CloneOf(subscriber1v1)},
|
||||
expected: []*ParticipantUpdate{{ParticipantInfo: publisher1v2}},
|
||||
validate: func(t *testing.T, rm *Room, updates []*ParticipantUpdate) {
|
||||
require.Empty(t, rm.batchedUpdates)
|
||||
@@ -651,7 +650,7 @@ func TestDataChannel(t *testing.T) {
|
||||
}
|
||||
setSource(mode, packet, p)
|
||||
|
||||
packetExp := utils.CloneProto(packet)
|
||||
packetExp := proto.CloneOf(packet)
|
||||
if mode != legacySID {
|
||||
packetExp.ParticipantIdentity = string(p.Identity())
|
||||
packetExp.GetUser().ParticipantIdentity = string(p.Identity())
|
||||
@@ -699,7 +698,7 @@ func TestDataChannel(t *testing.T) {
|
||||
setSource(mode, packet, p)
|
||||
setDest(mode, packet, p1)
|
||||
|
||||
packetExp := utils.CloneProto(packet)
|
||||
packetExp := proto.CloneOf(packet)
|
||||
if mode != legacySID {
|
||||
packetExp.ParticipantIdentity = string(p.Identity())
|
||||
packetExp.GetUser().ParticipantIdentity = string(p.Identity())
|
||||
|
||||
@@ -323,7 +323,7 @@ func (t *SubscribedTrack) UpdateSubscriberSettings(settings *livekit.UpdateTrack
|
||||
}
|
||||
|
||||
isImmediate = isImmediate || (!settings.Disabled && settings.Disabled != t.isMutedLocked())
|
||||
t.settings = utils.CloneProto(settings)
|
||||
t.settings = proto.CloneOf(settings)
|
||||
t.logger.Debugw("saving subscriber track settings", "settings", logger.Proto(t.settings))
|
||||
t.settingsLock.Unlock()
|
||||
|
||||
|
||||
@@ -675,7 +675,7 @@ func (t *TransportManager) GetICEConfig() *livekit.ICEConfig {
|
||||
if t.iceConfig == nil {
|
||||
return nil
|
||||
}
|
||||
return utils.CloneProto(t.iceConfig)
|
||||
return proto.CloneOf(t.iceConfig)
|
||||
}
|
||||
|
||||
func (t *TransportManager) resetTransportConfigureLocked(reconfigured bool) {
|
||||
|
||||
Reference in New Issue
Block a user