blob: 8e641c7d92fc5fa143e9a562abb03293bc91241e [file] [log] [blame]
Yin-Chia Yehb97babb2015-03-12 13:42:44 -07001/*
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 Yehb97babb2015-03-12 13:42:44 -070020#include <gui/IGraphicBufferProducer.h>
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080021#include <binder/Parcelable.h>
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070022
23namespace android {
24
25class Surface;
26
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080027namespace hardware {
28namespace camera2 {
29namespace params {
30
31class OutputConfiguration : public android::Parcelable {
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070032public:
33
34 static const int INVALID_ROTATION;
Zhijun He018107a2016-01-18 15:32:50 -080035 static const int INVALID_SET_ID;
Zhijun He5d677d12016-05-29 16:52:39 -070036 enum SurfaceType{
37 SURFACE_TYPE_UNKNOWN = -1,
38 SURFACE_TYPE_SURFACE_VIEW = 0,
39 SURFACE_TYPE_SURFACE_TEXTURE = 1
40 };
Shuzhen Wang0129d522016-10-30 22:43:41 -070041 const std::vector<sp<IGraphicBufferProducer>>& getGraphicBufferProducers() const;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070042 int getRotation() const;
Zhijun He018107a2016-01-18 15:32:50 -080043 int getSurfaceSetID() const;
Zhijun He5d677d12016-05-29 16:52:39 -070044 int getSurfaceType() const;
45 int getWidth() const;
46 int getHeight() const;
Shuzhen Wang758c2152017-01-10 18:26:18 -080047 bool isDeferred() const;
48 bool isShared() const;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070049 /**
50 * Keep impl up-to-date with OutputConfiguration.java in frameworks/base
51 */
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080052 virtual status_t writeToParcel(android::Parcel* parcel) const override;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080053
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080054 virtual status_t readFromParcel(const android::Parcel* parcel) override;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080055
56 // getGraphicBufferProducer will be NULL
57 // getRotation will be INVALID_ROTATION
58 // getSurfaceSetID will be INVALID_SET_ID
59 OutputConfiguration();
60
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070061 // getGraphicBufferProducer will be NULL if error occurred
62 // getRotation will be INVALID_ROTATION if error occurred
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080063 // getSurfaceSetID will be INVALID_SET_ID if error occurred
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080064 OutputConfiguration(const android::Parcel& parcel);
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070065
Zhijun He018107a2016-01-18 15:32:50 -080066 OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation,
67 int surfaceSetID = INVALID_SET_ID);
Ruben Brunk3450ba72015-06-16 11:00:37 -070068
Yin-Chia Yehead91462016-01-06 16:45:08 -080069 bool operator == (const OutputConfiguration& other) const {
Shuzhen Wang0129d522016-10-30 22:43:41 -070070 return ( mRotation == other.mRotation &&
Zhijun He5d677d12016-05-29 16:52:39 -070071 mSurfaceSetID == other.mSurfaceSetID &&
72 mSurfaceType == other.mSurfaceType &&
73 mWidth == other.mWidth &&
Shuzhen Wang0129d522016-10-30 22:43:41 -070074 mHeight == other.mHeight &&
Shuzhen Wang758c2152017-01-10 18:26:18 -080075 mIsDeferred == other.mIsDeferred &&
76 mIsShared == other.mIsShared &&
Shuzhen Wang0129d522016-10-30 22:43:41 -070077 gbpsEqual(other));
Yin-Chia Yehead91462016-01-06 16:45:08 -080078 }
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 Talvalad56db1d2015-12-17 16:50:35 -080084 if (mSurfaceSetID != other.mSurfaceSetID) {
85 return mSurfaceSetID < other.mSurfaceSetID;
86 }
Zhijun He5d677d12016-05-29 16:52:39 -070087 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 Wang0129d522016-10-30 22:43:41 -070096 if (mRotation != other.mRotation) {
97 return mRotation < other.mRotation;
98 }
Shuzhen Wang758c2152017-01-10 18:26:18 -080099 if (mIsDeferred != other.mIsDeferred) {
100 return mIsDeferred < other.mIsDeferred;
101 }
102 if (mIsShared != other.mIsShared) {
103 return mIsShared < other.mIsShared;
104 }
Shuzhen Wang0129d522016-10-30 22:43:41 -0700105 return gbpsLessThan(other);
Yin-Chia Yehead91462016-01-06 16:45:08 -0800106 }
107 bool operator > (const OutputConfiguration& other) const {
108 return (*this != other && !(*this < other));
109 }
110
Shuzhen Wang0129d522016-10-30 22:43:41 -0700111 bool gbpsEqual(const OutputConfiguration& other) const;
112 bool gbpsLessThan(const OutputConfiguration& other) const;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700113private:
Shuzhen Wang0129d522016-10-30 22:43:41 -0700114 std::vector<sp<IGraphicBufferProducer>> mGbps;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700115 int mRotation;
Zhijun He018107a2016-01-18 15:32:50 -0800116 int mSurfaceSetID;
Zhijun He5d677d12016-05-29 16:52:39 -0700117 int mSurfaceType;
118 int mWidth;
119 int mHeight;
Shuzhen Wang758c2152017-01-10 18:26:18 -0800120 bool mIsDeferred;
121 bool mIsShared;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700122 // helper function
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800123 static String16 readMaybeEmptyString16(const android::Parcel* parcel);
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700124};
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800125} // namespace params
126} // namespace camera2
127} // namespace hardware
128
129
130using hardware::camera2::params::OutputConfiguration;
131
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700132}; // namespace android
133
134#endif