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