Documentation ¶
Index ¶
- Constants
- Variables
- func Dispose()
- func Entry(confFile string)
- func RunServer(c *Config)
- type Config
- type GOP
- type GOPCache
- type Group
- func (group *Group) AddHTTPFLVSubSession(session *httpflv.SubSession)
- func (group *Group) AddHTTPTSSubSession(session *httpts.SubSession)
- func (group *Group) AddRTMPPubSession(session *rtmp.ServerSession) bool
- func (group *Group) AddRTMPPullSession(session *rtmp.PullSession) bool
- func (group *Group) AddRTMPPushSession(url string, session *rtmp.PushSession)
- func (group *Group) AddRTMPSubSession(session *rtmp.ServerSession)
- func (group *Group) AddRTSPPubSession(session *rtsp.PubSession) bool
- func (group *Group) DelHTTPFLVSubSession(session *httpflv.SubSession)
- func (group *Group) DelHTTPTSSubSession(session *httpts.SubSession)
- func (group *Group) DelRTMPPubSession(session *rtmp.ServerSession)
- func (group *Group) DelRTMPPullSession(session *rtmp.PullSession)
- func (group *Group) DelRTMPPushSession(url string, session *rtmp.PushSession)
- func (group *Group) DelRTMPSubSession(session *rtmp.ServerSession)
- func (group *Group) DelRTSPPubSession(session *rtsp.PubSession)
- func (group *Group) DelRTSPSubSession(session *rtsp.SubSession)
- func (group *Group) Dispose()
- func (group *Group) GetStat() base.StatGroup
- func (group *Group) HandleNewRTSPSubSessionDescribe(session *rtsp.SubSession) (ok bool, sdp []byte)
- func (group *Group) HandleNewRTSPSubSessionPlay(session *rtsp.SubSession) bool
- func (group *Group) HasInSession() bool
- func (group *Group) HasOutSession() bool
- func (group *Group) IsHLSMuxerAlive() bool
- func (group *Group) IsTotalEmpty() bool
- func (group *Group) KickOutSession(sessionID string) bool
- func (group *Group) OnAVConfig(asc, vps, sps, pps []byte)
- func (group *Group) OnAVPacket(pkt base.AVPacket)
- func (group *Group) OnRTPPacket(pkt rtprtcp.RTPPacket)
- func (group *Group) OnReadRTMPAVMsg(msg base.RTMPMsg)
- func (group *Group) OnTSPackets(rawFrame []byte, boundary bool)
- func (group *Group) RunLoop()
- func (group *Group) StartPull(url string)
- func (group *Group) StringifyDebugStats() string
- func (group *Group) Tick()
- type HLSConfig
- type HTTPAPIConfig
- type HTTPAPIServer
- type HTTPAPIServerObserver
- type HTTPFLVConfig
- type HTTPNotify
- func (h *HTTPNotify) OnPubStart(info base.PubStartInfo)
- func (h *HTTPNotify) OnPubStop(info base.PubStopInfo)
- func (h *HTTPNotify) OnRTMPConnect(info base.RTMPConnectInfo)
- func (h *HTTPNotify) OnServerStart()
- func (h *HTTPNotify) OnSubStart(info base.SubStartInfo)
- func (h *HTTPNotify) OnSubStop(info base.SubStopInfo)
- func (h *HTTPNotify) OnUpdate(info base.UpdateInfo)
- func (h *HTTPNotify) RunLoop()
- type HTTPNotifyConfig
- type HTTPTSConfig
- type LazyChunkDivider
- type LazyGet
- type LazyRTMPMsg2FLVTag
- type PProfConfig
- type PostTask
- type RTMPConfig
- type RTSPConfig
- type RelayPullConfig
- type RelayPushConfig
- type ServerManager
- func (sm *ServerManager) Dispose()
- func (sm *ServerManager) GetGroup(appName string, streamName string) *Group
- func (sm *ServerManager) OnCtrlKickOutSession(info base.APICtrlKickOutSession) base.HTTPResponseBasic
- func (sm *ServerManager) OnCtrlStartPull(info base.APICtrlStartPullReq)
- func (sm *ServerManager) OnDelHTTPFLVSubSession(session *httpflv.SubSession)
- func (sm *ServerManager) OnDelHTTPTSSubSession(session *httpts.SubSession)
- func (sm *ServerManager) OnDelRTMPPubSession(session *rtmp.ServerSession)
- func (sm *ServerManager) OnDelRTMPSubSession(session *rtmp.ServerSession)
- func (sm *ServerManager) OnDelRTSPPubSession(session *rtsp.PubSession)
- func (sm *ServerManager) OnDelRTSPSession(session *rtsp.ServerCommandSession)
- func (sm *ServerManager) OnDelRTSPSubSession(session *rtsp.SubSession)
- func (sm *ServerManager) OnNewHTTPFLVSubSession(session *httpflv.SubSession) bool
- func (sm *ServerManager) OnNewHTTPTSSubSession(session *httpts.SubSession) bool
- func (sm *ServerManager) OnNewRTMPPubSession(session *rtmp.ServerSession) bool
- func (sm *ServerManager) OnNewRTMPSubSession(session *rtmp.ServerSession) bool
- func (sm *ServerManager) OnNewRTSPPubSession(session *rtsp.PubSession) bool
- func (sm *ServerManager) OnNewRTSPSessionConnect(session *rtsp.ServerCommandSession)
- func (sm *ServerManager) OnNewRTSPSubSessionDescribe(session *rtsp.SubSession) (ok bool, sdp []byte)
- func (sm *ServerManager) OnNewRTSPSubSessionPlay(session *rtsp.SubSession) bool
- func (sm *ServerManager) OnRTMPConnect(session *rtmp.ServerSession, opa rtmp.ObjectPairArray)
- func (sm *ServerManager) OnStatAllGroup() (sgs []base.StatGroup)
- func (sm *ServerManager) OnStatGroup(streamName string) *base.StatGroup
- func (sm *ServerManager) RunLoop()
Constants ¶
const ConfigVersion = "0.0.1"
Variables ¶
var ErrLogic = errors.New("lal.logic: fxxk")
Functions ¶
Types ¶
type Config ¶
type Config struct { RTMPConfig RTMPConfig `json:"rtmp"` HTTPFLVConfig HTTPFLVConfig `json:"httpflv"` HLSConfig HLSConfig `json:"hls"` HTTPTSConfig HTTPTSConfig `json:"httpts"` RTSPConfig RTSPConfig `json:"rtsp"` RelayPushConfig RelayPushConfig `json:"relay_push"` RelayPullConfig RelayPullConfig `json:"relay_pull"` HTTPAPIConfig HTTPAPIConfig `json:"http_api"` ServerID string `json:"server_id"` HTTPNotifyConfig HTTPNotifyConfig `json:"http_notify"` PProfConfig PProfConfig `json:"pprof"` LogConfig nazalog.Option `json:"log"` }
type GOPCache ¶
type GOPCache struct { Metadata []byte VideoSeqHeader []byte AACSeqHeader []byte // contains filtered or unexported fields }
func (*GOPCache) GetGOPCount ¶
func (*GOPCache) GetGOPDataAt ¶
type Group ¶
type Group struct { UniqueKey string // const after init // contains filtered or unexported fields }
func (*Group) AddHTTPFLVSubSession ¶
func (group *Group) AddHTTPFLVSubSession(session *httpflv.SubSession)
func (*Group) AddHTTPTSSubSession ¶
func (group *Group) AddHTTPTSSubSession(session *httpts.SubSession)
TODO chef:
这里应该也要考虑触发hls muxer开启 也即HTTPTS sub需要使用hls muxer,hls muxer开启和关闭都要考虑HTTPTS sub
func (*Group) AddRTMPPubSession ¶
func (group *Group) AddRTMPPubSession(session *rtmp.ServerSession) bool
func (*Group) AddRTMPPullSession ¶
func (group *Group) AddRTMPPullSession(session *rtmp.PullSession) bool
func (*Group) AddRTMPPushSession ¶
func (group *Group) AddRTMPPushSession(url string, session *rtmp.PushSession)
func (*Group) AddRTMPSubSession ¶
func (group *Group) AddRTMPSubSession(session *rtmp.ServerSession)
func (*Group) AddRTSPPubSession ¶
func (group *Group) AddRTSPPubSession(session *rtsp.PubSession) bool
TODO chef: rtsp package中,增加回调返回值判断,如果是false,将连接关掉
func (*Group) DelHTTPFLVSubSession ¶
func (group *Group) DelHTTPFLVSubSession(session *httpflv.SubSession)
func (*Group) DelHTTPTSSubSession ¶
func (group *Group) DelHTTPTSSubSession(session *httpts.SubSession)
func (*Group) DelRTMPPubSession ¶
func (group *Group) DelRTMPPubSession(session *rtmp.ServerSession)
func (*Group) DelRTMPPullSession ¶
func (group *Group) DelRTMPPullSession(session *rtmp.PullSession)
func (*Group) DelRTMPPushSession ¶
func (group *Group) DelRTMPPushSession(url string, session *rtmp.PushSession)
func (*Group) DelRTMPSubSession ¶
func (group *Group) DelRTMPSubSession(session *rtmp.ServerSession)
func (*Group) DelRTSPPubSession ¶
func (group *Group) DelRTSPPubSession(session *rtsp.PubSession)
func (*Group) DelRTSPSubSession ¶
func (group *Group) DelRTSPSubSession(session *rtsp.SubSession)
func (*Group) Dispose ¶
func (group *Group) Dispose()
主动释放所有资源。保证所有资源的生命周期逻辑上都在我们的控制中。降低出bug的几率,降低心智负担。 注意,Dispose后,不应再使用这个对象。 值得一提,如果是从其他协程回调回来的消息,在使用Group中的资源前,要判断资源是否存在以及可用。
TODO chef:
后续弄个协程来替换掉目前锁的方式,来做消息同步。这样有个好处,就是不用写很多的资源有效判断。统一写一个就好了。 目前Dispose在IsTotalEmpty时调用,暂时没有这个问题。
func (*Group) HandleNewRTSPSubSessionDescribe ¶
func (group *Group) HandleNewRTSPSubSessionDescribe(session *rtsp.SubSession) (ok bool, sdp []byte)
func (*Group) HandleNewRTSPSubSessionPlay ¶
func (group *Group) HandleNewRTSPSubSessionPlay(session *rtsp.SubSession) bool
func (*Group) HasInSession ¶
func (*Group) HasOutSession ¶
func (*Group) IsHLSMuxerAlive ¶
func (*Group) IsTotalEmpty ¶
func (*Group) KickOutSession ¶
func (*Group) OnAVConfig ¶
rtsp.PubSession
func (*Group) OnReadRTMPAVMsg ¶
rtmp.PubSession or rtmp.PullSession
func (*Group) OnTSPackets ¶
hls.Muxer
func (*Group) StringifyDebugStats ¶
type HLSConfig ¶
type HLSConfig struct { SubListenAddr string `json:"sub_listen_addr"` hls.MuxerConfig CleanupFlag bool `json:"cleanup_flag"` EventObserverConfig hls.MuxerEventObserver `json:"-"` HttpReadFileFallback hls.ReadFileFallback `json:"-"` }
type HTTPAPIConfig ¶
type HTTPAPIServer ¶
type HTTPAPIServer struct {
// contains filtered or unexported fields
}
func NewHTTPAPIServer ¶
func NewHTTPAPIServer(addr string, observer HTTPAPIServerObserver) *HTTPAPIServer
func (*HTTPAPIServer) Listen ¶
func (h *HTTPAPIServer) Listen() (err error)
func (*HTTPAPIServer) Runloop ¶
func (h *HTTPAPIServer) Runloop() error
type HTTPAPIServerObserver ¶
type HTTPAPIServerObserver interface { OnStatAllGroup() []base.StatGroup OnStatGroup(streamName string) *base.StatGroup OnCtrlStartPull(info base.APICtrlStartPullReq) OnCtrlKickOutSession(info base.APICtrlKickOutSession) base.HTTPResponseBasic }
type HTTPFLVConfig ¶
type HTTPFLVConfig struct { httpflv.ServerConfig GOPNum int `json:"gop_num"` }
type HTTPNotify ¶
type HTTPNotify struct {
// contains filtered or unexported fields
}
func (*HTTPNotify) OnPubStart ¶
func (h *HTTPNotify) OnPubStart(info base.PubStartInfo)
func (*HTTPNotify) OnPubStop ¶
func (h *HTTPNotify) OnPubStop(info base.PubStopInfo)
func (*HTTPNotify) OnRTMPConnect ¶
func (h *HTTPNotify) OnRTMPConnect(info base.RTMPConnectInfo)
func (*HTTPNotify) OnServerStart ¶
func (h *HTTPNotify) OnServerStart()
注意,这里的函数命名以On开头并不是因为是回调函数,而是notify给业务方的接口叫做on_server_start
func (*HTTPNotify) OnSubStart ¶
func (h *HTTPNotify) OnSubStart(info base.SubStartInfo)
func (*HTTPNotify) OnSubStop ¶
func (h *HTTPNotify) OnSubStop(info base.SubStopInfo)
func (*HTTPNotify) OnUpdate ¶
func (h *HTTPNotify) OnUpdate(info base.UpdateInfo)
func (*HTTPNotify) RunLoop ¶
func (h *HTTPNotify) RunLoop()
type HTTPNotifyConfig ¶
type HTTPNotifyConfig struct { Enable bool `json:"enable"` UpdateIntervalSec int `json:"update_interval_sec"` OnServerStart string `json:"on_server_start"` OnUpdate string `json:"on_update"` OnPubStart string `json:"on_pub_start"` OnPubStop string `json:"on_pub_stop"` OnSubStart string `json:"on_sub_start"` OnSubStop string `json:"on_sub_stop"` OnRTMPConnect string `json:"on_rtmp_connect"` }
type HTTPTSConfig ¶
type LazyChunkDivider ¶
type LazyChunkDivider struct {
// contains filtered or unexported fields
}
考虑以下两种场景: - 只有上行,没有下行,没有必要做rtmp chunk切片的操作 - 有多个下行,只需要做一次rtmp chunk切片 所以这一步做了懒处理
func (*LazyChunkDivider) Get ¶
func (lcd *LazyChunkDivider) Get() []byte
func (*LazyChunkDivider) Init ¶
func (lcd *LazyChunkDivider) Init(message []byte, header *base.RTMPHeader)
type LazyRTMPMsg2FLVTag ¶
type LazyRTMPMsg2FLVTag struct {
// contains filtered or unexported fields
}
懒转换
func (*LazyRTMPMsg2FLVTag) Get ¶
func (l *LazyRTMPMsg2FLVTag) Get() []byte
func (*LazyRTMPMsg2FLVTag) Init ¶
func (l *LazyRTMPMsg2FLVTag) Init(msg base.RTMPMsg)
type PProfConfig ¶
type RTMPConfig ¶
type RTSPConfig ¶
type RelayPullConfig ¶
type RelayPushConfig ¶
type ServerManager ¶
type ServerManager struct {
// contains filtered or unexported fields
}
func NewServerManager ¶
func NewServerManager() *ServerManager
func (*ServerManager) Dispose ¶
func (sm *ServerManager) Dispose()
func (*ServerManager) GetGroup ¶
func (sm *ServerManager) GetGroup(appName string, streamName string) *Group
func (*ServerManager) OnCtrlKickOutSession ¶
func (sm *ServerManager) OnCtrlKickOutSession(info base.APICtrlKickOutSession) base.HTTPResponseBasic
HTTPAPIServerObserver
func (*ServerManager) OnCtrlStartPull ¶
func (sm *ServerManager) OnCtrlStartPull(info base.APICtrlStartPullReq)
HTTPAPIServerObserver
func (*ServerManager) OnDelHTTPFLVSubSession ¶
func (sm *ServerManager) OnDelHTTPFLVSubSession(session *httpflv.SubSession)
ServerObserver of httpflv.Server
func (*ServerManager) OnDelHTTPTSSubSession ¶
func (sm *ServerManager) OnDelHTTPTSSubSession(session *httpts.SubSession)
ServerObserver of httpts.Server
func (*ServerManager) OnDelRTMPPubSession ¶
func (sm *ServerManager) OnDelRTMPPubSession(session *rtmp.ServerSession)
ServerObserver of rtmp.Server
func (*ServerManager) OnDelRTMPSubSession ¶
func (sm *ServerManager) OnDelRTMPSubSession(session *rtmp.ServerSession)
ServerObserver of rtmp.Server
func (*ServerManager) OnDelRTSPPubSession ¶
func (sm *ServerManager) OnDelRTSPPubSession(session *rtsp.PubSession)
ServerObserver of rtsp.Server
func (*ServerManager) OnDelRTSPSession ¶
func (sm *ServerManager) OnDelRTSPSession(session *rtsp.ServerCommandSession)
ServerObserver of rtsp.Server
func (*ServerManager) OnDelRTSPSubSession ¶
func (sm *ServerManager) OnDelRTSPSubSession(session *rtsp.SubSession)
ServerObserver of rtsp.Server
func (*ServerManager) OnNewHTTPFLVSubSession ¶
func (sm *ServerManager) OnNewHTTPFLVSubSession(session *httpflv.SubSession) bool
ServerObserver of httpflv.Server
func (*ServerManager) OnNewHTTPTSSubSession ¶
func (sm *ServerManager) OnNewHTTPTSSubSession(session *httpts.SubSession) bool
ServerObserver of httpts.Server
func (*ServerManager) OnNewRTMPPubSession ¶
func (sm *ServerManager) OnNewRTMPPubSession(session *rtmp.ServerSession) bool
ServerObserver of rtmp.Server
func (*ServerManager) OnNewRTMPSubSession ¶
func (sm *ServerManager) OnNewRTMPSubSession(session *rtmp.ServerSession) bool
ServerObserver of rtmp.Server
func (*ServerManager) OnNewRTSPPubSession ¶
func (sm *ServerManager) OnNewRTSPPubSession(session *rtsp.PubSession) bool
ServerObserver of rtsp.Server
func (*ServerManager) OnNewRTSPSessionConnect ¶
func (sm *ServerManager) OnNewRTSPSessionConnect(session *rtsp.ServerCommandSession)
ServerObserver of rtsp.Server
func (*ServerManager) OnNewRTSPSubSessionDescribe ¶
func (sm *ServerManager) OnNewRTSPSubSessionDescribe(session *rtsp.SubSession) (ok bool, sdp []byte)
ServerObserver of rtsp.Server
func (*ServerManager) OnNewRTSPSubSessionPlay ¶
func (sm *ServerManager) OnNewRTSPSubSessionPlay(session *rtsp.SubSession) bool
ServerObserver of rtsp.Server
func (*ServerManager) OnRTMPConnect ¶
func (sm *ServerManager) OnRTMPConnect(session *rtmp.ServerSession, opa rtmp.ObjectPairArray)
ServerObserver of rtmp.Server
func (*ServerManager) OnStatAllGroup ¶
func (sm *ServerManager) OnStatAllGroup() (sgs []base.StatGroup)
HTTPAPIServerObserver
func (*ServerManager) OnStatGroup ¶
func (sm *ServerManager) OnStatGroup(streamName string) *base.StatGroup
HTTPAPIServerObserver
func (*ServerManager) RunLoop ¶
func (sm *ServerManager) RunLoop()