TotalCaptureResult.java revision 7a316f6b1b040f0113161db87a36397aebfb80b8
1/* 2 * Copyright (C) 2014 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 17package android.hardware.camera2; 18 19import android.hardware.camera2.impl.CameraMetadataNative; 20import android.hardware.camera2.impl.CaptureResultExtras; 21 22import java.util.ArrayList; 23import java.util.Collections; 24import java.util.List; 25 26/** 27 * <p>The total assembled results of a single image capture from the image sensor.</p> 28 * 29 * <p>Contains the final configuration for the capture hardware (sensor, lens, 30 * flash), the processing pipeline, the control algorithms, and the output 31 * buffers.</p> 32 * 33 * <p>A {@code TotalCaptureResult} is produced by a {@link CameraDevice} after processing a 34 * {@link CaptureRequest}. All properties listed for capture requests can also 35 * be queried on the capture result, to determine the final values used for 36 * capture. The result also includes additional metadata about the state of the 37 * camera device during the capture.</p> 38 * 39 * <p>All properties returned by {@link CameraCharacteristics#getAvailableCaptureResultKeys()} 40 * are available (that is {@link CaptureResult#get} will return non-{@code null}, if and only if 41 * that key that was enabled by the request. A few keys such as 42 * {@link CaptureResult#STATISTICS_FACES} are disabled by default unless enabled with a switch (such 43 * as {@link CaptureRequest#STATISTICS_FACE_DETECT_MODE}). Refer to each key documentation on 44 * a case-by-case basis.</p> 45 * 46 * <p>{@link TotalCaptureResult} objects are immutable.</p> 47 * 48 * @see CameraDevice.CaptureCallback#onCaptureCompleted 49 */ 50public final class TotalCaptureResult extends CaptureResult { 51 52 private final List<CaptureResult> mPartialResults; 53 private final int mSessionId; 54 55 /** 56 * Takes ownership of the passed-in camera metadata and the partial results 57 * 58 * @param partials a list of partial results; {@code null} will be substituted for an empty list 59 * @hide 60 */ 61 public TotalCaptureResult(CameraMetadataNative results, CaptureRequest parent, 62 CaptureResultExtras extras, List<CaptureResult> partials, int sessionId) { 63 super(results, parent, extras); 64 65 if (partials == null) { 66 mPartialResults = new ArrayList<>(); 67 } else { 68 mPartialResults = partials; 69 } 70 71 mSessionId = sessionId; 72 } 73 74 /** 75 * Creates a request-less result. 76 * 77 * <p><strong>For testing only.</strong></p> 78 * @hide 79 */ 80 public TotalCaptureResult(CameraMetadataNative results, int sequenceId) { 81 super(results, sequenceId); 82 83 mPartialResults = new ArrayList<>(); 84 mSessionId = CameraCaptureSession.SESSION_ID_NONE; 85 } 86 87 /** 88 * Get the read-only list of partial results that compose this total result. 89 * 90 * <p>The list is returned is unmodifiable; attempting to modify it will result in a 91 * {@code UnsupportedOperationException} being thrown.</p> 92 * 93 * <p>The list size will be inclusive between {@code 0} and 94 * {@link CameraCharacteristics#REQUEST_PARTIAL_RESULT_COUNT}, with elements in ascending order 95 * of when {@link CameraCaptureSession.CaptureCallback#onCaptureProgressed} was invoked.</p> 96 * 97 * @return unmodifiable list of partial results 98 */ 99 public List<CaptureResult> getPartialResults() { 100 return Collections.unmodifiableList(mPartialResults); 101 } 102 103 /** 104 * Get the ID of the session where the capture request of this result was submitted. 105 * 106 * @return The session ID 107 * @hide 108 */ 109 public int getSessionId() { 110 return mSessionId; 111 } 112} 113