• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef COMPONENT_NODE_H
16 #define COMPONENT_NODE_H
17 #include <nocopyable.h>
18 #include <OMX_Component.h>
19 #include "codec_callback_if.h"
20 #include "codec_capability_parser.h"
21 #include "codec_component_type.h"
22 #include "codec_type.h"
23 
24 namespace OHOS {
25 namespace Codec {
26 namespace CodecAdapter {
27 class ComponentNode : public NoCopyable {
28 public:
29     explicit ComponentNode(CODEC_HANDLETYPE handle, CodecExInfo info);
~ComponentNode()30     ~ComponentNode() {}
31     int32_t GetComponentVersion(CompVerInfo &verInfo);
32     int32_t SendCommand(OMX_COMMANDTYPE cmd, uint32_t param, int8_t *cmdData, uint32_t cmdDataLen);
33     int32_t GetParameter(OMX_INDEXTYPE paramIndex, int8_t *param, uint32_t paramLen);
34     int32_t SetParameter(OMX_INDEXTYPE paramIndex, const int8_t *param, uint32_t paramLen);
35     int32_t GetConfig(OMX_INDEXTYPE index, int8_t *config, uint32_t configLen);
36     int32_t SetConfig(OMX_INDEXTYPE index, const int8_t *config, uint32_t configLen);
37     int32_t GetExtensionIndex(const char *parameterName, OMX_INDEXTYPE *indexType);
38     int32_t GetState(OMX_STATETYPE *state);
39     int32_t ComponentTunnelRequest(
40         uint32_t port, int32_t omxHandleTypeTunneledComp, uint32_t tunneledPort, OMX_TUNNELSETUPTYPE *tunnelSetup);
41     int32_t UseBuffer(uint32_t portIndex, OmxCodecBuffer &buffer);
42     int32_t AllocateBuffer(uint32_t portIndex, OmxCodecBuffer &buffer);
43     int32_t FreeBuffer(uint32_t portIndex, const OmxCodecBuffer &buffer);
44     int32_t EmptyThisBuffer(const OmxCodecBuffer &buffer);
45     int32_t FillThisBuffer(const OmxCodecBuffer &buffer);
46     int32_t SetCallbacks(const CodecCallbackType *omxCallback, int64_t appData);
47     int32_t UseEglImage(OmxCodecBuffer &buffer, uint32_t portIndex, int8_t *eglImage, uint32_t eglImageLen);
48     int32_t ComponentRoleEnum(uint8_t *role, uint32_t roleLen, uint32_t index);
49     int32_t ComponentDeInit();
50     int32_t static OnEvent(UINTPTR userData, EventType event, uint32_t length, int32_t eventData[]);
51     int32_t static InputBufferAvailable(UINTPTR userData, CodecBuffer *inBuf, int32_t *acquireFd);
52     int32_t static OutputBufferAvailable(UINTPTR userData, CodecBuffer *outBuf, int32_t *acquireFd);
53     int32_t SetState(OMX_STATETYPE state);
GetHandle()54     CODEC_HANDLETYPE GetHandle()
55     {
56         return comp_;
57     }
58 
59 public:
60     static CodecCallback callbacks_;
61 
62 private:
63     int32_t SetPortMode(uint32_t portIndex, OmxCodecBuffer &buffer, AllocateBufferMode mode);
64     int32_t ChangeComponentState(uint32_t param);
65     int32_t FlushComponent(uint32_t param);
66     int32_t OnEvent(EventType event, uint32_t length, int32_t eventData[]);
67     int32_t OnEmptyBufferDone(CodecBuffer *inBuf, int32_t *acquireFd);
68     int32_t OnFillBufferDone(CodecBuffer *outBuf, int32_t *acquireFd);
69 
70 private:
71     CODEC_HANDLETYPE comp_;          // Compnent handle
72     CodecCallbackType *omxCallback_; // Callbacks in HDI
73     CodecExInfo exInfo_;
74     int64_t appData_;
75     uint32_t bufferId_;
76     bool setCallbackComplete_;
77     OMX_STATETYPE state_;
78     CodecType codecType_;
79     AllocateBufferMode inputMode_;
80     AllocateBufferMode outputMode_;
81 };
82 }  // namespace CodecAdapter
83 }  // namespace Codec
84 }  // namespace OHOS
85 #endif /* COMPONENT_NODE_H */
86