From 01941ed2e45345e8279625d0fdf94e72e0ff0e38 Mon Sep 17 00:00:00 2001 From: Deivid Soto Date: Fri, 8 May 2026 12:44:06 +0200 Subject: [PATCH] fix(streaming): allow HLS sessions when webrtc disabled OnWebRTCSession gated cfg.Download.WebRTC.Enabled before the transport=="hls" branch, so HLS sessions were rejected even though they only need ffmpeg + StreamServer (no WebRTC peer). Reorder: path validation first, then HLS branch, then WebRTC.Enabled gate (only for DataChannel transport). HLS now works without enabling [downloads.webrtc]. --- internal/cmd/daemon.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/internal/cmd/daemon.go b/internal/cmd/daemon.go index 17ad49b..c9e7fa8 100644 --- a/internal/cmd/daemon.go +++ b/internal/cmd/daemon.go @@ -424,10 +424,6 @@ func runDaemonStart() error { if webrtcRegistry.has(sess.SessionID) { return // already running } - if !cfg.Download.WebRTC.Enabled { - log.Printf("webrtc session %s rejected: webrtc disabled in config", agent.ShortID(sess.SessionID)) - return - } filePath := sess.FilePath if filePath == "" { log.Printf("webrtc session %s rejected: empty file path", agent.ShortID(sess.SessionID)) @@ -451,13 +447,10 @@ func runDaemonStart() error { filePath = found } - // Branch on transport: HLS sessions register with the StreamServer - // HLS registry and serve over HTTP; default ("" or "webrtc") runs - // the legacy DataChannel pipeline. + // Branch on transport: HLS sessions only need ffmpeg + StreamServer, + // not a WebRTC peer, so they must bypass the WebRTC.Enabled gate. + // Default ("" or "webrtc") runs the DataChannel pipeline and requires it. if strings.EqualFold(sess.Transport, "hls") { - if webrtcRegistry.has(sess.SessionID) { - return - } tcRuntime := buildTranscodeRuntime(ctx, cfg) if tcRuntime.FFmpegPath == "" || tcRuntime.FFprobePath == "" { log.Printf("[hls %s] rejected: ffmpeg/ffprobe unavailable", agent.ShortID(sess.SessionID)) @@ -484,6 +477,12 @@ func runDaemonStart() error { return } + // Non-HLS transport requires WebRTC peer support. + if !cfg.Download.WebRTC.Enabled { + log.Printf("webrtc session %s rejected: webrtc disabled in config", agent.ShortID(sess.SessionID)) + return + } + sessCtx, sessCancel := context.WithCancel(ctx) //nolint:gosec // G118 cancel stored in registry webrtcRegistry.add(sess.SessionID, sessCancel) go func() {