Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 20 | #include <gui/IGraphicBufferProducer.h> |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 21 | #include <binder/Parcelable.h> |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 22 | |
| 23 | namespace android { |
| 24 | |
| 25 | class Surface; |
| 26 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 27 | namespace hardware { |
| 28 | namespace camera2 { |
| 29 | namespace params { |
| 30 | |
| 31 | class OutputConfiguration : public android::Parcelable { |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 32 | public: |
| 33 | |
| 34 | static const int INVALID_ROTATION; |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 35 | static const int INVALID_SET_ID; |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 36 | enum SurfaceType{ |
| 37 | SURFACE_TYPE_UNKNOWN = -1, |
| 38 | SURFACE_TYPE_SURFACE_VIEW = 0, |
| 39 | SURFACE_TYPE_SURFACE_TEXTURE = 1 |
| 40 | }; |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 41 | const std::vector<sp<IGraphicBufferProducer>>& getGraphicBufferProducers() const; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 42 | int getRotation() const; |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 43 | int getSurfaceSetID() const; |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 44 | int getSurfaceType() const; |
| 45 | int getWidth() const; |
| 46 | int getHeight() const; |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 47 | bool isDeferred() const; |
| 48 | bool isShared() const; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 49 | /** |
| 50 | * Keep impl up-to-date with OutputConfiguration.java in frameworks/base |
| 51 | */ |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 52 | virtual status_t writeToParcel(android::Parcel* parcel) const override; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 53 | |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 54 | virtual status_t readFromParcel(const android::Parcel* parcel) override; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 55 | |
| 56 | // getGraphicBufferProducer will be NULL |
| 57 | // getRotation will be INVALID_ROTATION |
| 58 | // getSurfaceSetID will be INVALID_SET_ID |
| 59 | OutputConfiguration(); |
| 60 | |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 61 | // getGraphicBufferProducer will be NULL if error occurred |
| 62 | // getRotation will be INVALID_ROTATION if error occurred |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 63 | // getSurfaceSetID will be INVALID_SET_ID if error occurred |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 64 | OutputConfiguration(const android::Parcel& parcel); |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 65 | |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 66 | OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation, |
| 67 | int surfaceSetID = INVALID_SET_ID); |
Ruben Brunk | 3450ba7 | 2015-06-16 11:00:37 -0700 | [diff] [blame] | 68 | |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 69 | bool operator == (const OutputConfiguration& other) const { |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 70 | return ( mRotation == other.mRotation && |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 71 | mSurfaceSetID == other.mSurfaceSetID && |
| 72 | mSurfaceType == other.mSurfaceType && |
| 73 | mWidth == other.mWidth && |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 74 | mHeight == other.mHeight && |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 75 | mIsDeferred == other.mIsDeferred && |
| 76 | mIsShared == other.mIsShared && |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 77 | gbpsEqual(other)); |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 78 | } |
| 79 | bool operator != (const OutputConfiguration& other) const { |
| 80 | return !(*this == other); |
| 81 | } |
| 82 | bool operator < (const OutputConfiguration& other) const { |
| 83 | if (*this == other) return false; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 84 | if (mSurfaceSetID != other.mSurfaceSetID) { |
| 85 | return mSurfaceSetID < other.mSurfaceSetID; |
| 86 | } |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 87 | if (mSurfaceType != other.mSurfaceType) { |
| 88 | return mSurfaceType < other.mSurfaceType; |
| 89 | } |
| 90 | if (mWidth != other.mWidth) { |
| 91 | return mWidth < other.mWidth; |
| 92 | } |
| 93 | if (mHeight != other.mHeight) { |
| 94 | return mHeight < other.mHeight; |
| 95 | } |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 96 | if (mRotation != other.mRotation) { |
| 97 | return mRotation < other.mRotation; |
| 98 | } |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 99 | if (mIsDeferred != other.mIsDeferred) { |
| 100 | return mIsDeferred < other.mIsDeferred; |
| 101 | } |
| 102 | if (mIsShared != other.mIsShared) { |
| 103 | return mIsShared < other.mIsShared; |
| 104 | } |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 105 | return gbpsLessThan(other); |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 106 | } |
| 107 | bool operator > (const OutputConfiguration& other) const { |
| 108 | return (*this != other && !(*this < other)); |
| 109 | } |
| 110 | |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 111 | bool gbpsEqual(const OutputConfiguration& other) const; |
| 112 | bool gbpsLessThan(const OutputConfiguration& other) const; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 113 | private: |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 114 | std::vector<sp<IGraphicBufferProducer>> mGbps; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 115 | int mRotation; |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 116 | int mSurfaceSetID; |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 117 | int mSurfaceType; |
| 118 | int mWidth; |
| 119 | int mHeight; |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 120 | bool mIsDeferred; |
| 121 | bool mIsShared; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 122 | // helper function |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 123 | static String16 readMaybeEmptyString16(const android::Parcel* parcel); |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 124 | }; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 125 | } // namespace params |
| 126 | } // namespace camera2 |
| 127 | } // namespace hardware |
| 128 | |
| 129 | |
| 130 | using hardware::camera2::params::OutputConfiguration; |
| 131 | |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 132 | }; // namespace android |
| 133 | |
| 134 | #endif |