blob: 657745c80e913bfc67678481a10e0f089abb7347 [file] [log] [blame]
Igor Murashkindb075af2014-05-21 10:07:08 -07001/*
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
Eino-Ville Talvala8b905572015-05-14 15:43:01 -070019import android.annotation.NonNull;
Igor Murashkindb075af2014-05-21 10:07:08 -070020import android.hardware.camera2.impl.CameraMetadataNative;
Igor Murashkinbdf366c2014-07-25 16:54:20 -070021import android.hardware.camera2.impl.CaptureResultExtras;
Igor Murashkindb075af2014-05-21 10:07:08 -070022
Igor Murashkin1e854c52014-08-28 15:21:49 -070023import java.util.ArrayList;
Igor Murashkindb075af2014-05-21 10:07:08 -070024import java.util.Collections;
25import 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 Talvalafd887432014-09-04 13:07:40 -070049 * @see CameraDevice.CaptureCallback#onCaptureCompleted
Igor Murashkindb075af2014-05-21 10:07:08 -070050 */
51public final class TotalCaptureResult extends CaptureResult {
52
Igor Murashkin1e854c52014-08-28 15:21:49 -070053 private final List<CaptureResult> mPartialResults;
Chien-Yu Chen7a316f6b2015-04-13 14:31:45 -070054 private final int mSessionId;
Igor Murashkin1e854c52014-08-28 15:21:49 -070055
Igor Murashkindb075af2014-05-21 10:07:08 -070056 /**
Igor Murashkin1e854c52014-08-28 15:21:49 -070057 * 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 Murashkindb075af2014-05-21 10:07:08 -070060 * @hide
61 */
Igor Murashkinbdf366c2014-07-25 16:54:20 -070062 public TotalCaptureResult(CameraMetadataNative results, CaptureRequest parent,
Chien-Yu Chen7a316f6b2015-04-13 14:31:45 -070063 CaptureResultExtras extras, List<CaptureResult> partials, int sessionId) {
Igor Murashkinbdf366c2014-07-25 16:54:20 -070064 super(results, parent, extras);
Igor Murashkin1e854c52014-08-28 15:21:49 -070065
66 if (partials == null) {
67 mPartialResults = new ArrayList<>();
68 } else {
69 mPartialResults = partials;
70 }
Chien-Yu Chen7a316f6b2015-04-13 14:31:45 -070071
72 mSessionId = sessionId;
Igor Murashkindb075af2014-05-21 10:07:08 -070073 }
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 Murashkin1e854c52014-08-28 15:21:49 -070083
84 mPartialResults = new ArrayList<>();
Chien-Yu Chen7a316f6b2015-04-13 14:31:45 -070085 mSessionId = CameraCaptureSession.SESSION_ID_NONE;
Igor Murashkindb075af2014-05-21 10:07:08 -070086 }
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 Murashkin1e854c52014-08-28 15:21:49 -070094 * <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 Talvalafd887432014-09-04 13:07:40 -070096 * of when {@link CameraCaptureSession.CaptureCallback#onCaptureProgressed} was invoked.</p>
Igor Murashkindb075af2014-05-21 10:07:08 -070097 *
98 * @return unmodifiable list of partial results
99 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700100 @NonNull
Igor Murashkindb075af2014-05-21 10:07:08 -0700101 public List<CaptureResult> getPartialResults() {
Igor Murashkin1e854c52014-08-28 15:21:49 -0700102 return Collections.unmodifiableList(mPartialResults);
Igor Murashkindb075af2014-05-21 10:07:08 -0700103 }
Chien-Yu Chen7a316f6b2015-04-13 14:31:45 -0700104
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 Murashkindb075af2014-05-21 10:07:08 -0700114}