Skip to content

Commit

Permalink
hls: fix 404 error when hlsAlwaysRemux and sourceOnDemand are both tr…
Browse files Browse the repository at this point in the history
…ue (#1818) (#1834)
  • Loading branch information
aler9 authored May 18, 2023
1 parent 6cb7572 commit 6e5f87f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
20 changes: 8 additions & 12 deletions internal/core/hls_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,17 @@ outer:
for {
select {
case pa := <-m.chPathSourceReady:
if m.alwaysRemux {
m.createMuxer(pa.name, "")
if m.alwaysRemux && !pa.conf.SourceOnDemand {
if _, ok := m.muxers[pa.name]; !ok {
m.createMuxer(pa.name, "")
}
}

case pa := <-m.chPathSourceNotReady:
if m.alwaysRemux {
c, ok := m.muxers[pa.name]
if ok {
c.close()
delete(m.muxers, pa.name)
}
c, ok := m.muxers[pa.name]
if ok && c.remoteAddr == "" { // created with "always remux"
c.close()
delete(m.muxers, pa.name)
}

case req := <-m.chHandleRequest:
Expand All @@ -178,9 +178,6 @@ outer:
case ok:
r.processRequest(&req)

case m.alwaysRemux:
req.res <- nil

default:
r := m.createMuxer(req.path, req.ctx.ClientIP())
r.processRequest(&req)
Expand Down Expand Up @@ -239,7 +236,6 @@ func (m *hlsManager) createMuxer(pathName string, remoteAddr string) *hlsMuxer {
m.ctx,
remoteAddr,
m.externalAuthenticationURL,
m.alwaysRemux,
m.variant,
m.segmentCount,
m.segmentDuration,
Expand Down
5 changes: 1 addition & 4 deletions internal/core/hls_muxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ type hlsMuxerParent interface {
type hlsMuxer struct {
remoteAddr string
externalAuthenticationURL string
alwaysRemux bool
variant conf.HLSVariant
segmentCount int
segmentDuration conf.StringDuration
Expand Down Expand Up @@ -91,7 +90,6 @@ func newHLSMuxer(
parentCtx context.Context,
remoteAddr string,
externalAuthenticationURL string,
alwaysRemux bool,
variant conf.HLSVariant,
segmentCount int,
segmentDuration conf.StringDuration,
Expand All @@ -109,7 +107,6 @@ func newHLSMuxer(
m := &hlsMuxer{
remoteAddr: remoteAddr,
externalAuthenticationURL: externalAuthenticationURL,
alwaysRemux: alwaysRemux,
variant: variant,
segmentCount: segmentCount,
segmentDuration: segmentDuration,
Expand Down Expand Up @@ -210,7 +207,7 @@ func (m *hlsMuxer) run() {
case err := <-innerErr:
innerCtxCancel()

if m.alwaysRemux {
if m.remoteAddr == "" { // created with "always remux"
m.Log(logger.Info, "ERR: %v", err)
m.clearQueuedRequests()
isReady = false
Expand Down

0 comments on commit 6e5f87f

Please sign in to comment.