khronosfws/openmax_al/src/mediarecorder/xametadatainsertionitf.c
changeset 31 8dfd592727cb
parent 16 43d09473c595
child 33 5e8b14bae8c3
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 Insertion Itf Impl
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 #include <stdio.h>
    18 #include <stdio.h>
    19 #include <stdlib.h>
    19 #include <stdlib.h>
    20 #include <assert.h>
    20 #include <assert.h>
    21 #include "xametadatainsertionitf.h"
    21 #include "xametadatainsertionitf.h"
    25 #define MAX_TAGS 255
    25 #define MAX_TAGS 255
    26 /* XAMetadataInsertionItfImpl* GetImpl(XAMetadataInsertionItf self)
    26 /* XAMetadataInsertionItfImpl* GetImpl(XAMetadataInsertionItf self)
    27  * Description: Validate interface pointer and cast it to implementation pointer.
    27  * Description: Validate interface pointer and cast it to implementation pointer.
    28  */
    28  */
    29 static XAMetadataInsertionItfImpl* GetImpl(XAMetadataInsertionItf self)
    29 static XAMetadataInsertionItfImpl* GetImpl(XAMetadataInsertionItf self)
    30 {
    30     {
    31     if( self )
    31     if (self)
    32     {
    32         {
    33         XAMetadataInsertionItfImpl* impl = (XAMetadataInsertionItfImpl*)(*self);
    33         XAMetadataInsertionItfImpl* impl =
    34         if( impl && (impl == impl->self) )
    34                 (XAMetadataInsertionItfImpl*) (*self);
    35         {
    35         if (impl && (impl == impl->self))
       
    36             {
    36             return impl;
    37             return impl;
    37         }
    38             }
    38     }
    39         }
    39     return NULL;
    40     return NULL;
    40 }
    41     }
    41 
    42 
    42 /*****************************************************************************
    43 /*****************************************************************************
    43  * Base interface XAMetadataInsertionItf implementation
    44  * Base interface XAMetadataInsertionItf implementation
    44  *****************************************************************************/
    45  *****************************************************************************/
    45 
    46 
    46 /* XAMetadataInsertionItfImpl_CreateChildNode
    47 /* XAMetadataInsertionItfImpl_CreateChildNode
    47  * Description: Creates a new child node for the given parent.
    48  * Description: Creates a new child node for the given parent.
    48  */
    49  */
    49 XAresult XAMetadataInsertionItfImpl_CreateChildNode(XAMetadataInsertionItf self,
    50 XAresult XAMetadataInsertionItfImpl_CreateChildNode(
    50                                                     XAint32 parentNodeID,
    51         XAMetadataInsertionItf self, XAint32 parentNodeID, XAuint32 type,
    51                                                     XAuint32 type,
    52         XAchar *mimeType, XAint32 *pChildNodeID)
    52                                                     XAchar *mimeType,
    53     {
    53                                                     XAint32 *pChildNodeID)
       
    54 {
       
    55     XAMetadataInsertionItfImpl *impl = NULL;
    54     XAMetadataInsertionItfImpl *impl = NULL;
    56     XAresult ret = XA_RESULT_SUCCESS;
    55     XAresult ret = XA_RESULT_SUCCESS;
    57 
    56 
    58     DEBUG_API("->XAMetadataInsertionItfImpl_CreateChildNode");
    57     DEBUG_API("->XAMetadataInsertionItfImpl_CreateChildNode");
    59     impl = GetImpl(self);
    58     impl = GetImpl(self);
    60     if(!impl || !mimeType || !pChildNodeID )
    59     if (!impl || !mimeType || !pChildNodeID)
    61     {
    60         {
    62         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    61         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    63         /* invalid parameter */
    62         /* invalid parameter */
    64         ret = XA_RESULT_PARAMETER_INVALID;
    63         ret = XA_RESULT_PARAMETER_INVALID;
    65     }
    64         }
    66     else
    65     else
    67     {
    66         {
    68 
    67 
    69     if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST)
    68         if (impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST)
    70         {
    69             {
    71         if(impl->adaptCtx)
    70             if (impl->adaptCtx)
    72             {
    71                 {
    73                 ret = XAMetadataInsertionItfAdapt_CreateChildNode(
    72                 ret = XAMetadataInsertionItfAdapt_CreateChildNode(
    74                         (XAAdaptationGstCtx*)impl->adaptCtx,parentNodeID,type,mimeType,pChildNodeID);
    73                         (XAAdaptationGstCtx*) impl->adaptCtx, parentNodeID,
    75             }
    74                         type, mimeType, pChildNodeID);
    76             else
    75                 }
    77             {
    76             else
    78                 ret = XA_RESULT_INTERNAL_ERROR;
    77                 {
    79             }
    78                 ret = XA_RESULT_INTERNAL_ERROR;
    80     
    79                 }
    81         }
    80 
    82     else
    81             }
    83         {
    82         else
    84         DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED");
    83             {
    85         DEBUG_API("<-XAMetadataInsertionItfImpl_CreateChildNode");
    84             DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED");
    86         return XA_RESULT_FEATURE_UNSUPPORTED; 
    85             DEBUG_API("<-XAMetadataInsertionItfImpl_CreateChildNode");
    87         }
    86             return XA_RESULT_FEATURE_UNSUPPORTED;
    88     }
    87             }
    89     DEBUG_API("<-XAMetadataInsertionItfImpl_CreateChildNode");
    88         }DEBUG_API("<-XAMetadataInsertionItfImpl_CreateChildNode");
    90     return ret;
    89     return ret;
    91 }
    90     }
    92 
    91 
    93 /* XAresult XAMetadataInsertionItfImpl_GetSupportedKeysCount
    92 /* XAresult XAMetadataInsertionItfImpl_GetSupportedKeysCount
    94  * Description: A query method to tell if the metadata keys (for writing metadata)
    93  * Description: A query method to tell if the metadata keys (for writing metadata)
    95  * can be freely chosen by the application or if they are fixed (for the given node).
    94  * can be freely chosen by the application or if they are fixed (for the given node).
    96  */
    95  */
    97 XAresult XAMetadataInsertionItfImpl_GetSupportedKeysCount(XAMetadataInsertionItf self,
    96 XAresult XAMetadataInsertionItfImpl_GetSupportedKeysCount(
    98                                                           XAint32 nodeID,
    97         XAMetadataInsertionItf self, XAint32 nodeID, XAboolean *pFreeKeys,
    99                                                           XAboolean *pFreeKeys,
    98         XAuint32 *pKeyCount, XAuint32 *pEncodingCount)
   100                                                           XAuint32 *pKeyCount,
    99     {
   101                                                           XAuint32 *pEncodingCount)
       
   102 {
       
   103     XAMetadataInsertionItfImpl *impl = NULL;
   100     XAMetadataInsertionItfImpl *impl = NULL;
   104     XAresult ret = XA_RESULT_SUCCESS;
   101     XAresult ret = XA_RESULT_SUCCESS;
   105 
   102 
   106     DEBUG_API("->XAMetadataInsertionItfImpl_GetSupportedKeysCount");
   103     DEBUG_API("->XAMetadataInsertionItfImpl_GetSupportedKeysCount");
   107     impl = GetImpl(self);
   104     impl = GetImpl(self);
   108     if(!impl || !pFreeKeys || !pKeyCount || !pEncodingCount )
   105     if (!impl || !pFreeKeys || !pKeyCount || !pEncodingCount)
   109     {
   106         {
   110         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   107         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   111         /* invalid parameter */
   108         /* invalid parameter */
   112         ret = XA_RESULT_PARAMETER_INVALID;
   109         ret = XA_RESULT_PARAMETER_INVALID;
   113     }
   110         }
   114     else
   111     else
   115     {
   112         {
   116     if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST)
   113         if (impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST)
   117         {
   114             {
   118         if( impl->adaptCtx )
   115             if (impl->adaptCtx)
   119             {
   116                 {
   120             ret = XAMetadataInsertionItfAdapt_GetSupportedKeysCount(
   117                 ret = XAMetadataInsertionItfAdapt_GetSupportedKeysCount(
   121                     (XAAdaptationGstCtx*)impl->adaptCtx,nodeID,pFreeKeys,pKeyCount,pEncodingCount);
   118                         (XAAdaptationGstCtx*) impl->adaptCtx, nodeID,
   122             }
   119                         pFreeKeys, pKeyCount, pEncodingCount);
   123         else
   120                 }
   124             {
   121             else
   125             ret = XA_RESULT_INTERNAL_ERROR;
   122                 {
   126             }
   123                 ret = XA_RESULT_INTERNAL_ERROR;
   127         }
   124                 }
   128     else
   125             }
   129         {
   126         else
   130         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   127             {
   131         DEBUG_API("<-XAMetadataInsertionItfImpl_GetSupportedKeysCount");
   128             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   132         return XA_RESULT_PARAMETER_INVALID;     
   129             DEBUG_API("<-XAMetadataInsertionItfImpl_GetSupportedKeysCount");
   133         }
   130             return XA_RESULT_PARAMETER_INVALID;
   134     }
   131             }
   135     DEBUG_API("<-XAMetadataInsertionItfImpl_GetSupportedKeysCount");
   132         }DEBUG_API("<-XAMetadataInsertionItfImpl_GetSupportedKeysCount");
   136     return ret;
   133     return ret;
   137 }
   134     }
   138 
   135 
   139 /* XAresult XAMetadataInsertionItfImpl_GetKeySize
   136 /* XAresult XAMetadataInsertionItfImpl_GetKeySize
   140  * Description: Returns the byte size required for a supported metadata
   137  * Description: Returns the byte size required for a supported metadata
   141  * key pointed by the given index
   138  * key pointed by the given index
   142  */
   139  */
   143 XAresult XAMetadataInsertionItfImpl_GetKeySize(XAMetadataInsertionItf self,
   140 XAresult XAMetadataInsertionItfImpl_GetKeySize(XAMetadataInsertionItf self,
   144                                                XAint32 nodeID,
   141         XAint32 nodeID, XAuint32 keyIndex, XAuint32 *pKeySize)
   145                                                XAuint32 keyIndex,
   142     {
   146                                                XAuint32 *pKeySize)
       
   147 {
       
   148     XAMetadataInsertionItfImpl *impl = NULL;
   143     XAMetadataInsertionItfImpl *impl = NULL;
   149     XAresult ret = XA_RESULT_SUCCESS;
   144     XAresult ret = XA_RESULT_SUCCESS;
   150 
   145 
   151     DEBUG_API("->XAMetadataInsertionItfImpl_GetKeySize");
   146     DEBUG_API("->XAMetadataInsertionItfImpl_GetKeySize");
   152     impl = GetImpl(self);
   147     impl = GetImpl(self);
   153     if(!impl || !pKeySize )
   148     if (!impl || !pKeySize)
   154     {
   149         {
   155         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   150         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   156         /* invalid parameter */
   151         /* invalid parameter */
   157         ret = XA_RESULT_PARAMETER_INVALID;
   152         ret = XA_RESULT_PARAMETER_INVALID;
   158     }
   153         }
   159     else
   154     else
   160     {
   155         {
   161     if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST)
   156         if (impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST)
   162         {
   157             {
   163 
   158 
   164         if( impl->adaptCtx )
   159             if (impl->adaptCtx)
   165             {
   160                 {
   166             ret = XAMetadataInsertionItfAdapt_GetKeySize(
   161                 ret = XAMetadataInsertionItfAdapt_GetKeySize(
   167                     (XAAdaptationGstCtx*)impl->adaptCtx, nodeID, keyIndex, pKeySize);
   162                         (XAAdaptationGstCtx*) impl->adaptCtx, nodeID,
   168             }
   163                         keyIndex, pKeySize);
   169         else
   164                 }
   170             {
   165             else
   171             ret = XA_RESULT_INTERNAL_ERROR;
   166                 {
   172             }
   167                 ret = XA_RESULT_INTERNAL_ERROR;
   173         }
   168                 }
   174     else
   169             }
   175         {
   170         else
   176         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   171             {
   177         DEBUG_API("<-XAMetadataInsertionItfImpl_GetKeySize");
   172             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   178         return XA_RESULT_PARAMETER_INVALID;   
   173             DEBUG_API("<-XAMetadataInsertionItfImpl_GetKeySize");
   179         }
   174             return XA_RESULT_PARAMETER_INVALID;
   180     }
   175             }
   181     DEBUG_API("<-XAMetadataInsertionItfImpl_GetKeySize");
   176         }DEBUG_API("<-XAMetadataInsertionItfImpl_GetKeySize");
   182     return ret;
   177     return ret;
   183 }
   178     }
   184 
   179 
   185 /* XAresult XAMetadataInsertionItfImpl_GetKey
   180 /* XAresult XAMetadataInsertionItfImpl_GetKey
   186  * Description; Returns a XAMetadataInfo structure and associated data
   181  * Description; Returns a XAMetadataInfo structure and associated data
   187  * referenced by the structure for a supported key
   182  * referenced by the structure for a supported key
   188  */
   183  */
   189 XAresult XAMetadataInsertionItfImpl_GetKey(XAMetadataInsertionItf self,
   184 XAresult XAMetadataInsertionItfImpl_GetKey(XAMetadataInsertionItf self,
   190                                            XAint32 nodeID,
   185         XAint32 nodeID, XAuint32 keyIndex, XAuint32 keySize,
   191                                            XAuint32 keyIndex,
   186         XAMetadataInfo *pKey)
   192                                            XAuint32 keySize,
   187     {
   193                                            XAMetadataInfo *pKey)
       
   194 {
       
   195     XAMetadataInsertionItfImpl *impl = NULL;
   188     XAMetadataInsertionItfImpl *impl = NULL;
   196     XAresult ret = XA_RESULT_SUCCESS;
   189     XAresult ret = XA_RESULT_SUCCESS;
   197 
   190 
   198     DEBUG_API("->XAMetadataInsertionItfImpl_GetKey");
   191     DEBUG_API("->XAMetadataInsertionItfImpl_GetKey");
   199     impl = GetImpl(self);
   192     impl = GetImpl(self);
   200     if(!impl || !pKey )
   193     if (!impl || !pKey)
   201     {
   194         {
   202         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   195         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   203         /* invalid parameter */
   196         /* invalid parameter */
   204         ret = XA_RESULT_PARAMETER_INVALID;
   197         ret = XA_RESULT_PARAMETER_INVALID;
   205     }
   198         }
   206     else
   199     else
   207     {
   200         {
   208     if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST)
   201         if (impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST)
   209         {
   202             {
   210 
   203 
   211         if( impl->adaptCtx )
   204             if (impl->adaptCtx)
   212             {
   205                 {
   213             ret = XAMetadataInsertionItfAdapt_GetKey(
   206                 ret = XAMetadataInsertionItfAdapt_GetKey(
   214                     (XAAdaptationGstCtx*)impl->adaptCtx,nodeID,keyIndex,keySize,pKey);
   207                         (XAAdaptationGstCtx*) impl->adaptCtx, nodeID,
   215             }
   208                         keyIndex, keySize, pKey);
   216         else
   209                 }
   217             {
   210             else
   218             ret = XA_RESULT_INTERNAL_ERROR;
   211                 {
   219             }
   212                 ret = XA_RESULT_INTERNAL_ERROR;
   220         }
   213                 }
   221     else
   214             }
   222         {
   215         else
   223         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   216             {
   224         DEBUG_API("<-XAMetadataInsertionItfImpl_GetKey");
   217             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   225         return XA_RESULT_PARAMETER_INVALID;   
   218             DEBUG_API("<-XAMetadataInsertionItfImpl_GetKey");
   226         }    
   219             return XA_RESULT_PARAMETER_INVALID;
   227 
   220             }
   228     }
   221 
   229     DEBUG_API("<-XAMetadataInsertionItfImpl_GetKey");
   222         }DEBUG_API("<-XAMetadataInsertionItfImpl_GetKey");
   230     return ret;
   223     return ret;
   231 }
   224     }
   232 
   225 
   233 /* XAresult XAMetadataInsertionItfImpl_GetFreeKeysEncoding
   226 /* XAresult XAMetadataInsertionItfImpl_GetFreeKeysEncoding
   234  * Description: A method to be used in case implementation supports
   227  * Description: A method to be used in case implementation supports
   235  * free keys for metadata insertion.
   228  * free keys for metadata insertion.
   236  */
   229  */
   237 XAresult XAMetadataInsertionItfImpl_GetFreeKeysEncoding(XAMetadataInsertionItf self,
   230 XAresult XAMetadataInsertionItfImpl_GetFreeKeysEncoding(
   238                                                         XAint32 nodeID,
   231         XAMetadataInsertionItf self, XAint32 nodeID, XAuint32 encodingIndex,
   239                                                         XAuint32 encodingIndex,
   232         XAuint32 *pEncoding)
   240                                                         XAuint32 *pEncoding)
   233     {
   241 {
       
   242     XAMetadataInsertionItfImpl *impl = NULL;
   234     XAMetadataInsertionItfImpl *impl = NULL;
   243     XAresult ret = XA_RESULT_SUCCESS;
   235     XAresult ret = XA_RESULT_SUCCESS;
   244 
   236 
   245     DEBUG_API("->XAMetadataInsertionItfImpl_GetFreeKeysEncoding");
   237     DEBUG_API("->XAMetadataInsertionItfImpl_GetFreeKeysEncoding");
   246     impl = GetImpl(self);
   238     impl = GetImpl(self);
   247     if( !impl || !pEncoding )
   239     if (!impl || !pEncoding)
   248     {
   240         {
   249         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   241         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   250         /* invalid parameter */
   242         /* invalid parameter */
   251         ret =XA_RESULT_PARAMETER_INVALID;
   243         ret = XA_RESULT_PARAMETER_INVALID;
   252     }
   244         }
   253     else
   245     else
   254     {
   246         {
   255     if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST)
   247         if (impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST)
   256         {
   248             {
   257 
   249 
   258         if( impl->adaptCtx )
   250             if (impl->adaptCtx)
   259             {
   251                 {
   260             ret = XAMetadataInsertionItfAdapt_GetFreeKeysEncoding(
   252                 ret = XAMetadataInsertionItfAdapt_GetFreeKeysEncoding(
   261                     (XAAdaptationGstCtx*)impl->adaptCtx,nodeID,encodingIndex,pEncoding);
   253                         (XAAdaptationGstCtx*) impl->adaptCtx, nodeID,
   262             }
   254                         encodingIndex, pEncoding);
   263         else
   255                 }
   264             {
   256             else
   265             ret = XA_RESULT_INTERNAL_ERROR;
   257                 {
   266             }
   258                 ret = XA_RESULT_INTERNAL_ERROR;
   267         }
   259                 }
   268     else
   260             }
   269         {
   261         else
   270         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   262             {
   271         DEBUG_API("<-XAMetadataInsertionItfImpl_GetFreeKeysEncoding");
   263             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   272         return XA_RESULT_PARAMETER_INVALID;   
   264             DEBUG_API("<-XAMetadataInsertionItfImpl_GetFreeKeysEncoding");
   273         }        
   265             return XA_RESULT_PARAMETER_INVALID;
   274     }
   266             }
   275     DEBUG_API("<-XAMetadataInsertionItfImpl_GetFreeKeysEncoding");
   267         }DEBUG_API("<-XAMetadataInsertionItfImpl_GetFreeKeysEncoding");
   276     return ret;
   268     return ret;
   277 }
   269     }
   278 
   270 
   279 /* XAresult XAMetadataInsertionItfImpl_InsertMetadataItem
   271 /* XAresult XAMetadataInsertionItfImpl_InsertMetadataItem
   280  * Description: Inserts the key/value pair to the specified node of the metadata tree.
   272  * Description: Inserts the key/value pair to the specified node of the metadata tree.
   281  */
   273  */
   282 XAresult XAMetadataInsertionItfImpl_InsertMetadataItem(XAMetadataInsertionItf self,
   274 XAresult XAMetadataInsertionItfImpl_InsertMetadataItem(
   283                                                        XAint32 nodeID,
   275         XAMetadataInsertionItf self, XAint32 nodeID, XAMetadataInfo *pKey,
   284                                                        XAMetadataInfo *pKey,
   276         XAMetadataInfo *pValue, XAboolean overwrite)
   285                                                        XAMetadataInfo *pValue,
   277     {
   286                                                        XAboolean overwrite)
       
   287 {
       
   288     XAMetadataInsertionItfImpl *impl = NULL;
   278     XAMetadataInsertionItfImpl *impl = NULL;
   289     XAresult ret = XA_RESULT_SUCCESS;
   279     XAresult ret = XA_RESULT_SUCCESS;
   290 
   280 
   291     DEBUG_API("->XAMetadataInsertionItfImpl_InsertMetadataItem");
   281     DEBUG_API("->XAMetadataInsertionItfImpl_InsertMetadataItem");
   292     impl = GetImpl(self);
   282     impl = GetImpl(self);
   293     if( !impl || !pKey || !pValue )
   283     if (!impl || !pKey || !pValue)
   294     {
   284         {
   295         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   285         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   296         /* invalid parameter */
   286         /* invalid parameter */
   297         ret = XA_RESULT_PARAMETER_INVALID;
   287         ret = XA_RESULT_PARAMETER_INVALID;
   298     }
   288         }
   299     else
   289     else
   300     {
   290         {
   301     if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST)
   291         if (impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST)
   302         {
   292             {
   303 
   293 
   304         if( impl->adaptCtx )
   294             if (impl->adaptCtx)
   305             {
   295                 {
   306             ret = XAMetadataInsertionItfAdapt_InsertMetadataItem(
   296                 ret = XAMetadataInsertionItfAdapt_InsertMetadataItem(
   307                     (XAAdaptationGstCtx*)impl->adaptCtx,nodeID,pKey,pValue,overwrite);
   297                         (XAAdaptationGstCtx*) impl->adaptCtx, nodeID, pKey,
   308             impl->currentTags.mdeKeys[impl->currentTags.itemcount] = pKey;
   298                         pValue, overwrite);
   309             impl->currentTags.mdeValues[impl->currentTags.itemcount] = pValue;
   299                 impl->currentTags.mdeKeys[impl->currentTags.itemcount] = pKey;
   310             impl->currentTags.itemcount++;
   300                 impl->currentTags.mdeValues[impl->currentTags.itemcount]
   311             }
   301                         = pValue;
   312         else
   302                 impl->currentTags.itemcount++;
   313             {
   303                 }
   314             ret = XA_RESULT_INTERNAL_ERROR;
   304             else
   315             }
   305                 {
   316         }
   306                 ret = XA_RESULT_INTERNAL_ERROR;
   317     else
   307                 }
   318         {
   308             }
   319         DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED");
   309         else
   320         DEBUG_API("<-XAMetadataInsertionItfImpl_GetFreeKeysEncoding");
   310             {
   321         return XA_RESULT_FEATURE_UNSUPPORTED;   
   311             DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED");
   322         }            
   312             DEBUG_API("<-XAMetadataInsertionItfImpl_GetFreeKeysEncoding");
   323     }
   313             return XA_RESULT_FEATURE_UNSUPPORTED;
   324     DEBUG_API("<-XAMetadataInsertionItfImpl_InsertMetadataItem");
   314             }
   325     return ret;
   315         }DEBUG_API("<-XAMetadataInsertionItfImpl_InsertMetadataItem");
   326 }
   316     return ret;
       
   317     }
   327 
   318 
   328 /* XAresult XAMetadataInsertionItfImpl_RegisterCallback
   319 /* XAresult XAMetadataInsertionItfImpl_RegisterCallback
   329  * Description: Registers a callback on the object that executes after each of
   320  * Description: Registers a callback on the object that executes after each of
   330  * the actual writings of metadata key/value pairs takes place.
   321  * the actual writings of metadata key/value pairs takes place.
   331  */
   322  */
   332 XAresult XAMetadataInsertionItfImpl_RegisterCallback(XAMetadataInsertionItf self,
   323 XAresult XAMetadataInsertionItfImpl_RegisterCallback(
   333                                                      xaMetadataInsertionCallback callback,
   324         XAMetadataInsertionItf self, xaMetadataInsertionCallback callback,
   334                                                      void *pContext)
   325         void *pContext)
   335 {
   326     {
   336     XAMetadataInsertionItfImpl *impl = NULL;
   327     XAMetadataInsertionItfImpl *impl = NULL;
   337 
   328 
   338     DEBUG_API("->XAMetadataInsertionItfImpl_RegisterCallback");
   329     DEBUG_API("->XAMetadataInsertionItfImpl_RegisterCallback");
   339     impl = GetImpl(self);
   330     impl = GetImpl(self);
   340     if( !impl )
   331     if (!impl)
   341     {
   332         {
   342         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   333         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   343         DEBUG_API("<-XAMetadataInsertionItfImpl_RegisterCallback");
   334         DEBUG_API("<-XAMetadataInsertionItfImpl_RegisterCallback");
   344         /* invalid parameter */
   335         /* invalid parameter */
   345         return XA_RESULT_PARAMETER_INVALID;
   336         return XA_RESULT_PARAMETER_INVALID;
   346     }
   337         }
   347 
   338 
   348     if(callback)
   339     if (callback)
   349     {
   340         {
   350         XAAdaptationBase_AddEventHandler( impl->adaptCtx, &XAMetadataInsertionItfImpl_AdaptCb,
   341         XAAdaptationBase_AddEventHandler(impl->adaptCtx,
   351                                           XA_METADATAEVENTS, impl );
   342                 &XAMetadataInsertionItfImpl_AdaptCb, XA_METADATAEVENTS, impl);
   352         impl->callback = callback;
   343         impl->callback = callback;
   353         impl->cbcontext  = pContext;
   344         impl->cbcontext = pContext;
   354         impl->cbPtrToSelf = self;
   345         impl->cbPtrToSelf = self;
   355     }
   346         }
   356     else
   347     else
   357     {
   348         {
   358         XAAdaptationBase_RemoveEventHandler(impl->adaptCtx, &XAMetadataInsertionItfImpl_AdaptCb );
   349         XAAdaptationBase_RemoveEventHandler(impl->adaptCtx,
   359     }
   350                 &XAMetadataInsertionItfImpl_AdaptCb);
       
   351         }
   360 
   352 
   361     DEBUG_API("<-XAMetadataInsertionItfImpl_RegisterCallback");
   353     DEBUG_API("<-XAMetadataInsertionItfImpl_RegisterCallback");
   362     return XA_RESULT_SUCCESS;
   354     return XA_RESULT_SUCCESS;
   363 }
   355     }
   364 
   356 
   365 /*****************************************************************************
   357 /*****************************************************************************
   366  * XAMetadataTraversalImpl -specific methods
   358  * XAMetadataTraversalImpl -specific methods
   367  *****************************************************************************/
   359  *****************************************************************************/
   368 
   360 
   369 
       
   370 /* XAMetadataInsertionItfImpl* XAMetadataInsertionItfImpl_Create()
   361 /* XAMetadataInsertionItfImpl* XAMetadataInsertionItfImpl_Create()
   371  * Description: Allocate and initialize MetadataInsertionItfImpl
   362  * Description: Allocate and initialize MetadataInsertionItfImpl
   372  */
   363  */
   373 XAMetadataInsertionItfImpl* XAMetadataInsertionItfImpl_Create(XAMediaRecorderImpl* impl)
   364 XAMetadataInsertionItfImpl* XAMetadataInsertionItfImpl_Create(
   374 {
   365         XAMediaRecorderImpl* impl)
   375     XAMetadataInsertionItfImpl* self = (XAMetadataInsertionItfImpl*)
   366     {
   376         calloc(1,sizeof(XAMetadataInsertionItfImpl));
   367     XAMetadataInsertionItfImpl* self = (XAMetadataInsertionItfImpl*) calloc(
       
   368             1, sizeof(XAMetadataInsertionItfImpl));
   377     //XAMediaRecorderAdaptationCtx* mCtx = (XAMediaRecorderAdaptationCtx*)(impl->adaptationCtx);
   369     //XAMediaRecorderAdaptationCtx* mCtx = (XAMediaRecorderAdaptationCtx*)(impl->adaptationCtx);
   378     
   370 
   379     DEBUG_API("->XAMetadataInsertionItfImpl_Create");
   371     DEBUG_API("->XAMetadataInsertionItfImpl_Create");
   380     if( self )
   372     if (self)
   381     {
   373         {
   382         //if(mCtx->fwtype == FWMgrFWGST)
   374         //if(mCtx->fwtype == FWMgrFWGST)
   383             {
   375             {
   384             /* init itf default implementation */
   376             /* init itf default implementation */
   385             self->itf.CreateChildNode = XAMetadataInsertionItfImpl_CreateChildNode;
   377             self->itf.CreateChildNode
   386             self->itf.GetFreeKeysEncoding = XAMetadataInsertionItfImpl_GetFreeKeysEncoding;
   378                     = XAMetadataInsertionItfImpl_CreateChildNode;
       
   379             self->itf.GetFreeKeysEncoding
       
   380                     = XAMetadataInsertionItfImpl_GetFreeKeysEncoding;
   387             self->itf.GetKey = XAMetadataInsertionItfImpl_GetKey;
   381             self->itf.GetKey = XAMetadataInsertionItfImpl_GetKey;
   388             self->itf.GetKeySize = XAMetadataInsertionItfImpl_GetKeySize;
   382             self->itf.GetKeySize = XAMetadataInsertionItfImpl_GetKeySize;
   389             self->itf.GetSupportedKeysCount = XAMetadataInsertionItfImpl_GetSupportedKeysCount;
   383             self->itf.GetSupportedKeysCount
   390             self->itf.InsertMetadataItem = XAMetadataInsertionItfImpl_InsertMetadataItem;
   384                     = XAMetadataInsertionItfImpl_GetSupportedKeysCount;
   391             self->itf.RegisterCallback = XAMetadataInsertionItfImpl_RegisterCallback;
   385             self->itf.InsertMetadataItem
       
   386                     = XAMetadataInsertionItfImpl_InsertMetadataItem;
       
   387             self->itf.RegisterCallback
       
   388                     = XAMetadataInsertionItfImpl_RegisterCallback;
   392             }
   389             }
   393 
   390 
   394         /* init variables*/
   391         /* init variables*/
   395         
   392 
   396         self->callback = NULL;
   393         self->callback = NULL;
   397         self->cbcontext = NULL;
   394         self->cbcontext = NULL;
   398         self->cbPtrToSelf = NULL;
   395         self->cbPtrToSelf = NULL;
   399         self->adaptCtx = impl->adaptationCtx;
   396         self->adaptCtx = impl->adaptationCtx;
   400         self->currentTags.mdeKeys = calloc(MAX_TAGS,sizeof(XAMetadataInfo*));
   397         self->currentTags.mdeKeys = calloc(MAX_TAGS, sizeof(XAMetadataInfo*));
   401         self->currentTags.mdeValues = calloc(MAX_TAGS,sizeof(XAMetadataInfo*));
   398         self->currentTags.mdeValues = calloc(MAX_TAGS,
       
   399                 sizeof(XAMetadataInfo*));
   402         self->self = self;
   400         self->self = self;
   403 
   401 
   404     }
   402         }DEBUG_API("<-XAMetadataInsertionItfImpl_Create");
   405     DEBUG_API("<-XAMetadataInsertionItfImpl_Create");
       
   406     return self;
   403     return self;
   407 }
   404     }
   408 
   405 
   409 /* void XAMetadataInsertionItfImpl_Free(XAMetadataInsertionItfImpl* self)
   406 /* void XAMetadataInsertionItfImpl_Free(XAMetadataInsertionItfImpl* self)
   410  * Description: Free all resources reserved at XAMetadataInsertionItfImpl_Create()
   407  * Description: Free all resources reserved at XAMetadataInsertionItfImpl_Create()
   411  */
   408  */
   412 void XAMetadataInsertionItfImpl_Free(XAMetadataInsertionItfImpl* self)
   409 void XAMetadataInsertionItfImpl_Free(XAMetadataInsertionItfImpl* self)
   413 {
   410     {
   414     DEBUG_API("->XAMetadataInsertionItfImpl_Free");
   411     DEBUG_API("->XAMetadataInsertionItfImpl_Free");
   415     assert( self==self->self );
   412     assert( self==self->self );
   416     if(self->callback)
   413     if (self->callback)
   417     {
   414         {
   418         XAAdaptationBase_RemoveEventHandler(self->adaptCtx, &XAMetadataInsertionItfImpl_AdaptCb );
   415         XAAdaptationBase_RemoveEventHandler(self->adaptCtx,
   419     }
   416                 &XAMetadataInsertionItfImpl_AdaptCb);
       
   417         }
   420     XAMetadataAdapt_FreeImplTagList(&(self->currentTags), XA_BOOLEAN_FALSE);
   418     XAMetadataAdapt_FreeImplTagList(&(self->currentTags), XA_BOOLEAN_FALSE);
   421     free( self );
   419     free(self);
   422     DEBUG_API("<-XAMetadataInsertionItfImpl_Free");
   420     DEBUG_API("<-XAMetadataInsertionItfImpl_Free");
   423 }
   421     }
   424 
   422 
   425 /* With this method, adaptation infroms that tags are written to stream
   423 /* With this method, adaptation infroms that tags are written to stream
   426  */
   424  */
   427 void XAMetadataInsertionItfImpl_AdaptCb( void *pHandlerCtx, XAAdaptEvent *event )
   425 void XAMetadataInsertionItfImpl_AdaptCb(void *pHandlerCtx,
   428 {
   426         XAAdaptEvent *event)
       
   427     {
   429     XAMetadataInsertionItfImpl* impl = NULL;
   428     XAMetadataInsertionItfImpl* impl = NULL;
   430     XAuint32 idx = 0, nodeID = XA_ROOT_NODE_ID;
   429     XAuint32 idx = 0, nodeID = XA_ROOT_NODE_ID;
   431     XAboolean result = XA_BOOLEAN_TRUE;
   430     XAboolean result = XA_BOOLEAN_TRUE;
   432     DEBUG_API("->XAMetadataInsertionItfImpl_AdaptCb");
   431     DEBUG_API("->XAMetadataInsertionItfImpl_AdaptCb");
   433     impl = (XAMetadataInsertionItfImpl*)pHandlerCtx;
   432     impl = (XAMetadataInsertionItfImpl*) pHandlerCtx;
   434     if(!impl)
   433     if (!impl)
   435     {
   434         {
   436         DEBUG_ERR("XAMetadataInsertionItfImpl_AdaptCb, invalid context pointer!");
   435         DEBUG_ERR("XAMetadataInsertionItfImpl_AdaptCb, invalid context pointer!");
   437         DEBUG_API("<-XAMetadataInsertionItfImpl_AdaptCb");
   436         DEBUG_API("<-XAMetadataInsertionItfImpl_AdaptCb");
   438         return;
   437         return;
   439     }
   438         }
   440     if( event && event->eventid == XA_ADAPT_MDE_TAGS_WRITTEN )
   439     if (event && event->eventid == XA_ADAPT_MDE_TAGS_WRITTEN)
   441     {
   440         {
   442         /*here datasize field is used for return value*/
   441         /*here datasize field is used for return value*/
   443         if(event->datasize != XA_RESULT_SUCCESS)
   442         if (event->datasize != XA_RESULT_SUCCESS)
   444         {
   443             {
   445             DEBUG_ERR_A1("Adaptation failed to write metadata (code %x)!",(int)event->datasize);
   444             DEBUG_ERR_A1("Adaptation failed to write metadata (code %x)!",(int)event->datasize);
   446             result=XA_BOOLEAN_FALSE;
   445             result = XA_BOOLEAN_FALSE;
   447         }
   446             }
   448         /*all tags written, send cb for client to free the memory*/
   447         /*all tags written, send cb for client to free the memory*/
   449         for(idx=0;idx<impl->currentTags.itemcount;idx++)
   448         for (idx = 0; idx < impl->currentTags.itemcount; idx++)
   450         {
   449             {
   451             if(impl->callback)
   450             if (impl->callback)
   452             {
   451                 {
   453                 impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   452                 impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   454                                impl->currentTags.mdeKeys[idx],
   453                         impl->currentTags.mdeKeys[idx],
   455                                impl->currentTags.mdeValues[idx],
   454                         impl->currentTags.mdeValues[idx], nodeID, result);
   456                                nodeID, result);
   455                 }
   457             }
   456             impl->currentTags.mdeKeys[idx] = NULL;
   458             impl->currentTags.mdeKeys[idx]=NULL;
   457             impl->currentTags.mdeValues[idx] = NULL;
   459             impl->currentTags.mdeValues[idx]=NULL;
   458             }
   460         }
   459         impl->currentTags.itemcount = 0;
   461         impl->currentTags.itemcount=0;
   460         }
   462     }
   461     else
   463     else
   462         {
   464     {
       
   465         DEBUG_INFO("unhandled");
   463         DEBUG_INFO("unhandled");
   466     }
   464         }
   467     DEBUG_API("<-XAMetadataInsertionItfImpl_AdaptCb");
   465     DEBUG_API("<-XAMetadataInsertionItfImpl_AdaptCb");
   468 }
   466     }
   469 
   467