• 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 #include "isensor.h"
17 
18 namespace OHOS {
19 namespace Camera {
ISensor()20 ISensor::ISensor() {}
21 
ISensor(std::string sensorName)22 ISensor::ISensor(std::string sensorName) : sensorName_(sensorName) {}
23 
~ISensor()24 ISensor::~ISensor() {}
25 
InitPhysicalSize(CameraMetadata & camera_meta_data)26 void ISensor::InitPhysicalSize(CameraMetadata& camera_meta_data)
27 {
28     std::vector<float> physicalSize = {
29         2592,
30         1944,
31     };
32     camera_meta_data.addEntry(OHOS_SENSOR_INFO_PHYSICAL_SIZE, physicalSize.data(),
33         physicalSize.size());
34 }
InitAntiBandingModes(CameraMetadata & camera_meta_data)35 void ISensor::InitAntiBandingModes(CameraMetadata& camera_meta_data)
36 {
37     std::vector<uint8_t> aeAvailableAntiBandingModes = {
38         OHOS_CAMERA_AE_ANTIBANDING_MODE_OFF,
39         OHOS_CAMERA_AE_ANTIBANDING_MODE_50HZ,
40         OHOS_CAMERA_AE_ANTIBANDING_MODE_60HZ,
41         OHOS_CAMERA_AE_ANTIBANDING_MODE_AUTO,
42     };
43     camera_meta_data.addEntry(OHOS_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, aeAvailableAntiBandingModes.data(),
44                               aeAvailableAntiBandingModes.size());
45 }
InitAvailableModes(CameraMetadata & camera_meta_data)46 void ISensor::InitAvailableModes(CameraMetadata& camera_meta_data)
47 {
48     std::vector<uint8_t> aeAvailableModes = {
49         OHOS_CAMERA_AE_MODE_ON,
50     };
51     camera_meta_data.addEntry(OHOS_CONTROL_AE_AVAILABLE_MODES, aeAvailableModes.data(),
52                               aeAvailableModes.size());
53 }
InitFpsTarget(CameraMetadata & camera_meta_data)54 void ISensor::InitFpsTarget(CameraMetadata& camera_meta_data)
55 {
56     std::vector<int32_t> availableAeFpsTarget = {
57         15,
58         30,
59     };
60     camera_meta_data.addEntry(OHOS_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, availableAeFpsTarget.data(),
61                               availableAeFpsTarget.size());
62 }
InitCompensationRange(CameraMetadata & camera_meta_data)63 void ISensor::InitCompensationRange(CameraMetadata& camera_meta_data)
64 {
65     std::vector<int32_t> aeCompensationRange = {
66         0,
67         0,
68     };
69     camera_meta_data.addEntry(OHOS_CONTROL_AE_COMPENSATION_RANGE, aeCompensationRange.data(),
70                               aeCompensationRange.size());
71 }
72 
InitAwbModes(CameraMetadata & camera_meta_data)73 void ISensor::InitAwbModes(CameraMetadata& camera_meta_data)
74 {
75     std::vector<uint8_t> availableAwbModes = {
76         OHOS_CAMERA_AWB_MODE_OFF,
77     };
78     camera_meta_data.addEntry(OHOS_CONTROL_AWB_AVAILABLE_MODES, availableAwbModes.data(),
79                               availableAwbModes.size());
80 }
81 
InitSensitivityRange(CameraMetadata & camera_meta_data)82 void ISensor::InitSensitivityRange(CameraMetadata& camera_meta_data)
83 {
84     int32_t sensitivityRange[] = {
85         32,
86         2400,
87     };
88     camera_meta_data.addEntry(OHOS_SENSOR_INFO_SENSITIVITY_RANGE,
89         &sensitivityRange,
90         sizeof(sensitivityRange) / sizeof(int32_t));
91 }
92 } // namespace Camera
93 } // namespace OHOS