1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_DCAMERA_HANDLER_H 17 #define OHOS_DCAMERA_HANDLER_H 18 19 #include "ihardware_handler.h" 20 21 #include <set> 22 23 #include "camera_info.h" 24 #include "camera_input.h" 25 #include "camera_manager.h" 26 #include "camera_output_capability.h" 27 #include "json/json.h" 28 #include "single_instance.h" 29 #include "v1_0/dcamera_types.h" 30 31 namespace OHOS { 32 namespace DistributedHardware { 33 using namespace OHOS::HDI::DistributedCamera::V1_0; 34 35 class DCameraHandler : public IHardwareHandler { 36 DECLARE_SINGLE_INSTANCE_BASE(DCameraHandler); 37 public: 38 int32_t Initialize() override; 39 std::vector<DHItem> Query() override; 40 std::map<std::string, std::string> QueryExtraInfo() override; 41 bool IsSupportPlugin() override; 42 void RegisterPluginListener(std::shared_ptr<PluginListener> listener) override; 43 void UnRegisterPluginListener() override; 44 45 std::vector<std::string> GetCameras(); 46 47 private: 48 DCameraHandler() = default; 49 ~DCameraHandler(); 50 51 private: 52 int32_t CreateDHItem(sptr<CameraStandard::CameraDevice>& info, DHItem& item); 53 std::string GetCameraPosition(CameraStandard::CameraPosition position); 54 void ConfigFormatAndResolution(const DCStreamType type, Json::Value& root, 55 std::vector<CameraStandard::Profile>& profileList); 56 bool IsValid(const DCStreamType type, const CameraStandard::Size& size); 57 int32_t CovertToDcameraFormat(CameraStandard::CameraFormat format); 58 59 sptr<CameraStandard::CameraManager> cameraManager_; 60 std::shared_ptr<PluginListener> pluginListener_; 61 }; 62 63 #ifdef __cplusplus 64 extern "C" { 65 #endif // __cplusplus 66 __attribute__((visibility("default"))) IHardwareHandler* GetHardwareHandler(); 67 #ifdef __cplusplus 68 } 69 #endif // __cplusplus 70 } // namespace DistributedHardware 71 } // namespace OHOS 72 #endif // OHOS_DCAMERA_HANDLER_H