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 | }; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 41 | sp<IGraphicBufferProducer> getGraphicBufferProducer() const; |
| 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; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 47 | /** |
| 48 | * Keep impl up-to-date with OutputConfiguration.java in frameworks/base |
| 49 | */ |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 50 | virtual status_t writeToParcel(android::Parcel* parcel) const override; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 51 | |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 52 | virtual status_t readFromParcel(const android::Parcel* parcel) override; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 53 | |
| 54 | // getGraphicBufferProducer will be NULL |
| 55 | // getRotation will be INVALID_ROTATION |
| 56 | // getSurfaceSetID will be INVALID_SET_ID |
| 57 | OutputConfiguration(); |
| 58 | |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 59 | // getGraphicBufferProducer will be NULL if error occurred |
| 60 | // getRotation will be INVALID_ROTATION if error occurred |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 61 | // getSurfaceSetID will be INVALID_SET_ID if error occurred |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 62 | OutputConfiguration(const android::Parcel& parcel); |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 63 | |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 64 | OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation, |
| 65 | int surfaceSetID = INVALID_SET_ID); |
Ruben Brunk | 3450ba7 | 2015-06-16 11:00:37 -0700 | [diff] [blame] | 66 | |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 67 | bool operator == (const OutputConfiguration& other) const { |
| 68 | return (mGbp == other.mGbp && |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 69 | mRotation == other.mRotation && |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 70 | mSurfaceSetID == other.mSurfaceSetID && |
| 71 | mSurfaceType == other.mSurfaceType && |
| 72 | mWidth == other.mWidth && |
| 73 | mHeight == other.mHeight); |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 74 | } |
| 75 | bool operator != (const OutputConfiguration& other) const { |
| 76 | return !(*this == other); |
| 77 | } |
| 78 | bool operator < (const OutputConfiguration& other) const { |
| 79 | if (*this == other) return false; |
| 80 | if (mGbp != other.mGbp) return mGbp < other.mGbp; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 81 | if (mSurfaceSetID != other.mSurfaceSetID) { |
| 82 | return mSurfaceSetID < other.mSurfaceSetID; |
| 83 | } |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 84 | if (mSurfaceType != other.mSurfaceType) { |
| 85 | return mSurfaceType < other.mSurfaceType; |
| 86 | } |
| 87 | if (mWidth != other.mWidth) { |
| 88 | return mWidth < other.mWidth; |
| 89 | } |
| 90 | if (mHeight != other.mHeight) { |
| 91 | return mHeight < other.mHeight; |
| 92 | } |
| 93 | |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 94 | return mRotation < other.mRotation; |
| 95 | } |
| 96 | bool operator > (const OutputConfiguration& other) const { |
| 97 | return (*this != other && !(*this < other)); |
| 98 | } |
| 99 | |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 100 | private: |
| 101 | sp<IGraphicBufferProducer> mGbp; |
| 102 | int mRotation; |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 103 | int mSurfaceSetID; |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 104 | int mSurfaceType; |
| 105 | int mWidth; |
| 106 | int mHeight; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 107 | // helper function |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 108 | static String16 readMaybeEmptyString16(const android::Parcel* parcel); |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 109 | }; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 110 | } // namespace params |
| 111 | } // namespace camera2 |
| 112 | } // namespace hardware |
| 113 | |
| 114 | |
| 115 | using hardware::camera2::params::OutputConfiguration; |
| 116 | |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 117 | }; // namespace android |
| 118 | |
| 119 | #endif |