1 /* 2 * Copyright (C) 2015-2018 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_HARDWARE_CAMERA2_OUTPUTCONFIGURATION_H 18 #define ANDROID_HARDWARE_CAMERA2_OUTPUTCONFIGURATION_H 19 20 #include <gui/IGraphicBufferProducer.h> 21 #include <binder/Parcelable.h> 22 23 namespace android { 24 25 class Surface; 26 27 namespace hardware { 28 namespace camera2 { 29 namespace params { 30 31 class OutputConfiguration : public android::Parcelable { 32 public: 33 34 static const int INVALID_ROTATION; 35 static const int INVALID_SET_ID; 36 enum SurfaceType{ 37 SURFACE_TYPE_UNKNOWN = -1, 38 SURFACE_TYPE_SURFACE_VIEW = 0, 39 SURFACE_TYPE_SURFACE_TEXTURE = 1 40 }; 41 enum TimestampBaseType { 42 TIMESTAMP_BASE_DEFAULT = 0, 43 TIMESTAMP_BASE_SENSOR = 1, 44 TIMESTAMP_BASE_MONOTONIC = 2, 45 TIMESTAMP_BASE_REALTIME = 3, 46 TIMESTAMP_BASE_CHOREOGRAPHER_SYNCED = 4, 47 TIMESTAMP_BASE_MAX = TIMESTAMP_BASE_CHOREOGRAPHER_SYNCED, 48 }; 49 enum MirrorModeType { 50 MIRROR_MODE_AUTO = 0, 51 MIRROR_MODE_NONE = 1, 52 MIRROR_MODE_H = 2, 53 MIRROR_MODE_V = 3, 54 }; 55 56 const std::vector<sp<IGraphicBufferProducer>>& getGraphicBufferProducers() const; 57 int getRotation() const; 58 int getSurfaceSetID() const; 59 int getSurfaceType() const; 60 int getWidth() const; 61 int getHeight() const; 62 int64_t getDynamicRangeProfile() const; 63 int32_t getColorSpace() const; 64 bool isDeferred() const; 65 bool isShared() const; 66 String16 getPhysicalCameraId() const; 67 bool isMultiResolution() const; 68 int64_t getStreamUseCase() const; 69 int getTimestampBase() const; 70 int getMirrorMode() const; 71 bool useReadoutTimestamp() const; 72 73 // set of sensor pixel mode resolutions allowed {MAX_RESOLUTION, DEFAULT_MODE}; 74 const std::vector<int32_t>& getSensorPixelModesUsed() const; 75 /** 76 * Keep impl up-to-date with OutputConfiguration.java in frameworks/base 77 */ 78 virtual status_t writeToParcel(android::Parcel* parcel) const override; 79 80 virtual status_t readFromParcel(const android::Parcel* parcel) override; 81 82 // getGraphicBufferProducer will be NULL 83 // getRotation will be INVALID_ROTATION 84 // getSurfaceSetID will be INVALID_SET_ID 85 OutputConfiguration(); 86 87 // getGraphicBufferProducer will be NULL if error occurred 88 // getRotation will be INVALID_ROTATION if error occurred 89 // getSurfaceSetID will be INVALID_SET_ID if error occurred 90 OutputConfiguration(const android::Parcel& parcel); 91 92 OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation, 93 const String16& physicalCameraId, 94 int surfaceSetID = INVALID_SET_ID, bool isShared = false); 95 96 OutputConfiguration(const std::vector<sp<IGraphicBufferProducer>>& gbps, 97 int rotation, const String16& physicalCameraId, 98 int surfaceSetID = INVALID_SET_ID, 99 int surfaceType = OutputConfiguration::SURFACE_TYPE_UNKNOWN, int width = 0, 100 int height = 0, bool isShared = false); 101 102 bool operator == (const OutputConfiguration& other) const { 103 return ( mRotation == other.mRotation && 104 mSurfaceSetID == other.mSurfaceSetID && 105 mSurfaceType == other.mSurfaceType && 106 mWidth == other.mWidth && 107 mHeight == other.mHeight && 108 mIsDeferred == other.mIsDeferred && 109 mIsShared == other.mIsShared && 110 gbpsEqual(other) && 111 mPhysicalCameraId == other.mPhysicalCameraId && 112 mIsMultiResolution == other.mIsMultiResolution && 113 sensorPixelModesUsedEqual(other) && 114 mDynamicRangeProfile == other.mDynamicRangeProfile && 115 mColorSpace == other.mColorSpace && 116 mStreamUseCase == other.mStreamUseCase && 117 mTimestampBase == other.mTimestampBase && 118 mMirrorMode == other.mMirrorMode && 119 mUseReadoutTimestamp == other.mUseReadoutTimestamp); 120 } 121 bool operator != (const OutputConfiguration& other) const { 122 return !(*this == other); 123 } 124 bool operator < (const OutputConfiguration& other) const { 125 if (*this == other) return false; 126 if (mSurfaceSetID != other.mSurfaceSetID) { 127 return mSurfaceSetID < other.mSurfaceSetID; 128 } 129 if (mSurfaceType != other.mSurfaceType) { 130 return mSurfaceType < other.mSurfaceType; 131 } 132 if (mWidth != other.mWidth) { 133 return mWidth < other.mWidth; 134 } 135 if (mHeight != other.mHeight) { 136 return mHeight < other.mHeight; 137 } 138 if (mRotation != other.mRotation) { 139 return mRotation < other.mRotation; 140 } 141 if (mIsDeferred != other.mIsDeferred) { 142 return mIsDeferred < other.mIsDeferred; 143 } 144 if (mIsShared != other.mIsShared) { 145 return mIsShared < other.mIsShared; 146 } 147 if (mPhysicalCameraId != other.mPhysicalCameraId) { 148 return mPhysicalCameraId < other.mPhysicalCameraId; 149 } 150 if (mIsMultiResolution != other.mIsMultiResolution) { 151 return mIsMultiResolution < other.mIsMultiResolution; 152 } 153 if (!sensorPixelModesUsedEqual(other)) { 154 return sensorPixelModesUsedLessThan(other); 155 } 156 if (mDynamicRangeProfile != other.mDynamicRangeProfile) { 157 return mDynamicRangeProfile < other.mDynamicRangeProfile; 158 } 159 if (mColorSpace != other.mColorSpace) { 160 return mColorSpace < other.mColorSpace; 161 } 162 if (mStreamUseCase != other.mStreamUseCase) { 163 return mStreamUseCase < other.mStreamUseCase; 164 } 165 if (mTimestampBase != other.mTimestampBase) { 166 return mTimestampBase < other.mTimestampBase; 167 } 168 if (mMirrorMode != other.mMirrorMode) { 169 return mMirrorMode < other.mMirrorMode; 170 } 171 if (mUseReadoutTimestamp != other.mUseReadoutTimestamp) { 172 return mUseReadoutTimestamp < other.mUseReadoutTimestamp; 173 } 174 return gbpsLessThan(other); 175 } 176 177 bool operator > (const OutputConfiguration& other) const { 178 return (*this != other && !(*this < other)); 179 } 180 181 bool gbpsEqual(const OutputConfiguration& other) const; 182 bool sensorPixelModesUsedEqual(const OutputConfiguration& other) const; 183 bool sensorPixelModesUsedLessThan(const OutputConfiguration& other) const; 184 bool gbpsLessThan(const OutputConfiguration& other) const; addGraphicProducer(sp<IGraphicBufferProducer> gbp)185 void addGraphicProducer(sp<IGraphicBufferProducer> gbp) {mGbps.push_back(gbp);} 186 private: 187 std::vector<sp<IGraphicBufferProducer>> mGbps; 188 int mRotation; 189 int mSurfaceSetID; 190 int mSurfaceType; 191 int mWidth; 192 int mHeight; 193 bool mIsDeferred; 194 bool mIsShared; 195 String16 mPhysicalCameraId; 196 bool mIsMultiResolution; 197 std::vector<int32_t> mSensorPixelModesUsed; 198 int64_t mDynamicRangeProfile; 199 int32_t mColorSpace; 200 int64_t mStreamUseCase; 201 int mTimestampBase; 202 int mMirrorMode; 203 bool mUseReadoutTimestamp; 204 }; 205 } // namespace params 206 } // namespace camera2 207 } // namespace hardware 208 209 210 using hardware::camera2::params::OutputConfiguration; 211 212 }; // namespace android 213 214 #endif 215