Ejemplo n.º 1
0
/** @brief The OMX_FreeHandle standard function
 *
 * This function executes the BOSA_DestroyComponent of the component loaders
 *
 * @param hComponent the component handle to be freed
 *
 * @return The error of the BOSA_DestroyComponent function or OMX_ErrorNone
 */
OSCL_EXPORT_REF OMX_ERRORTYPE OMX_FreeHandle(OMX_HANDLETYPE hComponent)
{
    OMX_ERRORTYPE err;
    OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *) hComponent;

    if (pthread_mutex_lock(&mutex) != 0)
    {
        return OMX_ErrorUndefined;
    }

    err = pHandle->ComponentDeInit(pHandle);
    dlclose(((ACT_OMX_COMPONENTTYPE*) pHandle)->pModule);
    free(pHandle);
    if (err == OMX_ErrorNone)
    {
        // the component has been found and destroyed
        if (pthread_mutex_unlock(&mutex) != 0)
        {
            return OMX_ErrorUndefined;
        }
        return OMX_ErrorNone;
    }
    if (pthread_mutex_unlock(&mutex) != 0)
    {
        return OMX_ErrorUndefined;
    }
    ALOGV("Out of %s\n", __func__);
    return OMX_ErrorComponentNotFound;
}
Ejemplo n.º 2
0
void vcil_in_fill_this_buffer(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen)
{
    IL_PASS_BUFFER_EXECUTE_T *exe = call;
    IL_RESPONSE_HEADER_T *ret = resp;
    OMX_COMPONENTTYPE *pComp = exe->reference;
    OMX_BUFFERHEADERTYPE *pHeader = exe->bufferHeader.pOutputPortPrivate;
    OMX_U8 *pBuffer = pHeader->pBuffer;
    OMX_PTR *pAppPrivate = pHeader->pAppPrivate;
    OMX_PTR *pPlatformPrivate = pHeader->pPlatformPrivate;
    OMX_PTR *pInputPortPrivate = pHeader->pInputPortPrivate;
    OMX_PTR *pOutputPortPrivate = pHeader->pOutputPortPrivate;

    vc_assert(pHeader);
    memcpy(pHeader, &exe->bufferHeader, sizeof(OMX_BUFFERHEADERTYPE));

    pHeader->pBuffer = pBuffer;
    pHeader->pAppPrivate = pAppPrivate;
    pHeader->pPlatformPrivate = pPlatformPrivate;
    pHeader->pInputPortPrivate = pInputPortPrivate;
    pHeader->pOutputPortPrivate = pOutputPortPrivate;

    vc_assert(is_valid_hostside_buffer(pHeader));

    *rlen = sizeof(IL_RESPONSE_HEADER_T);
    ret->func = IL_FILL_THIS_BUFFER;
    ret->err = pComp->FillThisBuffer(pComp, pHeader);
}
OMX_ERRORTYPE SEC_OMX_ComponentUnload(SEC_OMX_COMPONENT *sec_component)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;
    OMX_COMPONENTTYPE *pOMXComponent = NULL;

    FunctionIn();

    if (!sec_component) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }

    pOMXComponent = sec_component->pOMXComponent;
    if (pOMXComponent != NULL) {
        pOMXComponent->ComponentDeInit(pOMXComponent);
        SEC_OSAL_Free(pOMXComponent);
        sec_component->pOMXComponent = NULL;
    }

    if (sec_component->libHandle != NULL) {
        SEC_OSAL_dlclose(sec_component->libHandle);
        sec_component->libHandle = NULL;
    }

EXIT:
    FunctionOut();

    return ret;
}
OMX_ERRORTYPE Exynos_OMX_ComponentUnload(EXYNOS_OMX_COMPONENT *exynos_component)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;
    OMX_COMPONENTTYPE *pOMXComponent = NULL;

    FunctionIn();

    if (!exynos_component) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }

    pOMXComponent = exynos_component->pOMXComponent;
    if (pOMXComponent != NULL) {
        pOMXComponent->ComponentDeInit(pOMXComponent);
        Exynos_OSAL_Free(pOMXComponent);
        exynos_component->pOMXComponent = NULL;
    }

    if (exynos_component->libHandle != NULL) {
        Exynos_OSAL_dlclose(exynos_component->libHandle);
        exynos_component->libHandle = NULL;
    }

EXIT:
    FunctionOut();

    return ret;
}
Ejemplo n.º 5
0
void vcil_in_free_buffer(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen)
{
    IL_FREE_BUFFER_EXECUTE_T *exe = call;
    IL_RESPONSE_HEADER_T *ret = resp;
    OMX_COMPONENTTYPE *pComp = exe->reference;
    OMX_BUFFERHEADERTYPE *pHeader;
    OMX_U8 *buffer;
    OMX_PARAM_PORTDEFINITIONTYPE def;
    OMX_ERRORTYPE error;

    def.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
    def.nVersion.nVersion = OMX_VERSION;
    def.nPortIndex = exe->port;
    error = pComp->GetParameter(pComp, OMX_IndexParamPortDefinition, &def);
    vc_assert(error == OMX_ErrorNone);
    if (def.eDir == OMX_DirInput)
        pHeader = exe->inputPrivate;
    else
        pHeader = exe->outputPrivate;

    buffer = pHeader->pBuffer;

    *rlen = sizeof(IL_RESPONSE_HEADER_T);
    ret->func = IL_FREE_BUFFER;
    ret->err = pComp->FreeBuffer(pComp, exe->port, pHeader);
    if (ret->err == OMX_ErrorNone)
        vcos_free(buffer);
}
static OMX_ERRORTYPE OMX_ConfigureDynamicPFramesInH264E( OMX_HANDLETYPE hComponent,
	OMX_BUFFERHEADERTYPE * pBufferHdr,  OMX_U32 nCurrentFrameRate,  OMX_U32 nTargetFrameRate)
{
	OMX_ERRORTYPE eError = OMX_ErrorNone;
	OMX_U32 remainder = 0;
	OMX_U16 nTargetPFrames =0; /* Target Pframes to be provided to Encoder */
	OMX_U16 nCurrentPFrames = 0; /* Current pFrame Value configured to  Encoder */
	OMX_VIDEO_CONFIG_AVCINTRAPERIOD tPframeH264e;
	OMX_VIDEO_PARAM_AVCTYPE h264type;
	OMX_COMPONENTTYPE *pHandle;
	if (hComponent == NULL){
		DOMX_ERROR("Component is invalid/ not present ");
		return OMX_ErrorBadParameter;
	}
	pHandle = (OMX_COMPONENTTYPE *) hComponent;

	/* Initialise the OMX structures */
	OMX_INIT_STRUCT(tPframeH264e, OMX_VIDEO_CONFIG_AVCINTRAPERIOD);
	OMX_INIT_STRUCT(h264type,OMX_VIDEO_PARAM_AVCTYPE);

	/* Read number of B Frames if not read yet */
	if(!nBFrames){
		h264type.nPortIndex = 1;
		eError = pHandle->GetParameter(hComponent,OMX_IndexParamVideoAvc,&h264type);
		if(eError != OMX_ErrorNone) {
			DOMX_ERROR(" Error while reading component info = %d",eError);
			return eError;
		}
		nBFrames = h264type.nBFrames;
	}

	/* Read Current pFrames set in Encoder */
	tPframeH264e.nPortIndex = 1;
	eError = pHandle->GetConfig(hComponent,OMX_IndexConfigVideoAVCIntraPeriod,&tPframeH264e);
	if(eError != OMX_ErrorNone) {
		DOMX_ERROR(" Error while Getting PFrame info, Error code = %d",eError);
		return eError;
	}
	nCurrentPFrames = tPframeH264e.nPFrames;

	/* Calculate Target P Frames */
	nTargetPFrames = (nCurrentPFrames * nTargetFrameRate) /nCurrentFrameRate;
	/* Number of pFrames should be multiple of (B FRAMES + 1) */
	remainder = nTargetPFrames % (nBFrames + 1);
	nTargetPFrames = nTargetPFrames - remainder;
	if(nTargetPFrames == nCurrentPFrames){
		DOMX_INFO(" No Change in P Frames, No Update required");
		return OMX_ErrorNone;
	}

	/* Update the new PFrames to the Encoder */
	tPframeH264e.nPFrames = nTargetPFrames;
	eError = pHandle->SetConfig(hComponent,OMX_IndexConfigVideoAVCIntraPeriod,&tPframeH264e);
	if(eError != OMX_ErrorNone) {
		DOMX_ERROR(" Error while setting PFrame info, Error code = %d",eError);
	}
	return eError;
}
Ejemplo n.º 7
0
void vcil_in_set_parameter(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen)
{
    IL_SET_EXECUTE_T *exe = call;
    IL_RESPONSE_HEADER_T *ret = resp;
    OMX_COMPONENTTYPE *pComp  = exe->reference;

    *rlen = sizeof(IL_RESPONSE_HEADER_T);
    ret->func = IL_SET_PARAMETER;
    ret->err = pComp->SetParameter(pComp, exe->index, exe->param);
}
Ejemplo n.º 8
0
void vcil_in_get_state(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen)
{
    IL_EXECUTE_HEADER_T *exe = call;
    IL_GET_STATE_RESPONSE_T *ret = resp;
    OMX_COMPONENTTYPE *pComp = exe->reference;

    *rlen = sizeof(IL_GET_STATE_RESPONSE_T);
    ret->func = IL_GET_STATE;
    ret->err = pComp->GetState(pComp, &ret->state);
}
Ejemplo n.º 9
0
void vcil_in_get_component_version(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen)
{
    IL_EXECUTE_HEADER_T *exe = call;
    IL_GET_VERSION_RESPONSE_T *ret = resp;
    OMX_COMPONENTTYPE *pComp = exe->reference;

    *rlen = sizeof(IL_GET_VERSION_RESPONSE_T);
    ret->func = IL_GET_COMPONENT_VERSION;
    ret->err = pComp->GetComponentVersion(pComp, ret->name, &ret->component_version, &ret->spec_version, &ret->uuid);
}
Ejemplo n.º 10
0
void vcil_in_get_extension_index(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen)
{
    IL_GET_EXTENSION_EXECUTE_T *exe = call;
    IL_GET_EXTENSION_RESPONSE_T *ret = resp;
    OMX_COMPONENTTYPE *pComp = exe->reference;

    *rlen = sizeof(IL_GET_EXTENSION_RESPONSE_T);
    ret->func = IL_GET_EXTENSION_INDEX;
    ret->err = pComp->GetExtensionIndex(pComp, exe->name, &ret->index);
}
OMX_ERRORTYPE SEC_OMX_ComponentLoad(SEC_OMX_COMPONENT *sec_component)
{
    OMX_ERRORTYPE      ret = OMX_ErrorNone;
    OMX_HANDLETYPE     libHandle;
    OMX_COMPONENTTYPE *pOMXComponent;

    FunctionIn();

    OMX_ERRORTYPE (*SEC_OMX_ComponentInit)(OMX_HANDLETYPE hComponent, OMX_STRING componentName);

    libHandle = SEC_OSAL_dlopen((OMX_STRING)sec_component->libName, RTLD_NOW);
    if (!libHandle) {
        ret = OMX_ErrorInvalidComponentName;
        SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInvalidComponentName, Line:%d", __LINE__);
        goto EXIT;
    }

    SEC_OMX_ComponentInit = SEC_OSAL_dlsym(libHandle, "SEC_OMX_ComponentInit");
    if (!SEC_OMX_ComponentInit) {
        SEC_OSAL_dlclose(libHandle);
        ret = OMX_ErrorInvalidComponent;
        SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInvalidComponent, Line:%d", __LINE__);
        goto EXIT;
    }

    pOMXComponent = (OMX_COMPONENTTYPE *)SEC_OSAL_Malloc(sizeof(OMX_COMPONENTTYPE));
    INIT_SET_SIZE_VERSION(pOMXComponent, OMX_COMPONENTTYPE);
    ret = (*SEC_OMX_ComponentInit)((OMX_HANDLETYPE)pOMXComponent, (OMX_STRING)sec_component->componentName);
    if (ret != OMX_ErrorNone) {
        SEC_OSAL_Free(pOMXComponent);
        SEC_OSAL_dlclose(libHandle);
        ret = OMX_ErrorInvalidComponent;
        SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInvalidComponent, Line:%d", __LINE__);
        goto EXIT;
    } else {
        if (SEC_OMX_ComponentAPICheck(pOMXComponent) != OMX_ErrorNone) {
            if (NULL != pOMXComponent->ComponentDeInit)
                pOMXComponent->ComponentDeInit(pOMXComponent);
            SEC_OSAL_Free(pOMXComponent);
            SEC_OSAL_dlclose(libHandle);
            ret = OMX_ErrorInvalidComponent;
            SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInvalidComponent, Line:%d", __LINE__);
            goto EXIT;
        }
        sec_component->libHandle = libHandle;
        sec_component->pOMXComponent = pOMXComponent;
        ret = OMX_ErrorNone;
    }

EXIT:
    FunctionOut();

    return ret;
}
Ejemplo n.º 12
0
/******************************Public*Routine******************************\
* OMX_FreeHandle()
*
* Description:This method will unload the OMX component pointed by
* OMX_HANDLETYPE. It is the responsibility of the calling method to ensure that
* the Deinit method of the component has been called prior to unloading component
*
* Parameters:
* @param[in] hComponent the component to unload
*
* Returns:    OMX_NOERROR          Successful
*
* Note
*
\**************************************************************************/
OMX_ERRORTYPE OMX_FreeHandle(OMX_HANDLETYPE hComponent)
{

	OMX_ERRORTYPE eError = OMX_ErrorUndefined;
	OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *) hComponent;
	int i;

	if (pthread_mutex_lock(&mutex) != 0)
	{
		TIMM_OSAL_Error("Core: Error in Mutex lock");
	}

	CORE_require(pHandle != NULL, OMX_ErrorBadParameter, NULL);
	CORE_require(count > 0, OMX_ErrorUndefined,
	    "OMX_FreeHandle called without calling OMX_Init first");

	/* Locate the component handle in the array of handles */
	for (i = 0; i < COUNTOF(pModules); i++)
	{
		if (pComponents[i] == hComponent)
			break;
	}

	CORE_assert(i != COUNTOF(pModules), OMX_ErrorBadParameter, NULL);

	eError = pHandle->ComponentDeInit(hComponent);
	if (eError != OMX_ErrorNone)
	{
		TIMM_OSAL_Error("Error From ComponentDeInit..");
	}

	/* release the component and the component handle */
	dlclose(pModules[i]);
	pModules[i] = NULL;
	free(pComponents[i]);

	pComponents[i] = NULL;
	eError = OMX_ErrorNone;

      EXIT:
	/* The unload is now complete, so set the error code to pass and exit */
	if (pthread_mutex_unlock(&mutex) != 0)
	{
		TIMM_OSAL_Error("Core: Error in Mutex unlock");
	}

	return eError;
}
OMX_ERRORTYPE load_component(HTEST *hTest, OMX_U32 idx)
{
	OMX_ERRORTYPE ret = OMX_ErrorNone;
	OMX_COMPONENTTYPE *hComponent = NULL;
	OMX_COMPONENTINITTYPE pInit = NULL;
	OMX_STRING cError;

	hTest->pLibHandle[idx] = dlopen(hTest->lib_name[idx], RTLD_NOW);
	if(hTest->pLibHandle[idx] == NULL)
	{
		cError = dlerror();
		printf("%s\n", cError);
		return OMX_ErrorInvalidComponentName;
	}

	pInit = (OMX_COMPONENTINITTYPE)dlsym(hTest->pLibHandle[idx], hTest->itf_name[idx]);
	if(pInit == NULL)
	{
		cError = dlerror();
		printf("%s\n", cError);
		return OMX_ErrorInvalidComponent;
	}

	hComponent = (OMX_COMPONENTTYPE*)fsl_osal_malloc_new(sizeof(OMX_COMPONENTTYPE));
	if(hComponent == NULL)
	{
		printf("Failed to allocate memory for hComponent.\n");
		return OMX_ErrorInsufficientResources;
	}
	OMX_INIT_STRUCT(hComponent, OMX_COMPONENTTYPE);

	ret = pInit((OMX_HANDLETYPE)(hComponent));
	if(ret != OMX_ErrorNone)
	{
		printf("Load component failed.\n");
		return OMX_ErrorInvalidComponentName;
	}

	hComponent->SetCallbacks(hComponent, &gCallBacks, hTest);
	hTest->component[idx].hComponent = hComponent;


	return OMX_ErrorNone;
}
Ejemplo n.º 14
0
void vcil_in_use_buffer(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen)
{
    IL_ADD_BUFFER_EXECUTE_T *exe = call;
    IL_ADD_BUFFER_RESPONSE_T *ret = resp;
    OMX_COMPONENTTYPE *pComp = exe->reference;
    OMX_U8 *buffer;
    OMX_BUFFERHEADERTYPE *bufferHeader;

    *rlen = sizeof(IL_ADD_BUFFER_RESPONSE_T);

    buffer = vcos_malloc_aligned(exe->size, 32, "vcin mapping buffer"); // 32-byte aligned
    if (!buffer)
    {
        ret->err = OMX_ErrorInsufficientResources;
        return;
    }

    //OMX_OSAL_Trace(OMX_OSAL_TRACE_COMPONENT, "hostcomp: use buffer(%p)\n", buffer);
    ret->func = IL_USE_BUFFER;
    ret->err = pComp->UseBuffer(pComp, &bufferHeader, exe->port, exe->bufferReference, exe->size, buffer);

    if (ret->err == OMX_ErrorNone)
    {
        // we're going to pass this buffer to VC
        // initialise our private field in their copy with the host buffer reference
        OMX_PARAM_PORTDEFINITIONTYPE def;
        OMX_ERRORTYPE error;
        def.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
        def.nVersion.nVersion = OMX_VERSION;
        def.nPortIndex = exe->port;
        error = pComp->GetParameter(pComp, OMX_IndexParamPortDefinition, &def);
        vc_assert(error == OMX_ErrorNone);

        ret->reference = bufferHeader;
        memcpy(&ret->bufferHeader, bufferHeader, sizeof(OMX_BUFFERHEADERTYPE));

        if (def.eDir == OMX_DirInput)
            ret->bufferHeader.pInputPortPrivate = bufferHeader;
        else
            ret->bufferHeader.pOutputPortPrivate = bufferHeader;
    }
    else
        vcos_free(buffer);
}
Ejemplo n.º 15
0
void vcil_in_empty_this_buffer(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen)
{
    IL_RESPONSE_HEADER_T *ret = resp;
    OMX_COMPONENTTYPE *pComp;
    OMX_BUFFERHEADERTYPE *pHeader;

    pHeader = ilcs_receive_buffer(st->ilcs, call, clen, &pComp);

    *rlen = sizeof(IL_RESPONSE_HEADER_T);
    ret->func = IL_EMPTY_THIS_BUFFER;

    if(pHeader)
    {
        vc_assert(is_valid_hostside_buffer(pHeader));
        ret->err = pComp->EmptyThisBuffer(pComp, pHeader);
    }
    else
        ret->err = OMX_ErrorHardware;
}
OMX_ERRORTYPE SEC_MFC_H264Enc_SetConfig(
    OMX_HANDLETYPE hComponent,
    OMX_INDEXTYPE nIndex,
    OMX_PTR pComponentConfigStructure)
{
    OMX_ERRORTYPE          ret = OMX_ErrorNone;
    OMX_COMPONENTTYPE     *pOMXComponent = NULL;
    SEC_OMX_BASECOMPONENT *pSECComponent = NULL;

    FunctionIn();

    if (hComponent == NULL || pComponentConfigStructure == 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 (nIndex) {
    default:
        ret = pOMXComponent->SetConfig(hComponent, nIndex, pComponentConfigStructure);
        break;
    }

EXIT:
    FunctionOut();

    return ret;
}
Ejemplo n.º 17
0
void vcil_in_get_parameter(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen)
{
    IL_GET_EXECUTE_T *exe = call;
    IL_GET_RESPONSE_T *ret = resp;
    OMX_COMPONENTTYPE *pComp  = exe->reference;
    OMX_U32 size = *((OMX_U32 *) (&exe->param));

    ret->func = IL_GET_PARAMETER;

    if(size > VC_ILCS_MAX_PARAM_SIZE)
    {
        *rlen = IL_GET_RESPONSE_HEADER_SIZE;
        ret->err = OMX_ErrorHardware;
    }
    else
    {
        *rlen = size + IL_GET_RESPONSE_HEADER_SIZE;
        ret->err = pComp->GetParameter(pComp, exe->index, exe->param);
        memcpy(ret->param, exe->param, size);
    }
}
Ejemplo n.º 18
0
static OMX_ERRORTYPE OMX_ConfigureDynamicFrameRate( OMX_HANDLETYPE hComponent,
	OMX_BUFFERHEADERTYPE * pBufferHdr, OMX_STRING hCompName)
{
	OMX_ERRORTYPE eError = OMX_ErrorNone;
	OMX_U32 nTargetFrameRate = 0; /* Target Frame Rate to be provided to Encoder */
	OMX_U32 nCurrentFrameRate = 0; /* Current Frame Rate currently set  in Encoder */
	OMX_CONFIG_FRAMERATETYPE tFrameRate;
	OMX_COMPONENTTYPE *pHandle;
	if (hComponent == NULL){
		DOMX_ERROR("Component is invalid/ not present ");
		return OMX_ErrorBadParameter;
	}
	pHandle = (OMX_COMPONENTTYPE *) hComponent;

	/* Initialise the OMX structures */
	OMX_INIT_STRUCT(tFrameRate,OMX_CONFIG_FRAMERATETYPE);

	/* Intialise nLastFrameRateUpdateTime for the 1st frame */
	if((!nFrameCounter) && (!nLastFrameRateUpdateTime)){
		nLastFrameRateUpdateTime = pBufferHdr-> nTimeStamp;
	}

	/* Increment the Frame Counter and Calculate Frame Rate*/
	nFrameCounter++;
	nVideoTime = pBufferHdr->nTimeStamp - nLastFrameRateUpdateTime;

	if(nVideoTime < 0) {
		return OMX_ErrorBadParameter;
	}

	/*Get Port Frame Rate if not read yet*/
	if(!nFrameRateThreshold) {
		tFrameRate.nPortIndex = 1; /* Output Port Index */
		/* Read Current FrameRate */
		eError = pHandle->GetConfig(hComponent,OMX_IndexConfigVideoFramerate,&tFrameRate);
		nFrameRateThreshold = tFrameRate.xEncodeFramerate >>16;
		nPortFrameRate = nFrameRateThreshold;
		DOMX_INFO(" Port Frame Rate is %d ", nPortFrameRate);
	}
/** @brief creator of the requested OpenMAX component
 *
 * This function searches for the requested component in the internal list.
 * If the component is found, its constructor is called,
 * and the standard callbacks are assigned.
 * A pointer to a standard OpenMAX component is returned.
 */
OMX_ERRORTYPE BOSA_ST_CreateComponent(
  BOSA_COMPONENTLOADER *loader,
  OMX_HANDLETYPE* pHandle,
  OMX_STRING cComponentName,
  OMX_PTR pAppData,
  OMX_CALLBACKTYPE* pCallBacks) {

  int i;
  unsigned int j;
  int componentPosition = -1;
  OMX_ERRORTYPE eError = OMX_ErrorNone;
  stLoaderComponentType** templateList;
  OMX_COMPONENTTYPE *openmaxStandComp;
  omx_base_component_PrivateType * priv;

  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
  templateList = (stLoaderComponentType**)loader->loaderPrivate;
  i = 0;
  while(templateList[i]) {
    if(!strcmp(templateList[i]->name, cComponentName)) {
      //given component name matches with the general component names
      componentPosition = i;
      break;
    } else {
      for(j=0;j<templateList[i]->name_specific_length;j++) {
        if(!strcmp(templateList[i]->name_specific[j], cComponentName)) {
          //given component name matches with specific component names
          componentPosition = i;
          break;
        }
      }
      if(componentPosition != -1) {
        break;
      }
    }
    i++;
  }
  if (componentPosition == -1) {
    DEBUG(DEB_LEV_ERR, "Component not found with current ST static component loader.\n");
    return OMX_ErrorComponentNotFound;
  }

  //component name matches with general component name field
  DEBUG(DEB_LEV_PARAMS, "Found base requested template %s\n", cComponentName);
  /* Build ST component from template and fill fields */
  templateList[componentPosition]->name_requested = strndup (cComponentName, OMX_MAX_STRINGNAME_SIZE);

  openmaxStandComp = calloc(1,sizeof(OMX_COMPONENTTYPE));
  if (!openmaxStandComp) {
    return OMX_ErrorInsufficientResources;
  }
  eError = templateList[componentPosition]->constructor(openmaxStandComp,cComponentName);
  if (eError != OMX_ErrorNone) {
    if (eError == OMX_ErrorInsufficientResources) {
      *pHandle = openmaxStandComp;
      priv = (omx_base_component_PrivateType *) openmaxStandComp->pComponentPrivate;
      priv->loader = loader;
      return OMX_ErrorInsufficientResources;
    }
    DEBUG(DEB_LEV_ERR, "Error during component construction\n");
    openmaxStandComp->ComponentDeInit(openmaxStandComp);
    free(openmaxStandComp);
    openmaxStandComp = NULL;
    return OMX_ErrorComponentNotFound;
  }
  priv = (omx_base_component_PrivateType *) openmaxStandComp->pComponentPrivate;
  priv->loader = loader;

  *pHandle = openmaxStandComp;
  ((OMX_COMPONENTTYPE*)*pHandle)->SetCallbacks(*pHandle, pCallBacks, pAppData);
  DEBUG(DEB_LEV_FULL_SEQ, "Template %s found returning from OMX_GetHandle\n", cComponentName);
  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
  return eError;
}
Ejemplo n.º 20
0
/* OMX_GetHandle */
OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(
   OMX_OUT OMX_HANDLETYPE* pHandle,
   OMX_IN  OMX_STRING cComponentName,
   OMX_IN  OMX_PTR pAppData,
   OMX_IN  OMX_CALLBACKTYPE* pCallBacks)
{
   OMX_ERRORTYPE eError;
   OMX_COMPONENTTYPE *pComp;
   OMX_HANDLETYPE hHandle = 0;

   if (pHandle == NULL || cComponentName == NULL || pCallBacks == NULL || ilcs_service == NULL)
   {
      if(pHandle)
         *pHandle = NULL;
      return OMX_ErrorBadParameter;
   }

   {
      pComp = (OMX_COMPONENTTYPE *)malloc(sizeof(OMX_COMPONENTTYPE));
      if (!pComp)
      {
         vcos_assert(0);
         return OMX_ErrorInsufficientResources;
      }
      memset(pComp, 0, sizeof(OMX_COMPONENTTYPE));
      hHandle = (OMX_HANDLETYPE)pComp;
      pComp->nSize = sizeof(OMX_COMPONENTTYPE);
      pComp->nVersion.nVersion = OMX_VERSION;
      eError = vcil_out_create_component(ilcs_get_common(ilcs_service), hHandle, cComponentName);

      if (eError == OMX_ErrorNone) {
         // Check that all function pointers have been filled in.
         // All fields should be non-zero.
         int i;
         uint32_t *p = (uint32_t *) pComp;
         for(i=0; i<sizeof(OMX_COMPONENTTYPE)>>2; i++)
            if(*p++ == 0)
               eError = OMX_ErrorInvalidComponent;

         if(eError != OMX_ErrorNone && pComp->ComponentDeInit)
            pComp->ComponentDeInit(hHandle);
      }

      if (eError == OMX_ErrorNone) {
         eError = pComp->SetCallbacks(hHandle,pCallBacks,pAppData);
         if (eError != OMX_ErrorNone)
            pComp->ComponentDeInit(hHandle);
      }
      if (eError == OMX_ErrorNone) {
         *pHandle = hHandle;
      }
      else {
         *pHandle = NULL;
         free(pComp);
      }
   }

   if (eError == OMX_ErrorNone) {
      vcos_mutex_lock(&lock);
      nActiveHandles++;
      vcos_mutex_unlock(&lock);
   }

   return eError;
}
Ejemplo n.º 21
0
/******************************Public*Routine******************************\
* OMX_FreeHandle()
*
* Description:This method will unload the OMX component pointed by
* OMX_HANDLETYPE. It is the responsibility of the calling method to ensure that
* the Deinit method of the component has been called prior to unloading component
*
* Parameters:
* @param[in] hComponent the component to unload
*
* Returns:    OMX_NOERROR          Successful
*
* Note
*
\**************************************************************************/
OMX_ERRORTYPE OMX_FreeHandle (OMX_HANDLETYPE hComponent)
{
	OMX_ERRORTYPE retVal = OMX_ErrorUndefined;
	OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)hComponent;
	OMX_U32 refIndex = 0;
	OMX_S32 handleIndex = 0;
	OMX_U32 i = 0;

	if(pthread_mutex_lock(&g_Mutex) != 0)
	{
		DEBUG_PRINT_ERROR("%s :: Core: Error in Mutex lock\n", __func__);
		return OMX_ErrorUndefined;
	}

	/* Locate the component handle in the array of handles */
	for(i = 0; i < COUNTOF(pModules); i++)
	{
		if(pComponents[i] == hComponent)
        {      
			break;
        }
	}

	if(i == COUNTOF(pModules))
	{
		DEBUG_PRINT_ERROR("%s :: Core: component %p is not found\n", __func__, hComponent);
		retVal = OMX_ErrorBadParameter;
		goto EXIT;
	}

	/* call component deinit method */
	retVal = pHandle->ComponentDeInit(hComponent);
	if (retVal != OMX_ErrorNone)
	{
		DEBUG_PRINT_ERROR("%s :: ComponentDeInit failed %d\n", __func__, retVal);
		goto EXIT;
	}

	for (refIndex=0; refIndex < MAX_TABLE_SIZE; refIndex++)
	{
		for (handleIndex=0; handleIndex < g_ComponentTable[refIndex].refCount; handleIndex++)
		{
			/* get the position for the component in the table */
			if (g_ComponentTable[refIndex].pHandle[handleIndex] == hComponent)
			{
				if (g_ComponentTable[refIndex].refCount)
				{
					g_ComponentTable[refIndex].refCount -= 1;
				}
				g_ComponentTable[refIndex].pHandle[handleIndex] = NULL;

#ifdef DYNAMIC_LOAD
				dlclose(pModules[i]);
#endif
				pModules[i] = NULL;
				free(pComponents[i]);
				pComponents[i] = NULL;
				retVal = OMX_ErrorNone;

				goto EXIT;
			}
		}
	}

	// If we are here, we have not found the matching component
	retVal = OMX_ErrorComponentNotFound;

EXIT:
	/* The unload is now complete, so set the error code to pass and exit */
	if(pthread_mutex_unlock(&g_Mutex) != 0)
	{
		DEBUG_PRINT_ERROR("%s :: Core: Error in Mutex unlock\n", __func__);
		return OMX_ErrorUndefined;
	}

	return retVal;
}