mirror of
https://github.com/livekit/livekit.git
synced 2026-08-02 17:49:30 +00:00
Include packetsMissing field in string representation (#1659)
* Include packetsMissing field in string representation * do not set stub directly
This commit is contained in:
@@ -31,7 +31,7 @@ func newMockParticipant(identity livekit.ParticipantIdentity, protocol types.Pro
|
||||
IsPublisher: publisher,
|
||||
})
|
||||
|
||||
p.SetMetadataStub = func(m string) {
|
||||
p.SetMetadataCalls(func(m string) {
|
||||
var f func(participant types.LocalParticipant)
|
||||
if p.OnParticipantUpdateCallCount() > 0 {
|
||||
f = p.OnParticipantUpdateArgsForCall(p.OnParticipantUpdateCallCount() - 1)
|
||||
@@ -39,7 +39,7 @@ func newMockParticipant(identity livekit.ParticipantIdentity, protocol types.Pro
|
||||
if f != nil {
|
||||
f(p)
|
||||
}
|
||||
}
|
||||
})
|
||||
updateTrack := func() {
|
||||
var f func(participant types.LocalParticipant, track types.MediaTrack)
|
||||
if p.OnTrackUpdatedCallCount() > 0 {
|
||||
@@ -50,12 +50,12 @@ func newMockParticipant(identity livekit.ParticipantIdentity, protocol types.Pro
|
||||
}
|
||||
}
|
||||
|
||||
p.SetTrackMutedStub = func(sid livekit.TrackID, muted bool, fromServer bool) {
|
||||
p.SetTrackMutedCalls(func(sid livekit.TrackID, muted bool, fromServer bool) {
|
||||
updateTrack()
|
||||
}
|
||||
p.AddTrackStub = func(req *livekit.AddTrackRequest) {
|
||||
})
|
||||
p.AddTrackCalls(func(req *livekit.AddTrackRequest) {
|
||||
updateTrack()
|
||||
}
|
||||
})
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ func TestDisableCodecs(t *testing.T) {
|
||||
participant.SetResponseSink(sink)
|
||||
var answer webrtc.SessionDescription
|
||||
var answerReceived atomic.Bool
|
||||
sink.WriteMessageStub = func(msg proto.Message) error {
|
||||
sink.WriteMessageCalls(func(msg proto.Message) error {
|
||||
if res, ok := msg.(*livekit.SignalResponse); ok {
|
||||
if res.GetAnswer() != nil {
|
||||
answer = FromProtoSessionDescription(res.GetAnswer())
|
||||
@@ -430,7 +430,7 @@ func TestDisableCodecs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
})
|
||||
participant.HandleOffer(sdp)
|
||||
|
||||
testutils.WithTimeout(t, func() string {
|
||||
@@ -579,7 +579,7 @@ func TestPreferAudioCodecForRed(t *testing.T) {
|
||||
participant.SetResponseSink(sink)
|
||||
var answer webrtc.SessionDescription
|
||||
var answerReceived atomic.Bool
|
||||
sink.WriteMessageStub = func(msg proto.Message) error {
|
||||
sink.WriteMessageCalls(func(msg proto.Message) error {
|
||||
if res, ok := msg.(*livekit.SignalResponse); ok {
|
||||
if res.GetAnswer() != nil {
|
||||
answer = FromProtoSessionDescription(res.GetAnswer())
|
||||
@@ -588,7 +588,7 @@ func TestPreferAudioCodecForRed(t *testing.T) {
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
})
|
||||
participant.HandleOffer(sdp)
|
||||
|
||||
require.Eventually(t, func() bool { return answerReceived.Load() }, 5*time.Second, 10*time.Millisecond)
|
||||
|
||||
@@ -214,9 +214,9 @@ func TestUnsubscribe(t *testing.T) {
|
||||
st.OnClose(func(willBeResumed bool) {
|
||||
sm.handleSubscribedTrackClose(s, willBeResumed)
|
||||
})
|
||||
res.Track.(*typesfakes.FakeMediaTrack).RemoveSubscriberStub = func(pID livekit.ParticipantID, willBeResumed bool) {
|
||||
res.Track.(*typesfakes.FakeMediaTrack).RemoveSubscriberCalls(func(pID livekit.ParticipantID, willBeResumed bool) {
|
||||
setTestSubscribedTrackClosed(t, st, willBeResumed)
|
||||
}
|
||||
})
|
||||
|
||||
sm.lock.Lock()
|
||||
sm.subscriptions["track"] = s
|
||||
@@ -280,12 +280,12 @@ func TestSubscribeStatusChanged(t *testing.T) {
|
||||
st2.OnClose(func(willBeResumed bool) {
|
||||
sm.handleSubscribedTrackClose(s2, willBeResumed)
|
||||
})
|
||||
st1.MediaTrack().(*typesfakes.FakeMediaTrack).RemoveSubscriberStub = func(pID livekit.ParticipantID, willBeResumed bool) {
|
||||
st1.MediaTrack().(*typesfakes.FakeMediaTrack).RemoveSubscriberCalls(func(pID livekit.ParticipantID, willBeResumed bool) {
|
||||
setTestSubscribedTrackClosed(t, st1, willBeResumed)
|
||||
}
|
||||
st2.MediaTrack().(*typesfakes.FakeMediaTrack).RemoveSubscriberStub = func(pID livekit.ParticipantID, willBeResumed bool) {
|
||||
})
|
||||
st2.MediaTrack().(*typesfakes.FakeMediaTrack).RemoveSubscriberCalls(func(pID livekit.ParticipantID, willBeResumed bool) {
|
||||
setTestSubscribedTrackClosed(t, st2, willBeResumed)
|
||||
}
|
||||
})
|
||||
|
||||
require.Equal(t, int32(1), numParticipantSubscribed.Load())
|
||||
require.Equal(t, int32(0), numParticipantUnsubscribed.Load())
|
||||
|
||||
@@ -101,11 +101,12 @@ func (w *windowStat) calculateBitrateScore(expectedBitrate int64) float64 {
|
||||
}
|
||||
|
||||
func (w *windowStat) String() string {
|
||||
return fmt.Sprintf("start: %+v, dur: %+v, pe: %d, pl: %d, b: %d, rtt: %d, jitter: %0.2f",
|
||||
return fmt.Sprintf("start: %+v, dur: %+v, pe: %d, pl: %d, pm: %d, b: %d, rtt: %d, jitter: %0.2f",
|
||||
w.startedAt,
|
||||
w.duration,
|
||||
w.packetsExpected,
|
||||
w.packetsLost,
|
||||
w.packetsMissing,
|
||||
w.bytes,
|
||||
w.rttMax,
|
||||
w.jitterMax,
|
||||
|
||||
Reference in New Issue
Block a user