1 /* 2 * Copyright (c) 2022 Shenzhen Kaihong DID 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 CODEC_CONFIG_H 17 #define CODEC_CONFIG_H 18 #include <refbase.h> 19 #include "v3_0/codec_types.h" 20 #include "device_resource_if.h" 21 using OHOS::HDI::Codec::V3_0::CodecCompCapability; 22 namespace OHOS { 23 namespace Codec { 24 namespace Omx { 25 typedef struct { 26 std::string attrName; 27 int32_t &value; 28 uint32_t defaultValue; 29 } ConfigUintNodeAttr; 30 typedef struct { 31 std::string attrName; 32 std::vector<int32_t> &vec; 33 } ConfigUintArrayNodeAttr; 34 35 class CodecComponentConfig { 36 public: 37 ~CodecComponentConfig() = default; 38 static CodecComponentConfig *GetInstance(); 39 void Init(const DeviceResourceNode &node); 40 int32_t CodecCompCapabilityInit(); 41 int32_t GetComponentNum(int32_t &count); 42 int32_t GetComponentCapabilityList(std::vector<CodecCompCapability> &capList, int32_t count); 43 44 protected: 45 CodecComponentConfig(); 46 47 private: 48 int32_t GetGroupCapabilities(const std::string &nodeName); 49 int32_t GetOneCapability(const struct DeviceResourceIface &iface, const struct DeviceResourceNode &childNode, 50 CodecCompCapability &cap, bool isVideoGroup); 51 int32_t GetMiscOfCapability(const struct DeviceResourceIface &iface, const struct DeviceResourceNode &childNode, 52 CodecCompCapability &cap); 53 int32_t GetUintTableConfig(const struct DeviceResourceIface &iface, const struct DeviceResourceNode &node, 54 ConfigUintArrayNodeAttr &attr); 55 int32_t GetMaskedConfig(const struct DeviceResourceIface &iface, const struct DeviceResourceNode &node, 56 const std::string &attrName, uint32_t &mask); 57 int32_t GetAudioPortCapability(const struct DeviceResourceIface &iface, const struct DeviceResourceNode &childNode, 58 CodecCompCapability &cap); 59 int32_t GetVideoPortCapability(const struct DeviceResourceIface &iface, const struct DeviceResourceNode &childNode, 60 CodecCompCapability &cap); 61 62 private: 63 DeviceResourceNode node_; 64 std::vector<CodecCompCapability> capList_; 65 static CodecComponentConfig config_; 66 }; 67 } // namespace Omx 68 } // namespace Codec 69 } // namespace OHOS 70 #endif // CODEC_CONFIG_H