20 #include <string.h> |
20 #include <string.h> |
21 #include <assert.h> |
21 #include <assert.h> |
22 |
22 |
23 #include "xametadataextractionitf.h" |
23 #include "xametadataextractionitf.h" |
24 #include "xadebug.h" |
24 #include "xadebug.h" |
25 #ifdef _GSTREAMER_BACKEND_ |
25 |
26 #include "XAMetadataAdaptation.h" |
26 #include "xametadataadaptation.h" |
27 #endif |
27 |
|
28 #include "xaadaptationmmf.h" |
|
29 #include "xametadataadaptctxmmf.h" |
|
30 #include "xamediaplayeradaptctxmmf.h" |
|
31 #include "cmetadatautilityitf.h" |
|
32 |
28 /* XAMetadataExtractionItfImpl* GetImpl(XAMetadataExtractionItf self) |
33 /* XAMetadataExtractionItfImpl* GetImpl(XAMetadataExtractionItf self) |
29 * Description: Validate interface pointer and cast it to implementation pointer. |
34 * Description: Validate interface pointer and cast it to implementation pointer. |
30 **/ |
35 **/ |
31 static XAMetadataExtractionItfImpl* GetImpl(XAMetadataExtractionItf self) |
36 static XAMetadataExtractionItfImpl* GetImpl(XAMetadataExtractionItf self) |
32 { |
37 { |
64 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
83 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
65 res = XA_RESULT_PARAMETER_INVALID; |
84 res = XA_RESULT_PARAMETER_INVALID; |
66 } |
85 } |
67 else |
86 else |
68 { |
87 { |
69 #ifdef _GSTREAMER_BACKEND_ |
88 |
70 if( impl->adaptCtx ) |
89 if( impl->adaptCtx ) |
71 { |
90 { |
72 if(impl->filteringOn) |
91 |
73 { |
92 if(impl->adaptCtx->fwtype == FWMgrFWMMF) |
74 *pItemCount = impl->filteredcount; |
93 { |
75 } |
94 void *mmfCtx = GetMetadataUtilityContext((XAAdaptationMMFCtx*)impl->adaptCtx); |
76 else |
95 if(mmfCtx) |
77 { |
96 { |
78 *pItemCount = impl->currentTags.itemcount; |
97 res = mmf_get_item_count(mmfCtx, pItemCount); |
79 } |
98 } |
80 res = XA_RESULT_SUCCESS; |
99 else |
|
100 { |
|
101 res = XA_RESULT_PARAMETER_INVALID; |
|
102 } |
|
103 } |
|
104 else |
|
105 { |
|
106 if(impl->filteringOn) |
|
107 { |
|
108 *pItemCount = impl->filteredcount; |
|
109 } |
|
110 else |
|
111 { |
|
112 *pItemCount = impl->currentTags.itemcount; |
|
113 } |
|
114 res = XA_RESULT_SUCCESS; |
|
115 } |
81 } |
116 } |
82 else |
117 else |
83 { |
118 { |
84 res = XA_RESULT_INTERNAL_ERROR; |
119 res = XA_RESULT_INTERNAL_ERROR; |
85 } |
120 } |
86 #endif |
121 |
87 DEBUG_INFO_A1("itemCount = %d", (int)*pItemCount); |
122 DEBUG_INFO_A1("itemCount = %d", (int)*pItemCount); |
88 } |
123 } |
89 |
124 |
90 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetItemCount (%d)", (int)res); |
125 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetItemCount (%d)", (int)res); |
91 return res; |
126 return res; |
115 DEBUG_API("<-XAMetadataExtractionItfImpl_GetKeySize"); |
150 DEBUG_API("<-XAMetadataExtractionItfImpl_GetKeySize"); |
116 return XA_RESULT_PARAMETER_INVALID; |
151 return XA_RESULT_PARAMETER_INVALID; |
117 } |
152 } |
118 *pKeySize = 0; |
153 *pKeySize = 0; |
119 |
154 |
120 /* check index and return unfiltered index */ |
155 if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF) |
121 if( CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS ) |
156 { |
122 { |
157 void *mmfCtx = GetMetadataUtilityContext((XAAdaptationMMFCtx*)impl->adaptCtx); |
123 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
158 if(mmfCtx) |
124 DEBUG_API("<-XAMetadataExtractionItfImpl_GetKeySize"); |
159 { |
125 return XA_RESULT_PARAMETER_INVALID; |
160 res = mmf_get_key_size(mmfCtx, index, pKeySize); |
126 } |
161 } |
127 #ifdef _GSTREAMER_BACKEND_ |
162 else |
128 /* size = size of struct + size of data - 1 (struct size already includes one char) */ |
163 { |
129 *pKeySize = sizeof(XAMetadataInfo) + impl->currentTags.mdeKeys[newidx]->size - 1; |
164 res = XA_RESULT_PARAMETER_INVALID; |
130 #endif |
165 } |
|
166 } |
|
167 else |
|
168 { |
|
169 /* check index and return unfiltered index */ |
|
170 if( CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS ) |
|
171 { |
|
172 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
173 DEBUG_API("<-XAMetadataExtractionItfImpl_GetKeySize"); |
|
174 return XA_RESULT_PARAMETER_INVALID; |
|
175 } |
|
176 |
|
177 /* size = size of struct + size of data - 1 (struct size already includes one char) */ |
|
178 *pKeySize = sizeof(XAMetadataInfo) + impl->currentTags.mdeKeys[newidx]->size - 1; |
|
179 } |
|
180 |
131 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetKeySize (%d)", (int)res); |
181 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetKeySize (%d)", (int)res); |
132 return res; |
182 return res; |
133 } |
183 } |
134 |
184 |
135 /* |
185 /* |
161 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
211 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
162 DEBUG_API("<-XAMetadataExtractionItfImpl_GetKey"); |
212 DEBUG_API("<-XAMetadataExtractionItfImpl_GetKey"); |
163 return XA_RESULT_PARAMETER_INVALID; |
213 return XA_RESULT_PARAMETER_INVALID; |
164 } |
214 } |
165 |
215 |
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); |
216 memset(pKey,0,keySize); |
175 #ifdef _GSTREAMER_BACKEND_ |
217 |
176 /* needed size = size of struct + size of data - 1 (struct size already includes one char) */ |
218 if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF) |
177 neededsize = sizeof(XAMetadataInfo) + impl->currentTags.mdeKeys[newidx]->size - 1; |
219 { |
178 if( keySize<neededsize ) |
220 void *mmfCtx = GetMetadataUtilityContext((XAAdaptationMMFCtx*)impl->adaptCtx); |
179 { /* cannot fit all of key data */ |
221 if(mmfCtx) |
180 newdatasize = impl->currentTags.mdeKeys[newidx]->size - (neededsize-keySize); |
222 { |
181 DEBUG_ERR("XA_RESULT_BUFFER_INSUFFICIENT"); |
223 res = mmf_get_key(mmfCtx, index, keySize, pKey); |
182 res = XA_RESULT_BUFFER_INSUFFICIENT; |
224 } |
183 } |
225 else |
184 else |
226 { |
185 { |
227 res = XA_RESULT_PARAMETER_INVALID; |
186 newdatasize = impl->currentTags.mdeKeys[newidx]->size; |
228 } |
187 res = XA_RESULT_SUCCESS; |
229 } |
188 } |
230 else |
189 /* copy data up to given size */ |
231 { |
190 memcpy(pKey,impl->currentTags.mdeKeys[newidx],keySize-1); |
232 |
191 /* ensure null-termination */ |
233 /* check index and return unfiltered index */ |
192 #endif |
234 if(CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS) |
193 memset(pKey->data+newdatasize-1,0,1); |
235 { |
194 pKey->size = newdatasize; |
236 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
237 DEBUG_API("<-XAMetadataExtractionItfImpl_GetKey"); |
|
238 return XA_RESULT_PARAMETER_INVALID; |
|
239 } |
|
240 |
|
241 |
|
242 /* needed size = size of struct + size of data - 1 (struct size already includes one char) */ |
|
243 neededsize = sizeof(XAMetadataInfo) + impl->currentTags.mdeKeys[newidx]->size - 1; |
|
244 if( keySize<neededsize ) |
|
245 { /* cannot fit all of key data */ |
|
246 newdatasize = impl->currentTags.mdeKeys[newidx]->size - (neededsize-keySize); |
|
247 DEBUG_ERR("XA_RESULT_BUFFER_INSUFFICIENT"); |
|
248 res = XA_RESULT_BUFFER_INSUFFICIENT; |
|
249 } |
|
250 else |
|
251 { |
|
252 newdatasize = impl->currentTags.mdeKeys[newidx]->size; |
|
253 res = XA_RESULT_SUCCESS; |
|
254 } |
|
255 /* copy data up to given size */ |
|
256 memcpy(pKey,impl->currentTags.mdeKeys[newidx],keySize-1); |
|
257 /* ensure null-termination */ |
|
258 |
|
259 memset(pKey->data+newdatasize-1,0,1); |
|
260 pKey->size = newdatasize; |
|
261 } |
195 |
262 |
196 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetKey (%d)", (int)res); |
263 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetKey (%d)", (int)res); |
197 return res; |
264 return res; |
198 } |
265 } |
199 |
266 |
221 DEBUG_API("<-XAMetadataExtractionItfImpl_GetValueSize"); |
288 DEBUG_API("<-XAMetadataExtractionItfImpl_GetValueSize"); |
222 return XA_RESULT_PARAMETER_INVALID; |
289 return XA_RESULT_PARAMETER_INVALID; |
223 } |
290 } |
224 *pValueSize = 0; |
291 *pValueSize = 0; |
225 |
292 |
226 /* check index and return unfiltered index */ |
293 if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF) |
227 if(CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS) |
294 { |
228 { |
295 void *mmfCtx = GetMetadataUtilityContext((XAAdaptationMMFCtx*)impl->adaptCtx); |
229 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
296 if(mmfCtx) |
230 DEBUG_API("<-XAMetadataExtractionItfImpl_GetValueSize"); |
297 { |
231 return XA_RESULT_PARAMETER_INVALID; |
298 res = mmf_get_value_size(mmfCtx, index,pValueSize); |
232 } |
299 } |
233 #ifdef _GSTREAMER_BACKEND_ |
300 else |
234 /* size = size of struct + size of data - 1 (struct size already includes one char) */ |
301 { |
235 *pValueSize = sizeof(XAMetadataInfo) + impl->currentTags.mdeValues[newidx]->size - 1; |
302 res = XA_RESULT_PARAMETER_INVALID; |
236 #endif |
303 } |
|
304 } |
|
305 else |
|
306 { |
|
307 /* check index and return unfiltered index */ |
|
308 if(CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS) |
|
309 { |
|
310 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
311 DEBUG_API("<-XAMetadataExtractionItfImpl_GetValueSize"); |
|
312 return XA_RESULT_PARAMETER_INVALID; |
|
313 } |
|
314 |
|
315 /* size = size of struct + size of data - 1 (struct size already includes one char) */ |
|
316 *pValueSize = sizeof(XAMetadataInfo) + impl->currentTags.mdeValues[newidx]->size - 1; |
|
317 } |
|
318 |
237 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetValueSize (%d)", (int)res); |
319 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetValueSize (%d)", (int)res); |
238 return res; |
320 return res; |
239 } |
321 } |
240 |
322 |
241 /* |
323 /* |
253 XAMetadataInfo *pValue) |
335 XAMetadataInfo *pValue) |
254 { |
336 { |
255 XAMetadataExtractionItfImpl *impl = NULL; |
337 XAMetadataExtractionItfImpl *impl = NULL; |
256 XAresult res = XA_RESULT_SUCCESS; |
338 XAresult res = XA_RESULT_SUCCESS; |
257 XAuint32 newidx = 0; |
339 XAuint32 newidx = 0; |
258 #ifdef _GSTREAMER_BACKEND_ |
340 |
259 XAuint32 neededsize = 0; |
341 XAuint32 neededsize = 0; |
260 #endif |
342 |
261 XAuint32 newdatasize = 0; |
343 XAuint32 newdatasize = 0; |
262 DEBUG_API("->XAMetadataExtractionItfImpl_GetValue"); |
344 DEBUG_API("->XAMetadataExtractionItfImpl_GetValue"); |
263 |
345 |
264 impl = GetImpl(self); |
346 impl = GetImpl(self); |
265 if( !impl || !pValue ) |
347 if( !impl || !pValue ) |
267 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
349 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
268 DEBUG_API("<-XAMetadataExtractionItfImpl_GetValue"); |
350 DEBUG_API("<-XAMetadataExtractionItfImpl_GetValue"); |
269 return XA_RESULT_PARAMETER_INVALID; |
351 return XA_RESULT_PARAMETER_INVALID; |
270 } |
352 } |
271 |
353 |
272 /* check index and return unfiltered index */ |
354 memset(pValue,0,valueSize); |
273 if(CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS) |
355 |
274 { |
356 if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF) |
275 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
357 { |
276 DEBUG_API("<-XAMetadataExtractionItfImpl_GetValue"); |
358 void *mmfCtx = GetMetadataUtilityContext((XAAdaptationMMFCtx*)impl->adaptCtx); |
277 return XA_RESULT_PARAMETER_INVALID; |
359 if(mmfCtx) |
278 } |
360 { |
279 |
361 res = mmf_get_value(mmfCtx, index, valueSize, pValue); |
280 memset(pValue,0,valueSize); |
362 } |
281 #ifdef _GSTREAMER_BACKEND_ |
363 else |
282 /* needed size = size of struct + size of data - 1 (struct size already includes one char) */ |
364 { |
283 neededsize = sizeof(XAMetadataInfo) + impl->currentTags.mdeValues[newidx]->size - 1; |
365 res = XA_RESULT_PARAMETER_INVALID; |
284 if( valueSize<neededsize ) |
366 } |
285 { /* cannot fit all of key data */ |
367 } |
286 newdatasize = impl->currentTags.mdeValues[newidx]->size - (neededsize-valueSize); |
368 else |
287 DEBUG_ERR("XA_RESULT_BUFFER_INSUFFICIENT"); |
369 { |
288 res = XA_RESULT_BUFFER_INSUFFICIENT; |
370 /* check index and return unfiltered index */ |
289 } |
371 if(CheckAndUnfilterIndex(impl,index,&newidx) != XA_RESULT_SUCCESS) |
290 else |
372 { |
291 { |
373 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
292 newdatasize = impl->currentTags.mdeValues[newidx]->size; |
374 DEBUG_API("<-XAMetadataExtractionItfImpl_GetValue"); |
293 res = XA_RESULT_SUCCESS; |
375 return XA_RESULT_PARAMETER_INVALID; |
294 } |
376 } |
295 /* copy data up to given size */ |
377 |
296 memcpy(pValue,impl->currentTags.mdeValues[newidx],valueSize-1); |
378 /* needed size = size of struct + size of data - 1 (struct size already includes one char) */ |
297 /* ensure null-termination */ |
379 neededsize = sizeof(XAMetadataInfo) + impl->currentTags.mdeValues[newidx]->size - 1; |
298 #endif |
380 if( valueSize<neededsize ) |
299 memset(pValue->data+newdatasize-1,0,1); |
381 { /* cannot fit all of key data */ |
300 |
382 newdatasize = impl->currentTags.mdeValues[newidx]->size - (neededsize-valueSize); |
301 pValue->size = newdatasize; |
383 DEBUG_ERR("XA_RESULT_BUFFER_INSUFFICIENT"); |
|
384 res = XA_RESULT_BUFFER_INSUFFICIENT; |
|
385 } |
|
386 else |
|
387 { |
|
388 newdatasize = impl->currentTags.mdeValues[newidx]->size; |
|
389 res = XA_RESULT_SUCCESS; |
|
390 } |
|
391 /* copy data up to given size */ |
|
392 memcpy(pValue,impl->currentTags.mdeValues[newidx],valueSize-1); |
|
393 /* ensure null-termination */ |
|
394 |
|
395 memset(pValue->data+newdatasize-1,0,1); |
|
396 |
|
397 pValue->size = newdatasize; |
|
398 } |
302 |
399 |
303 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetValue (%d)",(int)res); |
400 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_GetValue (%d)",(int)res); |
304 return res; |
401 return res; |
305 } |
402 } |
306 |
403 |
328 XAuint32 valueEncoding, |
425 XAuint32 valueEncoding, |
329 XAuint8 filterMask) |
426 XAuint8 filterMask) |
330 { |
427 { |
331 XAresult res = XA_RESULT_SUCCESS; |
428 XAresult res = XA_RESULT_SUCCESS; |
332 |
429 |
|
430 XAuint32 idx = 0; |
|
431 XAuint8 matchMask = 0; |
333 |
432 |
334 #ifdef _GSTREAMER_BACKEND_ |
433 |
335 XAMetadataExtractionItfImpl *impl = NULL; |
434 XAMetadataExtractionItfImpl *impl = NULL; |
336 const XAchar* parsedkey; |
435 const XAchar* parsedkey; |
337 impl = GetImpl(self); |
436 impl = GetImpl(self); |
338 #endif |
437 |
339 DEBUG_API("->XAMetadataExtractionItfImpl_AddKeyFilter"); |
438 DEBUG_API("->XAMetadataExtractionItfImpl_AddKeyFilter"); |
340 |
439 |
341 #ifdef _GSTREAMER_BACKEND_ |
440 |
342 XAuint32 idx = 0; |
441 |
343 XAuint8 matchMask = 0; |
|
344 if( !impl ) |
442 if( !impl ) |
345 { |
443 { |
346 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
444 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
347 DEBUG_API("<-XAMetadataExtractionItfImpl_AddKeyFilter"); |
445 DEBUG_API("<-XAMetadataExtractionItfImpl_AddKeyFilter"); |
348 return XA_RESULT_PARAMETER_INVALID; |
446 return XA_RESULT_PARAMETER_INVALID; |
349 } |
447 } |
350 else |
448 else |
351 { |
449 { |
352 impl->filteringOn = XA_BOOLEAN_TRUE; |
450 |
353 for(idx=0; idx < impl->currentTags.itemcount; idx++) |
451 if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF) |
354 { |
452 { |
355 if((filterMask & XA_METADATA_FILTER_KEY) && pKey) |
453 DEBUG_API("<-XAMetadataExtractionItfImpl_AddKeyFilter Not Supported in MMF"); |
356 { |
454 res = XA_RESULT_PARAMETER_INVALID; |
357 parsedkey = XAMetadataAdapt_ParseKhronosKey(pKey); |
455 } |
358 if( strcmp((char*)parsedkey, |
456 else |
359 (char*)impl->currentTags.mdeKeys[idx]->data) == 0 ) |
457 { |
360 { |
458 impl->filteringOn = XA_BOOLEAN_TRUE; |
361 matchMask |= XA_METADATA_FILTER_KEY; |
459 for(idx=0; idx < impl->currentTags.itemcount; idx++) |
362 } |
460 { |
363 } |
461 if((filterMask & XA_METADATA_FILTER_KEY) && pKey) |
364 if(filterMask & XA_METADATA_FILTER_LANG && pValueLangCountry) |
462 { |
365 { |
463 parsedkey = XAMetadataAdapt_ParseKhronosKey(pKey); |
366 if( strcmp((char*)pValueLangCountry, |
464 if( strcmp((char*)parsedkey, |
367 (char*)impl->currentTags.mdeKeys[idx]->langCountry) == 0 ) |
465 (char*)impl->currentTags.mdeKeys[idx]->data) == 0 ) |
368 { |
466 { |
369 matchMask |= XA_METADATA_FILTER_LANG; |
467 matchMask |= XA_METADATA_FILTER_KEY; |
370 } |
468 } |
371 } |
469 } |
372 if(filterMask & XA_METADATA_FILTER_ENCODING) |
470 if(filterMask & XA_METADATA_FILTER_LANG && pValueLangCountry) |
373 { |
471 { |
374 if(keyEncoding==impl->currentTags.mdeKeys[idx]->encoding) |
472 if( strcmp((char*)pValueLangCountry, |
375 { |
473 (char*)impl->currentTags.mdeKeys[idx]->langCountry) == 0 ) |
376 matchMask |= XA_METADATA_FILTER_ENCODING; |
474 { |
377 } |
475 matchMask |= XA_METADATA_FILTER_LANG; |
378 if(valueEncoding==impl->currentTags.mdeValues[idx]->encoding) |
476 } |
379 { |
477 } |
380 matchMask |= XA_METADATA_FILTER_ENCODING; |
478 if(filterMask & XA_METADATA_FILTER_ENCODING) |
381 } |
479 { |
382 } |
480 if(keyEncoding==impl->currentTags.mdeKeys[idx]->encoding) |
383 /* check if all filters apply */ |
481 { |
384 if(filterMask == matchMask) |
482 matchMask |= XA_METADATA_FILTER_ENCODING; |
385 { |
483 } |
386 if(impl->tagmatchesfilter[idx] == XA_BOOLEAN_FALSE) |
484 if(valueEncoding==impl->currentTags.mdeValues[idx]->encoding) |
387 { |
485 { |
388 impl->tagmatchesfilter[idx] = XA_BOOLEAN_TRUE; |
486 matchMask |= XA_METADATA_FILTER_ENCODING; |
389 impl->filteredcount++; |
487 } |
390 } |
488 } |
391 } |
489 /* check if all filters apply */ |
392 /*reset matchmask*/ |
490 if(filterMask == matchMask) |
393 matchMask=0; |
491 { |
394 } |
492 if(impl->tagmatchesfilter[idx] == XA_BOOLEAN_FALSE) |
395 } |
493 { |
396 #endif |
494 impl->tagmatchesfilter[idx] = XA_BOOLEAN_TRUE; |
|
495 impl->filteredcount++; |
|
496 } |
|
497 } |
|
498 /*reset matchmask*/ |
|
499 matchMask=0; |
|
500 } |
|
501 } |
|
502 } |
397 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_AddKeyFilter (%d)", (int)res); |
503 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_AddKeyFilter (%d)", (int)res); |
398 return res; |
504 return res; |
399 } |
505 } |
400 |
506 |
401 /* |
507 /* |
403 */ |
509 */ |
404 XAresult XAMetadataExtractionItfImpl_ClearKeyFilter(XAMetadataExtractionItf self) |
510 XAresult XAMetadataExtractionItfImpl_ClearKeyFilter(XAMetadataExtractionItf self) |
405 { |
511 { |
406 XAMetadataExtractionItfImpl *impl = NULL; |
512 XAMetadataExtractionItfImpl *impl = NULL; |
407 XAresult res = XA_RESULT_SUCCESS; |
513 XAresult res = XA_RESULT_SUCCESS; |
408 #ifdef _GSTREAMER_BACKEND_ |
514 |
409 XAuint32 idx = 0; |
515 XAuint32 idx = 0; |
410 #endif |
516 |
411 DEBUG_API("->XAMetadataExtractionItfImpl_ClearKeyFilter"); |
517 DEBUG_API("->XAMetadataExtractionItfImpl_ClearKeyFilter"); |
412 impl = GetImpl(self); |
518 impl = GetImpl(self); |
413 if( !impl ) |
519 if( !impl ) |
414 { |
520 { |
415 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
521 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
416 res = XA_RESULT_PARAMETER_INVALID; |
522 res = XA_RESULT_PARAMETER_INVALID; |
417 } |
523 } |
418 else |
524 else |
419 { |
525 { |
420 if(impl->tagmatchesfilter) |
526 |
421 { |
527 if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWMMF) |
422 #ifdef _GSTREAMER_BACKEND_ |
528 { |
423 for(idx=0; idx < impl->currentTags.itemcount; idx++) |
529 DEBUG_API("<-XAMetadataExtractionItfImpl_ClearKeyFilter Not Supported in MMF"); |
424 { |
530 res = XA_RESULT_PARAMETER_INVALID; |
425 impl->tagmatchesfilter[idx] = XA_BOOLEAN_FALSE; |
531 } |
426 } |
532 else |
427 #endif |
533 { |
428 } |
534 if(impl->tagmatchesfilter) |
429 impl->filteredcount = 0; |
535 { |
430 impl->filteringOn = XA_BOOLEAN_FALSE; |
536 |
|
537 for(idx=0; idx < impl->currentTags.itemcount; idx++) |
|
538 { |
|
539 impl->tagmatchesfilter[idx] = XA_BOOLEAN_FALSE; |
|
540 } |
|
541 |
|
542 } |
|
543 impl->filteredcount = 0; |
|
544 impl->filteringOn = XA_BOOLEAN_FALSE; |
|
545 } |
431 } |
546 } |
432 |
547 |
433 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_ClearKeyFilter (%d)", (int)res); |
548 DEBUG_API_A1("<-XAMetadataExtractionItfImpl_ClearKeyFilter (%d)", (int)res); |
434 return res; |
549 return res; |
435 } |
550 } |
436 |
551 |
437 /***************************************************************************** |
552 /***************************************************************************** |
438 * XAMetadataExtractionItfImpl -specific methods |
553 * XAMetadataExtractionItfImpl -specific methods |
439 *****************************************************************************/ |
554 *****************************************************************************/ |
440 #ifdef _GSTREAMER_BACKEND_ |
555 |
441 /* XAMetadataExtractionItfImpl* XAMetadataExtractionItfImpl_Create() |
556 /* XAMetadataExtractionItfImpl* XAMetadataExtractionItfImpl_Create() |
442 * Description: Allocate and initialize XAMetadataExtractionItfImpl |
557 * Description: Allocate and initialize XAMetadataExtractionItfImpl |
443 */ |
558 */ |
444 XAMetadataExtractionItfImpl* XAMetadataExtractionItfImpl_Create(XAAdaptationBaseCtx *adaptCtx) |
559 XAMetadataExtractionItfImpl* XAMetadataExtractionItfImpl_Create(XAAdaptationBaseCtx *adaptCtx) |
445 { |
560 { |
462 /* init variables */ |
577 /* init variables */ |
463 self->filteredcount = 0; |
578 self->filteredcount = 0; |
464 self->filteringOn = XA_BOOLEAN_FALSE; |
579 self->filteringOn = XA_BOOLEAN_FALSE; |
465 |
580 |
466 self->adaptCtx = adaptCtx; |
581 self->adaptCtx = adaptCtx; |
467 XAAdaptationBase_AddEventHandler( adaptCtx, &XAMetadataExtractionItfImp_AdaptCb, XA_METADATAEVENTS, self ); |
582 |
|
583 if(self->adaptCtx->fwtype != FWMgrFWMMF) |
|
584 { |
|
585 XAAdaptationBase_AddEventHandler( adaptCtx, &XAMetadataExtractionItfImp_AdaptCb, XA_METADATAEVENTS, self ); |
|
586 } |
468 |
587 |
469 self->self = self; |
588 self->self = self; |
470 } |
589 } |
471 |
590 |
472 DEBUG_API("<-XAMetadataExtractionItfImpl_Create"); |
591 DEBUG_API("<-XAMetadataExtractionItfImpl_Create"); |
473 return self; |
592 return self; |
474 } |
593 } |
475 #endif |
594 |
476 /* void XAMetadataExtractionItfImpl_Free(XAMetadataExtractionItfImpl* self) |
595 /* void XAMetadataExtractionItfImpl_Free(XAMetadataExtractionItfImpl* self) |
477 * Description: Free all resources reserved at XAMetadataExtractionItfImpl_Create |
596 * Description: Free all resources reserved at XAMetadataExtractionItfImpl_Create |
478 */ |
597 */ |
479 void XAMetadataExtractionItfImpl_Free(XAMetadataExtractionItfImpl* self) |
598 void XAMetadataExtractionItfImpl_Free(XAMetadataExtractionItfImpl* self) |
480 { |
599 { |
481 DEBUG_API("->XAMetadataExtractionItfImpl_Free"); |
600 DEBUG_API("->XAMetadataExtractionItfImpl_Free"); |
482 assert(self==self->self); |
601 assert(self==self->self); |
483 #ifdef _GSTREAMER_BACKEND_ |
602 |
484 XAAdaptationBase_RemoveEventHandler( self->adaptCtx, &XAMetadataExtractionItfImp_AdaptCb ); |
603 if(self->adaptCtx->fwtype != FWMgrFWMMF) |
485 XAMetadataAdapt_FreeImplTagList(&(self->currentTags), XA_BOOLEAN_TRUE); |
604 { |
486 #endif |
605 XAAdaptationBase_RemoveEventHandler( self->adaptCtx, &XAMetadataExtractionItfImp_AdaptCb ); |
487 if(self->tagmatchesfilter) |
606 XAMetadataAdapt_FreeImplTagList(&(self->currentTags), XA_BOOLEAN_TRUE); |
488 { |
607 |
489 free(self->tagmatchesfilter); |
608 if(self->tagmatchesfilter) |
490 } |
609 { |
|
610 free(self->tagmatchesfilter); |
|
611 } |
|
612 } |
|
613 |
491 free(self); |
614 free(self); |
492 DEBUG_API("<-XAMetadataExtractionItfImpl_Free"); |
615 DEBUG_API("<-XAMetadataExtractionItfImpl_Free"); |
493 } |
616 } |
494 |
617 |
495 #ifdef _GSTREAMER_BACKEND_ |
618 |
496 /* 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, |
497 * has changed, live stream contains metadata...) |
620 * has changed, live stream contains metadata...) |
498 */ |
621 */ |
499 void XAMetadataExtractionItfImp_AdaptCb( void *pHandlerCtx, XAAdaptEvent *event ) |
622 void XAMetadataExtractionItfImp_AdaptCb( void *pHandlerCtx, XAAdaptEvent *event ) |
500 { |
623 { |
508 return; |
631 return; |
509 } |
632 } |
510 if( event && event->eventid == XA_ADAPT_MDE_TAGS_AVAILABLE ) |
633 if( event && event->eventid == XA_ADAPT_MDE_TAGS_AVAILABLE ) |
511 { |
634 { |
512 /* get the tag list */ |
635 /* get the tag list */ |
513 XAMetadataExtractionItfAdapt_FillTagList( impl->adaptCtx, &(impl->currentTags) ); |
636 XAMetadataExtractionItfAdapt_FillTagList( (XAAdaptationGstCtx*)impl->adaptCtx, &(impl->currentTags) ); |
514 if(impl->tagmatchesfilter) |
637 if(impl->tagmatchesfilter) |
515 { |
638 { |
516 free(impl->tagmatchesfilter); |
639 free(impl->tagmatchesfilter); |
517 } |
640 } |
518 impl->tagmatchesfilter = calloc(impl->currentTags.itemcount,sizeof(XAboolean)); |
641 impl->tagmatchesfilter = calloc(impl->currentTags.itemcount,sizeof(XAboolean)); |
523 DEBUG_INFO("unhandled"); |
646 DEBUG_INFO("unhandled"); |
524 } |
647 } |
525 DEBUG_API("<-XAMetadataExtractionItfImp_AdaptCb"); |
648 DEBUG_API("<-XAMetadataExtractionItfImp_AdaptCb"); |
526 } |
649 } |
527 |
650 |
528 #endif |
651 |
529 /* For given index over filtered array, return index over whole array |
652 /* For given index over filtered array, return index over whole array |
530 */ |
653 */ |
531 XAresult CheckAndUnfilterIndex(XAMetadataExtractionItfImpl *impl, |
654 XAresult CheckAndUnfilterIndex(XAMetadataExtractionItfImpl *impl, |
532 XAuint32 oldidx, XAuint32 *newidx) |
655 XAuint32 oldidx, XAuint32 *newidx) |
533 { |
656 { |
534 DEBUG_API("->CheckAndUnfilterIndex"); |
657 DEBUG_API("->CheckAndUnfilterIndex"); |
535 #ifdef _GSTREAMER_BACKEND_ |
658 |
536 if( impl->filteringOn ) |
659 if( impl->filteringOn ) |
537 { |
660 { |
538 XAint16 i=-1; |
661 XAint16 i=-1; |
539 if(oldidx>=impl->filteredcount) |
662 if(oldidx>=impl->filteredcount) |
540 { |
663 { |