Documentation
¶
Overview ¶
Package config holds the root configuration struct and Viper-based loading.
Index ¶
- type BufferConfig
- type CORSConfig
- type HooksConfig
- type IngestorConfig
- type ListenersConfig
- type LogConfig
- type ManagerConfig
- type PublisherConfig
- type PublisherDASHConfig
- type PublisherHLSConfig
- type RTMPListenerConfig
- type RTSPListenerConfig
- type SRTListenerConfig
- type ServerConfig
- type StorageConfig
- type TranscoderConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferConfig ¶
type BufferConfig struct {
// Capacity is the number of MPEG-TS packets per stream buffer.
Capacity int `mapstructure:"capacity" json:"capacity" yaml:"capacity"`
}
BufferConfig controls the in-memory ring buffer.
type CORSConfig ¶
type CORSConfig struct {
// Enabled turns CORS middleware on for the HTTP listener.
Enabled bool `mapstructure:"enabled" json:"enabled" yaml:"enabled"`
// AllowedOrigins lists values for Access-Control-Allow-Origin. Use "*"
// for any origin (cannot be used together with AllowCredentials).
AllowedOrigins []string `mapstructure:"allowed_origins" json:"allowed_origins" yaml:"allowed_origins"`
// AllowedMethods lists Access-Control-Allow-Methods; empty uses a REST default set.
AllowedMethods []string `mapstructure:"allowed_methods" json:"allowed_methods,omitempty" yaml:"allowed_methods,omitempty"`
// AllowedHeaders lists Access-Control-Allow-Headers; empty uses a common API default set.
AllowedHeaders []string `mapstructure:"allowed_headers" json:"allowed_headers,omitempty" yaml:"allowed_headers,omitempty"`
// ExposedHeaders lists Access-Control-Expose-Headers.
ExposedHeaders []string `mapstructure:"exposed_headers" json:"exposed_headers,omitempty" yaml:"exposed_headers,omitempty"`
// AllowCredentials sets Access-Control-Allow-Credentials. Must be false
// when AllowedOrigins contains "*".
AllowCredentials bool `mapstructure:"allow_credentials" json:"allow_credentials" yaml:"allow_credentials"`
// MaxAge is the preflight cache duration in seconds (Access-Control-Max-Age).
MaxAge int `mapstructure:"max_age" json:"max_age" yaml:"max_age"`
}
CORSConfig controls Cross-Origin Resource Sharing for the HTTP API and static media routes mounted on the same listener.
type HooksConfig ¶
type HooksConfig struct {
// WorkerCount is the number of concurrent hook delivery goroutines.
WorkerCount int `mapstructure:"worker_count" json:"worker_count" yaml:"worker_count"`
// KafkaBrokers is the list of Kafka broker addresses used by all Kafka-type hooks.
// Example: ["localhost:9092", "broker2:9092"].
// Empty = Kafka hooks are not available.
KafkaBrokers []string `mapstructure:"kafka_brokers" json:"kafka_brokers,omitempty" yaml:"kafka_brokers,omitempty"`
}
HooksConfig controls the hook dispatcher worker pool. Per-hook settings (max retries, timeout, secret, event filter) are configured on each Hook via the API.
type IngestorConfig ¶
type IngestorConfig struct {
// HLSMaxSegmentBuffer caps the number of pre-fetched HLS segments held in memory.
// This is a server-wide memory guard, not a per-stream policy.
HLSMaxSegmentBuffer int `mapstructure:"hls_max_segment_buffer" json:"hls_max_segment_buffer" yaml:"hls_max_segment_buffer"` // default 8
}
IngestorConfig controls server-level ingestion infrastructure. Per-input settings (timeouts, S3 region, SRT latency, etc.) are configured on each Input via the API and stored in the data storage.
Network listeners (RTMP, SRT, RTSP) are configured in the top-level ListenersConfig and shared with the publisher, so the same port serves both push (ingest) and pull (play) traffic.
type ListenersConfig ¶
type ListenersConfig struct {
RTMP RTMPListenerConfig `mapstructure:"rtmp" json:"rtmp" yaml:"rtmp"`
RTSP RTSPListenerConfig `mapstructure:"rtsp" json:"rtsp" yaml:"rtsp"`
SRT SRTListenerConfig `mapstructure:"srt" json:"srt" yaml:"srt"`
}
ListenersConfig groups all live network listeners.
Each protocol uses ONE port that serves both directions of traffic:
- RTMP: encoders push, players pull, on the same TCP port (default 1935).
- RTSP: clients pull live streams (default 554).
- SRT: encoders push or clients pull on the same UDP port (default 9999), dispatched by the SRT streamid mode flag.
Setting Enabled=false (or leaving the section out entirely) disables that protocol's listener for both ingest and playback.
type LogConfig ¶
type LogConfig struct {
Level string `mapstructure:"level" json:"level" yaml:"level"` // debug | info | warn | error
Format string `mapstructure:"format" json:"format" yaml:"format"` // text | json
}
LogConfig controls structured logging output.
type ManagerConfig ¶
type ManagerConfig struct {
// InputPacketTimeoutSec is the maximum gap without a successful read on the
// active input before it is marked failed. Pull protocols that deliver in
// bursts (e.g. HLS: one segment per Read) need this at least as large as the
// typical interval between reads (segment duration + playlist poll), or a
// healthy primary will be falsely failed over to a lower priority.
InputPacketTimeoutSec int `mapstructure:"input_packet_timeout_sec" json:"input_packet_timeout_sec" yaml:"input_packet_timeout_sec"`
}
ManagerConfig controls Stream Manager failover and input health checks.
type PublisherConfig ¶
type PublisherConfig struct {
HLS PublisherHLSConfig `mapstructure:"hls" json:"hls" yaml:"hls"`
DASH PublisherDASHConfig `mapstructure:"dash" json:"dash" yaml:"dash"`
}
PublisherConfig controls filesystem-based output delivery (HLS, DASH). Live network listeners (RTSP, RTMP, SRT) are configured in ListenersConfig because the same port serves both ingest and playback.
type PublisherDASHConfig ¶
type PublisherDASHConfig struct {
Dir string `mapstructure:"dir" json:"dir" yaml:"dir"`
// Live* mirror HLS packaging semantics for the DASH muxer.
LiveEphemeral bool `mapstructure:"live_ephemeral" json:"live_ephemeral" yaml:"live_ephemeral"`
LiveSegmentSec int `mapstructure:"live_segment_sec" json:"live_segment_sec" yaml:"live_segment_sec"`
LiveWindow int `mapstructure:"live_window" json:"live_window" yaml:"live_window"`
LiveHistory int `mapstructure:"live_history" json:"live_history" yaml:"live_history"`
}
PublisherDASHConfig is filesystem + live packaging for MPEG-DASH (dynamic MPD + ISO BMFF init/media .m4s). Dir must be set and must not match PublisherHLSConfig.Dir (separate subscribers and segment files).
type PublisherHLSConfig ¶
type PublisherHLSConfig struct {
Dir string `mapstructure:"dir" json:"dir" yaml:"dir"`
// LiveEphemeral enables bounded retention (sliding manifest, delete old segments).
LiveEphemeral bool `mapstructure:"live_ephemeral" json:"live_ephemeral" yaml:"live_ephemeral"`
// LiveSegmentSec is segment duration in seconds.
LiveSegmentSec int `mapstructure:"live_segment_sec" json:"live_segment_sec" yaml:"live_segment_sec"`
// LiveWindow is the sliding window size (segments) in the playlist.
LiveWindow int `mapstructure:"live_window" json:"live_window" yaml:"live_window"`
// LiveHistory is extra segments kept on disk after they leave the manifest.
LiveHistory int `mapstructure:"live_history" json:"live_history" yaml:"live_history"`
}
PublisherHLSConfig is filesystem + live packaging for Apple HLS (m3u8 + segments).
type RTMPListenerConfig ¶
type RTMPListenerConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled" yaml:"enabled"`
ListenHost string `mapstructure:"listen_host" json:"listen_host" yaml:"listen_host"`
Port int `mapstructure:"port" json:"port" yaml:"port"` // default 1935
}
RTMPListenerConfig is the shared RTMP listener used by both ingest and play. Encoders publish to rtmp://host:port/<key>; players pull from rtmp://host:port/<app>/<key>.
type RTSPListenerConfig ¶
type RTSPListenerConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled" yaml:"enabled"`
ListenHost string `mapstructure:"listen_host" json:"listen_host" yaml:"listen_host"`
Port int `mapstructure:"port" json:"port" yaml:"port"` // default 554
// Transport is "tcp" (default) or "udp" for the RTSP muxer.
Transport string `mapstructure:"transport" json:"transport" yaml:"transport"`
}
RTSPListenerConfig is the RTSP listener (publisher-side; ingest is pull-only). Clients use rtsp://host:port/live/<stream_code>.
type SRTListenerConfig ¶
type SRTListenerConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled" yaml:"enabled"`
ListenHost string `mapstructure:"listen_host" json:"listen_host" yaml:"listen_host"`
Port int `mapstructure:"port" json:"port" yaml:"port"` // default 9999
// LatencyMS is the SRT latency in milliseconds applied to the listener.
LatencyMS int `mapstructure:"latency_ms" json:"latency_ms" yaml:"latency_ms"`
}
SRTListenerConfig is the shared SRT listener. Players set streamid=live/<stream_code>; publish ingest is dispatched by the streamid mode flag (mode=publish vs mode=request).
type ServerConfig ¶
type ServerConfig struct {
HTTPAddr string `mapstructure:"http_addr" json:"http_addr" yaml:"http_addr"`
CORS CORSConfig `mapstructure:"cors" json:"cors" yaml:"cors"`
}
ServerConfig holds HTTP/gRPC server settings.
type StorageConfig ¶
type StorageConfig struct {
// Driver selects the backend: "json" | "yaml"
Driver string `mapstructure:"driver"`
// JSON backend
JSONDir string `mapstructure:"json_dir"`
// YAML backend
YAMLDir string `mapstructure:"yaml_dir"`
}
StorageConfig selects the storage backend and its connection details.
func LoadStorage ¶
func LoadStorage() (StorageConfig, error)
LoadStorage reads only the StorageConfig from environment variables and an optional config file. All other config sections are managed by GlobalConfig in the store.
type TranscoderConfig ¶
type TranscoderConfig struct {
FFmpegPath string `mapstructure:"ffmpeg_path" json:"ffmpeg_path" yaml:"ffmpeg_path"`
}
TranscoderConfig controls FFmpeg invocation. There is intentionally no concurrency cap on the worker pool — every rendition spawns its own FFmpeg process and the OS (rlimit / GPU encoder slots) is the natural upper bound. Operators who need a soft cap should provision the host accordingly rather than relying on application-level throttling.