fix: push proxy push on publish

This commit is contained in:
langhuihui
2025-02-26 15:25:58 +08:00
parent 7a7b77d2b4
commit d92d3b5820
3 changed files with 23 additions and 5 deletions

View File

@@ -197,9 +197,7 @@ func (p *Publisher) Start() (err error) {
s.Waiting.WakeUp(p.StreamPath, p)
p.processAliasOnStart()
for plugin := range s.Plugins.Range {
plugin.OnPublish(p)
}
p.Plugin.Server.OnPublish(p)
//s.Transforms.PublishEvent <- p
p.AddTask(&PublishTimeout{Publisher: p})
if p.PublishTimeout > 0 {

View File

@@ -108,8 +108,17 @@ func (d *PushProxy) ChangeStatus(status byte) {
d.Update()
switch status {
case PushProxyStatusOnline:
if d.PushOnStart && from == PushProxyStatusOffline {
d.Handler.Push()
if from == PushProxyStatusOffline {
if d.PushOnStart {
d.Handler.Push()
} else {
d.server.Streams.Call(func() error {
if d.server.Streams.Has(d.GetStreamPath()) {
d.Handler.Push()
}
return nil
})
}
}
}
}

View File

@@ -569,6 +569,17 @@ func (s *Server) Dispose() {
}
}
func (s *Server) OnPublish(p *Publisher) {
for plugin := range s.Plugins.Range {
plugin.OnPublish(p)
}
for pushProxy := range s.PushProxies.Range {
if pushProxy.Status == PushProxyStatusOnline && pushProxy.GetStreamPath() == p.StreamPath && !pushProxy.PushOnStart {
pushProxy.Handler.Push()
}
}
}
func (s *Server) OnSubscribe(streamPath string, args url.Values) {
for plugin := range s.Plugins.Range {
plugin.OnSubscribe(streamPath, args)