• 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 "json/json.h"
27 #include "single_instance.h"
28 #include "types.h"
29 
30 namespace OHOS {
31 namespace DistributedHardware {
32 struct ConfigInfo {
33     DCStreamType type;
34     std::string formatKey;
35     sptr<CameraStandard::CameraInput> cameraInput;
36 };
37 
38 class DCameraHandler : public IHardwareHandler {
39 DECLARE_SINGLE_INSTANCE_BASE(DCameraHandler);
40 public:
41     int32_t Initialize() override;
42     std::vector<DHItem> Query() override;
43     std::map<std::string, std::string> QueryExtraInfo() override;
44     bool IsSupportPlugin() override;
45     void RegisterPluginListener(std::shared_ptr<PluginListener> listener) override;
46 
47     std::vector<std::string> GetCameras();
48 
49 private:
50     DCameraHandler() = default;
51     ~DCameraHandler();
52 
53 private:
54     DHItem CreateDHItem(sptr<CameraStandard::CameraInfo>& info);
55     std::string GetCameraPosition(camera_position_enum_t position);
56     void ConfigFormatAndResolution(ConfigInfo& info, Json::Value& outputFormat, Json::Value& resolution,
57                                    std::vector<camera_format_t>& formatList, std::set<camera_format_t>& formatSet);
58     bool IsValid(DCStreamType type, CameraStandard::CameraPicSize& size);
59 
60     sptr<CameraStandard::CameraManager> cameraManager_;
61     std::shared_ptr<PluginListener> pluginListener_;
62 };
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 __attribute__((visibility("default"))) IHardwareHandler* GetHardwareHandler();
68 #ifdef __cplusplus
69 }
70 #endif
71 } // namespace DistributedHardware
72 } // namespace OHOS
73 #endif // OHOS_DCAMERA_HANDLER_H