De-centralize some configs to where they are used. (#3162)
* De-centralize some configs to where they are used. And make default variables. Renaming a bit, but these are all internal config and have not been added to documented config. * Keep documented config as is. * test * typo
This commit is contained in:
@@ -18,7 +18,6 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/protocol/logger"
|
||||
)
|
||||
|
||||
@@ -30,8 +29,42 @@ const (
|
||||
frameRateDecreaseFactor = 0.9 // fast decrease
|
||||
)
|
||||
|
||||
// -------------------------------------------------------
|
||||
|
||||
type StreamTrackerFrameConfig struct {
|
||||
MinFPS float64 `yaml:"min_fps,omitempty"`
|
||||
}
|
||||
|
||||
var (
|
||||
DefaultStreamTrackerFrameConfigVideo = map[int32]StreamTrackerFrameConfig{
|
||||
0: {
|
||||
MinFPS: 5.0,
|
||||
},
|
||||
1: {
|
||||
MinFPS: 5.0,
|
||||
},
|
||||
2: {
|
||||
MinFPS: 5.0,
|
||||
},
|
||||
}
|
||||
|
||||
DefaultStreamTrackerFrameConfigScreenshare = map[int32]StreamTrackerFrameConfig{
|
||||
0: {
|
||||
MinFPS: 0.5,
|
||||
},
|
||||
1: {
|
||||
MinFPS: 0.5,
|
||||
},
|
||||
2: {
|
||||
MinFPS: 0.5,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// -------------------------------------------------------
|
||||
|
||||
type StreamTrackerFrameParams struct {
|
||||
Config config.StreamTrackerFrameConfig
|
||||
Config StreamTrackerFrameConfig
|
||||
ClockRate uint32
|
||||
Logger logger.Logger
|
||||
}
|
||||
|
||||
@@ -17,12 +17,56 @@ package streamtracker
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/protocol/logger"
|
||||
)
|
||||
|
||||
// --------------------------------------------
|
||||
|
||||
type StreamTrackerPacketConfig struct {
|
||||
SamplesRequired uint32 `yaml:"samples_required,omitempty"` // number of samples needed per cycle
|
||||
CyclesRequired uint32 `yaml:"cycles_required,omitempty"` // number of cycles needed to be active
|
||||
CycleDuration time.Duration `yaml:"cycle_duration,omitempty"`
|
||||
}
|
||||
|
||||
var (
|
||||
DefaultStreamTrackerPacketConfigVideo = map[int32]StreamTrackerPacketConfig{
|
||||
0: {SamplesRequired: 1,
|
||||
CyclesRequired: 4,
|
||||
CycleDuration: 500 * time.Millisecond,
|
||||
},
|
||||
1: {SamplesRequired: 5,
|
||||
CyclesRequired: 20,
|
||||
CycleDuration: 500 * time.Millisecond,
|
||||
},
|
||||
2: {SamplesRequired: 5,
|
||||
CyclesRequired: 20,
|
||||
CycleDuration: 500 * time.Millisecond,
|
||||
},
|
||||
}
|
||||
|
||||
DefaultStreamTrackerPacketConfigScreenshare = map[int32]StreamTrackerPacketConfig{
|
||||
0: {
|
||||
SamplesRequired: 1,
|
||||
CyclesRequired: 1,
|
||||
CycleDuration: 2 * time.Second,
|
||||
},
|
||||
1: {
|
||||
SamplesRequired: 1,
|
||||
CyclesRequired: 1,
|
||||
CycleDuration: 2 * time.Second,
|
||||
},
|
||||
2: {
|
||||
SamplesRequired: 1,
|
||||
CyclesRequired: 1,
|
||||
CycleDuration: 2 * time.Second,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// --------------------------------------------
|
||||
|
||||
type StreamTrackerPacketParams struct {
|
||||
Config config.StreamTrackerPacketConfig
|
||||
Config StreamTrackerPacketConfig
|
||||
Logger logger.Logger
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,13 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/atomic"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/livekit-server/pkg/testutils"
|
||||
"github.com/livekit/protocol/logger"
|
||||
)
|
||||
|
||||
func newStreamTrackerPacket(samplesRequired uint32, cyclesRequired uint32, cycleDuration time.Duration) *StreamTracker {
|
||||
stp := NewStreamTrackerPacket(StreamTrackerPacketParams{
|
||||
Config: config.StreamTrackerPacketConfig{
|
||||
Config: StreamTrackerPacketConfig{
|
||||
SamplesRequired: samplesRequired,
|
||||
CyclesRequired: cyclesRequired,
|
||||
CycleDuration: cycleDuration,
|
||||
|
||||
Reference in New Issue
Block a user