Add fps calculator for VP8 and DependencyDescriptor (#1110)

* Add fps calculator for VP8 and DependencyDescriptor

* clean code

* unit test

* clean code

* solve comment
This commit is contained in:
cnderrauber
2022-10-26 09:28:28 +08:00
committed by GitHub
parent 96a058b503
commit 7a7fc09372
17 changed files with 1040 additions and 35 deletions
+12 -12
View File
@@ -34,7 +34,7 @@ func TestStreamTracker(t *testing.T) {
require.Equal(t, StreamStatusStopped, tracker.Status())
// observe first packet
tracker.Observe(1, 0, 20, 10)
tracker.Observe(0, 20, 10)
testutils.WithTimeout(t, func() string {
if callbackCalled.Load() {
@@ -65,7 +65,7 @@ func TestStreamTracker(t *testing.T) {
callbackStatusMu.Unlock()
})
tracker.Observe(1, 0, 20, 10)
tracker.Observe(0, 20, 10)
testutils.WithTimeout(t, func() string {
callbackStatusMu.RLock()
defer callbackStatusMu.RUnlock()
@@ -102,7 +102,7 @@ func TestStreamTracker(t *testing.T) {
tracker.Start()
require.Equal(t, StreamStatusStopped, tracker.Status())
tracker.Observe(1, 0, 20, 10)
tracker.Observe(0, 20, 10)
testutils.WithTimeout(t, func() string {
if tracker.Status() == StreamStatusActive {
return ""
@@ -113,11 +113,11 @@ func TestStreamTracker(t *testing.T) {
tracker.maybeSetStatus(StreamStatusStopped)
tracker.Observe(2, 0, 20, 10)
tracker.Observe(0, 20, 10)
tracker.detectChanges()
require.Equal(t, StreamStatusStopped, tracker.Status())
tracker.Observe(3, 0, 20, 10)
tracker.Observe(0, 20, 10)
tracker.detectChanges()
require.Equal(t, StreamStatusActive, tracker.Status())
@@ -127,7 +127,7 @@ func TestStreamTracker(t *testing.T) {
t.Run("changes to inactive when paused", func(t *testing.T) {
tracker := newStreamTracker(5, 60, 500*time.Millisecond)
tracker.Start()
tracker.Observe(1, 0, 20, 10)
tracker.Observe(0, 20, 10)
testutils.WithTimeout(t, func() string {
if tracker.Status() == StreamStatusActive {
return ""
@@ -153,7 +153,7 @@ func TestStreamTracker(t *testing.T) {
require.Equal(t, StreamStatusStopped, tracker.Status())
// observe first packet
tracker.Observe(1, 0, 20, 10)
tracker.Observe(0, 20, 10)
testutils.WithTimeout(t, func() string {
if callbackCalled.Load() == 1 {
@@ -167,10 +167,10 @@ func TestStreamTracker(t *testing.T) {
require.Equal(t, uint32(1), callbackCalled.Load())
// observe a few more
tracker.Observe(2, 0, 20, 10)
tracker.Observe(3, 0, 20, 10)
tracker.Observe(4, 0, 20, 10)
tracker.Observe(5, 0, 20, 10)
tracker.Observe(0, 20, 10)
tracker.Observe(0, 20, 10)
tracker.Observe(0, 20, 10)
tracker.Observe(0, 20, 10)
tracker.detectChanges()
// should still be active
@@ -181,7 +181,7 @@ func TestStreamTracker(t *testing.T) {
require.Equal(t, StreamStatusStopped, tracker.Status())
// first packet after reset
tracker.Observe(1, 0, 20, 10)
tracker.Observe(0, 20, 10)
testutils.WithTimeout(t, func() string {
if callbackCalled.Load() == 2 {