1/*
2 * Copyright (c) 2010, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * *  Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 *
12 * *  Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * *  Neither the name of Texas Instruments Incorporated nor the names of
17 *    its contributors may be used to endorse or promote products derived
18 *    from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33/**
34 *  @file  omx_proxy_sample.c
35 *         This file contains methods that provides the functionality for
36 *         the OpenMAX1.1 DOMX Framework Tunnel Proxy component.
37 *********************************************************************************************
38 This is the proxy specific wrapper that passes the component name to the generic proxy init()
39 The proxy wrapper also does some runtime/static time onfig on per proxy basis
40 This is a thin wrapper that is called when componentiit() of the proxy is called
41 static OMX_ERRORTYPE PROXY_Wrapper_init(OMX_HANDLETYPE hComponent, OMX_PTR pAppData);
42 this layer gets called first whenever a proxy s get handle is called
43 ************************************************************************************************
44 *  @path WTSD_DucatiMMSW\omx\omx_il_1_x\omx_proxy_component\src
45 *
46 *  @rev 1.0
47 */
48
49/*==============================================================
50 *! Revision History
51 *! ============================
52 *! 19-August-2009 B Ravi Kiran ravi.kiran@ti.com: Initial Version
53 *================================================================*/
54
55/******************************************************************
56 *   INCLUDE FILES
57 ******************************************************************/
58#include <stdio.h>
59#include <string.h>
60#include <assert.h>
61#include "omx_proxy_common.h"
62#include <timm_osal_interfaces.h>
63//change to ducati1 later
64#define COMPONENT_NAME "OMX.TI.DUCATI1.MISC.SAMPLE"	// needs to be specific for every configuration wrapper
65
66OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
67{
68	OMX_ERRORTYPE eError = OMX_ErrorNone;
69	OMX_COMPONENTTYPE *pHandle = NULL;
70	PROXY_COMPONENT_PRIVATE *pComponentPrivate;
71	pHandle = (OMX_COMPONENTTYPE *) hComponent;
72
73	DOMX_DEBUG
74	    ("_____________________INSISDE PROXY WRAPPER__________________________\n");
75
76	pHandle->pComponentPrivate =
77	    (PROXY_COMPONENT_PRIVATE *)
78	    TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE), TIMM_OSAL_TRUE,
79	    0, TIMMOSAL_MEM_SEGMENT_INT);
80
81	pComponentPrivate =
82	    (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate;
83	if (pHandle->pComponentPrivate == NULL)
84	{
85		DOMX_DEBUG
86		    (" ERROR IN ALLOCATING PROXY COMPONENT PRIVATE STRUCTURE");
87		eError = OMX_ErrorInsufficientResources;
88		goto EXIT;
89	}
90	pComponentPrivate->cCompName =
91	    TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8),
92	    TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT);
93	// Copying component Name - this will be picked up in the proxy common
94	assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH);
95	TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME,
96	    strlen(COMPONENT_NAME) + 1);
97	eError = OMX_ProxyCommonInit(hComponent);	// Calling Proxy Common Init()
98
99	if (eError != OMX_ErrorNone)
100	{
101		DOMX_DEBUG("\Error in Initializing Proxy");
102		TIMM_OSAL_Free(pComponentPrivate->cCompName);
103		TIMM_OSAL_Free(pComponentPrivate);
104	}
105
106
107      EXIT:
108	return eError;
109}
110