I have an application written in Swift (for iOS) and I need to rewrite it for Android. I'd like to use the "new" Camera 2 API but I don't have much experience with it. I was hoping you could give me a little boost. Currently in the iOS project the following classes are being used:
let captureSession = AVCaptureSession()
let videoOutput = AVCaptureVideoDataOutput()
var captureDevice : AVCaptureDevice?
var previewLayer : AVCaptureVideoPreviewLayer?
Which classes are the corresponding ones when it comes to Android? I guess the CameraDevice class is basically going to be the AVCaptureDevice class and the CameraCaptureSession is going to be the AVCaptureSession one. What about you AVCaptureVideoDataOutput and AVCAptureVideoPreviewLayer ones? Thanks!
Having tried before to maintain the structure of an iOS app in Android, with a far simpler domain that Camera2, I would suggest it is probably more trouble than it is worth.
Android and iOS have some quite particular architectural patterns and you may find that you are really swimming against the tide in one if you try to match the structure of the other.
Camers2 in particular is really quite involved - I would take a look at the example on GitHub (like below) and use this as a starting point. However, take a good look at the issues list and questions tagged with Camera2 on Stack overflow as there are definitely still issues with it that you really don't want to rediscover yourself if you can avoid it: