Toggle estimator config (#32)

* add estimator to conifg.

* ensure video auto is false when estimator is disabled.
This commit is contained in:
Miroslav Šedivý
2023-02-26 21:54:10 +01:00
committed by GitHub
parent 64abfd0b1a
commit a4a3ff79ad
3 changed files with 81 additions and 38 deletions

View File

@ -26,6 +26,9 @@ type WebRTC struct {
NAT1To1IPs []string
IpRetrievalUrl string
EstimatorEnabled bool
EstimatorInitialBitrate int
}
func (WebRTC) Init(cmd *cobra.Command) error {
@ -69,6 +72,18 @@ func (WebRTC) Init(cmd *cobra.Command) error {
return err
}
// bandwidth estimator
cmd.PersistentFlags().Bool("webrtc.estimator.enabled", false, "enables the bandwidth estimator")
if err := viper.BindPFlag("webrtc.estimator.enabled", cmd.PersistentFlags().Lookup("webrtc.estimator.enabled")); err != nil {
return err
}
cmd.PersistentFlags().Int("webrtc.estimator.initial_bitrate", 1_000_000, "initial bitrate for the bandwidth estimator")
if err := viper.BindPFlag("webrtc.estimator.initial_bitrate", cmd.PersistentFlags().Lookup("webrtc.estimator.initial_bitrate")); err != nil {
return err
}
return nil
}
@ -135,4 +150,9 @@ func (s *WebRTC) Set() {
log.Warn().Err(err).Msgf("IP retrieval failed")
}
}
// bandwidth estimator
s.EstimatorEnabled = viper.GetBool("webrtc.estimator.enabled")
s.EstimatorInitialBitrate = viper.GetInt("webrtc.estimator.initial_bitrate")
}