1/* 2 * Copyright (c) 2022-2023 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#include "codec_component_capability_config.h" 17#include "codec_log_wrapper.h" 18 19static CodecCapablites g_codecCapabilites = {0}; 20static const struct DeviceResourceNode *g_resourceNode = NULL; 21 22int32_t InitDataNode(const struct DeviceResourceNode *node) 23{ 24 if (node == NULL) { 25 CODEC_LOGE("data node is null!"); 26 return HDF_FAILURE; 27 } 28 g_resourceNode = node; 29 return HDF_SUCCESS; 30} 31 32int32_t ClearCapabilityData() 33{ 34 return ClearCapabilityGroup(&g_codecCapabilites); 35} 36 37int32_t LoadCapabilityData() 38{ 39 return LoadCodecCapabilityFromHcs(g_resourceNode, &g_codecCapabilites); 40} 41 42int32_t GetComponentNum(int32_t *num) 43{ 44 if (!g_codecCapabilites.inited) { 45 CODEC_LOGE("g_codecCapabilites not init!"); 46 return HDF_FAILURE; 47 } 48 *num = g_codecCapabilites.total; 49 return HDF_SUCCESS; 50} 51 52int32_t GetComponentCapabilityList(CodecCompCapability *capList, int32_t count) 53{ 54 if (!g_codecCapabilites.inited) { 55 CODEC_LOGE("g_codecCapabilites not init!"); 56 return HDF_FAILURE; 57 } 58 if (count != g_codecCapabilites.total) { 59 CODEC_LOGE("The length does not match!"); 60 return HDF_FAILURE; 61 } 62 int32_t groupIndex; 63 int32_t capIndex; 64 int32_t curCount = 0; 65 CodecCapablityGroup *group = NULL; 66 CodecCompCapability *cap = NULL; 67 CodecCapablityGroup *codeCapGroups[] = { 68 &(g_codecCapabilites.videoHwEncoderGroup), &(g_codecCapabilites.videoHwDecoderGroup), 69 &(g_codecCapabilites.audioHwEncoderGroup), &(g_codecCapabilites.audioHwDecoderGroup), 70 &(g_codecCapabilites.videoSwEncoderGroup), &(g_codecCapabilites.videoSwDecoderGroup), 71 &(g_codecCapabilites.audioSwEncoderGroup), &(g_codecCapabilites.audioSwDecoderGroup)}; 72 73 for (groupIndex = 0; groupIndex < CODEC_CAPABLITY_GROUP_NUM; groupIndex++) { 74 group = codeCapGroups[groupIndex]; 75 if (group == NULL) { 76 continue; 77 } 78 for (capIndex = 0; (capIndex < group->num) && (count > 0); capIndex++) { 79 cap = &group->capablitis[capIndex]; 80 capList[curCount++] = *cap; 81 } 82 } 83 return HDF_SUCCESS; 84} 85