Java Code Examples for com.android.camera.async.UpdatableCountDownLatch

Following code examples demonstrate how to use com.android.camera.async.UpdatableCountDownLatchfrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use com.android.camera.async.UpdatableCountDownLatchand various code implementation of this class.

    @Override
    public void run(Updatable<Void> imageExposureUpdatable, ImageSaver imageSaver) throws
            InterruptedException, CameraAccessException, CameraCaptureSessionClosedException,
            ResourceAcquisitionFailedException {
        try (FrameServer.Session session = mFrameServer.createExclusiveSession();
                ImageStream imageStream = mImageReader.createStream(1)) {
            UpdatableCountDownLatch<Void> exposureLatch = new UpdatableCountDownLatch<>(1);
            RequestBuilder photoRequest = mBuilderFactory.create(CameraDevice
                    .TEMPLATE_STILL_CAPTURE);
            photoRequest.addStream(imageStream);
            MetadataFuture metadataFuture = new MetadataFuture();
            photoRequest.addResponseListener(metadataFuture);
            photoRequest.addResponseListener(forFrameExposure(imageExposureUpdatable));
            photoRequest.addResponseListener(forFrameExposure(exposureLatch));
            session.submitRequest(Arrays.asList(photoRequest.build()),
                    FrameServer.RequestType.NON_REPEATING);

            exposureLatch.await();
            session.close();

            ImageProxy image = imageStream.getNext();
            imageSaver.addFullSizeImage(image, metadataFuture.getMetadata());
        } catch (BufferQueue.BufferQueueClosedException e) {
        } finally {
            imageSaver.close();
        }
    } 


Advertisement
Javadoc
Counts down on each update.
Advertisement