mirror of
https://github.com/openharmony/drivers_peripheral.git
synced 2026-08-24 18:15:56 -04:00
feat: Add multi instance of CodecComponentType
Signed-off-by: zhangguorong <zhangguorong@kaihongdigi.com>
This commit is contained in:
+4
-2
@@ -13,10 +13,12 @@
|
||||
"deps": {
|
||||
"components": [
|
||||
"device_driver_framework",
|
||||
"hiviewdfx_hilog_native"
|
||||
"hiviewdfx_hilog_native",
|
||||
"display"
|
||||
],
|
||||
"third_part": [
|
||||
"googletest"
|
||||
"googletest",
|
||||
"libdrm"
|
||||
]
|
||||
},
|
||||
"build": {
|
||||
|
||||
+21
-53
@@ -17,20 +17,41 @@ import("//drivers/adapter/uhdf2/uhdf.gni")
|
||||
ohos_shared_library("libcodec_hdi_omx_server") {
|
||||
include_dirs = [
|
||||
"//drivers/peripheral/codec/interfaces/include",
|
||||
"//drivers/peripheral/codec/hal/v2.0/hdi_impl/include",
|
||||
"//drivers/peripheral/codec/hal/include",
|
||||
"//third_party/openmax/api/1.1.2",
|
||||
"//drivers/peripheral/base",
|
||||
]
|
||||
sources = [
|
||||
"src/codec_adapter.cpp",
|
||||
"src/codec_callback_type_proxy.c",
|
||||
"src/codec_component_capability_config.c",
|
||||
"src/codec_component_manager_service.c",
|
||||
"src/codec_component_manager_stub.c",
|
||||
"src/codec_component_type_driver.c",
|
||||
"src/codec_component_type_service.c",
|
||||
"src/codec_component_type_stub.c",
|
||||
"src/codec_config_parser.c",
|
||||
"src/codec_types.c",
|
||||
"v2.0/hdi_impl/src/codec_dyna_buffer.cpp",
|
||||
"v2.0/hdi_impl/src/codec_handle_buffer.cpp",
|
||||
"v2.0/hdi_impl/src/codec_share_buffer.cpp",
|
||||
"v2.0/hdi_impl/src/component_mgr.cpp",
|
||||
"v2.0/hdi_impl/src/component_node.cpp",
|
||||
"v2.0/hdi_impl/src/icodec_buffer.cpp",
|
||||
]
|
||||
|
||||
cflags_cc = [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Werror",
|
||||
"-Wno-#warnings",
|
||||
"-Wno-missing-braces",
|
||||
"-Wno-missing-field-initializers",
|
||||
]
|
||||
|
||||
if (is_standard_system) {
|
||||
deps = [ "//third_party/libdrm:libdrm" ]
|
||||
external_deps = [
|
||||
"device_driver_framework:libhdf_host",
|
||||
"device_driver_framework:libhdf_ipc_adapter",
|
||||
@@ -79,58 +100,6 @@ ohos_shared_library("libcodec_hdi_omx_client") {
|
||||
} else {
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
}
|
||||
|
||||
install_images = [ chipset_base_dir ]
|
||||
subsystem_name = "hdf"
|
||||
part_name = "codec_device_driver"
|
||||
}
|
||||
|
||||
ohos_shared_library("libcodec_hdi_omx_service_impl") {
|
||||
include_dirs = [
|
||||
"//drivers/adapter/uhdf2/include/hdi",
|
||||
"//drivers/peripheral/codec/hal/v2.0/hdi_impl/include",
|
||||
"//drivers/peripheral/codec/interfaces/include",
|
||||
"//drivers/peripheral/codec/hal/include",
|
||||
"//third_party/openmax/api/1.1.2",
|
||||
"//drivers/peripheral/base",
|
||||
]
|
||||
sources = [
|
||||
"src/codec_adapter.cpp",
|
||||
"src/codec_component_type_service.c",
|
||||
"v2.0/hdi_impl/src/codec_dyna_buffer.cpp",
|
||||
"v2.0/hdi_impl/src/codec_handle_buffer.cpp",
|
||||
"v2.0/hdi_impl/src/codec_share_buffer.cpp",
|
||||
"v2.0/hdi_impl/src/component_mgr.cpp",
|
||||
"v2.0/hdi_impl/src/component_node.cpp",
|
||||
"v2.0/hdi_impl/src/component_node_mgr.cpp",
|
||||
"v2.0/hdi_impl/src/icodec_buffer.cpp",
|
||||
]
|
||||
|
||||
cflags_cc = [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Werror",
|
||||
"-Wno-#warnings",
|
||||
"-Wno-missing-braces",
|
||||
"-Wno-missing-field-initializers",
|
||||
]
|
||||
|
||||
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",
|
||||
"graphic_chipsetsdk:buffer_handle",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"utils_base:utils",
|
||||
]
|
||||
|
||||
deps = [ "//third_party/libdrm:libdrm" ]
|
||||
} else {
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
}
|
||||
|
||||
install_images = [ chipset_base_dir ]
|
||||
subsystem_name = "hdf"
|
||||
part_name = "codec_device_driver"
|
||||
@@ -168,6 +137,5 @@ group("codec_hdi_omx") {
|
||||
":libcodec_hdi_omx_callback_type_service_impl",
|
||||
":libcodec_hdi_omx_client",
|
||||
":libcodec_hdi_omx_server",
|
||||
":libcodec_hdi_omx_service_impl",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -21,91 +21,95 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct CodecComponentNode;
|
||||
/**
|
||||
* @brief Create a component by name.
|
||||
*/
|
||||
extern int32_t OMXAdapterCreateComponent(OMX_HANDLETYPE *compHandle, char *compName, int8_t *appData,
|
||||
int32_t appDataSize, struct CodecCallbackType *callbacks);
|
||||
extern int32_t OMXAdapterCreateComponent(struct CodecComponentNode **codecNode, char *compName, int64_t appData,
|
||||
struct CodecCallbackType *callbacks);
|
||||
/**
|
||||
* @brief Release the componet by handle.
|
||||
*/
|
||||
extern int32_t OmxAdapterDestoryComponent(OMX_HANDLETYPE compHandle);
|
||||
extern int32_t OmxAdapterDestoryComponent(struct CodecComponentNode *codecNode);
|
||||
/**
|
||||
* @brief Get the version of the component.
|
||||
*/
|
||||
extern int32_t OmxAdapterComponentVersion(OMX_HANDLETYPE compHandle, struct CompVerInfo *verInfo);
|
||||
extern int32_t OmxAdapterComponentVersion(struct CodecComponentNode *codecNode, struct CompVerInfo *verInfo);
|
||||
/**
|
||||
* @brief Send command to the component.
|
||||
*/
|
||||
extern int32_t OmxAdapterSendCommand(OMX_HANDLETYPE compHandle, enum OMX_COMMANDTYPE cmd, uint32_t param,
|
||||
extern int32_t OmxAdapterSendCommand(struct CodecComponentNode *codecNode, enum OMX_COMMANDTYPE cmd, uint32_t param,
|
||||
int8_t *cmdData, uint32_t cmdDataLen);
|
||||
/**
|
||||
* @brief Get the parameter by index.
|
||||
*/
|
||||
extern int32_t OmxAdapterGetParameter(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE paramIndex, int8_t *param,
|
||||
uint32_t paramLen);
|
||||
extern int32_t OmxAdapterGetParameter(struct CodecComponentNode *codecNode, enum OMX_INDEXTYPE paramIndex,
|
||||
int8_t *param, uint32_t paramLen);
|
||||
/**
|
||||
* @brief Set the parameter by index.
|
||||
*/
|
||||
extern int32_t OmxAdapterSetParameter(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE index, int8_t *param,
|
||||
extern int32_t OmxAdapterSetParameter(struct CodecComponentNode *codecNode, enum OMX_INDEXTYPE index, int8_t *param,
|
||||
uint32_t paramLen);
|
||||
/**
|
||||
* @brief Get the config by index.
|
||||
*
|
||||
* This func can be invoked when the component is in any state except the OMX_StateInvalid state.
|
||||
*/
|
||||
extern int32_t OmxAdapterGetConfig(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE index, int8_t *config,
|
||||
extern int32_t OmxAdapterGetConfig(struct CodecComponentNode *codecNode, enum OMX_INDEXTYPE index, int8_t *config,
|
||||
uint32_t configLen);
|
||||
extern int32_t OmxAdapterSetConfig(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE index, int8_t *config,
|
||||
extern int32_t OmxAdapterSetConfig(struct CodecComponentNode *codecNode, enum OMX_INDEXTYPE index, int8_t *config,
|
||||
uint32_t configLen);
|
||||
extern int32_t OmxAdapterGetExtensionIndex(OMX_HANDLETYPE compHandle, const char *parameterName,
|
||||
extern int32_t OmxAdapterGetExtensionIndex(struct CodecComponentNode *codecNode, const char *parameterName,
|
||||
enum OMX_INDEXTYPE *indexType);
|
||||
extern int32_t OmxAdapterGetState(OMX_HANDLETYPE compHandle, enum OMX_STATETYPE *state);
|
||||
extern int32_t OmxAdapterGetState(struct CodecComponentNode *codecNode, enum OMX_STATETYPE *state);
|
||||
/**
|
||||
* @brief Set up tunneled communication between an output port and an input port.
|
||||
*/
|
||||
extern int32_t OmxAdapterComponentTunnelRequest(OMX_HANDLETYPE compHandle, uint32_t port,
|
||||
extern int32_t OmxAdapterComponentTunnelRequest(struct CodecComponentNode *codecNode, uint32_t port,
|
||||
int32_t omxHandleTypeTunneledComp, uint32_t tunneledPort,
|
||||
struct OMX_TUNNELSETUPTYPE *tunnelSetup);
|
||||
/**
|
||||
* @brief The component uses a buffer already allocated by the IL client.
|
||||
*/
|
||||
extern int32_t OmxAdapterUseBuffer(OMX_HANDLETYPE compHandle, uint32_t portIndex, struct OmxCodecBuffer *omxBuffer);
|
||||
extern int32_t OmxAdapterUseBuffer(struct CodecComponentNode *codecNode, uint32_t portIndex,
|
||||
struct OmxCodecBuffer *omxBuffer);
|
||||
/**
|
||||
* @brief The component allocate a buffer.
|
||||
*/
|
||||
extern int32_t OmxAdapterAllocateBuffer(OMX_HANDLETYPE compHandle, uint32_t portIndex,
|
||||
extern int32_t OmxAdapterAllocateBuffer(struct CodecComponentNode *codecNode, uint32_t portIndex,
|
||||
struct OmxCodecBuffer *omxBuffer);
|
||||
/**
|
||||
* @brief The component free the buffer.
|
||||
*/
|
||||
extern int32_t OmxAdapterFreeBuffer(OMX_HANDLETYPE compHandle, uint32_t portIndex, struct OmxCodecBuffer *omxBuffer);
|
||||
extern int32_t OmxAdapterFreeBuffer(struct CodecComponentNode *codecNode, uint32_t portIndex,
|
||||
struct OmxCodecBuffer *omxBuffer);
|
||||
/**
|
||||
* @brief Send a filled buffer to the input port of the component.
|
||||
*/
|
||||
extern int32_t OmxAdapterEmptyThisBuffer(OMX_HANDLETYPE compHandle, struct OmxCodecBuffer *omxBuffer);
|
||||
extern int32_t OmxAdapterEmptyThisBuffer(struct CodecComponentNode *codecNode, struct OmxCodecBuffer *omxBuffer);
|
||||
/**
|
||||
* @brief Send a empty buffer to the output port of the component.
|
||||
*/
|
||||
extern int32_t OmxAdapterFillThisBuffer(OMX_HANDLETYPE compHandle, struct OmxCodecBuffer *omxBuffer);
|
||||
extern int32_t OmxAdapterFillThisBuffer(struct CodecComponentNode *codecNode, struct OmxCodecBuffer *omxBuffer);
|
||||
/**
|
||||
* @brief Set the callback.
|
||||
*/
|
||||
extern int32_t OmxAdapterSetCallbacks(OMX_HANDLETYPE compHandle, struct CodecCallbackType *omxCallback, int8_t *appData,
|
||||
uint32_t appDataLen);
|
||||
extern int32_t OmxAdapterSetCallbacks(struct CodecComponentNode *codecNode, struct CodecCallbackType *omxCallback,
|
||||
int64_t appData);
|
||||
/**
|
||||
* @brief DeInit the component.
|
||||
*/
|
||||
extern int32_t OmxAdapterDeInit(OMX_HANDLETYPE compHandle);
|
||||
extern int32_t OmxAdapterDeInit(struct CodecComponentNode *codecNode);
|
||||
/**
|
||||
* @brief The component use the buffer allocated in EGL.
|
||||
*/
|
||||
extern int32_t OmxAdapterUseEglImage(OMX_HANDLETYPE compHandle, struct OmxCodecBuffer *buffer, uint32_t portIndex,
|
||||
int8_t *eglImage, uint32_t eglImageLen);
|
||||
extern int32_t OmxAdapterUseEglImage(struct CodecComponentNode *codecNode, struct OmxCodecBuffer *buffer,
|
||||
uint32_t portIndex, int8_t *eglImage, uint32_t eglImageLen);
|
||||
/**
|
||||
* @brief Get the role of the component.
|
||||
*/
|
||||
extern int32_t OmxAdapterComponentRoleEnum(OMX_HANDLETYPE compHandle, uint8_t *role, uint32_t roleLen, uint32_t index);
|
||||
extern int32_t OmxAdapterComponentRoleEnum(struct CodecComponentNode *codecNode, uint8_t *role, uint32_t roleLen,
|
||||
uint32_t index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 CODEC_COMPONENT_MANAGER_SERVICE_H
|
||||
#define CODEC_COMPONENT_MANAGER_SERVICE_H
|
||||
|
||||
#include <hdf_dlist.h>
|
||||
#include <pthread.h>
|
||||
#include "codec_component_if.h"
|
||||
#include "codec_component_manager_stub.h"
|
||||
#include "codec_component_type_service.h"
|
||||
#include "codec_internal.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct CompoentTypeNode {
|
||||
uint32_t componentId;
|
||||
struct CodecComponentType *service;
|
||||
struct DListHead node;
|
||||
};
|
||||
|
||||
struct CodecComponentManagerSerivce {
|
||||
struct CodecComponentManagerStub stub;
|
||||
pthread_mutex_t listMute;
|
||||
struct DListHead head;
|
||||
};
|
||||
struct CodecComponentManagerSerivce *CodecComponentManagerSerivceGet(void);
|
||||
void OmxComponentManagerSeriveRelease(struct CodecComponentManagerSerivce *instance);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // CODEC_COMPONENT_MANAGER_SERVICE_H
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 CODEC_COMPONENT_MANAGER_STUB_H
|
||||
#define CODEC_COMPONENT_MANAGER_STUB_H
|
||||
|
||||
#include "codec_component_manager.h"
|
||||
#include "codec_internal.h"
|
||||
#include "codec_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct CodecComponentManagerStub {
|
||||
struct CodecComponentManager interface;
|
||||
int32_t (*OnRemoteRequest)(struct CodecComponentManager *serviceImpl, int code, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply);
|
||||
};
|
||||
|
||||
bool CodecComponentManagerStubConstruct(struct CodecComponentManagerStub *stub);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // HDI_OMXCOMPONENTTYPESTUB_H
|
||||
@@ -18,12 +18,16 @@
|
||||
|
||||
#include "codec_component_if.h"
|
||||
#include "codec_internal.h"
|
||||
|
||||
#include "codec_adapter_interface.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void CodecComponentTypeServiceConstruct(struct OmxComponentManager *manager, struct CodecComponentType* service);
|
||||
void CodecComponentTypeServiceConstruct(struct CodecComponentType *service);
|
||||
struct CodecComponentType *CodecComponentTypeServiceGet(void);
|
||||
void CodecComponentTypeServiceRelease(struct CodecComponentType *self);
|
||||
void CodecCompoentTypeServiceSetCodecNode(struct CodecComponentType *self, struct CodecComponentNode *codecNode);
|
||||
struct CodecComponentNode *CodecCompoentTypeServiceGetCodecNode(struct CodecComponentType *self);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -16,31 +16,27 @@
|
||||
#ifndef HDI_OMXCOMPONENTTYPESTUB_H
|
||||
#define HDI_OMXCOMPONENTTYPESTUB_H
|
||||
|
||||
#include <hdf_remote_service.h>
|
||||
#include <hdf_sbuf.h>
|
||||
#include "codec_component_if.h"
|
||||
#include "codec_internal.h"
|
||||
#include "codec_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct CodecComponentTypeStub {
|
||||
struct CodecComponentType service;
|
||||
struct OmxComponentManager managerService;
|
||||
struct HdfDeviceObject *device;
|
||||
void *dlHandler;
|
||||
OMX_HANDLETYPE componentHandle;
|
||||
struct CodecComponentType interface;
|
||||
struct HdfRemoteService *remote;
|
||||
struct HdfRemoteDispatcher dispatcher;
|
||||
};
|
||||
|
||||
int32_t CodecComponentTypeServiceOnRemoteRequest(struct CodecComponentTypeStub *service,
|
||||
int32_t cmdId, struct HdfSBuf *data, struct HdfSBuf *reply);
|
||||
bool CodecComponentTypeStubConstruct(struct CodecComponentTypeStub *stub);
|
||||
|
||||
struct CodecComponentTypeStub* CodecComponentTypeStubGetInstance(void);
|
||||
|
||||
void CodecComponentTypeStubRelease(struct CodecComponentTypeStub *instance);
|
||||
void CodecComponentTypeStubRelease(struct CodecComponentTypeStub *stub);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // HDI_OMXCOMPONENTTYPESTUB_H
|
||||
#endif // HDI_OMXCOMPONENTTYPESTUB_H
|
||||
@@ -24,7 +24,7 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define CODEC_HDI_OMX_SERVICE_NAME "codec_hdi_omx_service"
|
||||
|
||||
#define COMPONENT_MANAGER_SERVICE_DESC "ohos.hdi.codec_service"
|
||||
enum ComponentDispatchCmd {
|
||||
CMD_CODEC_GET_COMPONENT_NUM,
|
||||
CMD_CODEC_GET_COMPONENT_CAPABILITY_LIST,
|
||||
|
||||
+171
-45
@@ -13,119 +13,245 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <hdf_log.h>
|
||||
#include <memory.h>
|
||||
#include <securec.h>
|
||||
#include "codec_adapter_interface.h"
|
||||
#include "component_node_mgr.h"
|
||||
#include "component_mgr.h"
|
||||
#include "component_node.h"
|
||||
using namespace OHOS::Codec::Omx;
|
||||
|
||||
static ComponentNodeMgr g_mgr;
|
||||
static ComponentMgr g_mgr;
|
||||
struct CodecComponentNode {
|
||||
std::shared_ptr<ComponentNode> node;
|
||||
};
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t OMXAdapterCreateComponent(OMX_HANDLETYPE *compHandle, char *compName, int8_t *appData, int32_t appDataSize,
|
||||
int32_t OMXAdapterCreateComponent(struct CodecComponentNode **codecNode, char *compName, int64_t appData,
|
||||
struct CodecCallbackType *callbacks)
|
||||
{
|
||||
return g_mgr.CreateComponent(compHandle, compName, appData, appDataSize, callbacks);
|
||||
OMX_COMPONENTTYPE *comp = nullptr;
|
||||
CodecComponentNode *tempNode = new CodecComponentNode;
|
||||
if (codecNode == nullptr) {
|
||||
HDF_LOGE("%{public}s ceate CodecComponentNode error", __func__);
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (!g_mgr.IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s load lib failed", __func__);
|
||||
return HDF_ERR_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
tempNode->node = std::make_shared<ComponentNode>(callbacks, appData);
|
||||
auto err = g_mgr.CreateComponentInstance(compName, &ComponentNode::callbacks_, tempNode->node.get(), &comp);
|
||||
if (err != OMX_ErrorNone) {
|
||||
HDF_LOGE("%{public}s ceate component instance err[%{public}d]", __func__, err);
|
||||
delete tempNode;
|
||||
tempNode = nullptr;
|
||||
return err;
|
||||
}
|
||||
tempNode->node->SetHandle((OMX_HANDLETYPE)comp);
|
||||
|
||||
*codecNode = tempNode;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t OmxAdapterDestoryComponent(OMX_HANDLETYPE compHandle)
|
||||
int32_t OmxAdapterDestoryComponent(struct CodecComponentNode *codecNode)
|
||||
{
|
||||
return g_mgr.DestoryComponent(compHandle);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (!g_mgr.IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s load lib failed", __func__);
|
||||
return HDF_ERR_NOT_SUPPORT;
|
||||
}
|
||||
auto err = g_mgr.DeleteComponentInstance((OMX_COMPONENTTYPE *)codecNode->node->GetHandle());
|
||||
if (err != OMX_ErrorNone) {
|
||||
HDF_LOGE("%{public}s DeleteComponentInstance err[%{public}d]", __func__, err);
|
||||
return err;
|
||||
}
|
||||
codecNode->node = nullptr;
|
||||
delete codecNode;
|
||||
codecNode = nullptr;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t OmxAdapterComponentVersion(OMX_HANDLETYPE compHandle, struct CompVerInfo *verInfo)
|
||||
int32_t OmxAdapterComponentVersion(struct CodecComponentNode *codecNode, struct CompVerInfo *verInfo)
|
||||
{
|
||||
return g_mgr.GetComponentVersion(compHandle, *verInfo);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || verInfo == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or verInfois is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->GetComponentVersion(*verInfo);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterSendCommand(OMX_HANDLETYPE compHandle, enum OMX_COMMANDTYPE cmd, uint32_t param, int8_t *cmdData,
|
||||
uint32_t cmdDataLen)
|
||||
int32_t OmxAdapterSendCommand(struct CodecComponentNode *codecNode, enum OMX_COMMANDTYPE cmd, uint32_t param,
|
||||
int8_t *cmdData, uint32_t cmdDataLen)
|
||||
{
|
||||
return g_mgr.SendCommand(compHandle, cmd, param, cmdData, cmdDataLen);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode or node is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->SendCommand(cmd, param, cmdData, cmdDataLen);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterGetParameter(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE paramIndex, int8_t *param,
|
||||
int32_t OmxAdapterGetParameter(struct CodecComponentNode *codecNode, enum OMX_INDEXTYPE paramIndex, int8_t *param,
|
||||
uint32_t paramLen)
|
||||
{
|
||||
return g_mgr.GetParameter(compHandle, paramIndex, param, paramLen);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || param == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or param is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
return codecNode->node->GetParameter(paramIndex, param, paramLen);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterSetParameter(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE index, int8_t *param, uint32_t paramLen)
|
||||
int32_t OmxAdapterSetParameter(struct CodecComponentNode *codecNode, enum OMX_INDEXTYPE index, int8_t *param,
|
||||
uint32_t paramLen)
|
||||
{
|
||||
return g_mgr.SetParameter(compHandle, index, param, paramLen);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || param == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or param is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->SetParameter(index, param, paramLen);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterGetConfig(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE index, int8_t *config, uint32_t configLen)
|
||||
int32_t OmxAdapterGetConfig(struct CodecComponentNode *codecNode, enum OMX_INDEXTYPE index, int8_t *config,
|
||||
uint32_t configLen)
|
||||
{
|
||||
return g_mgr.GetConfig(compHandle, index, config, configLen);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || config == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or config is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->GetConfig(index, config, configLen);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterSetConfig(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE index, int8_t *config, uint32_t configLen)
|
||||
int32_t OmxAdapterSetConfig(struct CodecComponentNode *codecNode, enum OMX_INDEXTYPE index, int8_t *config,
|
||||
uint32_t configLen)
|
||||
{
|
||||
return g_mgr.SetConfig(compHandle, index, config, configLen);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || config == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or config is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->SetConfig(index, config, configLen);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterGetExtensionIndex(OMX_HANDLETYPE compHandle, const char *parameterName, enum OMX_INDEXTYPE *indexType)
|
||||
int32_t OmxAdapterGetExtensionIndex(struct CodecComponentNode *codecNode, const char *parameterName,
|
||||
enum OMX_INDEXTYPE *indexType)
|
||||
{
|
||||
return g_mgr.GetExtensionIndex(compHandle, parameterName, indexType);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || parameterName == nullptr || indexType == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node , parameterName or indexType is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->GetExtensionIndex(parameterName, indexType);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterGetState(OMX_HANDLETYPE compHandle, enum OMX_STATETYPE *state)
|
||||
int32_t OmxAdapterGetState(struct CodecComponentNode *codecNode, enum OMX_STATETYPE *state)
|
||||
{
|
||||
return g_mgr.GetState(compHandle, state);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || state == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or state is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->GetState(state);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterComponentTunnelRequest(OMX_HANDLETYPE compHandle, uint32_t port, int32_t omxHandleTypeTunneledComp,
|
||||
uint32_t tunneledPort, struct OMX_TUNNELSETUPTYPE *tunnelSetup)
|
||||
int32_t OmxAdapterComponentTunnelRequest(struct CodecComponentNode *codecNode, uint32_t port,
|
||||
int32_t omxHandleTypeTunneledComp, uint32_t tunneledPort,
|
||||
struct OMX_TUNNELSETUPTYPE *tunnelSetup)
|
||||
{
|
||||
return g_mgr.ComponentTunnelRequest(compHandle, port, omxHandleTypeTunneledComp, tunneledPort, tunnelSetup);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || tunnelSetup == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or tunnelSetup is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->ComponentTunnelRequest(port, omxHandleTypeTunneledComp, tunneledPort, tunnelSetup);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterUseBuffer(OMX_HANDLETYPE compHandle, uint32_t portIndex, struct OmxCodecBuffer *omxBuffer)
|
||||
int32_t OmxAdapterUseBuffer(struct CodecComponentNode *codecNode, uint32_t portIndex, struct OmxCodecBuffer *omxBuffer)
|
||||
{
|
||||
return g_mgr.UseBuffer(compHandle, portIndex, *omxBuffer);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || omxBuffer == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or omxBuffer is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->UseBuffer(portIndex, *omxBuffer);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterAllocateBuffer(OMX_HANDLETYPE compHandle, uint32_t portIndex, struct OmxCodecBuffer *omxBuffer)
|
||||
int32_t OmxAdapterAllocateBuffer(struct CodecComponentNode *codecNode, uint32_t portIndex,
|
||||
struct OmxCodecBuffer *omxBuffer)
|
||||
{
|
||||
return g_mgr.AllocateBuffer(compHandle, portIndex, *omxBuffer);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || omxBuffer == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or omxBuffer is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->AllocateBuffer(portIndex, *omxBuffer);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterFreeBuffer(OMX_HANDLETYPE compHandle, uint32_t portIndex, struct OmxCodecBuffer *omxBuffer)
|
||||
int32_t OmxAdapterFreeBuffer(struct CodecComponentNode *codecNode, uint32_t portIndex, struct OmxCodecBuffer *omxBuffer)
|
||||
{
|
||||
return g_mgr.FreeBuffer(compHandle, portIndex, *omxBuffer);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || omxBuffer == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or omxBuffer is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->FreeBuffer(portIndex, *omxBuffer);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterEmptyThisBuffer(OMX_HANDLETYPE compHandle, struct OmxCodecBuffer *omxBuffer)
|
||||
int32_t OmxAdapterEmptyThisBuffer(struct CodecComponentNode *codecNode, struct OmxCodecBuffer *omxBuffer)
|
||||
{
|
||||
return g_mgr.EmptyThisBuffer(compHandle, *omxBuffer);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || omxBuffer == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or omxBuffer is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->EmptyThisBuffer(*omxBuffer);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterFillThisBuffer(OMX_HANDLETYPE compHandle, struct OmxCodecBuffer *omxBuffer)
|
||||
int32_t OmxAdapterFillThisBuffer(struct CodecComponentNode *codecNode, struct OmxCodecBuffer *omxBuffer)
|
||||
{
|
||||
return g_mgr.FillThisBuffer(compHandle, *omxBuffer);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || omxBuffer == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or omxBuffer is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->FillThisBuffer(*omxBuffer);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterSetCallbacks(OMX_HANDLETYPE compHandle, struct CodecCallbackType *omxCallback, int8_t *appData,
|
||||
uint32_t appDataLen)
|
||||
int32_t OmxAdapterSetCallbacks(struct CodecComponentNode *codecNode, struct CodecCallbackType *omxCallback,
|
||||
int64_t appData)
|
||||
{
|
||||
return g_mgr.SetCallbacks(compHandle, omxCallback, appData, appDataLen);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || omxCallback == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or omxCallback is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->SetCallbacks(omxCallback, appData);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterDeInit(OMX_HANDLETYPE compHandle)
|
||||
int32_t OmxAdapterDeInit(struct CodecComponentNode *codecNode)
|
||||
{
|
||||
return g_mgr.DeInit(compHandle);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode or node is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->DeInit();
|
||||
}
|
||||
|
||||
int32_t OmxAdapterUseEglImage(OMX_HANDLETYPE compHandle, struct OmxCodecBuffer *buffer, uint32_t portIndex,
|
||||
int32_t OmxAdapterUseEglImage(struct CodecComponentNode *codecNode, struct OmxCodecBuffer *buffer, uint32_t portIndex,
|
||||
int8_t *eglImage, uint32_t eglImageLen)
|
||||
{
|
||||
return g_mgr.UseEglImage(compHandle, *buffer, portIndex, eglImage, eglImageLen);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || buffer == nullptr || eglImage == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node, buffer or eglImage is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->UseEglImage(*buffer, portIndex, eglImage, eglImageLen);
|
||||
}
|
||||
|
||||
int32_t OmxAdapterComponentRoleEnum(OMX_HANDLETYPE compHandle, uint8_t *role, uint32_t roleLen, uint32_t index)
|
||||
int32_t OmxAdapterComponentRoleEnum(struct CodecComponentNode *codecNode, uint8_t *role, uint32_t roleLen,
|
||||
uint32_t index)
|
||||
{
|
||||
return g_mgr.ComponentRoleEnum(compHandle, role, roleLen, index);
|
||||
if (codecNode == nullptr || codecNode->node == nullptr || role == nullptr) {
|
||||
HDF_LOGE("%{public}s codecNode, node or role is null", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->ComponentRoleEnum(role, roleLen, index);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
||||
@@ -39,11 +39,9 @@ static void ReleaseSbuf(struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
}
|
||||
|
||||
static int32_t CodecCallbackTypeProxyCall(struct CodecCallbackType *self, int32_t id, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
if (self->remote == NULL ||
|
||||
self->remote->dispatcher == NULL ||
|
||||
self->remote->dispatcher->Dispatch == NULL) {
|
||||
if (self->remote == NULL || self->remote->dispatcher == NULL || self->remote->dispatcher->Dispatch == NULL) {
|
||||
HDF_LOGE("%{public}s: obj is null", __func__);
|
||||
return HDF_ERR_INVALID_OBJECT;
|
||||
}
|
||||
@@ -65,12 +63,11 @@ static int32_t WriteArray(struct HdfSBuf *data, int8_t *array, uint32_t arrayLen
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t WriteEventInfo(struct HdfSBuf *data, struct EventInfo* info)
|
||||
static int32_t WriteEventInfo(struct HdfSBuf *data, struct EventInfo *info)
|
||||
{
|
||||
int32_t ret = WriteArray(data, info->appData, info->appDataLen);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
if (!HdfSbufWriteInt64(data, info->appData)) {
|
||||
HDF_LOGE("%{public}s: write appData failed!", __func__);
|
||||
return ret;
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (!HdfSbufWriteUint32(data, info->data1)) {
|
||||
@@ -83,15 +80,15 @@ static int32_t WriteEventInfo(struct HdfSBuf *data, struct EventInfo* info)
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = WriteArray(data, info->eventData, info->eventDataLen);
|
||||
int32_t ret = WriteArray(data, info->eventData, info->eventDataLen);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: write eventData failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t CodecCallbackTypeProxyEventHandler(struct CodecCallbackType *self,
|
||||
enum OMX_EVENTTYPE event, struct EventInfo* info)
|
||||
static int32_t CodecCallbackTypeProxyEventHandler(struct CodecCallbackType *self, enum OMX_EVENTTYPE event,
|
||||
struct EventInfo *info)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
@@ -133,8 +130,8 @@ static int32_t CodecCallbackTypeProxyEventHandler(struct CodecCallbackType *self
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t CodecCallbackTypeProxyEmptyBufferDone(struct CodecCallbackType *self,
|
||||
int8_t *appData, uint32_t appDataLen, const struct OmxCodecBuffer *buffer)
|
||||
static int32_t CodecCallbackTypeProxyEmptyBufferDone(struct CodecCallbackType *self, int64_t appData,
|
||||
const struct OmxCodecBuffer *buffer)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
@@ -152,19 +149,11 @@ static int32_t CodecCallbackTypeProxyEmptyBufferDone(struct CodecCallbackType *s
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
if (!HdfSbufWriteUint32(data, appDataLen)) {
|
||||
if (!HdfSbufWriteInt64(data, appData)) {
|
||||
HDF_LOGE("%{public}s: write appData failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
for (uint32_t i = 0; i < appDataLen; i++) {
|
||||
if (!HdfSbufWriteInt8(data, appData[i])) {
|
||||
HDF_LOGE("%{public}s: write appData[i] failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
if (!OmxCodecBufferBlockMarshalling(data, buffer)) {
|
||||
HDF_LOGE("%{public}s: write buffer failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
@@ -182,8 +171,8 @@ static int32_t CodecCallbackTypeProxyEmptyBufferDone(struct CodecCallbackType *s
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t CodecCallbackTypeProxyFillBufferDone(struct CodecCallbackType *self,
|
||||
int8_t* appData, uint32_t appDataLen, struct OmxCodecBuffer* buffer)
|
||||
static int32_t CodecCallbackTypeProxyFillBufferDone(struct CodecCallbackType *self, int64_t appData,
|
||||
const struct OmxCodecBuffer *buffer)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
@@ -201,19 +190,11 @@ static int32_t CodecCallbackTypeProxyFillBufferDone(struct CodecCallbackType *se
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
if (!HdfSbufWriteUint32(data, appDataLen)) {
|
||||
if (!HdfSbufWriteInt64(data, appData)) {
|
||||
HDF_LOGE("%{public}s: write appData failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
for (uint32_t i = 0; i < appDataLen; i++) {
|
||||
if (!HdfSbufWriteInt8(data, appData[i])) {
|
||||
HDF_LOGE("%{public}s: write appData[i] failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
if (!OmxCodecBufferBlockMarshalling(data, buffer)) {
|
||||
HDF_LOGE("%{public}s: write buffer failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
@@ -245,7 +226,7 @@ struct CodecCallbackType *CodecCallbackTypeGet(struct HdfRemoteService *remote)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct CodecCallbackType *instance = (struct CodecCallbackType*)OsalMemAlloc(sizeof(struct CodecCallbackType));
|
||||
struct CodecCallbackType *instance = (struct CodecCallbackType *)OsalMemAlloc(sizeof(struct CodecCallbackType));
|
||||
if (instance == NULL) {
|
||||
HDF_LOGE("%{public}s: OsalMemAlloc failed!", __func__);
|
||||
return NULL;
|
||||
|
||||
@@ -19,22 +19,21 @@
|
||||
|
||||
#define HDF_LOG_TAG codec_hdi_cb_server
|
||||
|
||||
int32_t CodecCallbackTypeEventHandler(struct CodecCallbackType *self, enum OMX_EVENTTYPE eEvent,
|
||||
struct EventInfo *info)
|
||||
int32_t CodecCallbackTypeEventHandler(struct CodecCallbackType *self, enum OMX_EVENTTYPE eEvent, struct EventInfo *info)
|
||||
{
|
||||
HDF_LOGI("%{public}s, callback service impl", __func__);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CodecCallbackTypeEmptyBufferDone(struct CodecCallbackType *self,
|
||||
int8_t *appData, uint32_t appDataLen, const struct OmxCodecBuffer *buffer)
|
||||
int32_t CodecCallbackTypeEmptyBufferDone(struct CodecCallbackType *self, int64_t appData,
|
||||
const struct OmxCodecBuffer *buffer)
|
||||
{
|
||||
HDF_LOGI("%{public}s, callback service impl", __func__);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CodecCallbackTypeFillBufferDone(struct CodecCallbackType *self,
|
||||
int8_t* appData, uint32_t appDataLen, struct OmxCodecBuffer *buffer)
|
||||
int32_t CodecCallbackTypeFillBufferDone(struct CodecCallbackType *self, int64_t appData,
|
||||
const struct OmxCodecBuffer *buffer)
|
||||
{
|
||||
HDF_LOGI("%{public}s, callback service impl", __func__);
|
||||
return HDF_SUCCESS;
|
||||
|
||||
@@ -84,35 +84,30 @@ static int32_t ReadArray(struct HdfSBuf *data, int8_t **array, uint32_t *arrayLe
|
||||
static int32_t ReadEventInfo(struct HdfSBuf *data, struct EventInfo *info)
|
||||
{
|
||||
int32_t ret;
|
||||
ret = ReadArray(data, &info->appData, &info->appDataLen);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
if (!HdfSbufReadInt64(data, &info->appData)) {
|
||||
HDF_LOGE("%{public}s: read appData failed!", __func__);
|
||||
return ret;
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (!HdfSbufReadUint32(data, &info->data1)) {
|
||||
HDF_LOGE("%{public}s: read &data1 failed!", __func__);
|
||||
FreeMem(info->appData, info->appDataLen);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (!HdfSbufReadUint32(data, &info->data2)) {
|
||||
HDF_LOGE("%{public}s: read &data2 failed!", __func__);
|
||||
FreeMem(info->appData, info->appDataLen);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = ReadArray(data, &info->eventData, &info->eventDataLen);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: read eventData failed!", __func__);
|
||||
FreeMem(info->appData, info->appDataLen);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ReleaseEventInfo(struct EventInfo *info)
|
||||
{
|
||||
FreeMem(info->appData, info->appDataLen);
|
||||
FreeMem(info->eventData, info->eventDataLen);
|
||||
}
|
||||
|
||||
@@ -146,47 +141,28 @@ static int32_t SerStubEmptyBufferDone(struct CodecCallbackType *serviceImpl,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
int8_t *appData = NULL;
|
||||
uint32_t appDataLen = 0;
|
||||
int64_t appData = 0;
|
||||
struct OmxCodecBuffer buffer;
|
||||
InitOmxCodecBuffer(&buffer);
|
||||
|
||||
if (!HdfSbufReadUint32(data, &appDataLen)) {
|
||||
if (!HdfSbufReadInt64(data, &appData)) {
|
||||
HDF_LOGE("%{public}s: read appData size failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (appDataLen > 0) {
|
||||
appData = (int8_t*)OsalMemCalloc(sizeof(int8_t) * (appDataLen));
|
||||
if (appData == NULL) {
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < appDataLen; i++) {
|
||||
if (!HdfSbufReadInt8(data, &appData[i])) {
|
||||
HDF_LOGE("%{public}s: read &appData[i] failed!", __func__);
|
||||
FreeMem(appData, appDataLen);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!OmxCodecBufferBlockUnmarshalling(data, &buffer)) {
|
||||
HDF_LOGE("%{public}s: read buffer failed!", __func__);
|
||||
FreeMem(appData, appDataLen);
|
||||
ReleaseOmxCodecBuffer(&buffer);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = serviceImpl->EmptyBufferDone(serviceImpl, appData, appDataLen, &buffer);
|
||||
ret = serviceImpl->EmptyBufferDone(serviceImpl, appData, &buffer);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call EmptyBufferDone function failed!", __func__);
|
||||
FreeMem(appData, appDataLen);
|
||||
ReleaseOmxCodecBuffer(&buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
FreeMem(appData, appDataLen);
|
||||
ReleaseOmxCodecBuffer(&buffer);
|
||||
return ret;
|
||||
}
|
||||
@@ -195,45 +171,26 @@ static int32_t SerStubFillBufferDone(struct CodecCallbackType *serviceImpl,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
int8_t *appData = NULL;
|
||||
uint32_t appDataLen = 0;
|
||||
int64_t appData = 0;
|
||||
struct OmxCodecBuffer buffer;
|
||||
InitOmxCodecBuffer(&buffer);
|
||||
if (!HdfSbufReadUint32(data, &appDataLen)) {
|
||||
if (!HdfSbufReadInt64(data, &appData)) {
|
||||
HDF_LOGE("%{public}s: read appData size failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (appDataLen > 0) {
|
||||
appData = (int8_t*)OsalMemCalloc(sizeof(int8_t) * (appDataLen));
|
||||
if (appData == NULL) {
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < appDataLen; i++) {
|
||||
if (!HdfSbufReadInt8(data, &appData[i])) {
|
||||
HDF_LOGE("%{public}s: read &appData[i] failed!", __func__);
|
||||
FreeMem(appData, appDataLen);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!OmxCodecBufferBlockUnmarshalling(data, &buffer)) {
|
||||
HDF_LOGE("%{public}s: read buffer failed!", __func__);
|
||||
FreeMem(appData, appDataLen);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = serviceImpl->FillBufferDone(serviceImpl, appData, appDataLen, &buffer);
|
||||
ret = serviceImpl->FillBufferDone(serviceImpl, appData, &buffer);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call FillBufferDone function failed!", __func__);
|
||||
FreeMem(appData, appDataLen);
|
||||
ReleaseOmxCodecBuffer(&buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
FreeMem(appData, appDataLen);
|
||||
ReleaseOmxCodecBuffer(&buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ static int32_t GetComponentNum()
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
if (g_codecComponentManagerProxy.remoteOmx->dispatcher->Dispatch(g_codecComponentManagerProxy.remoteOmx,
|
||||
CMD_CODEC_GET_COMPONENT_NUM, data, reply) != HDF_SUCCESS) {
|
||||
if (g_codecComponentManagerProxy.remoteOmx->dispatcher->Dispatch(
|
||||
g_codecComponentManagerProxy.remoteOmx, CMD_CODEC_GET_COMPONENT_NUM, data, reply) != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: dispatch request failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -96,7 +96,8 @@ static int32_t GetComponentCapabilityList(CodecCompCapability *capList, int32_t
|
||||
}
|
||||
|
||||
if (g_codecComponentManagerProxy.remoteOmx->dispatcher->Dispatch(g_codecComponentManagerProxy.remoteOmx,
|
||||
CMD_CODEC_GET_COMPONENT_CAPABILITY_LIST, data, reply) != HDF_SUCCESS) {
|
||||
CMD_CODEC_GET_COMPONENT_CAPABILITY_LIST, data,
|
||||
reply) != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: dispatch request failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -119,14 +120,13 @@ static int32_t GetComponentCapabilityList(CodecCompCapability *capList, int32_t
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t CreateComponent(struct CodecComponentType **component, char *compName, void *appData,
|
||||
int32_t appDataSize, struct CodecCallbackType *callback)
|
||||
static int32_t CreateComponent(struct CodecComponentType **component, uint32_t *componentId, char *compName,
|
||||
int64_t appData, struct CodecCallbackType *callback)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
struct HdfSBuf *data = HdfSbufTypedObtain(SBUF_IPC);
|
||||
struct HdfSBuf *reply = HdfSbufTypedObtain(SBUF_IPC);
|
||||
if (data == NULL || reply == NULL) {
|
||||
if (data == NULL || reply == NULL || componentId == NULL) {
|
||||
HDF_LOGE("%{public}s: HdfSubf malloc failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
@@ -136,47 +136,46 @@ static int32_t CreateComponent(struct CodecComponentType **component, char *comp
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
if (!HdfSbufWriteString(data, compName)) {
|
||||
HDF_LOGE("%{public}s: write paramName failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
int8_t *priAppData = (int8_t*)appData;
|
||||
if (!HdfSbufWriteInt32(data, appDataSize)) {
|
||||
HDF_LOGE("%{public}s: write appDataSize failed!", __func__);
|
||||
if (!HdfSbufWriteInt64(data, appData)) {
|
||||
HDF_LOGE("%{public}s: write appData failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
for (int32_t i = 0; i < appDataSize; i++) {
|
||||
if (!HdfSbufWriteInt8(data, priAppData[i])) {
|
||||
HDF_LOGE("%{public}s: write priAppData[%{public}d] failed!", __func__, i);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
if (HdfSbufWriteRemoteService(data, callback->remote) != 0) {
|
||||
HDF_LOGE("%{public}s: write callback failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = g_codecComponentManagerProxy.remoteOmx->dispatcher->Dispatch(g_codecComponentManagerProxy.remoteOmx,
|
||||
CMD_CREATE_COMPONENT, data, reply);
|
||||
CMD_CREATE_COMPONENT, data, reply);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ret);
|
||||
ReleaseSbuf(data, reply);
|
||||
return ret;
|
||||
}
|
||||
*component = CodecComponentTypeGet(g_codecComponentManagerProxy.remoteOmx);
|
||||
|
||||
struct HdfRemoteService *componentRemote = HdfSbufReadRemoteService(reply);
|
||||
if (componentRemote == NULL) {
|
||||
HDF_LOGE("%{public}s: read componentRemote failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (!HdfSbufReadUint32(reply, componentId)) {
|
||||
HDF_LOGE("%{public}s: read componentId failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
*component = CodecComponentTypeGet(componentRemote);
|
||||
ReleaseSbuf(data, reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t DestoryComponent(struct CodecComponentType *component)
|
||||
static int32_t DestoryComponent(uint32_t componentId)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
@@ -193,15 +192,19 @@ static int32_t DestoryComponent(struct CodecComponentType *component)
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
if (!HdfSbufWriteUint32(data, componentId)) {
|
||||
HDF_LOGE("%{public}s: write componentId failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = g_codecComponentManagerProxy.remoteOmx->dispatcher->Dispatch(g_codecComponentManagerProxy.remoteOmx,
|
||||
CMD_DESTROY_COMPONENT, data, reply);
|
||||
CMD_DESTROY_COMPONENT, data, reply);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ret);
|
||||
ReleaseSbuf(data, reply);
|
||||
return ret;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
|
||||
ReleaseSbuf(data, reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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_component_manager_service.h"
|
||||
#include <hdf_base.h>
|
||||
#include <hdf_log.h>
|
||||
#include <osal_mem.h>
|
||||
#include <securec.h>
|
||||
#include <unistd.h>
|
||||
#include "codec_adapter_interface.h"
|
||||
#include "codec_component_manager_stub.h"
|
||||
#include "codec_component_type_service.h"
|
||||
|
||||
#define HDF_LOG_TAG codec_hdi_server
|
||||
|
||||
struct CodecComponentManagerSerivce *g_service = NULL;
|
||||
uint32_t g_compoentId = 0;
|
||||
uint32_t GetNextCompoentId()
|
||||
{
|
||||
uint32_t tempId = 0;
|
||||
if (g_service == NULL) {
|
||||
return tempId;
|
||||
}
|
||||
struct CompoentTypeNode *pos = NULL;
|
||||
struct CompoentTypeNode *next = NULL;
|
||||
bool find = false;
|
||||
|
||||
do {
|
||||
tempId = ++g_compoentId;
|
||||
find = false;
|
||||
DLIST_FOR_EACH_ENTRY_SAFE(pos, next, &g_service->head, struct CompoentTypeNode, node)
|
||||
{
|
||||
if (pos != NULL && tempId == pos->componentId) {
|
||||
find = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (find);
|
||||
return tempId;
|
||||
}
|
||||
|
||||
int32_t OmxManagerCreateComponent(struct CodecComponentType **component, uint32_t *componentId, char *compName,
|
||||
int64_t appData, struct CodecCallbackType *callbacks)
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
if (g_service == NULL) {
|
||||
HDF_LOGE("%{public}s, g_service is not init!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
struct CodecComponentType *comp = CodecComponentTypeServiceGet();
|
||||
if (comp == NULL) {
|
||||
HDF_LOGE("%{public}s, CodecComponentTypeServiceGet ret null!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
struct CompoentTypeNode *node = (struct CompoentTypeNode *)OsalMemCalloc(sizeof(struct CompoentTypeNode));
|
||||
if (node == NULL) {
|
||||
HDF_LOGE("%{public}s, CodecComponentTypeServiceGet ret null!", __func__);
|
||||
CodecComponentTypeServiceRelease(comp);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
struct CodecComponentNode *codecNode = NULL;
|
||||
int32_t err = OMXAdapterCreateComponent(&codecNode, compName, appData, callbacks);
|
||||
if (err != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s, OMXAdapterCreateComponent err [%{public}x]", __func__, err);
|
||||
CodecComponentTypeServiceRelease(comp);
|
||||
OsalMemFree(node);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
*component = comp;
|
||||
pthread_mutex_lock(&g_service->listMute);
|
||||
*componentId = GetNextCompoentId();
|
||||
CodecCompoentTypeServiceSetCodecNode(comp, codecNode);
|
||||
DListInsertTail(&node->node, &g_service->head);
|
||||
pthread_mutex_unlock(&g_service->listMute);
|
||||
|
||||
node->componentId = *componentId;
|
||||
node->service = comp;
|
||||
HDF_LOGI("%{public}s: comp is %{public}p, componentId:%{public}d", __func__, comp, node->componentId);
|
||||
return err;
|
||||
}
|
||||
|
||||
int32_t OmxManagerDestroyComponent(uint32_t compoentId)
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl, %{public}d!", __func__, compoentId);
|
||||
if (g_service == NULL) {
|
||||
HDF_LOGE("%{public}s, g_service is not init!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
struct CompoentTypeNode *pos = NULL;
|
||||
struct CompoentTypeNode *next = NULL;
|
||||
int32_t err = HDF_SUCCESS;
|
||||
pthread_mutex_lock(&g_service->listMute);
|
||||
DLIST_FOR_EACH_ENTRY_SAFE(pos, next, &g_service->head, struct CompoentTypeNode, node)
|
||||
{
|
||||
if (pos == NULL || compoentId != pos->componentId) {
|
||||
continue;
|
||||
}
|
||||
struct CodecComponentNode *codecNode = CodecCompoentTypeServiceGetCodecNode(pos->service);
|
||||
if (codecNode != NULL) {
|
||||
err = OmxAdapterDestoryComponent(codecNode);
|
||||
if (err != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s, OmxAdapterDestoryComponent ret err[%{public}d]!", __func__, err);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
DListRemove(&pos->node);
|
||||
CodecComponentTypeServiceRelease(pos->service);
|
||||
OsalMemFree(pos);
|
||||
pos = NULL;
|
||||
break;
|
||||
}
|
||||
pthread_mutex_unlock(&g_service->listMute);
|
||||
return err;
|
||||
}
|
||||
|
||||
void CodecComponentManagerServiceConstruct(struct CodecComponentManager *manager)
|
||||
{
|
||||
manager->CreateComponent = OmxManagerCreateComponent;
|
||||
manager->DestoryComponent = OmxManagerDestroyComponent;
|
||||
}
|
||||
|
||||
struct CodecComponentManagerSerivce *CodecComponentManagerSerivceGet(void)
|
||||
{
|
||||
if (g_service == NULL) {
|
||||
g_service = (struct CodecComponentManagerSerivce *)OsalMemCalloc(sizeof(struct CodecComponentManagerSerivce));
|
||||
if (g_service == NULL) {
|
||||
HDF_LOGE("%{public}s: malloc OmxComponentManagerService obj failed!", __func__);
|
||||
return NULL;
|
||||
}
|
||||
DListHeadInit(&g_service->head);
|
||||
if (!CodecComponentManagerStubConstruct(&g_service->stub)) {
|
||||
HDF_LOGE("%{public}s: construct SampleStub obj failed!", __func__);
|
||||
OmxComponentManagerSeriveRelease(g_service);
|
||||
g_service = NULL;
|
||||
}
|
||||
CodecComponentManagerServiceConstruct(&g_service->stub.interface);
|
||||
}
|
||||
return g_service;
|
||||
}
|
||||
|
||||
void OmxComponentManagerSeriveRelease(struct CodecComponentManagerSerivce *instance)
|
||||
{
|
||||
if (instance == NULL) {
|
||||
return;
|
||||
}
|
||||
if (g_service == instance) {
|
||||
g_service = NULL;
|
||||
}
|
||||
OsalMemFree(instance);
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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_component_manager_stub.h"
|
||||
#include <dlfcn.h>
|
||||
#include <hdf_device_desc.h>
|
||||
#include <hdf_device_object.h>
|
||||
#include <hdf_log.h>
|
||||
#include <osal_mem.h>
|
||||
#include <securec.h>
|
||||
#include "codec_component_capability_config.h"
|
||||
#include "codec_component_manager_service.h"
|
||||
#define CODEC_SERVICE_IMPL "libcodec_hdi_omx_service_impl"
|
||||
typedef void (*SERVICE_CONSTRUCT_FUNC)(struct OmxComponentManager *);
|
||||
static int32_t SerStubGetComponentNum(struct CodecComponentManager *serviceImpl, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
return HandleGetNumCmd(reply);
|
||||
}
|
||||
|
||||
static int32_t SerStubGetComponentCapablityList(struct CodecComponentManager *serviceImpl, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
return HandleGetAllCapablityListCmd(reply);
|
||||
}
|
||||
|
||||
static int32_t ReadParamsForCreateComponent(struct HdfSBuf *data, char **compName, int64_t *appData,
|
||||
struct CodecCallbackType **callback)
|
||||
{
|
||||
const char *compNameCp = HdfSbufReadString(data);
|
||||
if (compNameCp == NULL) {
|
||||
HDF_LOGE("%{public}s: read compNameCp failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (!HdfSbufReadInt64(data, appData)) {
|
||||
HDF_LOGE("%{public}s: read appData failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
*compName = strdup(compNameCp);
|
||||
|
||||
struct HdfRemoteService *callbackRemote = HdfSbufReadRemoteService(data);
|
||||
if (callbackRemote == NULL) {
|
||||
HDF_LOGE("%{public}s: read callbackRemote failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
*callback = CodecCallbackTypeGet(callbackRemote);
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SerStubCreateComponent(struct CodecComponentManager *serviceImpl, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret = HDF_SUCCESS;
|
||||
struct CodecComponentType *component = NULL;
|
||||
uint32_t componentId = 0;
|
||||
int64_t appData = 0;
|
||||
struct CodecCallbackType *callback = NULL;
|
||||
char *compName = NULL;
|
||||
|
||||
ret = ReadParamsForCreateComponent(data, &compName, &appData, &callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
if (compName != NULL) {
|
||||
OsalMemFree(compName);
|
||||
compName = NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
ret = serviceImpl->CreateComponent(&component, &componentId, compName, appData, callback);
|
||||
if (compName != NULL) {
|
||||
OsalMemFree(compName);
|
||||
compName = NULL;
|
||||
}
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call CreateComponent function failed!", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (HdfSbufWriteRemoteService(reply, component->AsObject(component)) != 0) {
|
||||
HDF_LOGE("%{public}s: write component failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (!HdfSbufWriteUint32(reply, componentId)) {
|
||||
HDF_LOGE("%{public}s: write componentId failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubDestroyComponent(struct CodecComponentManager *serviceImpl, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
uint32_t compoentId = 0;
|
||||
if (!HdfSbufReadUint32(data, &compoentId)) {
|
||||
HDF_LOGE("%{public}s: read compoentId failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
int32_t ret = serviceImpl->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call DestroyComponent function failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t CodecComponentManagerServiceOnRemoteRequest(struct CodecComponentManager *serviceImpl, int32_t cmdId,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
switch (cmdId) {
|
||||
case CMD_CODEC_GET_COMPONENT_NUM:
|
||||
return SerStubGetComponentNum(serviceImpl, data, reply);
|
||||
case CMD_CODEC_GET_COMPONENT_CAPABILITY_LIST:
|
||||
return SerStubGetComponentCapablityList(serviceImpl, data, reply);
|
||||
case CMD_CREATE_COMPONENT:
|
||||
return SerStubCreateComponent(serviceImpl, data, reply);
|
||||
case CMD_DESTROY_COMPONENT:
|
||||
return SerStubDestroyComponent(serviceImpl, data, reply);
|
||||
default:
|
||||
HDF_LOGE("%{public}s: not support cmd %{public}d", __func__, cmdId);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
static struct HdfRemoteService *CodecComponentManagerStubAsObject(struct CodecComponentManager *self)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CodecComponentManagerStubConstruct(struct CodecComponentManagerStub *stub)
|
||||
{
|
||||
if (stub == NULL) {
|
||||
HDF_LOGE("%{public}s: stub is null!", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
stub->OnRemoteRequest = CodecComponentManagerServiceOnRemoteRequest;
|
||||
stub->interface.AsObject = CodecComponentManagerStubAsObject;
|
||||
return true;
|
||||
}
|
||||
@@ -17,23 +17,32 @@
|
||||
#include <hdf_device_object.h>
|
||||
#include <hdf_log.h>
|
||||
#include <osal_mem.h>
|
||||
#include "codec_component_type_stub.h"
|
||||
#include "codec_component_capability_config.h"
|
||||
#include "codec_component_manager_service.h"
|
||||
#include "codec_component_type_stub.h"
|
||||
|
||||
#define HDF_LOG_TAG codec_hdi_server
|
||||
|
||||
struct HdfCodecComponentTypeHost {
|
||||
struct IDeviceIoService ioservice;
|
||||
struct CodecComponentTypeStub *instance;
|
||||
struct CodecComponentManagerSerivce *service;
|
||||
};
|
||||
|
||||
static int32_t CodecComponentTypeDriverDispatch(struct HdfDeviceIoClient *client, int32_t cmdId,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
struct HdfCodecComponentTypeHost *omxcomponenttypeHost = CONTAINER_OF(
|
||||
client->device->service, struct HdfCodecComponentTypeHost, ioservice);
|
||||
omxcomponenttypeHost->instance->device = client->device;
|
||||
return CodecComponentTypeServiceOnRemoteRequest(omxcomponenttypeHost->instance, cmdId, data, reply);
|
||||
struct HdfCodecComponentTypeHost *omxcomponenttypeHost =
|
||||
CONTAINER_OF(client->device->service, struct HdfCodecComponentTypeHost, ioservice);
|
||||
if (omxcomponenttypeHost->service == NULL || omxcomponenttypeHost->service->stub.OnRemoteRequest == NULL) {
|
||||
HDF_LOGE("%{public}s: invalid service obj", __func__);
|
||||
return HDF_ERR_INVALID_OBJECT;
|
||||
}
|
||||
if (!HdfDeviceObjectCheckInterfaceDesc(client->device, data)) {
|
||||
HDF_LOGE("%{public}s: check interface desc failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return omxcomponenttypeHost->service->stub.OnRemoteRequest(&omxcomponenttypeHost->service->stub.interface, cmdId,
|
||||
data, reply);
|
||||
}
|
||||
|
||||
int32_t HdfCodecComponentTypeDriverInit(struct HdfDeviceObject *deviceObject)
|
||||
@@ -53,14 +62,13 @@ int32_t HdfCodecComponentTypeDriverBind(struct HdfDeviceObject *deviceObject)
|
||||
{
|
||||
HDF_LOGI("HdfCodecComponentTypeDriverBind enter.");
|
||||
|
||||
struct HdfCodecComponentTypeHost *omxcomponenttypeHost = (struct HdfCodecComponentTypeHost *)OsalMemAlloc(
|
||||
sizeof(struct HdfCodecComponentTypeHost));
|
||||
struct HdfCodecComponentTypeHost *omxcomponenttypeHost =
|
||||
(struct HdfCodecComponentTypeHost *)OsalMemAlloc(sizeof(struct HdfCodecComponentTypeHost));
|
||||
if (omxcomponenttypeHost == NULL) {
|
||||
HDF_LOGE("HdfCodecComponentTypeDriverBind OsalMemAlloc HdfCodecComponentTypeHost failed!");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
int ret = HdfDeviceObjectSetInterfaceDesc(deviceObject, "ohos.hdi.codec_service");
|
||||
int ret = HdfDeviceObjectSetInterfaceDesc(deviceObject, COMPONENT_MANAGER_SERVICE_DESC);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("Failed to set interface desc");
|
||||
return ret;
|
||||
@@ -69,8 +77,8 @@ int32_t HdfCodecComponentTypeDriverBind(struct HdfDeviceObject *deviceObject)
|
||||
omxcomponenttypeHost->ioservice.Dispatch = CodecComponentTypeDriverDispatch;
|
||||
omxcomponenttypeHost->ioservice.Open = NULL;
|
||||
omxcomponenttypeHost->ioservice.Release = NULL;
|
||||
omxcomponenttypeHost->instance = CodecComponentTypeStubGetInstance();
|
||||
if (omxcomponenttypeHost->instance == NULL) {
|
||||
omxcomponenttypeHost->service = CodecComponentManagerSerivceGet();
|
||||
if (omxcomponenttypeHost->service == NULL) {
|
||||
OsalMemFree(omxcomponenttypeHost);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
@@ -82,9 +90,9 @@ int32_t HdfCodecComponentTypeDriverBind(struct HdfDeviceObject *deviceObject)
|
||||
void HdfCodecComponentTypeDriverRelease(struct HdfDeviceObject *deviceObject)
|
||||
{
|
||||
HDF_LOGI("HdfCodecComponentTypeDriverRelease enter.");
|
||||
struct HdfCodecComponentTypeHost *omxcomponenttypeHost
|
||||
= CONTAINER_OF(deviceObject->service, struct HdfCodecComponentTypeHost, ioservice);
|
||||
CodecComponentTypeStubRelease(omxcomponenttypeHost->instance);
|
||||
struct HdfCodecComponentTypeHost *omxcomponenttypeHost =
|
||||
CONTAINER_OF(deviceObject->service, struct HdfCodecComponentTypeHost, ioservice);
|
||||
OmxComponentManagerSeriveRelease(omxcomponenttypeHost->service);
|
||||
OsalMemFree(omxcomponenttypeHost);
|
||||
ClearCapabilityData();
|
||||
}
|
||||
|
||||
@@ -39,33 +39,17 @@ static void ReleaseSbuf(struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t WriteInterfaceToken(struct CodecComponentType *self, struct HdfSBuf *data)
|
||||
{
|
||||
struct CodecComponentTypeProxy *proxy = CONTAINER_OF(self, struct CodecComponentTypeProxy, instance);
|
||||
if (proxy == NULL) {
|
||||
HDF_LOGE("%{public}s: proxy is null", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(proxy->remote, data)) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t CodecComponentTypeProxyCall(struct CodecComponentType *self, int32_t id, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
struct CodecComponentTypeProxy *proxy = CONTAINER_OF(self, struct CodecComponentTypeProxy, instance);
|
||||
if (proxy->remote == NULL ||
|
||||
proxy->remote->dispatcher == NULL ||
|
||||
proxy->remote->dispatcher->Dispatch == NULL) {
|
||||
HDF_LOGE("%{public}s: obj is null", __func__);
|
||||
struct HdfRemoteService *remote = self->AsObject(self);
|
||||
if (remote == NULL || remote->dispatcher == NULL || remote->dispatcher->Dispatch == NULL ||
|
||||
remote->dispatcher->DispatchAsync == NULL) {
|
||||
HDF_LOGE("%{public}s: Invalid HdfRemoteService obj", __func__);
|
||||
return HDF_ERR_INVALID_OBJECT;
|
||||
}
|
||||
return proxy->remote->dispatcher->Dispatch(proxy->remote, id, data, reply);
|
||||
return remote->dispatcher->Dispatch(remote, id, data, reply);
|
||||
}
|
||||
|
||||
static int32_t ReadValuesForGetComponentVersion(struct HdfSBuf *reply, struct CompVerInfo *verInfo)
|
||||
{
|
||||
int32_t ret;
|
||||
@@ -94,7 +78,7 @@ static int32_t CodecComponentTypeProxyGetComponentVersion(struct CodecComponentT
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -125,7 +109,7 @@ static int32_t CodecComponentTypeProxySendCommand(struct CodecComponentType *sel
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -180,7 +164,7 @@ static int32_t CodecComponentTypeProxyGetParameter(struct CodecComponentType *se
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -238,7 +222,7 @@ static int32_t CodecComponentTypeProxySetParameter(struct CodecComponentType *se
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -287,7 +271,7 @@ static int32_t CodecComponentTypeProxyGetConfig(struct CodecComponentType *self,
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -345,7 +329,7 @@ static int32_t CodecComponentTypeProxySetConfig(struct CodecComponentType *self,
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -394,7 +378,7 @@ static int32_t CodecComponentTypeProxyGetExtensionIndex(struct CodecComponentTyp
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -436,7 +420,7 @@ static int32_t CodecComponentTypeProxyGetState(struct CodecComponentType *self,
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -472,7 +456,7 @@ static int32_t CodecComponentTypeProxyComponentTunnelRequest(struct CodecCompone
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -532,7 +516,7 @@ static int32_t CodecComponentTypeProxyUseBuffer(struct CodecComponentType *self,
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -580,7 +564,7 @@ static int32_t CodecComponentTypeProxyAllocateBuffer(struct CodecComponentType *
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -628,7 +612,7 @@ static int32_t CodecComponentTypeProxyFreeBuffer(struct CodecComponentType *self
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -670,7 +654,7 @@ static int32_t CodecComponentTypeProxyEmptyThisBuffer(struct CodecComponentType
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -706,7 +690,7 @@ static int32_t CodecComponentTypeProxyFillThisBuffer(struct CodecComponentType *
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -730,7 +714,7 @@ static int32_t CodecComponentTypeProxyFillThisBuffer(struct CodecComponentType *
|
||||
}
|
||||
|
||||
static int32_t CodecComponentTypeProxySetCallbacks(struct CodecComponentType *self,
|
||||
struct CodecCallbackType *callback, int8_t *appData, uint32_t appDataLen)
|
||||
struct CodecCallbackType *callback, int64_t appData)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
@@ -742,7 +726,7 @@ static int32_t CodecComponentTypeProxySetCallbacks(struct CodecComponentType *se
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -754,18 +738,11 @@ static int32_t CodecComponentTypeProxySetCallbacks(struct CodecComponentType *se
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (!HdfSbufWriteUint32(data, appDataLen)) {
|
||||
if (!HdfSbufWriteInt64(data, appData)) {
|
||||
HDF_LOGE("%{public}s: write appData failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
for (uint32_t i = 0; i < appDataLen; i++) {
|
||||
if (!HdfSbufWriteInt8(data, appData[i])) {
|
||||
HDF_LOGE("%{public}s: write appData[i] failed!", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
ret = CodecComponentTypeProxyCall(self, CMD_SET_CALLBACKS, data, reply);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
@@ -790,7 +767,7 @@ static int32_t CodecComponentTypeProxyComponentDeInit(struct CodecComponentType
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -820,7 +797,7 @@ static int32_t CodecComponentTypeProxyUseEglImage(struct CodecComponentType *sel
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -881,7 +858,7 @@ static int32_t CodecComponentTypeProxyComponentRoleEnum(struct CodecComponentTyp
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
if (WriteInterfaceToken(self, data) != HDF_SUCCESS) {
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(self->AsObject(self), data)) {
|
||||
HDF_LOGE("%{public}s: write interface token failed", __func__);
|
||||
ReleaseSbuf(data, reply);
|
||||
return HDF_FAILURE;
|
||||
@@ -918,6 +895,15 @@ static int32_t CodecComponentTypeProxyComponentRoleEnum(struct CodecComponentTyp
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct HdfRemoteService *CodecComponentTypeProxyAsObject(struct CodecComponentType *self)
|
||||
{
|
||||
if (self == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
struct CodecComponentTypeProxy *proxy = CONTAINER_OF(self, struct CodecComponentTypeProxy, instance);
|
||||
return proxy->remote;
|
||||
}
|
||||
|
||||
static void CodecComponentTypeProxyConstruct(struct CodecComponentType *instance)
|
||||
{
|
||||
instance->GetComponentVersion = CodecComponentTypeProxyGetComponentVersion;
|
||||
@@ -938,12 +924,23 @@ static void CodecComponentTypeProxyConstruct(struct CodecComponentType *instance
|
||||
instance->ComponentDeInit = CodecComponentTypeProxyComponentDeInit;
|
||||
instance->UseEglImage = CodecComponentTypeProxyUseEglImage;
|
||||
instance->ComponentRoleEnum = CodecComponentTypeProxyComponentRoleEnum;
|
||||
instance->AsObject = CodecComponentTypeProxyAsObject;
|
||||
}
|
||||
|
||||
struct CodecComponentType *CodecComponentTypeGet(struct HdfRemoteService *remote)
|
||||
{
|
||||
struct CodecComponentTypeProxy *proxy
|
||||
= (struct CodecComponentTypeProxy *)OsalMemAlloc(sizeof(struct CodecComponentTypeProxy));
|
||||
if (remote == NULL) {
|
||||
HDF_LOGE("%{public}s: remote is null", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!HdfRemoteServiceSetInterfaceDesc(remote, CODEC_COMPONENT_INTERFACE_DESC)) {
|
||||
HDF_LOGE("%{public}s: set interface token failed!", __func__);
|
||||
HdfRemoteServiceRecycle(remote);
|
||||
return NULL;
|
||||
}
|
||||
struct CodecComponentTypeProxy *proxy =
|
||||
(struct CodecComponentTypeProxy *)OsalMemAlloc(sizeof(struct CodecComponentTypeProxy));
|
||||
if (proxy == NULL) {
|
||||
HDF_LOGE("%{public}s: malloc CodecComponentType proxy failed!", __func__);
|
||||
HdfRemoteServiceRecycle(remote);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "codec_component_type_service.h"
|
||||
#include <hdf_base.h>
|
||||
#include <hdf_log.h>
|
||||
#include <osal_mem.h>
|
||||
@@ -20,28 +21,17 @@
|
||||
#include <unistd.h>
|
||||
#include "codec_adapter_interface.h"
|
||||
#include "codec_component_type_stub.h"
|
||||
#include "codec_component_type_service.h"
|
||||
|
||||
struct CodecComponentTypeService {
|
||||
struct CodecComponentTypeStub stub;
|
||||
struct CodecComponentNode *codecNode;
|
||||
};
|
||||
#define HDF_LOG_TAG codec_hdi_server
|
||||
|
||||
int32_t OmxManagerCreateComponent(OMX_HANDLETYPE *compHandle, char *compName, void *appData, int32_t appDataSize,
|
||||
struct CodecCallbackType *callbacks)
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
return OMXAdapterCreateComponent(compHandle, compName, (int8_t*)appData, appDataSize, callbacks);
|
||||
}
|
||||
|
||||
int32_t OmxManagerDestroyComponent(OMX_HANDLETYPE compHandle)
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
return OmxAdapterDestoryComponent(compHandle);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeGetComponentVersion(struct CodecComponentType *self, struct CompVerInfo *verInfo)
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterComponentVersion(stub->componentHandle, verInfo);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterComponentVersion(service->codecNode, verInfo);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeSendCommand(struct CodecComponentType *self,
|
||||
@@ -49,8 +39,8 @@ int32_t CodecComponentTypeSendCommand(struct CodecComponentType *self,
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterSendCommand(stub->componentHandle, cmd, param, cmdData, cmdDataLen);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterSendCommand(service->codecNode, cmd, param, cmdData, cmdDataLen);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeGetParameter(struct CodecComponentType *self,
|
||||
@@ -58,8 +48,8 @@ int32_t CodecComponentTypeGetParameter(struct CodecComponentType *self,
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterGetParameter(stub->componentHandle, paramIndex, paramStruct, paramStructLen);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterGetParameter(service->codecNode, paramIndex, paramStruct, paramStructLen);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeSetParameter(struct CodecComponentType *self,
|
||||
@@ -67,8 +57,8 @@ int32_t CodecComponentTypeSetParameter(struct CodecComponentType *self,
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterSetParameter(stub->componentHandle, index, paramStruct, paramStructLen);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterSetParameter(service->codecNode, index, paramStruct, paramStructLen);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeGetConfig(struct CodecComponentType *self,
|
||||
@@ -76,8 +66,8 @@ int32_t CodecComponentTypeGetConfig(struct CodecComponentType *self,
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterGetConfig(stub->componentHandle, index, cfgStruct, cfgStructLen);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterGetConfig(service->codecNode, index, cfgStruct, cfgStructLen);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeSetConfig(struct CodecComponentType *self,
|
||||
@@ -85,24 +75,24 @@ int32_t CodecComponentTypeSetConfig(struct CodecComponentType *self,
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterSetConfig(stub->componentHandle, index, cfgStruct, cfgStructLen);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterSetConfig(service->codecNode, index, cfgStruct, cfgStructLen);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeGetExtensionIndex(struct CodecComponentType *self,
|
||||
const char *paramName, uint32_t *indexType)
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterGetExtensionIndex(stub->componentHandle, paramName, (enum OMX_INDEXTYPE *)indexType);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterGetExtensionIndex(service->codecNode, paramName, (enum OMX_INDEXTYPE *)indexType);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeGetState(struct CodecComponentType *self, enum OMX_STATETYPE *state)
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterGetState(stub->componentHandle, state);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterGetState(service->codecNode, state);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeComponentTunnelRequest(struct CodecComponentType *self,
|
||||
@@ -111,8 +101,8 @@ int32_t CodecComponentTypeComponentTunnelRequest(struct CodecComponentType *self
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterComponentTunnelRequest(stub->componentHandle, port, tunneledComp, tunneledPort, tunnelSetup);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterComponentTunnelRequest(service->codecNode, port, tunneledComp, tunneledPort, tunnelSetup);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeUseBuffer(struct CodecComponentType *self,
|
||||
@@ -120,8 +110,8 @@ int32_t CodecComponentTypeUseBuffer(struct CodecComponentType *self,
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterUseBuffer(stub->componentHandle, portIndex, buffer);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterUseBuffer(service->codecNode, portIndex, buffer);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeAllocateBuffer(struct CodecComponentType *self,
|
||||
@@ -129,8 +119,8 @@ int32_t CodecComponentTypeAllocateBuffer(struct CodecComponentType *self,
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterAllocateBuffer(stub->componentHandle, portIndex, buffer);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterAllocateBuffer(service->codecNode, portIndex, buffer);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeFreeBuffer(struct CodecComponentType *self, uint32_t portIndex,
|
||||
@@ -138,39 +128,39 @@ int32_t CodecComponentTypeFreeBuffer(struct CodecComponentType *self, uint32_t p
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterFreeBuffer(stub->componentHandle, portIndex, (struct OmxCodecBuffer *)buffer);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterFreeBuffer(service->codecNode, portIndex, (struct OmxCodecBuffer *)buffer);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeEmptyThisBuffer(struct CodecComponentType *self,
|
||||
const struct OmxCodecBuffer *buffer)
|
||||
{
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterEmptyThisBuffer(stub->componentHandle, (struct OmxCodecBuffer *)buffer);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterEmptyThisBuffer(service->codecNode, (struct OmxCodecBuffer *)buffer);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeFillThisBuffer(struct CodecComponentType *self,
|
||||
const struct OmxCodecBuffer *buffer)
|
||||
{
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterFillThisBuffer(stub->componentHandle, (struct OmxCodecBuffer *)buffer);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterFillThisBuffer(service->codecNode, (struct OmxCodecBuffer *)buffer);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeSetCallbacks(struct CodecComponentType *self,
|
||||
struct CodecCallbackType* callback, int8_t *appData, uint32_t appDataLen)
|
||||
int32_t CodecComponentTypeSetCallbacks(struct CodecComponentType *self, struct CodecCallbackType *callback,
|
||||
int64_t appData)
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterSetCallbacks(stub->componentHandle, callback, appData, appDataLen);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterSetCallbacks(service->codecNode, callback, appData);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeComponentDeInit(struct CodecComponentType *self)
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterDeInit(stub->componentHandle);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterDeInit(service->codecNode);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeUseEglImage(struct CodecComponentType *self,
|
||||
@@ -178,8 +168,8 @@ int32_t CodecComponentTypeUseEglImage(struct CodecComponentType *self,
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterUseEglImage(stub->componentHandle, buffer, portIndex, eglImage, eglImageLen);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterUseEglImage(service->codecNode, buffer, portIndex, eglImage, eglImageLen);
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeComponentRoleEnum(struct CodecComponentType *self,
|
||||
@@ -187,14 +177,12 @@ int32_t CodecComponentTypeComponentRoleEnum(struct CodecComponentType *self,
|
||||
{
|
||||
HDF_LOGI("%{public}s, service impl!", __func__);
|
||||
|
||||
struct CodecComponentTypeStub *stub = (struct CodecComponentTypeStub *)self;
|
||||
return OmxAdapterComponentRoleEnum(stub->componentHandle, role, roleLen, index);
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
return OmxAdapterComponentRoleEnum(service->codecNode, role, roleLen, index);
|
||||
}
|
||||
|
||||
void CodecComponentTypeServiceConstruct(struct OmxComponentManager *manager, struct CodecComponentType *instance)
|
||||
void CodecComponentTypeServiceConstruct(struct CodecComponentType *instance)
|
||||
{
|
||||
manager->CreateComponent = OmxManagerCreateComponent;
|
||||
manager->DestoryComponent = OmxManagerDestroyComponent;
|
||||
instance->GetComponentVersion = CodecComponentTypeGetComponentVersion;
|
||||
instance->SendCommand = CodecComponentTypeSendCommand;
|
||||
instance->GetParameter = CodecComponentTypeGetParameter;
|
||||
@@ -213,4 +201,50 @@ void CodecComponentTypeServiceConstruct(struct OmxComponentManager *manager, str
|
||||
instance->ComponentDeInit = CodecComponentTypeComponentDeInit;
|
||||
instance->UseEglImage = CodecComponentTypeUseEglImage;
|
||||
instance->ComponentRoleEnum = CodecComponentTypeComponentRoleEnum;
|
||||
}
|
||||
struct CodecComponentType *CodecComponentTypeServiceGet(void)
|
||||
{
|
||||
struct CodecComponentTypeService *service =
|
||||
(struct CodecComponentTypeService *)OsalMemCalloc(sizeof(struct CodecComponentTypeService));
|
||||
if (service == NULL) {
|
||||
HDF_LOGE("%{public}s: malloc FooService obj failed!", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!CodecComponentTypeStubConstruct(&service->stub)) {
|
||||
HDF_LOGE("%{public}s: construct FooStub obj failed!", __func__);
|
||||
OsalMemFree(service);
|
||||
return NULL;
|
||||
}
|
||||
CodecComponentTypeServiceConstruct(&service->stub.interface);
|
||||
return &service->stub.interface;
|
||||
}
|
||||
|
||||
void CodecComponentTypeServiceRelease(struct CodecComponentType *self)
|
||||
{
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
if (service == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
CodecComponentTypeStubRelease(&service->stub);
|
||||
OsalMemFree(service);
|
||||
}
|
||||
|
||||
void CodecCompoentTypeServiceSetCodecNode(struct CodecComponentType *self, struct CodecComponentNode *codecNode)
|
||||
{
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
if (service == NULL) {
|
||||
return;
|
||||
}
|
||||
service->codecNode = codecNode;
|
||||
}
|
||||
|
||||
struct CodecComponentNode *CodecCompoentTypeServiceGetCodecNode(struct CodecComponentType *self)
|
||||
{
|
||||
struct CodecComponentTypeService *service = (struct CodecComponentTypeService *)self;
|
||||
if (service == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return service->codecNode;
|
||||
}
|
||||
@@ -30,10 +30,6 @@
|
||||
#else
|
||||
#define DRIVER_PATH "/vendor/lib"
|
||||
#endif
|
||||
#define CODEC_SERVICE_IMPL "libcodec_hdi_omx_service_impl"
|
||||
|
||||
typedef void (*SERVICE_CONSTRUCT_FUNC)(struct OmxComponentManager *, struct CodecComponentType *);
|
||||
|
||||
static void FreeMem(int8_t *mem, uint32_t memLen)
|
||||
{
|
||||
if (memLen > 0 && mem != NULL) {
|
||||
@@ -41,117 +37,12 @@ static void FreeMem(int8_t *mem, uint32_t memLen)
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t SerStubGetComponentNum(struct CodecComponentTypeStub *stub,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
return HandleGetNumCmd(reply);
|
||||
}
|
||||
|
||||
static int32_t SerStubGetComponentCapablityList(struct CodecComponentTypeStub *stub,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
return HandleGetAllCapablityListCmd(reply);
|
||||
}
|
||||
|
||||
static int32_t ReadParamsForCreateComponent(struct HdfSBuf *data, char **compName, int8_t **appData,
|
||||
uint32_t *appDataSize, struct CodecCallbackType **callback)
|
||||
{
|
||||
const char *compNameCp = HdfSbufReadString(data);
|
||||
if (compNameCp == NULL) {
|
||||
HDF_LOGE("%{public}s: read compNameCp failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (!HdfSbufReadUint32(data, appDataSize)) {
|
||||
HDF_LOGE("%{public}s: read appData size failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
*compName = strdup(compNameCp);
|
||||
|
||||
if (*appDataSize > 0) {
|
||||
*appData = (int8_t*)OsalMemCalloc(sizeof(int8_t) * (*appDataSize));
|
||||
if (*appData == NULL) {
|
||||
HDF_LOGE("%{public}s: HDF_ERR_MALLOC_FAIL!", __func__);
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < *appDataSize; i++) {
|
||||
if (!HdfSbufReadInt8(data, &(*appData)[i])) {
|
||||
HDF_LOGE("%{public}s: read appData[i] failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct HdfRemoteService *callbackRemote = HdfSbufReadRemoteService(data);
|
||||
if (callbackRemote == NULL) {
|
||||
HDF_LOGE("%{public}s: read callbackRemote failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
*callback = CodecCallbackTypeGet(callbackRemote);
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SerStubCreateComponent(struct CodecComponentTypeStub *stub,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
OMX_HANDLETYPE componentHandle;
|
||||
int8_t *appData = NULL;
|
||||
uint32_t appDataSize = 0;
|
||||
struct CodecCallbackType *callback = NULL;
|
||||
char *compName = NULL;
|
||||
|
||||
ret = ReadParamsForCreateComponent(data, &compName, &appData, &appDataSize, &callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
if (compName != NULL) {
|
||||
OsalMemFree(compName);
|
||||
compName = NULL;
|
||||
}
|
||||
if (appDataSize > 0 && appData != NULL) {
|
||||
OsalMemFree(appData);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = stub->managerService.CreateComponent(&componentHandle, compName, appData, appDataSize, callback);
|
||||
if (compName != NULL) {
|
||||
OsalMemFree(compName);
|
||||
compName = NULL;
|
||||
}
|
||||
if (appDataSize > 0 && appData != NULL) {
|
||||
OsalMemFree(appData);
|
||||
}
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call CreateComponent function failed!", __func__);
|
||||
return ret;
|
||||
}
|
||||
stub->componentHandle = componentHandle;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubDestroyComponent(struct CodecComponentTypeStub *stub,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
ret = stub->managerService.DestoryComponent(stub->componentHandle);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call DestroyComponent function failed!", __func__);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubGetComponentVersion(struct CodecComponentTypeStub *stub,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubGetComponentVersion(struct CodecComponentType *serviceImpl, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
struct CompVerInfo verInfo = {0};
|
||||
|
||||
ret = stub->service.GetComponentVersion(&stub->service, &verInfo);
|
||||
ret = serviceImpl->GetComponentVersion(serviceImpl, &verInfo);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call GetComponentVersion function failed!", __func__);
|
||||
return ret;
|
||||
@@ -164,7 +55,7 @@ static int32_t SerStubGetComponentVersion(struct CodecComponentTypeStub *stub,
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SerStubSendCommand(struct CodecComponentTypeStub *stub, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubSendCommand(struct CodecComponentType *serviceImpl, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
enum OMX_COMMANDTYPE cmd;
|
||||
@@ -203,7 +94,7 @@ static int32_t SerStubSendCommand(struct CodecComponentTypeStub *stub, struct Hd
|
||||
}
|
||||
}
|
||||
|
||||
ret = stub->service.SendCommand(&stub->service, cmd, param, cmdData, cmdDataLen);
|
||||
ret = serviceImpl->SendCommand(serviceImpl, cmd, param, cmdData, cmdDataLen);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call SendCommand function failed!", __func__);
|
||||
FreeMem(cmdData, cmdDataLen);
|
||||
@@ -214,7 +105,7 @@ static int32_t SerStubSendCommand(struct CodecComponentTypeStub *stub, struct Hd
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SerStubGetParameter(struct CodecComponentTypeStub *stub, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubGetParameter(struct CodecComponentType *serviceImpl, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
uint32_t paramIndex = 0;
|
||||
@@ -244,7 +135,7 @@ static int32_t SerStubGetParameter(struct CodecComponentTypeStub *stub, struct H
|
||||
}
|
||||
}
|
||||
|
||||
ret = stub->service.GetParameter(&stub->service, paramIndex, paramStruct, paramStructLen);
|
||||
ret = serviceImpl->GetParameter(serviceImpl, paramIndex, paramStruct, paramStructLen);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call GetParameter function failed!", __func__);
|
||||
FreeMem(paramStruct, paramStructLen);
|
||||
@@ -263,7 +154,7 @@ static int32_t SerStubGetParameter(struct CodecComponentTypeStub *stub, struct H
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SerStubSetParameter(struct CodecComponentTypeStub *stub, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubSetParameter(struct CodecComponentType *serviceImpl, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
uint32_t index = 0;
|
||||
@@ -296,7 +187,7 @@ static int32_t SerStubSetParameter(struct CodecComponentTypeStub *stub, struct H
|
||||
}
|
||||
}
|
||||
|
||||
ret = stub->service.SetParameter(&stub->service, index, paramStruct, paramStructLen);
|
||||
ret = serviceImpl->SetParameter(serviceImpl, index, paramStruct, paramStructLen);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call SetParameter function failed!", __func__);
|
||||
FreeMem(paramStruct, paramStructLen);
|
||||
@@ -307,7 +198,7 @@ static int32_t SerStubSetParameter(struct CodecComponentTypeStub *stub, struct H
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SerStubGetConfig(struct CodecComponentTypeStub *stub, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubGetConfig(struct CodecComponentType *serviceImpl, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
uint32_t index = 0;
|
||||
@@ -337,7 +228,7 @@ static int32_t SerStubGetConfig(struct CodecComponentTypeStub *stub, struct HdfS
|
||||
}
|
||||
}
|
||||
|
||||
ret = stub->service.GetConfig(&stub->service, index, cfgStruct, cfgStructLen);
|
||||
ret = serviceImpl->GetConfig(serviceImpl, index, cfgStruct, cfgStructLen);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call GetConfig function failed!", __func__);
|
||||
FreeMem(cfgStruct, cfgStructLen);
|
||||
@@ -356,7 +247,7 @@ static int32_t SerStubGetConfig(struct CodecComponentTypeStub *stub, struct HdfS
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubSetConfig(struct CodecComponentTypeStub *stub, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubSetConfig(struct CodecComponentType *serviceImpl, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
uint32_t index = 0;
|
||||
@@ -389,7 +280,7 @@ static int32_t SerStubSetConfig(struct CodecComponentTypeStub *stub, struct HdfS
|
||||
}
|
||||
}
|
||||
|
||||
ret = stub->service.SetConfig(&stub->service, index, cfgStruct, cfgStructLen);
|
||||
ret = serviceImpl->SetConfig(serviceImpl, index, cfgStruct, cfgStructLen);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call SetConfig function failed!", __func__);
|
||||
FreeMem(cfgStruct, cfgStructLen);
|
||||
@@ -400,8 +291,8 @@ static int32_t SerStubSetConfig(struct CodecComponentTypeStub *stub, struct HdfS
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubGetExtensionIndex(struct CodecComponentTypeStub *stub,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubGetExtensionIndex(struct CodecComponentType *serviceImpl, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
char *paramName = NULL;
|
||||
@@ -414,7 +305,7 @@ static int32_t SerStubGetExtensionIndex(struct CodecComponentTypeStub *stub,
|
||||
}
|
||||
paramName = strdup(paramNameCp);
|
||||
|
||||
ret = stub->service.GetExtensionIndex(&stub->service, paramName, &indexType);
|
||||
ret = serviceImpl->GetExtensionIndex(serviceImpl, paramName, &indexType);
|
||||
if (paramName != NULL) {
|
||||
OsalMemFree(paramName);
|
||||
paramName = NULL;
|
||||
@@ -432,12 +323,12 @@ static int32_t SerStubGetExtensionIndex(struct CodecComponentTypeStub *stub,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubGetState(struct CodecComponentTypeStub *stub, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubGetState(struct CodecComponentType *serviceImpl, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
enum OMX_STATETYPE state;
|
||||
|
||||
ret = stub->service.GetState(&stub->service, &state);
|
||||
ret = serviceImpl->GetState(serviceImpl, &state);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call GetState function failed!", __func__);
|
||||
return ret;
|
||||
@@ -451,8 +342,8 @@ static int32_t SerStubGetState(struct CodecComponentTypeStub *stub, struct HdfSB
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubComponentTunnelRequest(struct CodecComponentTypeStub *stub,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubComponentTunnelRequest(struct CodecComponentType *serviceImpl, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
uint32_t port = 0;
|
||||
@@ -480,7 +371,7 @@ static int32_t SerStubComponentTunnelRequest(struct CodecComponentTypeStub *stub
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = stub->service.ComponentTunnelRequest(&stub->service, port, tunneledComp, tunneledPort, &tunnelSetup);
|
||||
ret = serviceImpl->ComponentTunnelRequest(serviceImpl, port, tunneledComp, tunneledPort, &tunnelSetup);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call ComponentTunnelRequest function failed!", __func__);
|
||||
return ret;
|
||||
@@ -494,7 +385,7 @@ static int32_t SerStubComponentTunnelRequest(struct CodecComponentTypeStub *stub
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubUseBuffer(struct CodecComponentTypeStub *stub, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubUseBuffer(struct CodecComponentType *serviceImpl, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
struct OmxCodecBuffer buffer;
|
||||
@@ -512,7 +403,7 @@ static int32_t SerStubUseBuffer(struct CodecComponentTypeStub *stub, struct HdfS
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = stub->service.UseBuffer(&stub->service, portIndex, &buffer);
|
||||
ret = serviceImpl->UseBuffer(serviceImpl, portIndex, &buffer);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call UseBuffer function failed!", __func__);
|
||||
ReleaseOmxCodecBuffer(&buffer);
|
||||
@@ -528,8 +419,8 @@ static int32_t SerStubUseBuffer(struct CodecComponentTypeStub *stub, struct HdfS
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubAllocateBuffer(struct CodecComponentTypeStub *stub,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubAllocateBuffer(struct CodecComponentType *serviceImpl, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
struct OmxCodecBuffer buffer;
|
||||
@@ -546,8 +437,8 @@ static int32_t SerStubAllocateBuffer(struct CodecComponentTypeStub *stub,
|
||||
ReleaseOmxCodecBuffer(&buffer);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = stub->service.AllocateBuffer(&stub->service, portIndex, &buffer);
|
||||
|
||||
ret = serviceImpl->AllocateBuffer(serviceImpl, portIndex, &buffer);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call AllocateBuffer function failed!", __func__);
|
||||
ReleaseOmxCodecBuffer(&buffer);
|
||||
@@ -563,7 +454,7 @@ static int32_t SerStubAllocateBuffer(struct CodecComponentTypeStub *stub,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubFreeBuffer(struct CodecComponentTypeStub *stub, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubFreeBuffer(struct CodecComponentType *serviceImpl, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
uint32_t portIndex = 0;
|
||||
@@ -580,7 +471,7 @@ static int32_t SerStubFreeBuffer(struct CodecComponentTypeStub *stub, struct Hdf
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = stub->service.FreeBuffer(&stub->service, portIndex, &buffer);
|
||||
ret = serviceImpl->FreeBuffer(serviceImpl, portIndex, &buffer);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call FreeBuffer function failed!", __func__);
|
||||
ReleaseOmxCodecBuffer(&buffer);
|
||||
@@ -590,8 +481,8 @@ static int32_t SerStubFreeBuffer(struct CodecComponentTypeStub *stub, struct Hdf
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubEmptyThisBuffer(struct CodecComponentTypeStub *stub,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubEmptyThisBuffer(struct CodecComponentType *serviceImpl, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
struct OmxCodecBuffer buffer;
|
||||
@@ -602,7 +493,7 @@ static int32_t SerStubEmptyThisBuffer(struct CodecComponentTypeStub *stub,
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = stub->service.EmptyThisBuffer(&stub->service, &buffer);
|
||||
ret = serviceImpl->EmptyThisBuffer(serviceImpl, &buffer);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call EmptyThisBuffer function failed!", __func__);
|
||||
ReleaseOmxCodecBuffer(&buffer);
|
||||
@@ -612,8 +503,8 @@ static int32_t SerStubEmptyThisBuffer(struct CodecComponentTypeStub *stub,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubFillThisBuffer(struct CodecComponentTypeStub *stub,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubFillThisBuffer(struct CodecComponentType *serviceImpl, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
struct OmxCodecBuffer buffer;
|
||||
@@ -624,7 +515,7 @@ static int32_t SerStubFillThisBuffer(struct CodecComponentTypeStub *stub,
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = stub->service.FillThisBuffer(&stub->service, &buffer);
|
||||
ret = serviceImpl->FillThisBuffer(serviceImpl, &buffer);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call FillThisBuffer function failed!", __func__);
|
||||
ReleaseOmxCodecBuffer(&buffer);
|
||||
@@ -634,12 +525,11 @@ static int32_t SerStubFillThisBuffer(struct CodecComponentTypeStub *stub,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubSetCallbacks(struct CodecComponentTypeStub *stub, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubSetCallbacks(struct CodecComponentType *serviceImpl, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
struct CodecCallbackType* callback = NULL;
|
||||
int8_t *appData = NULL;
|
||||
uint32_t appDataLen = 0;
|
||||
struct CodecCallbackType *callback = NULL;
|
||||
int64_t appData = 0;
|
||||
|
||||
struct HdfRemoteService *callbackRemote = HdfSbufReadRemoteService(data);
|
||||
if (callbackRemote == NULL) {
|
||||
@@ -648,44 +538,25 @@ static int32_t SerStubSetCallbacks(struct CodecComponentTypeStub *stub, struct H
|
||||
}
|
||||
callback = CodecCallbackTypeGet(callbackRemote);
|
||||
|
||||
if (!HdfSbufReadUint32(data, &appDataLen)) {
|
||||
if (!HdfSbufReadInt64(data, &appData)) {
|
||||
HDF_LOGE("%{public}s: read appData size failed!", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (appDataLen > 0) {
|
||||
appData = (int8_t*)OsalMemCalloc(sizeof(int8_t) * (appDataLen));
|
||||
if (appData == NULL) {
|
||||
HDF_LOGE("%{public}s: HDF_ERR_MALLOC_FAIL!", __func__);
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < appDataLen; i++) {
|
||||
if (!HdfSbufReadInt8(data, &appData[i])) {
|
||||
HDF_LOGE("%{public}s: read &appData[i] failed!", __func__);
|
||||
FreeMem(appData, appDataLen);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret = stub->service.SetCallbacks(&stub->service, callback, appData, appDataLen);
|
||||
ret = serviceImpl->SetCallbacks(serviceImpl, callback, appData);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call SetCallbacks function failed!", __func__);
|
||||
FreeMem(appData, appDataLen);
|
||||
return ret;
|
||||
}
|
||||
|
||||
FreeMem(appData, appDataLen);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubComponentDeInit(struct CodecComponentTypeStub *stub,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubComponentDeInit(struct CodecComponentType *serviceImpl, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
ret = stub->service.ComponentDeInit(&stub->service);
|
||||
ret = serviceImpl->ComponentDeInit(serviceImpl);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call ComponentDeInit function failed!", __func__);
|
||||
}
|
||||
@@ -693,7 +564,7 @@ static int32_t SerStubComponentDeInit(struct CodecComponentTypeStub *stub,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubUseEglImage(struct CodecComponentTypeStub *stub, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubUseEglImage(struct CodecComponentType *serviceImpl, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
struct OmxCodecBuffer buffer;
|
||||
@@ -732,7 +603,7 @@ static int32_t SerStubUseEglImage(struct CodecComponentTypeStub *stub, struct Hd
|
||||
}
|
||||
}
|
||||
|
||||
ret = stub->service.UseEglImage(&stub->service, &buffer, portIndex, eglImage, eglImageLen);
|
||||
ret = serviceImpl->UseEglImage(serviceImpl, &buffer, portIndex, eglImage, eglImageLen);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call UseEglImage function failed!", __func__);
|
||||
FreeMem(eglImage, eglImageLen);
|
||||
@@ -749,8 +620,8 @@ static int32_t SerStubUseEglImage(struct CodecComponentTypeStub *stub, struct Hd
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t SerStubComponentRoleEnum(struct CodecComponentTypeStub *stub,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
static int32_t SerStubComponentRoleEnum(struct CodecComponentType *serviceImpl, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
uint8_t *role = NULL;
|
||||
@@ -774,7 +645,7 @@ static int32_t SerStubComponentRoleEnum(struct CodecComponentTypeStub *stub,
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = stub->service.ComponentRoleEnum(&stub->service, role, roleLen, index);
|
||||
ret = serviceImpl->ComponentRoleEnum(serviceImpl, role, roleLen, index);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: call ComponentRoleEnum function failed!", __func__);
|
||||
FreeMem((int8_t*)role, roleLen);
|
||||
@@ -793,159 +664,96 @@ static int32_t SerStubComponentRoleEnum(struct CodecComponentTypeStub *stub,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t HandleComponentManagerCmd(struct CodecComponentTypeStub *stub,
|
||||
int32_t cmdId, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
int32_t CodecComponentTypeServiceOnRemoteRequest(struct HdfRemoteService *remote, int32_t cmdId, struct HdfSBuf *data,
|
||||
struct HdfSBuf *reply)
|
||||
{
|
||||
switch (cmdId) {
|
||||
case CMD_CODEC_GET_COMPONENT_NUM:
|
||||
return SerStubGetComponentNum(stub, data, reply);
|
||||
case CMD_CODEC_GET_COMPONENT_CAPABILITY_LIST:
|
||||
return SerStubGetComponentCapablityList(stub, data, reply);
|
||||
case CMD_CREATE_COMPONENT:
|
||||
return SerStubCreateComponent(stub, data, reply);
|
||||
case CMD_DESTROY_COMPONENT:
|
||||
return SerStubDestroyComponent(stub, data, reply);
|
||||
default:
|
||||
HDF_LOGE("%{public}s: not support cmd %{public}d", __func__, cmdId);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t HandleComponentCmd(struct CodecComponentTypeStub *stub,
|
||||
int32_t cmdId, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
switch (cmdId) {
|
||||
case CMD_GET_COMPONENT_VERSION:
|
||||
return SerStubGetComponentVersion(stub, data, reply);
|
||||
case CMD_SEND_COMMAND:
|
||||
return SerStubSendCommand(stub, data, reply);
|
||||
case CMD_GET_PARAMETER:
|
||||
return SerStubGetParameter(stub, data, reply);
|
||||
case CMD_SET_PARAMETER:
|
||||
return SerStubSetParameter(stub, data, reply);
|
||||
case CMD_GET_CONFIG:
|
||||
return SerStubGetConfig(stub, data, reply);
|
||||
case CMD_SET_CONFIG:
|
||||
return SerStubSetConfig(stub, data, reply);
|
||||
case CMD_GET_EXTENSION_INDEX:
|
||||
return SerStubGetExtensionIndex(stub, data, reply);
|
||||
case CMD_GET_STATE:
|
||||
return SerStubGetState(stub, data, reply);
|
||||
case CMD_COMPONENT_TUNNEL_REQUEST:
|
||||
return SerStubComponentTunnelRequest(stub, data, reply);
|
||||
case CMD_USE_BUFFER:
|
||||
return SerStubUseBuffer(stub, data, reply);
|
||||
case CMD_ALLOCATE_BUFFER:
|
||||
return SerStubAllocateBuffer(stub, data, reply);
|
||||
case CMD_FREE_BUFFER:
|
||||
return SerStubFreeBuffer(stub, data, reply);
|
||||
case CMD_EMPTY_THIS_BUFFER:
|
||||
return SerStubEmptyThisBuffer(stub, data, reply);
|
||||
case CMD_FILL_THIS_BUFFER:
|
||||
return SerStubFillThisBuffer(stub, data, reply);
|
||||
case CMD_SET_CALLBACKS:
|
||||
return SerStubSetCallbacks(stub, data, reply);
|
||||
case CMD_COMPONENT_DE_INIT:
|
||||
return SerStubComponentDeInit(stub, data, reply);
|
||||
case CMD_USE_EGL_IMAGE:
|
||||
return SerStubUseEglImage(stub, data, reply);
|
||||
case CMD_COMPONENT_ROLE_ENUM:
|
||||
return SerStubComponentRoleEnum(stub, data, reply);
|
||||
default:
|
||||
HDF_LOGE("%{public}s: not support cmd %{public}d", __func__, cmdId);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t CodecComponentTypeServiceOnRemoteRequest(struct CodecComponentTypeStub *service,
|
||||
int32_t cmdId, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
if (!HdfDeviceObjectCheckInterfaceDesc(service->device, data)) {
|
||||
HDF_LOGE("%{public}s: check interface token failed!", __func__);
|
||||
struct CodecComponentType *serviceImpl = (struct CodecComponentType *)remote;
|
||||
if (!HdfRemoteServiceCheckInterfaceToken(serviceImpl->AsObject(serviceImpl), data)) {
|
||||
HDF_LOGE("%{public}s: interface token check failed", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
|
||||
switch (cmdId) {
|
||||
case CMD_CODEC_GET_COMPONENT_NUM:
|
||||
case CMD_CODEC_GET_COMPONENT_CAPABILITY_LIST:
|
||||
case CMD_CREATE_COMPONENT:
|
||||
case CMD_DESTROY_COMPONENT:
|
||||
return HandleComponentManagerCmd(service, cmdId, data, reply);
|
||||
case CMD_GET_COMPONENT_VERSION:
|
||||
return SerStubGetComponentVersion(serviceImpl, data, reply);
|
||||
case CMD_SEND_COMMAND:
|
||||
return SerStubSendCommand(serviceImpl, data, reply);
|
||||
case CMD_GET_PARAMETER:
|
||||
return SerStubGetParameter(serviceImpl, data, reply);
|
||||
case CMD_SET_PARAMETER:
|
||||
return SerStubSetParameter(serviceImpl, data, reply);
|
||||
case CMD_GET_CONFIG:
|
||||
return SerStubGetConfig(serviceImpl, data, reply);
|
||||
case CMD_SET_CONFIG:
|
||||
return SerStubSetConfig(serviceImpl, data, reply);
|
||||
case CMD_GET_EXTENSION_INDEX:
|
||||
return SerStubGetExtensionIndex(serviceImpl, data, reply);
|
||||
case CMD_GET_STATE:
|
||||
return SerStubGetState(serviceImpl, data, reply);
|
||||
case CMD_COMPONENT_TUNNEL_REQUEST:
|
||||
return SerStubComponentTunnelRequest(serviceImpl, data, reply);
|
||||
case CMD_USE_BUFFER:
|
||||
return SerStubUseBuffer(serviceImpl, data, reply);
|
||||
case CMD_ALLOCATE_BUFFER:
|
||||
return SerStubAllocateBuffer(serviceImpl, data, reply);
|
||||
case CMD_FREE_BUFFER:
|
||||
return SerStubFreeBuffer(serviceImpl, data, reply);
|
||||
case CMD_EMPTY_THIS_BUFFER:
|
||||
return SerStubEmptyThisBuffer(serviceImpl, data, reply);
|
||||
case CMD_FILL_THIS_BUFFER:
|
||||
return SerStubFillThisBuffer(serviceImpl, data, reply);
|
||||
case CMD_SET_CALLBACKS:
|
||||
return SerStubSetCallbacks(serviceImpl, data, reply);
|
||||
case CMD_COMPONENT_DE_INIT:
|
||||
return SerStubComponentDeInit(serviceImpl, data, reply);
|
||||
case CMD_USE_EGL_IMAGE:
|
||||
return SerStubUseEglImage(serviceImpl, data, reply);
|
||||
case CMD_COMPONENT_ROLE_ENUM:
|
||||
return HandleComponentCmd(service, cmdId, data, reply);
|
||||
return SerStubComponentRoleEnum(serviceImpl, data, reply);
|
||||
default:
|
||||
HDF_LOGE("%{public}s: not support cmd %{public}d", __func__, cmdId);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
static void *LoadServiceHandler(void)
|
||||
static struct HdfRemoteService *CodecComponentTypeAsObject(struct CodecComponentType *self)
|
||||
{
|
||||
char *libPath = NULL;
|
||||
void *handler = NULL;
|
||||
|
||||
libPath = HDF_LIBRARY_FULL_PATH(CODEC_SERVICE_IMPL);
|
||||
handler = dlopen(libPath, RTLD_LAZY);
|
||||
if (handler == NULL) {
|
||||
HDF_LOGE("%{public}s: dlopen failed %{public}s", __func__, dlerror());
|
||||
if (self == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return handler;
|
||||
struct CodecComponentTypeStub *stub = CONTAINER_OF(self, struct CodecComponentTypeStub, interface);
|
||||
return stub->remote;
|
||||
}
|
||||
|
||||
struct CodecComponentTypeStub *CodecComponentTypeStubGetInstance(void)
|
||||
bool CodecComponentTypeStubConstruct(struct CodecComponentTypeStub *stub)
|
||||
{
|
||||
SERVICE_CONSTRUCT_FUNC serviceConstructFunc = NULL;
|
||||
struct CodecComponentTypeStub *stub
|
||||
= (struct CodecComponentTypeStub *)OsalMemAlloc(sizeof(struct CodecComponentTypeStub));
|
||||
if (stub == NULL) {
|
||||
HDF_LOGE("%{public}s: OsalMemAlloc obj failed!", __func__);
|
||||
return NULL;
|
||||
HDF_LOGE("%{public}s: stub is null!", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
stub->dlHandler = LoadServiceHandler();
|
||||
if (stub->dlHandler == NULL) {
|
||||
HDF_LOGE("%{public}s: stub->dlHanlder is null", __func__);
|
||||
OsalMemFree(stub);
|
||||
return NULL;
|
||||
stub->dispatcher.Dispatch = CodecComponentTypeServiceOnRemoteRequest;
|
||||
stub->remote = HdfRemoteServiceObtain((struct HdfObject *)stub, &(stub->dispatcher));
|
||||
if (stub->remote == NULL) {
|
||||
HDF_LOGE("%{public}s: stub->remote is null", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
serviceConstructFunc = (SERVICE_CONSTRUCT_FUNC)dlsym(stub->dlHandler, "CodecComponentTypeServiceConstruct");
|
||||
if (serviceConstructFunc == NULL) {
|
||||
HDF_LOGE("%{public}s: dlsym failed %{public}s", __func__, dlerror());
|
||||
dlclose(stub->dlHandler);
|
||||
OsalMemFree(stub);
|
||||
return NULL;
|
||||
if (!HdfRemoteServiceSetInterfaceDesc(stub->remote, CODEC_COMPONENT_INTERFACE_DESC)) {
|
||||
HDF_LOGE("%{public}s: failed to set remote service interface descriptor", __func__);
|
||||
CodecComponentTypeStubRelease(stub);
|
||||
return false;
|
||||
}
|
||||
|
||||
serviceConstructFunc(&stub->managerService, &stub->service);
|
||||
return stub;
|
||||
stub->interface.AsObject = CodecComponentTypeAsObject;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CodecComponentTypeStubRelease(struct CodecComponentTypeStub *instance)
|
||||
void CodecComponentTypeStubRelease(struct CodecComponentTypeStub *stub)
|
||||
{
|
||||
if (instance == NULL) {
|
||||
if (stub == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
dlclose(instance->dlHandler);
|
||||
OsalMemFree(instance);
|
||||
HdfRemoteServiceRecycle(stub->remote);
|
||||
stub->remote = NULL;
|
||||
}
|
||||
+14
-27
@@ -184,20 +184,16 @@ static bool CodecBufferMarshalling(struct HdfSBuf *data, const struct OmxCodecBu
|
||||
HDF_LOGE("%{public}s: write fd failed!", __func__);
|
||||
return false;
|
||||
}
|
||||
} else if (dataBlock->bufferType == CODEC_BUFFER_TYPE_HANDLE
|
||||
|| dataBlock->bufferType == CODEC_BUFFER_TYPE_DYNAMIC_HANDLE) {
|
||||
} else if (dataBlock->bufferType == CODEC_BUFFER_TYPE_HANDLE ||
|
||||
dataBlock->bufferType == CODEC_BUFFER_TYPE_DYNAMIC_HANDLE) {
|
||||
BufferHandle *handle = (BufferHandle *)dataBlock->buffer;
|
||||
if (!BufferHandleMarshalling(data, handle)) {
|
||||
HDF_LOGE("%{public}s: write handle failed!", __func__);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
for (uint32_t i = 0; i < dataBlock->bufferLen; i++) {
|
||||
if (!HdfSbufWriteUint8(data, (dataBlock->buffer)[i])) {
|
||||
HDF_LOGE("%{public}s: write (dataBlock->buffer)[i] failed!", __func__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
HDF_LOGE("%{public}s:unsupport bufferType %{public}d!", __func__, dataBlock->bufferType);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -250,6 +246,10 @@ bool OmxCodecBufferBlockMarshalling(struct HdfSBuf *data, const struct OmxCodecB
|
||||
|
||||
static bool CodecBufferUnmarshalling(struct HdfSBuf *data, struct OmxCodecBuffer *dataBlock)
|
||||
{
|
||||
if (dataBlock == NULL) {
|
||||
HDF_LOGE("%{public}s: dataBlock is NULL!", __func__);
|
||||
return false;
|
||||
}
|
||||
if (!HdfSbufReadInt32(data, (int32_t *)&dataBlock->bufferType)) {
|
||||
HDF_LOGE("%{public}s: read dataBlock->bufferType failed!", __func__);
|
||||
return false;
|
||||
@@ -272,8 +272,8 @@ static bool CodecBufferUnmarshalling(struct HdfSBuf *data, struct OmxCodecBuffer
|
||||
return false;
|
||||
}
|
||||
dataBlock->buffer = (uint8_t *)(unsigned long)fd;
|
||||
} else if (dataBlock->bufferType == CODEC_BUFFER_TYPE_HANDLE
|
||||
|| dataBlock->bufferType == CODEC_BUFFER_TYPE_DYNAMIC_HANDLE) {
|
||||
} else if (dataBlock->bufferType == CODEC_BUFFER_TYPE_HANDLE ||
|
||||
dataBlock->bufferType == CODEC_BUFFER_TYPE_DYNAMIC_HANDLE) {
|
||||
BufferHandle *handle = NULL;
|
||||
if (!BufferHandleUnmarshalling(data, &handle)) {
|
||||
HDF_LOGE("%{public}s: read bufferhandle failed!", __func__);
|
||||
@@ -281,21 +281,8 @@ static bool CodecBufferUnmarshalling(struct HdfSBuf *data, struct OmxCodecBuffer
|
||||
}
|
||||
dataBlock->buffer = (uint8_t *)handle;
|
||||
} else {
|
||||
uint8_t *bufferCp = NULL;
|
||||
if (bufferCpLen > 0) {
|
||||
bufferCp = (uint8_t *)OsalMemCalloc(sizeof(uint8_t) * bufferCpLen);
|
||||
}
|
||||
if (bufferCp == NULL) {
|
||||
return false;
|
||||
}
|
||||
for (uint32_t i = 0; i < bufferCpLen; i++) {
|
||||
if (!HdfSbufReadUint8(data, &bufferCp[i])) {
|
||||
HDF_LOGE("%{public}s: read bufferCp[i] failed!", __func__);
|
||||
OsalMemFree(bufferCp);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
dataBlock->buffer = bufferCp;
|
||||
HDF_LOGE("%{public}s: unsupport bufferType %{public}d", __func__, dataBlock->bufferType);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -314,8 +301,8 @@ void ReleaseOmxCodecBuffer(struct OmxCodecBuffer *codecBuffer)
|
||||
return;
|
||||
}
|
||||
|
||||
if (codecBuffer->bufferType == CODEC_BUFFER_TYPE_DYNAMIC_HANDLE
|
||||
|| codecBuffer->bufferType == CODEC_BUFFER_TYPE_HANDLE) {
|
||||
if (codecBuffer->bufferType == CODEC_BUFFER_TYPE_DYNAMIC_HANDLE ||
|
||||
codecBuffer->bufferType == CODEC_BUFFER_TYPE_HANDLE) {
|
||||
FreeBufferHandle((BufferHandle *)codecBuffer->buffer);
|
||||
} else if (codecBuffer->bufferType != CODEC_BUFFER_TYPE_AVSHARE_MEM_FD) {
|
||||
OsalMemFree(codecBuffer->buffer);
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Codec {
|
||||
namespace Omx {
|
||||
class ComponentNode : NoCopyable {
|
||||
public:
|
||||
ComponentNode(struct CodecCallbackType *callback, int8_t *appData, int32_t appDataLen);
|
||||
ComponentNode(struct CodecCallbackType *callback, int64_t appData);
|
||||
|
||||
~ComponentNode();
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
|
||||
int32_t FillThisBuffer(struct OmxCodecBuffer &buffer);
|
||||
|
||||
int32_t SetCallbacks(struct CodecCallbackType *omxCallback, int8_t *appData, uint32_t appDataLen);
|
||||
int32_t SetCallbacks(struct CodecCallbackType *omxCallback, int64_t appData);
|
||||
|
||||
int32_t UseEglImage(struct OmxCodecBuffer &buffer, uint32_t portIndex, int8_t *eglImage, uint32_t eglImageLen);
|
||||
|
||||
@@ -84,6 +84,11 @@ public:
|
||||
this->comp_ = comp;
|
||||
}
|
||||
|
||||
OMX_HANDLETYPE GetHandle()
|
||||
{
|
||||
return comp_;
|
||||
}
|
||||
|
||||
public:
|
||||
static OMX_CALLBACKTYPE callbacks_; // callbacks
|
||||
|
||||
@@ -101,8 +106,7 @@ private:
|
||||
private:
|
||||
OMX_HANDLETYPE comp_; // Compnent handle
|
||||
struct CodecCallbackType *omxCallback_; // Callbacks in HDI
|
||||
int8_t *appData_; // Use data, default is nullptr
|
||||
int32_t appDataSize_; // User data length, default is 0
|
||||
int64_t appData_; // Use data, default is 0
|
||||
std::map<uint32_t, sptr<ICodecBuffer>> codecBufferMap_; // Key is buffferID
|
||||
std::map<OMX_BUFFERHEADERTYPE *, uint32_t> bufferHeaderMap_; // Key is omx buffer header type
|
||||
uint32_t bufferIdCount_;
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022 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 COMPONENT_NODE_MGR_H
|
||||
#define COMPONENT_NODE_MGR_H
|
||||
#include <OMX_Core.h>
|
||||
#include <map>
|
||||
#include <nocopyable.h>
|
||||
|
||||
#include "codec_callback_if.h"
|
||||
#include "codec_types.h"
|
||||
#include "component_mgr.h"
|
||||
#include "component_node.h"
|
||||
namespace OHOS {
|
||||
namespace Codec {
|
||||
namespace Omx {
|
||||
class ComponentNodeMgr : NoCopyable {
|
||||
public:
|
||||
ComponentNodeMgr();
|
||||
~ComponentNodeMgr();
|
||||
|
||||
int32_t CreateComponent(OMX_HANDLETYPE *compHandle, char *compName, int8_t *appData, int32_t appDataSize,
|
||||
struct CodecCallbackType *callbacks);
|
||||
|
||||
int32_t DestoryComponent(OMX_HANDLETYPE compHandle);
|
||||
|
||||
int32_t GetComponentVersion(OMX_HANDLETYPE compHandle, struct CompVerInfo &verInfo);
|
||||
|
||||
int32_t SendCommand(OMX_HANDLETYPE compHandle, enum OMX_COMMANDTYPE cmd, uint32_t param, int8_t *cmdData,
|
||||
uint32_t cmdDataLen);
|
||||
|
||||
int32_t GetParameter(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE paramIndex, int8_t *param, uint32_t paramLen);
|
||||
|
||||
int32_t SetParameter(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE paramIndex, int8_t *param, uint32_t paramLen);
|
||||
|
||||
int32_t GetConfig(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE index, int8_t *config, uint32_t configLen);
|
||||
|
||||
int32_t SetConfig(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE index, int8_t *config, uint32_t configLen);
|
||||
|
||||
int32_t GetExtensionIndex(OMX_HANDLETYPE compHandle, const char *parameterName, enum OMX_INDEXTYPE *indexType);
|
||||
|
||||
int32_t GetState(OMX_HANDLETYPE compHandle, enum OMX_STATETYPE *state);
|
||||
|
||||
int32_t ComponentTunnelRequest(OMX_HANDLETYPE compHandle, uint32_t port, int32_t omxHandleTypeTunneledComp,
|
||||
uint32_t tunneledPort, struct OMX_TUNNELSETUPTYPE *tunnelSetup);
|
||||
|
||||
int32_t UseBuffer(OMX_HANDLETYPE compHandle, uint32_t portIndex, struct OmxCodecBuffer &buffer);
|
||||
|
||||
int32_t AllocateBuffer(OMX_HANDLETYPE compHandle, uint32_t portIndex, struct OmxCodecBuffer &buffer);
|
||||
|
||||
int32_t FreeBuffer(OMX_HANDLETYPE compHandle, uint32_t portIndex, struct OmxCodecBuffer &buffer);
|
||||
|
||||
int32_t EmptyThisBuffer(OMX_HANDLETYPE compHandle, struct OmxCodecBuffer &buffer);
|
||||
|
||||
int32_t FillThisBuffer(OMX_HANDLETYPE compHandle, struct OmxCodecBuffer &buffer);
|
||||
|
||||
int32_t SetCallbacks(OMX_HANDLETYPE compHandle, struct CodecCallbackType *omxCallback, int8_t *appData,
|
||||
uint32_t appDataLen);
|
||||
|
||||
int32_t DeInit(OMX_HANDLETYPE compHandle);
|
||||
|
||||
int32_t UseEglImage(OMX_HANDLETYPE compHandle, struct OmxCodecBuffer &buffer, uint32_t portIndex, int8_t *eglImage,
|
||||
uint32_t eglImageLen);
|
||||
|
||||
int32_t ComponentRoleEnum(OMX_HANDLETYPE compHandle, uint8_t *role, uint32_t roleLen, uint32_t index);
|
||||
|
||||
private:
|
||||
std::shared_ptr<ComponentMgr> compMgr_;
|
||||
std::map<OMX_HANDLETYPE, std::shared_ptr<ComponentNode>> nodeMaps_;
|
||||
};
|
||||
} // namespace Omx
|
||||
} // namespace Codec
|
||||
} // namespace OHOS
|
||||
#endif /* COMPONENT_NODE_MGR_H */
|
||||
@@ -13,14 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "component_mgr.h"
|
||||
#include <cstring>
|
||||
#include <dlfcn.h>
|
||||
#include <hdf_base.h>
|
||||
#include <hdf_log.h>
|
||||
#include <memory.h>
|
||||
#include <securec.h>
|
||||
|
||||
#include "component_mgr.h"
|
||||
#define HDF_LOG_TAG codec_hdi_server
|
||||
constexpr int COMPONENT_NAME_MAX_LEN = 128;
|
||||
|
||||
|
||||
@@ -65,16 +65,9 @@ OMX_ERRORTYPE ComponentNode::OnFillBufferDone(OMX_HANDLETYPE component, void *ap
|
||||
OMX_CALLBACKTYPE ComponentNode::callbacks_ = {&ComponentNode::OnEvent, &ComponentNode::OnEmptyBufferDone,
|
||||
&ComponentNode::OnFillBufferDone};
|
||||
|
||||
ComponentNode::ComponentNode(struct CodecCallbackType *callback, int8_t *appData, int32_t appDataLen)
|
||||
ComponentNode::ComponentNode(struct CodecCallbackType *callback, int64_t appData)
|
||||
{
|
||||
if (appData != nullptr && appDataLen != 0) {
|
||||
appData_ = (int8_t *)OsalMemCalloc(sizeof(int8_t) * appDataLen);
|
||||
(void)memcpy_s(appData_, appDataLen, appData, appDataLen);
|
||||
appDataSize_ = appDataLen;
|
||||
} else {
|
||||
appData_ = nullptr;
|
||||
appDataSize_ = 0;
|
||||
}
|
||||
appData_ = appData;
|
||||
comp_ = nullptr;
|
||||
codecBufferMap_.clear();
|
||||
bufferHeaderMap_.clear();
|
||||
@@ -84,12 +77,6 @@ ComponentNode::ComponentNode(struct CodecCallbackType *callback, int8_t *appData
|
||||
|
||||
ComponentNode::~ComponentNode()
|
||||
{
|
||||
if (appData_ != nullptr) {
|
||||
OsalMemFree(appData_);
|
||||
appData_ = nullptr;
|
||||
appDataSize_ = 0;
|
||||
}
|
||||
|
||||
if (omxCallback_ != nullptr) {
|
||||
OsalMemFree(omxCallback_);
|
||||
omxCallback_ = nullptr;
|
||||
@@ -196,25 +183,15 @@ int32_t ComponentNode::ComponentTunnelRequest(uint32_t port, int32_t omxHandleTy
|
||||
return comType->ComponentTunnelRequest(comp_, port, (OMX_HANDLETYPE)tunneledComp, tunneledPort, tunnelSetup);
|
||||
}
|
||||
|
||||
int32_t ComponentNode::SetCallbacks(struct CodecCallbackType *omxCallback, int8_t *appData, uint32_t appDataLen)
|
||||
int32_t ComponentNode::SetCallbacks(struct CodecCallbackType *omxCallback, int64_t appData)
|
||||
{
|
||||
// release this->omxCallback_
|
||||
if (this->omxCallback_ != nullptr) {
|
||||
OsalMemFree(this->omxCallback_);
|
||||
this->omxCallback_ = nullptr;
|
||||
}
|
||||
|
||||
this->omxCallback_ = omxCallback;
|
||||
|
||||
if (this->appData_ != nullptr) {
|
||||
OsalMemFree(this->appData_);
|
||||
this->appData_ = nullptr;
|
||||
}
|
||||
if ((appData != nullptr) && appDataLen != 0) {
|
||||
this->appData_ = (int8_t *)OsalMemCalloc(sizeof(int8_t) * appDataLen);
|
||||
(void)memcpy_s(this->appData_, appDataLen, appData, appDataLen);
|
||||
}
|
||||
this->appDataSize_ = appDataLen;
|
||||
this->appData_ = appData;
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
@@ -268,14 +245,11 @@ int32_t ComponentNode::OnEvent(OMX_EVENTTYPE event, uint32_t data1, uint32_t dat
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
struct EventInfo info = {
|
||||
.appData = nullptr, .appDataLen = 0, .data1 = 0, .data2 = 0, .eventData = nullptr, .eventDataLen = 0};
|
||||
info.appData = appData_;
|
||||
info.appDataLen = appDataSize_;
|
||||
info.data1 = data1;
|
||||
info.data2 = data2;
|
||||
info.eventData = static_cast<int8_t *>(eventData);
|
||||
info.eventDataLen = 0;
|
||||
struct EventInfo info = {.appData = appData_,
|
||||
.data1 = data1,
|
||||
.data2 = data2,
|
||||
.eventData = static_cast<int8_t *>(eventData),
|
||||
.eventDataLen = 0};
|
||||
(void)omxCallback_->EventHandler(omxCallback_, event, &info);
|
||||
|
||||
return OMX_ErrorNone;
|
||||
@@ -293,7 +267,7 @@ int32_t ComponentNode::OnEmptyBufferDone(OMX_BUFFERHEADERTYPE *buffer)
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
struct OmxCodecBuffer &codecOmxBuffer = codecBuffer->GetCodecBuffer();
|
||||
(void)omxCallback_->EmptyBufferDone(omxCallback_, appData_, appDataSize_, &codecOmxBuffer);
|
||||
(void)omxCallback_->EmptyBufferDone(omxCallback_, appData_, &codecOmxBuffer);
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
@@ -311,7 +285,7 @@ int32_t ComponentNode::OnFillBufferDone(OMX_BUFFERHEADERTYPE *buffer)
|
||||
}
|
||||
|
||||
struct OmxCodecBuffer &codecOmxBuffer = codecBuffer->GetCodecBuffer();
|
||||
(void)omxCallback_->FillBufferDone(omxCallback_, appData_, appDataSize_, &codecOmxBuffer);
|
||||
(void)omxCallback_->FillBufferDone(omxCallback_, appData_, &codecOmxBuffer);
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,364 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022 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 <hdf_log.h>
|
||||
|
||||
#include "component_node_mgr.h"
|
||||
|
||||
#define HDF_LOG_TAG codec_hdi_server
|
||||
|
||||
namespace OHOS {
|
||||
namespace Codec {
|
||||
namespace Omx {
|
||||
ComponentNodeMgr::ComponentNodeMgr()
|
||||
{
|
||||
compMgr_ = std::make_shared<ComponentMgr>();
|
||||
}
|
||||
|
||||
ComponentNodeMgr::~ComponentNodeMgr()
|
||||
{
|
||||
if (compMgr_ != nullptr) {
|
||||
compMgr_ = nullptr;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.begin();
|
||||
while (iter != nodeMaps_.end()) {
|
||||
iter = nodeMaps_.erase(iter);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::CreateComponent(OMX_HANDLETYPE *compHandle, char *compName, int8_t *appData,
|
||||
int32_t appDataSize, struct CodecCallbackType *callbacks)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
OMX_COMPONENTTYPE *comp = nullptr;
|
||||
std::shared_ptr<ComponentNode> node = std::make_shared<ComponentNode>(callbacks, appData, appDataSize);
|
||||
auto err = compMgr_->CreateComponentInstance(compName, &ComponentNode::callbacks_, node.get(), &comp);
|
||||
if (err != OMX_ErrorNone) {
|
||||
HDF_LOGE("%{public}s ceate component instance error", __func__);
|
||||
node = nullptr;
|
||||
return err;
|
||||
}
|
||||
*compHandle = (OMX_HANDLETYPE)comp;
|
||||
node->SetHandle((OMX_HANDLETYPE)comp);
|
||||
nodeMaps_.emplace(std::make_pair(comp, node));
|
||||
return err;
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::DestoryComponent(OMX_HANDLETYPE compHandle)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
OMX_COMPONENTTYPE *comp = (OMX_COMPONENTTYPE *)compHandle;
|
||||
|
||||
auto iter = nodeMaps_.find((OMX_HANDLETYPE)comp);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
int32_t err = compMgr_->DeleteComponentInstance(comp);
|
||||
if (err == OMX_ErrorNone) {
|
||||
nodeMaps_.erase(iter);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::GetComponentVersion(OMX_HANDLETYPE compHandle, struct CompVerInfo &verInfo)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
return iter->second->GetComponentVersion(verInfo);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::SendCommand(OMX_HANDLETYPE compHandle, enum OMX_COMMANDTYPE cmd, uint32_t param,
|
||||
int8_t *cmdData, uint32_t cmdDataLen)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->SendCommand(cmd, param, cmdData, cmdDataLen);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::GetParameter(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE paramIndex, int8_t *param,
|
||||
uint32_t paramLen)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->GetParameter(paramIndex, param, paramLen);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::SetParameter(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE paramIndex, int8_t *param,
|
||||
uint32_t paramLen)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->SetParameter(paramIndex, param, paramLen);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::GetConfig(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE index, int8_t *config,
|
||||
uint32_t configLen)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->GetConfig(index, config, configLen);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::SetConfig(OMX_HANDLETYPE compHandle, enum OMX_INDEXTYPE index, int8_t *config,
|
||||
uint32_t configLen)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->SetConfig(index, config, configLen);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::GetExtensionIndex(OMX_HANDLETYPE compHandle, const char *parameterName,
|
||||
enum OMX_INDEXTYPE *indexType)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->GetExtensionIndex(parameterName, indexType);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::GetState(OMX_HANDLETYPE compHandle, enum OMX_STATETYPE *state)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->GetState(state);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::ComponentTunnelRequest(OMX_HANDLETYPE compHandle, uint32_t port,
|
||||
int32_t omxHandleTypeTunneledComp, uint32_t tunneledPort,
|
||||
struct OMX_TUNNELSETUPTYPE *tunnelSetup)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->ComponentTunnelRequest(port, omxHandleTypeTunneledComp, tunneledPort, tunnelSetup);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::UseBuffer(OMX_HANDLETYPE compHandle, uint32_t portIndex, struct OmxCodecBuffer &buffer)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->UseBuffer(portIndex, buffer);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::AllocateBuffer(OMX_HANDLETYPE compHandle, uint32_t portIndex, struct OmxCodecBuffer &buffer)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->AllocateBuffer(portIndex, buffer);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::FreeBuffer(OMX_HANDLETYPE compHandle, uint32_t portIndex, struct OmxCodecBuffer &buffer)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->FreeBuffer(portIndex, buffer);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::EmptyThisBuffer(OMX_HANDLETYPE compHandle, struct OmxCodecBuffer &buffer)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->EmptyThisBuffer(buffer);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::FillThisBuffer(OMX_HANDLETYPE compHandle, struct OmxCodecBuffer &buffer)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->FillThisBuffer(buffer);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::SetCallbacks(OMX_HANDLETYPE compHandle, struct CodecCallbackType *omxCallback,
|
||||
int8_t *appData, uint32_t appDataLen)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->SetCallbacks(omxCallback, appData, appDataLen);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::DeInit(OMX_HANDLETYPE compHandle)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->DeInit();
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::UseEglImage(OMX_HANDLETYPE compHandle, struct OmxCodecBuffer &buffer, uint32_t portIndex,
|
||||
int8_t *eglImage, uint32_t eglImageLen)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->UseEglImage(buffer, portIndex, eglImage, eglImageLen);
|
||||
}
|
||||
|
||||
int32_t ComponentNodeMgr::ComponentRoleEnum(OMX_HANDLETYPE compHandle, uint8_t *role, uint32_t roleLen, uint32_t index)
|
||||
{
|
||||
if (!compMgr_->IsLoadLibSuc()) {
|
||||
HDF_LOGE("%{public}s error loaded lib failed", __func__);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
|
||||
auto iter = nodeMaps_.find(compHandle);
|
||||
if (iter == nodeMaps_.end()) {
|
||||
HDF_LOGE("%{public}s can not find nodeInstance by component %{public}p", __func__, compHandle);
|
||||
return OMX_ErrorInvalidComponent;
|
||||
}
|
||||
return iter->second->ComponentRoleEnum(role, roleLen, index);
|
||||
}
|
||||
} // namespace Omx
|
||||
} // namespace Codec
|
||||
} // namespace OHOS
|
||||
@@ -94,7 +94,6 @@ struct CodecCallbackType {
|
||||
*
|
||||
* @param self Indicates the pointer to the callback to be invoked.
|
||||
* @param appData Indicates the pointer to the upper-layer instance passed to the callback.
|
||||
* @param appDataLen Indicates the length of <b>appData</b>, in bytes.
|
||||
* @param buffer Indicates the pointer to the input buffer {@link OmxCodecBuffer} that has data processed.
|
||||
*
|
||||
* @return Returns <b>HDF_SUCCESS</b> if the operation is successful.
|
||||
@@ -102,15 +101,13 @@ struct CodecCallbackType {
|
||||
* @return Returns <b>HDF_ERR_INVALID_OBJECT</b> if the operation failed due to invalid objects.
|
||||
* @return Returns <b>HDF_ERR_MALLOC_FAIL</b> if the operation failed due to insufficient memory.
|
||||
*/
|
||||
int32_t (*EmptyBufferDone)(struct CodecCallbackType *self, int8_t *appData,
|
||||
uint32_t appDataLen, const struct OmxCodecBuffer *buffer);
|
||||
int32_t (*EmptyBufferDone)(struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer);
|
||||
|
||||
/**
|
||||
* @brief Reports an event indicating that the output buffer is filled.
|
||||
*
|
||||
* @param self Indicates the pointer to the callback to be invoked.
|
||||
* @param appData Indicates the pointer to the upper-layer instance passed to the callback.
|
||||
* @param appDataLen Indicates the length of <b>appData</b>, in bytes.
|
||||
* @param buffer Indicates the pointer to the buffer {@link OmxCodecBuffer} that has data filled.
|
||||
*
|
||||
* @return Returns <b>HDF_SUCCESS</b> if the operation is successful.
|
||||
@@ -118,8 +115,7 @@ struct CodecCallbackType {
|
||||
* @return Returns <b>HDF_ERR_INVALID_OBJECT</b> if the operation failed due to invalid objects.
|
||||
* @return Returns <b>HDF_ERR_MALLOC_FAIL</b> if the operation failed due to insufficient memory.
|
||||
*/
|
||||
int32_t (*FillBufferDone)(struct CodecCallbackType *self, int8_t* appData,
|
||||
uint32_t appDataLen, struct OmxCodecBuffer* buffer);
|
||||
int32_t (*FillBufferDone)(struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define CODEC_COMPONENT_INTERFACE_DESC "CODEC_HDI_2.0_COMPONENT"
|
||||
|
||||
/**
|
||||
* @brief Defines the APIs for codec components.
|
||||
*
|
||||
@@ -324,15 +326,13 @@ struct CodecComponentType {
|
||||
* @param callback Indicates the pointer to the {@link CodecCallbackType} object.
|
||||
* @param appData Indicates the pointer to the value defined by the application.
|
||||
* The value is returned by the callback.
|
||||
* @param appDataLen Indicates the length of <b>appData</b>, in bytes.
|
||||
*
|
||||
* @return Returns <b>HDF_SUCCESS</b> if the operation is successful.
|
||||
* @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation failed due to invalid parameters.
|
||||
* @return Returns <b>HDF_ERR_INVALID_OBJECT</b> if the operation failed due to invalid objects.
|
||||
* @return Returns <b>HDF_ERR_MALLOC_FAIL</b> if the operation failed due to insufficient memory.
|
||||
*/
|
||||
int32_t (*SetCallbacks)(struct CodecComponentType *self, struct CodecCallbackType *callback,
|
||||
int8_t *appData, uint32_t appDataLen);
|
||||
int32_t (*SetCallbacks)(struct CodecComponentType *self, struct CodecCallbackType *callback, int64_t appData);
|
||||
|
||||
/**
|
||||
* @brief Deinitializes a component.
|
||||
@@ -387,6 +387,8 @@ struct CodecComponentType {
|
||||
* @return Returns <b>HDF_ERR_MALLOC_FAIL</b> if the operation failed due to insufficient memory.
|
||||
*/
|
||||
int32_t (*ComponentRoleEnum)(struct CodecComponentType *self, uint8_t *role, uint32_t roleLen, uint32_t index);
|
||||
|
||||
struct HdfRemoteService *(*AsObject)(struct CodecComponentType *self);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -86,10 +86,10 @@ struct CodecComponentManager {
|
||||
* You can use this API to create a codec component instance based on the component name.
|
||||
*
|
||||
* @param component Indicates the pointer to the codec component created.
|
||||
* @param componentId Indicates the id to the codec component created.
|
||||
* @param compName Indicates the name of the component to create.
|
||||
* @param appData Indicates the pointer to the value defined by the application.
|
||||
* The value is returned by the callback.
|
||||
* @param appDataSize Indicates the length of <b>appData</b>, in bytes.
|
||||
* @param callbacks Indicates the pointer to the callback defined by <b>OMX_CALLBACKTYPE</b>.
|
||||
* For details, see {@link CodecCallbackType}.
|
||||
*
|
||||
@@ -98,20 +98,22 @@ struct CodecComponentManager {
|
||||
* @return Returns <b>HDF_ERR_INVALID_OBJECT</b> if the operation failed due to invalid objects.
|
||||
* @return Returns <b>HDF_ERR_MALLOC_FAIL</b> if the operation failed due to insufficient memory.
|
||||
*/
|
||||
int32_t (*CreateComponent)(struct CodecComponentType **component, char *compName, void *appData,
|
||||
int32_t appDataSize, struct CodecCallbackType *callbacks);
|
||||
int32_t (*CreateComponent)(struct CodecComponentType **component, uint32_t *componentId, char *compName,
|
||||
int64_t appData, struct CodecCallbackType *callbacks);
|
||||
|
||||
/**
|
||||
* @brief Destroys a codec component instance.
|
||||
*
|
||||
* @param component Indicates the codec component to destroy.
|
||||
* @param componentId Indicates the codec component id to destroy.
|
||||
*
|
||||
* @return Returns <b>HDF_SUCCESS</b> if the operation is successful.
|
||||
* @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation failed due to invalid parameters.
|
||||
* @return Returns <b>HDF_ERR_INVALID_OBJECT</b> if the operation failed due to invalid objects.
|
||||
* @return Returns <b>HDF_ERR_MALLOC_FAIL</b> if the operation failed due to insufficient memory.
|
||||
*/
|
||||
int32_t (*DestoryComponent)(struct CodecComponentType *component);
|
||||
int32_t (*DestoryComponent)(uint32_t componentId);
|
||||
|
||||
struct HdfRemoteService *(*AsObject)(struct CodecComponentManager *self);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -253,8 +253,7 @@ struct CompVerInfo {
|
||||
* @brief Defines the <b>EventInfo</b>.
|
||||
*/
|
||||
struct EventInfo {
|
||||
int8_t *appData; /** The pointer to the upper-layer instance passed to the callback */
|
||||
uint32_t appDataLen; /** The length of <b>appData</b>, in bytes. */
|
||||
int64_t appData; /** The pointer to the upper-layer instance passed to the callback */
|
||||
uint32_t data1; /** Data 1 carried in the event. */
|
||||
uint32_t data2; /** Data 2 carried in the event. */
|
||||
int8_t *eventData; /** The pointer of data carried in the event. */
|
||||
|
||||
@@ -90,10 +90,10 @@ public:
|
||||
void Run();
|
||||
void Release();
|
||||
static int32_t OnEvent(struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info);
|
||||
static int32_t OnEmptyBufferDone(struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen,
|
||||
static int32_t OnEmptyBufferDone(struct CodecCallbackType *self, int64_t appData,
|
||||
const struct OmxCodecBuffer *buffer);
|
||||
static int32_t OnFillBufferDone(struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen,
|
||||
struct OmxCodecBuffer *buffer);
|
||||
static int32_t OnFillBufferDone(struct CodecCallbackType *self, int64_t appData,
|
||||
const struct OmxCodecBuffer *buffer);
|
||||
template <typename T>
|
||||
inline void InitParam(T ¶m)
|
||||
{
|
||||
@@ -117,7 +117,7 @@ private:
|
||||
int32_t UseBufferOnPort(PortIndex portIndex, int bufferCount, int bufferSize);
|
||||
int32_t UseBufferHandle(int bufferCount, int bufferSize);
|
||||
int32_t OnEmptyBufferDone(const struct OmxCodecBuffer &buffer);
|
||||
int32_t OnFillBufferDone(struct OmxCodecBuffer &buffer);
|
||||
int32_t OnFillBufferDone(const struct OmxCodecBuffer &buffer);
|
||||
int32_t CheckAndUseBufferHandle();
|
||||
int GetYuvSize();
|
||||
int32_t ConfigPortDefine();
|
||||
@@ -137,6 +137,7 @@ private:
|
||||
struct CodecComponentType *client_;
|
||||
struct CodecCallbackType *callback_;
|
||||
struct CodecComponentManager *omxMgr_;
|
||||
uint32_t compoentId_;
|
||||
std::map<int, std::shared_ptr<BufferInfo>> omxBuffers_; // key is buferid
|
||||
std::list<int> unUsedInBuffers_;
|
||||
std::list<int> unUsedOutBuffers_;
|
||||
|
||||
@@ -81,10 +81,10 @@ public:
|
||||
void Release();
|
||||
static int32_t OnEvent(struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info);
|
||||
|
||||
static int32_t OnEmptyBufferDone(struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen,
|
||||
static int32_t OnEmptyBufferDone(struct CodecCallbackType *self, int64_t appData,
|
||||
const struct OmxCodecBuffer *buffer);
|
||||
static int32_t OnFillBufferDone(struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen,
|
||||
struct OmxCodecBuffer *buffer);
|
||||
static int32_t OnFillBufferDone(struct CodecCallbackType *self, int64_t appData,
|
||||
const struct OmxCodecBuffer *buffer);
|
||||
template <typename T>
|
||||
inline void InitParam(T ¶m)
|
||||
{
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
|
||||
private:
|
||||
int32_t OnEmptyBufferDone(const struct OmxCodecBuffer &buffer);
|
||||
int32_t OnFillBufferDone(struct OmxCodecBuffer &buffer);
|
||||
int32_t OnFillBufferDone(const struct OmxCodecBuffer &buffer);
|
||||
int32_t ConfigBitMode();
|
||||
int32_t UseBufferOnPort(PortIndex portIndex, int bufferCount, int bufferSize);
|
||||
bool FillAllTheBuffer();
|
||||
@@ -129,6 +129,7 @@ private:
|
||||
struct CodecComponentType *client_;
|
||||
struct CodecCallbackType *callback_;
|
||||
struct CodecComponentManager *omxMgr_;
|
||||
uint32_t compoentId_;
|
||||
std::map<int, std::shared_ptr<BufferInfo>> omxBuffers_; // key is bufferID
|
||||
std::list<int> unUsedInBuffers_;
|
||||
std::list<int> unUsedOutBuffers_;
|
||||
|
||||
@@ -54,6 +54,7 @@ CodecHdiDecode::CodecHdiDecode() : fpIn_(nullptr), fpOut_(nullptr)
|
||||
codecMime_ = codecMime::AVC;
|
||||
count_ = 0;
|
||||
useBufferHandle_ = false;
|
||||
compoentId_ = 0;
|
||||
}
|
||||
|
||||
CodecHdiDecode::~CodecHdiDecode()
|
||||
@@ -151,9 +152,11 @@ bool CodecHdiDecode::Init(CommandOpt &opt)
|
||||
callback_->FillBufferDone = &CodecHdiDecode::OnFillBufferDone;
|
||||
int32_t err = HDF_SUCCESS;
|
||||
if (codecMime_ == codecMime::AVC) {
|
||||
err = omxMgr_->CreateComponent(&client_, const_cast<char *>(decoder_avc), 0, 0, callback_);
|
||||
err =
|
||||
omxMgr_->CreateComponent(&client_, &compoentId_, const_cast<char *>(decoder_avc), (int64_t)this, callback_);
|
||||
} else {
|
||||
err = omxMgr_->CreateComponent(&client_, const_cast<char *>(decoder_hevc), 0, 0, callback_);
|
||||
err = omxMgr_->CreateComponent(&client_, &compoentId_, const_cast<char *>(decoder_hevc), (int64_t)this,
|
||||
callback_);
|
||||
}
|
||||
|
||||
if (err != HDF_SUCCESS) {
|
||||
@@ -524,7 +527,8 @@ void CodecHdiDecode::FreeBuffers()
|
||||
|
||||
void CodecHdiDecode::Release()
|
||||
{
|
||||
omxMgr_->DestoryComponent(client_);
|
||||
omxMgr_->DestoryComponent(compoentId_);
|
||||
CodecComponentTypeRelease(client_);
|
||||
client_ = nullptr;
|
||||
CodecComponentManagerRelease();
|
||||
}
|
||||
@@ -623,9 +627,8 @@ void CodecHdiDecode::Run()
|
||||
}
|
||||
int32_t CodecHdiDecode::OnEvent(struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info)
|
||||
{
|
||||
HDF_LOGI("onEvent: appData[0x%{public}p], eEvent [%{public}d], "
|
||||
"nData1[%{public}d]",
|
||||
info->appData, event, info->data1);
|
||||
HDF_LOGI("%{public}s: appData[%{public}ld] eEvent [%{public}d], nData1[%{public}d]", __func__, info->appData, event,
|
||||
info->data1);
|
||||
switch (event) {
|
||||
case OMX_EventCmdComplete: {
|
||||
OMX_COMMANDTYPE cmd = (OMX_COMMANDTYPE)info->data1;
|
||||
@@ -643,15 +646,15 @@ int32_t CodecHdiDecode::OnEvent(struct CodecCallbackType *self, enum OMX_EVENTTY
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CodecHdiDecode::OnEmptyBufferDone(struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen,
|
||||
int32_t CodecHdiDecode::OnEmptyBufferDone(struct CodecCallbackType *self, int64_t appData,
|
||||
const struct OmxCodecBuffer *buffer)
|
||||
{
|
||||
HDF_LOGI("onEmptyBufferDone: pBuffer.bufferID [%{public}d]", buffer->bufferId);
|
||||
return g_core->OnEmptyBufferDone(*buffer);
|
||||
}
|
||||
|
||||
int32_t CodecHdiDecode::OnFillBufferDone(struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen,
|
||||
struct OmxCodecBuffer *buffer)
|
||||
int32_t CodecHdiDecode::OnFillBufferDone(struct CodecCallbackType *self, int64_t appData,
|
||||
const struct OmxCodecBuffer *buffer)
|
||||
{
|
||||
HDF_LOGI("onFillBufferDone: pBuffer.bufferID [%{public}d]", buffer->bufferId);
|
||||
return g_core->OnFillBufferDone(*buffer);
|
||||
@@ -664,7 +667,7 @@ int32_t CodecHdiDecode::OnEmptyBufferDone(const struct OmxCodecBuffer &buffer)
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CodecHdiDecode::OnFillBufferDone(struct OmxCodecBuffer &buffer)
|
||||
int32_t CodecHdiDecode::OnFillBufferDone(const struct OmxCodecBuffer &buffer)
|
||||
{
|
||||
if (exit_) {
|
||||
return HDF_SUCCESS;
|
||||
@@ -689,9 +692,6 @@ int32_t CodecHdiDecode::OnFillBufferDone(struct OmxCodecBuffer &buffer)
|
||||
}
|
||||
|
||||
(void)fflush(fpOut_);
|
||||
// reset buffer
|
||||
buffer.offset = 0;
|
||||
buffer.filledLen = 0;
|
||||
if (buffer.flag == OMX_BUFFERFLAG_EOS) {
|
||||
// end
|
||||
exit_ = true;
|
||||
|
||||
@@ -46,6 +46,7 @@ CodecHdiEncode::CodecHdiEncode() : fpIn_(nullptr), fpOut_(nullptr)
|
||||
useBufferHandle_ = false;
|
||||
width_ = 0;
|
||||
height_ = 0;
|
||||
compoentId_ = 0;
|
||||
}
|
||||
|
||||
CodecHdiEncode::~CodecHdiEncode()
|
||||
@@ -111,7 +112,8 @@ bool CodecHdiEncode::Init(CommandOpt &opt)
|
||||
callback_->FillBufferDone = &CodecHdiEncode::OnFillBufferDone;
|
||||
|
||||
// create a component
|
||||
auto err = omxMgr_->CreateComponent(&client_, const_cast<char *>(encoder_avc), 0, 0, callback_);
|
||||
auto err =
|
||||
omxMgr_->CreateComponent(&client_, &compoentId_, const_cast<char *>(encoder_avc), (int64_t)this, callback_);
|
||||
if (err != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s failed to CreateComponent", __func__);
|
||||
return false;
|
||||
@@ -422,9 +424,9 @@ void CodecHdiEncode::FreeBuffers()
|
||||
|
||||
void CodecHdiEncode::Release()
|
||||
{
|
||||
omxMgr_->DestoryComponent(client_);
|
||||
|
||||
// DestoryComponent has released client_ and omx component calls DeInit
|
||||
omxMgr_->DestoryComponent(compoentId_);
|
||||
CodecComponentTypeRelease(client_);
|
||||
client_ = nullptr;
|
||||
CodecComponentManagerRelease();
|
||||
}
|
||||
|
||||
@@ -565,7 +567,7 @@ int32_t CodecHdiEncode::createBufferHandle()
|
||||
|
||||
int32_t CodecHdiEncode::OnEvent(struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info)
|
||||
{
|
||||
HDF_LOGI("OnEvent: pAppData[0x%{public}p], eEvent [%{public}d], "
|
||||
HDF_LOGI("OnEvent: pAppData[%{public}ld], eEvent [%{public}d], "
|
||||
"nData1[%{public}d]",
|
||||
info->appData, event, info->data1);
|
||||
switch (event) {
|
||||
@@ -585,15 +587,15 @@ int32_t CodecHdiEncode::OnEvent(struct CodecCallbackType *self, enum OMX_EVENTTY
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CodecHdiEncode::OnEmptyBufferDone(struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen,
|
||||
int32_t CodecHdiEncode::OnEmptyBufferDone(struct CodecCallbackType *self, int64_t appData,
|
||||
const struct OmxCodecBuffer *buffer)
|
||||
{
|
||||
HDF_LOGI("OnEmptyBufferDone: pBuffer.bufferID [%{public}d]", buffer->bufferId);
|
||||
return g_core->OnEmptyBufferDone(*buffer);
|
||||
}
|
||||
|
||||
int32_t CodecHdiEncode::OnFillBufferDone(struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen,
|
||||
struct OmxCodecBuffer *buffer)
|
||||
int32_t CodecHdiEncode::OnFillBufferDone(struct CodecCallbackType *self, int64_t appData,
|
||||
const struct OmxCodecBuffer *buffer)
|
||||
{
|
||||
HDF_LOGI("OnFillBufferDone: pBuffer.bufferID [%{public}d]", buffer->bufferId);
|
||||
return g_core->OnFillBufferDone(*buffer);
|
||||
@@ -611,7 +613,7 @@ int32_t CodecHdiEncode::OnEmptyBufferDone(const struct OmxCodecBuffer &buffer)
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CodecHdiEncode::OnFillBufferDone(struct OmxCodecBuffer &buffer)
|
||||
int32_t CodecHdiEncode::OnFillBufferDone(const struct OmxCodecBuffer &buffer)
|
||||
{
|
||||
if (exit_) {
|
||||
return HDF_SUCCESS;
|
||||
@@ -627,8 +629,7 @@ int32_t CodecHdiEncode::OnFillBufferDone(struct OmxCodecBuffer &buffer)
|
||||
// save to file
|
||||
(void)fwrite(addr, 1, buffer.filledLen, fpOut_);
|
||||
(void)fflush(fpOut_);
|
||||
buffer.offset = 0;
|
||||
buffer.filledLen = 0;
|
||||
|
||||
if (buffer.flag == OMX_BUFFERFLAG_EOS) {
|
||||
exit_ = true;
|
||||
HDF_LOGI("OnFillBufferDone the END coming");
|
||||
|
||||
@@ -61,14 +61,14 @@ namespace Codec {
|
||||
struct CodecComponentType *component = nullptr;
|
||||
int32_t appData = testingAppData;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)"compName", &appData, sizeof(appData), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)"compName", appData, callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: CreateComponent failed\n", __func__);
|
||||
return false;
|
||||
@@ -89,11 +89,12 @@ namespace Codec {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -31,14 +31,14 @@ namespace Codec {
|
||||
struct CodecComponentType *component = nullptr;
|
||||
int32_t appData = testingAppData;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)"compName", &appData, sizeof(appData), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)"compName", appData, callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: CreateComponent failed\n", __func__);
|
||||
return false;
|
||||
@@ -51,11 +51,12 @@ namespace Codec {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
|
||||
return result;
|
||||
|
||||
+4
-3
@@ -31,14 +31,14 @@ namespace Codec {
|
||||
struct CodecComponentType *component = nullptr;
|
||||
int32_t appData = testingAppData;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)"compName", &appData, sizeof(appData), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)"compName", appData, callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: CreateComponent failed\n", __func__);
|
||||
return false;
|
||||
@@ -58,11 +58,12 @@ namespace Codec {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -29,25 +29,25 @@ namespace Codec {
|
||||
struct CodecComponentManager *manager = nullptr;
|
||||
struct CodecComponentType *component = nullptr;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)data, (void *)data,
|
||||
sizeof(*(int32_t *)data), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)data, (int64_t)data, callback);
|
||||
if (ret == HDF_SUCCESS) {
|
||||
HDF_LOGI("%{public}s: CreateComponent succeed\n", __func__);
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -61,14 +61,14 @@ namespace Codec {
|
||||
struct CodecComponentType *component = nullptr;
|
||||
int32_t appData = testingAppData;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)"compName", &appData, sizeof(appData), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)"compName", appData, callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: CreateComponent failed\n", __func__);
|
||||
return false;
|
||||
@@ -88,11 +88,12 @@ namespace Codec {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -31,14 +31,14 @@ namespace Codec {
|
||||
struct CodecComponentType *component = nullptr;
|
||||
int32_t appData = testingAppData;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)"compName", &appData, sizeof(appData), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)"compName", appData, callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: CreateComponent failed\n", __func__);
|
||||
return false;
|
||||
@@ -50,11 +50,12 @@ namespace Codec {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -31,14 +31,14 @@ namespace Codec {
|
||||
struct CodecComponentType *component = nullptr;
|
||||
int32_t appData = testingAppData;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)"compName", &appData, sizeof(appData), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)"compName", appData, callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: CreateComponent failed\n", __func__);
|
||||
return false;
|
||||
@@ -50,11 +50,12 @@ namespace Codec {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -31,14 +31,14 @@ namespace Codec {
|
||||
struct CodecComponentType *component = nullptr;
|
||||
int32_t appData = testingAppData;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)"compName", &appData, sizeof(appData), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)"compName", appData, callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: CreateComponent failed\n", __func__);
|
||||
return false;
|
||||
@@ -57,11 +57,12 @@ namespace Codec {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -30,14 +30,14 @@ namespace Codec {
|
||||
struct CodecComponentType *component = nullptr;
|
||||
int32_t appData = testingAppData;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)"compName", &appData, sizeof(appData), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)"compName", appData, callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: CreateComponent failed\n", __func__);
|
||||
return false;
|
||||
@@ -50,11 +50,12 @@ namespace Codec {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -31,14 +31,14 @@ namespace Codec {
|
||||
struct CodecComponentType *component = nullptr;
|
||||
int32_t appData = testingAppData;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)"compName", &appData, sizeof(appData), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)"compName", appData, callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: CreateComponent failed\n", __func__);
|
||||
return false;
|
||||
@@ -51,17 +51,18 @@ namespace Codec {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = component->SetCallbacks(component, callback, (int8_t *)data, sizeof(*data)*size);
|
||||
ret = component->SetCallbacks(component, callback, (int64_t)data);
|
||||
if (ret == HDF_SUCCESS) {
|
||||
HDF_LOGI("%{public}s: SetCallbacks succeed\n", __func__);
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -31,14 +31,14 @@ namespace Codec {
|
||||
struct CodecComponentType *component = nullptr;
|
||||
int32_t appData = testingAppData;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)"compName", &appData, sizeof(appData), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)"compName", appData, callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: CreateComponent failed\n", __func__);
|
||||
return false;
|
||||
@@ -50,11 +50,12 @@ namespace Codec {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -31,14 +31,14 @@ namespace Codec {
|
||||
struct CodecComponentType *component = nullptr;
|
||||
int32_t appData = testingAppData;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)"compName", &appData, sizeof(appData), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)"compName", appData, callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: CreateComponent failed\n", __func__);
|
||||
return false;
|
||||
@@ -57,11 +57,12 @@ namespace Codec {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -61,14 +61,14 @@ namespace Codec {
|
||||
struct CodecComponentType *component = nullptr;
|
||||
int32_t appData = testingAppData;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)"compName", &appData, sizeof(appData), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)"compName", appData, callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: CreateComponent failed\n", __func__);
|
||||
return false;
|
||||
@@ -88,11 +88,12 @@ namespace Codec {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -61,14 +61,14 @@ namespace Codec {
|
||||
struct CodecComponentType *component = nullptr;
|
||||
int32_t appData = testingAppData;
|
||||
CodecCallbackType* callback = CodecCallbackTypeStubGetInstance();
|
||||
|
||||
uint32_t compoentId = 0;
|
||||
manager = GetCodecComponentManager();
|
||||
if (manager == nullptr) {
|
||||
HDF_LOGE("%{public}s: GetCodecComponentManager failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = manager->CreateComponent(&component, (char*)"compName", &appData, sizeof(appData), callback);
|
||||
int32_t ret = manager->CreateComponent(&component, &compoentId, (char*)"compName", appData, callback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: CreateComponent failed\n", __func__);
|
||||
return false;
|
||||
@@ -88,11 +88,12 @@ namespace Codec {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = manager->DestoryComponent(component);
|
||||
ret = manager->DestoryComponent(compoentId);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%{public}s: DestoryComponent failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
CodecComponentTypeRelease(component);
|
||||
CodecComponentManagerRelease();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -39,11 +39,13 @@ using namespace testing::ext;
|
||||
namespace {
|
||||
struct CodecComponentManager *g_manager = nullptr;
|
||||
struct CodecComponentType *g_component = nullptr;
|
||||
uint32_t g_compoentId = 0;
|
||||
struct CodecCallbackType *g_callback = nullptr;
|
||||
int32_t g_count = 0;
|
||||
|
||||
#ifdef RK
|
||||
#define COMPONENT_NAME "OMX.rk.video_encoder.avc"
|
||||
#define COMPONENT_NAME "OMX.rk.video_encoder.avc"
|
||||
#define COMPOENT_DECODER_NAME "OMX.rk.video_decoder.avc"
|
||||
#endif
|
||||
|
||||
constexpr int32_t INT_TO_STR_LEN = 32;
|
||||
@@ -57,6 +59,7 @@ constexpr int32_t BUFFER_SIZE = 640 * 480 * 3;
|
||||
constexpr int32_t ROLE_LEN = 240;
|
||||
constexpr int32_t FRAMERATE = 30 << 16;
|
||||
constexpr uint32_t BUFFER_ID_ERROR = 65000;
|
||||
constexpr int64_t APP_DATA = 64;
|
||||
enum class PortIndex { PORT_INDEX_INPUT = 0, PORT_INDEX_OUTPUT = 1 };
|
||||
|
||||
template <typename T>
|
||||
@@ -285,7 +288,7 @@ HWTEST_F(CodecHdiOmxTest, HdfCodecHdiCreateComponentTest_001, TestSize.Level1)
|
||||
ASSERT_TRUE(g_manager != nullptr);
|
||||
ASSERT_TRUE(g_callback != nullptr);
|
||||
char name[] = "test";
|
||||
int32_t ret = g_manager->CreateComponent(&g_component, (char *)name, nullptr, 0, g_callback);
|
||||
int32_t ret = g_manager->CreateComponent(&g_component, &g_compoentId, (char *)name, APP_DATA, g_callback);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
ASSERT_TRUE(g_component == nullptr);
|
||||
}
|
||||
@@ -294,7 +297,7 @@ HWTEST_F(CodecHdiOmxTest, HdfCodecHdiCreateComponentTest_002, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(g_manager != nullptr);
|
||||
ASSERT_TRUE(g_callback != nullptr);
|
||||
int32_t ret = g_manager->CreateComponent(&g_component, nullptr, nullptr, 0, g_callback);
|
||||
int32_t ret = g_manager->CreateComponent(&g_component, &g_compoentId, nullptr, APP_DATA, g_callback);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
ASSERT_TRUE(g_component == nullptr);
|
||||
}
|
||||
@@ -302,16 +305,33 @@ HWTEST_F(CodecHdiOmxTest, HdfCodecHdiCreateComponentTest_002, TestSize.Level1)
|
||||
#ifdef COMPONENT_NAME
|
||||
HWTEST_F(CodecHdiOmxTest, HdfCodecHdiCreateComponentTest_003, TestSize.Level1)
|
||||
{
|
||||
const int32_t testingAppData = 33;
|
||||
ASSERT_TRUE(g_manager != nullptr);
|
||||
ASSERT_TRUE(g_callback != nullptr);
|
||||
int32_t appData = testingAppData;
|
||||
int32_t ret = g_manager->CreateComponent(&g_component, const_cast<char *>(COMPONENT_NAME), &appData,
|
||||
sizeof(appData), g_callback);
|
||||
int32_t ret = g_manager->CreateComponent(&g_component, &g_compoentId, const_cast<char *>(COMPONENT_NAME), APP_DATA,
|
||||
g_callback);
|
||||
ASSERT_EQ(ret, HDF_SUCCESS);
|
||||
ASSERT_TRUE(g_component != nullptr);
|
||||
}
|
||||
|
||||
HWTEST_F(CodecHdiOmxTest, HdfCodecHdiCreateComponentTest_004, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(g_manager != nullptr);
|
||||
struct CodecCallbackType *callback = CodecCallbackTypeStubGetInstance();
|
||||
ASSERT_TRUE(callback != nullptr);
|
||||
struct CodecComponentType *component = nullptr;
|
||||
uint32_t compoentId = 0;
|
||||
int32_t ret = g_manager->CreateComponent(&component, &compoentId, const_cast<char *>(COMPOENT_DECODER_NAME),
|
||||
APP_DATA, callback);
|
||||
ASSERT_EQ(ret, HDF_SUCCESS);
|
||||
ASSERT_TRUE(component != nullptr);
|
||||
ret = g_manager->DestoryComponent(compoentId);
|
||||
ASSERT_EQ(ret, HDF_SUCCESS);
|
||||
CodecComponentTypeRelease(component);
|
||||
component = nullptr;
|
||||
CodecCallbackTypeStubRelease(callback);
|
||||
callback = nullptr;
|
||||
}
|
||||
|
||||
// Test GetComponentVersion
|
||||
HWTEST_F(CodecHdiOmxTest, HdfCodecHdiGetVersionTest_001, TestSize.Level1)
|
||||
{
|
||||
@@ -966,17 +986,12 @@ HWTEST_F(CodecHdiOmxTest, HdfCodecHdiEmptyThisBufferTest_002, TestSize.Level1)
|
||||
HWTEST_F(CodecHdiOmxTest, HdfCodecHdiSetCallbackTest_001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(g_component != nullptr);
|
||||
const int32_t appDataLen = 10;
|
||||
if (g_callback != nullptr) {
|
||||
CodecCallbackTypeStubRelease(g_callback);
|
||||
}
|
||||
g_callback = CodecCallbackTypeStubGetInstance();
|
||||
ASSERT_TRUE(g_callback != nullptr);
|
||||
int8_t appData[appDataLen];
|
||||
for (int8_t i = 0; i < appDataLen; i++) {
|
||||
appData[i] = i;
|
||||
}
|
||||
int32_t ret = g_component->SetCallbacks(g_component, g_callback, appData, (uint32_t)appDataLen);
|
||||
int32_t ret = g_component->SetCallbacks(g_component, g_callback, APP_DATA);
|
||||
ASSERT_EQ(ret, HDF_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1076,8 +1091,9 @@ HWTEST_F(CodecHdiOmxTest, HdfCodecHdiDestoryComponentTest_001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(g_component != nullptr);
|
||||
ASSERT_TRUE(g_manager != nullptr);
|
||||
int ret = g_manager->DestoryComponent(g_component);
|
||||
int ret = g_manager->DestoryComponent(g_compoentId);
|
||||
ASSERT_EQ(ret, HDF_SUCCESS);
|
||||
CodecComponentTypeRelease(g_component);
|
||||
g_component = nullptr;
|
||||
}
|
||||
#endif // COMPONENT_NAME
|
||||
|
||||
Reference in New Issue
Block a user