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#ifndef ANDROID_HARDWARE_CAPTURERESULT_H
18#define ANDROID_HARDWARE_CAPTURERESULT_H
19
20#include <utils/RefBase.h>
21#include <binder/Parcelable.h>
22#include <camera/CameraMetadata.h>
23
24
25namespace android {
26
27namespace hardware {
28namespace camera2 {
29namespace impl {
30
31/**
32 * CaptureResultExtras is a structure to encapsulate various indices for a capture result.
33 * These indices are framework-internal and not sent to the HAL.
34 */
35struct CaptureResultExtras : public android::Parcelable {
36    /**
37     * An integer to index the request sequence that this result belongs to.
38     */
39    int32_t requestId;
40
41    /**
42     * An integer to index this result inside a request sequence, starting from 0.
43     */
44    int32_t burstId;
45
46    /**
47     * TODO: Add documentation for this field.
48     */
49    int32_t afTriggerId;
50
51    /**
52     * TODO: Add documentation for this field.
53     */
54    int32_t precaptureTriggerId;
55
56    /**
57     * A 64bit integer to index the frame number associated with this result.
58     */
59    int64_t frameNumber;
60
61    /**
62     * The partial result count (index) for this capture result.
63     */
64    int32_t partialResultCount;
65
66    /**
67     * For buffer drop errors, the stream ID for the stream that lost a buffer.
68     * Otherwise -1.
69     */
70    int32_t errorStreamId;
71
72    /**
73     * Constructor initializes object as invalid by setting requestId to be -1.
74     */
75    CaptureResultExtras()
76        : requestId(-1),
77          burstId(0),
78          afTriggerId(0),
79          precaptureTriggerId(0),
80          frameNumber(0),
81          partialResultCount(0),
82          errorStreamId(-1) {
83    }
84
85    /**
86     * This function returns true if it's a valid CaptureResultExtras object.
87     * Otherwise, returns false. It is valid only when requestId is non-negative.
88     */
89    bool isValid();
90
91    virtual status_t                readFromParcel(const android::Parcel* parcel) override;
92    virtual status_t                writeToParcel(android::Parcel* parcel) const override;
93};
94
95struct PhysicalCaptureResultInfo : public android::Parcelable {
96
97    PhysicalCaptureResultInfo()
98        : mPhysicalCameraId(),
99          mPhysicalCameraMetadata() {
100    }
101    PhysicalCaptureResultInfo(const String16& cameraId,
102            const CameraMetadata& cameraMetadata)
103            : mPhysicalCameraId(cameraId),
104              mPhysicalCameraMetadata(cameraMetadata) {
105    }
106
107    String16  mPhysicalCameraId;
108    CameraMetadata mPhysicalCameraMetadata;
109
110    virtual status_t                readFromParcel(const android::Parcel* parcel) override;
111    virtual status_t                writeToParcel(android::Parcel* parcel) const override;
112};
113
114} // namespace impl
115} // namespace camera2
116} // namespace hardware
117
118using hardware::camera2::impl::CaptureResultExtras;
119using hardware::camera2::impl::PhysicalCaptureResultInfo;
120
121struct CaptureResult : public virtual LightRefBase<CaptureResult> {
122    CameraMetadata          mMetadata;
123    std::vector<PhysicalCaptureResultInfo> mPhysicalMetadatas;
124    CaptureResultExtras     mResultExtras;
125
126    CaptureResult();
127
128    CaptureResult(const CaptureResult& otherResult);
129
130    status_t                readFromParcel(android::Parcel* parcel);
131    status_t                writeToParcel(android::Parcel* parcel) const;
132};
133
134}
135
136#endif /* ANDROID_HARDWARE_CAPTURERESULT_H */
137