• 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 HOS_CAMERA_VI_CONTROLLER_H
17 #define HOS_CAMERA_VI_CONTROLLER_H
18 
19 #include <map>
20 #include "icontroller.h"
21 #include "isensor.h"
22 #include "ivi_object.h"
23 #include "device_manager_adapter.h"
24 #include "mpi_adapter.h"
25 
26 namespace OHOS {
27 namespace Camera {
28 class ViController : public IController {
29 public:
30     ViController();
31     explicit ViController(std::string hardwareName);
32     virtual ~ViController();
33     RetCode Init();
34     std::shared_ptr<ISensor> GetSensor(std::string sensorName);
35     RetCode Configure(std::shared_ptr<CameraMetadata> meta);
GetStartViState()36     bool GetStartViState()
37     {
38         return startViState_;
39     };
GetFrameRateBySensor()40     RetCode GetFrameRateBySensor()
41     {
42         return RC_OK;
43     };
GetSizeBySensor()44     RetCode GetSizeBySensor()
45     {
46         return RC_OK;
47     };
StartCapture()48     RetCode StartCapture()
49     {
50         return RC_OK;
51     };
52     RetCode PowerUp(CameraId cameraId);
53     RetCode PowerDown(CameraId cameraId);
54     RetCode StopVi();
55     RetCode StartVi();
56     RetCode ConfigVi();
57     void SetAbilityMetaDataTag(std::vector<int32_t> abilityMetaDataTag);
58     RetCode GetAbilityMetaData(std::shared_ptr<CameraMetadata> meta);
59     bool GetMetaDataFlag();
60     void SetMetaDataFlag(bool metaDataFlag);
61     RetCode SetFlashlight(FlashMode flashMode, bool enable);
62 
63 private:
64     RetCode SendIspMetaData(std::shared_ptr<CameraMetadata> meta);
65     RetCode SendAEMetaData(common_metadata_header_t &data);
66     RetCode SendAWBMetaData(common_metadata_header_t &data);
67     RetCode GetIspMetaData(std::shared_ptr<CameraMetadata> meta);
68     RetCode GetAEMetaData(std::shared_ptr<CameraMetadata> meta);
69     RetCode GetAWBMetaData(std::shared_ptr<CameraMetadata> meta);
70     RetCode GetColorCorrectionGains(std::shared_ptr<CameraMetadata> meta);
71     template<typename T>
CheckNumequal(T oldnum,T num,int size)72     bool CheckNumequal(T oldnum, T num, int size)
73     {
74         if (oldnum == nullptr || num == nullptr) {
75             CAMERA_LOGE("oldnum or num is nullptr");
76             return false;
77         }
78         for (int i = 0; size > 0; i++, size--) {
79             if (oldnum[i] != num[i]) {
80                 return false;
81             }
82         }
83         return true;
84     };
85     std::mutex startVilock_;
86     std::mutex metaDataFlaglock_;
87     std::mutex metaDataSetlock_;
88     bool metaDataFlag_ = false;
89     bool startViState_ = false;
90     std::shared_ptr<IViObject> viObject_ = nullptr;
91     std::vector<int32_t> abilityMetaData_;
92 };
93 } // namespace Camera
94 } // namespace OHOS
95 #endif
96