Archived
2
0

default screen size

This commit is contained in:
Craig
2020-02-11 06:10:54 +00:00
parent e9cf941870
commit 4fe1d481a0
2 changed files with 44 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package config
import (
"regexp"
"strconv"
"strings"
@ -20,6 +21,9 @@ type WebRTC struct {
EphemeralMin uint16
EphemeralMax uint16
NAT1To1IPs []string
ScreenWidth int
ScreenHeight int
ScreenRate int
}
func (WebRTC) Init(cmd *cobra.Command) error {
@ -43,6 +47,11 @@ func (WebRTC) Init(cmd *cobra.Command) error {
return err
}
cmd.PersistentFlags().String("screen", "1280x720@30", "default screen resolution and framerate")
if err := viper.BindPFlag("vparams", cmd.PersistentFlags().Lookup("video")); err != nil {
return err
}
cmd.PersistentFlags().String("epr", "59000-59100", "limits the pool of ephemeral ports that ICE UDP connections can allocate from")
if err := viper.BindPFlag("epr", cmd.PersistentFlags().Lookup("epr")); err != nil {
return err
@ -150,4 +159,23 @@ func (s *WebRTC) Set() {
s.EphemeralMin = min
s.EphemeralMax = max
}
s.ScreenWidth = 1280
s.ScreenHeight = 720
s.ScreenRate = 30
r := regexp.MustCompile(`([0-9]{1,4})x([0-9]{1,4})@([0-9]{1,3})`)
res := r.FindStringSubmatch(viper.GetString("screen"))
if len(res) > 0 {
width, err1 := strconv.ParseInt(res[1], 10, 64)
height, err2 := strconv.ParseInt(res[1], 10, 64)
rate, err3 := strconv.ParseInt(res[1], 10, 64)
if err1 == nil && err2 == nil && err3 == nil {
s.ScreenWidth = int(width)
s.ScreenHeight = int(height)
s.ScreenRate = int(rate)
}
}
}