The documentation for AVCaptureDeviceRotationCoordinator says it is designed to work with any CALayer but it seems like it is designed to work only with AVCaptureVideoPreviewLayer. Can someone confirm it is possible to make it work with other layers such as CAMetalLayer or AVSampleBufferDisplayLayer?
AVCaptureDeviceRotationCoordinator for CAMetalLayer
Recommended
Hello @testinstadev,
it seems like it is designed to work only with AVCaptureVideoPreviewLayer
Was there some documentation that made you think that? It works with any CALayer type.
For example:
rotationCoordinator = AVCaptureDevice.RotationCoordinator(device: device, previewLayer: layer)
rotationCoordinator.publisher(for: \.videoRotationAngleForHorizonLevelPreview).sink { [self] degrees in
let radians = degrees * .pi / 180
displayLayer.setAffineTransform(CGAffineTransform(rotationAngle: radians))
}.store(in: &cancellables)
In that example, the displayLayer is an AVSampleBufferDisplayLayer, but it could be any layer type.
-- Greg