• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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_SESSIONCONFIGURATION_H
18 #define ANDROID_HARDWARE_CAMERA2_SESSIONCONFIGURATION_H
19 
20 #include <binder/Parcelable.h>
21 
22 namespace android {
23 
24 namespace hardware {
25 namespace camera2 {
26 namespace params {
27 
28 class OutputConfiguration;
29 
30 class SessionConfiguration : public android::Parcelable {
31 public:
32 
getOutputConfigurations()33     const std::vector<OutputConfiguration>& getOutputConfigurations() const {
34         return mOutputStreams;
35     }
36 
getInputWidth()37     int getInputWidth() const { return mInputWidth; }
getInputHeight()38     int getInputHeight() const { return mInputHeight; }
getInputFormat()39     int getInputFormat() const { return mInputFormat; }
getOperatingMode()40     int getOperatingMode() const { return mOperatingMode; }
inputIsMultiResolution()41     bool inputIsMultiResolution() const { return mInputIsMultiResolution; }
42 
43     virtual status_t writeToParcel(android::Parcel* parcel) const override;
44     virtual status_t readFromParcel(const android::Parcel* parcel) override;
45 
SessionConfiguration()46     SessionConfiguration() :
47             mInputWidth(0),
48             mInputHeight(0),
49             mInputFormat(-1),
50             mOperatingMode(-1) {}
51 
SessionConfiguration(const android::Parcel & parcel)52     SessionConfiguration(const android::Parcel& parcel) {
53         readFromParcel(&parcel);
54     }
55 
SessionConfiguration(int inputWidth,int inputHeight,int inputFormat,int operatingMode)56     SessionConfiguration(int inputWidth, int inputHeight, int inputFormat, int operatingMode) :
57         mInputWidth(inputWidth), mInputHeight(inputHeight), mInputFormat(inputFormat),
58         mOperatingMode(operatingMode) {}
59 
60     bool operator == (const SessionConfiguration& other) const {
61         return (outputsEqual(other) &&
62                 mInputWidth == other.mInputWidth &&
63                 mInputHeight == other.mInputHeight &&
64                 mInputFormat == other.mInputFormat &&
65                 mOperatingMode == other.mOperatingMode &&
66                 mInputIsMultiResolution == other.mInputIsMultiResolution);
67     }
68 
69     bool operator != (const SessionConfiguration& other) const {
70         return !(*this == other);
71     }
72 
73     bool operator < (const SessionConfiguration& other) const {
74         if (*this == other) return false;
75 
76         if (mInputWidth != other.mInputWidth) {
77             return mInputWidth < other.mInputWidth;
78         }
79 
80         if (mInputHeight != other.mInputHeight) {
81             return mInputHeight < other.mInputHeight;
82         }
83 
84         if (mInputFormat != other.mInputFormat) {
85             return mInputFormat < other.mInputFormat;
86         }
87 
88         if (mInputIsMultiResolution != other.mInputIsMultiResolution) {
89             return mInputIsMultiResolution < other.mInputIsMultiResolution;
90         }
91 
92         if (mOperatingMode != other.mOperatingMode) {
93             return mOperatingMode < other.mOperatingMode;
94         }
95 
96         return outputsLessThan(other);
97     }
98 
99     bool operator > (const SessionConfiguration& other) const {
100         return (*this != other && !(*this < other));
101     }
102 
103     bool outputsEqual(const SessionConfiguration& other) const;
104     bool outputsLessThan(const SessionConfiguration& other) const;
addOutputConfiguration(const OutputConfiguration & config)105     void addOutputConfiguration(const OutputConfiguration &config) {
106         mOutputStreams.push_back(config);
107     }
108 
109 private:
110 
111     std::vector<OutputConfiguration> mOutputStreams;
112     int                              mInputWidth, mInputHeight, mInputFormat, mOperatingMode;
113     bool                             mInputIsMultiResolution = false;
114 };
115 } // namespace params
116 } // namespace camera2
117 } // namespace hardware
118 
119 using hardware::camera2::params::SessionConfiguration;
120 
121 }; // namespace android
122 
123 #endif
124