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