|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <stdio.h> |
|
19 #include <stdlib.h> |
|
20 #include <string.h> |
|
21 #include <assert.h> |
|
22 |
|
23 #include "xametadataextractionitf.h" |
|
24 #include "xadebug.h" |
|
25 #ifdef _GSTREAMER_BACKEND_ |
|
26 #include "XAMetadataAdaptation.h" |
|
27 #endif |
|
28 /* XAMetadataExtractionItfImpl* GetImpl(XAMetadataExtractionItf self) |
|
29 * Description: Validate interface pointer and cast it to implementation pointer. |
|
30 **/ |
|
31 static XAMetadataExtractionItfImpl* GetImpl(XAMetadataExtractionItf self) |
|
32 { |
|
33 if( self ) |
|
34 { |
|
35 XAMetadataExtractionItfImpl* impl = (XAMetadataExtractionItfImpl*)(*self); |
|
36 if( impl && (impl == impl->self) ) |
|
37 { |
|
38 return impl; |
|
39 } |
|
40 } |
|
41 return NULL; |
|
42 } |
|
43 |
|
44 /***************************************************************************** |
|
45 * Base interface XAMetadataExtractionItf implementation |
|
46 *****************************************************************************/ |
|
47 |
|
48 /* |
|
49 * Returns the number of metadata items within the current scope of the object. |
|
50 * @XAuint32 *pItemCount |
|
51 * Number of metadata items. Must be non-NULL |
|
52 */ |
|
53 XAresult XAMetadataExtractionItfImpl_GetItemCount(XAMetadataExtractionItf self, |
|
54 XAuint32 *pItemCount) |
|
55 { |
|
56 XAMetadataExtractionItfImpl *impl = NULL; |
|
57 XAresult res = XA_RESULT_SUCCESS; |
|
58 DEBUG_API("->XAMetadataExtractionItfImpl_GetItemCount"); |
|
59 |
|
60 impl = GetImpl(self); |
|
61 /* check parameters */ |
|
62 if( !impl || !pItemCount ) |
|
63 { |
|
64 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
65 res = XA_RESULT_PARAMETER_INVALID; |
|
66 } |
|
67 else |
|
68 { |
|
69 #ifdef _GSTREAMER_BACKEND_ |
|
70 if( impl->adaptCtx ) |
|
71 { |
|
72 if(impl->filteringOn) |
|
73 { |
|
74 *pItemCount = impl->filteredcount; |
|
75 } |
|
76 else |
|
77 { |
|
78 *pItemCount = impl->currentTags.itemcount; |
|
79 } |
|
80 res = XA_RESULT_SUCCESS; |
|
81 } |
|
82 else |
|
83 { |
|
84 res = XA_RESULT_INTERNAL_ERROR; |
|
85 } |
|
86 #endif |
|
87 DEBUG_INFO_A1("itemCount = %d", (int)*pItemCount); |
|
88 } |
|
89 |
|
90 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetItemCount (%d)", (int)res); |
|
91 return res; |
|
92 } |
|
93 |
|
94 /* |
|
95 * Returns the byte size of a given metadata key |
|
96 * |
|
97 * @XAuint32 index |
|
98 * Metadata item Index. Range is [0, GetItemCount) |
|
99 * @XAuint32 *pKeySize |
|
100 * Address to store key size. size must be greater than 0. Must be non-NULL |
|
101 */ |
|
102 XAresult XAMetadataExtractionItfImpl_GetKeySize(XAMetadataExtractionItf self, |
|
103 XAuint32 index, |
|
104 XAuint32 *pKeySize) |
|
105 { |
|
106 XAMetadataExtractionItfImpl *impl = NULL; |
|
107 XAresult res = XA_RESULT_SUCCESS; |
|
108 XAuint32 newidx = 0; |
|
109 DEBUG_API("->XAMetadataExtractionItfImpl_GetKeySize"); |
|
110 |
|
111 impl = GetImpl(self); |
|
112 if( !impl || !pKeySize ) |
|
113 { |
|
114 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
115 DEBUG_API("<-XAMetadataExtractionItfImpl_GetKeySize"); |
|
116 return XA_RESULT_PARAMETER_INVALID; |
|
117 } |
|
118 *pKeySize = 0; |
|
119 |
|
120 /* check index and return unfiltered index */ |
|
121 if( CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS ) |
|
122 { |
|
123 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
124 DEBUG_API("<-XAMetadataExtractionItfImpl_GetKeySize"); |
|
125 return XA_RESULT_PARAMETER_INVALID; |
|
126 } |
|
127 #ifdef _GSTREAMER_BACKEND_ |
|
128 /* size = size of struct + size of data - 1 (struct size already includes one char) */ |
|
129 *pKeySize = sizeof(XAMetadataInfo) + impl->currentTags.mdeKeys[newidx]->size - 1; |
|
130 #endif |
|
131 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetKeySize (%d)", (int)res); |
|
132 return res; |
|
133 } |
|
134 |
|
135 /* |
|
136 * Returns a XAMetadataInfo structure and associated data referenced by the structure for a key. |
|
137 * @XAuint32 index |
|
138 * Metadata item Index. Range is [0, GetItemCount()) |
|
139 * @XAuint32 keySize |
|
140 * Size of the memory block passed as key. Range is [1, GetKeySize]. |
|
141 * @XAMetadataInfo *pKey |
|
142 * Address to store the key. Must be non-NULL |
|
143 */ |
|
144 XAresult XAMetadataExtractionItfImpl_GetKey(XAMetadataExtractionItf self, |
|
145 XAuint32 index, |
|
146 XAuint32 keySize, |
|
147 XAMetadataInfo *pKey) |
|
148 { |
|
149 XAMetadataExtractionItfImpl *impl = NULL; |
|
150 XAresult res = XA_RESULT_SUCCESS; |
|
151 XAuint32 newidx = 0; |
|
152 #ifdef _GSTREAMER_BACKEND_ |
|
153 XAuint32 neededsize = 0; |
|
154 #endif |
|
155 XAuint32 newdatasize = 0; |
|
156 DEBUG_API("->XAMetadataExtractionItfImpl_GetKey"); |
|
157 |
|
158 impl = GetImpl(self); |
|
159 if( !impl || !pKey ) |
|
160 { |
|
161 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
162 DEBUG_API("<-XAMetadataExtractionItfImpl_GetKey"); |
|
163 return XA_RESULT_PARAMETER_INVALID; |
|
164 } |
|
165 |
|
166 /* check index and return unfiltered index */ |
|
167 if(CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS) |
|
168 { |
|
169 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
170 DEBUG_API("<-XAMetadataExtractionItfImpl_GetKey"); |
|
171 return XA_RESULT_PARAMETER_INVALID; |
|
172 } |
|
173 |
|
174 memset(pKey,0,keySize); |
|
175 #ifdef _GSTREAMER_BACKEND_ |
|
176 /* needed size = size of struct + size of data - 1 (struct size already includes one char) */ |
|
177 neededsize = sizeof(XAMetadataInfo) + impl->currentTags.mdeKeys[newidx]->size - 1; |
|
178 if( keySize<neededsize ) |
|
179 { /* cannot fit all of key data */ |
|
180 newdatasize = impl->currentTags.mdeKeys[newidx]->size - (neededsize-keySize); |
|
181 DEBUG_ERR("XA_RESULT_BUFFER_INSUFFICIENT"); |
|
182 res = XA_RESULT_BUFFER_INSUFFICIENT; |
|
183 } |
|
184 else |
|
185 { |
|
186 newdatasize = impl->currentTags.mdeKeys[newidx]->size; |
|
187 res = XA_RESULT_SUCCESS; |
|
188 } |
|
189 /* copy data up to given size */ |
|
190 memcpy(pKey,impl->currentTags.mdeKeys[newidx],keySize-1); |
|
191 /* ensure null-termination */ |
|
192 #endif |
|
193 memset(pKey->data+newdatasize-1,0,1); |
|
194 pKey->size = newdatasize; |
|
195 |
|
196 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetKey (%d)", (int)res); |
|
197 return res; |
|
198 } |
|
199 |
|
200 |
|
201 /* |
|
202 * Returns the byte size of a given metadata value |
|
203 * @XAuint32 index |
|
204 * Metadata item Index. Range is [0, GetItemCount()) |
|
205 * @XAuint32 *pValueSize |
|
206 * Address to store value size. size must be greater than 0. Must be non-NULL |
|
207 */ |
|
208 XAresult XAMetadataExtractionItfImpl_GetValueSize(XAMetadataExtractionItf self, |
|
209 XAuint32 index, |
|
210 XAuint32 *pValueSize) |
|
211 { |
|
212 XAMetadataExtractionItfImpl *impl = NULL; |
|
213 XAresult res = XA_RESULT_SUCCESS; |
|
214 XAuint32 newidx = 0; |
|
215 DEBUG_API("->XAMetadataExtractionItfImpl_GetValueSize"); |
|
216 |
|
217 impl = GetImpl(self); |
|
218 if( !impl || !pValueSize ) |
|
219 { |
|
220 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
221 DEBUG_API("<-XAMetadataExtractionItfImpl_GetValueSize"); |
|
222 return XA_RESULT_PARAMETER_INVALID; |
|
223 } |
|
224 *pValueSize = 0; |
|
225 |
|
226 /* check index and return unfiltered index */ |
|
227 if(CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS) |
|
228 { |
|
229 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
230 DEBUG_API("<-XAMetadataExtractionItfImpl_GetValueSize"); |
|
231 return XA_RESULT_PARAMETER_INVALID; |
|
232 } |
|
233 #ifdef _GSTREAMER_BACKEND_ |
|
234 /* size = size of struct + size of data - 1 (struct size already includes one char) */ |
|
235 *pValueSize = sizeof(XAMetadataInfo) + impl->currentTags.mdeValues[newidx]->size - 1; |
|
236 #endif |
|
237 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetValueSize (%d)", (int)res); |
|
238 return res; |
|
239 } |
|
240 |
|
241 /* |
|
242 * Returns a XAMetadataInfo structure and associated data referenced by the structure for a value. |
|
243 * @XAuint32 index |
|
244 * Metadata item Index. Range is [0, GetItemCount()) |
|
245 * @XAuint32 valueSize |
|
246 * Size of the memory block passed as value. Range is [0, GetValueSize] |
|
247 * @XAMetadataInfo *pValue |
|
248 * Address to store the value. Must be non-NULL |
|
249 */ |
|
250 XAresult XAMetadataExtractionItfImpl_GetValue(XAMetadataExtractionItf self, |
|
251 XAuint32 index, |
|
252 XAuint32 valueSize, |
|
253 XAMetadataInfo *pValue) |
|
254 { |
|
255 XAMetadataExtractionItfImpl *impl = NULL; |
|
256 XAresult res = XA_RESULT_SUCCESS; |
|
257 XAuint32 newidx = 0; |
|
258 #ifdef _GSTREAMER_BACKEND_ |
|
259 XAuint32 neededsize = 0; |
|
260 #endif |
|
261 XAuint32 newdatasize = 0; |
|
262 DEBUG_API("->XAMetadataExtractionItfImpl_GetValue"); |
|
263 |
|
264 impl = GetImpl(self); |
|
265 if( !impl || !pValue ) |
|
266 { |
|
267 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
268 DEBUG_API("<-XAMetadataExtractionItfImpl_GetValue"); |
|
269 return XA_RESULT_PARAMETER_INVALID; |
|
270 } |
|
271 |
|
272 /* check index and return unfiltered index */ |
|
273 if(CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS) |
|
274 { |
|
275 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
276 DEBUG_API("<-XAMetadataExtractionItfImpl_GetValue"); |
|
277 return XA_RESULT_PARAMETER_INVALID; |
|
278 } |
|
279 |
|
280 memset(pValue,0,valueSize); |
|
281 #ifdef _GSTREAMER_BACKEND_ |
|
282 /* needed size = size of struct + size of data - 1 (struct size already includes one char) */ |
|
283 neededsize = sizeof(XAMetadataInfo) + impl->currentTags.mdeValues[newidx]->size - 1; |
|
284 if( valueSize<neededsize ) |
|
285 { /* cannot fit all of key data */ |
|
286 newdatasize = impl->currentTags.mdeValues[newidx]->size - (neededsize-valueSize); |
|
287 DEBUG_ERR("XA_RESULT_BUFFER_INSUFFICIENT"); |
|
288 res = XA_RESULT_BUFFER_INSUFFICIENT; |
|
289 } |
|
290 else |
|
291 { |
|
292 newdatasize = impl->currentTags.mdeValues[newidx]->size; |
|
293 res = XA_RESULT_SUCCESS; |
|
294 } |
|
295 /* copy data up to given size */ |
|
296 memcpy(pValue,impl->currentTags.mdeValues[newidx],valueSize-1); |
|
297 /* ensure null-termination */ |
|
298 #endif |
|
299 memset(pValue->data+newdatasize-1,0,1); |
|
300 |
|
301 pValue->size = newdatasize; |
|
302 |
|
303 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetValue (%d)",(int)res); |
|
304 return res; |
|
305 } |
|
306 |
|
307 |
|
308 /* |
|
309 * Adds a filter for a specific key |
|
310 * @XAuint32 keySize |
|
311 * Size in bytes, of the pKey parameter. Ignored if filtering by key is disabled |
|
312 * @const void *pKey |
|
313 * The key to filter by. The entire key must match. Ignored if filtering by key is disabled. |
|
314 * @XAuint32 keyEncoding |
|
315 * Character encoding of the pKey parameter. Ignored if filtering by key is disabled |
|
316 * @const XAchar *pValueLangCountry |
|
317 * Language / country code of the value to filter by. Ignored if filtering by language / country is disabled |
|
318 * @XAuint32 valueEncoding |
|
319 * Encoding of the value to filter by. Ignored if filtering by encoding is disabled |
|
320 * @XAuint8 filterMask |
|
321 * Bitmask indicating which criteria to filter by. Should be one of the XA_METADATA_FILTER macros |
|
322 */ |
|
323 XAresult XAMetadataExtractionItfImpl_AddKeyFilter(XAMetadataExtractionItf self, |
|
324 XAuint32 keySize, |
|
325 const void *pKey, |
|
326 XAuint32 keyEncoding, |
|
327 const XAchar *pValueLangCountry, |
|
328 XAuint32 valueEncoding, |
|
329 XAuint8 filterMask) |
|
330 { |
|
331 XAresult res = XA_RESULT_SUCCESS; |
|
332 |
|
333 |
|
334 #ifdef _GSTREAMER_BACKEND_ |
|
335 XAMetadataExtractionItfImpl *impl = NULL; |
|
336 const XAchar* parsedkey; |
|
337 impl = GetImpl(self); |
|
338 #endif |
|
339 DEBUG_API("->XAMetadataExtractionItfImpl_AddKeyFilter"); |
|
340 |
|
341 #ifdef _GSTREAMER_BACKEND_ |
|
342 XAuint32 idx = 0; |
|
343 XAuint8 matchMask = 0; |
|
344 if( !impl ) |
|
345 { |
|
346 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
347 DEBUG_API("<-XAMetadataExtractionItfImpl_AddKeyFilter"); |
|
348 return XA_RESULT_PARAMETER_INVALID; |
|
349 } |
|
350 else |
|
351 { |
|
352 impl->filteringOn = XA_BOOLEAN_TRUE; |
|
353 for(idx=0; idx < impl->currentTags.itemcount; idx++) |
|
354 { |
|
355 if((filterMask & XA_METADATA_FILTER_KEY) && pKey) |
|
356 { |
|
357 parsedkey = XAMetadataAdapt_ParseKhronosKey(pKey); |
|
358 if( strcmp((char*)parsedkey, |
|
359 (char*)impl->currentTags.mdeKeys[idx]->data) == 0 ) |
|
360 { |
|
361 matchMask |= XA_METADATA_FILTER_KEY; |
|
362 } |
|
363 } |
|
364 if(filterMask & XA_METADATA_FILTER_LANG && pValueLangCountry) |
|
365 { |
|
366 if( strcmp((char*)pValueLangCountry, |
|
367 (char*)impl->currentTags.mdeKeys[idx]->langCountry) == 0 ) |
|
368 { |
|
369 matchMask |= XA_METADATA_FILTER_LANG; |
|
370 } |
|
371 } |
|
372 if(filterMask & XA_METADATA_FILTER_ENCODING) |
|
373 { |
|
374 if(keyEncoding==impl->currentTags.mdeKeys[idx]->encoding) |
|
375 { |
|
376 matchMask |= XA_METADATA_FILTER_ENCODING; |
|
377 } |
|
378 if(valueEncoding==impl->currentTags.mdeValues[idx]->encoding) |
|
379 { |
|
380 matchMask |= XA_METADATA_FILTER_ENCODING; |
|
381 } |
|
382 } |
|
383 /* check if all filters apply */ |
|
384 if(filterMask == matchMask) |
|
385 { |
|
386 if(impl->tagmatchesfilter[idx] == XA_BOOLEAN_FALSE) |
|
387 { |
|
388 impl->tagmatchesfilter[idx] = XA_BOOLEAN_TRUE; |
|
389 impl->filteredcount++; |
|
390 } |
|
391 } |
|
392 /*reset matchmask*/ |
|
393 matchMask=0; |
|
394 } |
|
395 } |
|
396 #endif |
|
397 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_AddKeyFilter (%d)", (int)res); |
|
398 return res; |
|
399 } |
|
400 |
|
401 /* |
|
402 * Clears the key filter |
|
403 */ |
|
404 XAresult XAMetadataExtractionItfImpl_ClearKeyFilter(XAMetadataExtractionItf self) |
|
405 { |
|
406 XAMetadataExtractionItfImpl *impl = NULL; |
|
407 XAresult res = XA_RESULT_SUCCESS; |
|
408 #ifdef _GSTREAMER_BACKEND_ |
|
409 XAuint32 idx = 0; |
|
410 #endif |
|
411 DEBUG_API("->XAMetadataExtractionItfImpl_ClearKeyFilter"); |
|
412 impl = GetImpl(self); |
|
413 if( !impl ) |
|
414 { |
|
415 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
416 res = XA_RESULT_PARAMETER_INVALID; |
|
417 } |
|
418 else |
|
419 { |
|
420 if(impl->tagmatchesfilter) |
|
421 { |
|
422 #ifdef _GSTREAMER_BACKEND_ |
|
423 for(idx=0; idx < impl->currentTags.itemcount; idx++) |
|
424 { |
|
425 impl->tagmatchesfilter[idx] = XA_BOOLEAN_FALSE; |
|
426 } |
|
427 #endif |
|
428 } |
|
429 impl->filteredcount = 0; |
|
430 impl->filteringOn = XA_BOOLEAN_FALSE; |
|
431 } |
|
432 |
|
433 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_ClearKeyFilter (%d)", (int)res); |
|
434 return res; |
|
435 } |
|
436 |
|
437 /***************************************************************************** |
|
438 * XAMetadataExtractionItfImpl -specific methods |
|
439 *****************************************************************************/ |
|
440 #ifdef _GSTREAMER_BACKEND_ |
|
441 /* XAMetadataExtractionItfImpl* XAMetadataExtractionItfImpl_Create() |
|
442 * Description: Allocate and initialize XAMetadataExtractionItfImpl |
|
443 */ |
|
444 XAMetadataExtractionItfImpl* XAMetadataExtractionItfImpl_Create(XAAdaptationBaseCtx *adaptCtx) |
|
445 { |
|
446 XAMetadataExtractionItfImpl *self = NULL; |
|
447 DEBUG_API("->XAMetadataExtractionItfImpl_Create"); |
|
448 |
|
449 self = (XAMetadataExtractionItfImpl*)calloc(1,sizeof(XAMetadataExtractionItfImpl)); |
|
450 |
|
451 if( self ) |
|
452 { |
|
453 /* init itf default implementation */ |
|
454 self->itf.GetItemCount = XAMetadataExtractionItfImpl_GetItemCount; |
|
455 self->itf.GetKeySize = XAMetadataExtractionItfImpl_GetKeySize; |
|
456 self->itf.GetKey = XAMetadataExtractionItfImpl_GetKey; |
|
457 self->itf.GetValueSize = XAMetadataExtractionItfImpl_GetValueSize; |
|
458 self->itf.GetValue = XAMetadataExtractionItfImpl_GetValue; |
|
459 self->itf.AddKeyFilter = XAMetadataExtractionItfImpl_AddKeyFilter; |
|
460 self->itf.ClearKeyFilter = XAMetadataExtractionItfImpl_ClearKeyFilter; |
|
461 |
|
462 /* init variables */ |
|
463 self->filteredcount = 0; |
|
464 self->filteringOn = XA_BOOLEAN_FALSE; |
|
465 |
|
466 self->adaptCtx = adaptCtx; |
|
467 XAAdaptationBase_AddEventHandler( adaptCtx, &XAMetadataExtractionItfImp_AdaptCb, XA_METADATAEVENTS, self ); |
|
468 |
|
469 self->self = self; |
|
470 } |
|
471 |
|
472 DEBUG_API("<-XAMetadataExtractionItfImpl_Create"); |
|
473 return self; |
|
474 } |
|
475 #endif |
|
476 /* void XAMetadataExtractionItfImpl_Free(XAMetadataExtractionItfImpl* self) |
|
477 * Description: Free all resources reserved at XAMetadataExtractionItfImpl_Create |
|
478 */ |
|
479 void XAMetadataExtractionItfImpl_Free(XAMetadataExtractionItfImpl* self) |
|
480 { |
|
481 DEBUG_API("->XAMetadataExtractionItfImpl_Free"); |
|
482 assert(self==self->self); |
|
483 #ifdef _GSTREAMER_BACKEND_ |
|
484 XAAdaptationBase_RemoveEventHandler( self->adaptCtx, &XAMetadataExtractionItfImp_AdaptCb ); |
|
485 XAMetadataAdapt_FreeImplTagList(&(self->currentTags), XA_BOOLEAN_TRUE); |
|
486 #endif |
|
487 if(self->tagmatchesfilter) |
|
488 { |
|
489 free(self->tagmatchesfilter); |
|
490 } |
|
491 free(self); |
|
492 DEBUG_API("<-XAMetadataExtractionItfImpl_Free"); |
|
493 } |
|
494 |
|
495 #ifdef _GSTREAMER_BACKEND_ |
|
496 /* With this method, adaptation infroms that new tags are found (e.g. if source, |
|
497 * has changed, live stream contains metadata...) |
|
498 */ |
|
499 void XAMetadataExtractionItfImp_AdaptCb( void *pHandlerCtx, XAAdaptEvent *event ) |
|
500 { |
|
501 XAMetadataExtractionItfImpl* impl = NULL; |
|
502 DEBUG_API("->XAMetadataExtractionItfImp_AdaptCb"); |
|
503 impl = (XAMetadataExtractionItfImpl*)pHandlerCtx; |
|
504 if(!impl) |
|
505 { |
|
506 DEBUG_ERR("XAMetadataExtractionItfImp_AdaptCb, invalid context pointer!"); |
|
507 DEBUG_API("<-XAMetadataExtractionItfImp_AdaptCb"); |
|
508 return; |
|
509 } |
|
510 if( event && event->eventid == XA_ADAPT_MDE_TAGS_AVAILABLE ) |
|
511 { |
|
512 /* get the tag list */ |
|
513 XAMetadataExtractionItfAdapt_FillTagList( impl->adaptCtx, &(impl->currentTags) ); |
|
514 if(impl->tagmatchesfilter) |
|
515 { |
|
516 free(impl->tagmatchesfilter); |
|
517 } |
|
518 impl->tagmatchesfilter = calloc(impl->currentTags.itemcount,sizeof(XAboolean)); |
|
519 impl->filteredcount = 0; |
|
520 } |
|
521 else |
|
522 { |
|
523 DEBUG_INFO("unhandled"); |
|
524 } |
|
525 DEBUG_API("<-XAMetadataExtractionItfImp_AdaptCb"); |
|
526 } |
|
527 |
|
528 #endif |
|
529 /* For given index over filtered array, return index over whole array |
|
530 */ |
|
531 XAresult CheckAndUnfilterIndex(XAMetadataExtractionItfImpl *impl, |
|
532 XAuint32 oldidx, XAuint32 *newidx) |
|
533 { |
|
534 DEBUG_API("->CheckAndUnfilterIndex"); |
|
535 #ifdef _GSTREAMER_BACKEND_ |
|
536 if( impl->filteringOn ) |
|
537 { |
|
538 XAint16 i=-1; |
|
539 if(oldidx>=impl->filteredcount) |
|
540 { |
|
541 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
542 DEBUG_API("<-CheckAndUnfilterIndex"); |
|
543 return XA_RESULT_PARAMETER_INVALID; |
|
544 } |
|
545 *newidx=0; |
|
546 while(*newidx<impl->currentTags.itemcount) |
|
547 { |
|
548 if(impl->tagmatchesfilter[*newidx]) i++; |
|
549 if(i<oldidx) (*newidx)++; |
|
550 else break; |
|
551 } |
|
552 if(*newidx==impl->currentTags.itemcount) |
|
553 { |
|
554 /* should not end up here */ |
|
555 *newidx=0; |
|
556 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
557 DEBUG_API("<-CheckAndUnfilterIndex"); |
|
558 return XA_RESULT_PARAMETER_INVALID; |
|
559 } |
|
560 } |
|
561 else |
|
562 { |
|
563 if(oldidx>=impl->currentTags.itemcount) |
|
564 { |
|
565 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
566 DEBUG_API("<-CheckAndUnfilterIndex"); |
|
567 return XA_RESULT_PARAMETER_INVALID; |
|
568 } |
|
569 *newidx=oldidx; |
|
570 } |
|
571 #endif |
|
572 DEBUG_API("<-CheckAndUnfilterIndex"); |
|
573 return XA_RESULT_SUCCESS; |
|
574 } |
|
575 |
|
576 |