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> |
| 21 | |
| 22 | namespace android { |
| 23 | |
| 24 | class Surface; |
| 25 | |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 26 | class OutputConfiguration { |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 27 | public: |
| 28 | |
| 29 | static const int INVALID_ROTATION; |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 30 | static const int INVALID_SET_ID; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 31 | sp<IGraphicBufferProducer> getGraphicBufferProducer() const; |
| 32 | int getRotation() const; |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 33 | int getSurfaceSetID() const; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * Keep impl up-to-date with OutputConfiguration.java in frameworks/base |
| 37 | */ |
| 38 | status_t writeToParcel(Parcel& parcel) const; |
| 39 | // getGraphicBufferProducer will be NULL if error occurred |
| 40 | // getRotation will be INVALID_ROTATION if error occurred |
| 41 | OutputConfiguration(const Parcel& parcel); |
| 42 | |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 43 | OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation, |
| 44 | int surfaceSetID = INVALID_SET_ID); |
Ruben Brunk | 3450ba7 | 2015-06-16 11:00:37 -0700 | [diff] [blame] | 45 | |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 46 | bool operator == (const OutputConfiguration& other) const { |
| 47 | return (mGbp == other.mGbp && |
| 48 | mRotation == other.mRotation); |
| 49 | } |
| 50 | bool operator != (const OutputConfiguration& other) const { |
| 51 | return !(*this == other); |
| 52 | } |
| 53 | bool operator < (const OutputConfiguration& other) const { |
| 54 | if (*this == other) return false; |
| 55 | if (mGbp != other.mGbp) return mGbp < other.mGbp; |
| 56 | return mRotation < other.mRotation; |
| 57 | } |
| 58 | bool operator > (const OutputConfiguration& other) const { |
| 59 | return (*this != other && !(*this < other)); |
| 60 | } |
| 61 | |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 62 | private: |
| 63 | sp<IGraphicBufferProducer> mGbp; |
| 64 | int mRotation; |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 65 | int mSurfaceSetID; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 66 | // helper function |
| 67 | static String16 readMaybeEmptyString16(const Parcel& parcel); |
| 68 | }; |
| 69 | }; // namespace android |
| 70 | |
| 71 | #endif |