Documentation
¶
Index ¶
- Constants
- Variables
- func Run(ctx context.Context, configFile string) (err error)
- type AudioDeConf
- type AudioFrame
- type AudioRTP
- type ClientConfig
- type ClientIO
- type FLVFrame
- type FirstConfig
- type GlobalConfig
- func (conf *GlobalConfig) API_closeStream(w http.ResponseWriter, r *http.Request)
- func (conf *GlobalConfig) API_getConfig(w http.ResponseWriter, r *http.Request)
- func (conf *GlobalConfig) API_list_pull(w http.ResponseWriter, r *http.Request)
- func (conf *GlobalConfig) API_list_push(w http.ResponseWriter, r *http.Request)
- func (conf *GlobalConfig) API_modifyConfig(w http.ResponseWriter, r *http.Request)
- func (conf *GlobalConfig) API_plugins(rw http.ResponseWriter, r *http.Request)
- func (conf *GlobalConfig) API_stream(rw http.ResponseWriter, r *http.Request)
- func (conf *GlobalConfig) API_summary(rw http.ResponseWriter, r *http.Request)
- func (conf *GlobalConfig) API_sysInfo(rw http.ResponseWriter, r *http.Request)
- func (conf *GlobalConfig) API_updateConfig(w http.ResponseWriter, r *http.Request)
- func (conf *GlobalConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request)
- type IIO
- type IO
- type IOConfig
- type IPublisher
- type IPuller
- type IPusher
- type ISubscriber
- type NetWorkInfo
- type PlayContext
- type Plugin
- func (opt *Plugin) Publish(streamPath string, pub IPublisher) error
- func (opt *Plugin) Pull(streamPath string, url string, puller IPuller, save bool) (err error)
- func (opt *Plugin) Push(streamPath string, url string, pusher IPusher, save bool) (err error)
- func (opt *Plugin) Save() error
- func (opt *Plugin) Subscribe(streamPath string, sub ISubscriber) error
- func (opt *Plugin) SubscribeBlock(streamPath string, sub ISubscriber, t byte) (err error)
- func (opt *Plugin) Update(conf config.Config)
- type Publisher
- type Puller
- type Pusher
- type SEKick
- type SEclose
- type SEpublish
- type SEwaitClose
- type SEwaitPublish
- type StateEvent
- type Stream
- func (s *Stream) AddTrack(t Track)
- func (s *Stream) Close()
- func (r *Stream) IsClosed() bool
- func (r *Stream) NewDataTrack(locker sync.Locker) (dt *track.Data)
- func (s *Stream) Receive(event any) bool
- func (s *Stream) RemoveTrack(t Track)
- func (s *Stream) SSRC() uint32
- func (s *Stream) Summary() (r StreamSummay)
- type StreamAction
- type StreamState
- type StreamSummay
- type StreamTimeoutConfig
- type Subscriber
- type Summary
- type TSPublisher
- type TrackPlayer
- type TrackRemoved
- type Tracks
- type VideoDeConf
- type VideoFrame
- type VideoRTP
Constants ¶
View Source
const ( NO_SUCH_CONIFG = "no such config" NO_SUCH_STREAM = "no such stream" )
View Source
const ( SUBTYPE_RAW = iota SUBTYPE_AVCC SUBTYPE_RTP SUBTYPE_FLV )
Variables ¶
View Source
var ( SysInfo struct { StartTime time.Time //启动时间 LocalIP string Version string } ExecPath = os.Args[0] ExecDir = filepath.Dir(ExecPath) // ConfigRaw 配置信息的原始数据 ConfigRaw []byte Plugins = make(map[string]*Plugin) // Plugins 所有的插件配置 EngineConfig = &GlobalConfig{ Engine: config.Global, } Engine = InstallPlugin(EngineConfig) //复用安装插件逻辑,将全局配置信息注入,并启动server MergeConfigs = []string{"Publish", "Subscribe", "HTTP"} //需要合并配置的属性项,插件若没有配置则使用全局配置 EventBus = make(chan any, 10) )
View Source
var ActionNames = [...]string{"publish", "timeout", "publish lost", "close", "last leave", "first enter", "no tracks"}
View Source
var BadNameErr = errors.New("Bad Name")
View Source
var NoPullConfigErr = errors.New("no pull config")
View Source
var NoPushConfigErr = errors.New("no push config")
View Source
var Pullers sync.Map
View Source
var Pushers sync.Map
View Source
var StateNames = [...]string{"⌛", "🟢", "🟡", "🔴"}
View Source
var StreamFSM = [len(StateNames)]map[StreamAction]StreamState{ { ACTION_PUBLISH: STATE_PUBLISHING, ACTION_TIMEOUT: STATE_CLOSED, ACTION_LASTLEAVE: STATE_CLOSED, ACTION_CLOSE: STATE_CLOSED, }, { ACTION_PUBLISHLOST: STATE_WAITPUBLISH, ACTION_LASTLEAVE: STATE_WAITCLOSE, ACTION_CLOSE: STATE_CLOSED, }, { ACTION_PUBLISHLOST: STATE_CLOSED, ACTION_TIMEOUT: STATE_CLOSED, ACTION_FIRSTENTER: STATE_PUBLISHING, ACTION_CLOSE: STATE_CLOSED, }, {}, }
View Source
var StreamIsClosedErr = errors.New("Stream Is Closed")
Streams 所有的流集合
Functions ¶
Types ¶
type AudioDeConf ¶
type AudioDeConf DecoderConfiguration[AudioSlice]
type AudioFrame ¶
type AudioFrame AVFrame[AudioSlice]
type ClientIO ¶ added in v4.1.0
type ClientIO[C ClientConfig] struct { Config *C StreamPath string // 本地流标识 RemoteURL string // 远程服务器地址(用于推拉) ReConnectCount int //重连次数 }
ClientIO 作为Client角色(Puller,Pusher)的公共结构体
type FirstConfig ¶
type GlobalConfig ¶
func (*GlobalConfig) API_closeStream ¶
func (conf *GlobalConfig) API_closeStream(w http.ResponseWriter, r *http.Request)
func (*GlobalConfig) API_getConfig ¶
func (conf *GlobalConfig) API_getConfig(w http.ResponseWriter, r *http.Request)
API_getConfig 获取指定的配置信息
func (*GlobalConfig) API_list_pull ¶ added in v4.6.4
func (conf *GlobalConfig) API_list_pull(w http.ResponseWriter, r *http.Request)
func (*GlobalConfig) API_list_push ¶ added in v4.6.4
func (conf *GlobalConfig) API_list_push(w http.ResponseWriter, r *http.Request)
func (*GlobalConfig) API_modifyConfig ¶
func (conf *GlobalConfig) API_modifyConfig(w http.ResponseWriter, r *http.Request)
API_modifyConfig 修改并保存配置
func (*GlobalConfig) API_plugins ¶ added in v4.1.4
func (conf *GlobalConfig) API_plugins(rw http.ResponseWriter, r *http.Request)
func (*GlobalConfig) API_stream ¶ added in v4.1.0
func (conf *GlobalConfig) API_stream(rw http.ResponseWriter, r *http.Request)
func (*GlobalConfig) API_summary ¶
func (conf *GlobalConfig) API_summary(rw http.ResponseWriter, r *http.Request)
func (*GlobalConfig) API_sysInfo ¶
func (conf *GlobalConfig) API_sysInfo(rw http.ResponseWriter, r *http.Request)
func (*GlobalConfig) API_updateConfig ¶
func (conf *GlobalConfig) API_updateConfig(w http.ResponseWriter, r *http.Request)
API_updateConfig 热更新配置
func (*GlobalConfig) ServeHTTP ¶
func (conf *GlobalConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request)
type IO ¶
type IO[C IOConfig] struct { ID string Type string context.Context `json:"-"` //不要直接设置,应当通过OnEvent传入父级Context context.CancelFunc `json:"-"` //流关闭是关闭发布者或者订阅者 *zap.Logger `json:"-"` StartTime time.Time //创建时间 Stream *Stream `json:"-"` io.Reader `json:"-"` io.Writer `json:"-"` io.Closer `json:"-"` Args url.Values Config *C `json:"-"` Spesic IIO `json:"-"` }
发布者或者订阅者的共用结构体
type IPublisher ¶
type IPuller ¶
type IPuller interface { IPublisher Connect() error Pull() Reconnect() bool // contains filtered or unexported methods }
type IPusher ¶
type IPusher interface { ISubscriber Push() error Connect() error Reconnect() bool // contains filtered or unexported methods }
type ISubscriber ¶
type NetWorkInfo ¶
type NetWorkInfo struct { Name string Receive uint64 Sent uint64 ReceiveSpeed uint64 SentSpeed uint64 }
NetWorkInfo 网速信息
type PlayContext ¶
type PlayContext[T interface { GetDecConfSeq() int ReadRing() *AVRing[R] }, R RawSlice] struct { Track T Frame *AVFrame[R] // contains filtered or unexported fields }
func (*PlayContext[T, R]) MarshalJSON ¶
func (p *PlayContext[T, R]) MarshalJSON() ([]byte, error)
type Plugin ¶
type Plugin struct { context.Context `json:"-"` context.CancelFunc `json:"-"` Name string //插件名称 Config config.Plugin `json:"-"` //插件配置 Version string //插件版本 RawConfig config.Config //配置的map形式方便查询 Modified config.Config //修改过的配置项 *zap.Logger `json:"-"` }
Plugin 插件信息
func InstallPlugin ¶
InstallPlugin 安装插件,传入插件配置生成插件信息对象
func (*Plugin) SubscribeBlock ¶
func (opt *Plugin) SubscribeBlock(streamPath string, sub ISubscriber, t byte) (err error)
type Publisher ¶
type Publisher struct { IO[config.Publish] common.AudioTrack `json:"-"` common.VideoTrack `json:"-"` }
func (*Publisher) Equal ¶
func (p *Publisher) Equal(p2 IPublisher) bool
func (*Publisher) WriteAVCCAudio ¶ added in v4.1.0
type SEclose ¶
type SEclose struct {
StateEvent
}
type SEpublish ¶
type SEpublish struct {
StateEvent
}
type SEwaitClose ¶
type SEwaitClose struct {
StateEvent
}
type SEwaitPublish ¶
type SEwaitPublish struct { StateEvent Publisher IPublisher }
type StateEvent ¶
type StateEvent struct { Action StreamAction From StreamState Stream *Stream }
func (StateEvent) Next ¶
func (se StateEvent) Next() (next StreamState, ok bool)
type Stream ¶
type Stream struct { *zap.Logger StartTime time.Time //创建时间 StreamTimeoutConfig Path string Publisher IPublisher State StreamState Subscribers []ISubscriber // 订阅者 Tracks Tracks AppName string StreamName string // contains filtered or unexported fields }
Stream 流定义
func FilterStreams ¶
func FilterStreams[T IPublisher]() (ss []*Stream)
func (*Stream) RemoveTrack ¶
func (s *Stream) RemoveTrack(t Track)
func (*Stream) Summary ¶ added in v4.1.0
func (s *Stream) Summary() (r StreamSummay)
Summary 返回流的简要信息
type StreamAction ¶
type StreamAction byte
const ( ACTION_PUBLISH StreamAction = iota ACTION_TIMEOUT // 发布流长时间没有数据/长时间没有发布者发布流/等待关闭时间到 ACTION_PUBLISHLOST // 发布者意外断开 ACTION_CLOSE // 主动关闭流 ACTION_LASTLEAVE // 最后一个订阅者离开 ACTION_FIRSTENTER // 第一个订阅者进入 )
type StreamState ¶
type StreamState byte
const ( STATE_WAITPUBLISH StreamState = iota // 等待发布者状态 STATE_PUBLISHING // 正在发布流状态 STATE_WAITCLOSE // 等待关闭状态(自动关闭延时开启) STATE_CLOSED // 流已关闭,不可使用 )
四状态机
type StreamSummay ¶ added in v4.1.0
type StreamTimeoutConfig ¶
type Subscriber ¶
type Subscriber struct { IO[config.Subscribe] TrackPlayer `json:"-"` }
Subscriber 订阅者实体定义
func (*Subscriber) AddTrack ¶
func (s *Subscriber) AddTrack(t Track) bool
func (*Subscriber) IsPlaying ¶
func (s *Subscriber) IsPlaying() bool
func (*Subscriber) OnEvent ¶
func (s *Subscriber) OnEvent(event any)
func (*Subscriber) PlayFLV ¶ added in v4.3.0
func (s *Subscriber) PlayFLV()
func (*Subscriber) PlayRTP ¶ added in v4.4.0
func (s *Subscriber) PlayRTP()
func (*Subscriber) PlayRaw ¶ added in v4.3.0
func (s *Subscriber) PlayRaw()
type Summary ¶
type Summary 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 Streams []StreamSummay // contains filtered or unexported fields }
ServerSummary 系统摘要定义
type TSPublisher ¶
type TSPublisher struct { Publisher *mpegts.MpegTsStream // contains filtered or unexported fields }
func (*TSPublisher) OnEvent ¶
func (t *TSPublisher) OnEvent(event any)
func (*TSPublisher) OnPES ¶
func (t *TSPublisher) OnPES(pes mpegts.MpegTsPESPacket)
func (*TSPublisher) OnPmtStream ¶
func (t *TSPublisher) OnPmtStream(s mpegts.MpegTsPmtStream)
type TrackPlayer ¶
type TrackPlayer struct { context.Context `json:"-"` context.CancelFunc `json:"-"` Audio PlayContext[*track.Audio, AudioSlice] Video PlayContext[*track.Video, NALUSlice] SkipTS uint32 //跳过的时间戳 FirstAbsTS uint32 //订阅起始时间戳 }
type TrackRemoved ¶
type TrackRemoved struct {
Track
}
type Tracks ¶ added in v4.5.1
func (*Tracks) MarshalJSON ¶ added in v4.5.1
type VideoDeConf ¶
type VideoDeConf DecoderConfiguration[NALUSlice]
func (VideoDeConf) GetAnnexB ¶ added in v4.2.0
func (v VideoDeConf) GetAnnexB() (r net.Buffers)
type VideoFrame ¶
type VideoFrame AVFrame[NALUSlice]
func (*VideoFrame) GetAnnexB ¶ added in v4.2.0
func (v *VideoFrame) GetAnnexB() (r net.Buffers)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.