khronosfws/openmax_al/src/mmf_adaptation/xametadataadaptctxmmf.c
changeset 31 8dfd592727cb
parent 16 43d09473c595
child 42 1fa3fb47b1e3
equal deleted inserted replaced
22:128eb6a32b84 31:8dfd592727cb
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description: 
    14  * Description: Metadata Adaptation MMF
    15 *
    15  *
    16 */
    16  */
       
    17 
    17 #include <assert.h>
    18 #include <assert.h>
    18 #include <stdlib.h>
    19 #include <stdlib.h>
    19 #include "xametadataadaptctxmmf.h"
    20 #include "xametadataadaptctxmmf.h"
    20 #include "xaobjectitf.h"
    21 #include "xaobjectitf.h"
    21 #include "cmetadatautilityitf.h"
    22 #include "cmetadatautilityitf.h"
    22 
    23 
    23 XAAdaptationBaseCtx* XAMetadataAdaptCtxMMF_Create(XADataSource * pDataSrc)
    24 XAAdaptationBaseCtx* XAMetadataAdaptCtxMMF_Create(XADataSource * pDataSrc)
    24 {
    25     {
    25 
    26 
    26     XAMetadataAdaptationMMFCtx *pSelf = NULL;
    27     XAMetadataAdaptationMMFCtx *pSelf = NULL;
    27     DEBUG_API("->XAMetadataAdaptCtxMMF_Create");
    28     DEBUG_API("->XAMetadataAdaptCtxMMF_Create");
    28     
    29 
    29     pSelf = calloc(1, sizeof(XAMetadataAdaptationMMFCtx));
    30     pSelf = calloc(1, sizeof(XAMetadataAdaptationMMFCtx));
    30     if ( pSelf)
    31     if (pSelf)
    31     {
       
    32           
       
    33         if( XAAdaptationBaseMMF_Init(&(pSelf->baseObj),XAMDAdaptation)
       
    34             != XA_RESULT_SUCCESS )
       
    35         {
    32         {
       
    33 
       
    34         if (XAAdaptationBaseMMF_Init(&(pSelf->baseObj), XAMDAdaptation)
       
    35                 != XA_RESULT_SUCCESS)
       
    36             {
    36             DEBUG_ERR("Failed to init base context!!!");
    37             DEBUG_ERR("Failed to init base context!!!");
    37             free(pSelf);
    38             free(pSelf);
    38             pSelf = NULL;
    39             pSelf = NULL;
    39         }
    40             }
    40         else
    41         else
    41             
    42 
    42         {
    43             {
    43             pSelf->baseObj.baseObj.fwtype = FWMgrFWMMF;
    44             pSelf->baseObj.baseObj.fwtype = FWMgrFWMMF;
    44             pSelf->xaSource = pDataSrc;
    45             pSelf->xaSource = pDataSrc;
       
    46             }
       
    47 
       
    48         if (pDataSrc)
       
    49             {
       
    50             pSelf->mmfContext
       
    51                     = mmf_metadata_utility_init(
       
    52                             (char *) (((XADataLocator_URI*) (pDataSrc->pLocator))->URI));
       
    53             if (!pSelf->mmfContext)
       
    54                 {
       
    55                 DEBUG_ERR("Failed to init mmf context!!!");
       
    56                 free(pSelf);
       
    57                 pSelf = NULL;
       
    58                 }
       
    59             }
       
    60 
    45         }
    61         }
    46 
    62     else
    47 		if(pDataSrc)
    63         {
    48 		{
    64         DEBUG_ERR("Failed to create XAMetadataAdaptationMMFCtx !!!");
    49 			pSelf->mmfContext = mmf_metadata_utility_init((char *)(( (XADataLocator_URI*)(pDataSrc->pLocator))->URI));
    65         return NULL;
    50 			if(!pSelf->mmfContext)
    66         }
    51             {
    67        
    52 	            DEBUG_ERR("Failed to init mmf context!!!");
       
    53     	        free(pSelf);
       
    54         	    pSelf = NULL;           
       
    55             }
       
    56 		}
       
    57 
       
    58     }
       
    59 
    68 
    60     DEBUG_API("<- XAMetadataAdaptCtxMMF_Create");
    69     DEBUG_API("<- XAMetadataAdaptCtxMMF_Create");
    61     return (XAAdaptationBaseCtx*)(&pSelf->baseObj.baseObj);
    70     return (XAAdaptationBaseCtx*) (&pSelf->baseObj.baseObj);
    62 }
    71     }
    63 
       
    64 
    72 
    65 /*
    73 /*
    66  * XAresult XAMediaPlayerAdaptMMF_PostInit()
    74  * XAresult XAMediaPlayerAdaptMMF_PostInit()
    67  * 2nd phase initialization of Media Player Adaptation Context
    75  * 2nd phase initialization of Media Player Adaptation Context
    68  * @param XAMediaPlayerAdaptationMMFCtx* ctx - pointer to Media Player adaptation context
    76  * @param XAMediaPlayerAdaptationMMFCtx* ctx - pointer to Media Player adaptation context
    69  * @return XAresult - Success value
    77  * @return XAresult - Success value
    70  */
    78  */
    71 XAresult XAMetadataAdaptCtxMMF_PostInit( XAAdaptationMMFCtx* bCtx )
    79 XAresult XAMetadataAdaptCtxMMF_PostInit(XAAdaptationMMFCtx* bCtx)
    72 {
    80     {
    73  	XAresult ret = XA_RESULT_SUCCESS;
    81     XAresult ret = XA_RESULT_SUCCESS;
    74  
    82 
    75   DEBUG_API("<-XAMetadataAdaptCtxMMF_PostInit");
    83     DEBUG_API("<-XAMetadataAdaptCtxMMF_PostInit");
    76   return ret;
    84     return ret;
    77 }
    85     }
    78 
    86 
    79 /*
    87 /*
    80  * void XAMediaPlayerAdaptMMF_Destroy( XAMediaPlayerAdaptationMMFCtx* ctx )
    88  * void XAMediaPlayerAdaptMMF_Destroy( XAMediaPlayerAdaptationMMFCtx* ctx )
    81  * Destroys Media Player Adaptation Context
    89  * Destroys Media Player Adaptation Context
    82  * @param ctx - Media Player Adaptation context to be destroyed
    90  * @param ctx - Media Player Adaptation context to be destroyed
    83  */
    91  */
    84 void XAMetadataAdaptCtxMMF_Destroy( XAAdaptationMMFCtx* bCtx )
    92 void XAMetadataAdaptCtxMMF_Destroy(XAAdaptationMMFCtx* bCtx)
    85 {
    93     {
    86     DEBUG_API("->XAMetadataAdaptCtxMMF_Destroy");
    94     DEBUG_API("->XAMetadataAdaptCtxMMF_Destroy");
    87     if(bCtx == NULL)
    95     if (bCtx == NULL)
    88     {
    96         {
    89         DEBUG_ERR("Invalid parameter!!");
    97         DEBUG_ERR("Invalid parameter!!");DEBUG_API("<-XAMetadataAdaptCtxMMF_Destroy");
    90         DEBUG_API("<-XAMetadataAdaptCtxMMF_Destroy");
       
    91         return;
    98         return;
    92     }
    99         }
    93 	
       
    94     if(((XAMetadataAdaptationMMFCtx*)bCtx)->mmfContext)
       
    95     {
       
    96         mmf_metadata_utility_destroy(((XAMetadataAdaptationMMFCtx*)bCtx)->mmfContext);
       
    97     }
       
    98 
   100 
    99     XAAdaptationBase_Free( &bCtx->baseObj );
   101     if (((XAMetadataAdaptationMMFCtx*) bCtx)->mmfContext)
       
   102         {
       
   103         mmf_metadata_utility_destroy(
       
   104                 ((XAMetadataAdaptationMMFCtx*) bCtx)->mmfContext);
       
   105         }
       
   106 
       
   107     XAAdaptationBase_Free(&bCtx->baseObj);
   100     free(bCtx);
   108     free(bCtx);
   101     bCtx = NULL;
   109     bCtx = NULL;
   102 
   110 
   103     DEBUG_API("<-XAMetadataExtractorAdaptMMF_Destroy");
   111     DEBUG_API("<-XAMetadataExtractorAdaptMMF_Destroy");
   104 }
   112     }
   105 
   113 
   106