1b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh/* 2b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * Copyright (C) 2015 The Android Open Source Project 3b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * 4b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * Licensed under the Apache License, Version 2.0 (the "License"); 5b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * you may not use this file except in compliance with the License. 6b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * You may obtain a copy of the License at 7b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * 8b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * http://www.apache.org/licenses/LICENSE-2.0 9b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * 10b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * Unless required by applicable law or agreed to in writing, software 11b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * distributed under the License is distributed on an "AS IS" BASIS, 12b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * See the License for the specific language governing permissions and 14b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * limitations under the License. 15b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh */ 16b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh 17b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh#ifndef ANDROID_HARDWARE_CAMERA2_OUTPUTCONFIGURATION_H 18b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh#define ANDROID_HARDWARE_CAMERA2_OUTPUTCONFIGURATION_H 19b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh 20b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh#include <gui/IGraphicBufferProducer.h> 21d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala#include <binder/Parcelable.h> 22b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh 23b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yehnamespace android { 24b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh 25b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yehclass Surface; 26b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh 27d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvalanamespace hardware { 28d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvalanamespace camera2 { 29d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvalanamespace params { 30d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala 31d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvalaclass OutputConfiguration : public android::Parcelable { 32b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yehpublic: 33b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh 34b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh static const int INVALID_ROTATION; 35018107a82d80f186d3efca250e38e9c85436a4d9Zhijun He static const int INVALID_SET_ID; 36b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh sp<IGraphicBufferProducer> getGraphicBufferProducer() const; 37b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh int getRotation() const; 38018107a82d80f186d3efca250e38e9c85436a4d9Zhijun He int getSurfaceSetID() const; 39b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh 40b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh /** 41b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh * Keep impl up-to-date with OutputConfiguration.java in frameworks/base 42b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh */ 43d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala virtual status_t writeToParcel(Parcel* parcel) const override; 44d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala 45d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala virtual status_t readFromParcel(const Parcel* parcel) override; 46d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala 47d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala // getGraphicBufferProducer will be NULL 48d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala // getRotation will be INVALID_ROTATION 49d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala // getSurfaceSetID will be INVALID_SET_ID 50d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala OutputConfiguration(); 51d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala 52b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh // getGraphicBufferProducer will be NULL if error occurred 53b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh // getRotation will be INVALID_ROTATION if error occurred 54d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala // getSurfaceSetID will be INVALID_SET_ID if error occurred 55b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh OutputConfiguration(const Parcel& parcel); 56b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh 57018107a82d80f186d3efca250e38e9c85436a4d9Zhijun He OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation, 58018107a82d80f186d3efca250e38e9c85436a4d9Zhijun He int surfaceSetID = INVALID_SET_ID); 593450ba7879be6522ea46a56c5e66e5382f5dd5baRuben Brunk 60ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh bool operator == (const OutputConfiguration& other) const { 61ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh return (mGbp == other.mGbp && 62d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala mRotation == other.mRotation && 63d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala mSurfaceSetID == other.mSurfaceSetID); 64ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh } 65ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh bool operator != (const OutputConfiguration& other) const { 66ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh return !(*this == other); 67ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh } 68ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh bool operator < (const OutputConfiguration& other) const { 69ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh if (*this == other) return false; 70ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh if (mGbp != other.mGbp) return mGbp < other.mGbp; 71d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala if (mSurfaceSetID != other.mSurfaceSetID) { 72d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala return mSurfaceSetID < other.mSurfaceSetID; 73d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala } 74ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh return mRotation < other.mRotation; 75ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh } 76ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh bool operator > (const OutputConfiguration& other) const { 77ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh return (*this != other && !(*this < other)); 78ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh } 79ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh 80b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yehprivate: 81b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh sp<IGraphicBufferProducer> mGbp; 82b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh int mRotation; 83018107a82d80f186d3efca250e38e9c85436a4d9Zhijun He int mSurfaceSetID; 84b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh // helper function 85d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala static String16 readMaybeEmptyString16(const Parcel* parcel); 86b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh}; 87d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala} // namespace params 88d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala} // namespace camera2 89d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala} // namespace hardware 90d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala 91d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala 92d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvalausing hardware::camera2::params::OutputConfiguration; 93d56db1d2bee182d1851097a9c712712fc094d117Eino-Ville Talvala 94b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh}; // namespace android 95b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh 96b97babb8c08969b55af3b6456d15f764c8873d3fYin-Chia Yeh#endif 97