• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     const int32_t INVALID_FORMAT = -1;
53     int32_t CreateDHItem(sptr<CameraStandard::CameraDevice>& info, DHItem& item);
54     int32_t CreateAVCodecList(Json::Value& root);
55     std::string GetCameraPosition(CameraStandard::CameraPosition position);
56     void ConfigFormatAndResolution(const DCStreamType type, Json::Value& root,
57         std::vector<CameraStandard::Profile>& profileList);
58     bool IsValid(const DCStreamType type, const CameraStandard::Size& size);
59     int32_t CovertToDcameraFormat(CameraStandard::CameraFormat format);
60 
61     sptr<CameraStandard::CameraManager> cameraManager_;
62     std::shared_ptr<PluginListener> pluginListener_;
63 };
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif // __cplusplus
68 __attribute__((visibility("default"))) IHardwareHandler* GetHardwareHandler();
69 #ifdef __cplusplus
70 }
71 #endif // __cplusplus
72 } // namespace DistributedHardware
73 } // namespace OHOS
74 #endif // OHOS_DCAMERA_HANDLER_H