Documentation ¶
Index ¶
- Variables
- func SimpleAuthCalcSecret(key string, streamName string) string
- type CommonHttpAddrConfig
- type CommonHttpServerConfig
- type ComplexGroupManager
- func (gm *ComplexGroupManager) GetGroup(appName string, streamName string) *Group
- func (gm *ComplexGroupManager) GetOrCreateGroup(appName string, streamName string) (group *Group, createFlag bool)
- func (gm *ComplexGroupManager) Iterate(onIterateGroup func(group *Group) bool)
- func (gm *ComplexGroupManager) Len() int
- type Config
- type CustomizePubSessionContext
- func (ctx *CustomizePubSessionContext) Dispose()
- func (ctx *CustomizePubSessionContext) FeedAudioSpecificConfig(asc []byte) error
- func (ctx *CustomizePubSessionContext) FeedAvPacket(packet base.AvPacket) error
- func (ctx *CustomizePubSessionContext) FeedRtmpMsg(msg base.RtmpMsg) error
- func (ctx *CustomizePubSessionContext) StreamName() string
- func (ctx *CustomizePubSessionContext) UniqueKey() string
- func (ctx *CustomizePubSessionContext) WithCustomizePubSessionContextOption(modFn func(option *CustomizePubSessionOption)) *CustomizePubSessionContext
- func (ctx *CustomizePubSessionContext) WithOnRtmpMsg(onRtmpMsg func(msg base.RtmpMsg)) *CustomizePubSessionContext
- func (ctx *CustomizePubSessionContext) WithOption(modOption func(option *base.AvPacketStreamOption))
- type CustomizePubSessionOption
- type DebugConfig
- type DefaultHttpConfig
- type Group
- func (group *Group) AddCustomizePubSession(streamName string) (ICustomizePubSessionContext, error)
- func (group *Group) AddHlsSubSession(session *hls.SubSession)
- func (group *Group) AddHttpflvSubSession(session *httpflv.SubSession)
- func (group *Group) AddHttptsSubSession(session *httpts.SubSession)
- func (group *Group) AddRtmpPubSession(session *rtmp.ServerSession) error
- func (group *Group) AddRtmpPullSession(session *rtmp.PullSession) error
- func (group *Group) AddRtmpPushSession(url string, session *rtmp.PushSession)
- func (group *Group) AddRtmpSubSession(session *rtmp.ServerSession)
- func (group *Group) AddRtspPubSession(session *rtsp.PubSession) error
- func (group *Group) AddRtspPullSession(session *rtsp.PullSession) error
- func (group *Group) DelCustomizePubSession(sessionCtx ICustomizePubSessionContext)
- func (group *Group) DelHlsSubSession(session *hls.SubSession)
- func (group *Group) DelHttpflvSubSession(session *httpflv.SubSession)
- func (group *Group) DelHttptsSubSession(session *httpts.SubSession)
- func (group *Group) DelPsPubSession(session *gb28181.PubSession)
- 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) DelRtspPullSession(session *rtsp.PullSession)
- func (group *Group) DelRtspSubSession(session *rtsp.SubSession)
- func (group *Group) Dispose()
- func (group *Group) GetStat(maxsub int) base.StatGroup
- func (group *Group) HandleNewRtspSubSessionDescribe(session *rtsp.SubSession) (ok bool, sdp []byte)
- func (group *Group) HandleNewRtspSubSessionPlay(session *rtsp.SubSession)
- func (group *Group) HasInSession() bool
- func (group *Group) HasOutSession() bool
- func (group *Group) IsHlsMuxerAlive() bool
- func (group *Group) IsInactive() bool
- func (group *Group) KickSession(sessionId string) bool
- func (group *Group) OnAvPacket(pkt base.AvPacket)
- func (group *Group) OnAvPacketFromPsPubSession(pkt *base.AvPacket)
- func (group *Group) OnFragmentOpen()
- func (group *Group) OnHlsMakeTs(info base.HlsMakeTsInfo)
- func (group *Group) OnPatPmt(b []byte)
- func (group *Group) OnReadRtmpAvMsg(msg base.RtmpMsg)
- func (group *Group) OnRtpPacket(pkt rtprtcp.RtpPacket)
- func (group *Group) OnSdp(sdpCtx sdp.LogicContext)
- func (group *Group) OnTsPackets(tsPackets []byte, frame *mpegts.Frame, boundary bool)
- func (group *Group) OutSessionNum() int
- func (group *Group) RunLoop()
- func (group *Group) StartPull(info base.ApiCtrlStartRelayPullReq) (string, error)
- func (group *Group) StartRtpPub(req base.ApiCtrlStartRtpPubReq) (ret base.ApiCtrlStartRtpPubResp)
- func (group *Group) StopPull() string
- func (group *Group) StringifyDebugStats(maxsub int) string
- func (group *Group) Tick(tickCount uint32)
- type GroupOption
- type HlsConfig
- type HttpApiConfig
- type HttpApiServer
- type HttpNotify
- func (h *HttpNotify) NotifyOnHlsMakeTs(info base.HlsMakeTsInfo)
- func (h *HttpNotify) NotifyPubStart(info base.PubStartInfo)
- func (h *HttpNotify) NotifyPubStop(info base.PubStopInfo)
- func (h *HttpNotify) NotifyPullStart(info base.PullStartInfo)
- func (h *HttpNotify) NotifyPullStop(info base.PullStopInfo)
- func (h *HttpNotify) NotifyRtmpConnect(info base.RtmpConnectInfo)
- func (h *HttpNotify) NotifyServerStart(info base.LalInfo)
- func (h *HttpNotify) NotifySubStart(info base.SubStartInfo)
- func (h *HttpNotify) NotifySubStop(info base.SubStopInfo)
- func (h *HttpNotify) NotifyUpdate(info base.UpdateInfo)
- func (h *HttpNotify) OnHlsMakeTs(info base.HlsMakeTsInfo)
- func (h *HttpNotify) OnPubStart(info base.PubStartInfo)
- func (h *HttpNotify) OnPubStop(info base.PubStopInfo)
- func (h *HttpNotify) OnRelayPullStart(info base.PullStartInfo)
- func (h *HttpNotify) OnRelayPullStop(info base.PullStopInfo)
- func (h *HttpNotify) OnRtmpConnect(info base.RtmpConnectInfo)
- func (h *HttpNotify) OnServerStart(info base.LalInfo)
- 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 HttpServerHandler
- type HttpflvConfig
- type HttptsConfig
- type IAuthentication
- type ICustomizeHookSessionContext
- type ICustomizePubSessionContext
- type IGroupCreator
- type IGroupManager
- type IGroupObserver
- type IHttpServerHandlerObserver
- type ILalServer
- type INotifyHandler
- type InSessionConfig
- type IpBlacklist
- type ModConfigGroupCreator
- type ModCustomizePubSessionOptionFn
- type ModOption
- type Option
- type PostTask
- type PprofConfig
- type RecordConfig
- type RelayPushConfig
- type RtmpConfig
- type RtspConfig
- type ServerManager
- func (sm *ServerManager) AddCustomizePubSession(streamName string) (ICustomizePubSessionContext, error)
- func (sm *ServerManager) CleanupHlsIfNeeded(appName string, streamName string, path string)
- func (sm *ServerManager) Config() *Config
- func (sm *ServerManager) CreateGroup(appName string, streamName string) *Group
- func (sm *ServerManager) CtrlAddIpBlacklist(info base.ApiCtrlAddIpBlacklistReq) (ret base.ApiCtrlAddIpBlacklistResp)
- func (sm *ServerManager) CtrlKickSession(info base.ApiCtrlKickSessionReq) (ret base.ApiCtrlKickSessionResp)
- func (sm *ServerManager) CtrlStartRelayPull(info base.ApiCtrlStartRelayPullReq) (ret base.ApiCtrlStartRelayPullResp)
- func (sm *ServerManager) CtrlStartRtpPub(info base.ApiCtrlStartRtpPubReq) (ret base.ApiCtrlStartRtpPubResp)
- func (sm *ServerManager) CtrlStopRelayPull(streamName string) (ret base.ApiCtrlStopRelayPullResp)
- func (sm *ServerManager) DelCustomizePubSession(sessionCtx ICustomizePubSessionContext)
- func (sm *ServerManager) Dispose()
- func (sm *ServerManager) GetGroup(appName string, streamName string) *Group
- func (sm *ServerManager) OnDelHlsSubSession(session *hls.SubSession)
- 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) OnHlsMakeTs(info base.HlsMakeTsInfo)
- func (sm *ServerManager) OnNewHlsSubSession(session *hls.SubSession) error
- func (sm *ServerManager) OnNewHttpflvSubSession(session *httpflv.SubSession) error
- func (sm *ServerManager) OnNewHttptsSubSession(session *httpts.SubSession) error
- func (sm *ServerManager) OnNewRtmpPubSession(session *rtmp.ServerSession) error
- func (sm *ServerManager) OnNewRtmpSubSession(session *rtmp.ServerSession) error
- func (sm *ServerManager) OnNewRtspPubSession(session *rtsp.PubSession) error
- 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) error
- func (sm *ServerManager) OnRelayPullStart(info base.PullStartInfo)
- func (sm *ServerManager) OnRelayPullStop(info base.PullStopInfo)
- func (sm *ServerManager) OnRtmpConnect(session *rtmp.ServerSession, opa rtmp.ObjectPairArray)
- func (sm *ServerManager) RunLoop() error
- func (sm *ServerManager) StatAllGroup() (sgs []base.StatGroup)
- func (sm *ServerManager) StatGroup(streamName string) *base.StatGroup
- func (sm *ServerManager) StatLalInfo() base.LalInfo
- func (sm *ServerManager) WithOnHookSession(...)
- type SimpleAuthConfig
- type SimpleAuthCtx
- type SimpleGroupManager
- func (s *SimpleGroupManager) GetGroup(appName string, streamName string) *Group
- func (s *SimpleGroupManager) GetOrCreateGroup(appName string, streamName string) (group *Group, createFlag bool)
- func (s *SimpleGroupManager) Iterate(onIterateGroup func(group *Group) bool)
- func (s *SimpleGroupManager) Len() int
- type StaticRelayPullConfig
Constants ¶
This section is empty.
Variables ¶
var ( RelayPushTimeoutMs = 10000 RelayPushWriteAvTimeoutMs = 10000 StaticRelayPullTimeoutMs = 10000 DefaultApiCtrlStartRtpPubReqTimeoutMs = 60000 DefaultApiCtrlStartRelayPullReqPullTimeoutMs = 10000 )
var Log = nazalog.GetGlobalLogger()
Functions ¶
func SimpleAuthCalcSecret ¶
Types ¶
type CommonHttpAddrConfig ¶
type CommonHttpServerConfig ¶
type CommonHttpServerConfig struct { CommonHttpAddrConfig Enable bool `json:"enable"` EnableHttps bool `json:"enable_https"` UrlPattern string `json:"url_pattern"` }
type ComplexGroupManager ¶
type ComplexGroupManager struct {
// contains filtered or unexported fields
}
ComplexGroupManager
注意,这个模块的功能不完全,目前只使用SimpleGroupManager
TODO(chef):
- 现有逻辑重构至当前模块中【DONE】 - server_manger接入当前模块,替换掉原来的map【DONE】 - 重构整理使用server_manager的地方【DONE】 - 实现appName逻辑的IGroupManager【DONE】 - 增加单元测试【DONE】 - 配置文件或var.go中增加选取具体IGroupManager实现的开关 - 去除配置文件中一部分的url_pattern - 更新相应的文档:本文件注释,server_manager等中原有关于appName的注释,配置文件文档,流地址列表文档 - 创建group时没有appname,后面又有了,可以考虑更新一下 - ComplexGroupManager使用IGroupCreator
---------------------------------------------------------------------------------------------------------------------
背景:
- 有的协议需要结合appName和streamName作为流唯一标识(比如rtmp,httpflv,httpts)。
- 有的协议不需要appName,只使用streamName作为流唯一标识(比如rtsp?)。
目标:
- 有appName的协议,需要参考appName。
- 没appName的协议,需要和有appName的协议互通。
注意:
- 当以上两种类型的协议混用时,系统使用者应避免第二种协议的streamName,在第一种协议中存在相同的streamName,但是appName不止一个,这种情况下,内部无法知道该如何对应。
- group可能由第一种协议创建,也可能由第二种协议创建。
func NewComplexGroupManager ¶
func NewComplexGroupManager(groupCreator IGroupCreator) *ComplexGroupManager
func (*ComplexGroupManager) GetGroup ¶
func (gm *ComplexGroupManager) GetGroup(appName string, streamName string) *Group
func (*ComplexGroupManager) GetOrCreateGroup ¶
func (gm *ComplexGroupManager) GetOrCreateGroup(appName string, streamName string) (group *Group, createFlag bool)
func (*ComplexGroupManager) Iterate ¶
func (gm *ComplexGroupManager) Iterate(onIterateGroup func(group *Group) bool)
func (*ComplexGroupManager) Len ¶
func (gm *ComplexGroupManager) Len() int
type Config ¶
type Config struct { ConfVersion string `json:"conf_version"` RtmpConfig RtmpConfig `json:"rtmp"` InSessionConfig InSessionConfig `json:"in_session"` DefaultHttpConfig DefaultHttpConfig `json:"default_http"` HttpflvConfig HttpflvConfig `json:"httpflv"` HlsConfig HlsConfig `json:"hls"` HttptsConfig HttptsConfig `json:"httpts"` RtspConfig RtspConfig `json:"rtsp"` RecordConfig RecordConfig `json:"record"` RelayPushConfig RelayPushConfig `json:"relay_push"` StaticRelayPullConfig StaticRelayPullConfig `json:"static_relay_pull"` HttpApiConfig HttpApiConfig `json:"http_api"` ServerId string `json:"server_id"` HttpNotifyConfig HttpNotifyConfig `json:"http_notify"` SimpleAuthConfig SimpleAuthConfig `json:"simple_auth"` PprofConfig PprofConfig `json:"pprof"` LogConfig nazalog.Option `json:"log"` DebugConfig DebugConfig `json:"debug"` }
func LoadConfAndInitLog ¶
type CustomizePubSessionContext ¶
type CustomizePubSessionContext struct {
// contains filtered or unexported fields
}
func NewCustomizePubSessionContext ¶
func NewCustomizePubSessionContext(streamName string) *CustomizePubSessionContext
func (*CustomizePubSessionContext) Dispose ¶
func (ctx *CustomizePubSessionContext) Dispose()
func (*CustomizePubSessionContext) FeedAudioSpecificConfig ¶
func (ctx *CustomizePubSessionContext) FeedAudioSpecificConfig(asc []byte) error
func (*CustomizePubSessionContext) FeedAvPacket ¶
func (ctx *CustomizePubSessionContext) FeedAvPacket(packet base.AvPacket) error
func (*CustomizePubSessionContext) FeedRtmpMsg ¶
func (ctx *CustomizePubSessionContext) FeedRtmpMsg(msg base.RtmpMsg) error
func (*CustomizePubSessionContext) StreamName ¶
func (ctx *CustomizePubSessionContext) StreamName() string
func (*CustomizePubSessionContext) UniqueKey ¶
func (ctx *CustomizePubSessionContext) UniqueKey() string
func (*CustomizePubSessionContext) WithCustomizePubSessionContextOption ¶
func (ctx *CustomizePubSessionContext) WithCustomizePubSessionContextOption(modFn func(option *CustomizePubSessionOption)) *CustomizePubSessionContext
func (*CustomizePubSessionContext) WithOnRtmpMsg ¶
func (ctx *CustomizePubSessionContext) WithOnRtmpMsg(onRtmpMsg func(msg base.RtmpMsg)) *CustomizePubSessionContext
func (*CustomizePubSessionContext) WithOption ¶
func (ctx *CustomizePubSessionContext) WithOption(modOption func(option *base.AvPacketStreamOption))
type CustomizePubSessionOption ¶
type CustomizePubSessionOption struct {
DebugDumpPacket string
}
type DebugConfig ¶
type DefaultHttpConfig ¶
type DefaultHttpConfig struct {
CommonHttpAddrConfig
}
type Group ¶
type Group struct { UniqueKey string // const after init // contains filtered or unexported fields }
func NewGroup ¶
func NewGroup(appName string, streamName string, config *Config, option GroupOption, observer IGroupObserver) *Group
func (*Group) AddCustomizePubSession ¶
func (group *Group) AddCustomizePubSession(streamName string) (ICustomizePubSessionContext, error)
func (*Group) AddHlsSubSession ¶
func (group *Group) AddHlsSubSession(session *hls.SubSession)
AddHlsSubSession ...
func (*Group) AddHttpflvSubSession ¶
func (group *Group) AddHttpflvSubSession(session *httpflv.SubSession)
func (*Group) AddHttptsSubSession ¶
func (group *Group) AddHttptsSubSession(session *httpts.SubSession)
AddHttptsSubSession ...
func (*Group) AddRtmpPubSession ¶
func (group *Group) AddRtmpPubSession(session *rtmp.ServerSession) error
func (*Group) AddRtmpPullSession ¶
func (group *Group) AddRtmpPullSession(session *rtmp.PullSession) error
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) error
AddRtspPubSession TODO chef: rtsp package中,增加回调返回值判断,如果是false,将连接关掉
func (*Group) AddRtspPullSession ¶
func (group *Group) AddRtspPullSession(session *rtsp.PullSession) error
func (*Group) DelCustomizePubSession ¶
func (group *Group) DelCustomizePubSession(sessionCtx ICustomizePubSessionContext)
func (*Group) DelHlsSubSession ¶
func (group *Group) DelHlsSubSession(session *hls.SubSession)
func (*Group) DelHttpflvSubSession ¶
func (group *Group) DelHttpflvSubSession(session *httpflv.SubSession)
func (*Group) DelHttptsSubSession ¶
func (group *Group) DelHttptsSubSession(session *httpts.SubSession)
func (*Group) DelPsPubSession ¶
func (group *Group) DelPsPubSession(session *gb28181.PubSession)
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) DelRtspPullSession ¶
func (group *Group) DelRtspPullSession(session *rtsp.PullSession)
func (*Group) DelRtspSubSession ¶
func (group *Group) DelRtspSubSession(session *rtsp.SubSession)
func (*Group) HandleNewRtspSubSessionDescribe ¶
func (group *Group) HandleNewRtspSubSessionDescribe(session *rtsp.SubSession) (ok bool, sdp []byte)
func (*Group) HandleNewRtspSubSessionPlay ¶
func (group *Group) HandleNewRtspSubSessionPlay(session *rtsp.SubSession)
func (*Group) HasInSession ¶
func (*Group) HasOutSession ¶
func (*Group) IsHlsMuxerAlive ¶
func (*Group) IsInactive ¶
func (*Group) KickSession ¶
func (*Group) OnHlsMakeTs ¶
func (group *Group) OnHlsMakeTs(info base.HlsMakeTsInfo)
func (*Group) OnReadRtmpAvMsg ¶
OnReadRtmpAvMsg
输入rtmp数据. 来自 rtmp.ServerSession(Pub), rtmp.PullSession, CustomizePubSessionContext(remux.AvPacket2RtmpRemuxer), (remux.DummyAudioFilter) 的回调.
func (*Group) OnSdp ¶
func (group *Group) OnSdp(sdpCtx sdp.LogicContext)
OnSdp OnRtpPacket OnAvPacket
输入rtsp(rtp)和rtp合帧之后的数据. 来自 rtsp.PubSession 的回调.
func (*Group) OnTsPackets ¶
OnTsPackets ...
func (*Group) OutSessionNum ¶
func (*Group) StartPull ¶
func (group *Group) StartPull(info base.ApiCtrlStartRelayPullReq) (string, error)
StartPull 外部命令主动触发pull拉流
func (*Group) StartRtpPub ¶
func (group *Group) StartRtpPub(req base.ApiCtrlStartRtpPubReq) (ret base.ApiCtrlStartRtpPubResp)
func (*Group) StringifyDebugStats ¶
type GroupOption ¶
type GroupOption struct {
// contains filtered or unexported fields
}
type HlsConfig ¶
type HlsConfig struct { CommonHttpServerConfig UseMemoryAsDiskFlag bool `json:"use_memory_as_disk_flag"` hls.MuxerConfig SubSessionTimeoutMs int `json:"sub_session_timeout_ms"` SubSessionHashKey string `json:"sub_session_hash_key"` }
type HttpApiConfig ¶
type HttpApiServer ¶
type HttpApiServer struct {
// contains filtered or unexported fields
}
func NewHttpApiServer ¶
func NewHttpApiServer(addr string, sm *ServerManager) *HttpApiServer
func (*HttpApiServer) Listen ¶
func (h *HttpApiServer) Listen() (err error)
func (*HttpApiServer) RunLoop ¶
func (h *HttpApiServer) RunLoop() error
type HttpNotify ¶
type HttpNotify struct {
// contains filtered or unexported fields
}
func NewHttpNotify ¶
func NewHttpNotify(cfg HttpNotifyConfig, serverId string) *HttpNotify
func (*HttpNotify) NotifyOnHlsMakeTs ¶
func (h *HttpNotify) NotifyOnHlsMakeTs(info base.HlsMakeTsInfo)
func (*HttpNotify) NotifyPubStart ¶
func (h *HttpNotify) NotifyPubStart(info base.PubStartInfo)
func (*HttpNotify) NotifyPubStop ¶
func (h *HttpNotify) NotifyPubStop(info base.PubStopInfo)
func (*HttpNotify) NotifyPullStart ¶
func (h *HttpNotify) NotifyPullStart(info base.PullStartInfo)
func (*HttpNotify) NotifyPullStop ¶
func (h *HttpNotify) NotifyPullStop(info base.PullStopInfo)
func (*HttpNotify) NotifyRtmpConnect ¶
func (h *HttpNotify) NotifyRtmpConnect(info base.RtmpConnectInfo)
func (*HttpNotify) NotifyServerStart ¶
func (h *HttpNotify) NotifyServerStart(info base.LalInfo)
func (*HttpNotify) NotifySubStart ¶
func (h *HttpNotify) NotifySubStart(info base.SubStartInfo)
func (*HttpNotify) NotifySubStop ¶
func (h *HttpNotify) NotifySubStop(info base.SubStopInfo)
func (*HttpNotify) NotifyUpdate ¶
func (h *HttpNotify) NotifyUpdate(info base.UpdateInfo)
func (*HttpNotify) OnHlsMakeTs ¶
func (h *HttpNotify) OnHlsMakeTs(info base.HlsMakeTsInfo)
func (*HttpNotify) OnPubStart ¶
func (h *HttpNotify) OnPubStart(info base.PubStartInfo)
func (*HttpNotify) OnPubStop ¶
func (h *HttpNotify) OnPubStop(info base.PubStopInfo)
func (*HttpNotify) OnRelayPullStart ¶
func (h *HttpNotify) OnRelayPullStart(info base.PullStartInfo)
func (*HttpNotify) OnRelayPullStop ¶
func (h *HttpNotify) OnRelayPullStop(info base.PullStopInfo)
func (*HttpNotify) OnRtmpConnect ¶
func (h *HttpNotify) OnRtmpConnect(info base.RtmpConnectInfo)
func (*HttpNotify) OnServerStart ¶
func (h *HttpNotify) OnServerStart(info base.LalInfo)
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"` OnRelayPullStart string `json:"on_relay_pull_start"` OnRelayPullStop string `json:"on_relay_pull_stop"` OnRtmpConnect string `json:"on_rtmp_connect"` OnHlsMakeTs string `json:"on_hls_make_ts"` }
type HttpServerHandler ¶
type HttpServerHandler struct {
// contains filtered or unexported fields
}
func NewHttpServerHandler ¶
func NewHttpServerHandler(observer IHttpServerHandlerObserver) *HttpServerHandler
func (*HttpServerHandler) ServeSubSession ¶
func (h *HttpServerHandler) ServeSubSession(writer http.ResponseWriter, req *http.Request)
type HttpflvConfig ¶
type HttpflvConfig struct { CommonHttpServerConfig GopNum int `json:"gop_num"` SingleGopMaxFrameNum int `json:"single_gop_max_frame_num"` }
type HttptsConfig ¶
type HttptsConfig struct { CommonHttpServerConfig GopNum int `json:"gop_num"` SingleGopMaxFrameNum int `json:"single_gop_max_frame_num"` }
type IAuthentication ¶
type IAuthentication interface { OnPubStart(info base.PubStartInfo) error OnSubStart(info base.SubStartInfo) error OnHls(streamName, urlParam string) error }
type ICustomizeHookSessionContext ¶
type ICustomizeHookSessionContext interface { // OnMsg // // 注意,业务方应尽快处理回调消息,否则会阻塞lal server内部处理逻辑。 // // @param msg: 注意,业务方不应该修改或持有该内存块,如果有需要,应对该内存块进行拷贝,比如调用 msg.Clone() 生成新的 base.RtmpMsg 再使用 OnMsg(msg base.RtmpMsg) OnStop() }
ICustomizeHookSessionContext
业务方实现该接口,从而hook所有输入到lalserver中的流以及流中的数据。
type IGroupCreator ¶
type IGroupManager ¶
type IGroupManager interface { // GetOrCreateGroup // // @param appName 注意,如果没有,可以为"" // @return createFlag 如果为false表示group之前就存在,如果为true表示为当前新创建 // GetOrCreateGroup(appName string, streamName string) (group *Group, createFlag bool) // GetGroup // // @return 如果不存在,则返回nil // GetGroup(appName string, streamName string) *Group // Iterate 遍历所有 Group // // @param onIterateGroup 如果返回false,则删除这个 Group // Iterate(onIterateGroup func(group *Group) bool) Len() int }
IGroupManager
封装管理Group的容器 管理流标识(appName,streamName)与Group的映射关系。比如appName是否参与映射匹配
type IGroupObserver ¶
type IGroupObserver interface { CleanupHlsIfNeeded(appName string, streamName string, path string) OnHlsMakeTs(info base.HlsMakeTsInfo) OnRelayPullStart(info base.PullStartInfo) // TODO(chef): refactor me OnRelayPullStop(info base.PullStopInfo) }
type IHttpServerHandlerObserver ¶
type IHttpServerHandlerObserver interface { // OnNewHttpflvSubSession // // 通知上层有新的拉流者 // // @return nil则允许拉流,不为nil则关闭连接 // OnNewHttpflvSubSession(session *httpflv.SubSession) error OnDelHttpflvSubSession(session *httpflv.SubSession) OnNewHttptsSubSession(session *httpts.SubSession) error OnDelHttptsSubSession(session *httpts.SubSession) }
type ILalServer ¶
type ILalServer interface { RunLoop() error Dispose() // AddCustomizePubSession 定制化增强功能。业务方可以将自己的流输入到 ILalServer 中 // // @example 示例见 lal/app/demo/customize_lalserver // // @doc 文档见 <lalserver二次开发 - pub接入自定义流> https://pengrl.com/lal/#/customize_pub // AddCustomizePubSession(streamName string) (ICustomizePubSessionContext, error) // DelCustomizePubSession 将 ICustomizePubSessionContext 对象从 ILalServer 中删除 // // 注意,业务方调用该函数后,就不要再使用该 ICustomizePubSessionContext 对象的方法了,比如继续 FeedAvPacket 是无效的 // DelCustomizePubSession(ICustomizePubSessionContext) // WithOnHookSession // // hook所有输入到lal server的流。 // 二次开发时使用。 // 当有流进入lal server时, onHookSession 被调用,业务方应该在回调中返回一个实现了 ICustomizeHookSessionContext 接口的对象。 // 后续收到流数据以及流停止时, ICustomizeHookSessionContext 对象的 OnMsg 和 OnStop 方法会被调用。 WithOnHookSession(onHookSession func(uniqueKey string, streamName string) ICustomizeHookSessionContext) // StatLalInfo StatAllGroup StatGroup CtrlStartPull CtrlKickOutSession // // 一些获取状态、发送控制命令的API。 // 目的是方便业务方在不修改logic包内代码的前提下,在外层实现一些特定逻辑的定制化开发。 // StatLalInfo() base.LalInfo StatAllGroup() (sgs []base.StatGroup) StatGroup(streamName string) *base.StatGroup CtrlStartRelayPull(info base.ApiCtrlStartRelayPullReq) base.ApiCtrlStartRelayPullResp CtrlStopRelayPull(streamName string) base.ApiCtrlStopRelayPullResp CtrlKickSession(info base.ApiCtrlKickSessionReq) base.ApiCtrlKickSessionResp }
func NewLalServer ¶
func NewLalServer(modOption ...ModOption) ILalServer
NewLalServer 创建一个lal server
@param modOption: 定制化配置。可变参数,如果不关心,可以不填,具体字段见 Option
type INotifyHandler ¶
type INotifyHandler interface { OnServerStart(info base.LalInfo) OnUpdate(info base.UpdateInfo) OnPubStart(info base.PubStartInfo) OnPubStop(info base.PubStopInfo) OnSubStart(info base.SubStartInfo) OnSubStop(info base.SubStopInfo) OnRelayPullStart(info base.PullStartInfo) OnRelayPullStop(info base.PullStopInfo) OnRtmpConnect(info base.RtmpConnectInfo) OnHlsMakeTs(info base.HlsMakeTsInfo) }
INotifyHandler 事件通知接口
type InSessionConfig ¶
type IpBlacklist ¶
type IpBlacklist struct {
// contains filtered or unexported fields
}
func (*IpBlacklist) Add ¶
func (l *IpBlacklist) Add(ip string, durationSec int)
func (*IpBlacklist) Has ¶
func (l *IpBlacklist) Has(ip string) bool
type ModConfigGroupCreator ¶
type ModCustomizePubSessionOptionFn ¶
type ModCustomizePubSessionOptionFn func(option *CustomizePubSessionOption)
type Option ¶
type Option struct { // ConfFilename 配置文件。 // // 注意,如果为空,内部会尝试从 DefaultConfFilenameList 读取默认配置文件 ConfFilename string // ConfRawContent 配置内容,json格式。 // // 应用场景:有的业务方配置内容并非从配置文件中读取,比如集成 ILalServer 时配置内容来自配置中心网络下发,所以提供这个字段供业务方直接传入配置内容。 // // 注意,读取加载配置的优先级是 ConfRawContent > ConfFilename > DefaultConfFilenameList ConfRawContent []byte // NotifyHandler // // 事件监听 // 业务方可实现 INotifyHandler 接口并传入从而获取到对应的事件通知。 // 如果不填写保持默认值nil,内部默认走http notify的逻辑(当然,还需要在配置文件中开启http notify功能)。 // 注意,如果业务方实现了自己的事件监听,则lal server内部不再走http notify的逻辑(也即二选一)。 // NotifyHandler INotifyHandler // ModConfigGroupCreator // This func help us modify the group configuration base on appName or streamName // so that group can have it own configuration (configuration can be in other source like db) // It will help us reduce resource usage if we just want some specific group record flv or hls... ModConfigGroupCreator ModConfigGroupCreator // Authentication // This interface make authenticate customizable so that we can implement any authenticate strategy like jwt... // // 这是一个同步接口,回调函数处于内部的处理逻辑与锁中 Authentication IAuthentication }
type PprofConfig ¶
type RecordConfig ¶
type RelayPushConfig ¶
type RtmpConfig ¶
type RtmpConfig struct { Enable bool `json:"enable"` Addr string `json:"addr"` RtmpsEnable bool `json:"rtmps_enable"` RtmpsAddr string `json:"rtmps_addr"` RtmpsCertFile string `json:"rtmps_cert_file"` RtmpsKeyFile string `json:"rtmps_key_file"` GopNum int `json:"gop_num"` // TODO(chef): refactor 更名为gop_cache_num SingleGopMaxFrameNum int `json:"single_gop_max_frame_num"` MergeWriteSize int `json:"merge_write_size"` }
type RtspConfig ¶
type RtspConfig struct { Enable bool `json:"enable"` Addr string `json:"addr"` RtspsEnable bool `json:"rtsps_enable"` RtspsAddr string `json:"rtsps_addr"` RtspsCertFile string `json:"rtsps_cert_file"` RtspsKeyFile string `json:"rtsps_key_file"` OutWaitKeyFrameFlag bool `json:"out_wait_key_frame_flag"` WsRtspEnable bool `json:"ws_rtsp_enable"` WsRtspAddr string `json:"ws_rtsp_addr"` rtsp.ServerAuthConfig }
type ServerManager ¶
type ServerManager struct {
// contains filtered or unexported fields
}
func NewServerManager ¶
func NewServerManager(modOption ...ModOption) *ServerManager
func (*ServerManager) AddCustomizePubSession ¶
func (sm *ServerManager) AddCustomizePubSession(streamName string) (ICustomizePubSessionContext, error)
func (*ServerManager) CleanupHlsIfNeeded ¶
func (sm *ServerManager) CleanupHlsIfNeeded(appName string, streamName string, path string)
func (*ServerManager) Config ¶
func (sm *ServerManager) Config() *Config
func (*ServerManager) CreateGroup ¶
func (sm *ServerManager) CreateGroup(appName string, streamName string) *Group
func (*ServerManager) CtrlAddIpBlacklist ¶
func (sm *ServerManager) CtrlAddIpBlacklist(info base.ApiCtrlAddIpBlacklistReq) (ret base.ApiCtrlAddIpBlacklistResp)
func (*ServerManager) CtrlKickSession ¶
func (sm *ServerManager) CtrlKickSession(info base.ApiCtrlKickSessionReq) (ret base.ApiCtrlKickSessionResp)
CtrlKickSession
TODO(chef): refactor 不要返回http结果,返回error吧
func (*ServerManager) CtrlStartRelayPull ¶
func (sm *ServerManager) CtrlStartRelayPull(info base.ApiCtrlStartRelayPullReq) (ret base.ApiCtrlStartRelayPullResp)
func (*ServerManager) CtrlStartRtpPub ¶
func (sm *ServerManager) CtrlStartRtpPub(info base.ApiCtrlStartRtpPubReq) (ret base.ApiCtrlStartRtpPubResp)
func (*ServerManager) CtrlStopRelayPull ¶
func (sm *ServerManager) CtrlStopRelayPull(streamName string) (ret base.ApiCtrlStopRelayPullResp)
CtrlStopRelayPull
TODO(chef): 整理错误值
func (*ServerManager) DelCustomizePubSession ¶
func (sm *ServerManager) DelCustomizePubSession(sessionCtx ICustomizePubSessionContext)
func (*ServerManager) Dispose ¶
func (sm *ServerManager) Dispose()
func (*ServerManager) GetGroup ¶
func (sm *ServerManager) GetGroup(appName string, streamName string) *Group
func (*ServerManager) OnDelHlsSubSession ¶
func (sm *ServerManager) OnDelHlsSubSession(session *hls.SubSession)
func (*ServerManager) OnDelHttpflvSubSession ¶
func (sm *ServerManager) OnDelHttpflvSubSession(session *httpflv.SubSession)
func (*ServerManager) OnDelHttptsSubSession ¶
func (sm *ServerManager) OnDelHttptsSubSession(session *httpts.SubSession)
func (*ServerManager) OnDelRtmpPubSession ¶
func (sm *ServerManager) OnDelRtmpPubSession(session *rtmp.ServerSession)
func (*ServerManager) OnDelRtmpSubSession ¶
func (sm *ServerManager) OnDelRtmpSubSession(session *rtmp.ServerSession)
func (*ServerManager) OnDelRtspPubSession ¶
func (sm *ServerManager) OnDelRtspPubSession(session *rtsp.PubSession)
func (*ServerManager) OnDelRtspSession ¶
func (sm *ServerManager) OnDelRtspSession(session *rtsp.ServerCommandSession)
func (*ServerManager) OnDelRtspSubSession ¶
func (sm *ServerManager) OnDelRtspSubSession(session *rtsp.SubSession)
func (*ServerManager) OnHlsMakeTs ¶
func (sm *ServerManager) OnHlsMakeTs(info base.HlsMakeTsInfo)
func (*ServerManager) OnNewHlsSubSession ¶
func (sm *ServerManager) OnNewHlsSubSession(session *hls.SubSession) error
func (*ServerManager) OnNewHttpflvSubSession ¶
func (sm *ServerManager) OnNewHttpflvSubSession(session *httpflv.SubSession) error
func (*ServerManager) OnNewHttptsSubSession ¶
func (sm *ServerManager) OnNewHttptsSubSession(session *httpts.SubSession) error
func (*ServerManager) OnNewRtmpPubSession ¶
func (sm *ServerManager) OnNewRtmpPubSession(session *rtmp.ServerSession) error
func (*ServerManager) OnNewRtmpSubSession ¶
func (sm *ServerManager) OnNewRtmpSubSession(session *rtmp.ServerSession) error
func (*ServerManager) OnNewRtspPubSession ¶
func (sm *ServerManager) OnNewRtspPubSession(session *rtsp.PubSession) error
func (*ServerManager) OnNewRtspSessionConnect ¶
func (sm *ServerManager) OnNewRtspSessionConnect(session *rtsp.ServerCommandSession)
func (*ServerManager) OnNewRtspSubSessionDescribe ¶
func (sm *ServerManager) OnNewRtspSubSessionDescribe(session *rtsp.SubSession) (ok bool, sdp []byte)
func (*ServerManager) OnNewRtspSubSessionPlay ¶
func (sm *ServerManager) OnNewRtspSubSessionPlay(session *rtsp.SubSession) error
func (*ServerManager) OnRelayPullStart ¶
func (sm *ServerManager) OnRelayPullStart(info base.PullStartInfo)
func (*ServerManager) OnRelayPullStop ¶
func (sm *ServerManager) OnRelayPullStop(info base.PullStopInfo)
func (*ServerManager) OnRtmpConnect ¶
func (sm *ServerManager) OnRtmpConnect(session *rtmp.ServerSession, opa rtmp.ObjectPairArray)
func (*ServerManager) RunLoop ¶
func (sm *ServerManager) RunLoop() error
func (*ServerManager) StatAllGroup ¶
func (sm *ServerManager) StatAllGroup() (sgs []base.StatGroup)
func (*ServerManager) StatGroup ¶
func (sm *ServerManager) StatGroup(streamName string) *base.StatGroup
func (*ServerManager) StatLalInfo ¶
func (sm *ServerManager) StatLalInfo() base.LalInfo
func (*ServerManager) WithOnHookSession ¶
func (sm *ServerManager) WithOnHookSession(onHookSession func(uniqueKey string, streamName string) ICustomizeHookSessionContext)
type SimpleAuthConfig ¶
type SimpleAuthConfig struct { Key string `json:"key"` DangerousLalSecret string `json:"dangerous_lal_secret"` PubRtmpEnable bool `json:"pub_rtmp_enable"` SubRtmpEnable bool `json:"sub_rtmp_enable"` SubHttpflvEnable bool `json:"sub_httpflv_enable"` SubHttptsEnable bool `json:"sub_httpts_enable"` PubRtspEnable bool `json:"pub_rtsp_enable"` SubRtspEnable bool `json:"sub_rtsp_enable"` HlsM3u8Enable bool `json:"hls_m3u8_enable"` }
type SimpleAuthCtx ¶
type SimpleAuthCtx struct {
// contains filtered or unexported fields
}
func NewSimpleAuthCtx ¶
func NewSimpleAuthCtx(config SimpleAuthConfig) *SimpleAuthCtx
func (*SimpleAuthCtx) OnHls ¶
func (s *SimpleAuthCtx) OnHls(streamName string, urlParam string) error
func (*SimpleAuthCtx) OnPubStart ¶
func (s *SimpleAuthCtx) OnPubStart(info base.PubStartInfo) error
func (*SimpleAuthCtx) OnSubStart ¶
func (s *SimpleAuthCtx) OnSubStart(info base.SubStartInfo) error
type SimpleGroupManager ¶
type SimpleGroupManager struct {
// contains filtered or unexported fields
}
SimpleGroupManager 忽略appName,只使用streamName
func NewSimpleGroupManager ¶
func NewSimpleGroupManager(groupCreator IGroupCreator) *SimpleGroupManager
func (*SimpleGroupManager) GetGroup ¶
func (s *SimpleGroupManager) GetGroup(appName string, streamName string) *Group
func (*SimpleGroupManager) GetOrCreateGroup ¶
func (s *SimpleGroupManager) GetOrCreateGroup(appName string, streamName string) (group *Group, createFlag bool)
func (*SimpleGroupManager) Iterate ¶
func (s *SimpleGroupManager) Iterate(onIterateGroup func(group *Group) bool)
func (*SimpleGroupManager) Len ¶
func (s *SimpleGroupManager) Len() int
type StaticRelayPullConfig ¶
Source Files ¶
- auth.go
- config.go
- customize_pubsession.go
- group__.go
- group__core_streaming.go
- group__in.go
- group__out_sub.go
- group__record_flv.go
- group__record_hls.go
- group__record_mpegts.go
- group__relay_pull.go
- group__relay_push.go
- group_manager.go
- http_api.go
- http_notify.go
- http_server_handler.go
- ip_blacklist.go
- logic.go
- server_manager__.go
- server_manager__api.go
- server_manager__notify.go
- simple_auth.go
- var.go