Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 1 | /* |
Shuzhen Wang | c28189a | 2017-11-27 23:05:10 -0800 | [diff] [blame] | 2 | * Copyright (C) 2013-2018 The Android Open Source Project |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 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_CAMERA_PHOTOGRAPHY_CAMERADEVICECLIENT_H |
| 18 | #define ANDROID_SERVERS_CAMERA_PHOTOGRAPHY_CAMERADEVICECLIENT_H |
| 19 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 20 | #include <android/hardware/camera2/BnCameraDeviceUser.h> |
| 21 | #include <android/hardware/camera2/ICameraDeviceCallbacks.h> |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 22 | #include <camera/camera2/OutputConfiguration.h> |
Emilian Peev | 35ae826 | 2018-11-08 13:11:32 +0000 | [diff] [blame] | 23 | #include <camera/camera2/SessionConfiguration.h> |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 24 | #include <camera/camera2/SubmitInfo.h> |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 25 | #include <unordered_map> |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 26 | |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 27 | #include "CameraOfflineSessionClient.h" |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 28 | #include "CameraService.h" |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 29 | #include "common/FrameProcessorBase.h" |
| 30 | #include "common/Camera2ClientBase.h" |
Emilian Peev | 538c90e | 2018-12-17 18:03:19 +0000 | [diff] [blame] | 31 | #include "CompositeStream.h" |
Austin Borger | 74fca04 | 2022-05-23 12:41:21 -0700 | [diff] [blame] | 32 | #include "utils/CameraServiceProxyWrapper.h" |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 33 | #include "utils/SessionConfigurationUtils.h" |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 34 | |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 35 | using android::camera3::OutputStreamInfo; |
Emilian Peev | 538c90e | 2018-12-17 18:03:19 +0000 | [diff] [blame] | 36 | using android::camera3::CompositeStream; |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 37 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 38 | namespace android { |
| 39 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 40 | struct CameraDeviceClientBase : |
| 41 | public CameraService::BasicClient, |
| 42 | public hardware::camera2::BnCameraDeviceUser |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 43 | { |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 44 | typedef hardware::camera2::ICameraDeviceCallbacks TCamCallbacks; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 45 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 46 | const sp<hardware::camera2::ICameraDeviceCallbacks>& getRemoteCallback() { |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 47 | return mRemoteCallback; |
| 48 | } |
| 49 | |
| 50 | protected: |
| 51 | CameraDeviceClientBase(const sp<CameraService>& cameraService, |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 52 | const sp<hardware::camera2::ICameraDeviceCallbacks>& remoteCallback, |
Austin Borger | 249e659 | 2024-03-10 22:28:11 -0700 | [diff] [blame] | 53 | std::shared_ptr<AttributionAndPermissionUtils> attributionAndPermissionUtils, |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 54 | const std::string& clientPackageName, |
Jayant Chowdhary | eb0169f | 2022-01-31 00:00:02 -0800 | [diff] [blame] | 55 | bool systemNativeClient, |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 56 | const std::optional<std::string>& clientFeatureId, |
| 57 | const std::string& cameraId, |
Yin-Chia Yeh | c3e9d6f | 2018-02-06 10:56:32 -0800 | [diff] [blame] | 58 | int api1CameraId, |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 59 | int cameraFacing, |
Emilian Peev | 8b64f28 | 2021-03-25 16:49:57 -0700 | [diff] [blame] | 60 | int sensorOrientation, |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 61 | int clientPid, |
| 62 | uid_t clientUid, |
Austin Borger | 18b30a7 | 2022-10-27 12:20:29 -0700 | [diff] [blame] | 63 | int servicePid, |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 64 | int rotationOverride); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 65 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 66 | sp<hardware::camera2::ICameraDeviceCallbacks> mRemoteCallback; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | /** |
| 70 | * Implements the binder ICameraDeviceUser API, |
| 71 | * meant for HAL3-public implementation of |
| 72 | * android.hardware.photography.CameraDevice |
| 73 | */ |
| 74 | class CameraDeviceClient : |
| 75 | public Camera2ClientBase<CameraDeviceClientBase>, |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 76 | public camera2::FrameProcessorBase::FilteredListener |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 77 | { |
| 78 | public: |
| 79 | /** |
| 80 | * ICameraDeviceUser interface (see ICameraDeviceUser for details) |
| 81 | */ |
| 82 | |
| 83 | // Note that the callee gets a copy of the metadata. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 84 | virtual binder::Status submitRequest( |
| 85 | const hardware::camera2::CaptureRequest& request, |
| 86 | bool streaming = false, |
| 87 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 88 | hardware::camera2::utils::SubmitInfo *submitInfo = nullptr) override; |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 89 | // List of requests are copied. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 90 | virtual binder::Status submitRequestList( |
| 91 | const std::vector<hardware::camera2::CaptureRequest>& requests, |
| 92 | bool streaming = false, |
| 93 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 94 | hardware::camera2::utils::SubmitInfo *submitInfo = nullptr) override; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 95 | virtual binder::Status cancelRequest(int requestId, |
| 96 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 97 | int64_t* lastFrameNumber = NULL) override; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 98 | |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 99 | virtual binder::Status beginConfigure() override; |
Ruben Brunk | b2119af | 2014-05-09 19:57:56 -0700 | [diff] [blame] | 100 | |
Emilian Peev | 5fbe0ba | 2017-10-20 15:45:45 +0100 | [diff] [blame] | 101 | virtual binder::Status endConfigure(int operatingMode, |
Emilian Peev | cc0b795 | 2020-01-07 13:54:47 -0800 | [diff] [blame] | 102 | const hardware::camera2::impl::CameraMetadataNative& sessionParams, |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 103 | int64_t startTimeMs, |
Emilian Peev | cc0b795 | 2020-01-07 13:54:47 -0800 | [diff] [blame] | 104 | /*out*/ |
| 105 | std::vector<int>* offlineStreamIds) override; |
Ruben Brunk | b2119af | 2014-05-09 19:57:56 -0700 | [diff] [blame] | 106 | |
Emilian Peev | 35ae826 | 2018-11-08 13:11:32 +0000 | [diff] [blame] | 107 | // Verify specific session configuration. |
| 108 | virtual binder::Status isSessionConfigurationSupported( |
| 109 | const SessionConfiguration& sessionConfiguration, |
| 110 | /*out*/ |
| 111 | bool* streamStatus) override; |
| 112 | |
Yin-Chia Yeh | 5090c73 | 2017-07-20 16:05:29 -0700 | [diff] [blame] | 113 | // Returns -EBUSY if device is not idle or in error state |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 114 | virtual binder::Status deleteStream(int streamId) override; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 115 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 116 | virtual binder::Status createStream( |
| 117 | const hardware::camera2::params::OutputConfiguration &outputConfiguration, |
| 118 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 119 | int32_t* newStreamId = NULL) override; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 120 | |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 121 | // Create an input stream of width, height, and format. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 122 | virtual binder::Status createInputStream(int width, int height, int format, |
Shuzhen Wang | 83bff12 | 2020-11-20 15:51:39 -0800 | [diff] [blame] | 123 | bool isMultiResolution, |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 124 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 125 | int32_t* newStreamId = NULL) override; |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 126 | |
| 127 | // Get the buffer producer of the input stream |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 128 | virtual binder::Status getInputSurface( |
| 129 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 130 | view::Surface *inputSurface) override; |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 131 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 132 | // Create a request object from a template. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 133 | virtual binder::Status createDefaultRequest(int templateId, |
| 134 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 135 | hardware::camera2::impl::CameraMetadataNative* request) override; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 136 | |
| 137 | // Get the static metadata for the camera |
| 138 | // -- Caller owns the newly allocated metadata |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 139 | virtual binder::Status getCameraInfo( |
| 140 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 141 | hardware::camera2::impl::CameraMetadataNative* cameraCharacteristics) override; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 142 | |
Zhijun He | 2ab500c | 2013-07-23 08:02:53 -0700 | [diff] [blame] | 143 | // Wait until all the submitted requests have finished processing |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 144 | virtual binder::Status waitUntilIdle() override; |
Eino-Ville Talvala | abaa51d | 2013-08-14 11:37:00 -0700 | [diff] [blame] | 145 | |
| 146 | // Flush all active and pending requests as fast as possible |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 147 | virtual binder::Status flush( |
| 148 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 149 | int64_t* lastFrameNumber = NULL) override; |
Eino-Ville Talvala | abaa51d | 2013-08-14 11:37:00 -0700 | [diff] [blame] | 150 | |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 151 | // Prepare stream by preallocating its buffers |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 152 | virtual binder::Status prepare(int32_t streamId) override; |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 153 | |
Eino-Ville Talvala | b25e3c8 | 2015-07-15 16:04:27 -0700 | [diff] [blame] | 154 | // Tear down stream resources by freeing its unused buffers |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 155 | virtual binder::Status tearDown(int32_t streamId) override; |
Eino-Ville Talvala | b25e3c8 | 2015-07-15 16:04:27 -0700 | [diff] [blame] | 156 | |
Ruben Brunk | c78ac26 | 2015-08-13 17:58:46 -0700 | [diff] [blame] | 157 | // Prepare stream by preallocating up to maxCount of its buffers |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 158 | virtual binder::Status prepare2(int32_t maxCount, int32_t streamId) override; |
Ruben Brunk | c78ac26 | 2015-08-13 17:58:46 -0700 | [diff] [blame] | 159 | |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 160 | // Update an output configuration |
| 161 | virtual binder::Status updateOutputConfiguration(int streamId, |
| 162 | const hardware::camera2::params::OutputConfiguration &outputConfiguration) override; |
| 163 | |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 164 | // Finalize the output configurations with surfaces not added before. |
| 165 | virtual binder::Status finalizeOutputConfigurations(int32_t streamId, |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 166 | const hardware::camera2::params::OutputConfiguration &outputConfiguration) override; |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 167 | |
Yin-Chia Yeh | cfab4e1 | 2019-09-09 13:08:28 -0700 | [diff] [blame] | 168 | virtual binder::Status setCameraAudioRestriction(int32_t mode) override; |
| 169 | |
| 170 | virtual binder::Status getGlobalAudioRestriction(/*out*/int32_t* outMode) override; |
Yin-Chia Yeh | dba0323 | 2019-08-19 15:54:28 -0700 | [diff] [blame] | 171 | |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 172 | virtual binder::Status switchToOffline( |
| 173 | const sp<hardware::camera2::ICameraDeviceCallbacks>& cameraCb, |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame] | 174 | const std::vector<int>& offlineOutputIds, |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 175 | /*out*/ |
| 176 | sp<hardware::camera2::ICameraOfflineSession>* session) override; |
| 177 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 178 | /** |
| 179 | * Interface used by CameraService |
| 180 | */ |
| 181 | |
| 182 | CameraDeviceClient(const sp<CameraService>& cameraService, |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 183 | const sp<hardware::camera2::ICameraDeviceCallbacks>& remoteCallback, |
Austin Borger | 74fca04 | 2022-05-23 12:41:21 -0700 | [diff] [blame] | 184 | std::shared_ptr<CameraServiceProxyWrapper> cameraServiceProxyWrapper, |
Austin Borger | 249e659 | 2024-03-10 22:28:11 -0700 | [diff] [blame] | 185 | std::shared_ptr<AttributionAndPermissionUtils> attributionAndPermissionUtils, |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 186 | const std::string& clientPackageName, |
Jayant Chowdhary | eb0169f | 2022-01-31 00:00:02 -0800 | [diff] [blame] | 187 | bool clientPackageOverride, |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 188 | const std::optional<std::string>& clientFeatureId, |
| 189 | const std::string& cameraId, |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 190 | int cameraFacing, |
Emilian Peev | 8b64f28 | 2021-03-25 16:49:57 -0700 | [diff] [blame] | 191 | int sensorOrientation, |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 192 | int clientPid, |
| 193 | uid_t clientUid, |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 194 | int servicePid, |
Austin Borger | 18b30a7 | 2022-10-27 12:20:29 -0700 | [diff] [blame] | 195 | bool overrideForPerfClass, |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 196 | int rotationOverride, |
malikakash | 73125c6 | 2023-07-21 22:44:34 +0000 | [diff] [blame] | 197 | const std::string& originalCameraId); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 198 | virtual ~CameraDeviceClient(); |
| 199 | |
Emilian Peev | bd8c503 | 2018-02-14 23:05:40 +0000 | [diff] [blame] | 200 | virtual status_t initialize(sp<CameraProviderManager> manager, |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 201 | const std::string& monitorTags) override; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 202 | |
Jayant Chowdhary | 44d5f62 | 2023-09-20 03:11:41 +0000 | [diff] [blame] | 203 | virtual status_t setRotateAndCropOverride(uint8_t rotateAndCrop, |
| 204 | bool fromHal = false) override; |
Eino-Ville Talvala | f2e3709 | 2020-01-07 15:32:32 -0800 | [diff] [blame] | 205 | |
Bharatt Kukreja | 7146ced | 2022-10-25 15:45:29 +0000 | [diff] [blame] | 206 | virtual status_t setAutoframingOverride(uint8_t autoframingValue) override; |
| 207 | |
Eino-Ville Talvala | 305cec6 | 2020-11-12 14:18:17 -0800 | [diff] [blame] | 208 | virtual bool supportsCameraMute(); |
| 209 | virtual status_t setCameraMute(bool enabled); |
| 210 | |
Shuzhen Wang | af22e91 | 2023-04-11 16:03:17 -0700 | [diff] [blame] | 211 | virtual bool supportsZoomOverride() override; |
| 212 | virtual status_t setZoomOverride(int32_t zoomOverride) override; |
| 213 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 214 | virtual status_t dump(int fd, const Vector<String16>& args); |
| 215 | |
Eino-Ville Talvala | c400396 | 2016-01-13 10:07:04 -0800 | [diff] [blame] | 216 | virtual status_t dumpClient(int fd, const Vector<String16>& args); |
| 217 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 218 | virtual status_t startWatchingTags(const std::string &tags, int out); |
Avichal Rakesh | 7e53cad | 2021-10-05 13:46:30 -0700 | [diff] [blame] | 219 | virtual status_t stopWatchingTags(int out); |
| 220 | virtual status_t dumpWatchedEventsToVector(std::vector<std::string> &out); |
| 221 | |
Ravneet | aeb20dc | 2022-03-30 05:33:03 +0000 | [diff] [blame] | 222 | virtual status_t setCameraServiceWatchdog(bool enabled); |
| 223 | |
Shuzhen Wang | 16610a6 | 2022-12-15 22:38:07 -0800 | [diff] [blame] | 224 | virtual void setStreamUseCaseOverrides(const std::vector<int64_t>& useCaseOverrides); |
| 225 | virtual void clearStreamUseCaseOverrides() override; |
| 226 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 227 | /** |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 228 | * Device listener interface |
| 229 | */ |
| 230 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 231 | virtual void notifyIdle(int64_t requestCount, int64_t resultErrorCount, bool deviceError, |
Eino-Ville Talvala | ffc186b | 2024-04-09 18:10:47 -0700 | [diff] [blame] | 232 | std::pair<int32_t, int32_t> mostRequestedFpsRange, |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 233 | const std::vector<hardware::CameraStreamStats>& streamStats); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 234 | virtual void notifyError(int32_t errorCode, |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 235 | const CaptureResultExtras& resultExtras); |
| 236 | virtual void notifyShutter(const CaptureResultExtras& resultExtras, nsecs_t timestamp); |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 237 | virtual void notifyPrepared(int streamId); |
Shuzhen Wang | 9d06601 | 2016-09-30 11:30:20 -0700 | [diff] [blame] | 238 | virtual void notifyRequestQueueEmpty(); |
Chien-Yu Chen | e8c535e | 2016-04-14 12:18:26 -0700 | [diff] [blame] | 239 | virtual void notifyRepeatingRequestError(long lastFrameNumber); |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 240 | |
Shuzhen Wang | abbcb6b | 2020-12-09 22:32:44 -0800 | [diff] [blame] | 241 | void setImageDumpMask(int mask) { if (mDevice != nullptr) mDevice->setImageDumpMask(mask); } |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 242 | /** |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 243 | * Interface used by independent components of CameraDeviceClient. |
| 244 | */ |
| 245 | protected: |
| 246 | /** FilteredListener implementation **/ |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 247 | virtual void onResultAvailable(const CaptureResult& result); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 248 | virtual void detachDevice(); |
| 249 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 250 | bool supportsUltraHighResolutionCapture(const std::string &cameraId); |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 251 | |
| 252 | bool isSensorPixelModeConsistent(const std::list<int> &streamIdList, |
| 253 | const CameraMetadata &settings); |
| 254 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 255 | const CameraMetadata &getStaticInfo(const std::string &cameraId); |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 256 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 257 | private: |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 258 | // StreamSurfaceId encapsulates streamId + surfaceId for a particular surface. |
| 259 | // streamId specifies the index of the stream the surface belongs to, and the |
| 260 | // surfaceId specifies the index of the surface within the stream. (one stream |
| 261 | // could contain multiple surfaces.) |
| 262 | class StreamSurfaceId final { |
| 263 | public: |
| 264 | StreamSurfaceId() { |
| 265 | mStreamId = -1; |
| 266 | mSurfaceId = -1; |
| 267 | } |
| 268 | StreamSurfaceId(int32_t streamId, int32_t surfaceId) { |
| 269 | mStreamId = streamId; |
| 270 | mSurfaceId = surfaceId; |
| 271 | } |
| 272 | int32_t streamId() const { |
| 273 | return mStreamId; |
| 274 | } |
| 275 | int32_t surfaceId() const { |
| 276 | return mSurfaceId; |
| 277 | } |
| 278 | |
| 279 | private: |
| 280 | int32_t mStreamId; |
| 281 | int32_t mSurfaceId; |
| 282 | |
| 283 | }; // class StreamSurfaceId |
| 284 | |
| 285 | private: |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 286 | /** ICameraDeviceUser interface-related private members */ |
| 287 | |
| 288 | /** Preview callback related members */ |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 289 | sp<camera2::FrameProcessorBase> mFrameProcessor; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 290 | |
Emilian Peev | 00420d2 | 2018-02-05 21:33:13 +0000 | [diff] [blame] | 291 | std::vector<int32_t> mSupportedPhysicalRequestKeys; |
| 292 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 293 | template<typename TProviderPtr> |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 294 | status_t initializeImpl(TProviderPtr providerPtr, const std::string& monitorTags); |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 295 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 296 | /** Utility members */ |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 297 | binder::Status checkPidStatus(const char* checkLocation); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 298 | bool enforceRequestPermissions(CameraMetadata& metadata); |
| 299 | |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 300 | // Create an output stream with surface deferred for future. |
| 301 | binder::Status createDeferredSurfaceStreamLocked( |
| 302 | const hardware::camera2::params::OutputConfiguration &outputConfiguration, |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 303 | bool isShared, |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 304 | int* newStreamId = NULL); |
| 305 | |
Yin-Chia Yeh | 4dfa4cc | 2017-11-10 20:00:09 -0800 | [diff] [blame] | 306 | // Utility method to insert the surface into SurfaceMap |
| 307 | binder::Status insertGbpLocked(const sp<IGraphicBufferProducer>& gbp, |
Emilian Peev | f873aa5 | 2018-01-26 14:58:28 +0000 | [diff] [blame] | 308 | /*out*/SurfaceMap* surfaceMap, /*out*/Vector<int32_t>* streamIds, |
| 309 | /*out*/int32_t* currentStreamId); |
Yin-Chia Yeh | 4dfa4cc | 2017-11-10 20:00:09 -0800 | [diff] [blame] | 310 | |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 311 | // IGraphicsBufferProducer binder -> Stream ID + Surface ID for output streams |
| 312 | KeyedVector<sp<IBinder>, StreamSurfaceId> mStreamMap; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 313 | |
Yin-Chia Yeh | 4dfa4cc | 2017-11-10 20:00:09 -0800 | [diff] [blame] | 314 | // Stream ID -> OutputConfiguration. Used for looking up Surface by stream/surface index |
| 315 | KeyedVector<int32_t, hardware::camera2::params::OutputConfiguration> mConfiguredOutputs; |
| 316 | |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 317 | // Dynamic range profile id -> Supported dynamic profiles bitmap within an single capture |
| 318 | // request |
Emilian Peev | c81a759 | 2022-02-14 17:38:18 -0800 | [diff] [blame] | 319 | std::unordered_map<int64_t, int64_t> mDynamicProfileMap; |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 320 | |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 321 | struct InputStreamConfiguration { |
| 322 | bool configured; |
| 323 | int32_t width; |
| 324 | int32_t height; |
| 325 | int32_t format; |
| 326 | int32_t id; |
| 327 | } mInputStream; |
| 328 | |
Chien-Yu Chen | e8c535e | 2016-04-14 12:18:26 -0700 | [diff] [blame] | 329 | // Streaming request ID |
| 330 | int32_t mStreamingRequestId; |
Shuzhen Wang | c9ca678 | 2016-04-26 13:40:31 -0700 | [diff] [blame] | 331 | Mutex mStreamingRequestIdLock; |
Chien-Yu Chen | e8c535e | 2016-04-14 12:18:26 -0700 | [diff] [blame] | 332 | static const int32_t REQUEST_ID_NONE = -1; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 333 | |
| 334 | int32_t mRequestIdCounter; |
Eino-Ville Talvala | 412fe56 | 2015-08-20 17:08:32 -0700 | [diff] [blame] | 335 | |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 336 | std::vector<std::string> mPhysicalCameraIds; |
| 337 | |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 338 | // The list of output streams whose surfaces are deferred. We have to track them separately |
| 339 | // as there are no surfaces available and can not be put into mStreamMap. Once the deferred |
| 340 | // Surface is configured, the stream id will be moved to mStreamMap. |
| 341 | Vector<int32_t> mDeferredStreams; |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 342 | |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 343 | // stream ID -> outputStreamInfo mapping |
| 344 | std::unordered_map<int32_t, OutputStreamInfo> mStreamInfoMap; |
| 345 | |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 346 | // map high resolution camera id (logical / physical) -> list of stream ids configured |
| 347 | std::unordered_map<std::string, std::unordered_set<int>> mHighResolutionCameraIdToStreamIdSet; |
| 348 | |
| 349 | // set of high resolution camera id (logical / physical) |
| 350 | std::unordered_set<std::string> mHighResolutionSensors; |
| 351 | |
Emilian Peev | 2f5d601 | 2022-01-19 16:16:50 -0800 | [diff] [blame] | 352 | // Synchronize access to 'mCompositeStreamMap' |
| 353 | Mutex mCompositeLock; |
Emilian Peev | 538c90e | 2018-12-17 18:03:19 +0000 | [diff] [blame] | 354 | KeyedVector<sp<IBinder>, sp<CompositeStream>> mCompositeStreamMap; |
| 355 | |
Shuzhen Wang | 03d8cc1 | 2018-09-12 14:17:09 -0700 | [diff] [blame] | 356 | sp<CameraProviderManager> mProviderManager; |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 357 | |
| 358 | // Override the camera characteristics for performance class primary cameras. |
| 359 | bool mOverrideForPerfClass; |
Shuzhen Wang | d26b186 | 2022-03-07 12:05:05 -0800 | [diff] [blame] | 360 | |
Eino-Ville Talvala | ffc186b | 2024-04-09 18:10:47 -0700 | [diff] [blame] | 361 | // Various fields used to collect session statistics |
| 362 | struct RunningSessionStats { |
| 363 | // The string representation of object passed into CaptureRequest.setTag. |
| 364 | std::string mUserTag; |
| 365 | // The last set video stabilization mode |
| 366 | int mVideoStabilizationMode = -1; |
| 367 | // Whether a zoom_ratio < 1.0 has been used during this session |
| 368 | bool mUsedUltraWide = false; |
| 369 | // Whether a zoom settings override has been used during this session |
| 370 | bool mUsedSettingsOverrideZoom = false; |
| 371 | } mRunningSessionStats; |
malikakash | 73125c6 | 2023-07-21 22:44:34 +0000 | [diff] [blame] | 372 | |
| 373 | // This only exists in case of camera ID Remapping. |
| 374 | const std::string mOriginalCameraId; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 375 | }; |
| 376 | |
| 377 | }; // namespace android |
| 378 | |
| 379 | #endif |