forked from gabek/vadeo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
80 lines (59 loc) · 1.52 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
"fmt"
"io/ioutil"
"gopkg.in/yaml.v2"
)
const (
configFile = "config.yaml"
)
type Config struct {
AudioURL string `yaml:"audioUrl"`
AudioBitrate int `yaml:"audioBitrate"`
VideoQualityLevel int `yaml:"videoQualityLevel"`
CPUUsage string `yaml:"cpuUsage"`
VideoFramerate int `yaml:"framerate"`
StreamingURL string `yaml:"streamingURL"`
StreamingKey string `yaml:"streamingKey"`
OwncastServerURL string `yaml:"owncastServerURL"`
OwncastAccessToken string `yaml:"owncastAccessToken"`
UseArtistImage bool `yaml:"useArtistImage"`
UseAudioVisualizer bool `yaml:"useAudioVisualizer"`
FontFile string `yaml:"fontFile"`
ArtistFontSize int `yaml:"artistFontSize"`
TrackFontSize int `yaml:"trackFontSize"`
}
func loadConfig() Config {
var config Config
yamlFile, err := ioutil.ReadFile(configFile)
if err != nil {
fmt.Println("config file err", err)
return config
}
if err := yaml.Unmarshal(yamlFile, &config); err != nil {
fmt.Println("Error reading the config file.", err)
return config
}
if config.FontFile == "" {
config.FontFile = "FreeSans.ttf"
}
if config.ArtistFontSize == 0 {
config.ArtistFontSize = 40
}
if config.TrackFontSize == 0 {
config.TrackFontSize = 35
}
if config.AudioBitrate == 0 {
config.AudioBitrate = 128
}
if config.CPUUsage == "" {
config.CPUUsage = "faster"
}
if config.VideoQualityLevel == 0 {
config.VideoQualityLevel = 25
}
if config.VideoFramerate == 0 {
config.VideoFramerate = 24
}
return config
}