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> |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 25 | |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 26 | #include "CameraOfflineSessionClient.h" |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 27 | #include "CameraService.h" |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 28 | #include "common/FrameProcessorBase.h" |
| 29 | #include "common/Camera2ClientBase.h" |
Emilian Peev | 538c90e | 2018-12-17 18:03:19 +0000 | [diff] [blame] | 30 | #include "CompositeStream.h" |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 31 | |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 32 | using android::camera3::OutputStreamInfo; |
Emilian Peev | 538c90e | 2018-12-17 18:03:19 +0000 | [diff] [blame] | 33 | using android::camera3::CompositeStream; |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 34 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 35 | namespace android { |
| 36 | |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 37 | typedef std::function<CameraMetadata (const String8 &)> metadataGetter; |
| 38 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 39 | struct CameraDeviceClientBase : |
| 40 | public CameraService::BasicClient, |
| 41 | public hardware::camera2::BnCameraDeviceUser |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 42 | { |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 43 | typedef hardware::camera2::ICameraDeviceCallbacks TCamCallbacks; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 44 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 45 | const sp<hardware::camera2::ICameraDeviceCallbacks>& getRemoteCallback() { |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 46 | return mRemoteCallback; |
| 47 | } |
| 48 | |
| 49 | protected: |
| 50 | CameraDeviceClientBase(const sp<CameraService>& cameraService, |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 51 | const sp<hardware::camera2::ICameraDeviceCallbacks>& remoteCallback, |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 52 | const String16& clientPackageName, |
Jooyung Han | b3f7cd2 | 2020-01-23 12:27:18 +0900 | [diff] [blame] | 53 | const std::optional<String16>& clientFeatureId, |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 54 | const String8& cameraId, |
Yin-Chia Yeh | c3e9d6f | 2018-02-06 10:56:32 -0800 | [diff] [blame] | 55 | int api1CameraId, |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 56 | int cameraFacing, |
| 57 | int clientPid, |
| 58 | uid_t clientUid, |
| 59 | int servicePid); |
| 60 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 61 | sp<hardware::camera2::ICameraDeviceCallbacks> mRemoteCallback; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | /** |
| 65 | * Implements the binder ICameraDeviceUser API, |
| 66 | * meant for HAL3-public implementation of |
| 67 | * android.hardware.photography.CameraDevice |
| 68 | */ |
| 69 | class CameraDeviceClient : |
| 70 | public Camera2ClientBase<CameraDeviceClientBase>, |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 71 | public camera2::FrameProcessorBase::FilteredListener |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 72 | { |
| 73 | public: |
| 74 | /** |
| 75 | * ICameraDeviceUser interface (see ICameraDeviceUser for details) |
| 76 | */ |
| 77 | |
| 78 | // Note that the callee gets a copy of the metadata. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 79 | virtual binder::Status submitRequest( |
| 80 | const hardware::camera2::CaptureRequest& request, |
| 81 | bool streaming = false, |
| 82 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 83 | hardware::camera2::utils::SubmitInfo *submitInfo = nullptr) override; |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 84 | // List of requests are copied. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 85 | virtual binder::Status submitRequestList( |
| 86 | const std::vector<hardware::camera2::CaptureRequest>& requests, |
| 87 | bool streaming = false, |
| 88 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 89 | hardware::camera2::utils::SubmitInfo *submitInfo = nullptr) override; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 90 | virtual binder::Status cancelRequest(int requestId, |
| 91 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 92 | int64_t* lastFrameNumber = NULL) override; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 93 | |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 94 | virtual binder::Status beginConfigure() override; |
Ruben Brunk | b2119af | 2014-05-09 19:57:56 -0700 | [diff] [blame] | 95 | |
Emilian Peev | 5fbe0ba | 2017-10-20 15:45:45 +0100 | [diff] [blame] | 96 | virtual binder::Status endConfigure(int operatingMode, |
Emilian Peev | cc0b795 | 2020-01-07 13:54:47 -0800 | [diff] [blame] | 97 | const hardware::camera2::impl::CameraMetadataNative& sessionParams, |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 98 | int64_t startTimeMs, |
Emilian Peev | cc0b795 | 2020-01-07 13:54:47 -0800 | [diff] [blame] | 99 | /*out*/ |
| 100 | std::vector<int>* offlineStreamIds) override; |
Ruben Brunk | b2119af | 2014-05-09 19:57:56 -0700 | [diff] [blame] | 101 | |
Emilian Peev | 35ae826 | 2018-11-08 13:11:32 +0000 | [diff] [blame] | 102 | // Verify specific session configuration. |
| 103 | virtual binder::Status isSessionConfigurationSupported( |
| 104 | const SessionConfiguration& sessionConfiguration, |
| 105 | /*out*/ |
| 106 | bool* streamStatus) override; |
| 107 | |
Yin-Chia Yeh | 5090c73 | 2017-07-20 16:05:29 -0700 | [diff] [blame] | 108 | // Returns -EBUSY if device is not idle or in error state |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 109 | virtual binder::Status deleteStream(int streamId) override; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 110 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 111 | virtual binder::Status createStream( |
| 112 | const hardware::camera2::params::OutputConfiguration &outputConfiguration, |
| 113 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 114 | int32_t* newStreamId = NULL) override; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 115 | |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 116 | // Create an input stream of width, height, and format. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 117 | virtual binder::Status createInputStream(int width, int height, int format, |
| 118 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 119 | int32_t* newStreamId = NULL) override; |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 120 | |
| 121 | // Get the buffer producer of the input stream |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 122 | virtual binder::Status getInputSurface( |
| 123 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 124 | view::Surface *inputSurface) override; |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 125 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 126 | // Create a request object from a template. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 127 | virtual binder::Status createDefaultRequest(int templateId, |
| 128 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 129 | hardware::camera2::impl::CameraMetadataNative* request) override; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 130 | |
| 131 | // Get the static metadata for the camera |
| 132 | // -- Caller owns the newly allocated metadata |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 133 | virtual binder::Status getCameraInfo( |
| 134 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 135 | hardware::camera2::impl::CameraMetadataNative* cameraCharacteristics) override; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 136 | |
Zhijun He | 2ab500c | 2013-07-23 08:02:53 -0700 | [diff] [blame] | 137 | // Wait until all the submitted requests have finished processing |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 138 | virtual binder::Status waitUntilIdle() override; |
Eino-Ville Talvala | abaa51d | 2013-08-14 11:37:00 -0700 | [diff] [blame] | 139 | |
| 140 | // Flush all active and pending requests as fast as possible |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 141 | virtual binder::Status flush( |
| 142 | /*out*/ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 143 | int64_t* lastFrameNumber = NULL) override; |
Eino-Ville Talvala | abaa51d | 2013-08-14 11:37:00 -0700 | [diff] [blame] | 144 | |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 145 | // Prepare stream by preallocating its buffers |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 146 | virtual binder::Status prepare(int32_t streamId) override; |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 147 | |
Eino-Ville Talvala | b25e3c8 | 2015-07-15 16:04:27 -0700 | [diff] [blame] | 148 | // Tear down stream resources by freeing its unused buffers |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 149 | virtual binder::Status tearDown(int32_t streamId) override; |
Eino-Ville Talvala | b25e3c8 | 2015-07-15 16:04:27 -0700 | [diff] [blame] | 150 | |
Ruben Brunk | c78ac26 | 2015-08-13 17:58:46 -0700 | [diff] [blame] | 151 | // Prepare stream by preallocating up to maxCount of its buffers |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 152 | virtual binder::Status prepare2(int32_t maxCount, int32_t streamId) override; |
Ruben Brunk | c78ac26 | 2015-08-13 17:58:46 -0700 | [diff] [blame] | 153 | |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 154 | // Update an output configuration |
| 155 | virtual binder::Status updateOutputConfiguration(int streamId, |
| 156 | const hardware::camera2::params::OutputConfiguration &outputConfiguration) override; |
| 157 | |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 158 | // Finalize the output configurations with surfaces not added before. |
| 159 | virtual binder::Status finalizeOutputConfigurations(int32_t streamId, |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 160 | const hardware::camera2::params::OutputConfiguration &outputConfiguration) override; |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 161 | |
Yin-Chia Yeh | cfab4e1 | 2019-09-09 13:08:28 -0700 | [diff] [blame] | 162 | virtual binder::Status setCameraAudioRestriction(int32_t mode) override; |
| 163 | |
| 164 | virtual binder::Status getGlobalAudioRestriction(/*out*/int32_t* outMode) override; |
Yin-Chia Yeh | dba0323 | 2019-08-19 15:54:28 -0700 | [diff] [blame] | 165 | |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 166 | virtual binder::Status switchToOffline( |
| 167 | const sp<hardware::camera2::ICameraDeviceCallbacks>& cameraCb, |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame] | 168 | const std::vector<int>& offlineOutputIds, |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 169 | /*out*/ |
| 170 | sp<hardware::camera2::ICameraOfflineSession>* session) override; |
| 171 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 172 | /** |
| 173 | * Interface used by CameraService |
| 174 | */ |
| 175 | |
| 176 | CameraDeviceClient(const sp<CameraService>& cameraService, |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 177 | const sp<hardware::camera2::ICameraDeviceCallbacks>& remoteCallback, |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 178 | const String16& clientPackageName, |
Jooyung Han | b3f7cd2 | 2020-01-23 12:27:18 +0900 | [diff] [blame] | 179 | const std::optional<String16>& clientFeatureId, |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 180 | const String8& cameraId, |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 181 | int cameraFacing, |
| 182 | int clientPid, |
| 183 | uid_t clientUid, |
| 184 | int servicePid); |
| 185 | virtual ~CameraDeviceClient(); |
| 186 | |
Emilian Peev | bd8c503 | 2018-02-14 23:05:40 +0000 | [diff] [blame] | 187 | virtual status_t initialize(sp<CameraProviderManager> manager, |
| 188 | const String8& monitorTags) override; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 189 | |
Eino-Ville Talvala | f2e3709 | 2020-01-07 15:32:32 -0800 | [diff] [blame] | 190 | virtual status_t setRotateAndCropOverride(uint8_t rotateAndCrop) override; |
| 191 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 192 | virtual status_t dump(int fd, const Vector<String16>& args); |
| 193 | |
Eino-Ville Talvala | c400396 | 2016-01-13 10:07:04 -0800 | [diff] [blame] | 194 | virtual status_t dumpClient(int fd, const Vector<String16>& args); |
| 195 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 196 | /** |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 197 | * Device listener interface |
| 198 | */ |
| 199 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 200 | virtual void notifyIdle(int64_t requestCount, int64_t resultErrorCount, bool deviceError, |
| 201 | const std::vector<hardware::CameraStreamStats>& streamStats); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 202 | virtual void notifyError(int32_t errorCode, |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 203 | const CaptureResultExtras& resultExtras); |
| 204 | virtual void notifyShutter(const CaptureResultExtras& resultExtras, nsecs_t timestamp); |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 205 | virtual void notifyPrepared(int streamId); |
Shuzhen Wang | 9d06601 | 2016-09-30 11:30:20 -0700 | [diff] [blame] | 206 | virtual void notifyRequestQueueEmpty(); |
Chien-Yu Chen | e8c535e | 2016-04-14 12:18:26 -0700 | [diff] [blame] | 207 | virtual void notifyRepeatingRequestError(long lastFrameNumber); |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 208 | |
Shuzhen Wang | abbcb6b | 2020-12-09 22:32:44 -0800 | [diff] [blame] | 209 | void setImageDumpMask(int mask) { if (mDevice != nullptr) mDevice->setImageDumpMask(mask); } |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 210 | /** |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 211 | * Interface used by independent components of CameraDeviceClient. |
| 212 | */ |
| 213 | protected: |
| 214 | /** FilteredListener implementation **/ |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 215 | virtual void onResultAvailable(const CaptureResult& result); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 216 | virtual void detachDevice(); |
| 217 | |
Igor Murashkin | f8b2a6f | 2013-09-17 17:03:28 -0700 | [diff] [blame] | 218 | // Calculate the ANativeWindow transform from android.sensor.orientation |
| 219 | status_t getRotationTransformLocked(/*out*/int32_t* transform); |
| 220 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 221 | private: |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 222 | // StreamSurfaceId encapsulates streamId + surfaceId for a particular surface. |
| 223 | // streamId specifies the index of the stream the surface belongs to, and the |
| 224 | // surfaceId specifies the index of the surface within the stream. (one stream |
| 225 | // could contain multiple surfaces.) |
| 226 | class StreamSurfaceId final { |
| 227 | public: |
| 228 | StreamSurfaceId() { |
| 229 | mStreamId = -1; |
| 230 | mSurfaceId = -1; |
| 231 | } |
| 232 | StreamSurfaceId(int32_t streamId, int32_t surfaceId) { |
| 233 | mStreamId = streamId; |
| 234 | mSurfaceId = surfaceId; |
| 235 | } |
| 236 | int32_t streamId() const { |
| 237 | return mStreamId; |
| 238 | } |
| 239 | int32_t surfaceId() const { |
| 240 | return mSurfaceId; |
| 241 | } |
| 242 | |
| 243 | private: |
| 244 | int32_t mStreamId; |
| 245 | int32_t mSurfaceId; |
| 246 | |
| 247 | }; // class StreamSurfaceId |
| 248 | |
| 249 | private: |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 250 | /** ICameraDeviceUser interface-related private members */ |
| 251 | |
| 252 | /** Preview callback related members */ |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 253 | sp<camera2::FrameProcessorBase> mFrameProcessor; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 254 | |
Emilian Peev | 00420d2 | 2018-02-05 21:33:13 +0000 | [diff] [blame] | 255 | std::vector<int32_t> mSupportedPhysicalRequestKeys; |
| 256 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 257 | template<typename TProviderPtr> |
Emilian Peev | bd8c503 | 2018-02-14 23:05:40 +0000 | [diff] [blame] | 258 | status_t initializeImpl(TProviderPtr providerPtr, const String8& monitorTags); |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 259 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 260 | /** Utility members */ |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 261 | binder::Status checkPidStatus(const char* checkLocation); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 262 | bool enforceRequestPermissions(CameraMetadata& metadata); |
| 263 | |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 264 | // Create an output stream with surface deferred for future. |
| 265 | binder::Status createDeferredSurfaceStreamLocked( |
| 266 | const hardware::camera2::params::OutputConfiguration &outputConfiguration, |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 267 | bool isShared, |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 268 | int* newStreamId = NULL); |
| 269 | |
| 270 | // Set the stream transform flags to automatically rotate the camera stream for preview use |
| 271 | // cases. |
| 272 | binder::Status setStreamTransformLocked(int streamId); |
| 273 | |
Yin-Chia Yeh | 4dfa4cc | 2017-11-10 20:00:09 -0800 | [diff] [blame] | 274 | // Utility method to insert the surface into SurfaceMap |
| 275 | binder::Status insertGbpLocked(const sp<IGraphicBufferProducer>& gbp, |
Emilian Peev | f873aa5 | 2018-01-26 14:58:28 +0000 | [diff] [blame] | 276 | /*out*/SurfaceMap* surfaceMap, /*out*/Vector<int32_t>* streamIds, |
| 277 | /*out*/int32_t* currentStreamId); |
Yin-Chia Yeh | 4dfa4cc | 2017-11-10 20:00:09 -0800 | [diff] [blame] | 278 | |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 279 | // IGraphicsBufferProducer binder -> Stream ID + Surface ID for output streams |
| 280 | KeyedVector<sp<IBinder>, StreamSurfaceId> mStreamMap; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 281 | |
Yin-Chia Yeh | 4dfa4cc | 2017-11-10 20:00:09 -0800 | [diff] [blame] | 282 | // Stream ID -> OutputConfiguration. Used for looking up Surface by stream/surface index |
| 283 | KeyedVector<int32_t, hardware::camera2::params::OutputConfiguration> mConfiguredOutputs; |
| 284 | |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 285 | struct InputStreamConfiguration { |
| 286 | bool configured; |
| 287 | int32_t width; |
| 288 | int32_t height; |
| 289 | int32_t format; |
| 290 | int32_t id; |
| 291 | } mInputStream; |
| 292 | |
Chien-Yu Chen | e8c535e | 2016-04-14 12:18:26 -0700 | [diff] [blame] | 293 | // Streaming request ID |
| 294 | int32_t mStreamingRequestId; |
Shuzhen Wang | c9ca678 | 2016-04-26 13:40:31 -0700 | [diff] [blame] | 295 | Mutex mStreamingRequestIdLock; |
Chien-Yu Chen | e8c535e | 2016-04-14 12:18:26 -0700 | [diff] [blame] | 296 | static const int32_t REQUEST_ID_NONE = -1; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 297 | |
| 298 | int32_t mRequestIdCounter; |
Eino-Ville Talvala | 412fe56 | 2015-08-20 17:08:32 -0700 | [diff] [blame] | 299 | |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 300 | // The list of output streams whose surfaces are deferred. We have to track them separately |
| 301 | // as there are no surfaces available and can not be put into mStreamMap. Once the deferred |
| 302 | // Surface is configured, the stream id will be moved to mStreamMap. |
| 303 | Vector<int32_t> mDeferredStreams; |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 304 | |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 305 | // stream ID -> outputStreamInfo mapping |
| 306 | std::unordered_map<int32_t, OutputStreamInfo> mStreamInfoMap; |
| 307 | |
Emilian Peev | 538c90e | 2018-12-17 18:03:19 +0000 | [diff] [blame] | 308 | KeyedVector<sp<IBinder>, sp<CompositeStream>> mCompositeStreamMap; |
| 309 | |
Shuzhen Wang | 03d8cc1 | 2018-09-12 14:17:09 -0700 | [diff] [blame] | 310 | sp<CameraProviderManager> mProviderManager; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 311 | }; |
| 312 | |
| 313 | }; // namespace android |
| 314 | |
| 315 | #endif |