1 /*
2  * Copyright (c) 2020-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 #include "camera_ability.h"
16 #include "media_log.h"
17 
18 using namespace std;
19 namespace OHOS {
20 namespace Media {
CameraAbility()21 CameraAbility::CameraAbility() {}
~CameraAbility()22 CameraAbility::~CameraAbility() {}
23 
GetSupportedSizes(int format) const24 list<CameraPicSize> CameraAbility::GetSupportedSizes(int format) const
25 {
26     switch (format) {
27         case CAM_FORMAT_YVU420:
28         case CAM_FORMAT_JPEG:
29         case CAM_FORMAT_H264:
30         case CAM_FORMAT_H265: {
31             auto target = SizeMap_.find(static_cast<uint32_t>(format));
32             return target->second;
33         }
34         default: {
35             list<CameraPicSize> emptyList;
36             return emptyList;
37         }
38     }
39 }
40 
GetSupportedAfModes() const41 std::list<int32_t> CameraAbility::GetSupportedAfModes() const
42 {
43     return afModes;
44 }
45 
GetSupportedAeModes() const46 std::list<int32_t> CameraAbility::GetSupportedAeModes() const
47 {
48     return aeModes;
49 }
50 
GetSupportParameterRange(uint32_t key) const51 list<CameraPicSize> CameraAbility::GetSupportParameterRange(uint32_t key) const
52 {
53     switch (key) {
54         case CAM_FORMAT_YVU420:
55         case CAM_FORMAT_JPEG:
56         case CAM_FORMAT_H264:
57         case CAM_FORMAT_H265: {
58             auto target = SizeMap_.find(key);
59             return target->second;
60         }
61         default: {
62             list<CameraPicSize> emptyList;
63             return emptyList;
64         }
65     }
66 }
67 
SetSupportParameterRange(uint32_t key,list<CameraPicSize> & rangeList)68 void CameraAbility::SetSupportParameterRange(uint32_t key, list<CameraPicSize> &rangeList)
69 {
70     switch (key) {
71         case CAM_FORMAT_YVU420:
72         case CAM_FORMAT_JPEG:
73         case CAM_FORMAT_H264:
74         case CAM_FORMAT_H265: {
75             supportProperties_.emplace(key);
76             SizeMap_[key] = rangeList;
77             break;
78         }
79         default:
80             break;
81     }
82 }
83 
SetSupportParameterRange(uint32_t key,list<int32_t> & rangeList)84 void CameraAbility::SetSupportParameterRange(uint32_t key, list<int32_t> &rangeList)
85 {
86     switch (key) {
87         case CAM_AF_MODE:
88             supportProperties_.emplace(key);
89             afModes = rangeList;
90             break;
91         case CAM_AE_MODE:
92             supportProperties_.emplace(key);
93             aeModes = rangeList;
94             break;
95         default:
96             break;
97     }
98 }
99 
IsParameterSupport(uint32_t key) const100 bool CameraAbility::IsParameterSupport(uint32_t key) const
101 {
102     if (key >= CAM_FORMAT_BUTT) {
103         return false;
104     }
105     return true;
106 }
107 } // namespace Media
108 } // namespace OHOS