1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.camera.core.impl; 18 19 import android.hardware.camera2.CameraDevice; 20 import android.hardware.camera2.CaptureResult; 21 import android.hardware.camera2.TotalCaptureResult; 22 23 import androidx.camera.core.impl.CameraCaptureMetaData.AeMode; 24 import androidx.camera.core.impl.CameraCaptureMetaData.AeState; 25 import androidx.camera.core.impl.CameraCaptureMetaData.AfMode; 26 import androidx.camera.core.impl.CameraCaptureMetaData.AfState; 27 import androidx.camera.core.impl.CameraCaptureMetaData.AwbMode; 28 import androidx.camera.core.impl.CameraCaptureMetaData.AwbState; 29 import androidx.camera.core.impl.CameraCaptureMetaData.FlashState; 30 import androidx.camera.core.impl.utils.ExifData; 31 32 import org.jspecify.annotations.NonNull; 33 import org.jspecify.annotations.Nullable; 34 35 /** 36 * The result of a single image capture. 37 */ 38 public interface CameraCaptureResult { 39 40 /** Returns the current auto focus mode of operation. */ getAfMode()41 @NonNull AfMode getAfMode(); 42 43 /** Returns the current auto focus state. */ getAfState()44 @NonNull AfState getAfState(); 45 46 /** Returns the current auto exposure state. */ getAeState()47 @NonNull AeState getAeState(); 48 49 /** Returns the current auto white balance state. */ getAwbState()50 @NonNull AwbState getAwbState(); 51 52 /** Returns the current flash state. */ getFlashState()53 @NonNull FlashState getFlashState(); 54 55 /** Returns the current auto exposure mode. */ getAeMode()56 @NonNull AeMode getAeMode(); 57 58 /** Returns the current auto white balance mode. */ getAwbMode()59 @NonNull AwbMode getAwbMode(); 60 /** 61 * Returns the timestamp in nanoseconds. 62 * 63 * <p> If the timestamp was unavailable then it will return {@code -1L}. 64 */ getTimestamp()65 long getTimestamp(); 66 67 /** Returns the TagBundle object associated with the capture request. */ getTagBundle()68 @NonNull TagBundle getTagBundle(); 69 70 /** Populates the given Exif.Builder with attributes from this CameraCaptureResult. */ populateExifData(ExifData.@onNull Builder exifBuilder)71 default void populateExifData(ExifData.@NonNull Builder exifBuilder) { 72 exifBuilder.setFlashState(getFlashState()); 73 } 74 75 /** 76 * Returns the {@link CaptureResult} for reprocessable capture request. 77 * 78 * @return The {@link CaptureResult}. 79 * @see CameraDevice#createReprocessCaptureRequest(TotalCaptureResult) 80 */ getCaptureResult()81 default @Nullable CaptureResult getCaptureResult() { 82 return null; 83 } 84 85 /** An implementation of CameraCaptureResult which always return default results. */ 86 final class EmptyCameraCaptureResult implements CameraCaptureResult { 87 create()88 public static @NonNull CameraCaptureResult create() { 89 return new EmptyCameraCaptureResult(); 90 } 91 92 @Override getAfMode()93 public @NonNull AfMode getAfMode() { 94 return AfMode.UNKNOWN; 95 } 96 97 @Override getAfState()98 public @NonNull AfState getAfState() { 99 return AfState.UNKNOWN; 100 } 101 102 @Override getAeState()103 public @NonNull AeState getAeState() { 104 return AeState.UNKNOWN; 105 } 106 107 @Override getAwbState()108 public @NonNull AwbState getAwbState() { 109 return AwbState.UNKNOWN; 110 } 111 112 @Override getFlashState()113 public @NonNull FlashState getFlashState() { 114 return FlashState.UNKNOWN; 115 } 116 117 @Override getAeMode()118 public @NonNull AeMode getAeMode() { 119 return AeMode.UNKNOWN; 120 } 121 122 @Override getAwbMode()123 public @NonNull AwbMode getAwbMode() { 124 return AwbMode.UNKNOWN; 125 } 126 127 @Override getTimestamp()128 public long getTimestamp() { 129 return -1L; 130 } 131 132 @Override getTagBundle()133 public @NonNull TagBundle getTagBundle() { 134 return TagBundle.emptyBundle(); 135 } 136 137 @Override getCaptureResult()138 public @Nullable CaptureResult getCaptureResult() { 139 return null; 140 } 141 } 142 } 143