Files
MatchLiveTv/native/ios/MatchLiveTv/Streaming/BroadcastOrientationPolicy.swift
T
Emiliano FrascaroandCursor 270bf680a4 Fix regia basket e stabilità diretta iOS.
La regia remota non va più in 500 su basket/timed; iOS gestisce chiusura set, riconnessione RTMP e avanzamento quarti in modo affidabile.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-20 12:30:34 +02:00

32 lines
1.2 KiB
Swift

import AVFoundation
import UIKit
/// Regole orientamento in diretta (allineate al debounce Android).
enum BroadcastOrientationPolicy {
/// Attesa prima di applicare rotazione al mixer (evita burst da giro iPad).
static let debounceNanoseconds: UInt64 = 350_000_000
/// Finestra in cui ignorare `closed` RTMP dopo rotazione encoder.
static var suppressDisconnectSeconds: TimeInterval {
UIDevice.current.userInterfaceIdiom == .pad ? 2.5 : 1.0
}
static func shouldApplyMixerOrientation(
new: AVCaptureVideoOrientation,
previous: AVCaptureVideoOrientation?,
landscapeLocked: Bool
) -> Bool {
guard isApplicableForBroadcast(new, landscapeLocked: landscapeLocked) else { return false }
guard let previous else { return true }
return new != previous
}
/// In diretta landscape ignoriamo portrait/unknown: evita glitch quando il sensore passa da verticale.
static func isApplicableForBroadcast(
_ orientation: AVCaptureVideoOrientation,
landscapeLocked: Bool
) -> Bool {
guard landscapeLocked else { return true }
return orientation == .landscapeLeft || orientation == .landscapeRight
}
}