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 #include "utils.h" 18 19 #include <android/binder_auto_utils.h> 20 #include <string> 21 #include <set> 22 23 using ::android::acam::utils::native_handle_ptr_wrapper; 24 25 struct ACaptureSessionOutput { 26 explicit ACaptureSessionOutput(const native_handle_t* window, bool isShared = false, 27 const char* physicalCameraId = "") : mWindowACaptureSessionOutput28 mWindow(window), mIsShared(isShared), mPhysicalCameraId(physicalCameraId) {}; 29 30 bool operator == (const ACaptureSessionOutput& other) const { 31 return (mWindow == other.mWindow); 32 } 33 34 bool operator != (const ACaptureSessionOutput& other) const { 35 return mWindow != other.mWindow; 36 } 37 38 bool operator < (const ACaptureSessionOutput& other) const { 39 return mWindow < other.mWindow; 40 } 41 42 bool operator > (const ACaptureSessionOutput& other) const { 43 return mWindow > other.mWindow; 44 } 45 isWindowEqualACaptureSessionOutput46 inline bool isWindowEqual(ACameraWindowType* window) const { 47 return mWindow == native_handle_ptr_wrapper(window); 48 } 49 50 // returns true if the window was successfully added, false otherwise. addSharedWindowACaptureSessionOutput51 inline bool addSharedWindow(ACameraWindowType* window) { 52 auto ret = mSharedWindows.insert(window); 53 return ret.second; 54 } 55 56 // returns the number of elements removed. removeSharedWindowACaptureSessionOutput57 inline size_t removeSharedWindow(ACameraWindowType* window) { 58 return mSharedWindows.erase(window); 59 } 60 61 native_handle_ptr_wrapper mWindow; 62 std::set<native_handle_ptr_wrapper> mSharedWindows; 63 bool mIsShared; 64 int mRotation = CAMERA3_STREAM_ROTATION_0; 65 std::string mPhysicalCameraId; 66 }; 67 68 69