config

package
v4.0.0-beta7 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: MIT Imports: 21 Imported by: 42

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", "",
}

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 FileWr

type FileWr interface {
	io.Reader
	io.Writer
	io.Seeker
	io.Closer
}

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   int  // 发布无数据超时
	WaitCloseTimeout 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     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 Record

type Record struct {
	Ext        string //文件扩展名
	Path       string //存储文件的目录
	AutoRecord bool
	Filter     string

	CreateFileFn  func(filename string, append bool) (FileWr, error) `yaml:"-"`
	GetDurationFn func(file io.ReadSeeker) uint32                    `yaml:"-"`
	// contains filtered or unexported fields
}

func (*Record) Init

func (r *Record) Init()

func (*Record) NeedRecord

func (r *Record) NeedRecord(streamPath string) bool

func (*Record) Tree

func (r *Record) Tree(dstPath string, level int) (files []*VideoFileInfo, err error)

type Subscribe

type Subscribe struct {
	SubAudio    bool
	SubVideo    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)
}

type VideoFileInfo

type VideoFileInfo struct {
	Path     string
	Size     int64
	Duration uint32
}

Jump to

Keyboard shortcuts

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