Merge pull request #775 from stonerl/fix-crash-on-hls-live-playback

This commit is contained in:
Arkadiusz Fal 2024-08-31 14:54:08 +02:00 committed by GitHub
commit e9f502a486
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -153,7 +153,8 @@ extension PlayerBackend {
// Filter out non-HLS streams and streams with resolution more than maxResolution
let nonHLSStreams = streams.filter {
let isHLS = $0.kind == .hls
let isWithinResolution = $0.resolution <= maxResolution.value
// Safely unwrap resolution and maxResolution.value to avoid crashes
let isWithinResolution = ($0.resolution != nil && maxResolution.value != nil) ? $0.resolution! <= maxResolution.value! : false
logger.info("Stream ID: \($0.id) - Kind: \(String(describing: $0.kind)) - Resolution: \(String(describing: $0.resolution)) - Bitrate: \($0.bitrate ?? 0)")
logger.info("Is HLS: \(isHLS), Is within resolution: \(isWithinResolution)")
return !isHLS && isWithinResolution
@ -187,7 +188,8 @@ extension PlayerBackend {
}
let filteredStreams = adjustedStreams.filter { stream in
let isWithinResolution = stream.resolution <= maxResolution.value
// Safely unwrap resolution and maxResolution.value to avoid crashes
let isWithinResolution = (stream.resolution != nil && maxResolution.value != nil) ? stream.resolution! <= maxResolution.value! : false
logger.info("Filtered stream ID: \(stream.id) - Is within max resolution: \(isWithinResolution)")
return isWithinResolution
}