• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015-2018 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 
20 #include <gui/IGraphicBufferProducer.h>
21 #include <binder/Parcelable.h>
22 
23 namespace android {
24 
25 class Surface;
26 
27 namespace hardware {
28 namespace camera2 {
29 namespace params {
30 
31 class OutputConfiguration : public android::Parcelable {
32 public:
33 
34     static const int INVALID_ROTATION;
35     static const int INVALID_SET_ID;
36     enum SurfaceType{
37         SURFACE_TYPE_UNKNOWN = -1,
38         SURFACE_TYPE_SURFACE_VIEW = 0,
39         SURFACE_TYPE_SURFACE_TEXTURE = 1
40     };
41     const std::vector<sp<IGraphicBufferProducer>>& getGraphicBufferProducers() const;
42     int                        getRotation() const;
43     int                        getSurfaceSetID() const;
44     int                        getSurfaceType() const;
45     int                        getWidth() const;
46     int                        getHeight() const;
47     bool                       isDeferred() const;
48     bool                       isShared() const;
49     String16                   getPhysicalCameraId() const;
50     /**
51      * Keep impl up-to-date with OutputConfiguration.java in frameworks/base
52      */
53     virtual status_t           writeToParcel(android::Parcel* parcel) const override;
54 
55     virtual status_t           readFromParcel(const android::Parcel* parcel) override;
56 
57     // getGraphicBufferProducer will be NULL
58     // getRotation will be INVALID_ROTATION
59     // getSurfaceSetID will be INVALID_SET_ID
60     OutputConfiguration();
61 
62     // getGraphicBufferProducer will be NULL if error occurred
63     // getRotation will be INVALID_ROTATION if error occurred
64     // getSurfaceSetID will be INVALID_SET_ID if error occurred
65     OutputConfiguration(const android::Parcel& parcel);
66 
67     OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation,
68             const String16& physicalCameraId,
69             int surfaceSetID = INVALID_SET_ID, bool isShared = false);
70 
71     OutputConfiguration(const std::vector<sp<IGraphicBufferProducer>>& gbps,
72                         int rotation, const String16& physicalCameraId,
73                         int surfaceSetID = INVALID_SET_ID,
74                         int surfaceType = OutputConfiguration::SURFACE_TYPE_UNKNOWN, int width = 0,
75                         int height = 0, bool isShared = false);
76 
77     bool operator == (const OutputConfiguration& other) const {
78         return ( mRotation == other.mRotation &&
79                 mSurfaceSetID == other.mSurfaceSetID &&
80                 mSurfaceType == other.mSurfaceType &&
81                 mWidth == other.mWidth &&
82                 mHeight == other.mHeight &&
83                 mIsDeferred == other.mIsDeferred &&
84                 mIsShared == other.mIsShared &&
85                 gbpsEqual(other) &&
86                 mPhysicalCameraId == other.mPhysicalCameraId );
87     }
88     bool operator != (const OutputConfiguration& other) const {
89         return !(*this == other);
90     }
91     bool operator < (const OutputConfiguration& other) const {
92         if (*this == other) return false;
93         if (mSurfaceSetID != other.mSurfaceSetID) {
94             return mSurfaceSetID < other.mSurfaceSetID;
95         }
96         if (mSurfaceType != other.mSurfaceType) {
97             return mSurfaceType < other.mSurfaceType;
98         }
99         if (mWidth != other.mWidth) {
100             return mWidth < other.mWidth;
101         }
102         if (mHeight != other.mHeight) {
103             return mHeight < other.mHeight;
104         }
105         if (mRotation != other.mRotation) {
106             return mRotation < other.mRotation;
107         }
108         if (mIsDeferred != other.mIsDeferred) {
109             return mIsDeferred < other.mIsDeferred;
110         }
111         if (mIsShared != other.mIsShared) {
112             return mIsShared < other.mIsShared;
113         }
114         if (mPhysicalCameraId != other.mPhysicalCameraId) {
115             return mPhysicalCameraId < other.mPhysicalCameraId;
116         }
117         return gbpsLessThan(other);
118     }
119     bool operator > (const OutputConfiguration& other) const {
120         return (*this != other && !(*this < other));
121     }
122 
123     bool gbpsEqual(const OutputConfiguration& other) const;
124     bool gbpsLessThan(const OutputConfiguration& other) const;
addGraphicProducer(sp<IGraphicBufferProducer> gbp)125     void addGraphicProducer(sp<IGraphicBufferProducer> gbp) {mGbps.push_back(gbp);}
126 private:
127     std::vector<sp<IGraphicBufferProducer>> mGbps;
128     int                        mRotation;
129     int                        mSurfaceSetID;
130     int                        mSurfaceType;
131     int                        mWidth;
132     int                        mHeight;
133     bool                       mIsDeferred;
134     bool                       mIsShared;
135     String16                   mPhysicalCameraId;
136 };
137 } // namespace params
138 } // namespace camera2
139 } // namespace hardware
140 
141 
142 using hardware::camera2::params::OutputConfiguration;
143 
144 }; // namespace android
145 
146 #endif
147