Documentation ¶
Index ¶
- Constants
- Variables
- func Dispose()
- func Init(confFile string)
- func RunLoop()
- func SetConfig(c *Config)
- type CommonHttpAddrConfig
- type CommonHttpServerConfig
- type Config
- type DefaultHttpConfig
- 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) OnAvPacket(pkt base.AvPacket)
- 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(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 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 HttpServerHandler
- type HttpServerHandlerObserver
- type HttpflvConfig
- type HttptsConfig
- type LazyChunkDivider
- type LazyGet
- type LazyRtmpMsg2FlvTag
- type PostTask
- type PprofConfig
- type RecordConfig
- type RelayPullConfig
- type RelayPushConfig
- type RtmpConfig
- type RtspConfig
- 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() error
Constants ¶
const ConfVersion = "v0.2.2"
Variables ¶
var ErrLogic = errors.New("lal.logic: fxxk")
Functions ¶
Types ¶
type CommonHttpAddrConfig ¶ added in v0.24.1
type CommonHttpServerConfig ¶ added in v0.24.1
type CommonHttpServerConfig struct { CommonHttpAddrConfig Enable bool `json:"enable"` EnableHttps bool `json:"enable_https"` UrlPattern string `json:"url_pattern"` }
type Config ¶
type Config struct { ConfVersion string `json:"conf_version"` RtmpConfig RtmpConfig `json:"rtmp"` 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"` 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"` }
func LoadConfAndInitLog ¶ added in v0.19.12
type DefaultHttpConfig ¶ added in v0.24.1
type DefaultHttpConfig struct {
CommonHttpAddrConfig
}
type GopCache ¶ added in v0.24.1
type GopCache struct { Metadata []byte VideoSeqHeader []byte AacSeqHeader []byte // contains filtered or unexported fields }
提供两个功能:
- 缓存Metadata, VideoSeqHeader, AacSeqHeader
- 缓存音视频GOP数据
以下,只讨论GopCache的第2点功能
音频和视频都会缓存
GopCache也可能不缓存GOP数据,见NewGopCache函数的gopNum参数说明 ¶
以下,我们只讨论gopNum > 0(也即gopSize > 1)的情况
GopCache为空时,只有输入了关键帧,才能开启GOP缓存,非关键帧以及音频数据不会被缓存 因此,单音频的流是ok的,相当于不缓存任何数据
GopCache不为空时,输入关键帧触发生成新的GOP元素,其他情况则往最后一个GOP元素一直追加 ¶
first用于读取第一个GOP(可能不完整),last的前一个用于写入当前GOP
最近不完整的GOP也会被缓存,见NewGopCache函数的gopNum参数说明
----- gopNum = 1 gopSize = 2
first | first | first | 在后面两个状态间转换,就不画了 | | | | | | 0 1 | 0 1 | 0 1 | * * | * * | * * | | | | | | | last | last | last | | | | (empty) | (full) | (full) |
GetGopCount: 0 | 1 | 1 | -----
func NewGopCache ¶ added in v0.24.1
@param gopNum: gop缓存大小
如果为0,则不缓存音频数据,也即GOP缓存功能不生效 如果>0,则缓存<gopNum>个完整GOP,另外还可能有半个最近不完整的GOP
func (*GopCache) GetGopCount ¶ added in v0.24.1
获取GOP数量,注意,最后一个可能是不完整的
func (*GopCache) GetGopDataAt ¶ added in v0.24.1
type Group ¶
type Group struct { UniqueKey string // const after init // contains filtered or unexported fields }
func (*Group) AddHttpflvSubSession ¶ added in v0.24.1
func (group *Group) AddHttpflvSubSession(session *httpflv.SubSession)
func (*Group) AddHttptsSubSession ¶ added in v0.24.1
func (group *Group) AddHttptsSubSession(session *httpts.SubSession)
TODO chef:
这里应该也要考虑触发hls muxer开启 也即HTTPTS sub需要使用hls muxer,hls muxer开启和关闭都要考虑HTTPTS sub
func (*Group) AddRtmpPubSession ¶ added in v0.24.1
func (group *Group) AddRtmpPubSession(session *rtmp.ServerSession) bool
func (*Group) AddRtmpPullSession ¶ added in v0.24.1
func (group *Group) AddRtmpPullSession(session *rtmp.PullSession) bool
func (*Group) AddRtmpPushSession ¶ added in v0.24.1
func (group *Group) AddRtmpPushSession(url string, session *rtmp.PushSession)
func (*Group) AddRtmpSubSession ¶ added in v0.24.1
func (group *Group) AddRtmpSubSession(session *rtmp.ServerSession)
func (*Group) AddRtspPubSession ¶ added in v0.24.1
func (group *Group) AddRtspPubSession(session *rtsp.PubSession) bool
TODO chef: rtsp package中,增加回调返回值判断,如果是false,将连接关掉
func (*Group) DelHttpflvSubSession ¶ added in v0.24.1
func (group *Group) DelHttpflvSubSession(session *httpflv.SubSession)
func (*Group) DelHttptsSubSession ¶ added in v0.24.1
func (group *Group) DelHttptsSubSession(session *httpts.SubSession)
func (*Group) DelRtmpPubSession ¶ added in v0.24.1
func (group *Group) DelRtmpPubSession(session *rtmp.ServerSession)
func (*Group) DelRtmpPullSession ¶ added in v0.24.1
func (group *Group) DelRtmpPullSession(session *rtmp.PullSession)
func (*Group) DelRtmpPushSession ¶ added in v0.24.1
func (group *Group) DelRtmpPushSession(url string, session *rtmp.PushSession)
func (*Group) DelRtmpSubSession ¶ added in v0.24.1
func (group *Group) DelRtmpSubSession(session *rtmp.ServerSession)
func (*Group) DelRtspPubSession ¶ added in v0.24.1
func (group *Group) DelRtspPubSession(session *rtsp.PubSession)
func (*Group) DelRtspSubSession ¶ added in v0.24.1
func (group *Group) DelRtspSubSession(session *rtsp.SubSession)
func (*Group) Dispose ¶
func (group *Group) Dispose()
主动释放所有资源。保证所有资源的生命周期逻辑上都在我们的控制中。降低出bug的几率,降低心智负担。 注意,Dispose后,不应再使用这个对象。 值得一提,如果是从其他协程回调回来的消息,在使用Group中的资源前,要判断资源是否存在以及可用。
func (*Group) HandleNewRtspSubSessionDescribe ¶ added in v0.24.1
func (group *Group) HandleNewRtspSubSessionDescribe(session *rtsp.SubSession) (ok bool, sdp []byte)
func (*Group) HandleNewRtspSubSessionPlay ¶ added in v0.24.1
func (group *Group) HandleNewRtspSubSessionPlay(session *rtsp.SubSession) bool
func (*Group) HasInSession ¶
func (*Group) HasOutSession ¶
func (*Group) IsHlsMuxerAlive ¶ added in v0.24.1
func (*Group) IsTotalEmpty ¶
func (*Group) KickOutSession ¶
func (*Group) OnAvPacket ¶ added in v0.24.1
rtsp.PubSession
func (*Group) OnReadRtmpAvMsg ¶ added in v0.24.1
rtmp.PubSession or rtmp.PullSession
func (*Group) OnRtpPacket ¶ added in v0.24.1
rtsp.PubSession
func (*Group) OnSdp ¶ added in v0.24.1
func (group *Group) OnSdp(sdpCtx sdp.LogicContext)
rtsp.PubSession
func (*Group) OnTsPackets ¶ added in v0.24.1
hls.Muxer
func (*Group) StringifyDebugStats ¶
type HlsConfig ¶ added in v0.24.1
type HlsConfig struct { CommonHttpServerConfig UseMemoryAsDiskFlag bool `json:"use_memory_as_disk_flag"` HttpReadFileFallback hls.ReadFileFallback `json:"-"` EventObserverConfig hls.MuxerEventObserver `json:"-"` hls.MuxerConfig }
type HttpApiConfig ¶ added in v0.24.1
type HttpApiServer ¶ added in v0.24.1
type HttpApiServer struct {
// contains filtered or unexported fields
}
func NewHttpApiServer ¶ added in v0.24.1
func NewHttpApiServer(addr string, observer HttpApiServerObserver) *HttpApiServer
func (*HttpApiServer) Listen ¶ added in v0.24.1
func (h *HttpApiServer) Listen() (err error)
func (*HttpApiServer) Runloop ¶ added in v0.24.1
func (h *HttpApiServer) Runloop() error
type HttpApiServerObserver ¶ added in v0.24.1
type HttpApiServerObserver interface { OnStatAllGroup() []base.StatGroup OnStatGroup(streamName string) *base.StatGroup OnCtrlStartPull(info base.ApiCtrlStartPullReq) OnCtrlKickOutSession(info base.ApiCtrlKickOutSession) base.HttpResponseBasic }
type HttpNotify ¶ added in v0.24.1
type HttpNotify struct {
// contains filtered or unexported fields
}
func (*HttpNotify) OnPubStart ¶ added in v0.24.1
func (h *HttpNotify) OnPubStart(info base.PubStartInfo)
func (*HttpNotify) OnPubStop ¶ added in v0.24.1
func (h *HttpNotify) OnPubStop(info base.PubStopInfo)
func (*HttpNotify) OnRtmpConnect ¶ added in v0.24.1
func (h *HttpNotify) OnRtmpConnect(info base.RtmpConnectInfo)
func (*HttpNotify) OnServerStart ¶ added in v0.24.1
func (h *HttpNotify) OnServerStart()
注意,这里的函数命名以On开头并不是因为是回调函数,而是notify给业务方的接口叫做on_server_start
func (*HttpNotify) OnSubStart ¶ added in v0.24.1
func (h *HttpNotify) OnSubStart(info base.SubStartInfo)
func (*HttpNotify) OnSubStop ¶ added in v0.24.1
func (h *HttpNotify) OnSubStop(info base.SubStopInfo)
func (*HttpNotify) OnUpdate ¶ added in v0.24.1
func (h *HttpNotify) OnUpdate(info base.UpdateInfo)
func (*HttpNotify) RunLoop ¶ added in v0.24.1
func (h *HttpNotify) RunLoop()
type HttpNotifyConfig ¶ added in v0.24.1
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 HttpServerHandler ¶ added in v0.24.1
type HttpServerHandler struct {
// contains filtered or unexported fields
}
func NewHttpServerHandler ¶ added in v0.24.1
func NewHttpServerHandler(observer HttpServerHandlerObserver) *HttpServerHandler
func (*HttpServerHandler) ServeSubSession ¶ added in v0.24.1
func (h *HttpServerHandler) ServeSubSession(writer http.ResponseWriter, req *http.Request)
type HttpServerHandlerObserver ¶ added in v0.24.1
type HttpServerHandlerObserver interface { // 通知上层有新的拉流者 // 返回值: true则允许拉流,false则关闭连接 OnNewHttpflvSubSession(session *httpflv.SubSession) bool OnDelHttpflvSubSession(session *httpflv.SubSession) OnNewHttptsSubSession(session *httpts.SubSession) bool OnDelHttptsSubSession(session *httpts.SubSession) }
type HttpflvConfig ¶ added in v0.24.1
type HttpflvConfig struct { CommonHttpServerConfig GopNum int `json:"gop_num"` }
type HttptsConfig ¶ added in v0.24.1
type HttptsConfig struct {
CommonHttpServerConfig
}
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 ¶ added in v0.24.1
type LazyRtmpMsg2FlvTag struct {
// contains filtered or unexported fields
}
懒转换
func (*LazyRtmpMsg2FlvTag) Get ¶ added in v0.24.1
func (l *LazyRtmpMsg2FlvTag) Get() []byte
func (*LazyRtmpMsg2FlvTag) Init ¶ added in v0.24.1
func (l *LazyRtmpMsg2FlvTag) Init(msg base.RtmpMsg)
type PprofConfig ¶ added in v0.24.1
type RecordConfig ¶ added in v0.19.12
type RelayPullConfig ¶
type RelayPushConfig ¶
type RtmpConfig ¶ added in v0.24.1
type RtspConfig ¶ added in v0.24.1
type ServerManager ¶
type ServerManager struct {
// contains filtered or unexported fields
}
func NewServerManager ¶
func NewServerManager() *ServerManager
func NewStandaloneServerManager ¶ added in v0.24.2
func NewStandaloneServerManager(config *Config) *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 ¶ added in v0.24.1
func (sm *ServerManager) OnDelHttpflvSubSession(session *httpflv.SubSession)
ServerObserver of httpflv.Server
func (*ServerManager) OnDelHttptsSubSession ¶ added in v0.24.1
func (sm *ServerManager) OnDelHttptsSubSession(session *httpts.SubSession)
ServerObserver of httpts.Server
func (*ServerManager) OnDelRtmpPubSession ¶ added in v0.24.1
func (sm *ServerManager) OnDelRtmpPubSession(session *rtmp.ServerSession)
ServerObserver of rtmp.Server
func (*ServerManager) OnDelRtmpSubSession ¶ added in v0.24.1
func (sm *ServerManager) OnDelRtmpSubSession(session *rtmp.ServerSession)
ServerObserver of rtmp.Server
func (*ServerManager) OnDelRtspPubSession ¶ added in v0.24.1
func (sm *ServerManager) OnDelRtspPubSession(session *rtsp.PubSession)
ServerObserver of rtsp.Server
func (*ServerManager) OnDelRtspSession ¶ added in v0.24.1
func (sm *ServerManager) OnDelRtspSession(session *rtsp.ServerCommandSession)
ServerObserver of rtsp.Server
func (*ServerManager) OnDelRtspSubSession ¶ added in v0.24.1
func (sm *ServerManager) OnDelRtspSubSession(session *rtsp.SubSession)
ServerObserver of rtsp.Server
func (*ServerManager) OnNewHttpflvSubSession ¶ added in v0.24.1
func (sm *ServerManager) OnNewHttpflvSubSession(session *httpflv.SubSession) bool
ServerObserver of httpflv.Server
func (*ServerManager) OnNewHttptsSubSession ¶ added in v0.24.1
func (sm *ServerManager) OnNewHttptsSubSession(session *httpts.SubSession) bool
ServerObserver of httpts.Server
func (*ServerManager) OnNewRtmpPubSession ¶ added in v0.24.1
func (sm *ServerManager) OnNewRtmpPubSession(session *rtmp.ServerSession) bool
ServerObserver of rtmp.Server
func (*ServerManager) OnNewRtmpSubSession ¶ added in v0.24.1
func (sm *ServerManager) OnNewRtmpSubSession(session *rtmp.ServerSession) bool
ServerObserver of rtmp.Server
func (*ServerManager) OnNewRtspPubSession ¶ added in v0.24.1
func (sm *ServerManager) OnNewRtspPubSession(session *rtsp.PubSession) bool
ServerObserver of rtsp.Server
func (*ServerManager) OnNewRtspSessionConnect ¶ added in v0.24.1
func (sm *ServerManager) OnNewRtspSessionConnect(session *rtsp.ServerCommandSession)
ServerObserver of rtsp.Server
func (*ServerManager) OnNewRtspSubSessionDescribe ¶ added in v0.24.1
func (sm *ServerManager) OnNewRtspSubSessionDescribe(session *rtsp.SubSession) (ok bool, sdp []byte)
ServerObserver of rtsp.Server
func (*ServerManager) OnNewRtspSubSessionPlay ¶ added in v0.24.1
func (sm *ServerManager) OnNewRtspSubSessionPlay(session *rtsp.SubSession) bool
ServerObserver of rtsp.Server
func (*ServerManager) OnRtmpConnect ¶ added in v0.24.1
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() error