1 /*
2  * Copyright (c) 2023 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 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 CODEC_IMAGE_CONFIG_H
17 #define CODEC_IMAGE_CONFIG_H
18 #include <refbase.h>
19 #include "device_resource_if.h"
20 #include "v2_0/codec_image_type.h"
21 namespace OHOS {
22 namespace HDI {
23 namespace Codec {
24 namespace Image {
25 namespace V2_0 {
26 struct ConfigUintNodeAttr {
27     std::string attrName;
28     uint32_t &value;
29     uint32_t defaultValue;
30 } ;
31 struct ConfigUintArrayNodeAttr {
32     std::string attrName;
33     std::vector<uint32_t> &vec;
34 } ;
35 
36 class CodecImageConfig {
37 public:
38     ~CodecImageConfig() = default;
39     static CodecImageConfig *GetInstance();
40     void Init(const struct DeviceResourceNode &node);
41     int32_t GetImageCapabilityList(std::vector<CodecImageCapability> &capList);
42 
43 protected:
44     CodecImageConfig();
45 
46 private:
47     int32_t GetGroupCapabilities(const std::string &nodeName);
48     int32_t GetOneCapability(const struct DeviceResourceIface &iface, const struct DeviceResourceNode &childNode,
49                              CodecImageCapability &cap);
50     int32_t GetUintTableConfig(const struct DeviceResourceIface &iface, const struct DeviceResourceNode &node,
51                                ConfigUintArrayNodeAttr &attr);
52 
53 private:
54     struct DeviceResourceNode node_;
55     std::vector<CodecImageCapability> capList_;
56     static CodecImageConfig config_;
57 };
58 } // V2_0
59 } // Image
60 } // Codec
61 } // HDI
62 } // OHOS
63 #endif  // CODEC_IMAGE_CONFIG_H
64