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,
|
IsPublisher: publisher,
|
||||||
})
|
})
|
||||||
|
|
||||||
p.SetMetadataStub = func(m string) {
|
p.SetMetadataCalls(func(m string) {
|
||||||
var f func(participant types.LocalParticipant)
|
var f func(participant types.LocalParticipant)
|
||||||
if p.OnParticipantUpdateCallCount() > 0 {
|
if p.OnParticipantUpdateCallCount() > 0 {
|
||||||
f = p.OnParticipantUpdateArgsForCall(p.OnParticipantUpdateCallCount() - 1)
|
f = p.OnParticipantUpdateArgsForCall(p.OnParticipantUpdateCallCount() - 1)
|
||||||
@@ -39,7 +39,7 @@ func newMockParticipant(identity livekit.ParticipantIdentity, protocol types.Pro
|
|||||||
if f != nil {
|
if f != nil {
|
||||||
f(p)
|
f(p)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
updateTrack := func() {
|
updateTrack := func() {
|
||||||
var f func(participant types.LocalParticipant, track types.MediaTrack)
|
var f func(participant types.LocalParticipant, track types.MediaTrack)
|
||||||
if p.OnTrackUpdatedCallCount() > 0 {
|
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()
|
updateTrack()
|
||||||
}
|
})
|
||||||
p.AddTrackStub = func(req *livekit.AddTrackRequest) {
|
p.AddTrackCalls(func(req *livekit.AddTrackRequest) {
|
||||||
updateTrack()
|
updateTrack()
|
||||||
}
|
})
|
||||||
|
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ func TestDisableCodecs(t *testing.T) {
|
|||||||
participant.SetResponseSink(sink)
|
participant.SetResponseSink(sink)
|
||||||
var answer webrtc.SessionDescription
|
var answer webrtc.SessionDescription
|
||||||
var answerReceived atomic.Bool
|
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, ok := msg.(*livekit.SignalResponse); ok {
|
||||||
if res.GetAnswer() != nil {
|
if res.GetAnswer() != nil {
|
||||||
answer = FromProtoSessionDescription(res.GetAnswer())
|
answer = FromProtoSessionDescription(res.GetAnswer())
|
||||||
@@ -430,7 +430,7 @@ func TestDisableCodecs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
})
|
||||||
participant.HandleOffer(sdp)
|
participant.HandleOffer(sdp)
|
||||||
|
|
||||||
testutils.WithTimeout(t, func() string {
|
testutils.WithTimeout(t, func() string {
|
||||||
@@ -579,7 +579,7 @@ func TestPreferAudioCodecForRed(t *testing.T) {
|
|||||||
participant.SetResponseSink(sink)
|
participant.SetResponseSink(sink)
|
||||||
var answer webrtc.SessionDescription
|
var answer webrtc.SessionDescription
|
||||||
var answerReceived atomic.Bool
|
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, ok := msg.(*livekit.SignalResponse); ok {
|
||||||
if res.GetAnswer() != nil {
|
if res.GetAnswer() != nil {
|
||||||
answer = FromProtoSessionDescription(res.GetAnswer())
|
answer = FromProtoSessionDescription(res.GetAnswer())
|
||||||
@@ -588,7 +588,7 @@ func TestPreferAudioCodecForRed(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
})
|
||||||
participant.HandleOffer(sdp)
|
participant.HandleOffer(sdp)
|
||||||
|
|
||||||
require.Eventually(t, func() bool { return answerReceived.Load() }, 5*time.Second, 10*time.Millisecond)
|
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) {
|
st.OnClose(func(willBeResumed bool) {
|
||||||
sm.handleSubscribedTrackClose(s, willBeResumed)
|
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)
|
setTestSubscribedTrackClosed(t, st, willBeResumed)
|
||||||
}
|
})
|
||||||
|
|
||||||
sm.lock.Lock()
|
sm.lock.Lock()
|
||||||
sm.subscriptions["track"] = s
|
sm.subscriptions["track"] = s
|
||||||
@@ -280,12 +280,12 @@ func TestSubscribeStatusChanged(t *testing.T) {
|
|||||||
st2.OnClose(func(willBeResumed bool) {
|
st2.OnClose(func(willBeResumed bool) {
|
||||||
sm.handleSubscribedTrackClose(s2, willBeResumed)
|
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)
|
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)
|
setTestSubscribedTrackClosed(t, st2, willBeResumed)
|
||||||
}
|
})
|
||||||
|
|
||||||
require.Equal(t, int32(1), numParticipantSubscribed.Load())
|
require.Equal(t, int32(1), numParticipantSubscribed.Load())
|
||||||
require.Equal(t, int32(0), numParticipantUnsubscribed.Load())
|
require.Equal(t, int32(0), numParticipantUnsubscribed.Load())
|
||||||
|
|||||||
@@ -101,11 +101,12 @@ func (w *windowStat) calculateBitrateScore(expectedBitrate int64) float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowStat) String() string {
|
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.startedAt,
|
||||||
w.duration,
|
w.duration,
|
||||||
w.packetsExpected,
|
w.packetsExpected,
|
||||||
w.packetsLost,
|
w.packetsLost,
|
||||||
|
w.packetsMissing,
|
||||||
w.bytes,
|
w.bytes,
|
||||||
w.rttMax,
|
w.rttMax,
|
||||||
w.jitterMax,
|
w.jitterMax,
|
||||||
|
|||||||
Reference in New Issue
Block a user