mirror of
https://github.com/Monibuca/engine.git
synced 2025-09-27 04:46:03 +08:00
feat: wait publish tracks longger
This commit is contained in:
@@ -17,6 +17,7 @@ version: 版本
|
||||
name: 名称
|
||||
state: 状态
|
||||
initialize: 初始化
|
||||
"no tracks": 没有轨道
|
||||
"start read": 开始读取
|
||||
"start pull": 开始从远端拉流
|
||||
"stop pull": 停止从远端拉流
|
||||
|
11
stream.go
11
stream.go
@@ -266,14 +266,15 @@ func (s *Stream) SetIDR(video common.Track) {
|
||||
}
|
||||
func findOrCreateStream(streamPath string, waitTimeout time.Duration) (s *Stream, created bool) {
|
||||
p := strings.Split(streamPath, "/")
|
||||
if len(p) < 2 {
|
||||
pl := len(p)
|
||||
if pl < 2 {
|
||||
log.Warn(Red("Stream Path Format Error:"), streamPath)
|
||||
return nil, false
|
||||
}
|
||||
actual, loaded := Streams.LoadOrStore(streamPath, &Stream{
|
||||
Path: streamPath,
|
||||
AppName: p[0],
|
||||
StreamName: strings.Join(p[1:], "/"),
|
||||
AppName: strings.Join(p[1:pl-1], "/"),
|
||||
StreamName: p[pl-1],
|
||||
StartTime: time.Now(),
|
||||
timeout: time.NewTimer(waitTimeout),
|
||||
})
|
||||
@@ -484,8 +485,10 @@ func (s *Stream) run() {
|
||||
if !lost {
|
||||
if trackCount == 0 {
|
||||
s.Warn("no tracks")
|
||||
if time.Since(s.StartTime) > timeout {
|
||||
lost = true
|
||||
s.action(ACTION_CLOSE)
|
||||
}
|
||||
continue
|
||||
} else if s.Publisher != nil && s.Publisher.IsClosed() {
|
||||
s.Warn("publish is closed", zap.Error(context.Cause(s.publisher)), zap.String("ptr", fmt.Sprintf("%p", s.publisher.Context)))
|
||||
@@ -543,7 +546,7 @@ func (s *Stream) run() {
|
||||
needKick := !republish && oldPuber != nil && conf.KickExist // 需要踢掉老的发布者
|
||||
if needKick {
|
||||
s.Warn("kick", zap.String("old type", oldPuber.Type))
|
||||
s.Publisher.OnEvent(SEKick{CreateEvent[struct{}](util.Null)})
|
||||
s.Publisher.OnEvent(SEKick{CreateEvent(util.Null)})
|
||||
}
|
||||
s.Publisher = v.Value
|
||||
s.PublishTimeout = conf.PublishTimeout
|
||||
|
Reference in New Issue
Block a user