Il relay verso YouTube ora gestisce _air senza traccia audio, ritenta activate_broadcast finché l'ingest è active e riduce la finestra scheduledStartTime a ~20s. Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
912 B
Ruby
28 lines
912 B
Ruby
class YoutubeBroadcastActivateJob < ApplicationJob
|
|
queue_as :default
|
|
|
|
MAX_ATTEMPTS = 36
|
|
RETRY_WAIT = 10.seconds
|
|
class << self
|
|
def schedule_with_retries(session_id, attempt: 1)
|
|
set(wait: attempt == 1 ? 8.seconds : RETRY_WAIT).perform_later(session_id, attempt)
|
|
end
|
|
end
|
|
|
|
def perform(session_id, attempt = 1)
|
|
session = StreamSession.find_by(id: session_id)
|
|
return unless session&.platform == "youtube"
|
|
return if session.terminal?
|
|
return if session.youtube_broadcast_id.blank?
|
|
return unless Streams::YoutubeRelay.running?(session.id)
|
|
|
|
result = Youtube::BroadcastService.new(session.match.team).activate_broadcast!(session.youtube_broadcast_id)
|
|
return if result == :live || result == :transitioned
|
|
|
|
return unless result == :waiting_ingest
|
|
return if attempt >= MAX_ATTEMPTS
|
|
|
|
self.class.schedule_with_retries(session_id, attempt: attempt + 1)
|
|
end
|
|
end
|