config

package
v4.0.0-alpha9 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: MIT Imports: 15 Imported by: 43

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Global = &Engine{
	Publish{true, true, false, 10, 0},
	Subscribe{true, true, false, 10},
	HTTP{ListenAddr: ":8080", CORS: true, mux: http.DefaultServeMux},
	false, true, true, true, "wss://console.monibuca.com:8080", "",
}

Functions

This section is empty.

Types

type Config

type Config map[string]any

func Struct2Config

func Struct2Config(s any) (config Config)

func (Config) Assign

func (config Config) Assign(source Config)

覆盖配置

func (Config) Get

func (config Config) Get(key string) any

func (Config) GetChild

func (config Config) GetChild(key string) Config

func (Config) Has

func (config Config) Has(key string) (ok bool)

func (Config) HasChild

func (config Config) HasChild(key string) (ok bool)

func (Config) Merge

func (config Config) Merge(source Config)

合并配置,不覆盖

func (*Config) Set

func (config *Config) Set(key string, value any)

func (Config) Unmarshal

func (config Config) Unmarshal(s any)

type Engine

type Engine struct {
	Publish
	Subscribe
	HTTP
	RTPReorder bool
	EnableAVCC bool   //启用AVCC格式,rtmp协议使用
	EnableRTP  bool   //启用RTP格式,rtsp、gb18181等协议使用
	EnableFLV  bool   //开启FLV格式,hdl协议使用
	ConsoleURL string //远程控制台地址
	Secret     string //远程控制台密钥
}

func (*Engine) OnEvent

func (cfg *Engine) OnEvent(event any)

type HTTP

type HTTP struct {
	ListenAddr    string
	ListenAddrTLS string
	CertFile      string
	KeyFile       string
	CORS          bool //是否自动添加CORS头
	UserName      string
	Password      string
	// contains filtered or unexported fields
}

func (*HTTP) GetHTTPConfig

func (config *HTTP) GetHTTPConfig() *HTTP

func (*HTTP) HandleFunc

func (config *HTTP) HandleFunc(path string, f func(http.ResponseWriter, *http.Request))

func (*HTTP) InitMux

func (config *HTTP) InitMux()

func (*HTTP) Listen

func (config *HTTP) Listen(ctx context.Context) error

ListenAddrs Listen http and https

type HTTPConfig

type HTTPConfig interface {
	InitMux()
	GetHTTPConfig() *HTTP
	Listen(ctx context.Context) error
	HandleFunc(string, func(http.ResponseWriter, *http.Request))
}

type HTTPPlugin

type HTTPPlugin interface {
	Plugin
	http.Handler
}

type Plugin

type Plugin interface {
	// 可能的入参类型:FirstConfig 第一次初始化配置,Config 后续配置更新,SE系列(StateEvent)流状态变化事件
	OnEvent(any)
}

type Publish

type Publish struct {
	PubAudio         bool
	PubVideo         bool
	KickExist        bool   // 是否踢掉已经存在的发布者
	PublishTimeout   Second // 发布无数据超时
	WaitCloseTimeout Second // 延迟自动关闭(无订阅时)
}

func (*Publish) GetPublishConfig

func (c *Publish) GetPublishConfig() *Publish

type PublishConfig

type PublishConfig interface {
	GetPublishConfig() *Publish
}

type Pull

type Pull struct {
	RePull          int               // 断开后自动重拉,0 表示不自动重拉,-1 表示无限重拉,高于0 的数代表最大重拉次数
	PullOnStart     bool              // 启动时拉流
	PullOnSubscribe bool              // 订阅时自动拉流
	PullList        map[string]string // 自动拉流列表,以streamPath为key,url为value
}

func (*Pull) AddPull

func (p *Pull) AddPull(streamPath string, url string)

func (*Pull) GetPullConfig

func (p *Pull) GetPullConfig() *Pull

type PullConfig

type PullConfig interface {
	GetPullConfig() *Pull
}

type Push

type Push struct {
	RePush   int               // 断开后自动重推,0 表示不自动重推,-1 表示无限重推,高于0 的数代表最大重推次数
	PushList map[string]string // 自动推流列表
}

func (*Push) AddPush

func (p *Push) AddPush(streamPath string, url string)

func (*Push) GetPushConfig

func (p *Push) GetPushConfig() *Push

type PushConfig

type PushConfig interface {
	GetPushConfig() *Push
}

type Second

type Second int

func (Second) Duration

func (s Second) Duration() time.Duration

type Subscribe

type Subscribe struct {
	SubAudio    bool
	SubVideo    bool
	IFrameOnly  bool   // 只要关键帧
	WaitTimeout Second // 等待流超时
}

func (*Subscribe) GetSubscribeConfig

func (c *Subscribe) GetSubscribeConfig() *Subscribe

type SubscribeConfig

type SubscribeConfig interface {
	GetSubscribeConfig() *Subscribe
}

type TCP

type TCP struct {
	ListenAddr string
	ListenNum  int //同时并行监听数量,0为CPU核心数量
}

func (*TCP) Listen

func (tcp *TCP) Listen(ctx context.Context, plugin TCPPlugin) error

type TCPPlugin

type TCPPlugin interface {
	Plugin
	ServeTCP(*net.TCPConn)
}

Jump to

Keyboard shortcuts

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