-
Notifications
You must be signed in to change notification settings - Fork 1
/
omx.c
248 lines (192 loc) · 6.79 KB
/
omx.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#include "omx.h"
#include "logerr.h"
#include "dump.h"
/*****************************************************************************/
enum error_code omx_init(void)
{
OMX_ERRORTYPE result_omx = OMX_Init();
if(result_omx != OMX_ErrorNone)
{
LOG_ERROR("OMX_Init: (%s)", dump_OMX_ERRORTYPE (result_omx));
return ERROR;
}
return OK;
}
/*****************************************************************************/
enum error_code omx_deinit(void)
{
OMX_ERRORTYPE result_omx = OMX_Deinit();
if(result_omx != OMX_ErrorNone)
{
LOG_ERROR("OMX_Deinit: (%s)", dump_OMX_ERRORTYPE (result_omx));
return ERROR;
}
return OK;
}
/*****************************************************************************/
enum error_code
omx_get_handle(
OMX_OUT OMX_HANDLETYPE *pHandle,
OMX_IN OMX_STRING cComponentName,
OMX_IN OMX_PTR pAppData,
OMX_IN OMX_CALLBACKTYPE *pCallBacks)
{
OMX_ERRORTYPE result_omx = OMX_GetHandle(pHandle, cComponentName, pAppData, pCallBacks);
if(result_omx != OMX_ErrorNone)
{
LOG_ERROR("OMX_GetHandle: %s (%s)", cComponentName, dump_OMX_ERRORTYPE (result_omx));
return ERROR;
}
return OK;
}
/*****************************************************************************/
enum error_code
omx_free_handle(
OMX_IN OMX_HANDLETYPE hComponent)
{
OMX_ERRORTYPE result_omx = OMX_FreeHandle(hComponent);
if(result_omx != OMX_ErrorNone)
{
LOG_ERROR("OMX_FreeHandle: (%s)", dump_OMX_ERRORTYPE (result_omx));
return ERROR;
}
return OK;
}
/*****************************************************************************/
enum error_code
omx_set_config(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentConfigStructure)
{
OMX_ERRORTYPE result_omx = OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure);
if(result_omx != OMX_ErrorNone)
{
LOG_ERROR("OMX_SetConfig: %s(%8X) (%s)", dump_OMX_INDEXTYPE(nIndex), nIndex, dump_OMX_ERRORTYPE (result_omx));
return ERROR;
}
return OK;
}
/*****************************************************************************/
enum error_code
omx_send_command(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_COMMANDTYPE Cmd,
OMX_IN OMX_U32 nParam1,
OMX_IN OMX_PTR pCmdData)
{
OMX_ERRORTYPE result_omx = OMX_SendCommand(hComponent, Cmd, nParam1, pCmdData);
if(result_omx != OMX_ErrorNone)
{
LOG_ERROR("OMX_SendCommand: (%s)", dump_OMX_ERRORTYPE (result_omx));
return ERROR;
}
return OK;
}
/*****************************************************************************/
enum error_code
omx_get_parameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_INOUT OMX_PTR pComponentParameterStructure)
{
OMX_ERRORTYPE result_omx = OMX_GetParameter(hComponent, nParamIndex, pComponentParameterStructure);
if(result_omx != OMX_ErrorNone)
{
LOG_ERROR("OMX_GetParameter: %s(%8X) (%s)", dump_OMX_INDEXTYPE(nParamIndex), nParamIndex, dump_OMX_ERRORTYPE(result_omx));
return ERROR;
}
return OK;
}
/*****************************************************************************/
enum error_code
omx_set_parameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_IN OMX_PTR pComponentParameterStructure)
{
OMX_ERRORTYPE result_omx = OMX_SetParameter(hComponent, nParamIndex, pComponentParameterStructure);
if(result_omx != OMX_ErrorNone)
{
LOG_ERROR("OMX_SetParameter: %s(%8X) (%s)", dump_OMX_INDEXTYPE(nParamIndex), nParamIndex, dump_OMX_ERRORTYPE(result_omx));
return ERROR;
}
return OK;
}
/*****************************************************************************/
enum error_code
omx_allocate_buffer(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer,
OMX_IN OMX_U32 nPortIndex,
OMX_IN OMX_PTR pAppPrivate,
OMX_IN OMX_U32 nSizeBytes)
{
OMX_ERRORTYPE result_omx = OMX_AllocateBuffer(hComponent, ppBuffer, nPortIndex, pAppPrivate, nSizeBytes);
if(result_omx != OMX_ErrorNone)
{
LOG_ERROR("OMX_AllocateBuffer: port %d %d (%s)", nPortIndex, nSizeBytes, dump_OMX_ERRORTYPE(result_omx));
return ERROR;
}
return OK;
}
/*****************************************************************************/
enum error_code
omx_free_buffer(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_U32 nPortIndex,
OMX_IN OMX_BUFFERHEADERTYPE *pBuffer)
{
OMX_ERRORTYPE result_omx = OMX_FreeBuffer(hComponent, nPortIndex, pBuffer);
if(result_omx != OMX_ErrorNone)
{
LOG_ERROR("OMX_FreeBuffer: port %d (%s)", nPortIndex, dump_OMX_ERRORTYPE(result_omx));
return ERROR;
}
return OK;
}
/*****************************************************************************/
enum error_code
omx_fill_this_buffer(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_BUFFERHEADERTYPE *pBuffer)
{
OMX_ERRORTYPE result_omx = OMX_FillThisBuffer(hComponent, pBuffer);
if(result_omx != OMX_ErrorNone)
{
LOG_ERROR("OMX_FillThisBuffer: (%s)", dump_OMX_ERRORTYPE (result_omx));
return ERROR;
}
return OK;
}
/*****************************************************************************/
enum error_code
omx_setup_tunnel(
OMX_IN OMX_HANDLETYPE hOutput,
OMX_IN OMX_U32 nPortOutput,
OMX_IN OMX_HANDLETYPE hInput,
OMX_IN OMX_U32 nPortInput)
{
OMX_ERRORTYPE result_omx = OMX_SetupTunnel(hOutput, nPortOutput, hInput, nPortInput);
if(result_omx != OMX_ErrorNone)
{
LOG_ERROR("OMX_SetupTunnel: output %d input %d (%s)", nPortOutput, nPortInput, dump_OMX_ERRORTYPE (result_omx));
return ERROR;
}
return OK;
}
/*****************************************************************************/
enum error_code
omx_allocate_port_buffer(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer,
OMX_IN OMX_U32 nPortIndex,
OMX_IN OMX_PTR pAppPrivate)
{
enum error_code result;
OMX_PARAM_PORTDEFINITIONTYPE def_st; OMX_INIT_STRUCTURE (def_st);
def_st.nPortIndex = nPortIndex;
result = omx_get_parameter(hComponent, OMX_IndexParamPortDefinition, &def_st); if(result) return result;
return omx_allocate_buffer(hComponent, ppBuffer, nPortIndex, pAppPrivate, def_st.nBufferSize);
}
/*****************************************************************************/