diff --git a/openbis-ipad/source/objc/openBIS/ZXingObjC/client/ZXCapture.m b/openbis-ipad/source/objc/openBIS/ZXingObjC/client/ZXCapture.m index 1f4e6d9334122fbb67d75118d7e3c86b8cbe324c..67502b1cdf9d603b41d132c34e423805cf5d7bf2 100644 --- a/openbis-ipad/source/objc/openBIS/ZXingObjC/client/ZXCapture.m +++ b/openbis-ipad/source/objc/openBIS/ZXingObjC/client/ZXCapture.m @@ -161,7 +161,6 @@ static bool isIPad(); if (camera == self.front) { position = AVCaptureDevicePositionFront; } - for(unsigned int i=0; i < [devices count]; ++i) { ZXCaptureDevice *dev = [devices objectAtIndex:i]; if (dev.position == position) { @@ -248,6 +247,7 @@ static bool isIPad(); preset = AVCaptureSessionPresetMedium; } session.sessionPreset = preset; + }); [session addInput:input ZXQT(error:nil)]; } @@ -635,7 +635,7 @@ ZXAV(didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer) } - (int)front { - return 0; + return 1; } - (int)back { diff --git a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBBarcodeViewController.m b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBBarcodeViewController.m index 95daadd86eaf3cdeb9165619cc4ed48b56fcbd55..e261da9693290cb4da643be34945549ef008daa6 100644 --- a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBBarcodeViewController.m +++ b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBBarcodeViewController.m @@ -21,9 +21,15 @@ @interface CISDOBBarcodeViewController () @property (nonatomic, retain) ZXCapture* capture; +@property (nonatomic, retain) AVCaptureSession* cameraSession; +@property (nonatomic, retain) AVCaptureVideoPreviewLayer* previewLayer; +@property (nonatomic, retain) AVCaptureDevice *videoDevice; +@property (nonatomic, retain) AVCaptureDeviceInput *videoIn; + @property (nonatomic, retain) IBOutlet UILabel* decodedLabel; @property (nonatomic, retain) IBOutlet UIView* cameraView; + - (NSString*)displayForResult:(ZXResult*)result; @end @@ -53,6 +59,19 @@ #pragma mark - View Controller Methods - (void)viewWillAppear:(BOOL)animated { + /* + self.videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; + NSError *error; + self.videoIn = [AVCaptureDeviceInput deviceInputWithDevice:self.videoDevice error:&error]; + self.cameraSession = [[AVCaptureSession alloc] init]; + [self.cameraSession addInput:self.videoIn]; + self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.cameraSession]; + self.previewLayer.frame = CGRectMake(0.f, 0.f, 360.f, 360.f); + [self.previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill]; + + [self.cameraView.layer addSublayer: self.previewLayer]; + [self.cameraSession startRunning]; + */ [NSThread detachNewThreadSelector:@selector(loadBarcodeReader) toTarget:self withObject:nil]; [super viewWillAppear:animated]; } @@ -60,12 +79,17 @@ - (void)loadBarcodeReader { self.capture = [[ZXCapture alloc] init]; self.capture.delegate = self; - self.capture.rotation = 90.0f; + // self.capture.rotation = 90.0f; // Use the back camera - self.capture.camera = self.capture.back; + // self.capture.camera = self.capture.back; self.capture.layer.frame = CGRectMake(0.f, 0.f, 360.f, 360.f); + [self.cameraView.layer addSublayer: self.capture.layer]; + + + //[self.cameraSession stopRunning]; + //[self.previewLayer removeFromSuperlayer]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {