Has anyone figured this out.
It seems replaykit 2 always delevers frames at a fixed resolution of 886 x 1918
I've tried various solutions to rotate the screen but so far none work.
Using the code below crashes in the rotate step
vImageRotate90_ARGB8888(&srcBuffer, &destBuffer, factor, &color, vImage_Flags(0))
let flags = CVPixelBufferLockFlags(rawValue: 0)
guard kCVReturnSuccess == CVPixelBufferLockBaseAddress(srcPixelBuffer, flags) else {
return nil
}
defer { CVPixelBufferUnlockBaseAddress(srcPixelBuffer, flags) }
guard let srcData = CVPixelBufferGetBaseAddress(srcPixelBuffer) else {
print("Error: could not get pixel buffer base address")
return nil
}
let sourceWidth = CVPixelBufferGetWidth(srcPixelBuffer)
let sourceHeight = CVPixelBufferGetHeight(srcPixelBuffer)
var destWidth = sourceHeight
var destHeight = sourceWidth
var color = UInt8(0)
if factor % 2 == 0 {
destWidth = sourceWidth
destHeight = sourceHeight
}
let srcBytesPerRow = CVPixelBufferGetBytesPerRow(srcPixelBuffer)
var srcBuffer = vImage_Buffer(data: srcData,
height: vImagePixelCount(sourceHeight),
width: vImagePixelCount(sourceWidth),
rowBytes: srcBytesPerRow)
let destBytesPerRow = destWidth*4
guard let destData = malloc(destHeight*destBytesPerRow) else {
print("Error: out of memory")
return nil
}
var destBuffer = vImage_Buffer(data: destData,
height: vImagePixelCount(destHeight),
width: vImagePixelCount(destWidth),
rowBytes: destBytesPerRow)
let error = vImageRotate90_ARGB8888(&srcBuffer, &destBuffer, factor, &color, vImage_Flags(0))
if error != kvImageNoError {
print("Error:", error)
free(destData)