blob: 2961e2a529f1180a4600de43c69a3e01b56cab33 [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;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070047 /**
48 * Keep impl up-to-date with OutputConfiguration.java in frameworks/base
49 */
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080050 virtual status_t writeToParcel(android::Parcel* parcel) const override;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080051
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080052 virtual status_t readFromParcel(const android::Parcel* parcel) override;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080053
54 // getGraphicBufferProducer will be NULL
55 // getRotation will be INVALID_ROTATION
56 // getSurfaceSetID will be INVALID_SET_ID
57 OutputConfiguration();
58
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070059 // getGraphicBufferProducer will be NULL if error occurred
60 // getRotation will be INVALID_ROTATION if error occurred
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080061 // getSurfaceSetID will be INVALID_SET_ID if error occurred
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080062 OutputConfiguration(const android::Parcel& parcel);
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070063
Zhijun He018107a2016-01-18 15:32:50 -080064 OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation,
65 int surfaceSetID = INVALID_SET_ID);
Ruben Brunk3450ba72015-06-16 11:00:37 -070066
Yin-Chia Yehead91462016-01-06 16:45:08 -080067 bool operator == (const OutputConfiguration& other) const {
Shuzhen Wang0129d522016-10-30 22:43:41 -070068 return ( mRotation == other.mRotation &&
Zhijun He5d677d12016-05-29 16:52:39 -070069 mSurfaceSetID == other.mSurfaceSetID &&
70 mSurfaceType == other.mSurfaceType &&
71 mWidth == other.mWidth &&
Shuzhen Wang0129d522016-10-30 22:43:41 -070072 mHeight == other.mHeight &&
73 gbpsEqual(other));
Yin-Chia Yehead91462016-01-06 16:45:08 -080074 }
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;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080080 if (mSurfaceSetID != other.mSurfaceSetID) {
81 return mSurfaceSetID < other.mSurfaceSetID;
82 }
Zhijun He5d677d12016-05-29 16:52:39 -070083 if (mSurfaceType != other.mSurfaceType) {
84 return mSurfaceType < other.mSurfaceType;
85 }
86 if (mWidth != other.mWidth) {
87 return mWidth < other.mWidth;
88 }
89 if (mHeight != other.mHeight) {
90 return mHeight < other.mHeight;
91 }
Shuzhen Wang0129d522016-10-30 22:43:41 -070092 if (mRotation != other.mRotation) {
93 return mRotation < other.mRotation;
94 }
Zhijun He5d677d12016-05-29 16:52:39 -070095
Shuzhen Wang0129d522016-10-30 22:43:41 -070096 return gbpsLessThan(other);
Yin-Chia Yehead91462016-01-06 16:45:08 -080097 }
98 bool operator > (const OutputConfiguration& other) const {
99 return (*this != other && !(*this < other));
100 }
101
Shuzhen Wang0129d522016-10-30 22:43:41 -0700102 bool gbpsEqual(const OutputConfiguration& other) const;
103 bool gbpsLessThan(const OutputConfiguration& other) const;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700104private:
Shuzhen Wang0129d522016-10-30 22:43:41 -0700105 std::vector<sp<IGraphicBufferProducer>> mGbps;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700106 int mRotation;
Zhijun He018107a2016-01-18 15:32:50 -0800107 int mSurfaceSetID;
Zhijun He5d677d12016-05-29 16:52:39 -0700108 int mSurfaceType;
109 int mWidth;
110 int mHeight;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700111 // helper function
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800112 static String16 readMaybeEmptyString16(const android::Parcel* parcel);
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700113};
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800114} // namespace params
115} // namespace camera2
116} // namespace hardware
117
118
119using hardware::camera2::params::OutputConfiguration;
120
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700121}; // namespace android
122
123#endif