Skip to content

Commit

Permalink
typo bitrate config
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohan Totting committed Jan 5, 2024
1 parent 2b3ef37 commit e09d78e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions bitratecontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (bc *bitrateController) getDistributedQuality(totalTracks int) QualityLevel

distributedBandwidth := availableBandwidth / uint32(totalTracks)

bitrateConfig := bc.client.SFU().bitratesConfig
bitrateConfig := bc.client.SFU().bitrateConfigs

if distributedBandwidth < bitrateConfig.VideoMid {
return QualityLow
Expand Down Expand Up @@ -630,9 +630,9 @@ func (bc *bitrateController) onRemoteViewedSizeChanged(videoSize videoSize) {
claim.track.SetMaxQuality(QualityNone)
}

if videoSize.Width*videoSize.Height <= bc.client.sfu.bitratesConfig.VideoLowPixels {
if videoSize.Width*videoSize.Height <= bc.client.sfu.bitrateConfigs.VideoLowPixels {
claim.track.SetMaxQuality(QualityLow)
} else if videoSize.Width*videoSize.Height <= bc.client.sfu.bitratesConfig.VideoMidPixels {
} else if videoSize.Width*videoSize.Height <= bc.client.sfu.bitrateConfigs.VideoMidPixels {
claim.track.SetMaxQuality(QualityMid)
} else {
claim.track.SetMaxQuality(QualityHigh)
Expand Down
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func NewClient(s *SFU, id string, name string, peerConnectionConfig webrtc.Confi
congestionController, err := cc.NewInterceptor(func() (cc.BandwidthEstimator, error) {
// if bw below 100_000, somehow the estimator will struggle to probe the bandwidth and will stuck there. So we set the min to 100_000
// TODO: we need to use packet loss based bandwidth adjuster when the bandwidth is below 100_000
return gcc.NewSendSideBWE(gcc.SendSideBWEInitialBitrate(int(s.bitratesConfig.InitialBandwidth)))
return gcc.NewSendSideBWE(gcc.SendSideBWEInitialBitrate(int(s.bitrateConfigs.InitialBandwidth)))
})
if err != nil {
panic(err)
Expand Down Expand Up @@ -1149,7 +1149,7 @@ func (c *Client) GetEstimatedBandwidth() uint32 {
estimated := uint32(0)

if c.estimator == nil {
estimated = uint32(c.sfu.bitratesConfig.InitialBandwidth)
estimated = uint32(c.sfu.bitrateConfigs.InitialBandwidth)
} else {
estimated = uint32(c.estimator.GetTargetBitrate())
c.egressBandwidth.Store(estimated)
Expand Down
8 changes: 4 additions & 4 deletions room.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type Room struct {
type RoomOptions struct {
// Configures the bitrates configuration that will be used by the room
// Make sure to use the same bitrate config when publishing video because this is used to manage the usage bandwidth in this room
Bitrates BitratesConfig
Bitrates BitrateConfigs
// Configures the codecs that will be used by the room
Codecs []string
// Configures the timeout for client to join the room after register
Expand Down Expand Up @@ -367,12 +367,12 @@ func (r *Room) CreateDataChannel(label string, opts DataChannelOptions) error {
return r.sfu.CreateDataChannel(label, opts)
}

// BitratesConfig return the current bitrate configuration that used in bitrate controller
// BitrateConfigs return the current bitrate configuration that used in bitrate controller
// Client should use this to configure the bitrate when publishing media tracks
// Inconsistent bitrate configuration between client and server will result missed bitrate calculation and
// could affecting packet loss and media quality
func (r *Room) BitratesConfig() BitratesConfig {
return r.sfu.bitratesConfig
func (r *Room) BitrateConfigs() BitrateConfigs {
return r.sfu.bitrateConfigs
}

// CodecsPreference return the current codecs preference that used in SFU
Expand Down
24 changes: 12 additions & 12 deletions sfu.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
"golang.org/x/exp/slices"
)

// BitratesConfig is the configuration for the bitrate that will be used for adaptive bitrates controller
// BitrateConfigs is the configuration for the bitrate that will be used for adaptive bitrates controller
// The paramenter is in bps (bit per second) for non pixels parameters.
// For pixels parameters, it is total pixels (width * height) of the video.
// High, Mid, and Low are the references for bitrate controller to decide the max bitrate to send to the client.
type BitratesConfig struct {
type BitrateConfigs struct {
AudioRed uint32 `json:"audio_red,omitempty" yaml:"audio_red,omitempty" mapstructure:"audio_red,omitempty"`
Audio uint32 `json:"audio,omitempty" yaml:"audio,omitempty" mapstructure:"audio,omitempty"`
Video uint32 `json:"video,omitempty" yaml:"video,omitempty" mapstructure:"video,omitempty"`
Expand All @@ -28,8 +28,8 @@ type BitratesConfig struct {
InitialBandwidth uint32 `json:"initial_bandwidth,omitempty" yaml:"initial_bandwidth,omitempty" mapstructure:"initial_bandwidth,omitempty"`
}

func DefaultBitrates() BitratesConfig {
return BitratesConfig{
func DefaultBitrates() BitrateConfigs {
return BitrateConfigs{
AudioRed: 65_000,
Audio: 48_000,
Video: 1_200_000,
Expand Down Expand Up @@ -105,7 +105,7 @@ func (s *SFUClients) Remove(client *Client) error {
}

type SFU struct {
bitratesConfig BitratesConfig
bitrateConfigs BitrateConfigs
clients *SFUClients
context context.Context
cancel context.CancelFunc
Expand Down Expand Up @@ -139,7 +139,7 @@ type sfuOptions struct {
Mux *UDPMux
PortStart uint16
PortEnd uint16
Bitrates BitratesConfig
Bitrates BitrateConfigs
QualityPreset QualityPreset
Codecs []string
PLIInterval time.Duration
Expand All @@ -161,7 +161,7 @@ func New(ctx context.Context, opts sfuOptions) *SFU {
mu: sync.Mutex{},
iceServers: opts.IceServers,
mux: opts.Mux,
bitratesConfig: opts.Bitrates,
bitrateConfigs: opts.Bitrates,
enableBandwidthEstimator: opts.EnableBandwidthEstimator,
pliInterval: opts.PLIInterval,
qualityRef: opts.QualityPreset,
Expand Down Expand Up @@ -578,15 +578,15 @@ func (s *SFU) TotalActiveSessions() int {
func (s *SFU) QualityLevelToBitrate(level QualityLevel) uint32 {
switch level {
case QualityAudioRed:
return s.bitratesConfig.AudioRed
return s.bitrateConfigs.AudioRed
case QualityAudio:
return s.bitratesConfig.Audio
return s.bitrateConfigs.Audio
case QualityLow:
return s.bitratesConfig.VideoLow
return s.bitrateConfigs.VideoLow
case QualityMid:
return s.bitratesConfig.VideoMid
return s.bitrateConfigs.VideoMid
case QualityHigh:
return s.bitratesConfig.VideoHigh
return s.bitrateConfigs.VideoHigh
default:
return 0
}
Expand Down

0 comments on commit e09d78e

Please sign in to comment.