Rob Watson 5f026be769 refactor(config)!: update config file schema
BREAKING CHANGE: YAML schema
2025-04-18 18:00:28 +02:00

54 lines
1.3 KiB
Go

package config
import "cmp"
// Destination holds the configuration for a destination.
type Destination struct {
Name string `yaml:"name"`
URL string `yaml:"url"`
}
// LogFile holds the configuration for the log file.
type LogFile struct {
Enabled bool `yaml:"enabled"`
Path string `yaml:"path,omitempty"`
defaultPath string
}
// GetPath returns the path to the log file. If the path is not set, it
// returns the default log path.
func (l LogFile) GetPath() string {
return cmp.Or(l.Path, l.defaultPath)
}
// NetAddr holds an IP and/or port.
type NetAddr struct {
IP string `yaml:"ip,omitempty"`
Port int `yaml:"port,omitempty"`
}
// RTMPSource holds the configuration for the RTMP source.
type RTMPSource struct {
NetAddr `yaml:",inline"`
}
// MediaServerSource holds the configuration for the media server source.
type MediaServerSource struct {
StreamKey string `yaml:"streamKey,omitempty"`
Host string `yaml:"host,omitempty"`
RTMP *RTMPSource `yaml:"rtmp,omitempty"`
}
// Sources holds the configuration for the sources.
type Sources struct {
MediaServer MediaServerSource `yaml:"mediaServer"`
}
// Config holds the configuration for the application.
type Config struct {
LogFile LogFile `yaml:"logfile"`
Sources Sources `yaml:"sources"`
Destinations []Destination `yaml:"destinations"`
}