khronosfws/openmax_al/src/engine/xaengineitf.c
changeset 16 43d09473c595
parent 12 5a06f39ad45b
child 21 2ed61feeead6
child 31 8dfd592727cb
equal deleted inserted replaced
14:80975da52420 16:43d09473c595
    19 #include <stdlib.h>
    19 #include <stdlib.h>
    20 #include <assert.h>
    20 #include <assert.h>
    21 #include "xaengineitf.h"
    21 #include "xaengineitf.h"
    22 #include "xavibraitf.h"
    22 #include "xavibraitf.h"
    23 #include "xaledarrayitf.h"
    23 #include "xaledarrayitf.h"
    24 #ifdef _GSTREAMER_BACKEND_  
    24 #include "xaobjects.h"
    25 #include "XAStaticCapsAdaptation.h"
    25 #include "xacapabilitiesmgr.h"
    26 #endif
       
    27 
       
    28 /*static XAchar implementationText[] = "Implementation does not conform to AL Spec";*/
    26 /*static XAchar implementationText[] = "Implementation does not conform to AL Spec";*/
    29 
    27 
    30 
    28 /**
       
    29  * XAEngineItfImpl* GetImpl(XAEngineItf self)
       
    30  * Description: Validate interface pointer and cast it to implementation pointer.
       
    31  **/
       
    32 static XAEngineItfImpl* GetImpl(XAEngineItf self)
       
    33 {
       
    34     if( self )
       
    35     {
       
    36         XAEngineItfImpl* impl = (XAEngineItfImpl*)(*self);
       
    37         if( impl && (impl == impl->self) )
       
    38         {
       
    39             return impl;
       
    40         }
       
    41     }
       
    42     return NULL;
       
    43 }
    31 /**
    44 /**
    32  * Base interface XAEngineItf implementation
    45  * Base interface XAEngineItf implementation
    33  */
    46  */
    34 XAresult XAEngineItfImpl_CreateCameraDevice(XAEngineItf self,
    47 XAresult XAEngineItfImpl_CreateCameraDevice(XAEngineItf self,
    35                                             XAObjectItf *pDevice,
    48                                             XAObjectItf *pDevice,
    36                                             XAuint32 deviceID,
    49                                             XAuint32 deviceID,
    37                                             XAuint32 numInterfaces,
    50                                             XAuint32 numInterfaces,
    38                                             const XAInterfaceID *pInterfaceIds,
    51                                             const XAInterfaceID *pInterfaceIds,
    39                                             const XAboolean *pInterfaceRequired)
    52                                             const XAboolean *pInterfaceRequired)
    40 {
    53 {
    41     return XACameraDeviceImpl_CreateCameraDevice( pDevice, deviceID,numInterfaces,
    54     XAEngineItfImpl* impl = GetImpl(self);
    42                                                   pInterfaceIds, pInterfaceRequired );
    55     return XACameraDeviceImpl_CreateCameraDevice( impl->mapper,impl->capabilities,
       
    56                                                     pDevice, deviceID,numInterfaces,
       
    57                                                     pInterfaceIds, pInterfaceRequired );
    43 }
    58 }
    44 
    59 
    45 XAresult XAEngineItfImpl_CreateRadioDevice(XAEngineItf self,
    60 XAresult XAEngineItfImpl_CreateRadioDevice(XAEngineItf self,
    46                                             XAObjectItf *pDevice,
    61                                             XAObjectItf *pDevice,
    47                                             XAuint32 numInterfaces,
    62                                             XAuint32 numInterfaces,
    48                                             const XAInterfaceID *pInterfaceIds,
    63                                             const XAInterfaceID *pInterfaceIds,
    49                                             const XAboolean *pInterfaceRequired)
    64                                             const XAboolean *pInterfaceRequired)
    50 {
    65 {
    51     return XARadioDeviceImpl_CreateRadioDevice( pDevice, numInterfaces,
    66     return XARadioDeviceImpl_CreateRadioDevice( ((XAEngineItfImpl*)self)->mapper,
       
    67                                                 pDevice, numInterfaces,
    52                                                 pInterfaceIds, pInterfaceRequired );
    68                                                 pInterfaceIds, pInterfaceRequired );
    53 }
    69 }
    54 
    70 
    55 XAresult XAEngineItfImpl_CreateLEDDevice(XAEngineItf self,
    71 XAresult XAEngineItfImpl_CreateLEDDevice(XAEngineItf self,
    56                                          XAObjectItf *pDevice,
    72                                          XAObjectItf *pDevice,
    57                                          XAuint32 deviceID,
    73                                          XAuint32 deviceID,
    58                                          XAuint32 numInterfaces,
    74                                          XAuint32 numInterfaces,
    59                                          const XAInterfaceID *pInterfaceIds,
    75                                          const XAInterfaceID *pInterfaceIds,
    60                                          const XAboolean *pInterfaceRequired)
    76                                          const XAboolean *pInterfaceRequired)
    61 {
    77 {
    62     return XALEDArrayDeviceImpl_CreateLEDArrayDevice( pDevice, deviceID, numInterfaces,
    78     return XALEDArrayDeviceImpl_CreateLEDArrayDevice( ((XAEngineItfImpl*)self)->mapper,
    63                                                       pInterfaceIds, pInterfaceRequired );
    79                                                         pDevice, deviceID, numInterfaces,
       
    80                                                         pInterfaceIds, pInterfaceRequired );
    64 }
    81 }
    65 
    82 
    66 XAresult XAEngineItfImpl_CreateVibraDevice(XAEngineItf self,
    83 XAresult XAEngineItfImpl_CreateVibraDevice(XAEngineItf self,
    67                                            XAObjectItf *pDevice,
    84                                            XAObjectItf *pDevice,
    68                                            XAuint32 deviceID,
    85                                            XAuint32 deviceID,
    69                                            XAuint32 numInterfaces,
    86                                            XAuint32 numInterfaces,
    70                                            const XAInterfaceID *pInterfaceIds,
    87                                            const XAInterfaceID *pInterfaceIds,
    71                                            const XAboolean *pInterfaceRequired)
    88                                            const XAboolean *pInterfaceRequired)
    72 {
    89 {
    73     return XAVibraDeviceImpl_CreateVibraDevice( pDevice, deviceID, numInterfaces,
    90     return XAVibraDeviceImpl_CreateVibraDevice( ((XAEngineItfImpl*)self)->mapper,
       
    91                                                 pDevice, deviceID, numInterfaces,
    74                                                 pInterfaceIds, pInterfaceRequired);
    92                                                 pInterfaceIds, pInterfaceRequired);
    75 }
    93 }
    76 
    94 
    77 XAresult XAEngineItfImpl_CreateMediaPlayer(XAEngineItf self,
    95 XAresult XAEngineItfImpl_CreateMediaPlayer(XAEngineItf self,
    78                                            XAObjectItf *pPlayer,
    96                                            XAObjectItf *pPlayer,
    84                                            XADataSink *pLEDArray,
   102                                            XADataSink *pLEDArray,
    85                                            XAuint32 numInterfaces,
   103                                            XAuint32 numInterfaces,
    86                                            const XAInterfaceID *pInterfaceIds,
   104                                            const XAInterfaceID *pInterfaceIds,
    87                                            const XAboolean *pInterfaceRequired)
   105                                            const XAboolean *pInterfaceRequired)
    88 {
   106 {
    89     return XAMediaPlayerImpl_CreateMediaPlayer(pPlayer, pDataSrc, pBankSrc, pAudioSnk,
   107     XAEngineItfImpl* impl = GetImpl(self);
       
   108     return XAMediaPlayerImpl_CreateMediaPlayer(impl->mapper,impl->capabilities, pPlayer, 
       
   109                                              pDataSrc, pBankSrc, pAudioSnk,
    90                                              pImageVideoSnk, pVibra, pLEDArray,
   110                                              pImageVideoSnk, pVibra, pLEDArray,
    91                                              numInterfaces, pInterfaceIds, pInterfaceRequired);
   111                                              numInterfaces, pInterfaceIds, pInterfaceRequired);
    92 }
   112 }
    93 
   113 
    94 XAresult XAEngineItfImpl_CreateMediaRecorder(XAEngineItf self,
   114 XAresult XAEngineItfImpl_CreateMediaRecorder(XAEngineItf self,
    97                                              XADataSource * pImageVideoSrc,
   117                                              XADataSource * pImageVideoSrc,
    98                                              XADataSink * pDataSnk,
   118                                              XADataSink * pDataSnk,
    99                                              XAuint32 numInterfaces,
   119                                              XAuint32 numInterfaces,
   100                                              const XAInterfaceID * pInterfaceIds,
   120                                              const XAInterfaceID * pInterfaceIds,
   101                                              const XAboolean * pInterfaceRequired)
   121                                              const XAboolean * pInterfaceRequired)
   102 {
   122 {    
   103     return XAMediaRecorderImpl_CreateMediaRecorder(pRecorder, pAudioSrc, pImageVideoSrc, pDataSnk,
   123     XAEngineItfImpl* impl = GetImpl(self);
   104                                                    numInterfaces, pInterfaceIds, pInterfaceRequired);
   124     return XAMediaRecorderImpl_CreateMediaRecorder(impl->mapper,
       
   125                                                    impl->capabilities,
       
   126                                                    pRecorder,
       
   127                                                    pAudioSrc,
       
   128                                                    pImageVideoSrc,
       
   129                                                    pDataSnk,
       
   130                                                    numInterfaces,
       
   131                                                    pInterfaceIds,
       
   132                                                    pInterfaceRequired);
   105 }
   133 }
   106 
   134 
   107 XAresult XAEngineItfImpl_CreateOutputMix(XAEngineItf self,
   135 XAresult XAEngineItfImpl_CreateOutputMix(XAEngineItf self,
   108                                          XAObjectItf *pMix,
   136                                          XAObjectItf *pMix,
   109                                          XAuint32 numInterfaces,
   137                                          XAuint32 numInterfaces,
   110                                          const XAInterfaceID *pInterfaceIds,
   138                                          const XAInterfaceID *pInterfaceIds,
   111                                          const XAboolean *pInterfaceRequired)
   139                                          const XAboolean *pInterfaceRequired)
   112 {
   140 {
   113     return XAOMixImpl_CreateOutputMix(pMix, numInterfaces,
   141     XAEngineItfImpl* impl = GetImpl(self);
   114                                       pInterfaceIds, pInterfaceRequired);
   142     return XAOMixImpl_CreateOutputMix(impl->mapper,impl->capabilities,
       
   143                                         pMix, numInterfaces,
       
   144                                         pInterfaceIds, pInterfaceRequired);
   115 }
   145 }
   116 
   146 
   117 XAresult XAEngineItfImpl_CreateMetadataExtractor(XAEngineItf self,
   147 XAresult XAEngineItfImpl_CreateMetadataExtractor(XAEngineItf self,
   118                                                  XAObjectItf *pMetadataExtractor,
   148                                                  XAObjectItf *pMetadataExtractor,
   119                                                  XADataSource *pDataSource,
   149                                                  XADataSource *pDataSource,
   120                                                  XAuint32 numInterfaces,
   150                                                  XAuint32 numInterfaces,
   121                                                  const XAInterfaceID *pInterfaceIds,
   151                                                  const XAInterfaceID *pInterfaceIds,
   122                                                  const XAboolean *pInterfaceRequired)
   152                                                  const XAboolean *pInterfaceRequired)
   123 {
   153 {
   124     return XAMetadataExtractorImpl_Create(pMetadataExtractor, pDataSource,
   154     XAEngineItfImpl* impl = GetImpl(self);
   125                                           numInterfaces, pInterfaceIds, pInterfaceRequired);
   155     return XAMetadataExtractorImpl_Create(impl->mapper, impl->capabilities,
       
   156                                             pMetadataExtractor, pDataSource,
       
   157                                             numInterfaces, pInterfaceIds, pInterfaceRequired);
   126 }
   158 }
   127 
   159 
   128 XAresult XAEngineItfImpl_CreateExtensionObject(XAEngineItf self,
   160 XAresult XAEngineItfImpl_CreateExtensionObject(XAEngineItf self,
   129                                                XAObjectItf *pObject,
   161                                                XAObjectItf *pObject,
   130                                                void *pParameters,
   162                                                void *pParameters,
   310 XAresult XAEngineItfImpl_QueryLEDCapabilities(XAEngineItf self,
   342 XAresult XAEngineItfImpl_QueryLEDCapabilities(XAEngineItf self,
   311                                               XAuint32 *pIndex,
   343                                               XAuint32 *pIndex,
   312                                               XAuint32 *pLEDDeviceID,
   344                                               XAuint32 *pLEDDeviceID,
   313                                               XALEDDescriptor *pDescriptor)
   345                                               XALEDDescriptor *pDescriptor)
   314 {
   346 {
   315 #ifdef _GSTREAMER_BACKEND_  
   347   
   316     XALEDDescriptor descriptor;
   348     XALEDDescriptor descriptor;
   317 #endif    
   349     
   318     DEBUG_API("->XAEngineItfImpl_QueryLEDCapabilities");
   350     DEBUG_API("->XAEngineItfImpl_QueryLEDCapabilities");
   319 
   351 
   320     if( !pDescriptor )
   352     if( !pDescriptor )
   321     {   /*query number of devices*/
   353     {   /*query number of devices*/
   322         if( !pIndex )
   354         if( !pIndex )
   328         /* Number of devices */
   360         /* Number of devices */
   329         *pIndex = 1;
   361         *pIndex = 1;
   330     }
   362     }
   331     else
   363     else
   332     {   
   364     {   
   333 #ifdef _GSTREAMER_BACKEND_  
   365   
   334         /* query device capabilities */
   366         /* query device capabilities */
   335         if( pIndex )
   367         if( pIndex )
   336         {
   368         {
   337             if( *pIndex == 0 )
   369             if( *pIndex == 0 )
   338             {
   370             {
   357             descriptor.colorMask = COLOR_MASK;
   389             descriptor.colorMask = COLOR_MASK;
   358             descriptor.ledCount = LED_COUNT;
   390             descriptor.ledCount = LED_COUNT;
   359             descriptor.primaryLED = PRIMARY_LED;
   391             descriptor.primaryLED = PRIMARY_LED;
   360             *pDescriptor = descriptor;
   392             *pDescriptor = descriptor;
   361         }
   393         }
   362 #endif        
   394         
   363     }
   395     }
   364     DEBUG_API("<-XAEngineItfImpl_QueryLEDCapabilities");
   396     DEBUG_API("<-XAEngineItfImpl_QueryLEDCapabilities");
   365     return XA_RESULT_SUCCESS;
   397     return XA_RESULT_SUCCESS;
   366 }
   398 }
   367 
   399 
   368 XAresult XAEngineItfImpl_QueryVibraCapabilities(XAEngineItf self,
   400 XAresult XAEngineItfImpl_QueryVibraCapabilities(XAEngineItf self,
   369                                                 XAuint32 *pIndex,
   401                                                 XAuint32 *pIndex,
   370                                                 XAuint32 *pVibraDeviceID,
   402                                                 XAuint32 *pVibraDeviceID,
   371                                                 XAVibraDescriptor *pDescriptor)
   403                                                 XAVibraDescriptor *pDescriptor)
   372 {
   404 {
   373 #ifdef _GSTREAMER_BACKEND_  
   405   
   374     XAVibraDescriptor descriptor;
   406     XAVibraDescriptor descriptor;
   375 #endif
   407 
   376     DEBUG_API("->XAEngineItfImpl_QueryVibraCapabilities");
   408     DEBUG_API("->XAEngineItfImpl_QueryVibraCapabilities");
   377 
   409 
   378     if( !pDescriptor  )
   410     if( !pDescriptor  )
   379     {   /*query number of devices*/
   411     {   /*query number of devices*/
   380         if( !pIndex )
   412         if( !pIndex )
   386         /* Number of devices */
   418         /* Number of devices */
   387         *pIndex = 1;
   419         *pIndex = 1;
   388     }
   420     }
   389     else
   421     else
   390     {   
   422     {   
   391 #ifdef _GSTREAMER_BACKEND_  
   423   
   392         /* query device capabilities */
   424         /* query device capabilities */
   393         if( pIndex )
   425         if( pIndex )
   394         {
   426         {
   395             if( *pIndex == 0 )
   427             if( *pIndex == 0 )
   396             {
   428             {
   417             descriptor.maxFrequency = MAX_FREQUENCY;
   449             descriptor.maxFrequency = MAX_FREQUENCY;
   418             descriptor.supportsFrequency = XA_BOOLEAN_TRUE;
   450             descriptor.supportsFrequency = XA_BOOLEAN_TRUE;
   419             descriptor.supportsIntensity = XA_BOOLEAN_TRUE;
   451             descriptor.supportsIntensity = XA_BOOLEAN_TRUE;
   420             *pDescriptor = descriptor;
   452             *pDescriptor = descriptor;
   421         }
   453         }
   422 #endif        
   454         
   423     }
   455     }
   424 
   456 
   425     DEBUG_API("<-XAEngineItfImpl_QueryVibraCapabilities");
   457     DEBUG_API("<-XAEngineItfImpl_QueryVibraCapabilities");
   426     return XA_RESULT_SUCCESS;
   458     return XA_RESULT_SUCCESS;
   427 }
   459 }
   472 }
   504 }
   473 
   505 
   474 /**
   506 /**
   475  * XAEngineItfImpl -specific methods
   507  * XAEngineItfImpl -specific methods
   476  **/
   508  **/
   477 XAEngineItfImpl* XAEngineItfImpl_Create()
   509 XAEngineItfImpl* XAEngineItfImpl_Create(FrameworkMap* fwkmapper, XACapabilities* capabilities)
   478 {
   510 {
   479     XAEngineItfImpl* self = (XAEngineItfImpl*)
   511     XAEngineItfImpl* self = (XAEngineItfImpl*)
   480         calloc(1,sizeof(XAEngineItfImpl));
   512         calloc(1,sizeof(XAEngineItfImpl));
   481     DEBUG_API("->XAEngineItfImpl_Create");
   513     DEBUG_API("->XAEngineItfImpl_Create");
   482 
   514 
   499         self->itf.QueryLEDCapabilities = XAEngineItfImpl_QueryLEDCapabilities;
   531         self->itf.QueryLEDCapabilities = XAEngineItfImpl_QueryLEDCapabilities;
   500         self->itf.QueryVibraCapabilities = XAEngineItfImpl_QueryVibraCapabilities;
   532         self->itf.QueryVibraCapabilities = XAEngineItfImpl_QueryVibraCapabilities;
   501         self->itf.QueryNumSupportedExtensions = XAEngineItfImpl_QueryNumSupportedExtensions;
   533         self->itf.QueryNumSupportedExtensions = XAEngineItfImpl_QueryNumSupportedExtensions;
   502         self->itf.QuerySupportedExtension = XAEngineItfImpl_QuerySupportedExtension;
   534         self->itf.QuerySupportedExtension = XAEngineItfImpl_QuerySupportedExtension;
   503         self->itf.IsExtensionSupported = XAEngineItfImpl_IsExtensionSupported;
   535         self->itf.IsExtensionSupported = XAEngineItfImpl_IsExtensionSupported;
       
   536         self->mapper = fwkmapper;
       
   537         self->capabilities = capabilities;
       
   538         self->xyz = 50;
   504         self->self = self;
   539         self->self = self;
   505     }
   540     }
   506     DEBUG_API("<-XAEngineItfImpl_Create");
   541     DEBUG_API("<-XAEngineItfImpl_Create");
   507     return self;
   542     return self;
   508 }
   543 }