Browse Source

hls: fix 404 error when hlsAlwaysRemux and sourceOnDemand are both true (#1818) (#1834)

pull/1835/head
Alessandro Ros 3 years ago committed by GitHub
parent
commit
6e5f87f65e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      internal/core/hls_manager.go
  2. 5
      internal/core/hls_muxer.go

20
internal/core/hls_manager.go

@ -159,17 +159,17 @@ outer:
for { for {
select { select {
case pa := <-m.chPathSourceReady: case pa := <-m.chPathSourceReady:
if m.alwaysRemux { if m.alwaysRemux && !pa.conf.SourceOnDemand {
m.createMuxer(pa.name, "") if _, ok := m.muxers[pa.name]; !ok {
m.createMuxer(pa.name, "")
}
} }
case pa := <-m.chPathSourceNotReady: case pa := <-m.chPathSourceNotReady:
if m.alwaysRemux { c, ok := m.muxers[pa.name]
c, ok := m.muxers[pa.name] if ok && c.remoteAddr == "" { // created with "always remux"
if ok { c.close()
c.close() delete(m.muxers, pa.name)
delete(m.muxers, pa.name)
}
} }
case req := <-m.chHandleRequest: case req := <-m.chHandleRequest:
@ -178,9 +178,6 @@ outer:
case ok: case ok:
r.processRequest(&req) r.processRequest(&req)
case m.alwaysRemux:
req.res <- nil
default: default:
r := m.createMuxer(req.path, req.ctx.ClientIP()) r := m.createMuxer(req.path, req.ctx.ClientIP())
r.processRequest(&req) r.processRequest(&req)
@ -239,7 +236,6 @@ func (m *hlsManager) createMuxer(pathName string, remoteAddr string) *hlsMuxer {
m.ctx, m.ctx,
remoteAddr, remoteAddr,
m.externalAuthenticationURL, m.externalAuthenticationURL,
m.alwaysRemux,
m.variant, m.variant,
m.segmentCount, m.segmentCount,
m.segmentDuration, m.segmentDuration,

5
internal/core/hls_muxer.go

@ -60,7 +60,6 @@ type hlsMuxerParent interface {
type hlsMuxer struct { type hlsMuxer struct {
remoteAddr string remoteAddr string
externalAuthenticationURL string externalAuthenticationURL string
alwaysRemux bool
variant conf.HLSVariant variant conf.HLSVariant
segmentCount int segmentCount int
segmentDuration conf.StringDuration segmentDuration conf.StringDuration
@ -91,7 +90,6 @@ func newHLSMuxer(
parentCtx context.Context, parentCtx context.Context,
remoteAddr string, remoteAddr string,
externalAuthenticationURL string, externalAuthenticationURL string,
alwaysRemux bool,
variant conf.HLSVariant, variant conf.HLSVariant,
segmentCount int, segmentCount int,
segmentDuration conf.StringDuration, segmentDuration conf.StringDuration,
@ -109,7 +107,6 @@ func newHLSMuxer(
m := &hlsMuxer{ m := &hlsMuxer{
remoteAddr: remoteAddr, remoteAddr: remoteAddr,
externalAuthenticationURL: externalAuthenticationURL, externalAuthenticationURL: externalAuthenticationURL,
alwaysRemux: alwaysRemux,
variant: variant, variant: variant,
segmentCount: segmentCount, segmentCount: segmentCount,
segmentDuration: segmentDuration, segmentDuration: segmentDuration,
@ -210,7 +207,7 @@ func (m *hlsMuxer) run() {
case err := <-innerErr: case err := <-innerErr:
innerCtxCancel() innerCtxCancel()
if m.alwaysRemux { if m.remoteAddr == "" { // created with "always remux"
m.Log(logger.Info, "ERR: %v", err) m.Log(logger.Info, "ERR: %v", err)
m.clearQueuedRequests() m.clearQueuedRequests()
isReady = false isReady = false

Loading…
Cancel
Save