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 
16 /**
17  * @addtogroup MultiMedia_CameraAbility
18  * @{
19  *
20  * @brief Defines the camera capability set for applications to achieve and access the capabilities.
21  *
22  * @since 1.0
23  * @version 1.0
24  */
25 
26 /**
27  * @file camera_ability.h
28  *
29  * @brief Declares functions of the <b>CameraAbility</b> class.
30  *
31  *
32  * @since 1.0
33  * @version 1.0
34  */
35 
36 #ifndef OHOS_CAMERA_ABILITY_H
37 #define OHOS_CAMERA_ABILITY_H
38 
39 #include "media_log.h"
40 #include "meta_data.h"
41 
42 #include <cstdint>
43 #include <list>
44 #include <map>
45 #include <set>
46 
47 namespace OHOS {
48 namespace Media {
49 /**
50  * @brief Declares functions of the <b>CameraAbility</b> class.
51  *
52  *
53  * @since 1.0
54  * @version 1.0
55  */
56 class CameraAbility {
57 public:
58     /**
59      * @brief A constructor used to create a <b>CameraAbility</b> instance.
60      *
61      */
62     CameraAbility();
63 
64     /**
65      * @brief A destructor used to delete the <b>CameraAbility</b> instance.
66      *
67      */
68     virtual ~CameraAbility();
69 
70     /**
71      * @brief Obtains the supported image sizes for a specified image format.
72      *
73      * @param format Indicates the image format, which can be YUV, H.265, or H.264.
74      * @return Returns the image size list if obtained; returns <b>NULL</b> otherwise.
75      */
76     std::list<CameraPicSize> GetSupportedSizes(int format) const;
77 
78     /**
79      * @brief Obtains the supported autofocus (AF) modes.
80      *
81      * @return Returns the autofocus modes.
82      */
83     std::list<int32_t> GetSupportedAfModes() const;
84 
85     /**
86      * @brief Obtains the supported auto exposure (AE) modes.
87      *
88      * @return Returns the auto exposure modes.
89      */
90     std::list<int32_t> GetSupportedAeModes() const;
91 
92     /**
93      * @brief Sets value ranges for a specified parameter.
94      *
95      * @param key Indicates the parameter key.
96      * @param rangeList Indicates the list of parameter value ranges.
97      * @return Returns <b>SUCCESS</b> if the setting is successful; returns <b>FAIL</b> otherwise.
98      */
SetParameterRange(uint32_t key,std::list<T> rangeList)99     template<typename T> int32_t SetParameterRange(uint32_t key, std::list<T> rangeList)
100     {
101         if (IsParameterSupport(key)) {
102             SetSupportParameterRange(key, rangeList);
103             return MEDIA_OK;
104         }
105         return MEDIA_ERR;
106     }
107 
108     /**
109      * @brief Obtains the parameter value range based on a specified parameter key.
110      *
111      * @param key Indicates the parameter key.
112      * @return Returns the parameter value range if obtained; returns <b>NULL</b> otherwise.
113      */
GetParameterRange(uint32_t key)114     template<typename T> std::list<T> GetParameterRange(uint32_t key) const
115     {
116         if (supportProperties_.find(key) != supportProperties_.end()) {
117             return GetSupportParameterRange(key);
118         }
119         return nullptr;
120     }
121 
122 private:
123     void SetSupportParameterRange(uint32_t key, std::list<CameraPicSize> &rangeList);
124     void SetSupportParameterRange(uint32_t key, std::list<int32_t> &rangeList);
125     std::list<CameraPicSize> GetSupportParameterRange(uint32_t key) const;
126     bool IsParameterSupport(uint32_t key) const;
127     std::map<uint32_t, std::list<CameraPicSize>> SizeMap_;
128     std::set<uint32_t> supportProperties_;
129     std::list<int32_t> afModes;
130     std::list<int32_t> aeModes;
131 };
132 } // namespace Media
133 } // namespace OHOS
134 #endif // OHOS_CAMERA_ABILITY_H
135