diff --git a/pkg/logic/group__.go b/pkg/logic/group__.go index a34e11d..658157e 100644 --- a/pkg/logic/group__.go +++ b/pkg/logic/group__.go @@ -146,18 +146,22 @@ func NewGroup(appName string, streamName string, config *Config, observer IGroup StreamName: streamName, AppName: appName, }, - exitChan: make(chan struct{}, 1), - rtmpSubSessionSet: make(map[*rtmp.ServerSession]struct{}), - httpflvSubSessionSet: make(map[*httpflv.SubSession]struct{}), - httptsSubSessionSet: make(map[*httpts.SubSession]struct{}), - rtspSubSessionSet: make(map[*rtsp.SubSession]struct{}), - waitRtspSubSessionSet: make(map[*rtsp.SubSession]struct{}), - hlsSubSessionSet: make(map[*hls.SubSession]struct{}), - rtmpGopCache: remux.NewGopCache("rtmp", uk, config.RtmpConfig.GopNum, config.RtmpConfig.SingleGopMaxFrameNum), - httpflvGopCache: remux.NewGopCache("httpflv", uk, config.HttpflvConfig.GopNum, config.HttpflvConfig.SingleGopMaxFrameNum), - httptsGopCache: remux.NewGopCacheMpegts(uk, config.HttptsConfig.GopNum, config.HttptsConfig.SingleGopMaxFrameNum), - psPubPrevInactiveCheckTick: -1, - hlsCalcSessionStatIntervalSec: uint32(config.HlsConfig.FragmentDurationMs/100), + exitChan: make(chan struct{}, 1), + rtmpSubSessionSet: make(map[*rtmp.ServerSession]struct{}), + httpflvSubSessionSet: make(map[*httpflv.SubSession]struct{}), + httptsSubSessionSet: make(map[*httpts.SubSession]struct{}), + rtspSubSessionSet: make(map[*rtsp.SubSession]struct{}), + waitRtspSubSessionSet: make(map[*rtsp.SubSession]struct{}), + hlsSubSessionSet: make(map[*hls.SubSession]struct{}), + rtmpGopCache: remux.NewGopCache("rtmp", uk, config.RtmpConfig.GopNum, config.RtmpConfig.SingleGopMaxFrameNum), + httpflvGopCache: remux.NewGopCache("httpflv", uk, config.HttpflvConfig.GopNum, config.HttpflvConfig.SingleGopMaxFrameNum), + httptsGopCache: remux.NewGopCacheMpegts(uk, config.HttptsConfig.GopNum, config.HttptsConfig.SingleGopMaxFrameNum), + psPubPrevInactiveCheckTick: -1, + } + + g.hlsCalcSessionStatIntervalSec = uint32(config.HlsConfig.FragmentDurationMs / 100) // equals to (ms/1000) * 10 + if g.hlsCalcSessionStatIntervalSec == 0 { + g.hlsCalcSessionStatIntervalSec = defaultHlsCalcSessionStatIntervalSec } g.initRelayPushByConfig() diff --git a/pkg/logic/var.go b/pkg/logic/var.go index f618ef5..011a53d 100644 --- a/pkg/logic/var.go +++ b/pkg/logic/var.go @@ -28,3 +28,7 @@ var ( // checkSessionAliveIntervalSec uint32 = 10 ) + +const ( + defaultHlsCalcSessionStatIntervalSec uint32 = 10 +)