mirror of
https://github.com/HaishinKit/HaishinKit.swift.git
synced 2026-05-07 20:12:28 +00:00
33 lines
944 B
Swift
33 lines
944 B
Swift
import CoreImage
|
|
import CoreMedia
|
|
|
|
extension CMVideoFormatDescription {
|
|
var configurationBox: Data? {
|
|
guard let atoms = CMFormatDescriptionGetExtension(self, extensionKey: kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms) as? NSDictionary else {
|
|
return nil
|
|
}
|
|
switch mediaSubType {
|
|
case .h264:
|
|
return atoms["avcC"] as? Data
|
|
case .hevc:
|
|
return atoms["hvcC"] as? Data
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func makeDecodeConfigurtionRecord() -> (any DecoderConfigurationRecord)? {
|
|
guard let configurationBox else {
|
|
return nil
|
|
}
|
|
switch mediaSubType {
|
|
case .h264:
|
|
return AVCDecoderConfigurationRecord(data: configurationBox)
|
|
case .hevc:
|
|
return HEVCDecoderConfigurationRecord(data: configurationBox)
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
}
|