config

package
v4.10.2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: MIT Imports: 17 Imported by: 42

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Global = &Engine{
	Publish: Publish{true, true, false, 10, 0, 0},
	Subscribe: Subscribe{
		SubAudio:        true,
		SubVideo:        true,
		SubVideoArgName: "vts",
		SubAudioArgName: "ats",
		SubDataArgName:  "dts",
		SubAudioTracks:  nil,
		SubVideoTracks:  nil,
		LiveMode:        true,
		IFrameOnly:      false,
		WaitTimeout:     10,
	},
	HTTP:           HTTP{ListenAddr: ":8080", CORS: true, mux: http.DefaultServeMux},
	RTPReorder:     true,
	EnableAVCC:     true,
	EnableRTP:      true,
	EnableSubEvent: true,
	EnableAuth:     true,
	Console: Console{
		"console.monibuca.com:4242", "", "", "",
	},
	LogLevel:            "info",
	RTPReorderBufferLen: 50,
	SpeedLimit:          500,
	EventBusSize:        10,
}

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) CreateElem added in v4.7.0

func (config Config) CreateElem(eleType reflect.Type) reflect.Value

CreateElem 创建Map或者Slice中的元素

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 Console added in v4.5.0

type Console struct {
	Server        string //远程控制台地址
	Secret        string //远程控制台密钥
	PublicAddr    string //公网地址,提供远程控制台访问的地址,不配置的话使用自动识别的地址
	PublicAddrTLS string
}

type Engine

type Engine struct {
	Publish
	Subscribe
	HTTP
	RTPReorder     bool
	EnableAVCC     bool //启用AVCC格式,rtmp协议使用
	EnableRTP      bool //启用RTP格式,rtsp、gb18181等协议使用
	EnableSubEvent bool //启用订阅事件,禁用可以提高性能
	EnableAuth     bool //启用鉴权
	Console
	LogLevel            string
	RTPReorderBufferLen int //RTP重排序缓冲长度
	SpeedLimit          int //速度限制最大等待时间
	EventBusSize        int //事件总线大小
}

func (*Engine) OnEvent

func (cfg *Engine) OnEvent(event any)

func (*Engine) ReceiveRequest added in v4.7.1

func (cfg *Engine) ReceiveRequest(s quic.Stream, conn quic.Connection) error

func (*Engine) Remote added in v4.7.1

func (cfg *Engine) Remote(ctx context.Context) error

func (*Engine) WsRemote added in v4.7.1

func (cfg *Engine) WsRemote()

type HTTP

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

func (*HTTP) AddMiddleware added in v4.9.4

func (config *HTTP) AddMiddleware(middleware Middleware)

func (*HTTP) GetHTTPConfig

func (config *HTTP) GetHTTPConfig() *HTTP

func (*HTTP) Handle added in v4.9.4

func (config *HTTP) Handle(path string, f http.Handler)

func (*HTTP) Listen

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

ListenAddrs Listen http and https

type HTTPConfig

type HTTPConfig interface {
	GetHTTPConfig() *HTTP
	Listen(ctx context.Context) error
	Handle(string, http.Handler)
	AddMiddleware(Middleware)
}

type HTTPPlugin

type HTTPPlugin interface {
	Plugin
	http.Handler
}

type Middleware added in v4.9.4

type Middleware func(string, http.Handler) 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    int  // 发布无数据超时
	WaitCloseTimeout  int  // 延迟自动关闭(等待重连)
	DelayCloseTimeout int  // 延迟自动关闭(无订阅时)
}

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 map[string]string // 启动时拉流的列表
	PullOnSub   map[string]string // 订阅时自动拉流的列表
}

func (*Pull) AddPullOnStart added in v4.9.5

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

func (*Pull) AddPullOnSub added in v4.9.5

func (p *Pull) AddPullOnSub(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(url string, streamPath string)

func (*Push) GetPushConfig

func (p *Push) GetPushConfig() *Push

type PushConfig

type PushConfig interface {
	GetPushConfig() *Push
}

type Subscribe

type Subscribe struct {
	SubAudio        bool
	SubVideo        bool
	SubVideoArgName string   // 指定订阅的视频轨道参数名
	SubAudioArgName string   // 指定订阅的音频轨道参数名
	SubDataArgName  string   // 指定订阅的数据轨道参数名
	SubAudioTracks  []string // 指定订阅的音频轨道
	SubVideoTracks  []string // 指定订阅的视频轨道
	LiveMode        bool     // 实时模式:追赶发布者进度,在播放首屏后等待发布者的下一个关键帧,然后调到该帧。
	IFrameOnly      bool     // 只要关键帧
	WaitTimeout     int      // 等待流超时
}

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