blob: 424043b51aab825ec049b641abf982a653cc5007 [file] [log] [blame]
Yin-Chia Yeh5fd603e2019-11-20 11:22:27 -08001/*
2 * Copyright (C) 2019 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_SERVERS_CAMERA3_INFLIGHT_REQUEST_H
18#define ANDROID_SERVERS_CAMERA3_INFLIGHT_REQUEST_H
19
20#include <set>
21
22#include <camera/CaptureResult.h>
23#include <camera/CameraMetadata.h>
24#include <utils/String8.h>
25#include <utils/Timers.h>
26
27#include "hardware/camera3.h"
28
29#include "common/CameraDeviceBase.h"
30
31namespace android {
32
33namespace camera3 {
34
35struct InFlightRequest {
36 // Set by notify() SHUTTER call.
37 nsecs_t shutterTimestamp;
38 // Set by process_capture_result().
39 nsecs_t sensorTimestamp;
40 int requestStatus;
41 // Set by process_capture_result call with valid metadata
42 bool haveResultMetadata;
43 // Decremented by calls to process_capture_result with valid output
44 // and input buffers
45 int numBuffersLeft;
46 CaptureResultExtras resultExtras;
47 // If this request has any input buffer
48 bool hasInputBuffer;
49
50 // The last metadata that framework receives from HAL and
51 // not yet send out because the shutter event hasn't arrived.
52 // It's added by process_capture_result and sent when framework
53 // receives the shutter event.
54 CameraMetadata pendingMetadata;
55
56 // The metadata of the partial results that framework receives from HAL so far
57 // and has sent out.
58 CameraMetadata collectedPartialResult;
59
60 // Buffers are added by process_capture_result when output buffers
61 // return from HAL but framework has not yet received the shutter
62 // event. They will be returned to the streams when framework receives
63 // the shutter event.
64 Vector<camera3_stream_buffer_t> pendingOutputBuffers;
65
66 // Whether this inflight request's shutter and result callback are to be
67 // called. The policy is that if the request is the last one in the constrained
68 // high speed recording request list, this flag will be true. If the request list
69 // is not for constrained high speed recording, this flag will also be true.
70 bool hasCallback;
71
72 // Maximum expected frame duration for this request.
73 // For manual captures, equal to the max of requested exposure time and frame duration
74 // For auto-exposure modes, equal to 1/(lower end of target FPS range)
75 nsecs_t maxExpectedDuration;
76
77 // Whether the result metadata for this request is to be skipped. The
78 // result metadata should be skipped in the case of
79 // REQUEST/RESULT error.
80 bool skipResultMetadata;
81
82 // The physical camera ids being requested.
83 std::set<String8> physicalCameraIds;
84
85 // Map of physicalCameraId <-> Metadata
86 std::vector<PhysicalCaptureResultInfo> physicalMetadatas;
87
88 // Indicates a still capture request.
89 bool stillCapture;
90
91 // Indicates a ZSL capture request
92 bool zslCapture;
93
Eino-Ville Talvalaf2e37092020-01-07 15:32:32 -080094 // Indicates that ROTATE_AND_CROP was set to AUTO
95 bool rotateAndCropAuto;
96
Yin-Chia Yeh5fd603e2019-11-20 11:22:27 -080097 // Requested camera ids (both logical and physical) with zoomRatio != 1.0f
98 std::set<std::string> cameraIdsWithZoom;
99
100 // What shared surfaces an output should go to
101 SurfaceMap outputSurfaces;
102
103 // TODO: dedupe
104 static const nsecs_t kDefaultExpectedDuration = 100000000; // 100 ms
105
106 // Default constructor needed by KeyedVector
107 InFlightRequest() :
108 shutterTimestamp(0),
109 sensorTimestamp(0),
110 requestStatus(OK),
111 haveResultMetadata(false),
112 numBuffersLeft(0),
113 hasInputBuffer(false),
114 hasCallback(true),
115 maxExpectedDuration(kDefaultExpectedDuration),
116 skipResultMetadata(false),
117 stillCapture(false),
Eino-Ville Talvalaf2e37092020-01-07 15:32:32 -0800118 zslCapture(false),
119 rotateAndCropAuto(false) {
Yin-Chia Yeh5fd603e2019-11-20 11:22:27 -0800120 }
121
122 InFlightRequest(int numBuffers, CaptureResultExtras extras, bool hasInput,
123 bool hasAppCallback, nsecs_t maxDuration,
124 const std::set<String8>& physicalCameraIdSet, bool isStillCapture,
Eino-Ville Talvalaf2e37092020-01-07 15:32:32 -0800125 bool isZslCapture, bool rotateAndCropAuto, const std::set<std::string>& idsWithZoom,
Yin-Chia Yeh5fd603e2019-11-20 11:22:27 -0800126 const SurfaceMap& outSurfaces = SurfaceMap{}) :
127 shutterTimestamp(0),
128 sensorTimestamp(0),
129 requestStatus(OK),
130 haveResultMetadata(false),
131 numBuffersLeft(numBuffers),
132 resultExtras(extras),
133 hasInputBuffer(hasInput),
134 hasCallback(hasAppCallback),
135 maxExpectedDuration(maxDuration),
136 skipResultMetadata(false),
137 physicalCameraIds(physicalCameraIdSet),
138 stillCapture(isStillCapture),
139 zslCapture(isZslCapture),
Eino-Ville Talvalaf2e37092020-01-07 15:32:32 -0800140 rotateAndCropAuto(rotateAndCropAuto),
Yin-Chia Yeh5fd603e2019-11-20 11:22:27 -0800141 cameraIdsWithZoom(idsWithZoom),
142 outputSurfaces(outSurfaces) {
143 }
144};
145
146// Map from frame number to the in-flight request state
147typedef KeyedVector<uint32_t, InFlightRequest> InFlightRequestMap;
148
149} // namespace camera3
150
151} // namespace android
152
153#endif