1 /* 2 * Copyright (C) 2019 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 HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_CAMERA_PROVIDER_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_CAMERA_PROVIDER_H_ 19 20 #include <utils/Errors.h> 21 #include <memory> 22 23 #include "camera_buffer_allocator_hwl.h" 24 #include "camera_device.h" 25 #include "camera_provider_callback.h" 26 #include "camera_provider_hwl.h" 27 #include "vendor_tags.h" 28 29 namespace android { 30 namespace google_camera_hal { 31 class CameraProvider { 32 public: 33 // Create a Camera Provider. 34 // If camera_provider_hwl is nullptr, CameraProvider will try to open 35 // a library containing the camera_provider_hwl implementation for the device. 36 static std::unique_ptr<CameraProvider> Create( 37 std::unique_ptr<CameraProviderHwl> camera_provider_hwl = nullptr); 38 virtual ~CameraProvider(); 39 40 // Set callback functions. 41 status_t SetCallback(const CameraProviderCallback* callback); 42 43 // Trigger deferred callbacks (such as physical camera avail/unavail) right 44 // after setCallback() is called. 45 status_t TriggerDeferredCallbacks(); 46 47 // Get vendor tags. 48 status_t GetVendorTags( 49 std::vector<VendorTagSection>* vendor_tag_sections) const; 50 51 // Get a list of camera IDs. 52 status_t GetCameraIdList(std::vector<uint32_t>* camera_ids) const; 53 54 // Return if torch mode is supported. 55 bool IsSetTorchModeSupported() const; 56 57 // Create a CameraDevice for camera_id. 58 status_t CreateCameraDevice(uint32_t camera_id, 59 std::unique_ptr<CameraDevice>* device); 60 61 // Get the combinations of camera ids which support concurrent streaming 62 status_t GetConcurrentStreamingCameraIds( 63 std::vector<std::unordered_set<uint32_t>>* camera_id_combinations); 64 65 // Check if a set of concurrent stream configurations are supported 66 status_t IsConcurrentStreamCombinationSupported( 67 const std::vector<CameraIdAndStreamConfiguration>& configs, 68 bool* is_supported); 69 70 protected: 71 CameraProvider() = default; 72 73 private: 74 status_t Initialize(std::unique_ptr<CameraProviderHwl> camera_provider_hwl); 75 76 // Initialize the vendor tag manager 77 status_t InitializeVendorTags(); 78 79 status_t CreateCameraProviderHwl( 80 std::unique_ptr<CameraProviderHwl>* camera_provider_hwl); 81 82 // Provider library handle. 83 void* hwl_lib_handle_ = nullptr; 84 85 std::unique_ptr<CameraProviderHwl> camera_provider_hwl_; 86 87 const CameraProviderCallback* provider_callback_ = nullptr; 88 HwlCameraProviderCallback hwl_provider_callback_; 89 90 std::unique_ptr<CameraBufferAllocatorHwl> camera_allocator_hwl_; 91 // Combined list of vendor tags from HAL and HWL 92 std::vector<VendorTagSection> vendor_tag_sections_; 93 }; 94 95 } // namespace google_camera_hal 96 } // namespace android 97 98 #endif // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_CAMERA_PROVIDER_H_ 99