khronosfws/openmax_al/src/common/xametadataextractionitf.c
changeset 25 6f7ceef7b1d1
parent 19 4a629bc82c5e
child 33 5e8b14bae8c3
equal deleted inserted replaced
21:2ed61feeead6 25:6f7ceef7b1d1
     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 Extraction Interface Implementation
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 #include <stdio.h>
    18 #include <stdio.h>
    19 #include <stdlib.h>
    19 #include <stdlib.h>
    20 #include <string.h>
    20 #include <string.h>
    21 #include <assert.h>
    21 #include <assert.h>
    32 
    32 
    33 /* XAMetadataExtractionItfImpl* GetImpl(XAMetadataExtractionItf self)
    33 /* XAMetadataExtractionItfImpl* GetImpl(XAMetadataExtractionItf self)
    34  * Description: Validate interface pointer and cast it to implementation pointer.
    34  * Description: Validate interface pointer and cast it to implementation pointer.
    35  **/
    35  **/
    36 static XAMetadataExtractionItfImpl* GetImpl(XAMetadataExtractionItf self)
    36 static XAMetadataExtractionItfImpl* GetImpl(XAMetadataExtractionItf self)
    37 {
    37     {
    38     if( self )
    38     if (self)
    39     {
    39         {
    40         XAMetadataExtractionItfImpl* impl = (XAMetadataExtractionItfImpl*)(*self);
    40         XAMetadataExtractionItfImpl* impl =
    41         if( impl && (impl == impl->self) )
    41                 (XAMetadataExtractionItfImpl*) (*self);
    42         {
    42         if (impl && (impl == impl->self))
       
    43             {
    43             return impl;
    44             return impl;
    44         }
    45             }
    45     }
    46         }
    46     return NULL;
    47     return NULL;
    47 }
    48     }
    48 
    49 
    49 static void* GetMetadataUtilityContext(XAAdaptationMMFCtx* adaptCtx)
    50 static void* GetMetadataUtilityContext(XAAdaptationMMFCtx* adaptCtx)
    50 {
    51     {
    51 	switch(adaptCtx->baseObj.ctxId)
    52     if (adaptCtx)
    52 	{
    53         {
    53 		case XAMediaPlayerAdaptation:
    54         switch (adaptCtx->baseObj.ctxId)
    54 	          return ((XAMediaPlayerAdaptationMMFCtx*)adaptCtx)->mmfMetadataContext;
    55             {
    55 		case XAMDAdaptation:
    56             case XAMediaPlayerAdaptation:
    56 	          return ((XAMetadataAdaptationMMFCtx*)adaptCtx)->mmfContext;
    57                 return ((XAMediaPlayerAdaptationMMFCtx*) adaptCtx)->mmfMetadataContext;
    57 		default:
    58             case XAMDAdaptation:
    58 			break;
    59                 return ((XAMetadataAdaptationMMFCtx*) adaptCtx)->mmfContext;
    59 	}
    60             default:
    60 
    61                 break;
    61 	return NULL;
    62             }
    62 }
    63 
       
    64         }
       
    65     return NULL;
       
    66     }
    63 /*****************************************************************************
    67 /*****************************************************************************
    64  * Base interface XAMetadataExtractionItf implementation
    68  * Base interface XAMetadataExtractionItf implementation
    65  *****************************************************************************/
    69  *****************************************************************************/
    66 
    70 
    67 /*
    71 /*
    68  * Returns the number of metadata items within the current scope of the object.
    72  * Returns the number of metadata items within the current scope of the object.
    69  * @XAuint32 *pItemCount
    73  * @XAuint32 *pItemCount
    70  *      Number of metadata items.  Must be non-NULL
    74  *      Number of metadata items.  Must be non-NULL
    71  */
    75  */
    72 XAresult XAMetadataExtractionItfImpl_GetItemCount(XAMetadataExtractionItf self,
    76 XAresult XAMetadataExtractionItfImpl_GetItemCount(
    73                                                   XAuint32 *pItemCount)
    77         XAMetadataExtractionItf self, XAuint32 *pItemCount)
    74 {
    78     {
    75     XAMetadataExtractionItfImpl *impl = NULL;
    79     XAMetadataExtractionItfImpl *impl = NULL;
    76     XAresult res = XA_RESULT_SUCCESS;
    80     XAresult res = XA_RESULT_SUCCESS;
    77     DEBUG_API("->XAMetadataExtractionItfImpl_GetItemCount");
    81     DEBUG_API("->XAMetadataExtractionItfImpl_GetItemCount");
    78 
    82 
    79     impl = GetImpl(self);
    83     impl = GetImpl(self);
    80     /* check parameters */
    84     /* check parameters */
    81     if( !impl || !pItemCount )
    85     if (!impl || !pItemCount)
    82     {
    86         {
    83         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    87         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    84         res = XA_RESULT_PARAMETER_INVALID;
    88         res = XA_RESULT_PARAMETER_INVALID;
    85     }
    89         }
    86     else
    90     else
    87     {
    91         {
    88  
    92 
    89         if( impl->adaptCtx )
    93         if (impl->adaptCtx)
    90         {
    94             {
    91         	
    95 
    92 			if(impl->adaptCtx->fwtype == FWMgrFWMMF)
    96             if (impl->adaptCtx->fwtype == FWMgrFWMMF)
    93 			{
    97                 {
    94 				void *mmfCtx = GetMetadataUtilityContext((XAAdaptationMMFCtx*)impl->adaptCtx);
    98                 void *mmfCtx = GetMetadataUtilityContext(
    95 				if(mmfCtx)
    99                         (XAAdaptationMMFCtx*) impl->adaptCtx);
    96 				{
   100                 if (mmfCtx)
    97 					res = mmf_get_item_count(mmfCtx, pItemCount);
   101                     {
    98 				}
   102                     res = mmf_get_item_count(mmfCtx, pItemCount);
    99 				else
   103                     }
   100 				{
   104                 else
   101 					res = XA_RESULT_PARAMETER_INVALID;
   105                     {
   102 				}
   106                     res = XA_RESULT_PARAMETER_INVALID;
   103 			}
   107                     }
   104 			else
   108                 }
   105 			{
   109             else
   106             	if(impl->filteringOn)
   110                 {
   107             	{
   111                 if (impl->filteringOn)
   108 	                *pItemCount = impl->filteredcount;
   112                     {
   109     	        }
   113                     *pItemCount = impl->filteredcount;
   110         	    else
   114                     }
   111             	{
   115                 else
   112 	                *pItemCount = impl->currentTags.itemcount;
   116                     {
   113     	        }
   117                     *pItemCount = impl->currentTags.itemcount;
   114         	    res = XA_RESULT_SUCCESS;
   118                     }
   115 			}
   119                 res = XA_RESULT_SUCCESS;
   116         }
   120                 }
   117         else
   121             }
   118         {
   122         else
       
   123             {
   119             res = XA_RESULT_INTERNAL_ERROR;
   124             res = XA_RESULT_INTERNAL_ERROR;
   120         }
   125             }
   121 
   126 
   122         DEBUG_INFO_A1("itemCount = %d", (int)*pItemCount);
   127         DEBUG_INFO_A1("itemCount = %d", (int)*pItemCount);
   123     }
   128         }
   124 
   129 
   125     DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetItemCount (%d)", (int)res);
   130     DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetItemCount (%d)", (int)res);
   126     return res;
   131     return res;
   127 }
   132     }
   128 
   133 
   129 /*
   134 /*
   130  * Returns the byte size of a given metadata key
   135  * Returns the byte size of a given metadata key
   131  *
   136  *
   132  * @XAuint32 index
   137  * @XAuint32 index
   133  *      Metadata item Index. Range is [0, GetItemCount)
   138  *      Metadata item Index. Range is [0, GetItemCount)
   134  * @XAuint32 *pKeySize
   139  * @XAuint32 *pKeySize
   135  *      Address to store key size. size must be greater than 0.  Must be non-NULL
   140  *      Address to store key size. size must be greater than 0.  Must be non-NULL
   136  */
   141  */
   137 XAresult XAMetadataExtractionItfImpl_GetKeySize(XAMetadataExtractionItf self,
   142 XAresult XAMetadataExtractionItfImpl_GetKeySize(XAMetadataExtractionItf self,
   138                                                 XAuint32 index,
   143         XAuint32 index, XAuint32 *pKeySize)
   139                                                 XAuint32 *pKeySize)
   144     {
   140 {
       
   141     XAMetadataExtractionItfImpl *impl = NULL;
   145     XAMetadataExtractionItfImpl *impl = NULL;
   142     XAresult res = XA_RESULT_SUCCESS;
   146     XAresult res = XA_RESULT_SUCCESS;
   143     XAuint32 newidx = 0;
   147     XAuint32 newidx = 0;
   144     DEBUG_API("->XAMetadataExtractionItfImpl_GetKeySize");
   148     DEBUG_API("->XAMetadataExtractionItfImpl_GetKeySize");
   145 
   149 
   146     impl = GetImpl(self);
   150     impl = GetImpl(self);
   147     if( !impl || !pKeySize )
   151     if (!impl || !pKeySize)
   148     {
   152         {
   149         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   153         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XAMetadataExtractionItfImpl_GetKeySize");
   150         DEBUG_API("<-XAMetadataExtractionItfImpl_GetKeySize");
       
   151         return XA_RESULT_PARAMETER_INVALID;
   154         return XA_RESULT_PARAMETER_INVALID;
   152     }
   155         }
   153     *pKeySize = 0;
   156     *pKeySize = 0;
   154 
   157 
   155 	if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF)
   158     if (impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF)
   156 	{
   159         {
   157 		void *mmfCtx = GetMetadataUtilityContext((XAAdaptationMMFCtx*)impl->adaptCtx);
   160         void *mmfCtx = GetMetadataUtilityContext(
   158 		if(mmfCtx)
   161                 (XAAdaptationMMFCtx*) impl->adaptCtx);
   159 		{
   162         if (mmfCtx)
   160 			res = mmf_get_key_size(mmfCtx, index, pKeySize);
   163             {
   161 		}
   164             res = mmf_get_key_size(mmfCtx, index, pKeySize);
   162 		else
   165             }
   163 		{
   166         else
   164 			res = XA_RESULT_PARAMETER_INVALID;
   167             {
   165 		}
   168             res = XA_RESULT_PARAMETER_INVALID;
   166 	}
   169             }
   167 	else
   170         }
   168 	{
   171     else
   169 	    /* check index and return unfiltered index */
   172         {
   170 	    if( CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS )
   173         /* check index and return unfiltered index */
   171     	{
   174         if (CheckAndUnfilterIndex(impl, index, &newidx) != XA_RESULT_SUCCESS)
   172 	        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   175             {
   173     	    DEBUG_API("<-XAMetadataExtractionItfImpl_GetKeySize");
   176             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XAMetadataExtractionItfImpl_GetKeySize");
   174         	return XA_RESULT_PARAMETER_INVALID;
   177             return XA_RESULT_PARAMETER_INVALID;
   175 	    }
   178             }
   176  
   179 
   177 	    /* size = size of struct + size of data - 1 (struct size already includes one char) */
   180         /* size = size of struct + size of data - 1 (struct size already includes one char) */
   178     	*pKeySize = sizeof(XAMetadataInfo) + impl->currentTags.mdeKeys[newidx]->size - 1;
   181         *pKeySize = sizeof(XAMetadataInfo)
   179 	}
   182                 + impl->currentTags.mdeKeys[newidx]->size - 1;
       
   183         }
   180 
   184 
   181     DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetKeySize (%d)", (int)res);
   185     DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetKeySize (%d)", (int)res);
   182     return res;
   186     return res;
   183 }
   187     }
   184 
   188 
   185 /*
   189 /*
   186  * Returns a XAMetadataInfo structure and associated data referenced by the structure for a key.
   190  * Returns a XAMetadataInfo structure and associated data referenced by the structure for a key.
   187  * @XAuint32 index
   191  * @XAuint32 index
   188  *      Metadata item Index. Range is [0, GetItemCount())
   192  *      Metadata item Index. Range is [0, GetItemCount())
   190  *      Size of the memory block passed as key. Range is [1, GetKeySize].
   194  *      Size of the memory block passed as key. Range is [1, GetKeySize].
   191  * @XAMetadataInfo *pKey
   195  * @XAMetadataInfo *pKey
   192  *      Address to store the key.  Must be non-NULL
   196  *      Address to store the key.  Must be non-NULL
   193  */
   197  */
   194 XAresult XAMetadataExtractionItfImpl_GetKey(XAMetadataExtractionItf self,
   198 XAresult XAMetadataExtractionItfImpl_GetKey(XAMetadataExtractionItf self,
   195                                             XAuint32 index,
   199         XAuint32 index, XAuint32 keySize, XAMetadataInfo *pKey)
   196                                             XAuint32 keySize,
   200     {
   197                                             XAMetadataInfo *pKey)
       
   198 {
       
   199     XAMetadataExtractionItfImpl *impl = NULL;
   201     XAMetadataExtractionItfImpl *impl = NULL;
   200     XAresult res = XA_RESULT_SUCCESS;
   202     XAresult res = XA_RESULT_SUCCESS;
   201     XAuint32 newidx = 0;
   203     XAuint32 newidx = 0;
   202  
   204 
   203     XAuint32 neededsize = 0;
   205     XAuint32 neededsize = 0;
   204 
   206 
   205     XAuint32 newdatasize = 0;
   207     XAuint32 newdatasize = 0;
   206     DEBUG_API("->XAMetadataExtractionItfImpl_GetKey");
   208     DEBUG_API("->XAMetadataExtractionItfImpl_GetKey");
   207 
   209 
   208     impl = GetImpl(self);
   210     impl = GetImpl(self);
   209     if( !impl || !pKey )
   211     if (!impl || !pKey)
   210     {
   212         {
   211         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   213         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XAMetadataExtractionItfImpl_GetKey");
   212         DEBUG_API("<-XAMetadataExtractionItfImpl_GetKey");
       
   213         return XA_RESULT_PARAMETER_INVALID;
   214         return XA_RESULT_PARAMETER_INVALID;
   214     }
   215         }
   215 
   216 
   216     memset(pKey,0,keySize);
   217     memset(pKey, 0, keySize);
   217 	
   218 
   218 	if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF)
   219     if (impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF)
   219 	{
   220         {
   220 		void *mmfCtx = GetMetadataUtilityContext((XAAdaptationMMFCtx*)impl->adaptCtx);
   221         void *mmfCtx = GetMetadataUtilityContext(
   221 		if(mmfCtx)
   222                 (XAAdaptationMMFCtx*) impl->adaptCtx);
   222 		{
   223         if (mmfCtx)
   223 			res = mmf_get_key(mmfCtx, index, keySize, pKey);
   224             {
   224 		}
   225             res = mmf_get_key(mmfCtx, index, keySize, pKey);
   225 		else
   226             }
   226 		{
   227         else
   227 			res = XA_RESULT_PARAMETER_INVALID;
   228             {
   228 		}
   229             res = XA_RESULT_PARAMETER_INVALID;
   229 	}
   230             }
   230 	else
   231         }
   231 	{
   232     else
   232 
   233         {
   233 	    /* check index and return unfiltered index */
   234 
   234 	    if(CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS)
   235         /* check index and return unfiltered index */
   235 	    {
   236         if (CheckAndUnfilterIndex(impl, index, &newidx) != XA_RESULT_SUCCESS)
   236 	        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   237             {
   237 	        DEBUG_API("<-XAMetadataExtractionItfImpl_GetKey");
   238             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XAMetadataExtractionItfImpl_GetKey");
   238 	        return XA_RESULT_PARAMETER_INVALID;
   239             return XA_RESULT_PARAMETER_INVALID;
   239 	    }
   240             }
   240 
   241 
   241 	    
   242         /* needed size = size of struct + size of data - 1 (struct size already includes one char) */
   242 	    /* needed size = size of struct + size of data - 1 (struct size already includes one char) */
   243         neededsize = sizeof(XAMetadataInfo)
   243 	    neededsize = sizeof(XAMetadataInfo) + impl->currentTags.mdeKeys[newidx]->size - 1;
   244                 + impl->currentTags.mdeKeys[newidx]->size - 1;
   244 	    if( keySize<neededsize )
   245         if (keySize < neededsize)
   245 	    {   /* cannot fit all of key data */
   246             { /* cannot fit all of key data */
   246 	        newdatasize = impl->currentTags.mdeKeys[newidx]->size - (neededsize-keySize);
   247             newdatasize = impl->currentTags.mdeKeys[newidx]->size
   247 	        DEBUG_ERR("XA_RESULT_BUFFER_INSUFFICIENT");
   248                     - (neededsize - keySize);
   248 	        res = XA_RESULT_BUFFER_INSUFFICIENT;
   249             DEBUG_ERR("XA_RESULT_BUFFER_INSUFFICIENT");
   249 	    }
   250             res = XA_RESULT_BUFFER_INSUFFICIENT;
   250 	    else
   251             }
   251 	    {
   252         else
   252 	        newdatasize = impl->currentTags.mdeKeys[newidx]->size;
   253             {
   253 	        res = XA_RESULT_SUCCESS;
   254             newdatasize = impl->currentTags.mdeKeys[newidx]->size;
   254 	    }
   255             res = XA_RESULT_SUCCESS;
   255 	    /* copy data up to given size */
   256             }
   256 	    memcpy(pKey,impl->currentTags.mdeKeys[newidx],keySize-1);
   257         /* copy data up to given size */
   257 	    /* ensure null-termination */
   258         memcpy(pKey, impl->currentTags.mdeKeys[newidx], keySize - 1);
   258 	    
   259         /* ensure null-termination */
   259 	    memset(pKey->data+newdatasize-1,0,1);
   260 
   260 	    pKey->size = newdatasize;
   261         memset(pKey->data + newdatasize - 1, 0, 1);
   261 	}
   262         pKey->size = newdatasize;
       
   263         }
   262 
   264 
   263     DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetKey (%d)", (int)res);
   265     DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetKey (%d)", (int)res);
   264     return res;
   266     return res;
   265 }
   267     }
   266 
       
   267 
   268 
   268 /*
   269 /*
   269  * Returns the byte size of a given metadata value
   270  * Returns the byte size of a given metadata value
   270  * @XAuint32 index
   271  * @XAuint32 index
   271  *      Metadata item Index. Range is [0, GetItemCount())
   272  *      Metadata item Index. Range is [0, GetItemCount())
   272  * @XAuint32 *pValueSize
   273  * @XAuint32 *pValueSize
   273  *      Address to store value size. size must be greater than 0.  Must be non-NULL
   274  *      Address to store value size. size must be greater than 0.  Must be non-NULL
   274  */
   275  */
   275 XAresult XAMetadataExtractionItfImpl_GetValueSize(XAMetadataExtractionItf self,
   276 XAresult XAMetadataExtractionItfImpl_GetValueSize(
   276                                                   XAuint32 index,
   277         XAMetadataExtractionItf self, XAuint32 index, XAuint32 *pValueSize)
   277                                                   XAuint32 *pValueSize)
   278     {
   278 {
       
   279     XAMetadataExtractionItfImpl *impl = NULL;
   279     XAMetadataExtractionItfImpl *impl = NULL;
   280     XAresult res = XA_RESULT_SUCCESS;
   280     XAresult res = XA_RESULT_SUCCESS;
   281     XAuint32 newidx = 0;
   281     XAuint32 newidx = 0;
   282     DEBUG_API("->XAMetadataExtractionItfImpl_GetValueSize");
   282     DEBUG_API("->XAMetadataExtractionItfImpl_GetValueSize");
   283 
   283 
   284     impl = GetImpl(self);
   284     impl = GetImpl(self);
   285     if( !impl || !pValueSize )
   285     if (!impl || !pValueSize)
   286     {
   286         {
   287         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   287         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XAMetadataExtractionItfImpl_GetValueSize");
   288         DEBUG_API("<-XAMetadataExtractionItfImpl_GetValueSize");
       
   289         return XA_RESULT_PARAMETER_INVALID;
   288         return XA_RESULT_PARAMETER_INVALID;
   290     }
   289         }
   291     *pValueSize = 0;
   290     *pValueSize = 0;
   292 
   291 
   293 	if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF)
   292     if (impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF)
   294 	{
   293         {
   295 		void *mmfCtx = GetMetadataUtilityContext((XAAdaptationMMFCtx*)impl->adaptCtx);
   294         void *mmfCtx = GetMetadataUtilityContext(
   296 		if(mmfCtx)
   295                 (XAAdaptationMMFCtx*) impl->adaptCtx);
   297 		{
   296         if (mmfCtx)
   298 			res = mmf_get_value_size(mmfCtx, index,pValueSize);
   297             {
   299 		}
   298             res = mmf_get_value_size(mmfCtx, index, pValueSize);
   300 		else
   299             }
   301 		{
   300         else
   302 			res = XA_RESULT_PARAMETER_INVALID;
   301             {
   303 		}
   302             res = XA_RESULT_PARAMETER_INVALID;
   304 	}
   303             }
   305 	else
   304         }
   306 	{
   305     else
   307 	    /* check index and return unfiltered index */
   306         {
   308 	    if(CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS)
   307         /* check index and return unfiltered index */
   309 	    {
   308         if (CheckAndUnfilterIndex(impl, index, &newidx) != XA_RESULT_SUCCESS)
   310 	        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   309             {
   311 	        DEBUG_API("<-XAMetadataExtractionItfImpl_GetValueSize");
   310             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XAMetadataExtractionItfImpl_GetValueSize");
   312 	        return XA_RESULT_PARAMETER_INVALID;
   311             return XA_RESULT_PARAMETER_INVALID;
   313 	    }
   312             }
   314 	 
   313 
   315 	    /* size = size of struct + size of data - 1 (struct size already includes one char) */
   314         /* size = size of struct + size of data - 1 (struct size already includes one char) */
   316 	    *pValueSize = sizeof(XAMetadataInfo) + impl->currentTags.mdeValues[newidx]->size - 1;
   315         *pValueSize = sizeof(XAMetadataInfo)
   317 	}
   316                 + impl->currentTags.mdeValues[newidx]->size - 1;
       
   317         }
   318 
   318 
   319     DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetValueSize (%d)", (int)res);
   319     DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetValueSize (%d)", (int)res);
   320     return res;
   320     return res;
   321 }
   321     }
   322 
   322 
   323 /*
   323 /*
   324  * Returns a XAMetadataInfo structure and associated data referenced by the structure for a value.
   324  * Returns a XAMetadataInfo structure and associated data referenced by the structure for a value.
   325  *  @XAuint32 index
   325  *  @XAuint32 index
   326  *      Metadata item Index. Range is [0, GetItemCount())
   326  *      Metadata item Index. Range is [0, GetItemCount())
   328  *      Size of the memory block passed as value. Range is [0, GetValueSize]
   328  *      Size of the memory block passed as value. Range is [0, GetValueSize]
   329  *  @XAMetadataInfo *pValue
   329  *  @XAMetadataInfo *pValue
   330  *      Address to store the value.  Must be non-NULL
   330  *      Address to store the value.  Must be non-NULL
   331  */
   331  */
   332 XAresult XAMetadataExtractionItfImpl_GetValue(XAMetadataExtractionItf self,
   332 XAresult XAMetadataExtractionItfImpl_GetValue(XAMetadataExtractionItf self,
   333                                               XAuint32 index,
   333         XAuint32 index, XAuint32 valueSize, XAMetadataInfo *pValue)
   334                                               XAuint32 valueSize,
   334     {
   335                                               XAMetadataInfo *pValue)
       
   336 {
       
   337     XAMetadataExtractionItfImpl *impl = NULL;
   335     XAMetadataExtractionItfImpl *impl = NULL;
   338     XAresult res = XA_RESULT_SUCCESS;
   336     XAresult res = XA_RESULT_SUCCESS;
   339     XAuint32 newidx = 0;
   337     XAuint32 newidx = 0;
   340  
   338 
   341     XAuint32 neededsize = 0;
   339     XAuint32 neededsize = 0;
   342 
   340 
   343     XAuint32 newdatasize = 0;
   341     XAuint32 newdatasize = 0;
   344     DEBUG_API("->XAMetadataExtractionItfImpl_GetValue");
   342     DEBUG_API("->XAMetadataExtractionItfImpl_GetValue");
   345 
   343 
   346     impl = GetImpl(self);
   344     impl = GetImpl(self);
   347     if( !impl || !pValue )
   345     if (!impl || !pValue)
   348     {
   346         {
   349         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   347         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XAMetadataExtractionItfImpl_GetValue");
   350         DEBUG_API("<-XAMetadataExtractionItfImpl_GetValue");
       
   351         return XA_RESULT_PARAMETER_INVALID;
   348         return XA_RESULT_PARAMETER_INVALID;
   352     }
   349         }
   353 
   350 
   354 	memset(pValue,0,valueSize);
   351     memset(pValue, 0, valueSize);
   355 
   352 
   356 	if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF)
   353     if (impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF)
   357 	{
   354         {
   358 		void *mmfCtx = GetMetadataUtilityContext((XAAdaptationMMFCtx*)impl->adaptCtx);
   355         void *mmfCtx = GetMetadataUtilityContext(
   359 		if(mmfCtx)
   356                 (XAAdaptationMMFCtx*) impl->adaptCtx);
   360 		{
   357         if (mmfCtx)
   361 			res = mmf_get_value(mmfCtx, index, valueSize, pValue);
   358             {
   362 		}
   359             res = mmf_get_value(mmfCtx, index, valueSize, pValue);
   363 		else
   360             }
   364 		{
   361         else
   365 			res = XA_RESULT_PARAMETER_INVALID;
   362             {
   366 		}
   363             res = XA_RESULT_PARAMETER_INVALID;
   367 	}
   364             }
   368 	else
   365         }
   369 	{
   366     else
   370 	    /* check index and return unfiltered index */
   367         {
   371 	    if(CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS)
   368         /* check index and return unfiltered index */
   372 	    {
   369         if (CheckAndUnfilterIndex(impl, index, &newidx) != XA_RESULT_SUCCESS)
   373 	        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   370             {
   374 	        DEBUG_API("<-XAMetadataExtractionItfImpl_GetValue");
   371             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XAMetadataExtractionItfImpl_GetValue");
   375 	        return XA_RESULT_PARAMETER_INVALID;
   372             return XA_RESULT_PARAMETER_INVALID;
   376 	    }
   373             }
   377 
   374 
   378 	    /* needed size = size of struct + size of data - 1 (struct size already includes one char) */
   375         /* needed size = size of struct + size of data - 1 (struct size already includes one char) */
   379 	    neededsize = sizeof(XAMetadataInfo) + impl->currentTags.mdeValues[newidx]->size - 1;
   376         neededsize = sizeof(XAMetadataInfo)
   380 	    if( valueSize<neededsize )
   377                 + impl->currentTags.mdeValues[newidx]->size - 1;
   381 	    {   /* cannot fit all of key data */
   378         if (valueSize < neededsize)
   382 	        newdatasize = impl->currentTags.mdeValues[newidx]->size - (neededsize-valueSize);
   379             { /* cannot fit all of key data */
   383 	        DEBUG_ERR("XA_RESULT_BUFFER_INSUFFICIENT");
   380             newdatasize = impl->currentTags.mdeValues[newidx]->size
   384 	        res = XA_RESULT_BUFFER_INSUFFICIENT;
   381                     - (neededsize - valueSize);
   385 	    }
   382             DEBUG_ERR("XA_RESULT_BUFFER_INSUFFICIENT");
   386 	    else
   383             res = XA_RESULT_BUFFER_INSUFFICIENT;
   387 	    {
   384             }
   388 	        newdatasize = impl->currentTags.mdeValues[newidx]->size;
   385         else
   389 	        res = XA_RESULT_SUCCESS;
   386             {
   390 	    }
   387             newdatasize = impl->currentTags.mdeValues[newidx]->size;
   391 	    /* copy data up to given size */
   388             res = XA_RESULT_SUCCESS;
   392 	    memcpy(pValue,impl->currentTags.mdeValues[newidx],valueSize-1);
   389             }
   393 	    /* ensure null-termination */
   390         /* copy data up to given size */
   394 
   391         memcpy(pValue, impl->currentTags.mdeValues[newidx], valueSize - 1);
   395 	    memset(pValue->data+newdatasize-1,0,1);
   392         /* ensure null-termination */
   396 
   393 
   397 	    pValue->size = newdatasize;
   394         memset(pValue->data + newdatasize - 1, 0, 1);
   398 	}
   395 
       
   396         pValue->size = newdatasize;
       
   397         }
   399 
   398 
   400     DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetValue (%d)",(int)res);
   399     DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetValue (%d)",(int)res);
   401     return res;
   400     return res;
   402 }
   401     }
   403 
       
   404 
   402 
   405 /*
   403 /*
   406  * Adds a filter for a specific key
   404  * Adds a filter for a specific key
   407  * @XAuint32 keySize
   405  * @XAuint32 keySize
   408  *      Size in bytes, of the pKey parameter. Ignored if filtering by key is disabled
   406  *      Size in bytes, of the pKey parameter. Ignored if filtering by key is disabled
   415  * @XAuint32 valueEncoding
   413  * @XAuint32 valueEncoding
   416  *      Encoding of the value to filter by. Ignored if filtering by encoding is disabled
   414  *      Encoding of the value to filter by. Ignored if filtering by encoding is disabled
   417  * @XAuint8 filterMask
   415  * @XAuint8 filterMask
   418  *      Bitmask indicating which criteria to filter by. Should be one of the XA_METADATA_FILTER macros
   416  *      Bitmask indicating which criteria to filter by. Should be one of the XA_METADATA_FILTER macros
   419  */
   417  */
   420 XAresult XAMetadataExtractionItfImpl_AddKeyFilter(XAMetadataExtractionItf self,
   418 XAresult XAMetadataExtractionItfImpl_AddKeyFilter(
   421                                                   XAuint32 keySize,
   419         XAMetadataExtractionItf self, XAuint32 keySize, const void *pKey,
   422                                                   const void *pKey,
   420         XAuint32 keyEncoding, const XAchar *pValueLangCountry,
   423                                                   XAuint32 keyEncoding,
   421         XAuint32 valueEncoding, XAuint8 filterMask)
   424                                                   const XAchar *pValueLangCountry,
   422     {
   425                                                   XAuint32 valueEncoding,
       
   426                                                   XAuint8 filterMask)
       
   427 {
       
   428     XAresult res = XA_RESULT_SUCCESS;
   423     XAresult res = XA_RESULT_SUCCESS;
   429     
   424 
   430     XAuint32 idx = 0;
   425     XAuint32 idx = 0;
   431     XAuint8 matchMask = 0;
   426     XAuint8 matchMask = 0;
   432     
   427 
   433  
       
   434     XAMetadataExtractionItfImpl *impl = NULL;
   428     XAMetadataExtractionItfImpl *impl = NULL;
   435     const XAchar* parsedkey;
   429     const XAchar* parsedkey;
   436     impl = GetImpl(self);
   430     impl = GetImpl(self);
   437 
   431 
   438     DEBUG_API("->XAMetadataExtractionItfImpl_AddKeyFilter");
   432     DEBUG_API("->XAMetadataExtractionItfImpl_AddKeyFilter");
   439 
   433 
   440  
   434     if (!impl)
   441 
   435         {
   442     if( !impl )
   436         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XAMetadataExtractionItfImpl_AddKeyFilter");
   443     {
       
   444         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   445         DEBUG_API("<-XAMetadataExtractionItfImpl_AddKeyFilter");
       
   446         return XA_RESULT_PARAMETER_INVALID;
   437         return XA_RESULT_PARAMETER_INVALID;
   447     }
   438         }
   448     else
   439     else
   449     {
   440         {
   450     
   441 
   451 		if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF)
   442         if (impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF)
   452 		{
   443             {
   453 			DEBUG_API("<-XAMetadataExtractionItfImpl_AddKeyFilter Not Supported in MMF");
   444             DEBUG_API("<-XAMetadataExtractionItfImpl_AddKeyFilter Not Supported in MMF");
   454 			res = XA_RESULT_PARAMETER_INVALID;
   445             res = XA_RESULT_PARAMETER_INVALID;
   455 		}
   446             }
   456 		else
   447         else
   457 		{
   448             {
   458 	        impl->filteringOn = XA_BOOLEAN_TRUE;
   449             impl->filteringOn = XA_BOOLEAN_TRUE;
   459 	        for(idx=0; idx < impl->currentTags.itemcount; idx++)
   450             for (idx = 0; idx < impl->currentTags.itemcount; idx++)
   460 	        {
   451                 {
   461 	            if((filterMask & XA_METADATA_FILTER_KEY) && pKey)
   452                 if ((filterMask & XA_METADATA_FILTER_KEY) && pKey)
   462 	            {
   453                     {
   463 	                parsedkey = XAMetadataAdapt_ParseKhronosKey(pKey);
   454                     parsedkey = XAMetadataAdapt_ParseKhronosKey(pKey);
   464 	                if( strcmp((char*)parsedkey,
   455                     if (strcmp((char*) parsedkey,
   465 	                           (char*)impl->currentTags.mdeKeys[idx]->data) == 0 )
   456                             (char*) impl->currentTags.mdeKeys[idx]->data)
   466 	                {
   457                             == 0)
   467 	                    matchMask |= XA_METADATA_FILTER_KEY;
   458                         {
   468 	                }
   459                         matchMask |= XA_METADATA_FILTER_KEY;
   469 	            }
   460                         }
   470 	            if(filterMask & XA_METADATA_FILTER_LANG && pValueLangCountry)
   461                     }
   471 	            {
   462                 if (filterMask & XA_METADATA_FILTER_LANG && pValueLangCountry)
   472 	                if( strcmp((char*)pValueLangCountry,
   463                     {
   473 	                           (char*)impl->currentTags.mdeKeys[idx]->langCountry) == 0 )
   464                     if (strcmp(
   474 	                {
   465                             (char*) pValueLangCountry,
   475 	                    matchMask |= XA_METADATA_FILTER_LANG;
   466                             (char*) impl->currentTags.mdeKeys[idx]->langCountry)
   476 	                }
   467                             == 0)
   477 	            }
   468                         {
   478 	            if(filterMask & XA_METADATA_FILTER_ENCODING)
   469                         matchMask |= XA_METADATA_FILTER_LANG;
   479 	            {
   470                         }
   480 	                if(keyEncoding==impl->currentTags.mdeKeys[idx]->encoding)
   471                     }
   481 	                {
   472                 if (filterMask & XA_METADATA_FILTER_ENCODING)
   482 	                    matchMask |= XA_METADATA_FILTER_ENCODING;
   473                     {
   483 	                }
   474                     if (keyEncoding
   484 	                if(valueEncoding==impl->currentTags.mdeValues[idx]->encoding)
   475                             == impl->currentTags.mdeKeys[idx]->encoding)
   485 	                {
   476                         {
   486 	                    matchMask |= XA_METADATA_FILTER_ENCODING;
   477                         matchMask |= XA_METADATA_FILTER_ENCODING;
   487 	                }
   478                         }
   488 	            }
   479                     if (valueEncoding
   489 	            /* check if all filters apply */
   480                             == impl->currentTags.mdeValues[idx]->encoding)
   490 	            if(filterMask == matchMask)
   481                         {
   491 	            {
   482                         matchMask |= XA_METADATA_FILTER_ENCODING;
   492 	                if(impl->tagmatchesfilter[idx] == XA_BOOLEAN_FALSE)
   483                         }
   493 	                {
   484                     }
   494 	                    impl->tagmatchesfilter[idx] = XA_BOOLEAN_TRUE;
   485                 /* check if all filters apply */
   495 	                    impl->filteredcount++;
   486                 if (filterMask == matchMask)
   496 	                }
   487                     {
   497 	            }
   488                     if (impl->tagmatchesfilter[idx] == XA_BOOLEAN_FALSE)
   498 	            /*reset matchmask*/
   489                         {
   499 	            matchMask=0;
   490                         impl->tagmatchesfilter[idx] = XA_BOOLEAN_TRUE;
   500 	        }
   491                         impl->filteredcount++;
   501 	    }
   492                         }
   502     }
   493                     }
   503     DEBUG_API_A1("<-XAMetadataExtractionItfImpl_AddKeyFilter (%d)", (int)res);
   494                 /*reset matchmask*/
       
   495                 matchMask = 0;
       
   496                 }
       
   497             }
       
   498         }DEBUG_API_A1("<-XAMetadataExtractionItfImpl_AddKeyFilter (%d)", (int)res);
   504     return res;
   499     return res;
   505  }
   500     }
   506 
   501 
   507 /*
   502 /*
   508  * Clears the key filter
   503  * Clears the key filter
   509  */
   504  */
   510 XAresult XAMetadataExtractionItfImpl_ClearKeyFilter(XAMetadataExtractionItf self)
   505 XAresult XAMetadataExtractionItfImpl_ClearKeyFilter(
   511 {
   506         XAMetadataExtractionItf self)
       
   507     {
   512     XAMetadataExtractionItfImpl *impl = NULL;
   508     XAMetadataExtractionItfImpl *impl = NULL;
   513     XAresult res = XA_RESULT_SUCCESS;
   509     XAresult res = XA_RESULT_SUCCESS;
   514  
   510 
   515     XAuint32 idx = 0;
   511     XAuint32 idx = 0;
   516 
   512 
   517     DEBUG_API("->XAMetadataExtractionItfImpl_ClearKeyFilter");
   513     DEBUG_API("->XAMetadataExtractionItfImpl_ClearKeyFilter");
   518     impl = GetImpl(self);
   514     impl = GetImpl(self);
   519     if( !impl )
   515     if (!impl)
   520     {
   516         {
   521         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   517         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   522         res = XA_RESULT_PARAMETER_INVALID;
   518         res = XA_RESULT_PARAMETER_INVALID;
   523     }
   519         }
   524     else
   520     else
   525     {
   521         {
   526     
   522 
   527 		if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF)
   523         if (impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF)
   528 		{
   524             {
   529 			DEBUG_API("<-XAMetadataExtractionItfImpl_ClearKeyFilter Not Supported in MMF");
   525             DEBUG_API("<-XAMetadataExtractionItfImpl_ClearKeyFilter Not Supported in MMF");
   530 			res = XA_RESULT_PARAMETER_INVALID;
   526             res = XA_RESULT_PARAMETER_INVALID;
   531 		}
   527             }
   532 		else
   528         else
   533 		{
   529             {
   534 	        if(impl->tagmatchesfilter)
   530             if (impl->tagmatchesfilter)
   535 	        {
   531                 {
   536 	 
   532 
   537 	            for(idx=0; idx < impl->currentTags.itemcount; idx++)
   533                 for (idx = 0; idx < impl->currentTags.itemcount; idx++)
   538 	            {
   534                     {
   539 	                impl->tagmatchesfilter[idx] = XA_BOOLEAN_FALSE;
   535                     impl->tagmatchesfilter[idx] = XA_BOOLEAN_FALSE;
   540 	            }
   536                     }
   541 
   537 
   542 	        }
   538                 }
   543 	        impl->filteredcount = 0;
   539             impl->filteredcount = 0;
   544 	        impl->filteringOn = XA_BOOLEAN_FALSE;
   540             impl->filteringOn = XA_BOOLEAN_FALSE;
   545 	    }
   541             }
   546     }
   542         }
   547 
   543 
   548     DEBUG_API_A1("<-XAMetadataExtractionItfImpl_ClearKeyFilter (%d)", (int)res);
   544     DEBUG_API_A1("<-XAMetadataExtractionItfImpl_ClearKeyFilter (%d)", (int)res);
   549     return res;
   545     return res;
   550 }
   546     }
   551 
   547 
   552 /*****************************************************************************
   548 /*****************************************************************************
   553  * XAMetadataExtractionItfImpl -specific methods
   549  * XAMetadataExtractionItfImpl -specific methods
   554  *****************************************************************************/
   550  *****************************************************************************/
   555 
   551 
   556 /* XAMetadataExtractionItfImpl* XAMetadataExtractionItfImpl_Create()
   552 /* XAMetadataExtractionItfImpl* XAMetadataExtractionItfImpl_Create()
   557  * Description: Allocate and initialize XAMetadataExtractionItfImpl
   553  * Description: Allocate and initialize XAMetadataExtractionItfImpl
   558  */
   554  */
   559 XAMetadataExtractionItfImpl* XAMetadataExtractionItfImpl_Create(XAAdaptationBaseCtx *adaptCtx)
   555 XAMetadataExtractionItfImpl* XAMetadataExtractionItfImpl_Create(
   560 {
   556         XAAdaptationBaseCtx *adaptCtx)
       
   557     {
   561     XAMetadataExtractionItfImpl *self = NULL;
   558     XAMetadataExtractionItfImpl *self = NULL;
   562     DEBUG_API("->XAMetadataExtractionItfImpl_Create");
   559     DEBUG_API("->XAMetadataExtractionItfImpl_Create");
   563 
   560 
   564     self = (XAMetadataExtractionItfImpl*)calloc(1,sizeof(XAMetadataExtractionItfImpl));
   561     self = (XAMetadataExtractionItfImpl*) calloc(1,
   565 
   562             sizeof(XAMetadataExtractionItfImpl));
   566     if( self )
   563 
   567     {
   564     if (self)
       
   565         {
   568         /* init itf default implementation */
   566         /* init itf default implementation */
   569         self->itf.GetItemCount = XAMetadataExtractionItfImpl_GetItemCount;
   567         self->itf.GetItemCount = XAMetadataExtractionItfImpl_GetItemCount;
   570         self->itf.GetKeySize = XAMetadataExtractionItfImpl_GetKeySize;
   568         self->itf.GetKeySize = XAMetadataExtractionItfImpl_GetKeySize;
   571         self->itf.GetKey = XAMetadataExtractionItfImpl_GetKey;
   569         self->itf.GetKey = XAMetadataExtractionItfImpl_GetKey;
   572         self->itf.GetValueSize = XAMetadataExtractionItfImpl_GetValueSize;
   570         self->itf.GetValueSize = XAMetadataExtractionItfImpl_GetValueSize;
   578         self->filteredcount = 0;
   576         self->filteredcount = 0;
   579         self->filteringOn = XA_BOOLEAN_FALSE;
   577         self->filteringOn = XA_BOOLEAN_FALSE;
   580 
   578 
   581         self->adaptCtx = adaptCtx;
   579         self->adaptCtx = adaptCtx;
   582 
   580 
   583 		if(self->adaptCtx->fwtype != FWMgrFWMMF)
   581         if (self->adaptCtx->fwtype != FWMgrFWMMF)
   584 		{
   582             {
   585 	        XAAdaptationBase_AddEventHandler( adaptCtx, &XAMetadataExtractionItfImp_AdaptCb, XA_METADATAEVENTS, self );
   583             XAAdaptationBase_AddEventHandler(adaptCtx,
   586 		}
   584                     &XAMetadataExtractionItfImp_AdaptCb, XA_METADATAEVENTS,
       
   585                     self);
       
   586             }
   587 
   587 
   588         self->self = self;
   588         self->self = self;
   589     }
   589         }
   590 
   590 
   591     DEBUG_API("<-XAMetadataExtractionItfImpl_Create");
   591     DEBUG_API("<-XAMetadataExtractionItfImpl_Create");
   592     return self;
   592     return self;
   593 }
   593     }
   594 
   594 
   595 /* void XAMetadataExtractionItfImpl_Free(XAMetadataExtractionItfImpl* self)
   595 /* void XAMetadataExtractionItfImpl_Free(XAMetadataExtractionItfImpl* self)
   596  * Description: Free all resources reserved at XAMetadataExtractionItfImpl_Create
   596  * Description: Free all resources reserved at XAMetadataExtractionItfImpl_Create
   597  */
   597  */
   598 void XAMetadataExtractionItfImpl_Free(XAMetadataExtractionItfImpl* self)
   598 void XAMetadataExtractionItfImpl_Free(XAMetadataExtractionItfImpl* self)
   599 {
   599     {
   600     DEBUG_API("->XAMetadataExtractionItfImpl_Free");
   600     DEBUG_API("->XAMetadataExtractionItfImpl_Free");
   601     assert(self==self->self);
   601     assert(self==self->self);
   602  
   602 
   603 	 if(self->adaptCtx->fwtype != FWMgrFWMMF)
   603     if (self->adaptCtx->fwtype != FWMgrFWMMF)
   604 	 {
   604         {
   605     	XAAdaptationBase_RemoveEventHandler( self->adaptCtx, &XAMetadataExtractionItfImp_AdaptCb );
   605         XAAdaptationBase_RemoveEventHandler(self->adaptCtx,
   606 	    XAMetadataAdapt_FreeImplTagList(&(self->currentTags), XA_BOOLEAN_TRUE);
   606                 &XAMetadataExtractionItfImp_AdaptCb);
   607 		
   607         XAMetadataAdapt_FreeImplTagList(&(self->currentTags), XA_BOOLEAN_TRUE);
   608 		if(self->tagmatchesfilter)
   608 
   609 		{
   609         if (self->tagmatchesfilter)
   610 			free(self->tagmatchesfilter);
   610             {
   611 		}
   611             free(self->tagmatchesfilter);
   612 	 }
   612             }
       
   613         }
   613 
   614 
   614     free(self);
   615     free(self);
   615     DEBUG_API("<-XAMetadataExtractionItfImpl_Free");
   616     DEBUG_API("<-XAMetadataExtractionItfImpl_Free");
   616 }
   617     }
   617 
   618 
   618  
       
   619 /* With this method, adaptation infroms that new tags are found (e.g. if source,
   619 /* With this method, adaptation infroms that new tags are found (e.g. if source,
   620  * has changed, live stream contains metadata...)
   620  * has changed, live stream contains metadata...)
   621  */
   621  */
   622 void XAMetadataExtractionItfImp_AdaptCb( void *pHandlerCtx, XAAdaptEvent *event )
   622 void XAMetadataExtractionItfImp_AdaptCb(void *pHandlerCtx,
   623 {
   623         XAAdaptEvent *event)
       
   624     {
   624     XAMetadataExtractionItfImpl* impl = NULL;
   625     XAMetadataExtractionItfImpl* impl = NULL;
   625     DEBUG_API("->XAMetadataExtractionItfImp_AdaptCb");
   626     DEBUG_API("->XAMetadataExtractionItfImp_AdaptCb");
   626     impl = (XAMetadataExtractionItfImpl*)pHandlerCtx;
   627     impl = (XAMetadataExtractionItfImpl*) pHandlerCtx;
   627     if(!impl)
   628     if (!impl)
   628     {
   629         {
   629         DEBUG_ERR("XAMetadataExtractionItfImp_AdaptCb, invalid context pointer!");
   630         DEBUG_ERR("XAMetadataExtractionItfImp_AdaptCb, invalid context pointer!");DEBUG_API("<-XAMetadataExtractionItfImp_AdaptCb");
   630         DEBUG_API("<-XAMetadataExtractionItfImp_AdaptCb");
       
   631         return;
   631         return;
   632     }
   632         }
   633     if( event && event->eventid == XA_ADAPT_MDE_TAGS_AVAILABLE )
   633     if (event && event->eventid == XA_ADAPT_MDE_TAGS_AVAILABLE)
   634     {
   634         {
   635         /* get the tag list */
   635         /* get the tag list */
   636         XAMetadataExtractionItfAdapt_FillTagList( (XAAdaptationGstCtx*)impl->adaptCtx, &(impl->currentTags) );
   636         XAMetadataExtractionItfAdapt_FillTagList(
   637         if(impl->tagmatchesfilter)
   637                 (XAAdaptationGstCtx*) impl->adaptCtx, &(impl->currentTags));
   638         {
   638         if (impl->tagmatchesfilter)
       
   639             {
   639             free(impl->tagmatchesfilter);
   640             free(impl->tagmatchesfilter);
   640         }
   641             }
   641         impl->tagmatchesfilter = calloc(impl->currentTags.itemcount,sizeof(XAboolean));
   642         impl->tagmatchesfilter = calloc(impl->currentTags.itemcount,
       
   643                 sizeof(XAboolean));
   642         impl->filteredcount = 0;
   644         impl->filteredcount = 0;
   643     }
   645         }
   644     else
   646     else
   645     {
   647         {
   646         DEBUG_INFO("unhandled");
   648         DEBUG_INFO("unhandled");
   647     }
   649         }DEBUG_API("<-XAMetadataExtractionItfImp_AdaptCb");
   648     DEBUG_API("<-XAMetadataExtractionItfImp_AdaptCb");
   650     }
   649 }
       
   650 
       
   651 
   651 
   652 /* For given index over filtered array, return index over whole array
   652 /* For given index over filtered array, return index over whole array
   653  */
   653  */
   654 XAresult CheckAndUnfilterIndex(XAMetadataExtractionItfImpl *impl,
   654 XAresult CheckAndUnfilterIndex(XAMetadataExtractionItfImpl *impl,
   655                                XAuint32 oldidx, XAuint32 *newidx)
   655         XAuint32 oldidx, XAuint32 *newidx)
   656 {
   656     {
   657     DEBUG_API("->CheckAndUnfilterIndex");
   657     DEBUG_API("->CheckAndUnfilterIndex");
   658  
   658 
   659     if( impl->filteringOn )
   659     if (impl->filteringOn)
   660     {
   660         {
   661         XAint16 i=-1;
   661         XAint16 i = -1;
   662         if(oldidx>=impl->filteredcount)
   662         if (oldidx >= impl->filteredcount)
   663         {
   663             {
   664             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   664             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-CheckAndUnfilterIndex");
   665             DEBUG_API("<-CheckAndUnfilterIndex");
       
   666             return XA_RESULT_PARAMETER_INVALID;
   665             return XA_RESULT_PARAMETER_INVALID;
   667         }
   666             }
   668         *newidx=0;
   667         *newidx = 0;
   669         while(*newidx<impl->currentTags.itemcount)
   668         while (*newidx < impl->currentTags.itemcount)
   670         {
   669             {
   671             if(impl->tagmatchesfilter[*newidx]) i++;
   670             if (impl->tagmatchesfilter[*newidx])
   672             if(i<oldidx) (*newidx)++;
   671                 i++;
   673             else break;
   672             if (i < oldidx)
   674         }
   673                 (*newidx)++;
   675         if(*newidx==impl->currentTags.itemcount)
   674             else
   676         {
   675                 break;
       
   676             }
       
   677         if (*newidx == impl->currentTags.itemcount)
       
   678             {
   677             /* should not end up here */
   679             /* should not end up here */
   678             *newidx=0;
   680             *newidx = 0;
   679             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   681             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-CheckAndUnfilterIndex");
   680             DEBUG_API("<-CheckAndUnfilterIndex");
       
   681             return XA_RESULT_PARAMETER_INVALID;
   682             return XA_RESULT_PARAMETER_INVALID;
   682         }
   683             }
   683     }
   684         }
   684     else
   685     else
   685     {
   686         {
   686         if(oldidx>=impl->currentTags.itemcount)
   687         if (oldidx >= impl->currentTags.itemcount)
   687         {
   688             {
   688             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   689             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-CheckAndUnfilterIndex");
   689             DEBUG_API("<-CheckAndUnfilterIndex");
       
   690             return XA_RESULT_PARAMETER_INVALID;
   690             return XA_RESULT_PARAMETER_INVALID;
   691         }
   691             }
   692         *newidx=oldidx;
   692         *newidx = oldidx;
   693     }
   693         }
   694 
   694 
   695     DEBUG_API("<-CheckAndUnfilterIndex");
   695     DEBUG_API("<-CheckAndUnfilterIndex");
   696     return XA_RESULT_SUCCESS;
   696     return XA_RESULT_SUCCESS;
   697 }
   697     }
   698 
   698 
   699