mirror of
https://github.com/openharmony/drivers_peripheral.git
synced 2026-08-25 02:23:31 -04:00
3affbef335
Signed-off-by: qijinquan <qijinquan@kaihongdigi.com>
117 lines
4.1 KiB
C++
117 lines
4.1 KiB
C++
/*
|
|
* 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_H
|
|
#define COMPONENT_NODE_H
|
|
#include <OMX_Component.h>
|
|
#include <OMX_Core.h>
|
|
#include <OMX_Types.h>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <nocopyable.h>
|
|
#include <osal_mem.h>
|
|
|
|
#include "icodec_buffer.h"
|
|
#include "codec_callback_if.h"
|
|
#include "codec_component_type.h"
|
|
|
|
namespace OHOS {
|
|
namespace Codec {
|
|
namespace Omx {
|
|
class ComponentNode : NoCopyable {
|
|
public:
|
|
ComponentNode(struct CodecCallbackType *callback, int64_t appData);
|
|
|
|
~ComponentNode();
|
|
|
|
int32_t GetComponentVersion(struct CompVerInfo &verInfo);
|
|
|
|
int32_t SendCommand(OMX_COMMANDTYPE cmd, uint32_t param, int8_t *cmdData, uint32_t cmdDataLen);
|
|
|
|
int32_t GetParameter(OMX_INDEXTYPE paramIndex, int8_t *param, uint32_t paramLen);
|
|
|
|
int32_t SetParameter(OMX_INDEXTYPE paramIndex, int8_t *param, uint32_t paramLen);
|
|
|
|
int32_t GetConfig(OMX_INDEXTYPE index, int8_t *config, uint32_t configLen);
|
|
|
|
int32_t SetConfig(OMX_INDEXTYPE index, int8_t *config, uint32_t configLen);
|
|
|
|
int32_t GetExtensionIndex(const char *parameterName, OMX_INDEXTYPE *indexType);
|
|
|
|
int32_t GetState(OMX_STATETYPE *state);
|
|
|
|
int32_t ComponentTunnelRequest(uint32_t port, int32_t omxHandleTypeTunneledComp, uint32_t tunneledPort,
|
|
struct OMX_TUNNELSETUPTYPE *tunnelSetup);
|
|
|
|
int32_t UseBuffer(uint32_t portIndex, struct OmxCodecBuffer &buffer);
|
|
|
|
int32_t AllocateBuffer(uint32_t portIndex, struct OmxCodecBuffer &buffer);
|
|
|
|
int32_t FreeBuffer(uint32_t portIndex, struct OmxCodecBuffer &buffer);
|
|
|
|
int32_t EmptyThisBuffer(struct OmxCodecBuffer &buffer);
|
|
|
|
int32_t FillThisBuffer(struct OmxCodecBuffer &buffer);
|
|
|
|
int32_t SetCallbacks(struct CodecCallbackType *omxCallback, int64_t appData);
|
|
|
|
int32_t UseEglImage(struct OmxCodecBuffer &buffer, uint32_t portIndex, int8_t *eglImage, uint32_t eglImageLen);
|
|
|
|
int32_t ComponentRoleEnum(uint8_t *role, uint32_t roleLen, uint32_t index);
|
|
|
|
int32_t DeInit();
|
|
|
|
OMX_ERRORTYPE static OnEvent(OMX_HANDLETYPE component, void *appData, OMX_EVENTTYPE event, uint32_t data1,
|
|
uint32_t data2, void *eventData);
|
|
|
|
OMX_ERRORTYPE static OnEmptyBufferDone(OMX_HANDLETYPE component, void *appData, OMX_BUFFERHEADERTYPE *buffer);
|
|
|
|
OMX_ERRORTYPE static OnFillBufferDone(OMX_HANDLETYPE component, void *appData, OMX_BUFFERHEADERTYPE *buffer);
|
|
|
|
void SetHandle(OMX_HANDLETYPE comp)
|
|
{
|
|
this->comp_ = comp;
|
|
}
|
|
|
|
OMX_HANDLETYPE GetHandle()
|
|
{
|
|
return comp_;
|
|
}
|
|
|
|
public:
|
|
static OMX_CALLBACKTYPE callbacks_; // callbacks
|
|
|
|
private:
|
|
int32_t OnEvent(OMX_EVENTTYPE event, uint32_t data1, uint32_t data2, void *eventData);
|
|
|
|
int32_t OnEmptyBufferDone(OMX_BUFFERHEADERTYPE *buffer);
|
|
|
|
int32_t OnFillBufferDone(OMX_BUFFERHEADERTYPE *buffer);
|
|
|
|
uint32_t GenerateBufferId();
|
|
sptr<ICodecBuffer> GetBufferInfoByHeader(OMX_BUFFERHEADERTYPE *buffer);
|
|
bool GetBufferById(uint32_t bufferId, sptr<ICodecBuffer> &codecBuffer, OMX_BUFFERHEADERTYPE *&bufferHdrType);
|
|
|
|
private:
|
|
OMX_HANDLETYPE comp_; // Component handle
|
|
struct CodecCallbackType *omxCallback_; // Callbacks in HDI
|
|
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_;
|
|
};
|
|
} // namespace Omx
|
|
} // namespace Codec
|
|
} // namespace OHOS
|
|
#endif /* COMPONENT_NODE_H */ |