1
2/*
3 * Copyright (C) Texas Instruments - http://www.ti.com/
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * Lesser General Public License for more details.
15 *
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21#ifndef OMX_WBAMR_DEC_UTILS__H
22#define OMX_WBAMR_DEC_UTILS__H
23
24#include <OMX_Component.h>
25#include "OMX_TI_Common.h"
26#include "OMX_WbAmrDecoder.h"
27#ifdef RESOURCE_MANAGER_ENABLED
28#include <ResourceManagerProxyAPI.h>
29#endif
30
31
32/* ======================================================================= */
33/**
34 * @def    WBAMR_DEC__XXX_VER    Component version
35 */
36/* ======================================================================= */
37#define WBAMR_DEC_MAJOR_VER 0xF1
38#define WBAMR_DEC_MINOR_VER 0xF2
39/* ======================================================================= */
40/**
41 * @def    WBAMR_DEC_NOT_USED    Defines a value for "don't care" parameters
42 */
43/* ======================================================================= */
44#define WBAMR_DEC_NOT_USED 10
45/* ======================================================================= */
46/**
47 * @def    WBAMR_DEC_NORMAL_BUFFER    Defines the flag value with all flags turned off
48 */
49/* ======================================================================= */
50#define WBAMR_DEC_NORMAL_BUFFER 0
51/* ======================================================================= */
52/**
53 * @def    OMX_WBAMR_DEC_DEFAULT_SEGMENT    Default segment ID for the LCML
54 */
55/* ======================================================================= */
56#define OMX_WBAMR_DEC_DEFAULT_SEGMENT (0)
57/* ======================================================================= */
58/**
59 * @def    OMX_WBAMR_DEC_SN_TIMEOUT    Timeout value for the socket node
60 */
61/* ======================================================================= */
62#define OMX_WBAMR_DEC_SN_TIMEOUT (-1)
63/* ======================================================================= */
64/**
65 * @def    OMX_WBAMR_DEC_SN_PRIORITY   Priority for the socket node
66 */
67/* ======================================================================= */
68#define OMX_WBAMR_DEC_SN_PRIORITY (10)
69/* ======================================================================= */
70/**
71 * @def    OMX_WBAMR_DEC_NUM_DLLS   number of DLL's
72 */
73 /* =================================================================================== */
74/*
75* Different Frame sizes
76*/
77/* ================================================================================== */
78#define  WBAMR_DEC_FRAME_SIZE_18	18
79#define  WBAMR_DEC_FRAME_SIZE_23  	23
80#define  WBAMR_DEC_FRAME_SIZE_24  	24
81#define  WBAMR_DEC_FRAME_SIZE_33  	33
82#define  WBAMR_DEC_FRAME_SIZE_37  	37
83#define  WBAMR_DEC_FRAME_SIZE_41  	41
84#define  WBAMR_DEC_FRAME_SIZE_47  	47
85#define  WBAMR_DEC_FRAME_SIZE_51  	51
86#define  WBAMR_DEC_FRAME_SIZE_59  	59
87#define  WBAMR_DEC_FRAME_SIZE_61	61
88#define  WBAMR_DEC_FRAME_SIZE_6		6
89#define  WBAMR_DEC_FRAME_SIZE_1		1
90#define  WBAMR_DEC_FRAME_SIZE_0		0
91
92#define WBAMRDEC_APP_ID 100
93
94
95 /* ======================================================================= */
96/**
97 * @def    INPUT_WBAMRDEC_BUFFER_SIZE_IF2   Default input buffer size IF2
98 *
99 */
100/* ======================================================================= */
101#define INPUT_WBAMRDEC_BUFFER_SIZE_IF2 61
102
103/* ======================================================================= */
104/** WBAMRENC_MimeMode  format types
105*
106*  @param  WBAMRENC_MIMEMODE				MIME
107*
108*  @param  WBAMRENC_NONMIMEMODE				WBAMR mode
109*
110*/
111/* ======================================================================= */
112enum WBAMRDEC_MimeMode {
113	WBAMRDEC_FORMATCONFORMANCE = 0,
114	WBAMRDEC_MIMEMODE,
115	WBAMRDEC_IF2
116};
117
118/* ======================================================================= */
119#define OMX_WBAMR_DEC_NUM_DLLS (2)
120/* ======================================================================= */
121/**
122 * @def    WBAMR_DEC_USN_DLL_NAME   USN DLL name
123 */
124/* ======================================================================= */
125#ifdef UNDER_CE
126#define WBAMR_DEC_USN_DLL_NAME "\\windows\\usn.dll64P"
127#else
128#define WBAMR_DEC_USN_DLL_NAME "usn.dll64P"
129#endif
130
131/* ======================================================================= */
132/**
133 * @def    WBAMR_DEC_DLL_NAME   WB AMR Decoder socket node dll name
134 */
135/* ======================================================================= */
136#ifdef UNDER_CE
137#define WBAMR_DEC_DLL_NAME "\\windows\\wbamrdec_sn.dll64P"
138#else
139#define WBAMR_DEC_DLL_NAME "wbamrdec_sn.dll64P"
140#endif
141
142/* ===========================================================  */
143/**
144*  WBAMR_DEC_StartComponentThread()  Starts component thread
145*
146*
147*  @param hComp			OMX Handle
148*
149*  @return OMX_ErrorNone = Successful
150*          Other error code = fail
151*
152*/
153/*================================================================== */
154OMX_ERRORTYPE WBAMR_DEC_StartComponentThread(OMX_HANDLETYPE pHandle);
155/* ===========================================================  */
156/**
157*  WBAMR_DEC_StopComponentThread()  Stops component thread
158*
159*
160*  @param hComp			OMX Handle
161*
162*  @return OMX_ErrorNone = Successful
163*          Other error code = fail
164*
165*/
166/*================================================================== */
167OMX_ERRORTYPE WBAMR_DEC_StopComponentThread(OMX_HANDLETYPE pHandle);
168/* ===========================================================  */
169/**
170*  WBAMR_DEC_FreeCompResources()  Frees allocated memory
171*
172*
173*  @param hComp			OMX Handle
174*
175*  @return OMX_ErrorNone = Successful
176*          Other error code = fail
177*
178*/
179/*================================================================== */
180OMX_ERRORTYPE WBAMR_DEC_FreeCompResources(OMX_HANDLETYPE pComponent);
181/* ===========================================================  */
182/**
183*  WBAMR_DEC_GetCorresponding_LCMLHeader()  Returns LCML header
184* that corresponds to the given buffer
185*
186*  @param pComponentPrivate	Component private data
187*
188*  @return OMX_ErrorNone = Successful
189*          Other error code = fail
190*/
191/*================================================================== */
192OMX_ERRORTYPE WBAMR_DEC_GetCorresponding_LCMLHeader(WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate,
193                                          OMX_U8 *pBuffer,
194                                          OMX_DIRTYPE eDir,
195                                          LCML_WBAMR_DEC_BUFHEADERTYPE **ppLcmlHdr);
196/* ===========================================================  */
197/**
198*  WBAMR_DEC_LCML_Callback() Callback from LCML
199*
200*  @param event		Codec Event
201*
202*  @param args		Arguments from LCML
203*
204*  @return OMX_ErrorNone = Successful
205*          Other error code = fail
206*/
207/*================================================================== */
208OMX_ERRORTYPE WBAMR_DEC_LCML_Callback (TUsnCodecEvent event,void * args [10]);
209/* ===========================================================  */
210/**
211*  WBAMR_DEC_Fill_LCMLInitParams() Fills the parameters needed
212* to initialize the LCML
213*
214*  @param pHandle OMX Handle
215*
216*  @param plcml_Init LCML initialization parameters
217*
218*  @return OMX_ErrorNone = Successful
219*          Other error code = fail
220*
221*/
222/*================================================================== */
223OMX_ERRORTYPE WBAMR_DEC_Fill_LCMLInitParams(OMX_HANDLETYPE pHandle,
224                  LCML_DSP *plcml_Init,OMX_U16 arr[]);
225/* ===========================================================  */
226/**
227*  WBAMR_DEC_GetBufferDirection() Returns direction of pBufHeader
228*
229*  @param pBufHeader		Buffer header
230*
231*  @param eDir				Buffer direction
232*
233*  @param pComponentPrivate	Component private data
234*
235*  @return OMX_ErrorNone = Successful
236*          Other error code = fail
237*/
238/*================================================================== */
239OMX_ERRORTYPE WBAMR_DEC_GetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader, OMX_DIRTYPE *eDir);
240/* ===========================================================  */
241/**
242*  WBAMR_DEC_HandleCommand()  Handles commands sent via SendCommand()
243*
244*  @param pComponentPrivate	Component private data
245*
246*  @return OMX_ErrorNone = Successful
247*          Other error code = fail
248*  @return OMX_ErrorNone = Successful
249*          Other error code = fail
250*/
251/*================================================================== */
252OMX_U32 WBAMR_DEC_HandleCommand (WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate);
253/* ===========================================================  */
254/**
255*  WBAMR_DEC_HandleDataBuf_FromApp()  Handles data buffers received
256* from the IL Client
257*
258*  @param pComponentPrivate	Component private data
259*
260*  @return OMX_ErrorNone = Successful
261*          Other error code = fail
262*  @return OMX_ErrorNone = Successful
263*          Other error code = fail
264*/
265/*================================================================== */
266OMX_ERRORTYPE WBAMR_DEC_HandleDataBuf_FromApp(OMX_BUFFERHEADERTYPE *pBufHeader,
267        WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate);
268/* ===========================================================  */
269/**
270*  WBAMR_DEC_GetLCMLHandle()  Get the handle to the LCML
271*
272*
273*  @return OMX_ErrorNone = Successful
274*          Other error code = fail
275*/
276/*================================================================== */
277OMX_HANDLETYPE WBAMR_DEC_GetLCMLHandle(WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate);
278/* ===========================================================  */
279/**
280*  WBAMR_DEC_FreeLCMLHandle()  Frees the handle to the LCML
281*
282*
283*  @return OMX_ErrorNone = Successful
284*          Other error code = fail
285*/
286/*================================================================== */
287OMX_ERRORTYPE WBAMR_DEC_FreeLCMLHandle(WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate);
288/* ===========================================================  */
289/**
290*  WBAMR_DEC_CleanupInitParams()  Starts component thread
291*
292*  @param pComponent		OMX Handle
293*
294*  @return OMX_ErrorNone = Successful
295*          Other error code = fail
296*/
297/*================================================================== */
298OMX_ERRORTYPE WBAMR_DEC_CleanupInitParams(OMX_HANDLETYPE pComponent);
299/* ===========================================================  */
300/**
301*  WBAMR_DEC_SetPending()  Called when the component queues a buffer
302* to the LCML
303*
304*  @param pComponentPrivate		Component private data
305*
306*  @param pBufHdr				Buffer header
307*
308*  @param eDir					Direction of the buffer
309*
310*  @return None
311*/
312/*================================================================== */
313void WBAMR_DEC_SetPending(WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber);
314/* ===========================================================  */
315/**
316*  WBAMR_DEC_ClearPending()  Called when a buffer is returned
317* from the LCML
318*
319*  @param pComponentPrivate		Component private data
320*
321*  @param pBufHdr				Buffer header
322*
323*  @param eDir					Direction of the buffer
324*
325*  @return None
326*/
327/*================================================================== */
328void WBAMR_DEC_ClearPending(WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber) ;
329/* ===========================================================  */
330/**
331*  WMADEC_IsPending()
332*
333*
334*  @param pComponentPrivate		Component private data
335*
336*  @return OMX_ErrorNone = Successful
337*          Other error code = fail
338*/
339/*================================================================== */
340OMX_U32 WBAMR_DEC_IsPending(WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir);
341/* ===========================================================  */
342/**
343*  WMADEC_Fill_LCMLInitParamsEx()  Fills the parameters needed
344* to initialize the LCML without recreating the socket node
345*
346*  @param pComponent			OMX Handle
347*
348*  @return None
349*/
350
351/*================================================================== */
352OMX_ERRORTYPE WBAMR_DEC_Fill_LCMLInitParamsEx(OMX_HANDLETYPE pComponent);
353/* ===========================================================  */
354/**
355*  WMADEC_IsValid() Returns whether a buffer is valid
356*
357*
358*  @param pComponentPrivate		Component private data
359*
360*  @param pBuffer				Data buffer
361*
362*  @param eDir					Buffer direction
363*
364*  @return OMX_True = Valid
365*          OMX_False= Invalid
366*/
367/*================================================================== */
368OMX_U32 WBAMR_DEC_IsValid(WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U8 *pBuffer, OMX_DIRTYPE eDir) ;
369
370#ifdef RESOURCE_MANAGER_ENABLED
371void WBAMRDEC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData);
372#endif
373
374OMX_ERRORTYPE OMX_DmmMap(DSP_HPROCESSOR ProcHandle, int size, void* pArmPtr, DMM_BUFFER_OBJ* pDmmBuf, struct OMX_TI_Debug dbg);
375
376OMX_ERRORTYPE OMX_DmmUnMap(DSP_HPROCESSOR ProcHandle, void* pMapPtr, void* pResPtr, struct OMX_TI_Debug dbg);
377
378void WBAMRDEC_HandleUSNError (WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 arg);
379
380#ifdef UNDER_CE
381	#ifndef _OMX_EVENT_
382		#define _OMX_EVENT_
383		typedef struct OMX_Event {
384			HANDLE event;
385		} OMX_Event;
386	#endif
387	int OMX_CreateEvent(OMX_Event *event);
388	int OMX_SignalEvent(OMX_Event *event);
389	int OMX_WaitForEvent(OMX_Event *event);
390	int OMX_DestroyEvent(OMX_Event *event);
391#endif
392
393#endif
394