Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Sources/YouTubeKit/Models/Codecs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
//

import Foundation
#if canImport(VideoToolbox)
import VideoToolbox
#endif

protocol Codec: Sendable {
associatedtype BaseCodec where BaseCodec: Equatable
Expand Down Expand Up @@ -61,7 +64,7 @@ public enum VideoCodec: Codec {
public var isNativelyPlayable: Bool {
switch self {
case .mp4v(_): return true
case .av1(_): return false
case .av1(_): return Self.isAV1HardwareDecodeSupported
#if os(watchOS)
case .avc1(let version):
if version == "64002A" {
Expand All @@ -75,7 +78,16 @@ public enum VideoCodec: Codec {
case .unknown(_): return false
}
}


private static let isAV1HardwareDecodeSupported: Bool = {
#if canImport(VideoToolbox) && !os(watchOS)
if #available(iOS 13.0, macOS 10.15, tvOS 13.0, *) {
return VTIsHardwareDecodeSupported(kCMVideoCodecType_AV1)
}
#endif
return false
}()

}

// MARK: - Audio Codec
Expand Down