khronosfws/openmax_al/src/engine/xaengine.c
changeset 16 43d09473c595
parent 12 5a06f39ad45b
child 25 6f7ceef7b1d1
equal deleted inserted replaced
14:80975da52420 16:43d09473c595
    33 #include "xavideoencodercapabilitiesitf.h"
    33 #include "xavideoencodercapabilitiesitf.h"
    34 #include "xacameracapabilitiesitf.h"
    34 #include "xacameracapabilitiesitf.h"
    35 #include "xadevicevolumeitf.h"
    35 #include "xadevicevolumeitf.h"
    36 #include "xaconfigextensionsitf.h"
    36 #include "xaconfigextensionsitf.h"
    37 #include "xathreadsafety.h"
    37 #include "xathreadsafety.h"
    38 #ifdef _GSTREAMER_BACKEND_  
    38 #include "xaframeworkmgr.h"  
    39 #include "XAStaticCameraCapsAdaptation.h"
    39 #include "xastaticcameracapsadaptation.h"
    40 #endif
    40 
       
    41 
    41 /* Static mapping of enumeration XAEngineInterfaces to interface iids */
    42 /* Static mapping of enumeration XAEngineInterfaces to interface iids */
    42 static const XAInterfaceID* xaEngineItfIIDs[ENGINE_ITFCOUNT]={
    43 static const XAInterfaceID* xaEngineItfIIDs[ENGINE_ITFCOUNT]={
    43     &XA_IID_OBJECT,
    44     &XA_IID_OBJECT,
    44     &XA_IID_ENGINE,
    45     &XA_IID_ENGINE,
    45     &XA_IID_DYNAMICINTERFACEMANAGEMENT,
    46     &XA_IID_DYNAMICINTERFACEMANAGEMENT,
    46     &XA_IID_THREADSYNC,
    47     &XA_IID_THREADSYNC,
    47     &XA_IID_CONFIGEXTENSION,
    48 /*    &XA_IID_CONFIGEXTENSION,*/
    48     &XA_IID_DEVICEVOLUME,
    49 /*    &XA_IID_DEVICEVOLUME,*/
    49     &XA_IID_AUDIOIODEVICECAPABILITIES,
    50     &XA_IID_AUDIOIODEVICECAPABILITIES,
    50     &XA_IID_AUDIODECODERCAPABILITIES,
    51 /*    &XA_IID_AUDIODECODERCAPABILITIES,*/
    51     &XA_IID_AUDIOENCODERCAPABILITIES,
    52     &XA_IID_AUDIOENCODERCAPABILITIES
       
    53 /*
    52     &XA_IID_CAMERACAPABILITIES,
    54     &XA_IID_CAMERACAPABILITIES,
    53     &XA_IID_IMAGEDECODERCAPABILITIES,
    55     &XA_IID_IMAGEDECODERCAPABILITIES,
    54     &XA_IID_IMAGEENCODERCAPABILITIES,
    56     &XA_IID_IMAGEENCODERCAPABILITIES,
    55     &XA_IID_VIDEODECODERCAPABILITIES,
    57     &XA_IID_VIDEODECODERCAPABILITIES,
    56     &XA_IID_VIDEOENCODERCAPABILITIES
    58     &XA_IID_VIDEOENCODERCAPABILITIES
       
    59 */
    57 };
    60 };
    58 
    61 
    59 /*****************************************************************************
    62 /*****************************************************************************
    60  * Global methods
    63  * Global methods
    61  *****************************************************************************/
    64  *****************************************************************************/
   171         {
   174         {
   172             DEBUG_INFO_A1("Unable to initialize thread safety - ret:%x", ret );
   175             DEBUG_INFO_A1("Unable to initialize thread safety - ret:%x", ret );
   173         }
   176         }
   174     }
   177     }
   175 
   178 
   176 #ifdef _GSTREAMER_BACKEND_  
   179 /*
       
   180   
   177     pImpl->adaptationCtx = XAEngineAdapt_Create();
   181     pImpl->adaptationCtx = XAEngineAdapt_Create();
   178 #endif
   182 
       
   183 */
   179     /* Set ObjectItf to point to newly created object */
   184     /* Set ObjectItf to point to newly created object */
   180     *pEngine = ((XAObjectItf)&(pBaseObj->self));
   185     *pEngine = ((XAObjectItf)&(pBaseObj->self));
   181 
   186 
   182     DEBUG_API("<-XAEngineImpl_Create");
   187     DEBUG_API("<-XAEngineImpl_Create");
   183     return XA_RESULT_SUCCESS;
   188     return XA_RESULT_SUCCESS;
   255         DEBUG_API("<-XAEngineImpl_DoRealize");
   260         DEBUG_API("<-XAEngineImpl_DoRealize");
   256         /* invalid parameter */
   261         /* invalid parameter */
   257         return XA_RESULT_PARAMETER_INVALID;
   262         return XA_RESULT_PARAMETER_INVALID;
   258     }
   263     }
   259 
   264 
   260 #ifdef _GSTREAMER_BACKEND_  
   265    
   261     ret = XAEngineAdapt_PostInit( pObjImpl->adaptationCtx );
   266     /* Table containing use-case framework map */
   262 #endif
   267     pObjImpl->frameworkMap = XAFrameworkMgr_CreateFrameworkMap();
   263     if( ret != XA_RESULT_SUCCESS )
   268     if (pObjImpl->frameworkMap == NULL)
   264     {
   269     {
   265         DEBUG_ERR_A1("Engine postinit failed - %d", ret);
   270         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
   266         DEBUG_API("<-XAEngineImpl_DoRealize");
   271         DEBUG_API("<-XAEngineImpl_DoRealize");
       
   272         /* memory allocation failed */
       
   273         return XA_RESULT_MEMORY_FAILURE;
       
   274     }
       
   275 
       
   276 
       
   277     /* Create capabilities list */
       
   278     ret = XACapabilitiesMgr_CreateCapabilitieList(pObjImpl->frameworkMap, &(pObjImpl->capabilities));
       
   279     if (ret != XA_RESULT_SUCCESS)
       
   280         {
   267         return ret;
   281         return ret;
   268     }
   282         }
   269 
   283 
   270     ret = XAEngineAdaptMMF_PostInit( pObjImpl->adaptationMmfCtx );
   284 
   271     if( ret != XA_RESULT_SUCCESS )
       
   272     {
       
   273         DEBUG_ERR_A1("Engine postinit failed (MMF) - %d", ret);
       
   274         DEBUG_API("<-XAEngineImpl_DoRealize");
       
   275         return ret;
       
   276     }
       
   277     /* Realize all implicit and explicitly wanted interfaces */
   285     /* Realize all implicit and explicitly wanted interfaces */
   278     for(itfIdx=0; itfIdx<ENGINE_ITFCOUNT; itfIdx++)
   286     for(itfIdx=0; itfIdx<ENGINE_ITFCOUNT; itfIdx++)
   279     {
   287     {
   280         if(!(pObj->interfaceMap[itfIdx].pItf) &&
   288         if(!(pObj->interfaceMap[itfIdx].pItf) &&
   281            pObj->interfaceMap[itfIdx].required )
   289            pObj->interfaceMap[itfIdx].required )
   282         {
   290         {
   283             void *pItf = NULL;
   291             void *pItf = NULL;
   284             switch(itfIdx)
   292             switch(itfIdx)
   285             {
   293             {
   286                 case ENGINE_ENGINEITF:
   294                 case ENGINE_ENGINEITF:
   287                     pItf = XAEngineItfImpl_Create();
   295                     pItf = XAEngineItfImpl_Create(pObjImpl->frameworkMap, pObjImpl->capabilities);
   288                     break;
   296                     break;
   289                 case ENGINE_THREADSYNCITF:
   297                 case ENGINE_THREADSYNCITF:
   290                     pItf = XAThreadSyncItfImpl_Create();
   298                     pItf = XAThreadSyncItfImpl_Create();
   291                     break;
   299                     break;
   292                 case ENGINE_DIMITF:
   300                 case ENGINE_DIMITF:
   293                     pItf = XADIMItfImpl_Create();
   301                     pItf = XADIMItfImpl_Create();
   294                     break;
   302                     break;
   295                 case ENGINE_AUDIOIODEVICECAPAITF:
   303                 case ENGINE_AUDIOIODEVICECAPAITF:
   296                     pItf = XAAudIODevCapaItfImpl_Create();
   304                     pItf = XAAudIODevCapaItfImpl_Create(pObjImpl->capabilities);
   297                     break;
   305                     break;
   298                 case ENGINE_AUDIOENCODERCAPAITF:
   306                 case ENGINE_AUDIOENCODERCAPAITF:
   299                     pItf = XAAudioEncoderCapabilitiesItfImpl_Create();
   307                     pItf = XAAudioEncoderCapabilitiesItfImpl_Create(pObjImpl->capabilities);
   300                     break;
   308                     break;
       
   309 /*
   301                 case ENGINE_AUDIODECODERCAPAITF:
   310                 case ENGINE_AUDIODECODERCAPAITF:
   302                     pItf = XAAudioDecoderCapabilitiesItfImpl_Create();
   311                     pItf = XAAudioDecoderCapabilitiesItfImpl_Create();
   303                     break;
   312                     break;
   304                 case ENGINE_CONFIGEXTENSIONSITF:
   313                 case ENGINE_CONFIGEXTENSIONSITF:
   305                     pItf = XAConfigExtensionsItfImpl_Create();
   314                     pItf = XAConfigExtensionsItfImpl_Create();
   306                     break;
   315                     break;
   307                 case ENGINE_DEVICEVOLUMEITF:
   316                 case ENGINE_DEVICEVOLUMEITF:
   308 #ifdef _GSTREAMER_BACKEND_  
       
   309                     pItf = XADeviceVolumeItfImpl_Create(pObjImpl->adaptationCtx);
   317                     pItf = XADeviceVolumeItfImpl_Create(pObjImpl->adaptationCtx);
   310 #endif
       
   311                     break;
   318                     break;
   312                 case ENGINE_CAMERACAPAITF:
   319                 case ENGINE_CAMERACAPAITF:
   313 #ifdef _GSTREAMER_BACKEND_
   320 
   314                     XAStaticCameraCaps_Init();
   321                     XAStaticCameraCaps_Init();
   315                     pItf = XACameraCapabilitiesItfImpl_Create();
   322                     pItf = XACameraCapabilitiesItfImpl_Create();
   316 #endif                    
   323                     
   317                     break;
   324                     break;
   318                 case ENGINE_IMAGEDECODERCAPAITF:
   325                 case ENGINE_IMAGEDECODERCAPAITF:
   319                     pItf = XAImageDecoderCapabilitiesItfImpl_Create();
   326                     pItf = XAImageDecoderCapabilitiesItfImpl_Create();
   320                     break;
   327                     break;
   321                 case ENGINE_IMAGEENCODERCAPAITF:
   328                 case ENGINE_IMAGEENCODERCAPAITF:
   325                     pItf = XAVideoDecoderCapabilitiesItfImpl_Create();
   332                     pItf = XAVideoDecoderCapabilitiesItfImpl_Create();
   326                     break;
   333                     break;
   327                 case ENGINE_VIDEOENCODERCAPAITF:
   334                 case ENGINE_VIDEOENCODERCAPAITF:
   328                     pItf = XAVideoEncoderCapabilitiesItfImpl_Create();
   335                     pItf = XAVideoEncoderCapabilitiesItfImpl_Create();
   329                     break;
   336                     break;
       
   337 */
   330                 default:
   338                 default:
   331                     break;
   339                     break;
   332             }
   340             }
   333             if(!pItf)
   341             if(!pItf)
   334             {
   342             {
   392                     XAAudIODevCapaItfImpl_Free(pItf);
   400                     XAAudIODevCapaItfImpl_Free(pItf);
   393                     break;
   401                     break;
   394                 case ENGINE_AUDIOENCODERCAPAITF:
   402                 case ENGINE_AUDIOENCODERCAPAITF:
   395                     XAAudioEncoderCapabilitiesItfImpl_Free(pItf);
   403                     XAAudioEncoderCapabilitiesItfImpl_Free(pItf);
   396                     break;
   404                     break;
       
   405 /*
   397                 case ENGINE_AUDIODECODERCAPAITF:
   406                 case ENGINE_AUDIODECODERCAPAITF:
   398                     XAAudioDecoderCapabilitiesItfImpl_Free(pItf);
   407                     XAAudioDecoderCapabilitiesItfImpl_Free(pItf);
   399                     break;
   408                     break;
   400                 case ENGINE_CONFIGEXTENSIONSITF:
   409                 case ENGINE_CONFIGEXTENSIONSITF:
   401                     XAConfigExtensionsItfImpl_Free(pItf);
   410                     XAConfigExtensionsItfImpl_Free(pItf);
   402                     break;
   411                     break;
   403                 case ENGINE_DEVICEVOLUMEITF:
   412                 case ENGINE_DEVICEVOLUMEITF:
   404                     XADeviceVolumeItfImpl_Free(pItf);
   413                     XADeviceVolumeItfImpl_Free(pItf);
   405                     break;
   414                     break;
   406                 case ENGINE_CAMERACAPAITF:
   415                 case ENGINE_CAMERACAPAITF:
   407 #ifdef _GSTREAMER_BACKEND_
   416 
   408                     XACameraCapabilitiesItfImpl_Free(pItf);
   417                     XACameraCapabilitiesItfImpl_Free(pItf);
   409 #endif                    
   418                     
   410                     break;
   419                     break;
   411                 case ENGINE_IMAGEDECODERCAPAITF:
   420                 case ENGINE_IMAGEDECODERCAPAITF:
   412                     XAImageDecoderCapabilitiesItfImpl_Free(pItf);
   421                     XAImageDecoderCapabilitiesItfImpl_Free(pItf);
   413                     break;
   422                     break;
   414                 case ENGINE_IMAGEENCODERCAPAITF:
   423                 case ENGINE_IMAGEENCODERCAPAITF:
   418                     XAVideoDecoderCapabilitiesItfImpl_Free(pItf);
   427                     XAVideoDecoderCapabilitiesItfImpl_Free(pItf);
   419                     break;
   428                     break;
   420                 case ENGINE_VIDEOENCODERCAPAITF:
   429                 case ENGINE_VIDEOENCODERCAPAITF:
   421                     XAVideoEncoderCapabilitiesItfImpl_Free(pItf);
   430                     XAVideoEncoderCapabilitiesItfImpl_Free(pItf);
   422                     break;
   431                     break;
       
   432 */
   423                 default:
   433                 default:
   424                     break;
   434                     break;
   425             }
   435             }
   426             pObj->interfaceMap[itfIdx].pItf = NULL;
   436             pObj->interfaceMap[itfIdx].pItf = NULL;
   427         }
   437         }
   428     }
   438     }
   429 
   439 
   430     /* free all other allocated resources*/
   440     /* free all other allocated resources*/
   431 #ifdef _GSTREAMER_BACKEND_  
   441 /*  
   432     if ( pImpl->adaptationCtx != NULL )
   442     if ( pImpl->adaptationCtx != NULL )
   433     {
   443     {
   434         XAEngineAdapt_Destroy( pImpl->adaptationCtx );
   444         XAEngineAdapt_Destroy( pImpl->adaptationCtx );
   435         pImpl->adaptationCtx = NULL;
   445         pImpl->adaptationCtx = NULL;
   436     }
   446     }
   437 #endif    
   447     
   438     if ( pImpl->adaptationMmfCtx != NULL )
   448     if ( pImpl->adaptationMmfCtx != NULL )
   439     {
   449     {
   440         XAEngineAdaptMMF_Destroy( pImpl->adaptationMmfCtx );
   450         XAEngineAdaptMMF_Destroy( pImpl->adaptationMmfCtx );
   441         pImpl->adaptationMmfCtx = NULL;
   451         pImpl->adaptationMmfCtx = NULL;
   442     }
   452     }*/
   443 
   453     /* free framework map */
   444     XAThreadSafety_Destroy();
   454     XAFrameworkMgr_DeleteFrameworkMap(&pImpl->frameworkMap);
       
   455     
       
   456     /* TODO free capabilities list */
       
   457     XACapabilitiesMgr_DeleteCapabilitieList(&pImpl->capabilities);
       
   458     
       
   459      XAThreadSafety_Destroy();
   445 
   460 
   446     DEBUG_API("<-XAEngineImpl_FreeResources");
   461     DEBUG_API("<-XAEngineImpl_FreeResources");
   447     return;
   462     return;
   448 }
   463 }
   449 
   464