Corregge scadenza token regia oltre le 8h, tabellone HTML sulla pagina live, pulsanti pausa/ripresa in regia, link admin e broadcast ActionCable diretto. App Android: overlay branding, sync score da regia via WebSocket con reconnect e poll. Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
866 B
Ruby
30 lines
866 B
Ruby
module Sessions
|
|
# Sceglie il preset più alto supportato dall'upload misurato (test rete).
|
|
class SelectQuality
|
|
UPLOAD_HEADROOM = 0.8
|
|
|
|
PRESETS = [
|
|
{ id: "1080p_30_4.5mbps", target_bitrate: 4_500_000, target_fps: 30 },
|
|
{ id: "720p_30_4mbps", target_bitrate: 4_000_000, target_fps: 30 },
|
|
{ id: "720p_30_2.5mbps", target_bitrate: 2_500_000, target_fps: 30 },
|
|
{ id: "720p_30_1.5mbps", target_bitrate: 1_500_000, target_fps: 30 }
|
|
].freeze
|
|
|
|
def self.call(upload_mbps:)
|
|
new(upload_mbps: upload_mbps).call
|
|
end
|
|
|
|
def initialize(upload_mbps:)
|
|
@upload_mbps = upload_mbps.to_f
|
|
end
|
|
|
|
def call
|
|
PRESETS.find { |preset| upload_sufficient?(preset) } || PRESETS.last
|
|
end
|
|
|
|
def upload_sufficient?(preset)
|
|
@upload_mbps >= (preset[:target_bitrate] / 1_000_000.0 * UPLOAD_HEADROOM)
|
|
end
|
|
end
|
|
end
|