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