blob: 137d98c37291382cf4718f18978e26b7a7acfdfc [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>
21
22namespace android {
23
24class Surface;
25
Yin-Chia Yehead91462016-01-06 16:45:08 -080026class OutputConfiguration {
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070027public:
28
29 static const int INVALID_ROTATION;
Zhijun He018107a2016-01-18 15:32:50 -080030 static const int INVALID_SET_ID;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070031 sp<IGraphicBufferProducer> getGraphicBufferProducer() const;
32 int getRotation() const;
Zhijun He018107a2016-01-18 15:32:50 -080033 int getSurfaceSetID() const;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070034
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 He018107a2016-01-18 15:32:50 -080043 OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation,
44 int surfaceSetID = INVALID_SET_ID);
Ruben Brunk3450ba72015-06-16 11:00:37 -070045
Yin-Chia Yehead91462016-01-06 16:45:08 -080046 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 Yehb97babb2015-03-12 13:42:44 -070062private:
63 sp<IGraphicBufferProducer> mGbp;
64 int mRotation;
Zhijun He018107a2016-01-18 15:32:50 -080065 int mSurfaceSetID;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070066 // helper function
67 static String16 readMaybeEmptyString16(const Parcel& parcel);
68};
69}; // namespace android
70
71#endif