diff options
Diffstat (limited to 'sec_mm/sec_omx/sec_omx_component/common')
7 files changed, 0 insertions, 3233 deletions
diff --git a/sec_mm/sec_omx/sec_omx_component/common/Android.mk b/sec_mm/sec_omx/sec_omx_component/common/Android.mk deleted file mode 100644 index aa32005..0000000 --- a/sec_mm/sec_omx/sec_omx_component/common/Android.mk +++ /dev/null @@ -1,24 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := \ - SEC_OMX_Basecomponent.c \ - SEC_OMX_Baseport.c \ - SEC_OMX_Resourcemanager.c - - -LOCAL_MODULE := libsecbasecomponent.aries - -LOCAL_CFLAGS := - -LOCAL_STATIC_LIBRARIES := libsecosal.aries -LOCAL_SHARED_LIBRARIES := libcutils libutils - -LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ - $(SEC_OMX_INC)/sec \ - $(SEC_OMX_TOP)/sec_osal - -include $(BUILD_STATIC_LIBRARY) - diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c deleted file mode 100644 index 89e9aeb..0000000 --- a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c +++ /dev/null @@ -1,1486 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * @file SEC_OMX_Basecomponent.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "SEC_OSAL_Event.h" -#include "SEC_OSAL_Thread.h" -#include "SEC_OMX_Baseport.h" -#include "SEC_OMX_Basecomponent.h" -#include "SEC_OMX_Macros.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_BASE_COMP" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -/* Change CHECK_SIZE_VERSION Macro */ -OMX_ERRORTYPE SEC_OMX_Check_SizeVersion(OMX_PTR header, OMX_U32 size) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - - OMX_VERSIONTYPE* version = NULL; - if (header == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - version = (OMX_VERSIONTYPE*)((char*)header + sizeof(OMX_U32)); - if (*((OMX_U32*)header) != size) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (version->s.nVersionMajor != VERSIONMAJOR_NUMBER || - version->s.nVersionMinor != VERSIONMINOR_NUMBER) { - ret = OMX_ErrorVersionMismatch; - goto EXIT; - } - ret = OMX_ErrorNone; -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OMX_GetComponentVersion( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_STRING pComponentName, - OMX_OUT OMX_VERSIONTYPE *pComponentVersion, - OMX_OUT OMX_VERSIONTYPE *pSpecVersion, - OMX_OUT OMX_UUIDTYPE *pComponentUUID) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - OMX_U32 compUUID[3]; - - FunctionIn(); - - /* check parameters */ - if (hComponent == NULL || - pComponentName == NULL || pComponentVersion == NULL || - pSpecVersion == NULL || pComponentUUID == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - SEC_OSAL_Strcpy(pComponentName, pSECComponent->componentName); - SEC_OSAL_Memcpy(pComponentVersion, &(pSECComponent->componentVersion), sizeof(OMX_VERSIONTYPE)); - SEC_OSAL_Memcpy(pSpecVersion, &(pSECComponent->specVersion), sizeof(OMX_VERSIONTYPE)); - - /* Fill UUID with handle address, PID and UID. - * This should guarantee uiniqness */ - compUUID[0] = (OMX_U32)pOMXComponent; - compUUID[1] = getpid(); - compUUID[2] = getuid(); - SEC_OSAL_Memcpy(*pComponentUUID, compUUID, 3 * sizeof(*compUUID)); - - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_GetState ( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_STATETYPE *pState) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL || pState == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - *pState = pSECComponent->currentState; - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -static OMX_ERRORTYPE SEC_OMX_BufferProcessThread(OMX_PTR threadData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_MESSAGE *message = NULL; - - FunctionIn(); - - if (threadData == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)threadData; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pSECComponent->sec_BufferProcess(pOMXComponent); - - SEC_OSAL_ThreadExit(NULL); - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_ComponentStateSet(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 messageParam) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_MESSAGE *message; - OMX_STATETYPE destState = messageParam; - OMX_STATETYPE currentState = pSECComponent->currentState; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_S32 countValue = 0; - int i = 0, j = 0; - - FunctionIn(); - - /* check parameters */ - if (currentState == destState) { - ret = OMX_ErrorSameState; - goto EXIT; - } - if (currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - if ((currentState == OMX_StateLoaded) && (destState == OMX_StateIdle)) { - ret = SEC_OMX_Get_Resource(pOMXComponent); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - } - if (((currentState == OMX_StateIdle) && (destState == OMX_StateLoaded)) || - ((currentState == OMX_StateIdle) && (destState == OMX_StateInvalid)) || - ((currentState == OMX_StateExecuting) && (destState == OMX_StateInvalid)) || - ((currentState == OMX_StatePause) && (destState == OMX_StateInvalid))) { - SEC_OMX_Release_Resource(pOMXComponent); - } - - SEC_OSAL_Log(SEC_LOG_TRACE, "destState: %d", destState); - - switch (destState) { - case OMX_StateInvalid: - switch (currentState) { - case OMX_StateIdle: - case OMX_StateExecuting: - case OMX_StatePause: - case OMX_StateLoaded: - case OMX_StateWaitForResources: - pSECComponent->currentState = OMX_StateInvalid; - if (pSECComponent->hBufferProcess) { - pSECComponent->bExitBufferProcessThread = OMX_TRUE; - - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[i].bufferSemID, &countValue); - if (countValue == 0) - SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[i].bufferSemID); - } - - SEC_OSAL_SignalSet(pSECComponent->pauseEvent); - SEC_OSAL_ThreadTerminate(pSECComponent->hBufferProcess); - pSECComponent->hBufferProcess = NULL; - - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_MutexTerminate(pSECComponent->secDataBuffer[i].bufferMutex); - pSECComponent->secDataBuffer[i].bufferMutex = NULL; - } - - SEC_OSAL_SignalTerminate(pSECComponent->pauseEvent); - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_SemaphoreTerminate(pSECComponent->pSECPort[i].bufferSemID); - pSECComponent->pSECPort[i].bufferSemID = NULL; - } - } - if (pSECComponent->sec_mfc_componentTerminate != NULL) - pSECComponent->sec_mfc_componentTerminate(pOMXComponent); - break; - } - ret = OMX_ErrorInvalidState; - break; - case OMX_StateLoaded: - switch (currentState) { - case OMX_StateIdle: - pSECComponent->bExitBufferProcessThread = OMX_TRUE; - - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[i].bufferSemID, &countValue); - if (countValue == 0) - SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[i].bufferSemID); - } - - SEC_OSAL_SignalSet(pSECComponent->pauseEvent); - SEC_OSAL_ThreadTerminate(pSECComponent->hBufferProcess); - pSECComponent->hBufferProcess = NULL; - - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_MutexTerminate(pSECComponent->secDataBuffer[i].bufferMutex); - pSECComponent->secDataBuffer[i].bufferMutex = NULL; - } - - SEC_OSAL_SignalTerminate(pSECComponent->pauseEvent); - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_SemaphoreTerminate(pSECComponent->pSECPort[i].bufferSemID); - pSECComponent->pSECPort[i].bufferSemID = NULL; - } - - pSECComponent->sec_mfc_componentTerminate(pOMXComponent); - - for (i = 0; i < (pSECComponent->portParam.nPorts); i++) { - pSECPort = (pSECComponent->pSECPort + i); - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) > 0) { - message = (SEC_OMX_MESSAGE*)SEC_OSAL_Dequeue(&pSECPort->bufferQ); - if (message != NULL) - SEC_OSAL_Free(message); - } - ret = pSECComponent->sec_FreeTunnelBuffer(pSECComponent, i); - if (OMX_ErrorNone != ret) { - goto EXIT; - } - } else { - if (CHECK_PORT_ENABLED(pSECPort)) { - SEC_OSAL_SemaphoreWait(pSECPort->unloadedResource); - pSECPort->portDefinition.bPopulated = OMX_FALSE; - } - } - } - pSECComponent->currentState = OMX_StateLoaded; - break; - case OMX_StateWaitForResources: - ret = SEC_OMX_Out_WaitForResource(pOMXComponent); - pSECComponent->currentState = OMX_StateLoaded; - break; - case OMX_StateExecuting: - case OMX_StatePause: - default: - ret = OMX_ErrorIncorrectStateTransition; - break; - } - break; - case OMX_StateIdle: - switch (currentState) { - case OMX_StateLoaded: - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECPort = (pSECComponent->pSECPort + i); - if (pSECPort == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - if (CHECK_PORT_ENABLED(pSECPort)) { - ret = pSECComponent->sec_AllocateTunnelBuffer(pSECPort, i); - if (ret!=OMX_ErrorNone) - goto EXIT; - } - } else { - if (CHECK_PORT_ENABLED(pSECPort)) { - SEC_OSAL_SemaphoreWait(pSECComponent->pSECPort[i].loadedResource); - pSECPort->portDefinition.bPopulated = OMX_TRUE; - } - } - } - ret = pSECComponent->sec_mfc_componentInit(pOMXComponent); - if (ret != OMX_ErrorNone) { - /* - * if (CHECK_PORT_TUNNELED == OMX_TRUE) thenTunnel Buffer Free - */ - goto EXIT; - } - pSECComponent->bExitBufferProcessThread = OMX_FALSE; - SEC_OSAL_SignalCreate(&pSECComponent->pauseEvent); - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_SemaphoreCreate(&pSECComponent->pSECPort[i].bufferSemID); - } - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_MutexCreate(&pSECComponent->secDataBuffer[i].bufferMutex); - } - ret = SEC_OSAL_ThreadCreate(&pSECComponent->hBufferProcess, - SEC_OMX_BufferProcessThread, - pOMXComponent); - if (ret != OMX_ErrorNone) { - /* - * if (CHECK_PORT_TUNNELED == OMX_TRUE) thenTunnel Buffer Free - */ - - SEC_OSAL_SignalTerminate(pSECComponent->pauseEvent); - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_MutexTerminate(pSECComponent->secDataBuffer[i].bufferMutex); - pSECComponent->secDataBuffer[i].bufferMutex = NULL; - } - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_SemaphoreTerminate(pSECComponent->pSECPort[i].bufferSemID); - pSECComponent->pSECPort[i].bufferSemID = NULL; - } - - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - pSECComponent->currentState = OMX_StateIdle; - break; - case OMX_StateExecuting: - case OMX_StatePause: - SEC_OMX_BufferFlushProcessNoEvent(pOMXComponent, ALL_PORT_INDEX); - pSECComponent->currentState = OMX_StateIdle; - break; - case OMX_StateWaitForResources: - pSECComponent->currentState = OMX_StateIdle; - break; - } - break; - case OMX_StateExecuting: - switch (currentState) { - case OMX_StateLoaded: - ret = OMX_ErrorIncorrectStateTransition; - break; - case OMX_StateIdle: - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECPort = &pSECComponent->pSECPort[i]; - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort) && CHECK_PORT_ENABLED(pSECPort)) { - for (j = 0; j < pSECPort->tunnelBufferNum; j++) { - SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[i].bufferSemID); - } - } - } - - pSECComponent->transientState = SEC_OMX_TransStateMax; - pSECComponent->currentState = OMX_StateExecuting; - SEC_OSAL_SignalSet(pSECComponent->pauseEvent); - break; - case OMX_StatePause: - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECPort = &pSECComponent->pSECPort[i]; - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort) && CHECK_PORT_ENABLED(pSECPort)) { - OMX_U32 semaValue = 0, cnt = 0; - SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[i].bufferSemID, &semaValue); - if (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) > semaValue) { - cnt = SEC_OSAL_GetElemNum(&pSECPort->bufferQ) - semaValue; - for (j = 0; j < cnt; j++) { - SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[i].bufferSemID); - } - } - } - } - - pSECComponent->currentState = OMX_StateExecuting; - SEC_OSAL_SignalSet(pSECComponent->pauseEvent); - break; - case OMX_StateWaitForResources: - ret = OMX_ErrorIncorrectStateTransition; - break; - } - break; - case OMX_StatePause: - switch (currentState) { - case OMX_StateLoaded: - ret = OMX_ErrorIncorrectStateTransition; - break; - case OMX_StateIdle: - pSECComponent->currentState = OMX_StatePause; - break; - case OMX_StateExecuting: - pSECComponent->currentState = OMX_StatePause; - break; - case OMX_StateWaitForResources: - ret = OMX_ErrorIncorrectStateTransition; - break; - } - break; - case OMX_StateWaitForResources: - switch (currentState) { - case OMX_StateLoaded: - ret = SEC_OMX_In_WaitForResource(pOMXComponent); - pSECComponent->currentState = OMX_StateWaitForResources; - break; - case OMX_StateIdle: - case OMX_StateExecuting: - case OMX_StatePause: - ret = OMX_ErrorIncorrectStateTransition; - break; - } - break; - } - -EXIT: - if (ret == OMX_ErrorNone) { - if (pSECComponent->pCallbacks != NULL) { - pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, - pSECComponent->callbackData, - OMX_EventCmdComplete, OMX_CommandStateSet, - destState, NULL); - } - } else { - if (pSECComponent->pCallbacks != NULL) { - pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, ret, 0, NULL); - } - } - FunctionOut(); - - return ret; -} - -static OMX_ERRORTYPE SEC_OMX_MessageHandlerThread(OMX_PTR threadData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_MESSAGE *message = NULL; - OMX_U32 messageType = 0, portIndex = 0; - - FunctionIn(); - - if (threadData == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pOMXComponent = (OMX_COMPONENTTYPE *)threadData; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - while (pSECComponent->bExitMessageHandlerThread != OMX_TRUE) { - SEC_OSAL_SemaphoreWait(pSECComponent->msgSemaphoreHandle); - message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECComponent->messageQ); - if (message != NULL) { - messageType = message->messageType; - switch (messageType) { - case OMX_CommandStateSet: - ret = SEC_OMX_ComponentStateSet(pOMXComponent, message->messageParam); - break; - case OMX_CommandFlush: - ret = SEC_OMX_BufferFlushProcess(pOMXComponent, message->messageParam); - break; - case OMX_CommandPortDisable: - ret = SEC_OMX_PortDisableProcess(pOMXComponent, message->messageParam); - break; - case OMX_CommandPortEnable: - ret = SEC_OMX_PortEnableProcess(pOMXComponent, message->messageParam); - break; - case OMX_CommandMarkBuffer: - portIndex = message->messageParam; - pSECComponent->pSECPort[portIndex].markType.hMarkTargetComponent = ((OMX_MARKTYPE *)message->pCmdData)->hMarkTargetComponent; - pSECComponent->pSECPort[portIndex].markType.pMarkData = ((OMX_MARKTYPE *)message->pCmdData)->pMarkData; - break; - case (OMX_COMMANDTYPE)SEC_OMX_CommandComponentDeInit: - pSECComponent->bExitMessageHandlerThread = OMX_TRUE; - break; - default: - break; - } - SEC_OSAL_Free(message); - message = NULL; - } - } - - SEC_OSAL_ThreadExit(NULL); - -EXIT: - FunctionOut(); - - return ret; -} - -static OMX_ERRORTYPE SEC_StateSet(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) -{ - OMX_U32 destState = nParam; - OMX_U32 i = 0; - - if ((destState == OMX_StateIdle) && (pSECComponent->currentState == OMX_StateLoaded)) { - pSECComponent->transientState = SEC_OMX_TransStateLoadedToIdle; - for(i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECComponent->pSECPort[i].portState = OMX_StateIdle; - } - SEC_OSAL_Log(SEC_LOG_TRACE, "to OMX_StateIdle"); - } else if ((destState == OMX_StateLoaded) && (pSECComponent->currentState == OMX_StateIdle)) { - pSECComponent->transientState = SEC_OMX_TransStateIdleToLoaded; - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECComponent->pSECPort[i].portState = OMX_StateLoaded; - } - SEC_OSAL_Log(SEC_LOG_TRACE, "to OMX_StateLoaded"); - } else if ((destState == OMX_StateIdle) && (pSECComponent->currentState == OMX_StateExecuting)) { - pSECComponent->transientState = SEC_OMX_TransStateExecutingToIdle; - SEC_OSAL_Log(SEC_LOG_TRACE, "to OMX_StateIdle"); - } else if ((destState == OMX_StateExecuting) && (pSECComponent->currentState == OMX_StateIdle)) { - pSECComponent->transientState = SEC_OMX_TransStateIdleToExecuting; - SEC_OSAL_Log(SEC_LOG_TRACE, "to OMX_StateExecuting"); - } else if (destState == OMX_StateInvalid) { - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECComponent->pSECPort[i].portState = OMX_StateInvalid; - } - } - - return OMX_ErrorNone; -} - -static OMX_ERRORTYPE SEC_SetPortFlush(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_U32 portIndex = nParam; - OMX_U16 i = 0, cnt = 0, index = 0; - - - if ((pSECComponent->currentState == OMX_StateExecuting) || - (pSECComponent->currentState == OMX_StatePause)) { - if ((portIndex != ALL_PORT_INDEX) && - ((OMX_S32)portIndex >= (OMX_S32)pSECComponent->portParam.nPorts)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - /********************* - * need flush event set ????? - **********************/ - cnt = (portIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1; - for (i = 0; i < cnt; i++) { - if (portIndex == ALL_PORT_INDEX) - index = i; - else - index = portIndex; - pSECComponent->pSECPort[index].bIsPortFlushed = OMX_TRUE; - } - } else { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - ret = OMX_ErrorNone; - -EXIT: - return ret; -} - -static OMX_ERRORTYPE SEC_SetPortEnable(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_U32 portIndex = nParam; - OMX_U16 i = 0, cnt = 0; - - FunctionIn(); - - if ((portIndex != ALL_PORT_INDEX) && - ((OMX_S32)portIndex >= (OMX_S32)pSECComponent->portParam.nPorts)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - if (portIndex == ALL_PORT_INDEX) { - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECPort = &pSECComponent->pSECPort[i]; - if (CHECK_PORT_ENABLED(pSECPort)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } else { - pSECPort->portState = OMX_StateIdle; - } - } - } else { - pSECPort = &pSECComponent->pSECPort[portIndex]; - if (CHECK_PORT_ENABLED(pSECPort)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } else { - pSECPort->portState = OMX_StateIdle; - } - } - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; - -} - -static OMX_ERRORTYPE SEC_SetPortDisable(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_U32 portIndex = nParam; - OMX_U16 i = 0, cnt = 0; - - FunctionIn(); - - if ((portIndex != ALL_PORT_INDEX) && - ((OMX_S32)portIndex >= (OMX_S32)pSECComponent->portParam.nPorts)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - if (portIndex == ALL_PORT_INDEX) { - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECPort = &pSECComponent->pSECPort[i]; - if (!CHECK_PORT_ENABLED(pSECPort)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - pSECPort->portState = OMX_StateLoaded; - pSECPort->bIsPortDisabled = OMX_TRUE; - } - } else { - pSECPort = &pSECComponent->pSECPort[portIndex]; - pSECPort->portState = OMX_StateLoaded; - pSECPort->bIsPortDisabled = OMX_TRUE; - } - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -static OMX_ERRORTYPE SEC_SetMarkBuffer(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_U32 portIndex = nParam; - OMX_U16 i = 0, cnt = 0; - - - if (nParam >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - if ((pSECComponent->currentState == OMX_StateExecuting) || - (pSECComponent->currentState == OMX_StatePause)) { - ret = OMX_ErrorNone; - } else { - ret = OMX_ErrorIncorrectStateOperation; - } - -EXIT: - return ret; -} - -static OMX_ERRORTYPE SEC_OMX_CommandQueue( - SEC_OMX_BASECOMPONENT *pSECComponent, - OMX_COMMANDTYPE Cmd, - OMX_U32 nParam, - OMX_PTR pCmdData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_MESSAGE *command = (SEC_OMX_MESSAGE *)SEC_OSAL_Malloc(sizeof(SEC_OMX_MESSAGE)); - - if (command == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - command->messageType = (OMX_U32)Cmd; - command->messageParam = nParam; - command->pCmdData = pCmdData; - - ret = SEC_OSAL_Queue(&pSECComponent->messageQ, (void *)command); - if (ret != 0) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - ret = SEC_OSAL_SemaphorePost(pSECComponent->msgSemaphoreHandle); - -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OMX_SendCommand( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_COMMANDTYPE Cmd, - OMX_IN OMX_U32 nParam, - OMX_IN OMX_PTR pCmdData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_MESSAGE *message = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - switch (Cmd) { - case OMX_CommandStateSet : - SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandStateSet"); - SEC_StateSet(pSECComponent, nParam); - break; - case OMX_CommandFlush : - SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandFlush"); - ret = SEC_SetPortFlush(pSECComponent, nParam); - if (ret != OMX_ErrorNone) - goto EXIT; - break; - case OMX_CommandPortDisable : - SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandPortDisable"); - ret = SEC_SetPortDisable(pSECComponent, nParam); - if (ret != OMX_ErrorNone) - goto EXIT; - break; - case OMX_CommandPortEnable : - SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandPortEnable"); - ret = SEC_SetPortEnable(pSECComponent, nParam); - if (ret != OMX_ErrorNone) - goto EXIT; - break; - case OMX_CommandMarkBuffer : - SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandMarkBuffer"); - ret = SEC_SetMarkBuffer(pSECComponent, nParam); - if (ret != OMX_ErrorNone) - goto EXIT; - break; -/* - case SEC_CommandFillBuffer : - case SEC_CommandEmptyBuffer : - case SEC_CommandDeInit : -*/ - default: - break; - } - - ret = SEC_OMX_CommandQueue(pSECComponent, Cmd, nParam, pCmdData); - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_GetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR ComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (ComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - switch (nParamIndex) { - case (OMX_INDEXTYPE)OMX_COMPONENT_CAPABILITY_TYPE_INDEX: - { - /* For Android PV OpenCORE */ - OMXComponentCapabilityFlagsType *capabilityFlags = (OMXComponentCapabilityFlagsType *)ComponentParameterStructure; - SEC_OSAL_Memcpy(capabilityFlags, &pSECComponent->capabilityFlags, sizeof(OMXComponentCapabilityFlagsType)); - } - break; - case OMX_IndexParamAudioInit: - case OMX_IndexParamVideoInit: - case OMX_IndexParamImageInit: - case OMX_IndexParamOtherInit: - { - OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure; - ret = SEC_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - portParam->nPorts = 0; - portParam->nStartPortNumber = 0; - } - break; - case OMX_IndexParamPortDefinition: - { - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = portDefinition->nPortIndex; - SEC_OMX_BASEPORT *pSECPort; - - if (portIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(portDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[portIndex]; - SEC_OSAL_Memcpy(portDefinition, &pSECPort->portDefinition, portDefinition->nSize); - } - break; - case OMX_IndexParamPriorityMgmt: - { - OMX_PRIORITYMGMTTYPE *compPriority = (OMX_PRIORITYMGMTTYPE *)ComponentParameterStructure; - - ret = SEC_OMX_Check_SizeVersion(compPriority, sizeof(OMX_PRIORITYMGMTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - compPriority->nGroupID = pSECComponent->compPriority.nGroupID; - compPriority->nGroupPriority = pSECComponent->compPriority.nGroupPriority; - } - break; - - case OMX_IndexParamCompBufferSupplier: - { - OMX_PARAM_BUFFERSUPPLIERTYPE *bufferSupplier = (OMX_PARAM_BUFFERSUPPLIERTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = bufferSupplier->nPortIndex; - SEC_OMX_BASEPORT *pSECPort; - - if ((pSECComponent->currentState == OMX_StateLoaded) || - (pSECComponent->currentState == OMX_StateWaitForResources)) { - if (portIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(bufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[portIndex]; - - - if (pSECPort->portDefinition.eDir == OMX_DirInput) { - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - bufferSupplier->eBufferSupplier = OMX_BufferSupplyInput; - } else if (CHECK_PORT_TUNNELED(pSECPort)) { - bufferSupplier->eBufferSupplier = OMX_BufferSupplyOutput; - } else { - bufferSupplier->eBufferSupplier = OMX_BufferSupplyUnspecified; - } - } else { - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - bufferSupplier->eBufferSupplier = OMX_BufferSupplyOutput; - } else if (CHECK_PORT_TUNNELED(pSECPort)) { - bufferSupplier->eBufferSupplier = OMX_BufferSupplyInput; - } else { - bufferSupplier->eBufferSupplier = OMX_BufferSupplyUnspecified; - } - } - } - else - { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - } - break; - default: - { - ret = OMX_ErrorUnsupportedIndex; - goto EXIT; - } - break; - } - - ret = OMX_ErrorNone; - -EXIT: - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_SetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR ComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (ComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - switch (nIndex) { - case OMX_IndexParamAudioInit: - case OMX_IndexParamVideoInit: - case OMX_IndexParamImageInit: - case OMX_IndexParamOtherInit: - { - OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure; - ret = SEC_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((pSECComponent->currentState != OMX_StateLoaded) && - (pSECComponent->currentState != OMX_StateWaitForResources)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - ret = OMX_ErrorUndefined; - /* SEC_OSAL_Memcpy(&pSECComponent->portParam, portParam, sizeof(OMX_PORT_PARAM_TYPE)); */ - } - break; - case OMX_IndexParamPortDefinition: - { - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = portDefinition->nPortIndex; - SEC_OMX_BASEPORT *pSECPort; - - if (portIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(portDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[portIndex]; - - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - if (pSECPort->portDefinition.bEnabled == OMX_TRUE) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - } - if (portDefinition->nBufferCountActual < pSECPort->portDefinition.nBufferCountMin) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - SEC_OSAL_Memcpy(&pSECPort->portDefinition, portDefinition, portDefinition->nSize); - } - break; - case OMX_IndexParamPriorityMgmt: - { - OMX_PRIORITYMGMTTYPE *compPriority = (OMX_PRIORITYMGMTTYPE *)ComponentParameterStructure; - - if ((pSECComponent->currentState != OMX_StateLoaded) && - (pSECComponent->currentState != OMX_StateWaitForResources)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - ret = SEC_OMX_Check_SizeVersion(compPriority, sizeof(OMX_PRIORITYMGMTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - pSECComponent->compPriority.nGroupID = compPriority->nGroupID; - pSECComponent->compPriority.nGroupPriority = compPriority->nGroupPriority; - } - break; - case OMX_IndexParamCompBufferSupplier: - { - OMX_PARAM_BUFFERSUPPLIERTYPE *bufferSupplier = (OMX_PARAM_BUFFERSUPPLIERTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = bufferSupplier->nPortIndex; - SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[portIndex]; - - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - if (pSECPort->portDefinition.bEnabled == OMX_TRUE) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - } - - if (portIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(bufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyUnspecified) { - ret = OMX_ErrorNone; - goto EXIT; - } - if (CHECK_PORT_TUNNELED(pSECPort) == 0) { - ret = OMX_ErrorNone; /*OMX_ErrorNone ?????*/ - goto EXIT; - } - - if (pSECPort->portDefinition.eDir == OMX_DirInput) { - if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyInput) { - /* - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - ret = OMX_ErrorNone; - } - */ - pSECPort->tunnelFlags |= SEC_TUNNEL_IS_SUPPLIER; - bufferSupplier->nPortIndex = pSECPort->tunneledPort; - ret = OMX_SetParameter(pSECPort->tunneledComponent, OMX_IndexParamCompBufferSupplier, bufferSupplier); - goto EXIT; - } else if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyOutput) { - ret = OMX_ErrorNone; - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - pSECPort->tunnelFlags &= ~SEC_TUNNEL_IS_SUPPLIER; - bufferSupplier->nPortIndex = pSECPort->tunneledPort; - ret = OMX_SetParameter(pSECPort->tunneledComponent, OMX_IndexParamCompBufferSupplier, bufferSupplier); - } - goto EXIT; - } - } else if (pSECPort->portDefinition.eDir == OMX_DirOutput) { - if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyInput) { - ret = OMX_ErrorNone; - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - pSECPort->tunnelFlags &= ~SEC_TUNNEL_IS_SUPPLIER; - ret = OMX_ErrorNone; - } - goto EXIT; - } else if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyOutput) { - /* - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - ret = OMX_ErrorNone; - } - */ - pSECPort->tunnelFlags |= SEC_TUNNEL_IS_SUPPLIER; - ret = OMX_ErrorNone; - goto EXIT; - } - } - } - break; - default: - { - ret = OMX_ErrorUnsupportedIndex; - goto EXIT; - } - break; - } - - ret = OMX_ErrorNone; - -EXIT: - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_GetConfig( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_INOUT OMX_PTR pComponentConfigStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pComponentConfigStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - ret = OMX_ErrorUnsupportedIndex; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_SetConfig( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pComponentConfigStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pComponentConfigStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - ret = OMX_ErrorUnsupportedIndex; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_GetExtensionIndex( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, - OMX_OUT OMX_INDEXTYPE *pIndexType) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if ((cParameterName == NULL) || (pIndexType == NULL)) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - ret = OMX_ErrorBadParameter; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_SetCallbacks ( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_CALLBACKTYPE* pCallbacks, - OMX_IN OMX_PTR pAppData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pCallbacks == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - if (pSECComponent->currentState != OMX_StateLoaded) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - pSECComponent->pCallbacks = pCallbacks; - pSECComponent->callbackData = pAppData; - - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_UseEGLImage( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, - OMX_IN void *eglImage) -{ - return OMX_ErrorNotImplemented; -} - -OMX_ERRORTYPE SEC_OMX_BaseComponent_Constructor( - OMX_IN OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - pSECComponent = SEC_OSAL_Malloc(sizeof(SEC_OMX_BASECOMPONENT)); - if (pSECComponent == NULL) { - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - SEC_OSAL_Memset(pSECComponent, 0, sizeof(SEC_OMX_BASECOMPONENT)); - pOMXComponent->pComponentPrivate = (OMX_PTR)pSECComponent; - - ret = SEC_OSAL_SemaphoreCreate(&pSECComponent->msgSemaphoreHandle); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - ret = SEC_OSAL_MutexCreate(&pSECComponent->compMutex); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - - pSECComponent->bExitMessageHandlerThread = OMX_FALSE; - SEC_OSAL_QueueCreate(&pSECComponent->messageQ); - ret = SEC_OSAL_ThreadCreate(&pSECComponent->hMessageHandler, SEC_OMX_MessageHandlerThread, pOMXComponent); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - - pOMXComponent->GetComponentVersion = &SEC_OMX_GetComponentVersion; - pOMXComponent->SendCommand = &SEC_OMX_SendCommand; - pOMXComponent->GetExtensionIndex = &SEC_OMX_GetExtensionIndex; - pOMXComponent->GetState = &SEC_OMX_GetState; - pOMXComponent->SetCallbacks = &SEC_OMX_SetCallbacks; - pOMXComponent->UseEGLImage = &SEC_OMX_UseEGLImage; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_BaseComponent_Destructor( - OMX_IN OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - OMX_U32 semaValue = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - SEC_OMX_CommandQueue(pSECComponent, SEC_OMX_CommandComponentDeInit, 0, NULL); - SEC_OSAL_SleepMillisec(0); - SEC_OSAL_Get_SemaphoreCount(pSECComponent->msgSemaphoreHandle, &semaValue); - if (semaValue == 0) - SEC_OSAL_SemaphorePost(pSECComponent->msgSemaphoreHandle); - SEC_OSAL_SemaphorePost(pSECComponent->msgSemaphoreHandle); - - SEC_OSAL_ThreadTerminate(pSECComponent->hMessageHandler); - pSECComponent->hMessageHandler = NULL; - - SEC_OSAL_MutexTerminate(pSECComponent->compMutex); - pSECComponent->compMutex = NULL; - SEC_OSAL_SemaphoreTerminate(pSECComponent->msgSemaphoreHandle); - pSECComponent->msgSemaphoreHandle = NULL; - SEC_OSAL_QueueTerminate(&pSECComponent->messageQ); - - SEC_OSAL_Free(pSECComponent); - pSECComponent = NULL; - - ret = OMX_ErrorNone; -EXIT: - FunctionOut(); - - return ret; -} diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.h b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.h deleted file mode 100644 index d413257..0000000 --- a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * @file SEC_OMX_Basecomponent.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_BASECOMP -#define SEC_OMX_BASECOMP - -#include "SEC_OMX_Def.h" -#include "OMX_Component.h" -#include "SEC_OSAL_Queue.h" -#include "SEC_OMX_Baseport.h" - - -typedef struct _SEC_OMX_MESSAGE -{ - OMX_U32 messageType; - OMX_U32 messageParam; - OMX_PTR pCmdData; -} SEC_OMX_MESSAGE; - -typedef struct _SEC_OMX_DATABUFFER -{ - OMX_HANDLETYPE bufferMutex; - OMX_BUFFERHEADERTYPE* bufferHeader; - OMX_BOOL dataValid; - OMX_U32 allocSize; - OMX_U32 dataLen; - OMX_U32 usedDataLen; - OMX_U32 remainDataLen; - OMX_U32 nFlags; - OMX_TICKS timeStamp; -} SEC_OMX_DATABUFFER; - -typedef struct _SEC_BUFFER_HEADER{ - void *YPhyAddr; // [IN/OUT] physical address of Y - void *CPhyAddr; // [IN/OUT] physical address of CbCr - void *YVirAddr; // [IN/OUT] virtual address of Y - void *CVirAddr; // [IN/OUT] virtual address of CbCr - int YSize; // [IN/OUT] input size of Y data - int CSize; // [IN/OUT] input size of CbCr data -} SEC_BUFFER_HEADER; - -typedef struct _SEC_OMX_DATA -{ - OMX_BYTE dataBuffer; - OMX_U32 allocSize; - OMX_U32 dataLen; - OMX_U32 usedDataLen; - OMX_U32 remainDataLen; - OMX_U32 previousDataLen; - OMX_U32 nFlags; - OMX_TICKS timeStamp; - SEC_BUFFER_HEADER specificBufferHeader; -} SEC_OMX_DATA; - -/* for Check TimeStamp after Seek */ -typedef struct _SEC_OMX_TIMESTAPM -{ - OMX_BOOL needSetStartTimeStamp; - OMX_BOOL needCheckStartTimeStamp; - OMX_TICKS startTimeStamp; - OMX_U32 nStartFlags; -} SEC_OMX_TIMESTAMP; - -typedef struct _SEC_OMX_BASECOMPONENT -{ - OMX_STRING componentName; - OMX_VERSIONTYPE componentVersion; - OMX_VERSIONTYPE specVersion; - - OMX_STATETYPE currentState; - SEC_OMX_TRANS_STATETYPE transientState; - - SEC_CODEC_TYPE codecType; - SEC_OMX_PRIORITYMGMTTYPE compPriority; - OMX_MARKTYPE propagateMarkType; - OMX_HANDLETYPE compMutex; - - OMX_HANDLETYPE hCodecHandle; - - /* Message Handler */ - OMX_BOOL bExitMessageHandlerThread; - OMX_HANDLETYPE hMessageHandler; - OMX_HANDLETYPE msgSemaphoreHandle; - SEC_QUEUE messageQ; - - /* Buffer Process */ - OMX_BOOL bExitBufferProcessThread; - OMX_HANDLETYPE hBufferProcess; - - /* Buffer */ - SEC_OMX_DATABUFFER secDataBuffer[2]; - - /* Data */ - SEC_OMX_DATA processData[2]; - - /* Port */ - OMX_PORT_PARAM_TYPE portParam; - SEC_OMX_BASEPORT *pSECPort; - - OMX_HANDLETYPE pauseEvent; - - /* Callback function */ - OMX_CALLBACKTYPE *pCallbacks; - OMX_PTR callbackData; - - /* Save Timestamp */ - OMX_TICKS timeStamp[MAX_TIMESTAMP]; - SEC_OMX_TIMESTAMP checkTimeStamp; - - /* Save Flags */ - OMX_U32 nFlags[MAX_FLAGS]; - - OMX_BOOL getAllDelayBuffer; - OMX_BOOL remainOutputData; - OMX_BOOL reInputData; - - /* Android CapabilityFlags */ - OMXComponentCapabilityFlagsType capabilityFlags; - - OMX_BOOL bUseFlagEOF; - OMX_BOOL bSaveFlagEOS; - - OMX_ERRORTYPE (*sec_mfc_componentInit)(OMX_COMPONENTTYPE *pOMXComponent); - OMX_ERRORTYPE (*sec_mfc_componentTerminate)(OMX_COMPONENTTYPE *pOMXComponent); - OMX_ERRORTYPE (*sec_mfc_bufferProcess) (OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData); - - OMX_ERRORTYPE (*sec_AllocateTunnelBuffer)(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex); - OMX_ERRORTYPE (*sec_FreeTunnelBuffer)(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex); - OMX_ERRORTYPE (*sec_BufferProcess)(OMX_HANDLETYPE hComponent); - OMX_ERRORTYPE (*sec_BufferReset)(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex); - OMX_ERRORTYPE (*sec_InputBufferReturn)(OMX_COMPONENTTYPE *pOMXComponent); - OMX_ERRORTYPE (*sec_OutputBufferReturn)(OMX_COMPONENTTYPE *pOMXComponent); - - int (*sec_checkInputFrame)(unsigned char *pInputStream, int buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame); - -} SEC_OMX_BASECOMPONENT; - - -#ifdef __cplusplus -extern "C" { -#endif - - OMX_ERRORTYPE SEC_OMX_Check_SizeVersion(OMX_PTR header, OMX_U32 size); - - -#ifdef __cplusplus -}; -#endif - -#endif diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c deleted file mode 100644 index 97e00af..0000000 --- a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c +++ /dev/null @@ -1,1009 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * @file SEC_OMX_Baseport.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * HyeYeon Chung (hyeon.chung@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "SEC_OMX_Macros.h" -#include "SEC_OSAL_Event.h" -#include "SEC_OSAL_Semaphore.h" -#include "SEC_OSAL_Mutex.h" - -#include "SEC_OMX_Baseport.h" -#include "SEC_OMX_Basecomponent.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_BASE_PORT" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -OMX_ERRORTYPE SEC_OMX_FlushPort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BUFFERHEADERTYPE *bufferHeader = NULL; - SEC_OMX_MESSAGE *message = NULL; - OMX_U32 flushNum = 0; - OMX_S32 semValue = 0; - - FunctionIn(); - - pSECPort = &pSECComponent->pSECPort[portIndex]; - while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) > 0) { - SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[portIndex].bufferSemID, &semValue); - if (semValue == 0) - SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[portIndex].bufferSemID); - SEC_OSAL_SemaphoreWait(pSECComponent->pSECPort[portIndex].bufferSemID); - - message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECPort->bufferQ); - if (message != NULL) { - bufferHeader = (OMX_BUFFERHEADERTYPE *)message->pCmdData; - bufferHeader->nFilledLen = 0; - - if (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - if (portIndex) { - OMX_EmptyThisBuffer(pSECPort->tunneledComponent, bufferHeader); - } else { - OMX_FillThisBuffer(pSECPort->tunneledComponent, bufferHeader); - } - SEC_OSAL_Free(message); - message = NULL; - } else if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - SEC_OSAL_Log(SEC_LOG_ERROR, "Tunneled mode is not working, Line:%d", __LINE__); - ret = OMX_ErrorNotImplemented; - SEC_OSAL_Queue(&pSECPort->bufferQ, pSECPort); - goto EXIT; - } else { - if (portIndex == OUTPUT_PORT_INDEX) { - pSECComponent->pCallbacks->FillBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); - } else { - pSECComponent->pCallbacks->EmptyBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); - } - - SEC_OSAL_Free(message); - message = NULL; - } - } - } - - if (pSECComponent->secDataBuffer[portIndex].dataValid == OMX_TRUE) { - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - message = SEC_OSAL_Malloc(sizeof(SEC_OMX_MESSAGE)); - message->pCmdData = pSECComponent->secDataBuffer[portIndex].bufferHeader; - message->messageType = 0; - message->messageParam = -1; - SEC_OSAL_Queue(&pSECPort->bufferQ, message); - pSECComponent->sec_BufferReset(pOMXComponent, portIndex); - } else { - if (portIndex == INPUT_PORT_INDEX) - pSECComponent->sec_InputBufferReturn(pOMXComponent); - else if (portIndex == OUTPUT_PORT_INDEX) - pSECComponent->sec_OutputBufferReturn(pOMXComponent); - } - } - - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) < pSECPort->assignedBufferNum) { - SEC_OSAL_SemaphoreWait(pSECComponent->pSECPort[portIndex].bufferSemID); - } - if (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) != pSECPort->assignedBufferNum) - SEC_OSAL_SetElemNum(&pSECPort->bufferQ, pSECPort->assignedBufferNum); - } else { - while(1) { - int cnt; - SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[portIndex].bufferSemID, &cnt); - if (cnt == 0) - break; - SEC_OSAL_SemaphoreWait(pSECComponent->pSECPort[portIndex].bufferSemID); - } - SEC_OSAL_SetElemNum(&pSECPort->bufferQ, 0); - } - - pSECComponent->processData[portIndex].dataLen = 0; - pSECComponent->processData[portIndex].nFlags = 0; - pSECComponent->processData[portIndex].remainDataLen = 0; - pSECComponent->processData[portIndex].timeStamp = 0; - pSECComponent->processData[portIndex].usedDataLen = 0; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_BufferFlushProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_S32 portIndex = 0; - OMX_U32 i = 0, cnt = 0; - SEC_OMX_DATABUFFER *flushBuffer = NULL; - - FunctionIn(); - - if (pOMXComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - cnt = (nPortIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1; - - for (i = 0; i < cnt; i++) { - if (nPortIndex == ALL_PORT_INDEX) - portIndex = i; - else - portIndex = nPortIndex; - - SEC_OSAL_SignalSet(pSECComponent->pauseEvent); - - flushBuffer = &pSECComponent->secDataBuffer[portIndex]; - - SEC_OSAL_MutexLock(flushBuffer->bufferMutex); - ret = SEC_OMX_FlushPort(pOMXComponent, portIndex); - SEC_OSAL_MutexUnlock(flushBuffer->bufferMutex); - - pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_FALSE; - - if (ret == OMX_ErrorNone) { - SEC_OSAL_Log(SEC_LOG_TRACE,"OMX_CommandFlush EventCmdComplete"); - pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, - pSECComponent->callbackData, - OMX_EventCmdComplete, - OMX_CommandFlush, portIndex, NULL); - } - - if (portIndex == INPUT_PORT_INDEX) { - pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE; - pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; - SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); - SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); - pSECComponent->getAllDelayBuffer = OMX_FALSE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - pSECComponent->reInputData = OMX_FALSE; - } else if (portIndex == OUTPUT_PORT_INDEX) { - pSECComponent->remainOutputData = OMX_FALSE; - } - } - -EXIT: - if (ret != OMX_ErrorNone) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, - ret, 0, NULL); - } - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_BufferFlushProcessNoEvent(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_S32 portIndex = 0; - OMX_U32 i = 0, cnt = 0; - SEC_OMX_DATABUFFER *flushBuffer = NULL; - - FunctionIn(); - - if (pOMXComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - cnt = (nPortIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1; - - for (i = 0; i < cnt; i++) { - if (nPortIndex == ALL_PORT_INDEX) - portIndex = i; - else - portIndex = nPortIndex; - - pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_TRUE; - - SEC_OSAL_SignalSet(pSECComponent->pauseEvent); - - flushBuffer = &pSECComponent->secDataBuffer[portIndex]; - - SEC_OSAL_MutexLock(flushBuffer->bufferMutex); - ret = SEC_OMX_FlushPort(pOMXComponent, portIndex); - SEC_OSAL_MutexUnlock(flushBuffer->bufferMutex); - - pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_FALSE; - - if (portIndex == INPUT_PORT_INDEX) { - pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE; - pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; - SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); - SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); - pSECComponent->getAllDelayBuffer = OMX_FALSE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - pSECComponent->remainOutputData = OMX_FALSE; - pSECComponent->reInputData = OMX_FALSE; - } - } - -EXIT: - if (ret != OMX_ErrorNone) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, - ret, 0, NULL); - } - - FunctionOut(); - - return ret; -} - - -OMX_ERRORTYPE SEC_OMX_EnablePort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_U32 i = 0, cnt = 0; - - FunctionIn(); - - pSECPort = &pSECComponent->pSECPort[portIndex]; - pSECPort->portDefinition.bEnabled = OMX_TRUE; - - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - ret = pSECComponent->sec_AllocateTunnelBuffer(pSECPort, portIndex); - if (OMX_ErrorNone != ret) { - goto EXIT; - } - pSECPort->portDefinition.bPopulated = OMX_TRUE; - if (pSECComponent->currentState == OMX_StateExecuting) { - for (i=0; i<pSECPort->tunnelBufferNum; i++) { - SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[portIndex].bufferSemID); - } - } - } else if (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - SEC_OSAL_SemaphoreWait(pSECPort->loadedResource); - pSECPort->portDefinition.bPopulated = OMX_TRUE; - } - } else { - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - SEC_OSAL_SemaphoreWait(pSECPort->loadedResource); - pSECPort->portDefinition.bPopulated = OMX_TRUE; - } - } - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_PortEnableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - OMX_S32 portIndex = 0; - OMX_U32 i = 0, cnt = 0; - - FunctionIn(); - - if (pOMXComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - cnt = (nPortIndex == ALL_PORT_INDEX) ? ALL_PORT_NUM : 1; - - for (i = 0; i < cnt; i++) { - if (nPortIndex == ALL_PORT_INDEX) - portIndex = i; - else - portIndex = nPortIndex; - - ret = SEC_OMX_EnablePort(pOMXComponent, portIndex); - if (ret == OMX_ErrorNone) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventCmdComplete, - OMX_CommandPortEnable, portIndex, NULL); - } - } - -EXIT: - if (ret != OMX_ErrorNone) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, - ret, 0, NULL); - } - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_DisablePort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_U32 i = 0, elemNum = 0; - SEC_OMX_MESSAGE *message; - - FunctionIn(); - - pSECPort = &pSECComponent->pSECPort[portIndex]; - - if (!CHECK_PORT_ENABLED(pSECPort)) { - ret = OMX_ErrorNone; - goto EXIT; - } - - if (pSECComponent->currentState!=OMX_StateLoaded) { - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) >0 ) { - message = (SEC_OMX_MESSAGE*)SEC_OSAL_Dequeue(&pSECPort->bufferQ); - SEC_OSAL_Free(message); - } - ret = pSECComponent->sec_FreeTunnelBuffer(pSECPort, portIndex); - if (OMX_ErrorNone != ret) { - goto EXIT; - } - pSECPort->portDefinition.bPopulated = OMX_FALSE; - } else if (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - pSECPort->portDefinition.bPopulated = OMX_FALSE; - SEC_OSAL_SemaphoreWait(pSECPort->unloadedResource); - } else { - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) >0 ) { - message = (SEC_OMX_MESSAGE*)SEC_OSAL_Dequeue(&pSECPort->bufferQ); - SEC_OSAL_Free(message); - } - } - pSECPort->portDefinition.bPopulated = OMX_FALSE; - SEC_OSAL_SemaphoreWait(pSECPort->unloadedResource); - } - } - pSECPort->portDefinition.bEnabled = OMX_FALSE; - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_PortDisableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - OMX_S32 portIndex = 0; - OMX_U32 i = 0, cnt = 0; - SEC_OMX_DATABUFFER *flushBuffer = NULL; - - FunctionIn(); - - if (pOMXComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - cnt = (nPortIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1; - - /* port flush*/ - for(i = 0; i < cnt; i++) { - if (nPortIndex == ALL_PORT_INDEX) - portIndex = i; - else - portIndex = nPortIndex; - - pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_TRUE; - - flushBuffer = &pSECComponent->secDataBuffer[portIndex]; - - SEC_OSAL_MutexLock(flushBuffer->bufferMutex); - ret = SEC_OMX_FlushPort(pOMXComponent, portIndex); - SEC_OSAL_MutexUnlock(flushBuffer->bufferMutex); - - pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_FALSE; - - if (portIndex == INPUT_PORT_INDEX) { - pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE; - pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; - SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); - SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); - pSECComponent->getAllDelayBuffer = OMX_FALSE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - pSECComponent->reInputData = OMX_FALSE; - } else if (portIndex == OUTPUT_PORT_INDEX) { - pSECComponent->remainOutputData = OMX_FALSE; - } - } - - for(i = 0; i < cnt; i++) { - if (nPortIndex == ALL_PORT_INDEX) - portIndex = i; - else - portIndex = nPortIndex; - - ret = SEC_OMX_DisablePort(pOMXComponent, portIndex); - pSECComponent->pSECPort[portIndex].bIsPortDisabled = OMX_FALSE; - if (ret == OMX_ErrorNone) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventCmdComplete, - OMX_CommandPortDisable, portIndex, NULL); - } - } - -EXIT: - if (ret != OMX_ErrorNone) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, - ret, 0, NULL); - } - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_EmptyThisBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BOOL findBuffer = OMX_FALSE; - SEC_OMX_MESSAGE *message; - OMX_U32 i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - if (pBuffer == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pBuffer->nInputPortIndex != INPUT_PORT_INDEX) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - ret = SEC_OMX_Check_SizeVersion(pBuffer, sizeof(OMX_BUFFERHEADERTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((pSECComponent->currentState != OMX_StateIdle) && - (pSECComponent->currentState != OMX_StateExecuting) && - (pSECComponent->currentState != OMX_StatePause)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - if ((!CHECK_PORT_ENABLED(pSECPort)) || - ((CHECK_PORT_BEING_FLUSHED(pSECPort) || CHECK_PORT_BEING_DISABLED(pSECPort)) && - (!CHECK_PORT_TUNNELED(pSECPort) || !CHECK_PORT_BUFFER_SUPPLIER(pSECPort))) || - ((pSECComponent->transientState == SEC_OMX_TransStateExecutingToIdle) && - (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)))) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { - if (pBuffer == pSECPort->bufferHeader[i]) { - findBuffer = OMX_TRUE; - break; - } - } - - if (findBuffer == OMX_FALSE) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } else { - ret = OMX_ErrorNone; - } - - message = SEC_OSAL_Malloc(sizeof(SEC_OMX_MESSAGE)); - if (message == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - message->messageType = SEC_OMX_CommandEmptyBuffer; - message->messageParam = (OMX_U32) i; - message->pCmdData = (OMX_PTR)pBuffer; - - SEC_OSAL_Queue(&pSECPort->bufferQ, (void *)message); - SEC_OSAL_SemaphorePost(pSECPort->bufferSemID); - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_FillThisBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BOOL findBuffer = OMX_FALSE; - SEC_OMX_MESSAGE *message; - OMX_U32 i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - if (pBuffer == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pBuffer->nOutputPortIndex != OUTPUT_PORT_INDEX) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - ret = SEC_OMX_Check_SizeVersion(pBuffer, sizeof(OMX_BUFFERHEADERTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((pSECComponent->currentState != OMX_StateIdle) && - (pSECComponent->currentState != OMX_StateExecuting) && - (pSECComponent->currentState != OMX_StatePause)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - if ((!CHECK_PORT_ENABLED(pSECPort)) || - ((CHECK_PORT_BEING_FLUSHED(pSECPort) || CHECK_PORT_BEING_DISABLED(pSECPort)) && - (!CHECK_PORT_TUNNELED(pSECPort) || !CHECK_PORT_BUFFER_SUPPLIER(pSECPort))) || - ((pSECComponent->transientState == SEC_OMX_TransStateExecutingToIdle) && - (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)))) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { - if (pBuffer == pSECPort->bufferHeader[i]) { - findBuffer = OMX_TRUE; - break; - } - } - - if (findBuffer == OMX_FALSE) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } else { - ret = OMX_ErrorNone; - } - - message = SEC_OSAL_Malloc(sizeof(SEC_OMX_MESSAGE)); - if (message == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - message->messageType = SEC_OMX_CommandFillBuffer; - message->messageParam = (OMX_U32) i; - message->pCmdData = (OMX_PTR)pBuffer; - - SEC_OSAL_Queue(&pSECPort->bufferQ, (void *)message); - SEC_OSAL_SemaphorePost(pSECPort->bufferSemID); - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_Port_Constructor(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - SEC_OMX_BASEPORT *pSECInputPort = NULL; - SEC_OMX_BASEPORT *pSECOutputPort = NULL; - int i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - INIT_SET_SIZE_VERSION(&pSECComponent->portParam, OMX_PORT_PARAM_TYPE); - pSECComponent->portParam.nPorts = ALL_PORT_NUM; - pSECComponent->portParam.nStartPortNumber = INPUT_PORT_INDEX; - - pSECPort = SEC_OSAL_Malloc(sizeof(SEC_OMX_BASEPORT) * ALL_PORT_NUM); - if (pSECPort == NULL) { - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - SEC_OSAL_Memset(pSECPort, 0, sizeof(SEC_OMX_BASEPORT) * ALL_PORT_NUM); - pSECComponent->pSECPort = pSECPort; - - /* Input Port */ - pSECInputPort = &pSECPort[INPUT_PORT_INDEX]; - - SEC_OSAL_QueueCreate(&pSECInputPort->bufferQ); - - pSECInputPort->bufferHeader = SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE*) * MAX_BUFFER_NUM); - if (pSECInputPort->bufferHeader == NULL) { - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - SEC_OSAL_Memset(pSECInputPort->bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE*) * MAX_BUFFER_NUM); - - pSECInputPort->bufferStateAllocate = SEC_OSAL_Malloc(sizeof(OMX_U32) * MAX_BUFFER_NUM); - if (pSECInputPort->bufferStateAllocate == NULL) { - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - SEC_OSAL_Memset(pSECInputPort->bufferStateAllocate, 0, sizeof(OMX_U32) * MAX_BUFFER_NUM); - - pSECInputPort->bufferSemID = NULL; - pSECInputPort->assignedBufferNum = 0; - pSECInputPort->portState = OMX_StateMax; - pSECInputPort->bIsPortFlushed = OMX_FALSE; - pSECInputPort->bIsPortDisabled = OMX_FALSE; - pSECInputPort->tunneledComponent = NULL; - pSECInputPort->tunneledPort = 0; - pSECInputPort->tunnelBufferNum = 0; - pSECInputPort->bufferSupplier = OMX_BufferSupplyUnspecified; - pSECInputPort->tunnelFlags = 0; - pSECInputPort->eControlRate = OMX_Video_ControlRateDisable; - ret = SEC_OSAL_SemaphoreCreate(&pSECInputPort->loadedResource); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); - pSECInputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - goto EXIT; - } - ret = SEC_OSAL_SemaphoreCreate(&pSECInputPort->unloadedResource); - if (ret != OMX_ErrorNone) { - SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); - pSECInputPort->loadedResource = NULL; - SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); - pSECInputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - goto EXIT; - } - - INIT_SET_SIZE_VERSION(&pSECInputPort->portDefinition, OMX_PARAM_PORTDEFINITIONTYPE); - pSECInputPort->portDefinition.nPortIndex = INPUT_PORT_INDEX; - pSECInputPort->portDefinition.eDir = OMX_DirInput; - pSECInputPort->portDefinition.nBufferCountActual = 0; - pSECInputPort->portDefinition.nBufferCountMin = 0; - pSECInputPort->portDefinition.nBufferSize = 0; - pSECInputPort->portDefinition.bEnabled = OMX_FALSE; - pSECInputPort->portDefinition.bPopulated = OMX_FALSE; - pSECInputPort->portDefinition.eDomain = OMX_PortDomainMax; - pSECInputPort->portDefinition.bBuffersContiguous = OMX_FALSE; - pSECInputPort->portDefinition.nBufferAlignment = 0; - pSECInputPort->markType.hMarkTargetComponent = NULL; - pSECInputPort->markType.pMarkData = NULL; - pSECInputPort->bUseAndroidNativeBuffer = OMX_FALSE; - pSECInputPort->bStoreMetaDataInBuffer = OMX_FALSE; - - /* Output Port */ - pSECOutputPort = &pSECPort[OUTPUT_PORT_INDEX]; - - SEC_OSAL_QueueCreate(&pSECOutputPort->bufferQ); - - pSECOutputPort->bufferHeader = SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE*) * MAX_BUFFER_NUM); - if (pSECOutputPort->bufferHeader == NULL) { - SEC_OSAL_SemaphoreTerminate(pSECInputPort->unloadedResource); - pSECInputPort->unloadedResource = NULL; - SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); - pSECInputPort->loadedResource = NULL; - SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); - pSECInputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - SEC_OSAL_Memset(pSECOutputPort->bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE*) * MAX_BUFFER_NUM); - - pSECOutputPort->bufferStateAllocate = SEC_OSAL_Malloc(sizeof(OMX_U32) * MAX_BUFFER_NUM); - if (pSECOutputPort->bufferStateAllocate == NULL) { - SEC_OSAL_Free(pSECOutputPort->bufferHeader); - pSECOutputPort->bufferHeader = NULL; - - SEC_OSAL_SemaphoreTerminate(pSECInputPort->unloadedResource); - pSECInputPort->unloadedResource = NULL; - SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); - pSECInputPort->loadedResource = NULL; - SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); - pSECInputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - SEC_OSAL_Memset(pSECOutputPort->bufferStateAllocate, 0, sizeof(OMX_U32) * MAX_BUFFER_NUM); - - pSECOutputPort->bufferSemID = NULL; - pSECOutputPort->assignedBufferNum = 0; - pSECOutputPort->portState = OMX_StateMax; - pSECOutputPort->bIsPortFlushed = OMX_FALSE; - pSECOutputPort->bIsPortDisabled = OMX_FALSE; - pSECOutputPort->tunneledComponent = NULL; - pSECOutputPort->tunneledPort = 0; - pSECOutputPort->tunnelBufferNum = 0; - pSECOutputPort->bufferSupplier = OMX_BufferSupplyUnspecified; - pSECOutputPort->tunnelFlags = 0; - pSECOutputPort->eControlRate = OMX_Video_ControlRateDisable; - ret = SEC_OSAL_SemaphoreCreate(&pSECOutputPort->loadedResource); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Free(pSECOutputPort->bufferStateAllocate); - pSECOutputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECOutputPort->bufferHeader); - pSECOutputPort->bufferHeader = NULL; - - SEC_OSAL_SemaphoreTerminate(pSECInputPort->unloadedResource); - pSECInputPort->unloadedResource = NULL; - SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); - pSECInputPort->loadedResource = NULL; - SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); - pSECInputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - goto EXIT; - } - ret = SEC_OSAL_SemaphoreCreate(&pSECOutputPort->unloadedResource); - if (ret != OMX_ErrorNone) { - SEC_OSAL_SemaphoreTerminate(pSECOutputPort->loadedResource); - pSECOutputPort->loadedResource = NULL; - SEC_OSAL_Free(pSECOutputPort->bufferStateAllocate); - pSECOutputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECOutputPort->bufferHeader); - pSECOutputPort->bufferHeader = NULL; - - SEC_OSAL_SemaphoreTerminate(pSECInputPort->unloadedResource); - pSECInputPort->unloadedResource = NULL; - SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); - pSECInputPort->loadedResource = NULL; - SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); - pSECInputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - goto EXIT; - } - - INIT_SET_SIZE_VERSION(&pSECOutputPort->portDefinition, OMX_PARAM_PORTDEFINITIONTYPE); - pSECOutputPort->portDefinition.nPortIndex = OUTPUT_PORT_INDEX; - pSECOutputPort->portDefinition.eDir = OMX_DirOutput; - pSECOutputPort->portDefinition.nBufferCountActual = 0; - pSECOutputPort->portDefinition.nBufferCountMin = 0; - pSECOutputPort->portDefinition.nBufferSize = 0; - pSECOutputPort->portDefinition.bEnabled = OMX_FALSE; - pSECOutputPort->portDefinition.bPopulated = OMX_FALSE; - pSECOutputPort->portDefinition.eDomain = OMX_PortDomainMax; - pSECOutputPort->portDefinition.bBuffersContiguous = OMX_FALSE; - pSECOutputPort->portDefinition.nBufferAlignment = 0; - pSECOutputPort->markType.hMarkTargetComponent = NULL; - pSECOutputPort->markType.pMarkData = NULL; - pSECOutputPort->bUseAndroidNativeBuffer = OMX_FALSE; - pSECOutputPort->bStoreMetaDataInBuffer = OMX_FALSE; - - pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE; - pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; - pSECComponent->checkTimeStamp.startTimeStamp = 0; - pSECComponent->checkTimeStamp.nStartFlags = 0x0; - - pOMXComponent->EmptyThisBuffer = &SEC_OMX_EmptyThisBuffer; - pOMXComponent->FillThisBuffer = &SEC_OMX_FillThisBuffer; - - ret = OMX_ErrorNone; -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_Port_Destructor(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - - FunctionIn(); - - int i = 0; - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - for (i = 0; i < ALL_PORT_NUM; i++) { - pSECPort = &pSECComponent->pSECPort[i]; - - SEC_OSAL_SemaphoreTerminate(pSECPort->loadedResource); - pSECPort->loadedResource = NULL; - SEC_OSAL_SemaphoreTerminate(pSECPort->unloadedResource); - pSECPort->unloadedResource = NULL; - SEC_OSAL_Free(pSECPort->bufferStateAllocate); - pSECPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECPort->bufferHeader); - pSECPort->bufferHeader = NULL; - - SEC_OSAL_QueueTerminate(&pSECPort->bufferQ); - } - SEC_OSAL_Free(pSECComponent->pSECPort); - pSECComponent->pSECPort = NULL; - ret = OMX_ErrorNone; -EXIT: - FunctionOut(); - - return ret; -} diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h deleted file mode 100644 index 147f940..0000000 --- a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * @file SEC_OMX_Baseport.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * HyeYeon Chung (hyeon.chung@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_BASE_PORT -#define SEC_OMX_BASE_PORT - - -#include "OMX_Component.h" -#include "SEC_OMX_Def.h" -#include "SEC_OSAL_Queue.h" - - -#define BUFFER_STATE_ALLOCATED (1 << 0) -#define BUFFER_STATE_ASSIGNED (1 << 1) -#define HEADER_STATE_ALLOCATED (1 << 2) -#define BUFFER_STATE_FREE 0 - -#define MAX_BUFFER_NUM 20 - -#define INPUT_PORT_INDEX 0 -#define OUTPUT_PORT_INDEX 1 -#define ALL_PORT_INDEX -1 -#define ALL_PORT_NUM 2 - -typedef struct _SEC_OMX_BASEPORT -{ - OMX_BUFFERHEADERTYPE **bufferHeader; - OMX_U32 *bufferStateAllocate; - OMX_PARAM_PORTDEFINITIONTYPE portDefinition; - OMX_HANDLETYPE bufferSemID; - SEC_QUEUE bufferQ; - OMX_U32 assignedBufferNum; - OMX_STATETYPE portState; - OMX_HANDLETYPE loadedResource; - OMX_HANDLETYPE unloadedResource; - - OMX_BOOL bIsPortFlushed; - OMX_BOOL bIsPortDisabled; - OMX_MARKTYPE markType; - - OMX_CONFIG_RECTTYPE cropRectangle; - - /* Tunnel Info */ - OMX_HANDLETYPE tunneledComponent; - OMX_U32 tunneledPort; - OMX_U32 tunnelBufferNum; - OMX_BUFFERSUPPLIERTYPE bufferSupplier; - OMX_U32 tunnelFlags; - - OMX_VIDEO_CONTROLRATETYPE eControlRate; - - /* For Android Native Buffer */ - OMX_BOOL bUseAndroidNativeBuffer; - /* For Android Store Meta Data inBuffer */ - OMX_BOOL bStoreMetaDataInBuffer; - OMX_PTR pIMGGrallocModule; -} SEC_OMX_BASEPORT; - - -#ifdef __cplusplus -extern "C" { -#endif - -OMX_ERRORTYPE SEC_OMX_PortEnableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); -OMX_ERRORTYPE SEC_OMX_PortDisableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); -OMX_ERRORTYPE SEC_OMX_BufferFlushProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); -OMX_ERRORTYPE SEC_OMX_BufferFlushProcessNoEvent(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); - -#ifdef __cplusplus -}; -#endif - - -#endif diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.c b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.c deleted file mode 100644 index 41673ad..0000000 --- a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.c +++ /dev/null @@ -1,383 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * @file SEC_OMX_Resourcemanager.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "SEC_OMX_Resourcemanager.h" -#include "SEC_OMX_Basecomponent.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_RM" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -#define MAX_RESOURCE_VIDEO 4 - -/* Max allowable video scheduler component instance */ -static SEC_OMX_RM_COMPONENT_LIST *gpVideoRMComponentList = NULL; -static SEC_OMX_RM_COMPONENT_LIST *gpVideoRMWaitingList = NULL; -static OMX_HANDLETYPE ghVideoRMComponentListMutex = NULL; - - -OMX_ERRORTYPE addElementList(SEC_OMX_RM_COMPONENT_LIST **ppList, OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_RM_COMPONENT_LIST *pTempComp = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (*ppList != NULL) { - pTempComp = *ppList; - while (pTempComp->pNext != NULL) { - pTempComp = pTempComp->pNext; - } - pTempComp->pNext = (SEC_OMX_RM_COMPONENT_LIST *)SEC_OSAL_Malloc(sizeof(SEC_OMX_RM_COMPONENT_LIST)); - if (pTempComp->pNext == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - ((SEC_OMX_RM_COMPONENT_LIST *)(pTempComp->pNext))->pNext = NULL; - ((SEC_OMX_RM_COMPONENT_LIST *)(pTempComp->pNext))->pOMXStandComp = pOMXComponent; - ((SEC_OMX_RM_COMPONENT_LIST *)(pTempComp->pNext))->groupPriority = pSECComponent->compPriority.nGroupPriority; - goto EXIT; - } else { - *ppList = (SEC_OMX_RM_COMPONENT_LIST *)SEC_OSAL_Malloc(sizeof(SEC_OMX_RM_COMPONENT_LIST)); - if (*ppList == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - pTempComp = *ppList; - pTempComp->pNext = NULL; - pTempComp->pOMXStandComp = pOMXComponent; - pTempComp->groupPriority = pSECComponent->compPriority.nGroupPriority; - } - -EXIT: - return ret; -} - -OMX_ERRORTYPE removeElementList(SEC_OMX_RM_COMPONENT_LIST **ppList, OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_RM_COMPONENT_LIST *pCurrComp = NULL; - SEC_OMX_RM_COMPONENT_LIST *pPrevComp = NULL; - OMX_BOOL bDetectComp = OMX_FALSE; - - if (*ppList == NULL) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - - pCurrComp = *ppList; - while (pCurrComp != NULL) { - if (pCurrComp->pOMXStandComp == pOMXComponent) { - if (*ppList == pCurrComp) { - *ppList = pCurrComp->pNext; - SEC_OSAL_Free(pCurrComp); - } else { - pPrevComp->pNext = pCurrComp->pNext; - SEC_OSAL_Free(pCurrComp); - } - bDetectComp = OMX_TRUE; - break; - } else { - pPrevComp = pCurrComp; - pCurrComp = pCurrComp->pNext; - } - } - - if (bDetectComp == OMX_FALSE) - ret = OMX_ErrorComponentNotFound; - else - ret = OMX_ErrorNone; - -EXIT: - return ret; -} - -int searchLowPriority(SEC_OMX_RM_COMPONENT_LIST *RMComp_list, int inComp_priority, SEC_OMX_RM_COMPONENT_LIST **outLowComp) -{ - int ret = 0; - SEC_OMX_RM_COMPONENT_LIST *pTempComp = NULL; - SEC_OMX_RM_COMPONENT_LIST *pCandidateComp = NULL; - - if (RMComp_list == NULL) - ret = -1; - - pTempComp = RMComp_list; - *outLowComp = 0; - - while (pTempComp != NULL) { - if (pTempComp->groupPriority > inComp_priority) { - if (pCandidateComp != NULL) { - if (pCandidateComp->groupPriority < pTempComp->groupPriority) - pCandidateComp = pTempComp; - } else { - pCandidateComp = pTempComp; - } - } - - pTempComp = pTempComp->pNext; - } - - *outLowComp = pCandidateComp; - if (pCandidateComp == NULL) - ret = 0; - else - ret = 1; - -EXIT: - return ret; -} - -OMX_ERRORTYPE removeComponent(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateIdle) { - (*(pSECComponent->pCallbacks->EventHandler)) - (pOMXComponent, pSECComponent->callbackData, - OMX_EventError, OMX_ErrorResourcesLost, 0, NULL); - ret = OMX_SendCommand(pOMXComponent, OMX_CommandStateSet, OMX_StateLoaded, NULL); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - } else if ((pSECComponent->currentState == OMX_StateExecuting) || (pSECComponent->currentState == OMX_StatePause)) { - /* Todo */ - } - - ret = OMX_ErrorNone; - -EXIT: - return ret; -} - - -OMX_ERRORTYPE SEC_OMX_ResourceManager_Init() -{ - FunctionIn(); - SEC_OSAL_MutexCreate(&ghVideoRMComponentListMutex); - FunctionOut(); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE SEC_OMX_ResourceManager_Deinit() -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_RM_COMPONENT_LIST *pCurrComponent; - SEC_OMX_RM_COMPONENT_LIST *pNextComponent; - - FunctionIn(); - - SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); - - if (gpVideoRMComponentList) { - pCurrComponent = gpVideoRMComponentList; - while (pCurrComponent != NULL) { - pNextComponent = pCurrComponent->pNext; - SEC_OSAL_Free(pCurrComponent); - pCurrComponent = pNextComponent; - } - gpVideoRMComponentList = NULL; - } - - if (gpVideoRMWaitingList) { - pCurrComponent = gpVideoRMWaitingList; - while (pCurrComponent != NULL) { - pNextComponent = pCurrComponent->pNext; - SEC_OSAL_Free(pCurrComponent); - pCurrComponent = pNextComponent; - } - gpVideoRMWaitingList = NULL; - } - SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); - - SEC_OSAL_MutexTerminate(ghVideoRMComponentListMutex); - ghVideoRMComponentListMutex = NULL; - - ret = OMX_ErrorNone; -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_Get_Resource(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_RM_COMPONENT_LIST *pComponentTemp = NULL; - SEC_OMX_RM_COMPONENT_LIST *pComponentCandidate = NULL; - int numElem = 0; - int lowCompDetect = 0; - - FunctionIn(); - - SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pComponentTemp = gpVideoRMComponentList; - if (pSECComponent->codecType == HW_VIDEO_CODEC) { - if (pComponentTemp != NULL) { - while (pComponentTemp) { - numElem++; - pComponentTemp = pComponentTemp->pNext; - } - } else { - numElem = 0; - } - if (numElem >= MAX_RESOURCE_VIDEO) { - lowCompDetect = searchLowPriority(gpVideoRMComponentList, pSECComponent->compPriority.nGroupPriority, &pComponentCandidate); - if (lowCompDetect <= 0) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } else { - ret = removeComponent(pComponentCandidate->pOMXStandComp); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } else { - ret = removeElementList(&gpVideoRMComponentList, pComponentCandidate->pOMXStandComp); - ret = addElementList(&gpVideoRMComponentList, pOMXComponent); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - } - } - } else { - ret = addElementList(&gpVideoRMComponentList, pOMXComponent); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - } - } - ret = OMX_ErrorNone; - -EXIT: - - SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_Release_Resource(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_RM_COMPONENT_LIST *pComponentTemp = NULL; - OMX_COMPONENTTYPE *pOMXWaitComponent = NULL; - int numElem = 0; - - FunctionIn(); - - SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pComponentTemp = gpVideoRMWaitingList; - if (pSECComponent->codecType == HW_VIDEO_CODEC) { - if (gpVideoRMComponentList == NULL) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - - ret = removeElementList(&gpVideoRMComponentList, pOMXComponent); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - while (pComponentTemp) { - numElem++; - pComponentTemp = pComponentTemp->pNext; - } - if (numElem > 0) { - pOMXWaitComponent = gpVideoRMWaitingList->pOMXStandComp; - removeElementList(&gpVideoRMWaitingList, pOMXWaitComponent); - ret = OMX_SendCommand(pOMXWaitComponent, OMX_CommandStateSet, OMX_StateIdle, NULL); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - } - } - -EXIT: - - SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_In_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->codecType == HW_VIDEO_CODEC) - ret = addElementList(&gpVideoRMWaitingList, pOMXComponent); - - SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_Out_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->codecType == HW_VIDEO_CODEC) - ret = removeElementList(&gpVideoRMWaitingList, pOMXComponent); - - SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); - - FunctionOut(); - - return ret; -} - diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.h b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.h deleted file mode 100644 index b958575..0000000 --- a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * @file SEC_OMX_Resourcemanager.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_RESOURCEMANAGER -#define SEC_OMX_RESOURCEMANAGER - - -#include "SEC_OMX_Def.h" -#include "OMX_Component.h" - - -struct SEC_OMX_RM_COMPONENT_LIST; -typedef struct _SEC_OMX_RM_COMPONENT_LIST -{ - OMX_COMPONENTTYPE *pOMXStandComp; - OMX_U32 groupPriority; - struct SEC_OMX_RM_COMPONENT_LIST *pNext; -} SEC_OMX_RM_COMPONENT_LIST; - - -#ifdef __cplusplus -extern "C" { -#endif - -OMX_ERRORTYPE SEC_OMX_ResourceManager_Init(); -OMX_ERRORTYPE SEC_OMX_ResourceManager_Deinit(); -OMX_ERRORTYPE SEC_OMX_Get_Resource(OMX_COMPONENTTYPE *pOMXComponent); -OMX_ERRORTYPE SEC_OMX_Release_Resource(OMX_COMPONENTTYPE *pOMXComponent); -OMX_ERRORTYPE SEC_OMX_In_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent); -OMX_ERRORTYPE SEC_OMX_Out_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent); - -#ifdef __cplusplus -}; -#endif - -#endif |