I'm currently building a very simple app that displays the iPad (front/rear) camera live stream
using AVCaptureVideoPreviewLayer.
I just want to duplicate the SAME live stream and display it
on a second view, Just Like Apple's Photo Booth app on the iPad (9 views of the same stream).
After several attempts, i now understand that two sessions won't help,
as one overrides the other.
My current approach is to create 2 AVCaptureVideoPreviewLayers and use the same AVCaptureSession.
But Still, not working.
This is my code:
rightLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
[rightLayer setBackgroundColor:[[UIColor redColor] CGColor]];
[rightLayer setVideoGravity:AVLayerVideoGravityResizeAspect];
leftLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
[leftLayer setBackgroundColor:[[UIColor blueColor] CGColor]];
[leftLayer setVideoGravity:AVLayerVideoGravityResizeAspect];
CALayer *rootLayer = [myView layer];
[rootLayer setMasksToBounds:YES];
[rightLayer setFrame:CGRectMake(512, 0, 512, 748)];
[leftLayer setFrame:CGRectMake(0, 0, 512, 748)];
[rootLayer addSublayer:rightLayer];
[rootLayer addSublayer:leftLayer];
[session startRunning];
When i run my app, only the left layer displays the live stream.
The weird thing is, i couldn't find a single tutorial/ piece of code about
Apple's Photo Booth app and how to achieve the same behaviour.
Help please...
Thanks