conf

package
v0.0.0-...-8a90fd1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package conf contains the struct that holds the configuration of the software.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidPathName

func IsValidPathName(name string) error

IsValidPathName checks if a path name is valid.

Types

type AuthMethods

type AuthMethods []headers.AuthMethod

AuthMethods is the authMethods parameter.

func (AuthMethods) MarshalJSON

func (d AuthMethods) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*AuthMethods) UnmarshalEnv

func (d *AuthMethods) UnmarshalEnv(_ string, v string) error

UnmarshalEnv implements env.Unmarshaler.

func (*AuthMethods) UnmarshalJSON

func (d *AuthMethods) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Conf

type Conf struct {
	// General
	LogLevel                  LogLevel        `json:"logLevel"`
	LogDestinations           LogDestinations `json:"logDestinations"`
	LogFile                   string          `json:"logFile"`
	ReadTimeout               StringDuration  `json:"readTimeout"`
	WriteTimeout              StringDuration  `json:"writeTimeout"`
	ReadBufferCount           *int            `json:"readBufferCount,omitempty"` // deprecated
	WriteQueueSize            int             `json:"writeQueueSize"`
	UDPMaxPayloadSize         int             `json:"udpMaxPayloadSize"`
	ExternalAuthenticationURL string          `json:"externalAuthenticationURL"`
	API                       bool            `json:"api"`
	APIAddress                string          `json:"apiAddress"`
	Metrics                   bool            `json:"metrics"`
	MetricsAddress            string          `json:"metricsAddress"`
	PPROF                     bool            `json:"pprof"`
	PPROFAddress              string          `json:"pprofAddress"`
	RunOnConnect              string          `json:"runOnConnect"`
	RunOnConnectRestart       bool            `json:"runOnConnectRestart"`
	RunOnDisconnect           string          `json:"runOnDisconnect"`

	// RTSP server
	RTSP              bool        `json:"rtsp"`
	RTSPDisable       *bool       `json:"rtspDisable,omitempty"` // deprecated
	Protocols         Protocols   `json:"protocols"`
	Encryption        Encryption  `json:"encryption"`
	RTSPAddress       string      `json:"rtspAddress"`
	RTSPSAddress      string      `json:"rtspsAddress"`
	RTPAddress        string      `json:"rtpAddress"`
	RTCPAddress       string      `json:"rtcpAddress"`
	MulticastIPRange  string      `json:"multicastIPRange"`
	MulticastRTPPort  int         `json:"multicastRTPPort"`
	MulticastRTCPPort int         `json:"multicastRTCPPort"`
	ServerKey         string      `json:"serverKey"`
	ServerCert        string      `json:"serverCert"`
	AuthMethods       AuthMethods `json:"authMethods"`

	// RTMP server
	RTMP           bool       `json:"rtmp"`
	RTMPDisable    *bool      `json:"rtmpDisable,omitempty"` // deprecated
	RTMPAddress    string     `json:"rtmpAddress"`
	RTMPEncryption Encryption `json:"rtmpEncryption"`
	RTMPSAddress   string     `json:"rtmpsAddress"`
	RTMPServerKey  string     `json:"rtmpServerKey"`
	RTMPServerCert string     `json:"rtmpServerCert"`

	// HLS server
	HLS                bool           `json:"hls"`
	HLSDisable         *bool          `json:"hlsDisable,omitempty"` // depreacted
	HLSAddress         string         `json:"hlsAddress"`
	HLSEncryption      bool           `json:"hlsEncryption"`
	HLSServerKey       string         `json:"hlsServerKey"`
	HLSServerCert      string         `json:"hlsServerCert"`
	HLSAlwaysRemux     bool           `json:"hlsAlwaysRemux"`
	HLSVariant         HLSVariant     `json:"hlsVariant"`
	HLSSegmentCount    int            `json:"hlsSegmentCount"`
	HLSSegmentDuration StringDuration `json:"hlsSegmentDuration"`
	HLSPartDuration    StringDuration `json:"hlsPartDuration"`
	HLSSegmentMaxSize  StringSize     `json:"hlsSegmentMaxSize"`
	HLSAllowOrigin     string         `json:"hlsAllowOrigin"`
	HLSTrustedProxies  IPsOrCIDRs     `json:"hlsTrustedProxies"`
	HLSDirectory       string         `json:"hlsDirectory"`

	// WebRTC server
	WebRTC                      bool              `json:"webrtc"`
	WebRTCDisable               *bool             `json:"webrtcDisable,omitempty"` // deprecated
	WebRTCAddress               string            `json:"webrtcAddress"`
	WebRTCEncryption            bool              `json:"webrtcEncryption"`
	WebRTCServerKey             string            `json:"webrtcServerKey"`
	WebRTCServerCert            string            `json:"webrtcServerCert"`
	WebRTCAllowOrigin           string            `json:"webrtcAllowOrigin"`
	WebRTCTrustedProxies        IPsOrCIDRs        `json:"webrtcTrustedProxies"`
	WebRTCLocalUDPAddress       string            `json:"webrtcLocalUDPAddress"`
	WebRTCLocalTCPAddress       string            `json:"webrtcLocalTCPAddress"`
	WebRTCIPsFromInterfaces     bool              `json:"webrtcIPsFromInterfaces"`
	WebRTCIPsFromInterfacesList []string          `json:"webrtcIPsFromInterfacesList"`
	WebRTCAdditionalHosts       []string          `json:"webrtcAdditionalHosts"`
	WebRTCICEServers2           []WebRTCICEServer `json:"webrtcICEServers2"`
	WebRTCICEUDPMuxAddress      *string           `json:"webrtcICEUDPMuxAddress,omitempty"`  // deprecated
	WebRTCICETCPMuxAddress      *string           `json:"webrtcICETCPMuxAddress,omitempty"`  // deprecated
	WebRTCICEHostNAT1To1IPs     *[]string         `json:"webrtcICEHostNAT1To1IPs,omitempty"` // deprecated
	WebRTCICEServers            *[]string         `json:"webrtcICEServers,omitempty"`        // deprecated

	// SRT server
	SRT        bool   `json:"srt"`
	SRTAddress string `json:"srtAddress"`

	// Record (deprecated)
	Record                *bool           `json:"record,omitempty"`                // deprecated
	RecordPath            *string         `json:"recordPath,omitempty"`            // deprecated
	RecordFormat          *RecordFormat   `json:"recordFormat,omitempty"`          // deprecated
	RecordPartDuration    *StringDuration `json:"recordPartDuration,omitempty"`    // deprecated
	RecordSegmentDuration *StringDuration `json:"recordSegmentDuration,omitempty"` // deprecated
	RecordDeleteAfter     *StringDuration `json:"recordDeleteAfter,omitempty"`     // deprecated

	// Path defaults
	PathDefaults Path `json:"pathDefaults"`

	// Paths
	OptionalPaths map[string]*OptionalPath `json:"paths"`
	Paths         map[string]*Path         `json:"-"` // filled by Check()
}

Conf is a configuration.

func Load

func Load(fpath string, defaultConfPaths []string) (*Conf, string, error)

Load loads a Conf.

func (*Conf) AddPath

func (conf *Conf) AddPath(name string, p *OptionalPath) error

AddPath adds a path.

func (*Conf) Check

func (conf *Conf) Check() error

Check checks the configuration for errors.

func (Conf) Clone

func (conf Conf) Clone() *Conf

Clone clones the configuration.

func (*Conf) Global

func (conf *Conf) Global() *Global

Global returns the global part of Conf.

func (*Conf) PatchGlobal

func (conf *Conf) PatchGlobal(optional *OptionalGlobal)

PatchGlobal patches the global configuration.

func (*Conf) PatchPath

func (conf *Conf) PatchPath(name string, optional2 *OptionalPath) error

PatchPath patches a path.

func (*Conf) PatchPathDefaults

func (conf *Conf) PatchPathDefaults(optional *OptionalPath)

PatchPathDefaults patches path default settings.

func (*Conf) RemovePath

func (conf *Conf) RemovePath(name string) error

RemovePath removes a path.

func (*Conf) ReplacePath

func (conf *Conf) ReplacePath(name string, optional2 *OptionalPath) error

ReplacePath replaces a path.

func (*Conf) UnmarshalJSON

func (conf *Conf) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Credential

type Credential string

Credential is a parameter that is used as username or password.

func (Credential) MarshalJSON

func (d Credential) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Credential) UnmarshalEnv

func (d *Credential) UnmarshalEnv(_ string, v string) error

UnmarshalEnv implements env.Unmarshaler.

func (*Credential) UnmarshalJSON

func (d *Credential) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Encryption

type Encryption int

Encryption is the encryption parameter.

const (
	EncryptionNo Encryption = iota
	EncryptionOptional
	EncryptionStrict
)

values.

func (Encryption) MarshalJSON

func (d Encryption) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Encryption) UnmarshalEnv

func (d *Encryption) UnmarshalEnv(_ string, v string) error

UnmarshalEnv implements env.Unmarshaler.

func (*Encryption) UnmarshalJSON

func (d *Encryption) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Global

type Global struct {
	Values interface{}
}

Global is the global part of Conf.

func (*Global) MarshalJSON

func (p *Global) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

type HLSVariant

type HLSVariant gohlslib.MuxerVariant

HLSVariant is the hlsVariant parameter.

func (HLSVariant) MarshalJSON

func (d HLSVariant) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*HLSVariant) UnmarshalEnv

func (d *HLSVariant) UnmarshalEnv(_ string, v string) error

UnmarshalEnv implements env.Unmarshaler.

func (*HLSVariant) UnmarshalJSON

func (d *HLSVariant) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type IPsOrCIDRs

type IPsOrCIDRs []fmt.Stringer

IPsOrCIDRs is a parameter that contains a list of IPs or CIDRs.

func (IPsOrCIDRs) MarshalJSON

func (d IPsOrCIDRs) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*IPsOrCIDRs) ToTrustedProxies

func (d *IPsOrCIDRs) ToTrustedProxies() []string

ToTrustedProxies converts IPsOrCIDRs into a string slice for SetTrustedProxies.

func (*IPsOrCIDRs) UnmarshalEnv

func (d *IPsOrCIDRs) UnmarshalEnv(_ string, v string) error

UnmarshalEnv implements env.Unmarshaler.

func (*IPsOrCIDRs) UnmarshalJSON

func (d *IPsOrCIDRs) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type LogDestinations

type LogDestinations []logger.Destination

LogDestinations is the logDestionations parameter.

func (LogDestinations) MarshalJSON

func (d LogDestinations) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*LogDestinations) UnmarshalEnv

func (d *LogDestinations) UnmarshalEnv(_ string, v string) error

UnmarshalEnv implements env.Unmarshaler.

func (*LogDestinations) UnmarshalJSON

func (d *LogDestinations) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type LogLevel

type LogLevel logger.Level

LogLevel is the logLevel parameter.

func (LogLevel) MarshalJSON

func (d LogLevel) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*LogLevel) UnmarshalEnv

func (d *LogLevel) UnmarshalEnv(_ string, v string) error

UnmarshalEnv implements env.Unmarshaler.

func (*LogLevel) UnmarshalJSON

func (d *LogLevel) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type OptionalGlobal

type OptionalGlobal struct {
	Values interface{}
}

OptionalGlobal is a Conf whose values can all be optional.

func (*OptionalGlobal) MarshalJSON

func (p *OptionalGlobal) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*OptionalGlobal) UnmarshalJSON

func (p *OptionalGlobal) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type OptionalPath

type OptionalPath struct {
	Values interface{}
}

OptionalPath is a Path whose values can all be optional.

func (*OptionalPath) MarshalJSON

func (p *OptionalPath) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*OptionalPath) UnmarshalEnv

func (p *OptionalPath) UnmarshalEnv(prefix string, _ string) error

UnmarshalEnv implements env.Unmarshaler.

func (*OptionalPath) UnmarshalJSON

func (p *OptionalPath) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Path

type Path struct {
	Regexp *regexp.Regexp `json:"-"`    // filled by Check()
	Name   string         `json:"name"` // filled by Check()

	// General
	Source                     string         `json:"source"`
	SourceFingerprint          string         `json:"sourceFingerprint"`
	SourceOnDemand             bool           `json:"sourceOnDemand"`
	SourceOnDemandStartTimeout StringDuration `json:"sourceOnDemandStartTimeout"`
	SourceOnDemandCloseAfter   StringDuration `json:"sourceOnDemandCloseAfter"`
	MaxReaders                 int            `json:"maxReaders"`
	SRTReadPassphrase          string         `json:"srtReadPassphrase"`
	Fallback                   string         `json:"fallback"`

	// Record
	Record                bool           `json:"record"`
	RecordPath            string         `json:"recordPath"`
	RecordFormat          RecordFormat   `json:"recordFormat"`
	RecordPartDuration    StringDuration `json:"recordPartDuration"`
	RecordSegmentDuration StringDuration `json:"recordSegmentDuration"`
	RecordDeleteAfter     StringDuration `json:"recordDeleteAfter"`

	// Authentication
	PublishUser Credential `json:"publishUser"`
	PublishPass Credential `json:"publishPass"`
	PublishIPs  IPsOrCIDRs `json:"publishIPs"`
	ReadUser    Credential `json:"readUser"`
	ReadPass    Credential `json:"readPass"`
	ReadIPs     IPsOrCIDRs `json:"readIPs"`

	// Publisher source
	OverridePublisher        bool   `json:"overridePublisher"`
	DisablePublisherOverride *bool  `json:"disablePublisherOverride,omitempty"` // deprecated
	SRTPublishPassphrase     string `json:"srtPublishPassphrase"`

	// RTSP source
	RTSPTransport       RTSPTransport  `json:"rtspTransport"`
	RTSPAnyPort         bool           `json:"rtspAnyPort"`
	SourceProtocol      *RTSPTransport `json:"sourceProtocol,omitempty"`      // deprecated
	SourceAnyPortEnable *bool          `json:"sourceAnyPortEnable,omitempty"` // deprecated
	RTSPRangeType       RTSPRangeType  `json:"rtspRangeType"`
	RTSPRangeStart      string         `json:"rtspRangeStart"`

	// Redirect source
	SourceRedirect string `json:"sourceRedirect"`

	// Raspberry Pi Camera source
	RPICameraCamID             int     `json:"rpiCameraCamID"`
	RPICameraWidth             int     `json:"rpiCameraWidth"`
	RPICameraHeight            int     `json:"rpiCameraHeight"`
	RPICameraHFlip             bool    `json:"rpiCameraHFlip"`
	RPICameraVFlip             bool    `json:"rpiCameraVFlip"`
	RPICameraBrightness        float64 `json:"rpiCameraBrightness"`
	RPICameraContrast          float64 `json:"rpiCameraContrast"`
	RPICameraSaturation        float64 `json:"rpiCameraSaturation"`
	RPICameraSharpness         float64 `json:"rpiCameraSharpness"`
	RPICameraExposure          string  `json:"rpiCameraExposure"`
	RPICameraAWB               string  `json:"rpiCameraAWB"`
	RPICameraDenoise           string  `json:"rpiCameraDenoise"`
	RPICameraShutter           int     `json:"rpiCameraShutter"`
	RPICameraMetering          string  `json:"rpiCameraMetering"`
	RPICameraGain              float64 `json:"rpiCameraGain"`
	RPICameraEV                float64 `json:"rpiCameraEV"`
	RPICameraROI               string  `json:"rpiCameraROI"`
	RPICameraHDR               bool    `json:"rpiCameraHDR"`
	RPICameraTuningFile        string  `json:"rpiCameraTuningFile"`
	RPICameraMode              string  `json:"rpiCameraMode"`
	RPICameraFPS               float64 `json:"rpiCameraFPS"`
	RPICameraIDRPeriod         int     `json:"rpiCameraIDRPeriod"`
	RPICameraBitrate           int     `json:"rpiCameraBitrate"`
	RPICameraProfile           string  `json:"rpiCameraProfile"`
	RPICameraLevel             string  `json:"rpiCameraLevel"`
	RPICameraAfMode            string  `json:"rpiCameraAfMode"`
	RPICameraAfRange           string  `json:"rpiCameraAfRange"`
	RPICameraAfSpeed           string  `json:"rpiCameraAfSpeed"`
	RPICameraLensPosition      float64 `json:"rpiCameraLensPosition"`
	RPICameraAfWindow          string  `json:"rpiCameraAfWindow"`
	RPICameraTextOverlayEnable bool    `json:"rpiCameraTextOverlayEnable"`
	RPICameraTextOverlay       string  `json:"rpiCameraTextOverlay"`

	// Hooks
	RunOnInit                  string         `json:"runOnInit"`
	RunOnInitRestart           bool           `json:"runOnInitRestart"`
	RunOnDemand                string         `json:"runOnDemand"`
	RunOnDemandRestart         bool           `json:"runOnDemandRestart"`
	RunOnDemandStartTimeout    StringDuration `json:"runOnDemandStartTimeout"`
	RunOnDemandCloseAfter      StringDuration `json:"runOnDemandCloseAfter"`
	RunOnUnDemand              string         `json:"runOnUnDemand"`
	RunOnReady                 string         `json:"runOnReady"`
	RunOnReadyRestart          bool           `json:"runOnReadyRestart"`
	RunOnNotReady              string         `json:"runOnNotReady"`
	RunOnRead                  string         `json:"runOnRead"`
	RunOnReadRestart           bool           `json:"runOnReadRestart"`
	RunOnUnread                string         `json:"runOnUnread"`
	RunOnRecordSegmentCreate   string         `json:"runOnRecordSegmentCreate"`
	RunOnRecordSegmentComplete string         `json:"runOnRecordSegmentComplete"`
}

Path is a path configuration.

func (Path) Clone

func (pconf Path) Clone() *Path

Clone clones the configuration.

func (*Path) Equal

func (pconf *Path) Equal(other *Path) bool

Equal checks whether two Paths are equal.

func (Path) HasOnDemandPublisher

func (pconf Path) HasOnDemandPublisher() bool

HasOnDemandPublisher checks whether the path has a on-demand publisher.

func (Path) HasOnDemandStaticSource

func (pconf Path) HasOnDemandStaticSource() bool

HasOnDemandStaticSource checks whether the path has a on demand static source.

func (Path) HasStaticSource

func (pconf Path) HasStaticSource() bool

HasStaticSource checks whether the path has a static source.

type Protocol

type Protocol gortsplib.Transport

Protocol is a RTSP transport.

type Protocols

type Protocols map[Protocol]struct{}

Protocols is the protocols parameter.

func (Protocols) MarshalJSON

func (d Protocols) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Protocols) UnmarshalEnv

func (d *Protocols) UnmarshalEnv(_ string, v string) error

UnmarshalEnv implements env.Unmarshaler.

func (*Protocols) UnmarshalJSON

func (d *Protocols) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type RTSPRangeType

type RTSPRangeType int

RTSPRangeType is the type used in the Range header.

const (
	RTSPRangeTypeUndefined RTSPRangeType = iota
	RTSPRangeTypeClock
	RTSPRangeTypeNPT
	RTSPRangeTypeSMPTE
)

supported values.

func (RTSPRangeType) MarshalJSON

func (d RTSPRangeType) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*RTSPRangeType) UnmarshalEnv

func (d *RTSPRangeType) UnmarshalEnv(_ string, v string) error

UnmarshalEnv implements env.Unmarshaler.

func (*RTSPRangeType) UnmarshalJSON

func (d *RTSPRangeType) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type RTSPTransport

type RTSPTransport struct {
	*gortsplib.Transport
}

RTSPTransport is the rtspTransport parameter.

func (RTSPTransport) MarshalJSON

func (d RTSPTransport) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*RTSPTransport) UnmarshalEnv

func (d *RTSPTransport) UnmarshalEnv(_ string, v string) error

UnmarshalEnv implements env.Unmarshaler.

func (*RTSPTransport) UnmarshalJSON

func (d *RTSPTransport) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type RecordFormat

type RecordFormat int

RecordFormat is the recordFormat parameter.

const (
	RecordFormatFMP4 RecordFormat = iota
	RecordFormatMPEGTS
)

supported values.

func (RecordFormat) MarshalJSON

func (d RecordFormat) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*RecordFormat) UnmarshalEnv

func (d *RecordFormat) UnmarshalEnv(_ string, v string) error

UnmarshalEnv implements env.Unmarshaler.

func (*RecordFormat) UnmarshalJSON

func (d *RecordFormat) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type StringDuration

type StringDuration time.Duration

StringDuration is a duration that is unmarshaled from a string. Durations are normally unmarshaled from numbers.

func (StringDuration) MarshalJSON

func (d StringDuration) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*StringDuration) UnmarshalEnv

func (d *StringDuration) UnmarshalEnv(_ string, v string) error

UnmarshalEnv implements env.Unmarshaler.

func (*StringDuration) UnmarshalJSON

func (d *StringDuration) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type StringSize

type StringSize uint64

StringSize is a size that is unmarshaled from a string.

func (StringSize) MarshalJSON

func (s StringSize) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*StringSize) UnmarshalEnv

func (s *StringSize) UnmarshalEnv(_ string, v string) error

UnmarshalEnv implements env.Unmarshaler.

func (*StringSize) UnmarshalJSON

func (s *StringSize) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type WebRTCICEServer

type WebRTCICEServer struct {
	URL      string `json:"url"`
	Username string `json:"username"`
	Password string `json:"password"`
}

WebRTCICEServer is a WebRTC ICE Server.

Directories

Path Synopsis
Package decrypt contains the Decrypt function.
Package decrypt contains the Decrypt function.
Package env contains a function to load configuration from environment.
Package env contains a function to load configuration from environment.
Package yaml contains a yaml loader.
Package yaml contains a yaml loader.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL