Tweak screen share stream tracker. (#683)

* Tweak screen share stream tracker.

Screen share uses extremely low frame rate when content is static.
This leads to stream tracker changes and layer switches.
Use a longer measurement interval for screen share tracks.
Setting it to 4 seconds. The screen share frame rate is
approx. 1 fps and with two temporal layers, it should get
a frame every 2 seconds or so in every layer. But, that
does not work. Even three second measurement window was
reporting 0 rate. So, it is getting clumped. 4 seconds works
fine.

Also modifying the bit rate availability change to trigger
on a temporal layer becoming available or going away.

With these changes, on a local test, not seeing any unnecessary
PLIs from client and hence no unnecessary key frames from publisher.

* Fix test
This commit is contained in:
Raja Subramanian
2022-05-13 10:18:18 +05:30
committed by GitHub
parent 9eacad04c9
commit 710e06b7da
3 changed files with 41 additions and 39 deletions
+26 -19
View File
@@ -5,6 +5,7 @@ import (
"sync"
"time"
"github.com/go-logr/logr"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
)
@@ -16,38 +17,44 @@ var (
var (
ConfigVideo = []StreamTrackerParams{
{
SamplesRequired: 1,
CyclesRequired: 4,
CycleDuration: 500 * time.Millisecond,
SamplesRequired: 1,
CyclesRequired: 4,
CycleDuration: 500 * time.Millisecond,
BitrateReportInterval: 1 * time.Second,
},
{
SamplesRequired: 5,
CyclesRequired: 60,
CycleDuration: 500 * time.Millisecond,
SamplesRequired: 5,
CyclesRequired: 60,
CycleDuration: 500 * time.Millisecond,
BitrateReportInterval: 1 * time.Second,
},
{
SamplesRequired: 5,
CyclesRequired: 60,
CycleDuration: 500 * time.Millisecond,
SamplesRequired: 5,
CyclesRequired: 60,
CycleDuration: 500 * time.Millisecond,
BitrateReportInterval: 1 * time.Second,
},
}
// be very forgiving for screen share to account for cases like static screen where there could be only one packet per second
ConfigScreenshare = []StreamTrackerParams{
{
SamplesRequired: 1,
CyclesRequired: 1,
CycleDuration: 2 * time.Second,
SamplesRequired: 1,
CyclesRequired: 1,
CycleDuration: 2 * time.Second,
BitrateReportInterval: 4 * time.Second,
},
{
SamplesRequired: 1,
CyclesRequired: 1,
CycleDuration: 2 * time.Second,
SamplesRequired: 1,
CyclesRequired: 1,
CycleDuration: 2 * time.Second,
BitrateReportInterval: 4 * time.Second,
},
{
SamplesRequired: 1,
CyclesRequired: 1,
CycleDuration: 2 * time.Second,
SamplesRequired: 1,
CyclesRequired: 1,
CycleDuration: 2 * time.Second,
BitrateReportInterval: 4 * time.Second,
},
}
)
@@ -98,7 +105,7 @@ func (s *StreamTrackerManager) AddTracker(layer int32) *StreamTracker {
params = ConfigVideo[layer]
}
params.Logger = s.logger
params.Logger = logger.Logger(logr.Logger(s.logger).WithValues("layer", layer))
tracker := NewStreamTracker(params)
tracker.OnStatusChanged(func(status StreamStatus) {
if status == StreamStatusStopped {