Files
MatchLiveTv/backend/app/services/streams/overlay/badge_label.rb
Emiliano Frascaro 854738b46d Stabilizza live YouTube/RTMP e fix crash rotazione mobile.
Pipeline YouTube con relay, overlay e publisher sync lato backend; fix GL pauseGlDuringRotation su Android per evitare crash in rotazione durante lo streaming Flutter.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 15:30:55 +02:00

50 lines
1.6 KiB
Ruby

module Streams
module Overlay
# Etichetta stato broadcast (stessa logica della pagina live / badge HTML).
class BadgeLabel
Result = Struct.new(:text, :background, :foreground, keyword_init: true)
def self.for(session)
new(session).call
end
def initialize(session)
@session = session
end
def call
return Result.new(text: "DIRETTA CHIUSA", background: "#374151", foreground: "#dddddd") if @session.terminal?
return Result.new(text: "IN PAUSA", background: "#455a64", foreground: "#ffffff") if @session.paused?
if Mediamtx::PublisherOnline.active?(@session) || (@session.live? && !@session.paused?)
return Result.new(text: "IN ONDA", background: "#2e7d32", foreground: "#ffffff")
end
if path_has_output?
if @session.reconnecting?
return Result.new(text: "RICONNESSIONE", background: "#f57c00", foreground: "#ffffff")
end
if @session.connecting?
return Result.new(text: "CONNECTING", background: "#f57c00", foreground: "#ffffff")
end
# Slate alwaysAvailable senza telefono: non bruciare «COPERTINA» su YouTube.
return Result.new(text: "IN ATTESA", background: "#455a64", foreground: "#ffffff")
end
Result.new(text: "IN ATTESA", background: "#455a64", foreground: "#ffffff")
end
private
def path_info
@path_info ||= Mediamtx::PublisherOnline.path_info(@session)
end
def path_has_output?
info = path_info
info && (info["ready"] || info["available"] || info["online"])
end
end
end
end