engine

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PLUGIN_NONE       = 0
	PLUGIN_SUBSCRIBER = 1
	PLUGIN_PUBLISHER  = 1 << 1
	PLUGIN_HOOK       = 1 << 2
)

Plugins seting

Variables

View Source
var (
	Config = &Parameters{true}

	// ConfigRaw 配置信息的原始数据
	ConfigRaw []byte
	// Version 引擎版本号
	Version string
	// EngineInfo 引擎信息
	EngineInfo = &ExtendInfo{&Version, time.Now()}
)

Settings for engine

View Source
var (
	AllRoom = Collection{}
)
View Source
var AuthHooks = make(AuthHook, 0)
View Source
var OnDropHooks = make(OnDropHook, 0)
View Source
var OnPublishHooks = make(OnPublishHook, 0)
View Source
var OnSubscribeHooks = make(OnSubscribeHook, 0)
View Source
var OnSummaryHooks = make(OnSummaryHook, 0)
View Source
var Plugins = make(map[string]*PluginConfig)

Plugins 所有的插件配置

View Source
var (
	Summary = ServerSummary{}
)

Functions

func AddWriter

func AddWriter(wn io.Writer)

AddWriter 添加日志输出端

func InstallPlugin

func InstallPlugin(opt *PluginConfig)

InstallPlugin 安装插件

func MayBeError

func MayBeError(info error) (hasError bool)

MayBeError 优雅错误判断加日志辅助函数

func Print

func Print(v ...interface{})

Print 带颜色识别

func Printf

func Printf(format string, v ...interface{})

Printf calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Printf.

func Println

func Println(v ...interface{})

Println calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Println.

Types

type AuthHook

type AuthHook []func(string) error

func (AuthHook) AddHook

func (h AuthHook) AddHook(hook func(string) error)

func (AuthHook) Trigger

func (h AuthHook) Trigger(sign string) error

type ChangeRoomCmd

type ChangeRoomCmd struct {
	*OutputStream
	NewRoom *Room
}

type Collection

type Collection struct {
	sync.Map
}

func (*Collection) Get

func (c *Collection) Get(name string) (result *Room)

type ExtendInfo

type ExtendInfo struct {
	Version   *string
	StartTime time.Time //启动时间
}

ExtendInfo for extension

type InputStream

type InputStream struct {
	*Room
}

func (*InputStream) Close

func (p *InputStream) Close()

func (*InputStream) OnClosed

func (p *InputStream) OnClosed()

func (*InputStream) Publish

func (p *InputStream) Publish(streamPath string, publisher Publisher) bool

func (*InputStream) Running

func (p *InputStream) Running() bool

type ListenerConfig

type ListenerConfig struct {
	ListenAddr string
}

ListenerConfig 带有监听地址端口的插件配置类型

type LogWriter

type LogWriter struct {
	*MultiLogWriter
}

LogWriter 多端写日志类

func (*LogWriter) Write

func (w *LogWriter) Write(data []byte) (n int, err error)

type MultiLogWriter

type MultiLogWriter struct {
	sync.Map
}

func (*MultiLogWriter) Write

func (w *MultiLogWriter) Write(data []byte) (n int, err error)

type NetWorkInfo

type NetWorkInfo struct {
	Name         string
	Receive      uint64
	Sent         uint64
	ReceiveSpeed uint64
	SentSpeed    uint64
}

type OnDropHook

type OnDropHook []func(s *OutputStream)

func (OnDropHook) AddHook

func (h OnDropHook) AddHook(hook func(s *OutputStream))

func (OnDropHook) Trigger

func (h OnDropHook) Trigger(s *OutputStream)

type OnPublishHook

type OnPublishHook []func(r *Room)

func (OnPublishHook) AddHook

func (h OnPublishHook) AddHook(hook func(r *Room))

func (OnPublishHook) Trigger

func (h OnPublishHook) Trigger(r *Room)

type OnSubscribeHook

type OnSubscribeHook []func(s *OutputStream)

func (OnSubscribeHook) AddHook

func (h OnSubscribeHook) AddHook(hook func(s *OutputStream))

func (OnSubscribeHook) Trigger

func (h OnSubscribeHook) Trigger(s *OutputStream)

type OnSummaryHook

type OnSummaryHook []func(bool)

func (OnSummaryHook) AddHook

func (h OnSummaryHook) AddHook(hook func(bool))

func (OnSummaryHook) Trigger

func (h OnSummaryHook) Trigger(v bool)

type Option

type Option func(*Options)

type Options

type Options struct {
	Config  config.Config
	Context context.Context
}

Options for micro service

type OutputStream

type OutputStream struct {
	context.Context
	*Room
	SubscriberInfo
	SendHandler func(*avformat.SendPacket) error
	Cancel      context.CancelFunc
	Sign        string
	VTSent      bool
	ATSent      bool
	VSentTime   uint32
	ASentTime   uint32

	OffsetTime uint32
	// contains filtered or unexported fields
}

func (*OutputStream) Close

func (s *OutputStream) Close()

func (*OutputStream) IsClosed

func (s *OutputStream) IsClosed() bool

func (*OutputStream) Play

func (s *OutputStream) Play(streamPath string) (err error)

type Parameters

type Parameters struct {
	EnableWaitRoom bool
}

Parameters for engine

type PluginConfig

type PluginConfig struct {
	Name    string      //插件名称
	Type    byte        //类型
	Config  interface{} //插件配置
	UI      string      //界面路径
	Version string      //插件版本
	Dir     string      //插件代码路径
	Run     func()      //插件启动函数
}

PluginConfig 插件配置定义

type Publisher

type Publisher interface {
	OnClosed()
}

type Room

type Room struct {
	context.Context
	Publisher
	RoomInfo
	Control      chan interface{}
	Cancel       context.CancelFunc
	Subscribers  map[string]*OutputStream // 订阅者
	VideoTag     *avformat.AVPacket       // 每个视频包都是这样的结构,区别在于Payload的大小.FMS在发送AVC sequence header,需要加上 VideoTags,这个tag 1个字节(8bits)的数据
	AudioTag     *avformat.AVPacket       // 每个音频包都是这样的结构,区别在于Payload的大小.FMS在发送AAC sequence header,需要加上 AudioTags,这个tag 1个字节(8bits)的数据
	FirstScreen  []*avformat.AVPacket
	AudioChan    chan *avformat.AVPacket
	VideoChan    chan *avformat.AVPacket
	UseTimestamp bool //是否采用数据包中的时间戳
}

func (*Room) PushAudio

func (r *Room) PushAudio(audio *avformat.AVPacket)

func (*Room) PushVideo

func (r *Room) PushVideo(video *avformat.AVPacket)

func (*Room) Run

func (r *Room) Run()

func (*Room) Subscribe

func (r *Room) Subscribe(s *OutputStream)

func (*Room) UnSubscribe

func (r *Room) UnSubscribe(s *OutputStream)

type RoomInfo

type RoomInfo struct {
	StreamPath     string
	StartTime      time.Time
	SubscriberInfo []*SubscriberInfo
	Type           string
	VideoInfo      struct {
		PacketCount int
		CodecID     byte
		SPSInfo     avformat.SPSInfo
	}
	AudioInfo struct {
		PacketCount int
		SoundFormat byte //4bit
		SoundRate   int  //2bit
		SoundSize   byte //1bit
		SoundType   byte //1bit
	}
}

type ServerSummary

type ServerSummary struct {
	Address string
	Memory  struct {
		Total uint64
		Free  uint64
		Used  uint64
		Usage float64
	}
	CPUUsage float64
	HardDisk struct {
		Total uint64
		Free  uint64
		Used  uint64
		Usage float64
	}
	NetWork []NetWorkInfo
	Rooms   []*RoomInfo

	Children map[string]*ServerSummary
	// contains filtered or unexported fields
}

func (*ServerSummary) Add

func (s *ServerSummary) Add()

func (*ServerSummary) Done

func (s *ServerSummary) Done()

func (*ServerSummary) Report

func (s *ServerSummary) Report(slave *ServerSummary)

func (*ServerSummary) Running

func (s *ServerSummary) Running() bool

func (*ServerSummary) StartSummary

func (s *ServerSummary) StartSummary()

type Service

type Service interface {
	Init() error
	Run(configFile string) error
	String() string
}

Service for monibuca

type SubscribeCmd

type SubscribeCmd struct {
	*OutputStream
}

type Subscriber

type Subscriber interface {
	Send(*avformat.SendPacket) error
}

type SubscriberInfo

type SubscriberInfo struct {
	ID            string
	TotalDrop     int //总丢帧
	TotalPacket   int
	Type          string
	BufferLength  int
	SubscribeTime time.Time
}

type UnSubscribeCmd

type UnSubscribeCmd struct {
	*OutputStream
}

Directories

Path Synopsis
protos

Jump to

Keyboard shortcuts

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