diff --git a/codec/BUILD.gn b/codec/BUILD.gn index 0db678a1227e31bc6f72aca34484cb0af8145a2f..5bcf39187901ef09972b579babb8f5fbcd070c12 100644 --- a/codec/BUILD.gn +++ b/codec/BUILD.gn @@ -17,7 +17,6 @@ import("//drivers/adapter/uhdf2/uhdf.gni") group("hdf_media_codec") { deps = [ "hal:codec_hdi_omx", - "hal/config:codec_capability_config", "hal/v1.0/buffer_manager:codec_buffer_manager", ] } diff --git a/codec/hal/config/BUILD.gn b/codec/hal/config/BUILD.gn deleted file mode 100644 index c38c685fe1e14e130de1022baef426d7d16e83c2..0000000000000000000000000000000000000000 --- a/codec/hal/config/BUILD.gn +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright (c) 2021 Shenzhen Kaihong DID Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//drivers/adapter/uhdf2/uhdf.gni") - -ohos_shared_library("libcodec_capability_config") { - include_dirs = [ - "//drivers/peripheral/codec/interfaces/include", - "//drivers/peripheral/codec/hal/config/capability_config/include", - "//drivers/peripheral/codec/hal/config/common/include", - ] - sources = [ - "capability_config/src/codec_capability_config.c", - "capability_config/src/config_parser.c", - "common/src/codec_utils.c", - ] - - if (is_standard_system) { - external_deps = [ - "device_driver_framework:libhdf_host", - "device_driver_framework:libhdf_ipc_adapter", - "device_driver_framework:libhdf_utils", - "device_driver_framework:libhdi", - "hiviewdfx_hilog_native:libhilog", - ] - } else { - external_deps = [ "hilog:libhilog" ] - } - - install_images = [ chipset_base_dir ] - subsystem_name = "hdf" - part_name = "codec_device_driver" -} - -group("codec_capability_config") { - deps = [ ":libcodec_capability_config" ] -} diff --git a/codec/hal/config/capability_config/include/codec_config_reader.h b/codec/hal/config/capability_config/include/codec_config_reader.h deleted file mode 100644 index eb7b437be9ea5397c1a543a85ea8c4b9d9794373..0000000000000000000000000000000000000000 --- a/codec/hal/config/capability_config/include/codec_config_reader.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Shenzhen Kaihong DID Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DRIVERS_PERIPHERAL_CODEC_CONFIG_READER_H_ -#define DRIVERS_PERIPHERAL_CODEC_CONFIG_READER_H_ - -#include -#include "hdf_io_service_if.h" -#include "hdf_remote_service.h" -#include "codec_type.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -struct HdfRemoteService *GetConfigService(void); -int32_t EnumrateCapability(struct HdfRemoteService *remote, int index, CodecCapbility *cap); -int32_t GetCapability(struct HdfRemoteService *remote, - AvCodecMime mime, CodecType type, uint32_t flags, CodecCapbility *cap); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif // DRIVERS_PERIPHERAL_CODEC_CONFIG_READER_H_ diff --git a/codec/hal/config/capability_config/src/codec_capability_config.c b/codec/hal/config/capability_config/src/codec_capability_config.c deleted file mode 100644 index c7ca4f35f649af5a5c60a59662b1b6de039bebc7..0000000000000000000000000000000000000000 --- a/codec/hal/config/capability_config/src/codec_capability_config.c +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright (c) 2021 Shenzhen Kaihong DID Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "hdf_base.h" -#include "hdf_log.h" -#include "codec_type.h" -#include "config_parser.h" -#include "codec_utils.h" - -#define HDF_LOG_TAG "codec_config_service" - -static CodecCapablites codecCapabilites = {0}; -static const struct DeviceResourceNode *resourceNode; - -static int32_t SerializeCapAlignment(struct HdfSBuf *reply, Alignment *alignment) -{ - if (reply == NULL || alignment == NULL) { - HDF_LOGE("%{public}s: params null!", __func__); - return HDF_ERR_INVALID_PARAM; - } - if (!HdfSbufWriteInt32(reply, alignment->widthAlignment)) { - HDF_LOGE("%{public}s: Write widthAlignment failed!", __func__); - return HDF_FAILURE; - } - if (!HdfSbufWriteInt32(reply, alignment->heightAlignment)) { - HDF_LOGE("%{public}s: Write heightAlignment failed!", __func__); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -static int32_t SerializeCapRect(struct HdfSBuf *reply, Rect *rectangle) -{ - if (reply == NULL || rectangle == NULL) { - HDF_LOGE("%{public}s: params null!", __func__); - return HDF_ERR_INVALID_PARAM; - } - if (!HdfSbufWriteInt32(reply, rectangle->width)) { - HDF_LOGE("%{public}s: Write width failed!", __func__); - return HDF_FAILURE; - } - if (!HdfSbufWriteInt32(reply, rectangle->height)) { - HDF_LOGE("%{public}s: Write height failed!", __func__); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -static int32_t SerializeCapArray(struct HdfSBuf *reply, ResizableArray *resArr) -{ - if (reply == NULL || resArr == NULL) { - HDF_LOGE("%{public}s: params null!", __func__); - return HDF_ERR_INVALID_PARAM; - } - - if (!HdfSbufWriteUint32(reply, resArr->actualLen)) { - HDF_LOGE("%{public}s: Write actualLen failed!", __func__); - return HDF_FAILURE; - } - for (uint32_t i = 0; i < resArr->actualLen; i++) { - if (!HdfSbufWriteUint32(reply, resArr->element[i])) { - HDF_LOGE("%{public}s: Write HdfSubf failed!", __func__); - return HDF_FAILURE; - } - } - return HDF_SUCCESS; -} - -static int32_t SerializeCodecCapbility(struct HdfSBuf *reply, CodecCapbility *cap) -{ - if (reply == NULL || cap == NULL) { - HDF_LOGE("%{public}s: params NULL!", __func__); - return HDF_ERR_INVALID_PARAM; - } - if (!HdfSbufWriteUint32(reply, (uint32_t)cap->mime)) { - return HDF_FAILURE; - } - if (!HdfSbufWriteUint32(reply, (uint32_t)cap->type)) { - return HDF_FAILURE; - } - if (SerializeCapAlignment(reply, &cap->whAlignment) != HDF_SUCCESS) { - return HDF_FAILURE; - } - if (SerializeCapRect(reply, &cap->minSize) != HDF_SUCCESS) { - return HDF_FAILURE; - } - if (SerializeCapRect(reply, &cap->maxSize) != HDF_SUCCESS) { - return HDF_FAILURE; - } - if (!HdfSbufWriteUint64(reply, cap->minBitRate)) { - return HDF_FAILURE; - } - if (!HdfSbufWriteUint64(reply, cap->maxBitRate)) { - return HDF_FAILURE; - } - if (SerializeCapArray(reply, &cap->supportProfiles) != HDF_SUCCESS) { - return HDF_FAILURE; - } - if (SerializeCapArray(reply, &cap->supportLevels) != HDF_SUCCESS) { - return HDF_FAILURE; - } - if (SerializeCapArray(reply, &cap->supportPixelFormats) != HDF_SUCCESS) { - return HDF_FAILURE; - } - if (!HdfSbufWriteUint32(reply, cap->minInputBufferNum)) { - return HDF_FAILURE; - } - if (!HdfSbufWriteUint32(reply, cap->minOutputBufferNum)) { - return HDF_FAILURE; - } - if (!HdfSbufWriteUint32(reply, cap->allocateMask)) { - return HDF_FAILURE; - } - if (!HdfSbufWriteUint32(reply, cap->capsMask)) { - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -static int32_t EnumrateCapablity(int32_t index, CodecCapbility **capability) -{ - int32_t loopIndex; - int32_t cursor = index; - CodecCapablityGroup *codeCapGroups[] = {&(codecCapabilites.videoHwEncoderGroup), - &(codecCapabilites.videoHwDecoderGroup), - &(codecCapabilites.videoSwEncoderGroup), - &(codecCapabilites.videoSwDecoderGroup), - &(codecCapabilites.audioHwEncoderGroup), - &(codecCapabilites.audioHwDecoderGroup), - &(codecCapabilites.audioSwEncoderGroup), - &(codecCapabilites.audioSwDecoderGroup)}; - - for (loopIndex = 0; loopIndex < CODEC_CAPABLITY_GROUP_NUM; loopIndex++) { - if (cursor + 1 <= codeCapGroups[loopIndex]->num) { - *capability = &(codeCapGroups[loopIndex]->capablitis[cursor]); - return HDF_SUCCESS; - } else { - cursor -= codeCapGroups[loopIndex]->num; - } - } - - return HDF_FAILURE; -} - -static int32_t GetCapability(AvCodecMime mime, CodecType type, uint32_t flag, CodecCapbility **capability) -{ - int32_t groupIndex; - int32_t capIndex; - CodecCapablityGroup *group; - CodecCapbility *cap; - bool flagMatched = false; - CodecCapablityGroup *codeCapGroups[] = {&(codecCapabilites.videoHwEncoderGroup), - &(codecCapabilites.videoHwDecoderGroup), - &(codecCapabilites.audioHwEncoderGroup), - &(codecCapabilites.audioHwDecoderGroup), - &(codecCapabilites.videoSwEncoderGroup), - &(codecCapabilites.videoSwDecoderGroup), - &(codecCapabilites.audioSwEncoderGroup), - &(codecCapabilites.audioSwDecoderGroup)}; - const int32_t hardAndSoftSplitNumber = 4; - - for (groupIndex = 0; groupIndex < CODEC_CAPABLITY_GROUP_NUM; groupIndex++) { - group = codeCapGroups[groupIndex]; - for (capIndex = 0; capIndex < group->num; capIndex++) { - cap = &group->capablitis[capIndex]; - flagMatched = flag == 0 ? groupIndex < hardAndSoftSplitNumber : groupIndex >= hardAndSoftSplitNumber; - if (mime == cap->mime && type == cap->type && flagMatched) { - *capability = &group->capablitis[capIndex]; - return HDF_SUCCESS; - } - } - } - - return HDF_FAILURE; -} - -static int32_t ReloadCapabilities() -{ - ClearCapabilityGroup(&codecCapabilites); - LoadCodecCapabilityFromHcs(resourceNode, &codecCapabilites); - return HDF_SUCCESS; -} - -static int32_t HandleEnumrateCmd(struct HdfSBuf *data, struct HdfSBuf *reply) -{ - CodecCapbility *capbility = NULL; - uint32_t index; - - if (!HdfSbufReadUint32(data, &index)) { - HDF_LOGE("%{public}s: read index failed!", __func__); - return HDF_FAILURE; - } - if (!codecCapabilites.inited) { - return HDF_FAILURE; - } - if (EnumrateCapablity(index, &capbility) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: EnumrateCapablity - no more capability to Enumrate!", __func__); - return HDF_FAILURE; - } - if (capbility->mime == MEDIA_MIMETYPE_INVALID) { - HDF_LOGE("%{public}s: Capablity invalid, discard!", __func__); - return HDF_FAILURE; - } - if (SerializeCodecCapbility(reply, capbility) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: write capbility to sbuf failed!", __func__); - return HDF_FAILURE; - } - - return HDF_SUCCESS; -} - -static int32_t HandleGetCmd(struct HdfSBuf *data, struct HdfSBuf *reply) -{ - CodecCapbility *capbility = NULL; - AvCodecMime mime; - CodecType type; - uint32_t flags; - - if (!HdfSbufReadUint32(data, (uint32_t*)&mime)) { - HDF_LOGE("%{public}s: read input mime failed!", __func__); - return HDF_FAILURE; - } - if (!HdfSbufReadUint32(data, (uint32_t*)&type)) { - HDF_LOGE("%{public}s: read input type failed!", __func__); - return HDF_FAILURE; - } - if (!HdfSbufReadUint32(data, &flags)) { - HDF_LOGE("%{public}s: read input flags failed!", __func__); - return HDF_FAILURE; - } - if (GetCapability(mime, type, flags, &capbility) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: GetCapability - got nothing!", __func__); - return HDF_FAILURE; - } - if (SerializeCodecCapbility(reply, capbility) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: write capbility to sbuf failed!", __func__); - return HDF_FAILURE; - } - - return HDF_SUCCESS; -} - -static int32_t CodecCapabilityDispatch(struct HdfDeviceIoClient *client, int id, - struct HdfSBuf *data, struct HdfSBuf *reply) -{ - int32_t result = HDF_SUCCESS; - - if (client == NULL || data == NULL || reply == NULL) { - HDF_LOGE("%{public}s: params NULL!", __func__); - return HDF_ERR_INVALID_PARAM; - } - if (!HdfDeviceObjectCheckInterfaceDesc(client->device, data)) { - HDF_LOGE("check interface token failed"); - return HDF_ERR_INVALID_PARAM; - } - if (!codecCapabilites.inited) { - ReloadCapabilities(); - } - - switch (id) { - case CODEC_CONFIG_CMD_ENUMERATE_CAP: { - result = HandleEnumrateCmd(data, reply); - break; - } - - case CODEC_CONFIG_CMD_GET_CAP: { - result = HandleGetCmd(data, reply); - break; - } - - default: - break; - } - - return result; -} - -static int32_t CodecCapabilityBind(struct HdfDeviceObject *deviceObject) -{ - if (deviceObject == NULL) { - return HDF_FAILURE; - } - - static struct IDeviceIoService deviceIoService = { - .Dispatch = CodecCapabilityDispatch, - }; - - int ret = HdfDeviceObjectSetInterfaceDesc(deviceObject, "ohos.hdi.codec_service"); - if (ret != HDF_SUCCESS) { - HDF_LOGE("failed to set interface desc"); - return ret; - } - deviceObject->service = &deviceIoService; - - return HDF_SUCCESS; -} - -static int32_t CodecCapabilityInit(struct HdfDeviceObject *deviceObject) -{ - if (deviceObject == NULL) { - return HDF_FAILURE; - } - resourceNode = deviceObject->property; - if (LoadCodecCapabilityFromHcs(deviceObject->property, &codecCapabilites) != HDF_SUCCESS) { - ClearCapabilityGroup(&codecCapabilites); - } - return HDF_SUCCESS; -} - -static void CodecCapabilityRelease(struct HdfDeviceObject *deviceObject) -{ - ClearCapabilityGroup(&codecCapabilites); - return; -} - -struct HdfDriverEntry g_codecConfigDriverEntry = { - .moduleVersion = 1, - .moduleName = "codec_capability_config", // corresponding serviceName is "codec_capability_config_service"; - .Bind = CodecCapabilityBind, - .Init = CodecCapabilityInit, - .Release = CodecCapabilityRelease, -}; - -HDF_INIT(g_codecConfigDriverEntry); diff --git a/codec/hal/config/capability_config/src/codec_config_reader.c b/codec/hal/config/capability_config/src/codec_config_reader.c deleted file mode 100644 index 8d1886de86ef0eb2453d26da66c207bfc398756e..0000000000000000000000000000000000000000 --- a/codec/hal/config/capability_config/src/codec_config_reader.c +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (c) 2021 Shenzhen Kaihong DID Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "codec_config_reader.h" -#include -#include -#include -#include "config_parser.h" -#include "codec_utils.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define HDF_LOG_TAG "codec_config_client" - -static int32_t DeserializeCapAlignment(struct HdfSBuf *reply, Alignment *alignment) -{ - if (reply == NULL || alignment == NULL) { - HDF_LOGE("%{public}s: params NULL!", __func__); - return HDF_ERR_INVALID_PARAM; - } - if (!HdfSbufReadInt32(reply, &alignment->widthAlignment)) { - HDF_LOGE("%{public}s: read widthAlignment failed!", __func__); - return HDF_FAILURE; - } - if (!HdfSbufReadInt32(reply, &alignment->heightAlignment)) { - HDF_LOGE("%{public}s: read heightAlignment failed!", __func__); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -static int32_t DeserializeCapRect(struct HdfSBuf *reply, Rect *rectangle) -{ - if (reply == NULL || rectangle == NULL) { - HDF_LOGE("%{public}s: params NULL!", __func__); - return HDF_ERR_INVALID_PARAM; - } - if (!HdfSbufReadInt32(reply, &rectangle->width)) { - HDF_LOGE("%{public}s: read width failed!", __func__); - return HDF_FAILURE; - } - if (!HdfSbufReadInt32(reply, &rectangle->height)) { - HDF_LOGE("%{public}s: read height failed!", __func__); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -static int32_t DeserializeCapArray(struct HdfSBuf *reply, ResizableArray *resArr) -{ - if (reply == NULL || resArr == NULL) { - HDF_LOGE("%{public}s: params NULL!", __func__); - return HDF_ERR_INVALID_PARAM; - } - - resArr->actualLen = 0; - if (!HdfSbufReadUint32(reply, &resArr->actualLen)) { - HDF_LOGE("%{public}s: read actualLen failed!", __func__); - return HDF_FAILURE; - } - for (uint32_t i = 0; i < resArr->actualLen; i++) { - if (!HdfSbufReadUint32(reply, &resArr->element[i])) { - HDF_LOGE("%{public}s: read element failed!", __func__); - return HDF_FAILURE; - } - } - return HDF_SUCCESS; -} - -static int32_t DeserializeCodecCapability(struct HdfSBuf *reply, CodecCapbility *cap) -{ - if (reply == NULL || cap == NULL) { - return HDF_ERR_INVALID_PARAM; - } - if (!HdfSbufReadUint32(reply, (uint32_t*)&cap->mime)) { - return HDF_FAILURE; - } - if (!HdfSbufReadUint32(reply, (uint32_t*)&cap->type)) { - return HDF_FAILURE; - } - if (DeserializeCapAlignment(reply, &cap->whAlignment) != HDF_SUCCESS) { - return HDF_FAILURE; - } - if (DeserializeCapRect(reply, &cap->minSize) != HDF_SUCCESS) { - return HDF_FAILURE; - } - if (DeserializeCapRect(reply, &cap->maxSize) != HDF_SUCCESS) { - return HDF_FAILURE; - } - if (!HdfSbufReadUint64(reply, &cap->minBitRate)) { - return HDF_FAILURE; - } - if (!HdfSbufReadUint64(reply, &cap->maxBitRate)) { - return HDF_FAILURE; - } - if (DeserializeCapArray(reply, &cap->supportProfiles) != HDF_SUCCESS) { - return HDF_FAILURE; - } - if (DeserializeCapArray(reply, &cap->supportLevels) != HDF_SUCCESS) { - return HDF_FAILURE; - } - if (DeserializeCapArray(reply, &cap->supportPixelFormats) != HDF_SUCCESS) { - return HDF_FAILURE; - } - if (!HdfSbufReadUint32(reply, &cap->minInputBufferNum)) { - return HDF_FAILURE; - } - if (!HdfSbufReadUint32(reply, &cap->minOutputBufferNum)) { - return HDF_FAILURE; - } - if (!HdfSbufReadUint32(reply, &cap->allocateMask)) { - return HDF_FAILURE; - } - if (!HdfSbufReadUint32(reply, &cap->capsMask)) { - return HDF_FAILURE; - } - - return HDF_SUCCESS; -} - -struct HdfRemoteService *GetConfigService(void) -{ - struct HDIServiceManager *serviceMgr = HDIServiceManagerGet(); - if (serviceMgr == NULL) { - HDF_LOGE("%{public}s: HDIServiceManager not found!", __func__); - return NULL; - } - - struct HdfRemoteService *remote = serviceMgr->GetService(serviceMgr, "codec_capability_config_service"); - if (remote == NULL) { - HDF_LOGE("%{public}s: HdfRemoteService not found!", __func__); - return NULL; - } - if (!HdfRemoteServiceSetInterfaceDesc(remote, "ohos.hdi.codec_service")) { - HDF_LOGE("%{public}s: failed to init interface desc", __func__); - HdfRemoteServiceRecycle(remote); - return NULL; - } - - return remote; -} - -static void ReleaseSbuf(struct HdfSBuf *data, struct HdfSBuf *reply) -{ - if (data != NULL) { - HdfSbufRecycle(data); - } - if (reply != NULL) { - HdfSbufRecycle(reply); - } -} - -int32_t EnumrateCapability(struct HdfRemoteService *remote, int index, CodecCapbility *cap) -{ - struct HdfSBuf *data = HdfSbufTypedObtain(SBUF_IPC); - if (data == NULL) { - HDF_LOGE("%{public}s: Failed to obtain", __func__); - return HDF_FAILURE; - } - struct HdfSBuf *reply = HdfSbufTypedObtain(SBUF_IPC); - if (reply == NULL) { - HDF_LOGE("%{public}s: Failed to obtain reply", __func__); - HdfSbufRecycle(data); - return HDF_FAILURE; - } - if (!HdfRemoteServiceWriteInterfaceToken(remote, data)) { - HDF_LOGE("write interface token failed"); - ReleaseSbuf(data, reply); - return HDF_FAILURE; - } - if (!HdfSbufWriteUint32(data, index)) { - HDF_LOGE("%{public}s: write input index failed!", __func__); - ReleaseSbuf(data, reply); - return HDF_FAILURE; - } - - if (remote->dispatcher->Dispatch(remote, CODEC_CONFIG_CMD_ENUMERATE_CAP, data, reply) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: dispatch request failed!", __func__); - ReleaseSbuf(data, reply); - return HDF_FAILURE; - } - - if (DeserializeCodecCapability(reply, cap) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: DeserializeCodecCapbility failed!", __func__); - ReleaseSbuf(data, reply); - return HDF_FAILURE; - } - - ReleaseSbuf(data, reply); - return HDF_SUCCESS; -} - -int32_t GetCapability(struct HdfRemoteService *remote, - AvCodecMime mime, CodecType type, uint32_t flags, CodecCapbility *cap) -{ - struct HdfSBuf *data = HdfSbufTypedObtain(SBUF_IPC); - if (data == NULL) { - HDF_LOGE("%{public}s: Failed to obtain", __func__); - return HDF_FAILURE; - } - struct HdfSBuf *reply = HdfSbufTypedObtain(SBUF_IPC); - if (reply == NULL) { - HDF_LOGE("%{public}s: Failed to obtain reply", __func__); - HdfSbufRecycle(data); - return HDF_FAILURE; - } - if (!HdfRemoteServiceWriteInterfaceToken(remote, data)) { - HDF_LOGE("write interface token failed"); - ReleaseSbuf(data, reply); - return HDF_FAILURE; - } - if (!HdfSbufWriteUint32(data, (uint32_t)mime)) { - HDF_LOGE("%{public}s: write input mime failed!", __func__); - ReleaseSbuf(data, reply); - return HDF_FAILURE; - } - - if (!HdfSbufWriteUint32(data, (uint32_t)type)) { - HDF_LOGE("%{public}s: write input type failed!", __func__); - ReleaseSbuf(data, reply); - return HDF_FAILURE; - } - - if (!HdfSbufWriteUint32(data, flags)) { - HDF_LOGE("%{public}s: write input flags failed!", __func__); - ReleaseSbuf(data, reply); - return HDF_FAILURE; - } - - if (remote->dispatcher->Dispatch(remote, CODEC_CONFIG_CMD_GET_CAP, data, reply) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: dispatch request failed!", __func__); - ReleaseSbuf(data, reply); - return HDF_FAILURE; - } - - if (DeserializeCodecCapability(reply, cap) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: DeserializeCodecCapbility failed!", __func__); - ReleaseSbuf(data, reply); - return HDF_FAILURE; - } - - ReleaseSbuf(data, reply); - return HDF_SUCCESS; -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ diff --git a/codec/hal/config/common/include/codec_utils.h b/codec/hal/config/common/include/codec_utils.h deleted file mode 100644 index bf4159b9aa36dd2968c20e0bc3d560a997fd9ccd..0000000000000000000000000000000000000000 --- a/codec/hal/config/common/include/codec_utils.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2021 Shenzhen Kaihong DID Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DRIVERS_PERIPHERAL_CODEC_CONFIG_COMMON_UITLS_H_ -#define DRIVERS_PERIPHERAL_CODEC_CONFIG_COMMON_UITLS_H_ - -#include "hdf_base.h" -#include "codec_type.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -void PrintArray(const char *where, const char *name, ResizableArray *array); -void PrintCapability(const char *where, CodecCapbility *cap); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif // DRIVERS_PERIPHERAL_CODEC_CONFIG_COMMON_UITLS_H_ \ No newline at end of file diff --git a/codec/hal/config/common/src/codec_utils.c b/codec/hal/config/common/src/codec_utils.c deleted file mode 100644 index d6be58c83e3b7f3e2817a35582dbb3899543aa7a..0000000000000000000000000000000000000000 --- a/codec/hal/config/common/src/codec_utils.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2021 Shenzhen Kaihong DID Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "codec_utils.h" -#include "hdf_log.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define HDF_LOG_TAG "codec_config_common" - -void PrintArray(const char *where, const char *name, ResizableArray *array) -{ - uint32_t index; - - if (array == NULL) { - return; - } - HDF_LOGI("%{public}s, %{public}s len: %{public}d", where, name, (int32_t)array->actualLen); - for (index = 0; index < array->actualLen; index++) { - HDF_LOGI("%{public}s, %{public}s-%{public}d: %{public}d", - where, name, index, (int32_t)array->element[index]); - } -} - -void PrintCapability(const char *where, CodecCapbility *cap) -{ - int32_t mime = 0; - if (cap == NULL) { - HDF_LOGE("%{public}s, null capability!", where); - return; - } - mime = (int32_t)cap->mime; - if (mime < 0) { - HDF_LOGE("%{public}s, print invalid capability!", where); - return; - } - - HDF_LOGI("%{public}s, --- start print cap ----------------------------", where); - HDF_LOGI("%{public}s, mime: %{public}d", where, (int32_t)cap->mime); - HDF_LOGI("%{public}s, type: %{public}d", where, (int32_t)cap->type); - HDF_LOGI("%{public}s, widthAlignment: %{public}d", where, (int32_t)cap->whAlignment.widthAlignment); - HDF_LOGI("%{public}s, heightAlignment: %{public}d", where, (int32_t)cap->whAlignment.heightAlignment); - HDF_LOGI("%{public}s, minwidth: %{public}d", where, (int32_t)cap->minSize.width); - HDF_LOGI("%{public}s, minHeight: %{public}d", where, (int32_t)cap->minSize.height); - HDF_LOGI("%{public}s, maxwidth: %{public}d", where, (int32_t)cap->maxSize.width); - HDF_LOGI("%{public}s, maxheight: %{public}d", where, (int32_t)cap->maxSize.height); - HDF_LOGI("%{public}s, minBitRate: %{public}d", where, (int32_t)cap->minBitRate); - HDF_LOGI("%{public}s, maxBitRate: %{public}d", where, (int32_t)cap->maxBitRate); - PrintArray(where, "supportProfiles", &(cap->supportProfiles)); - PrintArray(where, "supportLevels", &(cap->supportLevels)); - PrintArray(where, "supportPixelFormats", &(cap->supportPixelFormats)); - HDF_LOGI("%{public}s, minInputBufferNum: %{public}d", where, (int32_t)cap->minInputBufferNum); - HDF_LOGI("%{public}s, minOutputBufferNum: %{public}d", where, (int32_t)cap->minOutputBufferNum); - HDF_LOGI("%{public}s, allocateMask: %{public}d", where, (int32_t)cap->allocateMask); - HDF_LOGI("%{public}s, capsMask: %{public}d", where, (int32_t)cap->capsMask); - HDF_LOGI("%{public}s, ------------------------------ end print cap ---", where); -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ diff --git a/codec/hdi_service/BUILD.gn b/codec/hdi_service/BUILD.gn index b9e213c418afefd29807843429d4ba1def41bacc..17049137c962257e0d38b5adfbc5af3221912906 100644 --- a/codec/hdi_service/BUILD.gn +++ b/codec/hdi_service/BUILD.gn @@ -60,6 +60,7 @@ ohos_shared_library("libcodec_server") { "//drivers/peripheral/codec/hal/v1.0/share_mem/src/share_mem.c", "codec_service_stub/codec_callback_service.c", "codec_service_stub/codec_callback_stub.c", + "codec_service_stub/codec_config_parser.c", "codec_service_stub/codec_host.c", "codec_service_stub/codec_service.c", "codec_service_stub/codec_stub.c", diff --git a/codec/hdi_service/codec_proxy/proxy_msgproc.c b/codec/hdi_service/codec_proxy/proxy_msgproc.c index b6efe643d91adff7b1b96a990138fa22b598760c..e31dc1062bbadd9b6d9c7e1166fb990825ad7954 100644 --- a/codec/hdi_service/codec_proxy/proxy_msgproc.c +++ b/codec/hdi_service/codec_proxy/proxy_msgproc.c @@ -62,7 +62,7 @@ int32_t CodecProxyParseArray(struct HdfSBuf *reply, ResizableArray *resArr) HDF_LOGE("%{public}s: params NULL!", __func__); return HDF_ERR_INVALID_PARAM; } - + resArr->actualLen = 0; if (!HdfSbufReadUint32(reply, &resArr->actualLen)) { HDF_LOGE("%{public}s: read actualLen failed!", __func__); return HDF_FAILURE; diff --git a/codec/hal/config/capability_config/src/config_parser.c b/codec/hdi_service/codec_service_stub/codec_config_parser.c similarity index 47% rename from codec/hal/config/capability_config/src/config_parser.c rename to codec/hdi_service/codec_service_stub/codec_config_parser.c index 03ecc53d85f3b75d0be88cba1bad60b561c717dd..c11919135a722dc9abd929cce893040a314a11cf 100644 --- a/codec/hal/config/capability_config/src/config_parser.c +++ b/codec/hdi_service/codec_service_stub/codec_config_parser.c @@ -13,14 +13,17 @@ * limitations under the License. */ -#include "config_parser.h" +#include "codec_config_parser.h" #include +#include #include "hdf_base.h" #include "hdf_log.h" -#include "codec_utils.h" #define HDF_LOG_TAG "codec_config_parser" +static CodecCapablites codecCapabilites = {0}; +static const struct DeviceResourceNode *resourceNode; + static int32_t GetGroupCapabilitiesNumber(const struct DeviceResourceNode *node, const char *nodeName, int32_t *num) { @@ -52,9 +55,9 @@ static int32_t GetUintTableConfig(const struct DeviceResourceIface *iface, const struct DeviceResourceNode *node, const char *attrName, ResizableArray *table) { int32_t count = iface->GetElemNum(node, attrName); - table->actualLen = 0; if (count <= 0) { + HDF_LOGE("%{public}s, %{public}s not set!", __func__, attrName); return HDF_FAILURE; } if (count > ELEMENT_MAX_LEN) { @@ -62,10 +65,8 @@ static int32_t GetUintTableConfig(const struct DeviceResourceIface *iface, __func__, count, ELEMENT_MAX_LEN); return HDF_FAILURE; } - iface->GetUint32Array(node, attrName, table->element, count, 0); table->actualLen = count; - return HDF_SUCCESS; } @@ -78,6 +79,7 @@ static int32_t GetMaskedConfig(const struct DeviceResourceIface *iface, *mask = 0; if (count <= 0) { + HDF_LOGE("%{public}s, %{public}s not set!", __func__, attrName); return HDF_FAILURE; } @@ -95,6 +97,88 @@ static int32_t GetMaskedConfig(const struct DeviceResourceIface *iface, return HDF_SUCCESS; } +static int32_t GetAudioOfCapability(const struct DeviceResourceIface *iface, + const struct DeviceResourceNode *childNode, CodecCapbility *cap) +{ + if (iface->GetUint32(childNode, CODEC_CONFIG_KEY_MIN_BITRATE, (uint32_t*)&cap->minBitRate, 0) != HDF_SUCCESS) { + cap->mime = MEDIA_MIMETYPE_INVALID; + HDF_LOGE("%{public}s, failed to get %{public}s for: %{public}s! Discarded", + __func__, CODEC_CONFIG_KEY_MIN_BITRATE, childNode->name); + return HDF_FAILURE; + } + if (iface->GetUint32(childNode, CODEC_CONFIG_KEY_MAX_BITRATE, (uint32_t*)&cap->maxBitRate, 0) != HDF_SUCCESS) { + cap->mime = MEDIA_MIMETYPE_INVALID; + HDF_LOGE("%{public}s, failed to get %{public}s for: %{public}s! Discarded", + __func__, CODEC_CONFIG_KEY_MAX_BITRATE, childNode->name); + return HDF_FAILURE; + } + return HDF_SUCCESS; +} + +static int32_t GetVideoOfCapability(const struct DeviceResourceIface *iface, + const struct DeviceResourceNode *childNode, CodecCapbility *cap) +{ + if (iface->GetUint32(childNode, CODEC_CONFIG_KEY_WIDTH_ALIGNMENT, + (uint32_t*)&cap->whAlignment.widthAlignment, 0) != HDF_SUCCESS) { + cap->mime = MEDIA_MIMETYPE_INVALID; + HDF_LOGE("%{public}s, failed to get %{public}s for: %{public}s! Discarded", + __func__, CODEC_CONFIG_KEY_WIDTH_ALIGNMENT, childNode->name); + return HDF_FAILURE; + } + if (iface->GetUint32(childNode, CODEC_CONFIG_KEY_HEIGHT_ALIGNMENT, + (uint32_t*)&cap->whAlignment.heightAlignment, 0) != HDF_SUCCESS) { + cap->mime = MEDIA_MIMETYPE_INVALID; + HDF_LOGE("%{public}s, failed to get %{public}s for: %{public}s! Discarded", + __func__, CODEC_CONFIG_KEY_HEIGHT_ALIGNMENT, childNode->name); + return HDF_FAILURE; + } + if (iface->GetUint32(childNode, CODEC_CONFIG_KEY_MIN_WIDTH, (uint32_t*)&cap->minSize.width, 0) != HDF_SUCCESS) { + cap->mime = MEDIA_MIMETYPE_INVALID; + HDF_LOGE("%{public}s, failed to get %{public}s for: %{public}s! Discarded", + __func__, CODEC_CONFIG_KEY_MIN_WIDTH, childNode->name); + return HDF_FAILURE; + } + if (iface->GetUint32(childNode, CODEC_CONFIG_KEY_MIN_HEIGHT, (uint32_t*)&cap->minSize.height, 0) != HDF_SUCCESS) { + cap->mime = MEDIA_MIMETYPE_INVALID; + HDF_LOGE("%{public}s, failed to get %{public}s for: %{public}s! Discarded", + __func__, CODEC_CONFIG_KEY_MIN_HEIGHT, childNode->name); + return HDF_FAILURE; + } + if (iface->GetUint32(childNode, CODEC_CONFIG_KEY_MAX_WIDTH, (uint32_t*)&cap->maxSize.width, 0) != HDF_SUCCESS) { + cap->mime = MEDIA_MIMETYPE_INVALID; + HDF_LOGE("%{public}s, failed to get %{public}s for: %{public}s! Discarded", + __func__, CODEC_CONFIG_KEY_MAX_WIDTH, childNode->name); + return HDF_FAILURE; + } + if (iface->GetUint32(childNode, CODEC_CONFIG_KEY_MAX_HEIGHT, (uint32_t*)&cap->maxSize.height, 0) != HDF_SUCCESS) { + cap->mime = MEDIA_MIMETYPE_INVALID; + HDF_LOGE("%{public}s, failed to get %{public}s for: %{public}s! Discarded", + __func__, CODEC_CONFIG_KEY_MAX_HEIGHT, childNode->name); + return HDF_FAILURE; + } + return HDF_SUCCESS; +} + +static int32_t GetBufferConfig(const struct DeviceResourceIface *iface, + const struct DeviceResourceNode *childNode, CodecCapbility *cap) +{ + if (iface->GetUint32(childNode, CODEC_CONFIG_KEY_MIN_INPUT_BUFFER_NUM, &cap->minInputBufferNum, 0) + != HDF_SUCCESS) { + cap->mime = MEDIA_MIMETYPE_INVALID; + HDF_LOGE("%{public}s, %{public}s:%{public}s not config.", + __func__, childNode->name, CODEC_CONFIG_KEY_MIN_INPUT_BUFFER_NUM); + return HDF_FAILURE; + } + if (iface->GetUint32(childNode, CODEC_CONFIG_KEY_MIN_OUTPUT_BUFFER_NUM, &cap->minOutputBufferNum, 0) + != HDF_SUCCESS) { + cap->mime = MEDIA_MIMETYPE_INVALID; + HDF_LOGE("%{public}s, %{public}s:%{public}s not config.", + __func__, childNode->name, CODEC_CONFIG_KEY_MIN_OUTPUT_BUFFER_NUM); + return HDF_FAILURE; + } + return HDF_SUCCESS; +} + static int32_t GetOneCapability(const struct DeviceResourceIface *iface, const struct DeviceResourceNode *childNode, CodecCapbility *cap) { @@ -107,39 +191,41 @@ static int32_t GetOneCapability(const struct DeviceResourceIface *iface, HDF_LOGE("%{public}s, failed to get mime for: %{public}s! Discarded", __func__, childNode->name); return HDF_FAILURE; } - if (iface->GetUint32(childNode, CODEC_CONFIG_KEY_TYPE, (uint32_t*)&cap->type, INVALID_TYPE) != HDF_SUCCESS) { cap->mime = MEDIA_MIMETYPE_INVALID; cap->type = INVALID_TYPE; HDF_LOGE("%{public}s, failed to get type for: %{public}s! Discarded", __func__, childNode->name); return HDF_FAILURE; } - - if (iface->GetUint32(childNode, CODEC_CONFIG_KEY_WIDTH_ALIGNMENT, - (uint32_t*)&cap->whAlignment.widthAlignment, 0) != HDF_SUCCESS - || iface->GetUint32(childNode, CODEC_CONFIG_KEY_HEIGHT_ALIGNMENT, - (uint32_t*)&cap->whAlignment.heightAlignment, 0) != HDF_SUCCESS - || iface->GetUint32(childNode, CODEC_CONFIG_KEY_MIN_WIDTH, (uint32_t*)&cap->minSize.width, 0) != HDF_SUCCESS - || iface->GetUint32(childNode, CODEC_CONFIG_KEY_MIN_HEIGHT, (uint32_t*)&cap->minSize.height, 0) != HDF_SUCCESS - || iface->GetUint32(childNode, CODEC_CONFIG_KEY_MAX_WIDTH, (uint32_t*)&cap->maxSize.width, 0) != HDF_SUCCESS - || iface->GetUint32(childNode, CODEC_CONFIG_KEY_MAX_HEIGHT, (uint32_t*)&cap->maxSize.height, 0) != HDF_SUCCESS - || iface->GetUint32(childNode, CODEC_CONFIG_KEY_MIN_BITRATE, (uint32_t*)&cap->minBitRate, 0) != HDF_SUCCESS - || iface->GetUint32(childNode, CODEC_CONFIG_KEY_MAX_BITRATE, (uint32_t*)&cap->maxBitRate, 0) != HDF_SUCCESS - || GetUintTableConfig(iface, childNode, CODEC_CONFIG_KEY_SUPPORT_PROFILES, - &(cap->supportProfiles)) != HDF_SUCCESS - || GetUintTableConfig(iface, childNode, CODEC_CONFIG_KEY_SUPPORT_LEVELS, &(cap->supportLevels)) != HDF_SUCCESS - || GetUintTableConfig(iface, childNode, CODEC_CONFIG_KEY_SUPPORT_PIXELF_MTS, - &(cap->supportPixelFormats)) != HDF_SUCCESS - || iface->GetUint32(childNode, CODEC_CONFIG_KEY_MIN_INPUT_BUFFER_NUM, - &cap->minInputBufferNum, 0) != HDF_SUCCESS - || iface->GetUint32(childNode, CODEC_CONFIG_KEY_MIN_OUTPUT_BUFFER_NUM, - &cap->minOutputBufferNum, 0) != HDF_SUCCESS - || GetMaskedConfig(iface, childNode, CODEC_CONFIG_KEY_ALLOCATE_MASK, &cap->allocateMask) != HDF_SUCCESS - || GetMaskedConfig(iface, childNode, CODEC_CONFIG_KEY_CAPS_MASK, &cap->capsMask) != HDF_SUCCESS) { - cap->mime = MEDIA_MIMETYPE_INVALID; - return HDF_FAILURE; + if (iface->GetUint32(childNode, CODEC_CONFIG_KEY_MAX_BITRATE, (uint32_t*)&cap->maxBitRate, 0) != HDF_SUCCESS) { + cap->mime = MEDIA_MIMETYPE_INVALID; + HDF_LOGE("%{public}s, failed to get %{public}s for: %{public}s! Discarded", + __func__, CODEC_CONFIG_KEY_MAX_BITRATE, childNode->name); + return HDF_FAILURE; + } + if ((GetUintTableConfig(iface, childNode, CODEC_CONFIG_KEY_SUPPORT_PROFILES, &(cap->supportProfiles)) + != HDF_SUCCESS) + || (GetUintTableConfig(iface, childNode, CODEC_CONFIG_KEY_SUPPORT_LEVELS, &(cap->supportLevels)) + != HDF_SUCCESS) + || (GetUintTableConfig(iface, childNode, CODEC_CONFIG_KEY_SUPPORT_PIXELF_MTS, &(cap->supportPixelFormats)) + != HDF_SUCCESS)) { + cap->mime = MEDIA_MIMETYPE_INVALID; + return HDF_FAILURE; + } + if ((GetMaskedConfig(iface, childNode, CODEC_CONFIG_KEY_ALLOCATE_MASK, &cap->allocateMask) != HDF_SUCCESS) + || (GetMaskedConfig(iface, childNode, CODEC_CONFIG_KEY_CAPS_MASK, &cap->capsMask) != HDF_SUCCESS)) { + cap->mime = MEDIA_MIMETYPE_INVALID; + return HDF_FAILURE; + } + if (GetBufferConfig(iface, childNode, cap) != HDF_SUCCESS) { + return HDF_FAILURE; + } + if (GetAudioOfCapability(iface, childNode, cap) != HDF_SUCCESS) { + return HDF_FAILURE; + } + if (GetVideoOfCapability(iface, childNode, cap) != HDF_SUCCESS) { + return HDF_FAILURE; } - return HDF_SUCCESS; } @@ -163,16 +249,19 @@ static int32_t GetGroupCapabilities(const struct DeviceResourceNode *node, return HDF_FAILURE; } DEV_RES_NODE_FOR_EACH_CHILD_NODE(codecGroupNode, childNode) { + if (index >= capsGroup->num) { + HDF_LOGE("%{public}s, failed to get child node: %{public}s, index error!", __func__, nodeName); + return HDF_FAILURE; + } cap = &(capsGroup->capablitis[index++]); GetOneCapability(iface, childNode, cap); } - return HDF_SUCCESS; } -int32_t LoadCodecCapabilityFromHcs(const struct DeviceResourceNode *node, CodecCapablites *caps) +int32_t LoadCodecCapabilityFromHcs(const struct DeviceResourceNode *node) { - CodecCapablityGroup *codecCapGroup; + CodecCapablityGroup *codecCapGroup = NULL; int32_t index; int32_t codecNum = 0; @@ -180,6 +269,7 @@ int32_t LoadCodecCapabilityFromHcs(const struct DeviceResourceNode *node, CodecC HDF_LOGE("%{public}s, load capability failed, node is null!", __func__); return HDF_FAILURE; } + resourceNode = node; char *codecGroupsNodeName[] = { NODE_VIDEO_HARDWARE_ENCODERS, NODE_VIDEO_HARDWARE_DECODERS, @@ -187,20 +277,17 @@ int32_t LoadCodecCapabilityFromHcs(const struct DeviceResourceNode *node, CodecC NODE_AUDIO_HARDWARE_ENCODERS, NODE_AUDIO_HARDWARE_DECODERS, NODE_AUDIO_SOFTWARE_ENCODERS, NODE_AUDIO_SOFTWARE_DECODERS }; - CodecCapablityGroup *codecCapGroups[] = { - &(caps->videoHwEncoderGroup), &(caps->videoHwDecoderGroup), - &(caps->videoSwEncoderGroup), &(caps->videoSwDecoderGroup), - &(caps->audioHwEncoderGroup), &(caps->audioHwDecoderGroup), - &(caps->audioSwEncoderGroup), &(caps->audioSwDecoderGroup) - }; - for (index = 0; index < CODEC_CAPABLITY_GROUP_NUM; index++) { + codecCapGroup = GetCapablityGroup(index); + if (codecCapGroup == NULL) { + continue; + } if (GetGroupCapabilitiesNumber(node, codecGroupsNodeName[index], &codecNum) == HDF_SUCCESS) { - codecCapGroup = codecCapGroups[index]; codecCapGroup->num = codecNum; if (codecNum > 0) { - codecCapGroup->capablitis - = (CodecCapbility *)OsalMemAlloc(sizeof(CodecCapbility) * codecNum); + size_t capablitisSize = sizeof(CodecCapbility) * codecNum; + codecCapGroup->capablitis = (CodecCapbility *)OsalMemAlloc(capablitisSize); + memset_s(codecCapGroup->capablitis, capablitisSize, 0, capablitisSize); } else { codecCapGroup->capablitis = NULL; } @@ -209,38 +296,64 @@ int32_t LoadCodecCapabilityFromHcs(const struct DeviceResourceNode *node, CodecC HDF_LOGE("%{public}s, MemAlloc for capability group failed!", __func__); return HDF_FAILURE; } + } else { + codecCapGroup->num = 0; } } - for (index = 0; index < CODEC_CAPABLITY_GROUP_NUM; index++) { - if (GetGroupCapabilities(node, codecGroupsNodeName[index], codecCapGroups[index]) != HDF_SUCCESS) { + if (GetGroupCapabilities(node, codecGroupsNodeName[index], GetCapablityGroup(index)) != HDF_SUCCESS) { return HDF_FAILURE; } } - caps->inited = true; + codecCapabilites.inited = true; return HDF_SUCCESS; } -int32_t ClearCapabilityGroup(CodecCapablites *caps) +int32_t ClearCapabilityGroup() { int32_t index; - CodecCapablityGroup *codecCapGroup; - CodecCapablityGroup *codecCapGroups[] = { - &(caps->videoHwEncoderGroup), &(caps->videoHwDecoderGroup), - &(caps->videoSwEncoderGroup), &(caps->videoSwDecoderGroup), - &(caps->audioHwEncoderGroup), &(caps->audioHwDecoderGroup), - &(caps->audioSwEncoderGroup), &(caps->audioSwDecoderGroup) - }; + CodecCapablityGroup *codecCapGroup = NULL; for (index = 0; index < CODEC_CAPABLITY_GROUP_NUM; index++) { - codecCapGroup = codecCapGroups[index]; + codecCapGroup = GetCapablityGroup(index); + if (codecCapGroup == NULL) { + continue; + } if (codecCapGroup->capablitis != NULL) { OsalMemFree(codecCapGroup->capablitis); codecCapGroup->num = 0; codecCapGroup->capablitis = NULL; } } - caps->inited = false; + codecCapabilites.inited = false; + return HDF_SUCCESS; +} +CodecCapablityGroup *GetCapablityGroup(int32_t groupIndex) +{ + CodecCapablityGroup *codecCapGroups[] = { + &(codecCapabilites.videoHwEncoderGroup), &(codecCapabilites.videoHwDecoderGroup), + &(codecCapabilites.videoSwEncoderGroup), &(codecCapabilites.videoSwDecoderGroup), + &(codecCapabilites.audioHwEncoderGroup), &(codecCapabilites.audioHwDecoderGroup), + &(codecCapabilites.audioSwEncoderGroup), &(codecCapabilites.audioSwDecoderGroup) + }; + if (groupIndex < 0) { + return NULL; + } + if (groupIndex >= CODEC_CAPABLITY_GROUP_NUM) { + return NULL; + } + return codecCapGroups[groupIndex]; +} + +bool CodecCapablitesInited() +{ + return codecCapabilites.inited; +} + +int32_t ReloadCapabilities() +{ + ClearCapabilityGroup(); + LoadCodecCapabilityFromHcs(resourceNode); return HDF_SUCCESS; } \ No newline at end of file diff --git a/codec/hal/config/capability_config/include/config_parser.h b/codec/hdi_service/codec_service_stub/codec_config_parser.h similarity index 95% rename from codec/hal/config/capability_config/include/config_parser.h rename to codec/hdi_service/codec_service_stub/codec_config_parser.h index bcc42fe6ff4b61fcfa69724aba9e67af03d61140..979845d2b0c54b5c24a83702e4a203599ce366ea 100644 --- a/codec/hal/config/capability_config/include/config_parser.h +++ b/codec/hdi_service/codec_service_stub/codec_config_parser.h @@ -77,7 +77,10 @@ typedef struct { CodecCapablityGroup audioSwDecoderGroup; } CodecCapablites; -int32_t LoadCodecCapabilityFromHcs(const struct DeviceResourceNode *node, CodecCapablites *caps); -int32_t ClearCapabilityGroup(CodecCapablites *caps); +int32_t LoadCodecCapabilityFromHcs(const struct DeviceResourceNode *node); +int32_t ClearCapabilityGroup(); +CodecCapablityGroup *GetCapablityGroup(int32_t groupIndex); +bool CodecCapablitesInited(); +int32_t ReloadCapabilities(); #endif // DRIVERS_PERIPHERAL_CODEC_CONFIG_PARSER_H_ diff --git a/codec/hdi_service/codec_service_stub/codec_host.c b/codec/hdi_service/codec_service_stub/codec_host.c index 1355047d9d98ec39382be62c75175d8a6638ef8f..d729732f937d9fcd27ae282ffb31197dcf98832e 100644 --- a/codec/hdi_service/codec_service_stub/codec_host.c +++ b/codec/hdi_service/codec_service_stub/codec_host.c @@ -13,10 +13,12 @@ * limitations under the License. */ -#include "codec_stub.h" #include #include #include +#include "codec_config_parser.h" +#include "codec_stub.h" + static int32_t CodecServiceDispatch(struct HdfDeviceIoClient *client, int cmdId, struct HdfSBuf *data, struct HdfSBuf *reply) @@ -28,11 +30,12 @@ void HdfCodecDriverRelease(struct HdfDeviceObject *deviceObject) { struct IDeviceIoService *testService = deviceObject->service; OsalMemFree(testService); + ClearCapabilityGroup(); } int HdfCodecDriverBind(struct HdfDeviceObject *deviceObject) { - HDF_LOGE("HdfCodecDriverBind enter!"); + HDF_LOGI("HdfCodecDriverBind enter!"); struct IDeviceIoService *ioService = (struct IDeviceIoService *)OsalMemAlloc(sizeof(struct IDeviceIoService)); if (ioService == NULL) { @@ -54,7 +57,11 @@ int HdfCodecDriverBind(struct HdfDeviceObject *deviceObject) int HdfCodecDriverInit(struct HdfDeviceObject *deviceObject) { - HDF_LOGE("HdfSampleDriverCInit enter, new hdi impl"); + HDF_LOGI("HdfSampleDriverCInit enter, new hdi impl"); + if (LoadCodecCapabilityFromHcs(deviceObject->property) != HDF_SUCCESS) { + HDF_LOGE("LoadCodecCapabilityFromHcs failed"); + ClearCapabilityGroup(); + } return HDF_SUCCESS; } diff --git a/codec/hdi_service/codec_service_stub/codec_service.c b/codec/hdi_service/codec_service_stub/codec_service.c index 1f62e168526de0089a84753a1ed619c97e5e59b0..6ea9e7a72eff5d21971d5551000ad8a8a27cdbc5 100644 --- a/codec/hdi_service/codec_service_stub/codec_service.c +++ b/codec/hdi_service/codec_service_stub/codec_service.c @@ -21,10 +21,15 @@ #include #include #include "ashmem_wrapper.h" +#include "codec_config_parser.h" #include "hdf_log.h" #include "osal_mem.h" #define HDF_LOG_TAG codec_hdi_service +#define VIDEO_HARDWARE_ENCODER_INDEX 0 +#define VIDEO_HARDWARE_DECODER_INDEX 1 +#define AUDIO_HARDWARE_ENCODER_INDEX 4 +#define AUDIO_HARDWARE_DECODER_INDEX 5 struct CodecInstance *g_codecInstance = NULL; @@ -191,12 +196,54 @@ int32_t CodecDeinit() int32_t CodecEnumerateCapbility(uint32_t index, CodecCapbility *cap) { - return HDF_SUCCESS; + int32_t loopIndex; + uint32_t cursor = index; + CodecCapablityGroup *group = NULL; + for (loopIndex = 0; loopIndex < CODEC_CAPABLITY_GROUP_NUM; loopIndex++) { + group = GetCapablityGroup(loopIndex); + if (group == NULL) { + continue; + } + if (cursor + 1 <= (uint32_t)group->num) { + *cap = group->capablitis[cursor]; + return HDF_SUCCESS; + } else { + cursor -= group->num; + } + } + + return HDF_FAILURE; } int32_t CodecGetCapbility(AvCodecMime mime, CodecType type, uint32_t flags, CodecCapbility *cap) { - return HDF_SUCCESS; + int32_t groupIndex; + int32_t capIndex; + CodecCapablityGroup *group = NULL; + CodecCapbility *capItem; + bool inputHardwareFlag = flags == 0; + + for (groupIndex = 0; groupIndex < CODEC_CAPABLITY_GROUP_NUM; groupIndex++) { + group = GetCapablityGroup(groupIndex); + if (group == NULL) { + continue; + } + bool curHardwareFlag = (groupIndex == VIDEO_HARDWARE_ENCODER_INDEX) + || (groupIndex == VIDEO_HARDWARE_DECODER_INDEX) || (groupIndex == AUDIO_HARDWARE_ENCODER_INDEX) + || (groupIndex == AUDIO_HARDWARE_DECODER_INDEX); + if (inputHardwareFlag != curHardwareFlag) { + continue; + } + for (capIndex = 0; capIndex < group->num; capIndex++) { + capItem = &group->capablitis[capIndex]; + if (mime == capItem->mime && type == capItem->type) { + *cap = group->capablitis[capIndex]; + return HDF_SUCCESS; + } + } + } + + return HDF_FAILURE; } int32_t CodecCreate(const char* name, const Param *attr, int32_t len, CODEC_HANDLETYPE *handle) diff --git a/codec/hdi_service/codec_service_stub/codec_stub.c b/codec/hdi_service/codec_service_stub/codec_stub.c index d1e3bc2258ed5bf56f3103d3e298f16d844be90c..55a0b52b769dcaf3dcd4262535f82dfa4e4ae327 100644 --- a/codec/hdi_service/codec_service_stub/codec_stub.c +++ b/codec/hdi_service/codec_service_stub/codec_stub.c @@ -17,10 +17,11 @@ #include #include #include "codec_callback_proxy.h" +#include "codec_config_parser.h" #include "codec_interface.h" +#include "codec_service.h" #include "icodec.h" #include "stub_msgproc.h" -#include "codec_service.h" #define HDF_LOG_TAG codec_hdi_stub #define HDF_CODEC_NAME_LEN 50 @@ -52,35 +53,42 @@ static int32_t SerCodecDeinit(struct HdfDeviceIoClient *client, struct HdfSBuf * } return errNum; } + static int32_t SerCodecEnumerateCapbility(struct HdfDeviceIoClient *client, struct HdfSBuf *data, - struct HdfSBuf *reply) + struct HdfSBuf *reply) { uint32_t index; CodecCapbility capbility; - if (!HdfSbufReadUint32(data, (uint32_t *)&index)) { - HDF_LOGE("%{public}s: read index data failed!", __func__); - return HDF_ERR_INVALID_PARAM; + if (!HdfSbufReadUint32(data, &index)) { + HDF_LOGE("%{public}s: read index failed!", __func__); + return HDF_FAILURE; } - int32_t errNum = HDF_SUCCESS; - if (errNum != HDF_SUCCESS) { - HDF_LOGE("%{public}s: call CodecEnumerateCapbility fuc failed!", __func__); - return errNum; + if (!CodecCapablitesInited()) { + HDF_LOGE("%{public}s: codec capablities not inited!", __func__); + return HDF_FAILURE; + } + if (CodecEnumerateCapbility(index, &capbility) != HDF_SUCCESS) { + HDF_LOGE("%{public}s: EnumrateCapablity - no more capability to Enumrate!", __func__); + return HDF_FAILURE; + } + if (capbility.mime == MEDIA_MIMETYPE_INVALID) { + HDF_LOGE("%{public}s: Capablity invalid, discard!", __func__); + return HDF_FAILURE; } if (CodecSerPackCapbility(reply, &capbility) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: write capbility failed!", __func__); - return HDF_ERR_INVALID_PARAM; + HDF_LOGE("%{public}s: write capbility to sbuf failed!", __func__); + return HDF_FAILURE; } - return errNum; + return HDF_SUCCESS; } static int32_t SerCodecGetCapbility(struct HdfDeviceIoClient *client, struct HdfSBuf *data, struct HdfSBuf *reply) { uint32_t flags; - int32_t errNum; AvCodecMime mime; CodecType type; - CodecCapbility cap; + CodecCapbility capbility; if (!HdfSbufReadUint32(data, (uint32_t*)&mime)) { HDF_LOGE("%{public}s: read input mime failed!", __func__); @@ -94,16 +102,15 @@ static int32_t SerCodecGetCapbility(struct HdfDeviceIoClient *client, struct Hdf HDF_LOGE("%{public}s: read input flags failed!", __func__); return HDF_ERR_INVALID_PARAM; } - errNum = CodecGetCapbility(mime, type, flags, &cap); - if (errNum != HDF_SUCCESS) { - HDF_LOGE("%{public}s: call CodecGetCapbility fuc failed!", __func__); - return errNum; + if (CodecGetCapbility(mime, type, flags, &capbility) != HDF_SUCCESS) { + HDF_LOGE("%{public}s: GetCapability - got nothing!", __func__); + return HDF_FAILURE; } - if (CodecSerPackCapbility(reply, &cap) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: write cap failed!", __func__); - return HDF_ERR_INVALID_PARAM; + if (CodecSerPackCapbility(reply, &capbility) != HDF_SUCCESS) { + HDF_LOGE("%{public}s: write capbility to sbuf failed!", __func__); + return HDF_FAILURE; } - return errNum; + return HDF_SUCCESS; } static int32_t SerCodecCreate(struct HdfDeviceIoClient *client, struct HdfSBuf *data, struct HdfSBuf *reply) @@ -554,6 +561,11 @@ int32_t CodecServiceOnRemoteRequest(struct HdfDeviceIoClient *client, int cmdId, HDF_LOGE("check interface token failed"); return HDF_ERR_INVALID_PARAM; } + if ((cmdId == CMD_CODEC_ENUM_CAP) || (cmdId == CMD_CODEC_GET_CAP)) { + if (!CodecCapablitesInited()) { + ReloadCapabilities(); + } + } switch (cmdId) { case CMD_CODEC_INIT: return SerCodecInit(client, data, reply); diff --git a/codec/test/demo/v2.0/BUILD.gn b/codec/test/demo/v2.0/BUILD.gn index 1d263e1d895582e13405a421b65bd6273e589b1f..07b98d8b3ced99eb569e05e00774230259460adf 100644 --- a/codec/test/demo/v2.0/BUILD.gn +++ b/codec/test/demo/v2.0/BUILD.gn @@ -20,8 +20,6 @@ ohos_executable("codec_hdi_omx_decode") { "//drivers/adapter/uhdf2/include/hdi", "//drivers/peripheral/codec/omx/include", "//drivers/peripheral/codec/interfaces/include", - "//drivers/peripheral/codec/hal/config/capability_config/include", - "//drivers/peripheral/codec/hal/config/common/include", "//utils/native/base/include", "//third_party/openmax/api/1.1.2", "//drivers/peripheral/display/hdi_service/gralloc/include", @@ -65,8 +63,6 @@ ohos_executable("codec_hdi_omx_encode") { "//drivers/adapter/uhdf2/include/hdi", "//drivers/peripheral/codec/omx/include", "//drivers/peripheral/codec/interfaces/include", - "//drivers/peripheral/codec/hal/config/capability_config/include", - "//drivers/peripheral/codec/hal/config/common/include", "//utils/native/base/include", "//third_party/openmax/api/1.1.2", "//drivers/peripheral/display/hdi_service/gralloc/include", diff --git a/codec/test/unittest/config/BUILD.gn b/codec/test/unittest/config/BUILD.gn deleted file mode 100644 index a108668209d1077775756b1369923c3621b4c0a2..0000000000000000000000000000000000000000 --- a/codec/test/unittest/config/BUILD.gn +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright (c) 2021 Shenzhen Kaihong DID Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//build/test.gni") -import("//drivers/adapter/uhdf2/uhdf.gni") - -ohos_unittest("codec_config_test") { - module_out_path = "hdf/codec" - include_dirs = [ - "//drivers/peripheral/codec/interfaces/include", - "//drivers/peripheral/codec/hal/config/capability_config/include", - "//drivers/peripheral/codec/hal/config/common/include", - ] - sources = [ - "//drivers/peripheral/codec/hal/config/capability_config/src/codec_config_reader.c", - "//drivers/peripheral/codec/hal/config/common/src/codec_utils.c", - "codec_config_test.cpp", - ] - - cflags = [ - "-Wall", - "-Wextra", - "-Werror", - "-fsigned-char", - "-fno-common", - "-fno-strict-aliasing", - ] - - deps = [ "//third_party/googletest:gtest_main" ] - - if (is_standard_system) { - external_deps = [ - "device_driver_framework:libhdf_host", - "device_driver_framework:libhdf_ipc_adapter", - "device_driver_framework:libhdf_utils", - "device_driver_framework:libhdi", - "hiviewdfx_hilog_native:libhilog", - ] - } else { - external_deps = [ "hilog:libhilog" ] - } -} diff --git a/codec/test/unittest/config/codec_config_test.cpp b/codec/test/unittest/config/codec_config_test.cpp deleted file mode 100644 index b30b4b0c7c21e98aeec1528ade9005454e06f023..0000000000000000000000000000000000000000 --- a/codec/test/unittest/config/codec_config_test.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2021 Shenzhen Kaihong DID Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "hdf_io_service_if.h" -#include "codec_config_reader.h" -#include "codec_utils.h" -#include "codec_type.h" - -using namespace std; -using namespace testing::ext; - -namespace { -class CodecConfigTest : public testing::Test { -public: - static void SetUpTestCase() {} - static void TearDownTestCase() {} - void SetUp() {} - void TearDown() {} -}; - -HWTEST_F(CodecConfigTest, CodecConfigTest_001, TestSize.Level0) -{ - struct HdfRemoteService *remote = GetConfigService(); - ASSERT_TRUE(remote != nullptr); - - for (int index = 0; index < 9; index++) { - CodecCapbility cap; - if (EnumrateCapability(remote, index, &cap) == HDF_SUCCESS) { - PrintCapability("codec_config_utest", &cap); - } - } -} - -HWTEST_F(CodecConfigTest, CodecConfigTest_002, TestSize.Level0) -{ - struct HdfRemoteService *remote = GetConfigService(); - ASSERT_TRUE(remote != nullptr); - - CodecCapbility cap; - if (GetCapability(remote, MEDIA_MIMETYPE_VIDEO_HEVC, VIDEO_ENCODER, 0, &cap) == HDF_SUCCESS) { - PrintCapability("codec_config_utest", &cap); - } -} -} diff --git a/codec/test/unittest/hdi_v1.0/BUILD.gn b/codec/test/unittest/hdi_v1.0/BUILD.gn index 36c9cbeed3e40ce0b002d538835715f56e0034f1..1e9d84280970e132eabdf5750a7a2d9890cb196d 100644 --- a/codec/test/unittest/hdi_v1.0/BUILD.gn +++ b/codec/test/unittest/hdi_v1.0/BUILD.gn @@ -21,15 +21,9 @@ ohos_unittest("codec_hdi_1.0_test") { "//drivers/peripheral/codec/interfaces/include/", "//drivers/peripheral/codec/hdi_service/codec_proxy/", "//drivers/peripheral/codec/hdi_service/codec_service_stub/", - "//drivers/peripheral/codec/hal/config/capability_config/include", - "//drivers/peripheral/codec/hal/config/common/include", "//drivers/peripheral/codec/hal/v1.0/share_mem/include", ] - sources = [ - "//drivers/peripheral/codec/hal/config/capability_config/src/codec_config_reader.c", - "//drivers/peripheral/codec/hal/config/common/src/codec_utils.c", - "codec_proxy_test.cpp", - ] + sources = [ "codec_proxy_test.cpp" ] cflags = [ "-Wall", diff --git a/codec/test/unittest/hdi_v1.0/codec_proxy_test.cpp b/codec/test/unittest/hdi_v1.0/codec_proxy_test.cpp index 144333790bf98c45dc246125f69a068cab4d42ce..009984b4d716ce88154a1b645eb2ab4980b4e517 100644 --- a/codec/test/unittest/hdi_v1.0/codec_proxy_test.cpp +++ b/codec/test/unittest/hdi_v1.0/codec_proxy_test.cpp @@ -17,8 +17,7 @@ #include #include #include "codec_callback_stub.h" -#include "codec_config_reader.h" -#include "codec_utils.h" +#include "hdf_log.h" #include "icodec.h" #include "share_mem.h" @@ -42,6 +41,7 @@ constexpr const char *TEST_SERVICE_NAME = "codec_hdi_service"; constexpr const int TEST_PACKET_BUFFER_SIZE = 4096; constexpr const int TEST_FRAME_BUFFER_SIZE = 640 * 480 * 3 / 2; constexpr const int QUEUE_TIME_OUT = 10; +constexpr const int CAPABILITY_COUNT = 8; struct ICodec *codecObj = nullptr; ShareMemory inputBuffer; ShareMemory outputBuffer; @@ -60,6 +60,54 @@ public: void TearDown() {} }; +static void PrintArray(const char *where, const char *name, ResizableArray *array) +{ + uint32_t index; + + if (array == NULL) { + return; + } + HDF_LOGI("%{public}s, %{public}s len: %{public}d", where, name, (int32_t)array->actualLen); + for (index = 0; index < array->actualLen; index++) { + HDF_LOGI("%{public}s, %{public}s-%{public}d: %{public}d", + where, name, index, (int32_t)array->element[index]); + } +} + +static void PrintCapability(const char *where, CodecCapbility *cap) +{ + int32_t mime = 0; + if (cap == NULL) { + HDF_LOGE("%{public}s, null capability!", where); + return; + } + mime = (int32_t)cap->mime; + if (mime < 0) { + HDF_LOGE("%{public}s, print invalid capability!", where); + return; + } + + HDF_LOGI("%{public}s, --- start print cap ----------------------------", where); + HDF_LOGI("%{public}s, mime: %{public}d", where, (int32_t)cap->mime); + HDF_LOGI("%{public}s, type: %{public}d", where, (int32_t)cap->type); + HDF_LOGI("%{public}s, widthAlignment: %{public}d", where, (int32_t)cap->whAlignment.widthAlignment); + HDF_LOGI("%{public}s, heightAlignment: %{public}d", where, (int32_t)cap->whAlignment.heightAlignment); + HDF_LOGI("%{public}s, minwidth: %{public}d", where, (int32_t)cap->minSize.width); + HDF_LOGI("%{public}s, minHeight: %{public}d", where, (int32_t)cap->minSize.height); + HDF_LOGI("%{public}s, maxwidth: %{public}d", where, (int32_t)cap->maxSize.width); + HDF_LOGI("%{public}s, maxheight: %{public}d", where, (int32_t)cap->maxSize.height); + HDF_LOGI("%{public}s, minBitRate: %{public}d", where, (int32_t)cap->minBitRate); + HDF_LOGI("%{public}s, maxBitRate: %{public}d", where, (int32_t)cap->maxBitRate); + PrintArray(where, "supportProfiles", &(cap->supportProfiles)); + PrintArray(where, "supportLevels", &(cap->supportLevels)); + PrintArray(where, "supportPixelFormats", &(cap->supportPixelFormats)); + HDF_LOGI("%{public}s, minInputBufferNum: %{public}d", where, (int32_t)cap->minInputBufferNum); + HDF_LOGI("%{public}s, minOutputBufferNum: %{public}d", where, (int32_t)cap->minOutputBufferNum); + HDF_LOGI("%{public}s, allocateMask: %{public}d", where, (int32_t)cap->allocateMask); + HDF_LOGI("%{public}s, capsMask: %{public}d", where, (int32_t)cap->capsMask); + HDF_LOGI("%{public}s, ------------------------------ end print cap ---", where); +} + HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetCodecObjTest_001, TestSize.Level1) { codecObj = HdiCodecGet(TEST_SERVICE_NAME); @@ -68,13 +116,10 @@ HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetCodecObjTest_001, TestSize.Level1) HWTEST_F(CodecProxyTest, HdfCodecHdiV1EnumerateCapbilityTest_002, TestSize.Level1) { - struct HdfRemoteService *remote = GetConfigService(); - ASSERT_TRUE(remote != nullptr); - int32_t ret = HDF_SUCCESS; - for (int32_t index = 0; index < 8; index++) { + for (int index = 0; index < CAPABILITY_COUNT; index++) { CodecCapbility cap; - ret = EnumrateCapability(remote, index, &cap); + ret = codecObj->CodecEnumerateCapbility(codecObj, index, &cap); ASSERT_EQ(ret, HDF_SUCCESS); PrintCapability("codec_config_utest", &cap); } @@ -82,11 +127,8 @@ HWTEST_F(CodecProxyTest, HdfCodecHdiV1EnumerateCapbilityTest_002, TestSize.Level HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetCapbilityTest_003, TestSize.Level1) { - struct HdfRemoteService *remote = GetConfigService(); - ASSERT_TRUE(remote != nullptr); - CodecCapbility cap; - int32_t ret = GetCapability(remote, MEDIA_MIMETYPE_VIDEO_HEVC, VIDEO_ENCODER, 0, &cap); + int32_t ret = codecObj->CodecGetCapbility(codecObj, MEDIA_MIMETYPE_VIDEO_HEVC, VIDEO_ENCODER, 0, &cap); ASSERT_EQ(ret, HDF_SUCCESS); PrintCapability("codec_config_utest", &cap); }