log common encoder errors

- log err when encoder prepare fails
- log err when encode failed due to parameter err
This commit is contained in:
Troy Lamerton 2020-02-02 11:34:00 +01:00
parent 75c0d18b37
commit c369fe0c79
1 changed files with 8 additions and 0 deletions

View File

@ -199,6 +199,10 @@ public final class H264Encoder {
guard
let refcon: UnsafeMutableRawPointer = outputCallbackRefCon,
let sampleBuffer: CMSampleBuffer = sampleBuffer, status == noErr else {
if status == kVTParameterErr {
// on iphone 11 with size=1792x827 this occurs
logger.error("encoding failed with kVTParameterErr. Perhaps the width x height is too big for the encoder setup?")
}
return
}
let encoder: H264Encoder = Unmanaged<H264Encoder>.fromOpaque(refcon).takeUnretainedValue()
@ -228,6 +232,10 @@ public final class H264Encoder {
invalidateSession = false
status = VTSessionSetProperties(_session!, propertyDictionary: properties as CFDictionary)
status = VTCompressionSessionPrepareToEncodeFrames(_session!)
guard status == noErr else {
logger.error("setup failed VTCompressionSessionPrepareToEncodeFrames. Size = \(width)x\(height)")
return nil
}
}
return _session
}