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_READOUT_SENSOR = 5, 48 TIMESTAMP_BASE_MAX = TIMESTAMP_BASE_READOUT_SENSOR, 49 }; 50 enum MirrorModeType { 51 MIRROR_MODE_AUTO = 0, 52 MIRROR_MODE_NONE = 1, 53 MIRROR_MODE_H = 2, 54 MIRROR_MODE_V = 3, 55 }; 56 57 const std::vector<sp<IGraphicBufferProducer>>& getGraphicBufferProducers() const; 58 int getRotation() const; 59 int getSurfaceSetID() const; 60 int getSurfaceType() const; 61 int getWidth() const; 62 int getHeight() const; 63 int64_t getDynamicRangeProfile() 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 72 // set of sensor pixel mode resolutions allowed {MAX_RESOLUTION, DEFAULT_MODE}; 73 const std::vector<int32_t>& getSensorPixelModesUsed() const; 74 /** 75 * Keep impl up-to-date with OutputConfiguration.java in frameworks/base 76 */ 77 virtual status_t writeToParcel(android::Parcel* parcel) const override; 78 79 virtual status_t readFromParcel(const android::Parcel* parcel) override; 80 81 // getGraphicBufferProducer will be NULL 82 // getRotation will be INVALID_ROTATION 83 // getSurfaceSetID will be INVALID_SET_ID 84 OutputConfiguration(); 85 86 // getGraphicBufferProducer will be NULL if error occurred 87 // getRotation will be INVALID_ROTATION if error occurred 88 // getSurfaceSetID will be INVALID_SET_ID if error occurred 89 OutputConfiguration(const android::Parcel& parcel); 90 91 OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation, 92 const String16& physicalCameraId, 93 int surfaceSetID = INVALID_SET_ID, bool isShared = false); 94 95 OutputConfiguration(const std::vector<sp<IGraphicBufferProducer>>& gbps, 96 int rotation, const String16& physicalCameraId, 97 int surfaceSetID = INVALID_SET_ID, 98 int surfaceType = OutputConfiguration::SURFACE_TYPE_UNKNOWN, int width = 0, 99 int height = 0, bool isShared = false); 100 101 bool operator == (const OutputConfiguration& other) const { 102 return ( mRotation == other.mRotation && 103 mSurfaceSetID == other.mSurfaceSetID && 104 mSurfaceType == other.mSurfaceType && 105 mWidth == other.mWidth && 106 mHeight == other.mHeight && 107 mIsDeferred == other.mIsDeferred && 108 mIsShared == other.mIsShared && 109 gbpsEqual(other) && 110 mPhysicalCameraId == other.mPhysicalCameraId && 111 mIsMultiResolution == other.mIsMultiResolution && 112 sensorPixelModesUsedEqual(other) && 113 mDynamicRangeProfile == other.mDynamicRangeProfile && 114 mStreamUseCase == other.mStreamUseCase && 115 mTimestampBase == other.mTimestampBase && 116 mMirrorMode == other.mMirrorMode); 117 } 118 bool operator != (const OutputConfiguration& other) const { 119 return !(*this == other); 120 } 121 bool operator < (const OutputConfiguration& other) const { 122 if (*this == other) return false; 123 if (mSurfaceSetID != other.mSurfaceSetID) { 124 return mSurfaceSetID < other.mSurfaceSetID; 125 } 126 if (mSurfaceType != other.mSurfaceType) { 127 return mSurfaceType < other.mSurfaceType; 128 } 129 if (mWidth != other.mWidth) { 130 return mWidth < other.mWidth; 131 } 132 if (mHeight != other.mHeight) { 133 return mHeight < other.mHeight; 134 } 135 if (mRotation != other.mRotation) { 136 return mRotation < other.mRotation; 137 } 138 if (mIsDeferred != other.mIsDeferred) { 139 return mIsDeferred < other.mIsDeferred; 140 } 141 if (mIsShared != other.mIsShared) { 142 return mIsShared < other.mIsShared; 143 } 144 if (mPhysicalCameraId != other.mPhysicalCameraId) { 145 return mPhysicalCameraId < other.mPhysicalCameraId; 146 } 147 if (mIsMultiResolution != other.mIsMultiResolution) { 148 return mIsMultiResolution < other.mIsMultiResolution; 149 } 150 if (!sensorPixelModesUsedEqual(other)) { 151 return sensorPixelModesUsedLessThan(other); 152 } 153 if (mDynamicRangeProfile != other.mDynamicRangeProfile) { 154 return mDynamicRangeProfile < other.mDynamicRangeProfile; 155 } 156 if (mStreamUseCase != other.mStreamUseCase) { 157 return mStreamUseCase < other.mStreamUseCase; 158 } 159 if (mTimestampBase != other.mTimestampBase) { 160 return mTimestampBase < other.mTimestampBase; 161 } 162 if (mMirrorMode != other.mMirrorMode) { 163 return mMirrorMode < other.mMirrorMode; 164 } 165 return gbpsLessThan(other); 166 } 167 168 bool operator > (const OutputConfiguration& other) const { 169 return (*this != other && !(*this < other)); 170 } 171 172 bool gbpsEqual(const OutputConfiguration& other) const; 173 bool sensorPixelModesUsedEqual(const OutputConfiguration& other) const; 174 bool sensorPixelModesUsedLessThan(const OutputConfiguration& other) const; 175 bool gbpsLessThan(const OutputConfiguration& other) const; addGraphicProducer(sp<IGraphicBufferProducer> gbp)176 void addGraphicProducer(sp<IGraphicBufferProducer> gbp) {mGbps.push_back(gbp);} 177 private: 178 std::vector<sp<IGraphicBufferProducer>> mGbps; 179 int mRotation; 180 int mSurfaceSetID; 181 int mSurfaceType; 182 int mWidth; 183 int mHeight; 184 bool mIsDeferred; 185 bool mIsShared; 186 String16 mPhysicalCameraId; 187 bool mIsMultiResolution; 188 std::vector<int32_t> mSensorPixelModesUsed; 189 int64_t mDynamicRangeProfile; 190 int64_t mStreamUseCase; 191 int mTimestampBase; 192 int mMirrorMode; 193 }; 194 } // namespace params 195 } // namespace camera2 196 } // namespace hardware 197 198 199 using hardware::camera2::params::OutputConfiguration; 200 201 }; // namespace android 202 203 #endif 204