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: 名称
|
name: 名称
|
||||||
state: 状态
|
state: 状态
|
||||||
initialize: 初始化
|
initialize: 初始化
|
||||||
|
"no tracks": 没有轨道
|
||||||
"start read": 开始读取
|
"start read": 开始读取
|
||||||
"start pull": 开始从远端拉流
|
"start pull": 开始从远端拉流
|
||||||
"stop pull": 停止从远端拉流
|
"stop pull": 停止从远端拉流
|
||||||
|
15
stream.go
15
stream.go
@@ -266,14 +266,15 @@ func (s *Stream) SetIDR(video common.Track) {
|
|||||||
}
|
}
|
||||||
func findOrCreateStream(streamPath string, waitTimeout time.Duration) (s *Stream, created bool) {
|
func findOrCreateStream(streamPath string, waitTimeout time.Duration) (s *Stream, created bool) {
|
||||||
p := strings.Split(streamPath, "/")
|
p := strings.Split(streamPath, "/")
|
||||||
if len(p) < 2 {
|
pl := len(p)
|
||||||
|
if pl < 2 {
|
||||||
log.Warn(Red("Stream Path Format Error:"), streamPath)
|
log.Warn(Red("Stream Path Format Error:"), streamPath)
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
actual, loaded := Streams.LoadOrStore(streamPath, &Stream{
|
actual, loaded := Streams.LoadOrStore(streamPath, &Stream{
|
||||||
Path: streamPath,
|
Path: streamPath,
|
||||||
AppName: p[0],
|
AppName: strings.Join(p[1:pl-1], "/"),
|
||||||
StreamName: strings.Join(p[1:], "/"),
|
StreamName: p[pl-1],
|
||||||
StartTime: time.Now(),
|
StartTime: time.Now(),
|
||||||
timeout: time.NewTimer(waitTimeout),
|
timeout: time.NewTimer(waitTimeout),
|
||||||
})
|
})
|
||||||
@@ -484,8 +485,10 @@ func (s *Stream) run() {
|
|||||||
if !lost {
|
if !lost {
|
||||||
if trackCount == 0 {
|
if trackCount == 0 {
|
||||||
s.Warn("no tracks")
|
s.Warn("no tracks")
|
||||||
lost = true
|
if time.Since(s.StartTime) > timeout {
|
||||||
s.action(ACTION_CLOSE)
|
lost = true
|
||||||
|
s.action(ACTION_CLOSE)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
} else if s.Publisher != nil && s.Publisher.IsClosed() {
|
} 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)))
|
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 // 需要踢掉老的发布者
|
needKick := !republish && oldPuber != nil && conf.KickExist // 需要踢掉老的发布者
|
||||||
if needKick {
|
if needKick {
|
||||||
s.Warn("kick", zap.String("old type", oldPuber.Type))
|
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.Publisher = v.Value
|
||||||
s.PublishTimeout = conf.PublishTimeout
|
s.PublishTimeout = conf.PublishTimeout
|
||||||
|
Reference in New Issue
Block a user