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
54    /**
55     * Takes ownership of the passed-in camera metadata and the partial results
56     *
57     * @param partials a list of partial results; {@code null} will be substituted for an empty list
58     * @hide
59     */
60    public TotalCaptureResult(CameraMetadataNative results, CaptureRequest parent,
61            CaptureResultExtras extras, List<CaptureResult> partials) {
62        super(results, parent, extras);
63
64        if (partials == null) {
65            mPartialResults = new ArrayList<>();
66        } else {
67            mPartialResults = partials;
68        }
69    }
70
71    /**
72     * Creates a request-less result.
73     *
74     * <p><strong>For testing only.</strong></p>
75     * @hide
76     */
77    public TotalCaptureResult(CameraMetadataNative results, int sequenceId) {
78        super(results, sequenceId);
79
80        mPartialResults = new ArrayList<>();
81    }
82
83    /**
84     * Get the read-only list of partial results that compose this total result.
85     *
86     * <p>The list is returned is unmodifiable; attempting to modify it will result in a
87     * {@code UnsupportedOperationException} being thrown.</p>
88     *
89     * <p>The list size will be inclusive between {@code 0} and
90     * {@link CameraCharacteristics#REQUEST_PARTIAL_RESULT_COUNT}, with elements in ascending order
91     * of when {@link CameraCaptureSession.CaptureCallback#onCaptureProgressed} was invoked.</p>
92     *
93     * @return unmodifiable list of partial results
94     */
95    public List<CaptureResult> getPartialResults() {
96        return Collections.unmodifiableList(mPartialResults);
97    }
98}
99