Home | History | Annotate | Download | only in camera2
      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 
     33     const std::vector<OutputConfiguration>& getOutputConfigurations() const {
     34         return mOutputStreams;
     35     }
     36 
     37     int getInputWidth() const { return mInputWidth; }
     38     int getInputHeight() const { return mInputHeight; }
     39     int getInputFormat() const { return mInputFormat; }
     40     int getOperatingMode() const { return mOperatingMode; }
     41 
     42     virtual status_t writeToParcel(android::Parcel* parcel) const override;
     43     virtual status_t readFromParcel(const android::Parcel* parcel) override;
     44 
     45     SessionConfiguration() :
     46             mInputWidth(0),
     47             mInputHeight(0),
     48             mInputFormat(-1),
     49             mOperatingMode(-1) {}
     50 
     51     SessionConfiguration(const android::Parcel& parcel) {
     52         readFromParcel(&parcel);
     53     }
     54 
     55     SessionConfiguration(int inputWidth, int inputHeight, int inputFormat, int operatingMode) :
     56         mInputWidth(inputWidth), mInputHeight(inputHeight), mInputFormat(inputFormat),
     57         mOperatingMode(operatingMode) {}
     58 
     59     bool operator == (const SessionConfiguration& other) const {
     60         return (outputsEqual(other) &&
     61                 mInputWidth == other.mInputWidth &&
     62                 mInputHeight == other.mInputHeight &&
     63                 mInputFormat == other.mInputFormat &&
     64                 mOperatingMode == other.mOperatingMode);
     65     }
     66 
     67     bool operator != (const SessionConfiguration& other) const {
     68         return !(*this == other);
     69     }
     70 
     71     bool operator < (const SessionConfiguration& other) const {
     72         if (*this == other) return false;
     73 
     74         if (mInputWidth != other.mInputWidth) {
     75             return mInputWidth < other.mInputWidth;
     76         }
     77 
     78         if (mInputHeight != other.mInputHeight) {
     79             return mInputHeight < other.mInputHeight;
     80         }
     81 
     82         if (mInputFormat != other.mInputFormat) {
     83             return mInputFormat < other.mInputFormat;
     84         }
     85 
     86         if (mOperatingMode != other.mOperatingMode) {
     87             return mOperatingMode < other.mOperatingMode;
     88         }
     89 
     90         return outputsLessThan(other);
     91     }
     92 
     93     bool operator > (const SessionConfiguration& other) const {
     94         return (*this != other && !(*this < other));
     95     }
     96 
     97     bool outputsEqual(const SessionConfiguration& other) const;
     98     bool outputsLessThan(const SessionConfiguration& other) const;
     99     void addOutputConfiguration(const OutputConfiguration &config) {
    100         mOutputStreams.push_back(config);
    101     }
    102 
    103 private:
    104 
    105     std::vector<OutputConfiguration> mOutputStreams;
    106     int                              mInputWidth, mInputHeight, mInputFormat, mOperatingMode;
    107 };
    108 } // namespace params
    109 } // namespace camera2
    110 } // namespace hardware
    111 
    112 using hardware::camera2::params::SessionConfiguration;
    113 
    114 }; // namespace android
    115 
    116 #endif
    117