khronosfws/openmax_al/src/mediaplayer/xamediaplayer.c
branchRCL_3
changeset 20 0ac9a5310753
parent 19 095bea5f582e
child 21 999b2818a0eb
equal deleted inserted replaced
19:095bea5f582e 20:0ac9a5310753
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: Media Player Object Implementation
       
    15  *
       
    16  */
       
    17 
       
    18 #include <stdio.h>
       
    19 #include <stdlib.h>
       
    20 #include <string.h>
       
    21 #include <assert.h>
       
    22 #include "xamediaplayer.h"
       
    23 #include "xaplayitf.h"
       
    24 #include "xaseekitf.h"
       
    25 #include "xaprefetchstatusitf.h"
       
    26 #include "xadynintmgmtitf.h"
       
    27 #include "xavolumeitf.h"
       
    28 #include "xametadataextractionitf.h"
       
    29 #include "xaplaybackrateitf.h"
       
    30 #include "xaconfigextensionsitf.h"
       
    31 #include "xathreadsafety.h"
       
    32 #include "xametadataadaptation.h"
       
    33 #include "xacapabilitiesmgr.h"
       
    34 #include "xadynamicsourceitf.h"
       
    35 #include "xastreaminformationitf.h"
       
    36 #include "xanlinearvolumeitf.h"
       
    37 #include "xanvolumeextitf.h"
       
    38 
       
    39 extern void* vfHandle;
       
    40 
       
    41 /* Static mapping of enumeration XAMediaPlayerInterfaces to interface iids */
       
    42 static const XAInterfaceID* xaMediaPlayerItfIIDs[MP_ITFCOUNT] =
       
    43     {
       
    44     &XA_IID_OBJECT,
       
    45     &XA_IID_DYNAMICINTERFACEMANAGEMENT,
       
    46     &XA_IID_PLAY,
       
    47     &XA_IID_SEEK,
       
    48     &XA_IID_VOLUME,
       
    49     &XA_IID_PREFETCHSTATUS,
       
    50     &XA_IID_CONFIGEXTENSION,
       
    51     &XA_IID_DYNAMICSOURCE,
       
    52     &XA_IID_METADATAEXTRACTION,
       
    53     &XA_IID_PLAYBACKRATE,
       
    54     &XA_IID_NOKIAVOLUMEEXT,
       
    55     &XA_IID_NOKIALINEARVOLUME,
       
    56     &XA_IID_STREAMINFORMATION
       
    57     };
       
    58 
       
    59 /* Global methods */
       
    60 
       
    61 /* XAResult XAMediaPlayerImpl_CreateMediaPlayer
       
    62  * Create object
       
    63  */
       
    64 XAresult XAMediaPlayerImpl_CreateMediaPlayer(FrameworkMap* mapper,
       
    65         XACapabilities* capabilities, XAObjectItf *pPlayer,
       
    66         XADataSource *pDataSrc, XADataSource *pBankSrc,
       
    67         XADataSink *pAudioSnk, XADataSink *pImageVideoSnk,
       
    68         XADataSink *pVibra, XADataSink *pLEDArray, XAuint32 numInterfaces,
       
    69         const XAInterfaceID *pInterfaceIds,
       
    70         const XAboolean *pInterfaceRequired)
       
    71     {
       
    72     XAuint8 itfIdx = 0;
       
    73     XAMediaType mediaType = XA_MEDIATYPE_UNKNOWN;
       
    74     XAMediaPlayerImpl* pPlayerImpl = NULL;
       
    75     FWMgrFwType fwType;
       
    76     XAObjectItfImpl* pBaseObj = NULL;
       
    77     const char *uri = NULL;
       
    78     XAresult ret = XA_RESULT_SUCCESS;
       
    79     XADataLocator_IODevice* tmpIODevice;
       
    80     XADataLocator_IODevice locatorIODevice;
       
    81 
       
    82     DEBUG_API("->XAMediaPlayerImpl_CreateMediaPlayer");
       
    83 
       
    84     XA_IMPL_THREAD_SAFETY_ENTRY(XATSMediaPlayer);
       
    85 
       
    86     if (!pPlayer || !pDataSrc)
       
    87         {
       
    88         XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaPlayer);
       
    89         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
    90         DEBUG_API("<-XAMediaPlayerImpl_CreateMediaPlayer");
       
    91         return XA_RESULT_PARAMETER_INVALID;
       
    92         }
       
    93     /* check sink&source parameters */
       
    94     ret = XACommon_ValidateDataLocator(6, pAudioSnk, pImageVideoSnk,
       
    95             pDataSrc, pBankSrc, pVibra, pLEDArray);
       
    96     if (ret != XA_RESULT_SUCCESS)
       
    97         {
       
    98         XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaPlayer);
       
    99         DEBUG_API("<-XAMediaPlayerImpl_CreateMediaPlayer");
       
   100         return ret;
       
   101         }
       
   102     /* also, check source availability */
       
   103     ret = XACommon_CheckDataSource(pDataSrc, &mediaType);
       
   104     if (ret != XA_RESULT_SUCCESS)
       
   105         {
       
   106         XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaPlayer);
       
   107         DEBUG_API("<-XAMediaPlayerImpl_CreateMediaPlayer");
       
   108         return ret;
       
   109         }
       
   110 
       
   111     /* instantiate object */
       
   112     pPlayerImpl = (XAMediaPlayerImpl*) calloc(1, sizeof(XAMediaPlayerImpl));
       
   113     if (!pPlayerImpl)
       
   114         {
       
   115         /* memory allocation failed */
       
   116         XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaPlayer);
       
   117         DEBUG_API("<-XAMediaPlayerImpl_CreateMediaPlayer");
       
   118         return XA_RESULT_MEMORY_FAILURE;
       
   119         }
       
   120     pBaseObj = &pPlayerImpl->baseObj;
       
   121 
       
   122     /* Initialize base object default implementation */
       
   123     XAObjectItfImpl_Init(pBaseObj, MP_ITFCOUNT, xaMediaPlayerItfIIDs,
       
   124             XAMediaPlayerImpl_DoRealize, XAMediaPlayerImpl_DoResume,
       
   125             XAMediaPlayerImpl_FreeResources);
       
   126 
       
   127     /* Mark interfaces that need to be exposed */
       
   128     /* Implicit and mandated interfaces */
       
   129     pBaseObj->interfaceMap[MP_PLAYITF].required = XA_BOOLEAN_TRUE;
       
   130     pBaseObj->interfaceMap[MP_DIMITF].required = XA_BOOLEAN_TRUE;
       
   131 
       
   132     /* Explicit interfaces */
       
   133     if ((numInterfaces != 0) && pInterfaceIds && pInterfaceRequired)
       
   134         {
       
   135         /* Check required interfaces */
       
   136         for (itfIdx = 0; itfIdx < numInterfaces; itfIdx++)
       
   137             {
       
   138             /* If mapEntry is null then required interface is not supported.*/
       
   139             XAObjItfMapEntry *entry = XAObjectItfImpl_GetItfEntry(
       
   140                     (XAObjectItf) &(pBaseObj), pInterfaceIds[itfIdx]);
       
   141             if (!entry)
       
   142                 {
       
   143                 if (pInterfaceRequired[itfIdx])
       
   144                     {
       
   145                     /* required interface cannot be accommodated - fail creation */
       
   146                     DEBUG_ERR("Required interface not found - abort creation!");
       
   147                     ret = XA_RESULT_FEATURE_UNSUPPORTED;
       
   148                     break;
       
   149                     }
       
   150                 else
       
   151                     {
       
   152                     DEBUG_INFO("Requested (not required) interface not found - continue creation");
       
   153                     }
       
   154                 }
       
   155             else
       
   156                 { /* weed out unsupported content-aware itf's */
       
   157                 if ((mediaType == XA_MEDIATYPE_IMAGE && (entry->mapIdx == MP_SEEKITF 
       
   158                         || entry->mapIdx == MP_VOLUMEITF)))
       
   159                     {
       
   160                     entry->required = XA_BOOLEAN_FALSE;
       
   161                     if (pInterfaceRequired[itfIdx])
       
   162                         {
       
   163                         DEBUG_ERR("Required interface not supported for given media - abort creation!");
       
   164                         ret = XA_RESULT_FEATURE_UNSUPPORTED;
       
   165                         break;
       
   166                         }
       
   167                     }
       
   168                 else
       
   169                     {
       
   170                     entry->required = XA_BOOLEAN_TRUE;
       
   171                     }
       
   172                 }
       
   173             }
       
   174         }
       
   175 
       
   176     if (ret != XA_RESULT_SUCCESS)
       
   177         { /* creation fails */
       
   178         XAObjectItfImpl_Destroy((XAObjectItf) &(pBaseObj));
       
   179         return ret;
       
   180         }
       
   181 
       
   182     /* Mark interfaces that can be handled dynamically */
       
   183     /* Mandated dynamic itfs */
       
   184     pBaseObj->interfaceMap[MP_METADATAEXTRACTIONITF].isDynamic
       
   185             = XA_BOOLEAN_TRUE;
       
   186     pBaseObj->interfaceMap[MP_PLAYBACKRATEITF].isDynamic = XA_BOOLEAN_TRUE;
       
   187 
       
   188     /*Set ObjectItf to point to newly created object*/
       
   189     *pPlayer = (XAObjectItf) &(pBaseObj->self);
       
   190 
       
   191     /*initialize XAPlayerImpl variables */
       
   192 
       
   193     pPlayerImpl->dataSrc = pDataSrc;
       
   194     pPlayerImpl->bankSrc = pBankSrc;
       
   195     pPlayerImpl->audioSnk = pAudioSnk;
       
   196     pPlayerImpl->imageVideoSnk = pImageVideoSnk;
       
   197     pPlayerImpl->vibra = pVibra;
       
   198     pPlayerImpl->LEDArray = pLEDArray;
       
   199 
       
   200     // Handle possible radio:      
       
   201     tmpIODevice = (XADataLocator_IODevice*) (pPlayerImpl->dataSrc->pLocator);
       
   202     locatorIODevice = *tmpIODevice;
       
   203     if (locatorIODevice.deviceType == XA_IODEVICE_RADIO)
       
   204         {
       
   205         fwType = (FWMgrFwType) FWMgrFWMMF;
       
   206         }
       
   207     else
       
   208         {
       
   209         /* Determine framework type that can handle recording */
       
   210         fwType = (FWMgrFwType) FWMgrMOUnknown;
       
   211         /**/
       
   212         if (pDataSrc->pLocator)
       
   213             {
       
   214             XADataLocator_URI* dataLoc =
       
   215                     (XADataLocator_URI*) pDataSrc->pLocator;
       
   216             if (dataLoc->locatorType == XA_DATALOCATOR_URI)
       
   217                 {
       
   218                 uri = (char*) dataLoc->URI;
       
   219                 }
       
   220             }
       
   221         fwType = XAFrameworkMgr_GetFramework(mapper, uri, FWMgrMOPlayer);
       
   222 
       
   223         if (fwType == FWMgrMOUnknown)
       
   224             {
       
   225             ret = XA_RESULT_CONTENT_UNSUPPORTED;
       
   226             XAObjectItfImpl_Destroy((XAObjectItf) &(pBaseObj));
       
   227             XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
       
   228             DEBUG_API("<-XAMediaPlayerImpl_CreateMediaPlayer");
       
   229             return ret;
       
   230             }
       
   231         } // end else
       
   232 
       
   233     if (fwType == FWMgrFWMMF)
       
   234         {
       
   235         pPlayerImpl->adaptationCtxMMF = XAMediaPlayerAdaptMMF_Create(
       
   236                 pPlayerImpl->dataSrc, pPlayerImpl->bankSrc,
       
   237                 pPlayerImpl->audioSnk, pPlayerImpl->imageVideoSnk,
       
   238                 pPlayerImpl->vibra, pPlayerImpl->LEDArray);
       
   239 
       
   240         pPlayerImpl->curAdaptCtx = pPlayerImpl->adaptationCtxMMF;
       
   241         }
       
   242 
       
   243     pPlayerImpl->curAdaptCtx->capslist = capabilities;
       
   244     pPlayerImpl->curAdaptCtx->fwtype = fwType;
       
   245 
       
   246     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
       
   247     DEBUG_API("<-XAMediaPlayerImpl_CreateMediaPlayer");
       
   248     return XA_RESULT_SUCCESS;
       
   249     }
       
   250 
       
   251 /* XAResult XAMediaPlayerImpl_QueryNumSupportedInterfaces
       
   252  * Statically query supported interfaces
       
   253  */
       
   254 XAresult XAMediaPlayerImpl_QueryNumSupportedInterfaces(
       
   255         XAuint32 * pNumSupportedInterfaces)
       
   256     {
       
   257     DEBUG_API("->XAMediaPlayerImpl_QueryNumSupportedInterfaces");
       
   258 
       
   259     if (pNumSupportedInterfaces)
       
   260         {
       
   261         *pNumSupportedInterfaces = MP_ITFCOUNT;
       
   262         DEBUG_API("<-XAMediaPlayerImpl_QueryNumSupportedInterfaces");
       
   263         return XA_RESULT_SUCCESS;
       
   264         }
       
   265     else
       
   266         {
       
   267         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   268         DEBUG_API("<-XAMediaPlayerImpl_QueryNumSupportedInterfaces");
       
   269         return XA_RESULT_PARAMETER_INVALID;
       
   270         }
       
   271     }
       
   272 
       
   273 /* XAResult XAMediaPlayerImpl_QuerySupportedInterfaces
       
   274  * Statically query supported interfaces
       
   275  */
       
   276 XAresult XAMediaPlayerImpl_QuerySupportedInterfaces(XAuint32 index,
       
   277         XAInterfaceID * pInterfaceId)
       
   278     {
       
   279     DEBUG_API("->XAMediaPlayerImpl_QuerySupportedInterfaces");
       
   280 
       
   281     if (index >= MP_ITFCOUNT || !pInterfaceId)
       
   282         {
       
   283         if (pInterfaceId)
       
   284             {
       
   285             *pInterfaceId = XA_IID_NULL;
       
   286             }DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   287             DEBUG_API("<-XAMediaPlayerImpl_QuerySupportedInterfaces");
       
   288         return XA_RESULT_PARAMETER_INVALID;
       
   289         }
       
   290     else
       
   291         {
       
   292         *pInterfaceId = *(xaMediaPlayerItfIIDs[index]);
       
   293         DEBUG_API("<-XAMediaPlayerImpl_QuerySupportedInterfaces");
       
   294         return XA_RESULT_SUCCESS;
       
   295         }
       
   296     }
       
   297 
       
   298 /*
       
   299  * Realize the object
       
   300  */
       
   301 XAresult XAMediaPlayerImpl_DoRealize(XAObjectItf self)
       
   302     {
       
   303     XAObjectItfImpl* pObj = (XAObjectItfImpl*) (*self);
       
   304     XAMediaPlayerImpl* pImpl = (XAMediaPlayerImpl*) (pObj);
       
   305     XAuint8 itfIdx = 0;
       
   306     void *pItf = NULL;
       
   307     XAresult ret = XA_RESULT_SUCCESS;
       
   308 
       
   309     DEBUG_API("->XAMediaPlayerImpl_DoRealize");
       
   310     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
       
   311 
       
   312     /* check casting from correct pointer type */
       
   313     if (!pImpl || pObj != pImpl->baseObj.self)
       
   314         {
       
   315         /* invalid parameter */
       
   316         XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
       
   317         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   318         DEBUG_API("<-XAMediaPlayerImpl_DoRealize");
       
   319         return XA_RESULT_PARAMETER_INVALID;
       
   320         }
       
   321 
       
   322     /* Realize all implicit and explicitly wanted interfaces */
       
   323     for (itfIdx = 0; itfIdx < MP_ITFCOUNT; itfIdx++)
       
   324         {
       
   325         if (!(pObj->interfaceMap[itfIdx].pItf)
       
   326                 && pObj->interfaceMap[itfIdx].required)
       
   327             {
       
   328             switch (itfIdx)
       
   329                 {
       
   330                 case MP_DIMITF:
       
   331                     pItf = XADIMItfImpl_Create();
       
   332                     if (pItf)
       
   333                         {
       
   334                         XADIMItfImpl_Init(pItf, self,
       
   335                                 XAMediaPlayerImpl_DoAddItf,
       
   336                                 XAMediaPlayerImpl_DoResumeItf,
       
   337                                 XAMediaPlayerImpl_DoRemoveItf);
       
   338                         }
       
   339                     break;
       
   340                 case MP_PLAYITF:
       
   341                     pItf = XAPlayItfImpl_Create(pImpl);
       
   342                     if (pImpl->dataSrc)
       
   343                         {
       
   344                         XAuint32 locType =
       
   345                                 *((XAuint32*) (pImpl->dataSrc->pLocator));
       
   346                         if (locType == XA_DATALOCATOR_IODEVICE)
       
   347                             {
       
   348                             XADataLocator_IODevice
       
   349                                     *ioDevice =
       
   350                                             (XADataLocator_IODevice*) (pImpl->dataSrc->pLocator);
       
   351                             if (ioDevice->deviceType == XA_IODEVICE_CAMERA)
       
   352                                 {
       
   353                                 vfHandle = (void*) pItf;
       
   354                                 DEBUG_INFO_A1("Stored view finder pointer to global address %x", vfHandle);
       
   355                                 }
       
   356                             }
       
   357                         else
       
   358                             {
       
   359 
       
   360                             }
       
   361                         }
       
   362                     break;
       
   363                 case MP_VOLUMEITF:
       
   364                     pItf = XAVolumeItfImpl_Create(pImpl->curAdaptCtx);
       
   365                     break;
       
   366                 case MP_SEEKITF:
       
   367                     pItf = XASeekItfImpl_Create(pImpl);
       
   368                     break;
       
   369                 case MP_PREFETCHSTATUSITF:
       
   370                     pItf = XAPrefetchStatusItfImpl_Create(pImpl);
       
   371                     break;
       
   372                 case MP_METADATAEXTRACTIONITF:
       
   373                     pItf = XAMetadataExtractionItfImpl_Create(
       
   374                             pImpl->curAdaptCtx);
       
   375                     break;
       
   376                 case MP_PLAYBACKRATEITF:
       
   377                     pItf = XAPlaybackRateItfImpl_Create(pImpl);
       
   378                     break;
       
   379                 case MP_CONFIGEXTENSIONITF:
       
   380                     pItf = XAConfigExtensionsItfImpl_Create();
       
   381                     XAConfigExtensionsItfImpl_SetContext(pItf,
       
   382                             pImpl->curAdaptCtx);
       
   383                     break;
       
   384                 case MP_DYNAMICSOURCEITF:
       
   385                     pItf = XADynamicSourceItfImpl_Create(pImpl->curAdaptCtx);
       
   386                     break;
       
   387                 case MP_NOKIAVOLUMEEXT:
       
   388                     pItf = XANokiaVolumeExtItfImpl_Create(pImpl->curAdaptCtx);
       
   389                     break;
       
   390                 case MP_NOKIALINEARVOLUME:
       
   391                     pItf = XANokiaLinearVolumeItfImpl_Create(
       
   392                             pImpl->curAdaptCtx);
       
   393                     break;
       
   394                 case MP_STREAMINFORMATIONITF:
       
   395                     pItf = XAStreamInformationItfImpl_Create(
       
   396                             pImpl->curAdaptCtx);
       
   397                     break;
       
   398                 default:
       
   399                     break;
       
   400                 }
       
   401             if (!pItf)
       
   402                 {
       
   403                 /* Memory allocation failed */
       
   404                 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
       
   405                 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
       
   406                 DEBUG_API("<-XAMediaPlayerImpl_DoRealize");
       
   407                 return XA_RESULT_MEMORY_FAILURE;
       
   408                 }
       
   409             else
       
   410                 {
       
   411                 pObj->interfaceMap[itfIdx].pItf = pItf;
       
   412                 }
       
   413             }
       
   414         }
       
   415     /* init adaptation */
       
   416     if (pImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
       
   417         {
       
   418         ret = XAMediaPlayerAdaptMMF_PostInit(
       
   419                 (XAAdaptationMMFCtx*) pImpl->adaptationCtxMMF);
       
   420         }
       
   421 
       
   422     if (ret != XA_RESULT_SUCCESS)
       
   423         {
       
   424         XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
       
   425         DEBUG_ERR("Adaptation init failed!");
       
   426         DEBUG_API("<-XAMediaPlayerImpl_DoRealize");
       
   427         return ret;
       
   428         }
       
   429 
       
   430     pObj->state = XA_OBJECT_STATE_REALIZED;
       
   431 
       
   432     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
       
   433     DEBUG_API("<-XAMediaPlayerImpl_DoRealize");
       
   434     return XA_RESULT_SUCCESS;
       
   435     }
       
   436 
       
   437 /*
       
   438  * Resume object
       
   439  */
       
   440 XAresult XAMediaPlayerImpl_DoResume(XAObjectItf self)
       
   441     {
       
   442     DEBUG_API("->XAMediaPlayerImpl_DoResume");
       
   443     DEBUG_API("<-XAMediaPlayerImpl_DoResume");
       
   444     /* suspended state not supported by this implementation */
       
   445     return XA_RESULT_PRECONDITIONS_VIOLATED;
       
   446     }
       
   447 
       
   448 /**
       
   449  * void XAMediaPlayerImpl_FreeResources(XAObjectItf self)
       
   450  * Description: Free all resources reserved at XAMediaPlayerImpl_DoRealize()
       
   451  **/
       
   452 void XAMediaPlayerImpl_FreeResources(XAObjectItf self)
       
   453     {
       
   454     XAObjectItfImpl* pObj = (XAObjectItfImpl*) (*self);
       
   455     XAuint8 itfIdx = 0;
       
   456     XAMediaPlayerImpl* pImpl = (XAMediaPlayerImpl*) pObj;
       
   457     DEBUG_API("->XAMediaPlayerImpl_FreeResources");
       
   458     XA_IMPL_THREAD_SAFETY_ENTRY_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
       
   459 
       
   460     assert(pObj && pImpl && pObj == pObj->self);
       
   461     for (itfIdx = 0; itfIdx < MP_ITFCOUNT; itfIdx++)
       
   462         {
       
   463         void *pItf = pObj->interfaceMap[itfIdx].pItf;
       
   464         if (pItf)
       
   465             {
       
   466             switch (itfIdx)
       
   467                 {
       
   468                 case MP_DIMITF:
       
   469                     XADIMItfImpl_Free(pItf);
       
   470                     break;
       
   471                 case MP_PLAYITF:
       
   472                     XAPlayItfImpl_Free(pItf);
       
   473                     break;
       
   474                 case MP_VOLUMEITF:
       
   475                     XAVolumeItfImpl_Free(pItf);
       
   476                     break;
       
   477                 case MP_SEEKITF:
       
   478                     XASeekItfImpl_Free(pItf);
       
   479                     break;
       
   480                 case MP_PREFETCHSTATUSITF:
       
   481                     XAPrefetchStatusItfImpl_Free(pItf);
       
   482                     break;
       
   483                 case MP_METADATAEXTRACTIONITF:
       
   484                     XAMetadataExtractionItfImpl_Free(pItf);
       
   485                     break;
       
   486                 case MP_PLAYBACKRATEITF:
       
   487                     XAPlaybackRateItfImpl_Free(pItf);
       
   488                     break;
       
   489                 case MP_CONFIGEXTENSIONITF:
       
   490                     XAConfigExtensionsItfImpl_Free(pItf);
       
   491                     break;
       
   492                 case MP_DYNAMICSOURCEITF:
       
   493                     XADynamicSourceItfImpl_Free(pItf);
       
   494                     break;
       
   495                 case MP_NOKIAVOLUMEEXT:
       
   496                     XANokiaVolumeExtItfImpl_Free(pItf);
       
   497                     break;
       
   498                 case MP_NOKIALINEARVOLUME:
       
   499                     XANokiaLinearVolumeItfImpl_Free(pItf);
       
   500                     break;
       
   501                 case MP_STREAMINFORMATIONITF:
       
   502                     XAStreamInformationItfImpl_Free(pItf);
       
   503                     break;
       
   504 
       
   505                 }
       
   506             pObj->interfaceMap[itfIdx].pItf = NULL;
       
   507             }
       
   508         }
       
   509 
       
   510     if (pImpl->curAdaptCtx)
       
   511         {
       
   512         if (pImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
       
   513             {
       
   514             XAMediaPlayerAdaptMMF_Destroy(
       
   515                     (XAAdaptationMMFCtx*) pImpl->adaptationCtxMMF);
       
   516             }
       
   517         }
       
   518 
       
   519     XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
       
   520     DEBUG_API("<-XAMediaPlayerImpl_FreeResources");
       
   521     return;
       
   522     }
       
   523 
       
   524 /* XAMediaPlayerImpl_DoAddItf
       
   525  * Dynamically add an interface, object specific parts
       
   526  */
       
   527 XAresult XAMediaPlayerImpl_DoAddItf(XAObjectItf self,
       
   528         XAObjItfMapEntry *mapEntry)
       
   529     {
       
   530 
       
   531     XAObjectItfImpl* pObj = (XAObjectItfImpl*) (*self);
       
   532     XAMediaPlayerImpl* pImpl = (XAMediaPlayerImpl*) (pObj);
       
   533 
       
   534     XAresult ret = XA_RESULT_SUCCESS;
       
   535     DEBUG_API("->XAMediaPlayerImpl_DoAddItf");
       
   536 
       
   537     if (mapEntry)
       
   538         {
       
   539         switch (mapEntry->mapIdx)
       
   540             {
       
   541 
       
   542             case MP_METADATAEXTRACTIONITF:
       
   543                 mapEntry->pItf = XAMetadataExtractionItfImpl_Create(
       
   544                         pImpl->curAdaptCtx);
       
   545                 break;
       
   546             case MP_PLAYBACKRATEITF:
       
   547                 mapEntry->pItf = XAPlaybackRateItfImpl_Create(pImpl);
       
   548                 break;
       
   549             default:
       
   550                 DEBUG_ERR("XAMediaPlayerImpl_DoAddItf unknown id")
       
   551                 ;
       
   552                 ret = XA_RESULT_FEATURE_UNSUPPORTED;
       
   553                 break;
       
   554             }
       
   555 
       
   556         if (!mapEntry->pItf && ret == XA_RESULT_SUCCESS)
       
   557             {
       
   558             DEBUG_ERR("XAMediaPlayerImpl_DoAddItf itf creation failed");
       
   559             ret = XA_RESULT_MEMORY_FAILURE;
       
   560             }
       
   561         }
       
   562     else
       
   563         {
       
   564         ret = XA_RESULT_PARAMETER_INVALID;
       
   565         }
       
   566 
       
   567     DEBUG_API("<-XAMediaPlayerImpl_DoAddItf");
       
   568     return ret;
       
   569     }
       
   570 
       
   571 /* XAMediaPlayerImpl_DoResumeItf
       
   572  * Try to resume lost interface, object specific parts
       
   573  */
       
   574 XAresult XAMediaPlayerImpl_DoResumeItf(XAObjectItf self,
       
   575         XAObjItfMapEntry *mapEntry)
       
   576     {
       
   577     /* For now, no difference between suspended and unrealised itfs */
       
   578     XAresult ret = XA_RESULT_SUCCESS;
       
   579     DEBUG_API("->XAMediaPlayerImpl_DoResumeItf");
       
   580     ret = XAMediaPlayerImpl_DoAddItf(self, mapEntry);
       
   581     DEBUG_API("<-XAMediaPlayerImpl_DoResumeItf");
       
   582     return ret;
       
   583     }
       
   584 
       
   585 /* XAMediaPlayerImpl_DoRemoveItf
       
   586  * Dynamically remove an interface, object specific parts
       
   587  */
       
   588 XAresult XAMediaPlayerImpl_DoRemoveItf(XAObjectItf self,
       
   589         XAObjItfMapEntry *mapEntry)
       
   590     {
       
   591     XAresult ret = XA_RESULT_SUCCESS;
       
   592     DEBUG_API("->XAMediaPlayerImpl_DoRemoveItf");
       
   593 
       
   594     if (mapEntry)
       
   595         {
       
   596         switch (mapEntry->mapIdx)
       
   597             {
       
   598             case MP_METADATAEXTRACTIONITF:
       
   599                 XAMetadataExtractionItfImpl_Free(mapEntry->pItf);
       
   600                 break;
       
   601             case MP_PLAYBACKRATEITF:
       
   602                 XAPlaybackRateItfImpl_Free(mapEntry->pItf);
       
   603                 break;
       
   604             default:
       
   605                 DEBUG_ERR("XAMediaPlayerImpl_DoRemoveItf unknown id")
       
   606                 ;
       
   607                 ret = XA_RESULT_FEATURE_UNSUPPORTED;
       
   608                 break;
       
   609             }
       
   610         mapEntry->pItf = NULL;
       
   611         }
       
   612     else
       
   613         {
       
   614         ret = XA_RESULT_PARAMETER_INVALID;
       
   615         }
       
   616 
       
   617     DEBUG_API("<-XAMediaPlayerImpl_DoRemoveItf");
       
   618     return ret;
       
   619     }
       
   620