17 |
17 |
18 #include <stdio.h> |
18 #include <stdio.h> |
19 #include <stdlib.h> |
19 #include <stdlib.h> |
20 #include <assert.h> |
20 #include <assert.h> |
21 #include "xametadatainsertionitf.h" |
21 #include "xametadatainsertionitf.h" |
22 #ifdef _GSTREAMER_BACKEND_ |
22 |
23 #include "XAMetadataAdaptation.h" |
23 #include "xametadataadaptation.h" |
24 #endif |
24 |
25 #define MAX_TAGS 255 |
25 #define MAX_TAGS 255 |
26 /* XAMetadataInsertionItfImpl* GetImpl(XAMetadataInsertionItf self) |
26 /* XAMetadataInsertionItfImpl* GetImpl(XAMetadataInsertionItf self) |
27 * Description: Validate interface pointer and cast it to implementation pointer. |
27 * Description: Validate interface pointer and cast it to implementation pointer. |
28 */ |
28 */ |
29 static XAMetadataInsertionItfImpl* GetImpl(XAMetadataInsertionItf self) |
29 static XAMetadataInsertionItfImpl* GetImpl(XAMetadataInsertionItf self) |
63 /* invalid parameter */ |
63 /* invalid parameter */ |
64 ret = XA_RESULT_PARAMETER_INVALID; |
64 ret = XA_RESULT_PARAMETER_INVALID; |
65 } |
65 } |
66 else |
66 else |
67 { |
67 { |
68 #ifdef _GSTREAMER_BACKEND_ |
68 |
69 if( impl->adaptCtx ) |
69 if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST) |
70 { |
70 { |
71 ret = XAMetadataInsertionItfAdapt_CreateChildNode( |
71 if(impl->adaptCtx) |
72 impl->adaptCtx,parentNodeID,type,mimeType,pChildNodeID); |
72 { |
73 } |
73 ret = XAMetadataInsertionItfAdapt_CreateChildNode( |
74 else |
74 (XAAdaptationGstCtx*)impl->adaptCtx,parentNodeID,type,mimeType,pChildNodeID); |
75 { |
75 } |
76 ret = XA_RESULT_INTERNAL_ERROR; |
76 else |
77 } |
77 { |
78 #endif |
78 ret = XA_RESULT_INTERNAL_ERROR; |
79 /*******************************************/ |
79 } |
80 /****This is being done since mmf does not |
80 |
81 * support metadata Insertion |
81 } |
82 *******************************************/ |
82 else |
83 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
83 { |
|
84 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
85 DEBUG_API("<-XAMetadataInsertionItfImpl_CreateChildNode"); |
|
86 return XA_RESULT_FEATURE_UNSUPPORTED; |
|
87 } |
84 } |
88 } |
85 DEBUG_API("<-XAMetadataInsertionItfImpl_CreateChildNode"); |
89 DEBUG_API("<-XAMetadataInsertionItfImpl_CreateChildNode"); |
86 return ret; |
90 return ret; |
87 } |
91 } |
88 |
92 |
107 /* invalid parameter */ |
111 /* invalid parameter */ |
108 ret = XA_RESULT_PARAMETER_INVALID; |
112 ret = XA_RESULT_PARAMETER_INVALID; |
109 } |
113 } |
110 else |
114 else |
111 { |
115 { |
112 #ifdef _GSTREAMER_BACKEND_ |
116 if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST) |
|
117 { |
113 if( impl->adaptCtx ) |
118 if( impl->adaptCtx ) |
114 { |
119 { |
115 ret = XAMetadataInsertionItfAdapt_GetSupportedKeysCount( |
120 ret = XAMetadataInsertionItfAdapt_GetSupportedKeysCount( |
116 impl->adaptCtx,nodeID,pFreeKeys,pKeyCount,pEncodingCount); |
121 (XAAdaptationGstCtx*)impl->adaptCtx,nodeID,pFreeKeys,pKeyCount,pEncodingCount); |
117 } |
122 } |
118 else |
123 else |
119 { |
124 { |
120 ret = XA_RESULT_INTERNAL_ERROR; |
125 ret = XA_RESULT_INTERNAL_ERROR; |
121 } |
126 } |
122 #endif |
127 } |
123 /*******************************************/ |
128 else |
124 /****This is being done since mmf does not |
129 { |
125 * support metadata Insertion |
130 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
126 *******************************************/ |
131 DEBUG_API("<-XAMetadataInsertionItfImpl_GetSupportedKeysCount"); |
127 |
132 return XA_RESULT_PARAMETER_INVALID; |
128 ret = XA_RESULT_PARAMETER_INVALID; |
133 } |
129 } |
134 } |
130 DEBUG_API("<-XAMetadataInsertionItfImpl_GetSupportedKeysCount"); |
135 DEBUG_API("<-XAMetadataInsertionItfImpl_GetSupportedKeysCount"); |
131 return ret; |
136 return ret; |
132 } |
137 } |
133 |
138 |
151 /* invalid parameter */ |
156 /* invalid parameter */ |
152 ret = XA_RESULT_PARAMETER_INVALID; |
157 ret = XA_RESULT_PARAMETER_INVALID; |
153 } |
158 } |
154 else |
159 else |
155 { |
160 { |
156 #ifdef _GSTREAMER_BACKEND_ |
161 if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST) |
|
162 { |
|
163 |
157 if( impl->adaptCtx ) |
164 if( impl->adaptCtx ) |
158 { |
165 { |
159 ret = XAMetadataInsertionItfAdapt_GetKeySize( |
166 ret = XAMetadataInsertionItfAdapt_GetKeySize( |
160 impl->adaptCtx, nodeID, keyIndex, pKeySize); |
167 (XAAdaptationGstCtx*)impl->adaptCtx, nodeID, keyIndex, pKeySize); |
161 } |
168 } |
162 else |
169 else |
163 { |
170 { |
164 ret = XA_RESULT_INTERNAL_ERROR; |
171 ret = XA_RESULT_INTERNAL_ERROR; |
165 } |
172 } |
166 #endif |
173 } |
167 /*******************************************/ |
174 else |
168 /****This is being done since mmf does not |
175 { |
169 * support metadata Insertion |
176 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
170 *******************************************/ |
177 DEBUG_API("<-XAMetadataInsertionItfImpl_GetKeySize"); |
171 |
178 return XA_RESULT_PARAMETER_INVALID; |
172 ret = XA_RESULT_PARAMETER_INVALID; |
179 } |
173 } |
180 } |
174 DEBUG_API("<-XAMetadataInsertionItfImpl_GetKeySize"); |
181 DEBUG_API("<-XAMetadataInsertionItfImpl_GetKeySize"); |
175 return ret; |
182 return ret; |
176 } |
183 } |
177 |
184 |
196 /* invalid parameter */ |
203 /* invalid parameter */ |
197 ret = XA_RESULT_PARAMETER_INVALID; |
204 ret = XA_RESULT_PARAMETER_INVALID; |
198 } |
205 } |
199 else |
206 else |
200 { |
207 { |
201 #ifdef _GSTREAMER_BACKEND_ |
208 if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST) |
|
209 { |
|
210 |
202 if( impl->adaptCtx ) |
211 if( impl->adaptCtx ) |
203 { |
212 { |
204 ret = XAMetadataInsertionItfAdapt_GetKey( |
213 ret = XAMetadataInsertionItfAdapt_GetKey( |
205 impl->adaptCtx,nodeID,keyIndex,keySize,pKey); |
214 (XAAdaptationGstCtx*)impl->adaptCtx,nodeID,keyIndex,keySize,pKey); |
206 } |
215 } |
207 else |
216 else |
208 { |
217 { |
209 ret = XA_RESULT_INTERNAL_ERROR; |
218 ret = XA_RESULT_INTERNAL_ERROR; |
210 } |
219 } |
211 #endif |
220 } |
212 /*******************************************/ |
221 else |
213 /****This is being done since mmf does not |
222 { |
214 * support metadata Insertion |
223 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
215 *******************************************/ |
224 DEBUG_API("<-XAMetadataInsertionItfImpl_GetKey"); |
216 |
225 return XA_RESULT_PARAMETER_INVALID; |
217 ret = XA_RESULT_PARAMETER_INVALID; |
226 } |
|
227 |
218 } |
228 } |
219 DEBUG_API("<-XAMetadataInsertionItfImpl_GetKey"); |
229 DEBUG_API("<-XAMetadataInsertionItfImpl_GetKey"); |
220 return ret; |
230 return ret; |
221 } |
231 } |
222 |
232 |
240 /* invalid parameter */ |
250 /* invalid parameter */ |
241 ret =XA_RESULT_PARAMETER_INVALID; |
251 ret =XA_RESULT_PARAMETER_INVALID; |
242 } |
252 } |
243 else |
253 else |
244 { |
254 { |
245 #ifdef _GSTREAMER_BACKEND_ |
255 if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST) |
|
256 { |
|
257 |
246 if( impl->adaptCtx ) |
258 if( impl->adaptCtx ) |
247 { |
259 { |
248 ret = XAMetadataInsertionItfAdapt_GetFreeKeysEncoding( |
260 ret = XAMetadataInsertionItfAdapt_GetFreeKeysEncoding( |
249 impl->adaptCtx,nodeID,encodingIndex,pEncoding); |
261 (XAAdaptationGstCtx*)impl->adaptCtx,nodeID,encodingIndex,pEncoding); |
250 } |
262 } |
251 else |
263 else |
252 { |
264 { |
253 ret = XA_RESULT_INTERNAL_ERROR; |
265 ret = XA_RESULT_INTERNAL_ERROR; |
254 } |
266 } |
255 #endif |
267 } |
256 /*******************************************/ |
268 else |
257 /****This is being done since mmf does not |
269 { |
258 * support metadata Insertion |
270 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
259 *******************************************/ |
271 DEBUG_API("<-XAMetadataInsertionItfImpl_GetFreeKeysEncoding"); |
260 |
272 return XA_RESULT_PARAMETER_INVALID; |
261 ret = XA_RESULT_PARAMETER_INVALID; |
273 } |
262 } |
274 } |
263 DEBUG_API("<-XAMetadataInsertionItfImpl_GetFreeKeysEncoding"); |
275 DEBUG_API("<-XAMetadataInsertionItfImpl_GetFreeKeysEncoding"); |
264 return ret; |
276 return ret; |
265 } |
277 } |
266 |
278 |
284 /* invalid parameter */ |
296 /* invalid parameter */ |
285 ret = XA_RESULT_PARAMETER_INVALID; |
297 ret = XA_RESULT_PARAMETER_INVALID; |
286 } |
298 } |
287 else |
299 else |
288 { |
300 { |
289 #ifdef _GSTREAMER_BACKEND_ |
301 if(impl->adaptCtx && impl->adaptCtx->fwtype == FWMgrFWGST) |
|
302 { |
|
303 |
290 if( impl->adaptCtx ) |
304 if( impl->adaptCtx ) |
291 { |
305 { |
292 ret = XAMetadataInsertionItfAdapt_InsertMetadataItem( |
306 ret = XAMetadataInsertionItfAdapt_InsertMetadataItem( |
293 impl->adaptCtx,nodeID,pKey,pValue,overwrite); |
307 (XAAdaptationGstCtx*)impl->adaptCtx,nodeID,pKey,pValue,overwrite); |
294 /*store pointers for callback*/ |
|
295 impl->currentTags.mdeKeys[impl->currentTags.itemcount] = pKey; |
308 impl->currentTags.mdeKeys[impl->currentTags.itemcount] = pKey; |
296 impl->currentTags.mdeValues[impl->currentTags.itemcount] = pValue; |
309 impl->currentTags.mdeValues[impl->currentTags.itemcount] = pValue; |
297 impl->currentTags.itemcount++; |
310 impl->currentTags.itemcount++; |
298 } |
311 } |
299 else |
312 else |
300 { |
313 { |
301 ret = XA_RESULT_INTERNAL_ERROR; |
314 ret = XA_RESULT_INTERNAL_ERROR; |
302 } |
315 } |
303 #endif |
316 } |
304 /*******************************************/ |
317 else |
305 /****This is being done since mmf does not |
318 { |
306 * support metadata Insertion |
319 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
307 *******************************************/ |
320 DEBUG_API("<-XAMetadataInsertionItfImpl_GetFreeKeysEncoding"); |
308 |
321 return XA_RESULT_FEATURE_UNSUPPORTED; |
309 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
322 } |
310 } |
323 } |
311 DEBUG_API("<-XAMetadataInsertionItfImpl_InsertMetadataItem"); |
324 DEBUG_API("<-XAMetadataInsertionItfImpl_InsertMetadataItem"); |
312 return ret; |
325 return ret; |
313 } |
326 } |
314 |
327 |
329 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
342 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
330 DEBUG_API("<-XAMetadataInsertionItfImpl_RegisterCallback"); |
343 DEBUG_API("<-XAMetadataInsertionItfImpl_RegisterCallback"); |
331 /* invalid parameter */ |
344 /* invalid parameter */ |
332 return XA_RESULT_PARAMETER_INVALID; |
345 return XA_RESULT_PARAMETER_INVALID; |
333 } |
346 } |
334 #ifdef _GSTREAMER_BACKEND_ |
347 |
335 if(callback) |
348 if(callback) |
336 { |
349 { |
337 XAAdaptationBase_AddEventHandler( impl->adaptCtx, &XAMetadataInsertionItfImpl_AdaptCb, |
350 XAAdaptationBase_AddEventHandler( impl->adaptCtx, &XAMetadataInsertionItfImpl_AdaptCb, |
338 XA_METADATAEVENTS, impl ); |
351 XA_METADATAEVENTS, impl ); |
|
352 impl->callback = callback; |
|
353 impl->cbcontext = pContext; |
|
354 impl->cbPtrToSelf = self; |
339 } |
355 } |
340 else |
356 else |
341 { |
357 { |
342 XAAdaptationBase_RemoveEventHandler(impl->adaptCtx, &XAMetadataInsertionItfImpl_AdaptCb ); |
358 XAAdaptationBase_RemoveEventHandler(impl->adaptCtx, &XAMetadataInsertionItfImpl_AdaptCb ); |
343 } |
359 } |
344 #endif |
|
345 impl->callback = callback; |
|
346 impl->cbcontext = pContext; |
|
347 impl->cbPtrToSelf = self; |
|
348 |
360 |
349 DEBUG_API("<-XAMetadataInsertionItfImpl_RegisterCallback"); |
361 DEBUG_API("<-XAMetadataInsertionItfImpl_RegisterCallback"); |
350 return XA_RESULT_SUCCESS; |
362 return XA_RESULT_SUCCESS; |
351 } |
363 } |
352 |
364 |
356 |
368 |
357 |
369 |
358 /* XAMetadataInsertionItfImpl* XAMetadataInsertionItfImpl_Create() |
370 /* XAMetadataInsertionItfImpl* XAMetadataInsertionItfImpl_Create() |
359 * Description: Allocate and initialize MetadataInsertionItfImpl |
371 * Description: Allocate and initialize MetadataInsertionItfImpl |
360 */ |
372 */ |
361 XAMetadataInsertionItfImpl* XAMetadataInsertionItfImpl_Create( |
373 XAMetadataInsertionItfImpl* XAMetadataInsertionItfImpl_Create(XAMediaRecorderImpl* impl) |
362 #ifdef _GSTREAMER_BACKEND_ |
|
363 XAAdaptationBaseCtx *adaptCtx |
|
364 #endif |
|
365 ) |
|
366 { |
374 { |
367 XAMetadataInsertionItfImpl* self = (XAMetadataInsertionItfImpl*) |
375 XAMetadataInsertionItfImpl* self = (XAMetadataInsertionItfImpl*) |
368 calloc(1,sizeof(XAMetadataInsertionItfImpl)); |
376 calloc(1,sizeof(XAMetadataInsertionItfImpl)); |
|
377 //XAMediaRecorderAdaptationCtx* mCtx = (XAMediaRecorderAdaptationCtx*)(impl->adaptationCtx); |
|
378 |
369 DEBUG_API("->XAMetadataInsertionItfImpl_Create"); |
379 DEBUG_API("->XAMetadataInsertionItfImpl_Create"); |
370 if( self ) |
380 if( self ) |
371 { |
381 { |
372 /* init itf default implementation */ |
382 //if(mCtx->fwtype == FWMgrFWGST) |
373 self->itf.CreateChildNode = XAMetadataInsertionItfImpl_CreateChildNode; |
383 { |
374 self->itf.GetFreeKeysEncoding = XAMetadataInsertionItfImpl_GetFreeKeysEncoding; |
384 /* init itf default implementation */ |
375 self->itf.GetKey = XAMetadataInsertionItfImpl_GetKey; |
385 self->itf.CreateChildNode = XAMetadataInsertionItfImpl_CreateChildNode; |
376 self->itf.GetKeySize = XAMetadataInsertionItfImpl_GetKeySize; |
386 self->itf.GetFreeKeysEncoding = XAMetadataInsertionItfImpl_GetFreeKeysEncoding; |
377 self->itf.GetSupportedKeysCount = XAMetadataInsertionItfImpl_GetSupportedKeysCount; |
387 self->itf.GetKey = XAMetadataInsertionItfImpl_GetKey; |
378 self->itf.InsertMetadataItem = XAMetadataInsertionItfImpl_InsertMetadataItem; |
388 self->itf.GetKeySize = XAMetadataInsertionItfImpl_GetKeySize; |
379 self->itf.RegisterCallback = XAMetadataInsertionItfImpl_RegisterCallback; |
389 self->itf.GetSupportedKeysCount = XAMetadataInsertionItfImpl_GetSupportedKeysCount; |
|
390 self->itf.InsertMetadataItem = XAMetadataInsertionItfImpl_InsertMetadataItem; |
|
391 self->itf.RegisterCallback = XAMetadataInsertionItfImpl_RegisterCallback; |
|
392 } |
380 |
393 |
381 /* init variables*/ |
394 /* init variables*/ |
382 |
395 |
383 self->callback = NULL; |
396 self->callback = NULL; |
384 self->cbcontext = NULL; |
397 self->cbcontext = NULL; |
385 self->cbPtrToSelf = NULL; |
398 self->cbPtrToSelf = NULL; |
386 #ifdef _GSTREAMER_BACKEND_ |
399 self->adaptCtx = impl->adaptationCtx; |
387 self->adaptCtx = adaptCtx; |
|
388 self->currentTags.mdeKeys = calloc(MAX_TAGS,sizeof(XAMetadataInfo*)); |
400 self->currentTags.mdeKeys = calloc(MAX_TAGS,sizeof(XAMetadataInfo*)); |
389 self->currentTags.mdeValues = calloc(MAX_TAGS,sizeof(XAMetadataInfo*)); |
401 self->currentTags.mdeValues = calloc(MAX_TAGS,sizeof(XAMetadataInfo*)); |
390 #endif |
|
391 self->self = self; |
402 self->self = self; |
392 |
403 |
393 } |
404 } |
394 DEBUG_API("<-XAMetadataInsertionItfImpl_Create"); |
405 DEBUG_API("<-XAMetadataInsertionItfImpl_Create"); |
395 return self; |
406 return self; |
402 { |
413 { |
403 DEBUG_API("->XAMetadataInsertionItfImpl_Free"); |
414 DEBUG_API("->XAMetadataInsertionItfImpl_Free"); |
404 assert( self==self->self ); |
415 assert( self==self->self ); |
405 if(self->callback) |
416 if(self->callback) |
406 { |
417 { |
407 #ifdef _GSTREAMER_BACKEND_ |
|
408 XAAdaptationBase_RemoveEventHandler(self->adaptCtx, &XAMetadataInsertionItfImpl_AdaptCb ); |
418 XAAdaptationBase_RemoveEventHandler(self->adaptCtx, &XAMetadataInsertionItfImpl_AdaptCb ); |
409 #endif |
419 } |
410 } |
|
411 #ifdef _GSTREAMER_BACKEND_ |
|
412 XAMetadataAdapt_FreeImplTagList(&(self->currentTags), XA_BOOLEAN_FALSE); |
420 XAMetadataAdapt_FreeImplTagList(&(self->currentTags), XA_BOOLEAN_FALSE); |
413 #endif |
|
414 free( self ); |
421 free( self ); |
415 DEBUG_API("<-XAMetadataInsertionItfImpl_Free"); |
422 DEBUG_API("<-XAMetadataInsertionItfImpl_Free"); |
416 } |
423 } |
417 #ifdef _GSTREAMER_BACKEND_ |
424 |
418 /* With this method, adaptation infroms that tags are written to stream |
425 /* With this method, adaptation infroms that tags are written to stream |
419 */ |
426 */ |
420 void XAMetadataInsertionItfImpl_AdaptCb( void *pHandlerCtx, XAAdaptEvent *event ) |
427 void XAMetadataInsertionItfImpl_AdaptCb( void *pHandlerCtx, XAAdaptEvent *event ) |
421 { |
428 { |
422 XAMetadataInsertionItfImpl* impl = NULL; |
429 XAMetadataInsertionItfImpl* impl = NULL; |