package config import ( "fmt" "strings" ) type Config struct { LogLevel string `yaml:"log_level"` Auth bool `yaml:"auth"` AuthSecret string `yaml:"auth_secret"` Port int `yaml:"port"` UStreamer UStreamer `yaml:"ustreamer"` FFmpeg FFmpeg `yaml:"ffmpeg"` WebRtc WebRtc `yaml:"webrtc"` Stream Stream `yaml:"stream"` NanoKVMUISupport bool `yaml:"nano_kvm_ui_support"` } type WebRtc struct { Host string `yaml:"host"` Port int `yaml:"port"` } type ExtProcess struct { Path string `yaml:"path"` Args string `yaml:"args"` } type Stream struct { Source string `yaml:"source"` // mjpeg or h264 } const ( StreamSourceMjpeg = "mjpeg" StreamSourceH264 = "h264" ) type FFmpeg struct { ExtProcess FPS int `yaml:"fps"` Bitrate int `yaml:"bitrate"` } func (f FFmpeg) FormatArgs() []string { return strings.Split(fmt.Sprintf(f.Args, f.Bitrate*1000, f.FPS), " ") } type UStreamer struct { Host string `yaml:"host"` Port int `yaml:"port"` ExtProcess } var c Config func Get() Config { return c } func Init() { c = Config{ LogLevel: "debug", Auth: false, Port: 8080, UStreamer: UStreamer{ Host: "0.0.0.0", Port: 8888, ExtProcess: ExtProcess{ Path: "/app/ustreamer", Args: "--host 0.0.0.0 --port 8888 -m BGR24 -f 60", }, }, FFmpeg: FFmpeg{ ExtProcess: ExtProcess{ Path: "/app/ffmpeg", Args: "-re -i /dev/video0 -c:v h264_rkmpp -b:v %d -framerate %d -bsf:v h264_mp4toannexb -g 10 -f rtp rtp://127.0.0.1:5004?pkt_size=1200", }, FPS: 60, Bitrate: 6000, }, WebRtc: WebRtc{ Host: "127.0.0.1", Port: 5004, }, Stream: Stream{ Source: StreamSourceMjpeg, }, NanoKVMUISupport: true, } }