1 /*
2  * Copyright (c) 2022-2023 Shenzhen Kaihong DID Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * 		http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef CODEC_OMX_ADAPTER_INTERFACE_H
17 #define CODEC_OMX_ADAPTER_INTERFACE_H
18 #include "codec_callback_if.h"
19 #include "codec_types.h"
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 struct CodecComponentNode;
25 /**
26  * @brief Create a component by name.
27  */
28 int32_t OMXAdapterCreateComponent(struct CodecComponentNode **codecNode, char *compName, int64_t appData,
29                                   struct CodecCallbackType *callbacks);
30 /**
31  * @brief Release the component by handle.
32  */
33 int32_t OmxAdapterDestroyComponent(struct CodecComponentNode *codecNode);
34 /**
35  * @brief Get the version of the component.
36  */
37 int32_t OmxAdapterComponentVersion(struct CodecComponentNode *codecNode, struct CompVerInfo *verInfo);
38 /**
39  * @brief Send command to the component.
40  */
41 int32_t OmxAdapterSendCommand(struct CodecComponentNode *codecNode, OMX_COMMANDTYPE cmd, uint32_t param,
42                               int8_t *cmdData, uint32_t cmdDataLen);
43 /**
44  * @brief Get the parameter by index.
45  */
46 int32_t OmxAdapterGetParameter(struct CodecComponentNode *codecNode, OMX_INDEXTYPE paramIndex, int8_t *param,
47                                uint32_t paramLen);
48 /**
49  * @brief Set the parameter by index.
50  */
51 int32_t OmxAdapterSetParameter(struct CodecComponentNode *codecNode, OMX_INDEXTYPE index, int8_t *param,
52                                uint32_t paramLen);
53 /**
54  * @brief Get the config by index.
55  *
56  * This func can be invoked when the component is in any state except the OMX_StateInvalid state.
57  */
58 int32_t OmxAdapterGetConfig(struct CodecComponentNode *codecNode, OMX_INDEXTYPE index, int8_t *config,
59                             uint32_t configLen);
60 int32_t OmxAdapterSetConfig(struct CodecComponentNode *codecNode, OMX_INDEXTYPE index, int8_t *config,
61                             uint32_t configLen);
62 int32_t OmxAdapterGetExtensionIndex(struct CodecComponentNode *codecNode, const char *parameterName,
63                                     OMX_INDEXTYPE *indexType);
64 int32_t OmxAdapterGetState(struct CodecComponentNode *codecNode, OMX_STATETYPE *state);
65 /**
66  * @brief Set up tunneled communication between an output port and an input port.
67  */
68 int32_t OmxAdapterComponentTunnelRequest(struct CodecComponentNode *codecNode, uint32_t port,
69                                          int32_t omxHandleTypeTunneledComp, uint32_t tunneledPort,
70                                          struct OMX_TUNNELSETUPTYPE *tunnelSetup);
71 /**
72  * @brief The component uses a buffer already allocated by the IL client.
73  */
74 int32_t OmxAdapterUseBuffer(struct CodecComponentNode *codecNode, uint32_t portIndex,
75                             struct OmxCodecBuffer *omxBuffer);
76 /**
77  * @brief The component allocate a buffer.
78  */
79 int32_t OmxAdapterAllocateBuffer(struct CodecComponentNode *codecNode, uint32_t portIndex,
80                                  struct OmxCodecBuffer *omxBuffer);
81 /**
82  * @brief The component free the buffer.
83  */
84 int32_t OmxAdapterFreeBuffer(struct CodecComponentNode *codecNode, uint32_t portIndex,
85                              struct OmxCodecBuffer *omxBuffer);
86 /**
87  * @brief Send a filled buffer to the input port of the component.
88  */
89 int32_t OmxAdapterEmptyThisBuffer(struct CodecComponentNode *codecNode, struct OmxCodecBuffer *omxBuffer);
90 /**
91  * @brief Send a empty buffer to the output port of the component.
92  */
93 int32_t OmxAdapterFillThisBuffer(struct CodecComponentNode *codecNode, struct OmxCodecBuffer *omxBuffer);
94 /**
95  * @brief Set the callback.
96  */
97 int32_t OmxAdapterSetCallbacks(struct CodecComponentNode *codecNode, struct CodecCallbackType *omxCallback,
98                                int64_t appData);
99 /**
100  * @brief DeInit the component.
101  */
102 int32_t OmxAdapterDeInit(struct CodecComponentNode *codecNode);
103 /**
104  * @brief The component use the buffer allocated in EGL.
105  */
106 int32_t OmxAdapterUseEglImage(struct CodecComponentNode *codecNode, struct OmxCodecBuffer *buffer,
107                               uint32_t portIndex, int8_t *eglImage, uint32_t eglImageLen);
108 /**
109  * @brief Get the role of the component.
110  */
111 int32_t OmxAdapterComponentRoleEnum(struct CodecComponentNode *codecNode, uint8_t *role, uint32_t roleLen,
112                                     uint32_t index);
113 /**
114  * @brief Set the role for the component.
115  */
116 int32_t OmxAdapterSetComponentRole(struct CodecComponentNode *codecNode, char *compName);
117 /**
118  * @brief build hidumper reply.
119  */
120 int32_t OmxAdapterWriteDumperData(char *info, uint32_t size, uint32_t compId, struct CodecComponentNode *codecNode);
121 #ifdef __cplusplus
122 };
123 #endif
124 
125 #endif  // CODEC_OMX_ADAPTER_INTERFACE_H