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