Files
MatchLiveTv/backend/app/services/streams/overlay.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

47 lines
1.2 KiB
Ruby

module Streams
module Overlay
module_function
def overlay_dir(session_id)
Rails.root.join("tmp/stream_overlays", session_id.to_s)
end
def overlay_png_path(session)
overlay_dir(session.id).join("overlay.png")
end
def overlay_pipe_path(session)
overlay_dir(session.id).join("overlay.pipe")
end
# Logo chiaro watermark (brand/logo-white-m.png → branding/ in deploy).
def brand_logo_path
candidates = [
Rails.root.join("branding/logo-white-m.png"),
Rails.root.join("brand/logo-white-m.png"),
Rails.root.join("public/logo-white.png"),
Rails.root.join("public/logo.png")
]
candidates.find(&:file?) || candidates.first
end
def badge_away_color(team)
club = team.club
candidate = club&.effective_secondary_color.presence || "#1565c0"
return candidate unless light_hex_color?(candidate)
"#1565c0"
end
def light_hex_color?(hex)
h = hex.to_s.delete_prefix("#")
return false unless h.match?(/\A\h{6}\z/i)
r = h[0..1].to_i(16)
g = h[2..3].to_i(16)
b = h[4..5].to_i(16)
(0.299 * r + 0.587 * g + 0.114 * b) > 200
end
end
end