blob: ceeaa71b61da241f1c2e62105c407b11bca74bf4 [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
94 // Requested camera ids (both logical and physical) with zoomRatio != 1.0f
95 std::set<std::string> cameraIdsWithZoom;
96
97 // What shared surfaces an output should go to
98 SurfaceMap outputSurfaces;
99
100 // TODO: dedupe
101 static const nsecs_t kDefaultExpectedDuration = 100000000; // 100 ms
102
103 // Default constructor needed by KeyedVector
104 InFlightRequest() :
105 shutterTimestamp(0),
106 sensorTimestamp(0),
107 requestStatus(OK),
108 haveResultMetadata(false),
109 numBuffersLeft(0),
110 hasInputBuffer(false),
111 hasCallback(true),
112 maxExpectedDuration(kDefaultExpectedDuration),
113 skipResultMetadata(false),
114 stillCapture(false),
115 zslCapture(false) {
116 }
117
118 InFlightRequest(int numBuffers, CaptureResultExtras extras, bool hasInput,
119 bool hasAppCallback, nsecs_t maxDuration,
120 const std::set<String8>& physicalCameraIdSet, bool isStillCapture,
121 bool isZslCapture, const std::set<std::string>& idsWithZoom,
122 const SurfaceMap& outSurfaces = SurfaceMap{}) :
123 shutterTimestamp(0),
124 sensorTimestamp(0),
125 requestStatus(OK),
126 haveResultMetadata(false),
127 numBuffersLeft(numBuffers),
128 resultExtras(extras),
129 hasInputBuffer(hasInput),
130 hasCallback(hasAppCallback),
131 maxExpectedDuration(maxDuration),
132 skipResultMetadata(false),
133 physicalCameraIds(physicalCameraIdSet),
134 stillCapture(isStillCapture),
135 zslCapture(isZslCapture),
136 cameraIdsWithZoom(idsWithZoom),
137 outputSurfaces(outSurfaces) {
138 }
139};
140
141// Map from frame number to the in-flight request state
142typedef KeyedVector<uint32_t, InFlightRequest> InFlightRequestMap;
143
144} // namespace camera3
145
146} // namespace android
147
148#endif