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 |
|
19 #include <gst/gst.h> |
|
20 #include <gst/interfaces/photography.h> |
|
21 #include "xaadaptationgst.h" |
|
22 #include "xamediaplayeradaptctx.h" |
|
23 #include "xamediarecorderadaptctx.h" |
|
24 #include "xacameraadaptctx.h" |
|
25 #include "xaimageeffectsitfadaptation.h" |
|
26 |
|
27 /* |
|
28 * XAresult XAImageEffectsItfAdapt_QuerySupportedImageEffects(XAAdaptationGstCtx *bCtx, |
|
29 * XAuint32 index, |
|
30 * XAuint32 *pImageEffectId) |
|
31 */ |
|
32 XAresult XAImageEffectsItfAdapt_QuerySupportedImageEffects(XAAdaptationGstCtx *bCtx, |
|
33 XAuint32 index, |
|
34 XAuint32 *pImageEffectId) |
|
35 { |
|
36 XAresult ret = XA_RESULT_SUCCESS; |
|
37 DEBUG_API("->XAImageEffectsItfAdapt_QuerySupportedImageEffects") |
|
38 |
|
39 if(!bCtx || (bCtx->baseObj.ctxId != XAMediaPlayerAdaptation && bCtx->baseObj.ctxId != XAMediaRecorderAdaptation |
|
40 && bCtx->baseObj.ctxId != XACameraAdaptation) || index > NUM_SUPPORTED_EFFECTS - 1 || !pImageEffectId) |
|
41 { |
|
42 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
43 DEBUG_API("<-XAImageEffectsItfAdapt_QuerySupportedImageEffects") |
|
44 return XA_RESULT_PARAMETER_INVALID; |
|
45 } |
|
46 |
|
47 /* check which effect is supported */ |
|
48 if(bCtx->baseObj.ctxId == XAMediaPlayerAdaptation || bCtx->baseObj.ctxId == XAMediaRecorderAdaptation) |
|
49 { |
|
50 switch( index ) |
|
51 { |
|
52 case 0: |
|
53 *pImageEffectId = XA_IMAGEEFFECT_MONOCHROME; |
|
54 break; |
|
55 case 1: |
|
56 *pImageEffectId = XA_IMAGEEFFECT_NEGATIVE; |
|
57 break; |
|
58 case 2: |
|
59 *pImageEffectId = XA_IMAGEEFFECT_SEPIA; |
|
60 break; |
|
61 case 3: |
|
62 *pImageEffectId = XA_IMAGEEFFECT_EMBOSS; |
|
63 break; |
|
64 case 4: |
|
65 *pImageEffectId = XA_IMAGEEFFECT_PAINTBRUSH; |
|
66 break; |
|
67 case 5: |
|
68 *pImageEffectId = XA_IMAGEEFFECT_SOLARIZE; |
|
69 break; |
|
70 case 6: |
|
71 *pImageEffectId = XA_IMAGEEFFECT_CARTOON; |
|
72 break; |
|
73 default: |
|
74 ret = XA_RESULT_PARAMETER_INVALID; |
|
75 break; |
|
76 } |
|
77 } |
|
78 if(bCtx->baseObj.ctxId == XACameraAdaptation) |
|
79 { |
|
80 XACameraAdaptationCtx* mCtx = (XACameraAdaptationCtx*) bCtx; |
|
81 |
|
82 if(GST_IS_PHOTOGRAPHY(mCtx->baseObj.bin)) |
|
83 { |
|
84 /* real image effects for camera */ |
|
85 switch( index ) |
|
86 { |
|
87 case 0: |
|
88 *pImageEffectId = XA_IMAGEEFFECT_NEGATIVE; |
|
89 break; |
|
90 case 1: |
|
91 *pImageEffectId = XA_IMAGEEFFECT_SEPIA; |
|
92 break; |
|
93 case 3: |
|
94 *pImageEffectId = XA_IMAGEEFFECT_SOLARIZE; |
|
95 break; |
|
96 default: |
|
97 ret = XA_RESULT_PARAMETER_INVALID; |
|
98 break; |
|
99 } |
|
100 } |
|
101 else |
|
102 { |
|
103 /* Stubbed image effects for camera */ |
|
104 switch( index ) |
|
105 { |
|
106 case 0: |
|
107 *pImageEffectId = XA_IMAGEEFFECT_MONOCHROME; |
|
108 break; |
|
109 case 1: |
|
110 *pImageEffectId = XA_IMAGEEFFECT_NEGATIVE; |
|
111 break; |
|
112 case 2: |
|
113 *pImageEffectId = XA_IMAGEEFFECT_SEPIA; |
|
114 break; |
|
115 case 3: |
|
116 *pImageEffectId = XA_IMAGEEFFECT_EMBOSS; |
|
117 break; |
|
118 case 4: |
|
119 *pImageEffectId = XA_IMAGEEFFECT_PAINTBRUSH; |
|
120 break; |
|
121 case 5: |
|
122 *pImageEffectId = XA_IMAGEEFFECT_SOLARIZE; |
|
123 break; |
|
124 case 6: |
|
125 *pImageEffectId = XA_IMAGEEFFECT_CARTOON; |
|
126 break; |
|
127 default: |
|
128 ret = XA_RESULT_PARAMETER_INVALID; |
|
129 break; |
|
130 } |
|
131 } |
|
132 } |
|
133 |
|
134 DEBUG_API("<-XAImageEffectsItfAdapt_QuerySupportedImageEffects") |
|
135 return ret; |
|
136 } |
|
137 |
|
138 /* |
|
139 * XAresult XAImageEffectsItfAdapt_EnableImageEffect(XAAdaptationGstCtx *bCtx, |
|
140 * XAuint32 imageEffectID) |
|
141 */ |
|
142 XAresult XAImageEffectsItfAdapt_EnableImageEffect(XAAdaptationGstCtx *bCtx, |
|
143 XAuint32 imageEffectID) |
|
144 { |
|
145 XAresult ret = XA_RESULT_SUCCESS; |
|
146 gdouble tempImageEffect = 0; |
|
147 GstElement *balanceElement = NULL; |
|
148 DEBUG_API("->XAImageEffectsItfAdapt_EnableImageEffect") |
|
149 |
|
150 if(!bCtx || (bCtx->baseObj.ctxId != XAMediaPlayerAdaptation && bCtx->baseObj.ctxId != XAMediaRecorderAdaptation |
|
151 && bCtx->baseObj.ctxId != XACameraAdaptation)) |
|
152 { |
|
153 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
154 DEBUG_API("<-XAImageEffectsItfAdapt_EnableImageEffect") |
|
155 return XA_RESULT_PARAMETER_INVALID; |
|
156 } |
|
157 |
|
158 /* check which effect is enabled (STUB for player and recorder - all effect are done |
|
159 * via videobalance plugin. Used different saturations values). */ |
|
160 if(bCtx->baseObj.ctxId == XAMediaPlayerAdaptation || bCtx->baseObj.ctxId == XAMediaRecorderAdaptation) |
|
161 { |
|
162 switch( imageEffectID ) |
|
163 { |
|
164 case XA_IMAGEEFFECT_MONOCHROME: |
|
165 tempImageEffect = IMAGEEFFECT_MONOCHROME; |
|
166 break; |
|
167 case XA_IMAGEEFFECT_NEGATIVE: |
|
168 tempImageEffect = IMAGEEFFECT_NEGATIVE; |
|
169 break; |
|
170 case XA_IMAGEEFFECT_SEPIA: |
|
171 tempImageEffect = IMAGEEFFECT_SEPIA; |
|
172 break; |
|
173 case XA_IMAGEEFFECT_EMBOSS: |
|
174 tempImageEffect = IMAGEEFFECT_EMBOSS; |
|
175 break; |
|
176 case XA_IMAGEEFFECT_PAINTBRUSH: |
|
177 tempImageEffect = IMAGEEFFECT_PAINTBRUSH; |
|
178 break; |
|
179 case XA_IMAGEEFFECT_SOLARIZE: |
|
180 tempImageEffect = IMAGEEFFECT_SOLARIZE; |
|
181 break; |
|
182 case XA_IMAGEEFFECT_CARTOON: |
|
183 tempImageEffect = IMAGEEFFECT_CARTOON; |
|
184 break; |
|
185 default: |
|
186 { |
|
187 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
188 DEBUG_API("<-XAImageEffectsItfAdapt_EnableImageEffect") |
|
189 return XA_RESULT_FEATURE_UNSUPPORTED; |
|
190 } |
|
191 } |
|
192 |
|
193 if(bCtx->baseObj.ctxId == XAMediaPlayerAdaptation) |
|
194 { |
|
195 XAMediaPlayerAdaptationCtx* mCtx = (XAMediaPlayerAdaptationCtx*) bCtx; |
|
196 |
|
197 balanceElement = gst_bin_get_by_name( GST_BIN(mCtx->baseObj.bin), "pp_balance"); |
|
198 |
|
199 if( balanceElement && (imageEffectID != mCtx->imageEffectID) ) |
|
200 { |
|
201 g_object_set(G_OBJECT(balanceElement), "saturation", (gdouble)tempImageEffect, NULL); |
|
202 mCtx->imageEffectID = imageEffectID; |
|
203 ret = XAImageEffectsItfAdapt_HandleImageType(bCtx); |
|
204 } |
|
205 } |
|
206 |
|
207 if(bCtx->baseObj.ctxId == XAMediaRecorderAdaptation) |
|
208 { |
|
209 XAMediaRecorderAdaptationCtx* mCtx = (XAMediaRecorderAdaptationCtx*) bCtx; |
|
210 |
|
211 balanceElement = gst_bin_get_by_name( GST_BIN(mCtx->baseObj.bin), "pp_balance"); |
|
212 |
|
213 if( balanceElement && (imageEffectID != mCtx->imageEffectID) ) |
|
214 { |
|
215 g_object_set(G_OBJECT(balanceElement), "saturation", (gdouble)tempImageEffect, NULL); |
|
216 mCtx->imageEffectID = imageEffectID; |
|
217 } |
|
218 } |
|
219 } |
|
220 |
|
221 if(bCtx->baseObj.ctxId == XACameraAdaptation ) |
|
222 { |
|
223 XACameraAdaptationCtx* mCtx = (XACameraAdaptationCtx*) bCtx; |
|
224 GstColourToneMode gstColorToneMode = GST_PHOTOGRAPHY_COLOUR_TONE_MODE_NORMAL; |
|
225 |
|
226 if(GST_IS_PHOTOGRAPHY(mCtx->baseObj.bin)) |
|
227 { |
|
228 switch( imageEffectID ) |
|
229 { |
|
230 case XA_IMAGEEFFECT_NEGATIVE: |
|
231 { |
|
232 gstColorToneMode = GST_PHOTOGRAPHY_COLOUR_TONE_MODE_NEGATIVE; |
|
233 break; |
|
234 } |
|
235 case XA_IMAGEEFFECT_SEPIA: |
|
236 { |
|
237 gstColorToneMode = GST_PHOTOGRAPHY_COLOUR_TONE_MODE_SEPIA; |
|
238 break; |
|
239 } |
|
240 case XA_IMAGEEFFECT_SOLARIZE: |
|
241 { |
|
242 gstColorToneMode = GST_PHOTOGRAPHY_COLOUR_TONE_MODE_SOLARIZE; |
|
243 break; |
|
244 } |
|
245 default: |
|
246 { |
|
247 mCtx->imageEffectID = 0; |
|
248 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
249 DEBUG_API("<-XAImageEffectsItfAdapt_EnableImageEffect") |
|
250 return XA_RESULT_FEATURE_UNSUPPORTED; |
|
251 } |
|
252 } |
|
253 |
|
254 if( imageEffectID != mCtx->imageEffectID ) |
|
255 { |
|
256 if( !gst_photography_set_colour_tone_mode( GST_PHOTOGRAPHY(mCtx->baseObj.bin), gstColorToneMode ) ) |
|
257 { |
|
258 DEBUG_ERR("XA_RESULT_INTERNAL_ERROR"); |
|
259 DEBUG_API("<-XAImageEffectsItfAdapt_EnableImageEffect") |
|
260 return XA_RESULT_INTERNAL_ERROR; |
|
261 } |
|
262 mCtx->imageEffectID = imageEffectID; |
|
263 } |
|
264 } |
|
265 else |
|
266 { |
|
267 GstElement *videoPP = NULL; |
|
268 /* Stubbed image effects for camera */ |
|
269 switch( imageEffectID ) |
|
270 { |
|
271 case XA_IMAGEEFFECT_MONOCHROME: |
|
272 tempImageEffect = IMAGEEFFECT_MONOCHROME; |
|
273 break; |
|
274 case XA_IMAGEEFFECT_NEGATIVE: |
|
275 tempImageEffect = IMAGEEFFECT_NEGATIVE; |
|
276 break; |
|
277 case XA_IMAGEEFFECT_SEPIA: |
|
278 tempImageEffect = IMAGEEFFECT_SEPIA; |
|
279 break; |
|
280 case XA_IMAGEEFFECT_EMBOSS: |
|
281 tempImageEffect = IMAGEEFFECT_EMBOSS; |
|
282 break; |
|
283 case XA_IMAGEEFFECT_PAINTBRUSH: |
|
284 tempImageEffect = IMAGEEFFECT_PAINTBRUSH; |
|
285 break; |
|
286 case XA_IMAGEEFFECT_SOLARIZE: |
|
287 tempImageEffect = IMAGEEFFECT_SOLARIZE; |
|
288 break; |
|
289 case XA_IMAGEEFFECT_CARTOON: |
|
290 tempImageEffect = IMAGEEFFECT_CARTOON; |
|
291 break; |
|
292 default: |
|
293 { |
|
294 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
295 DEBUG_API("<-XAImageEffectsItfAdapt_EnableImageEffect") |
|
296 return XA_RESULT_FEATURE_UNSUPPORTED; |
|
297 } |
|
298 } |
|
299 |
|
300 videoPP = gst_bin_get_by_name( GST_BIN(mCtx->baseObj.bin), "videopp_camera"); |
|
301 if ( !videoPP ) |
|
302 { |
|
303 DEBUG_ERR("Could not receive videopp from camerabin!"); |
|
304 } |
|
305 else |
|
306 { |
|
307 /* Get camera balance element */ |
|
308 balanceElement = gst_bin_get_by_name( GST_BIN(videoPP), "pp_balance"); |
|
309 |
|
310 if( balanceElement && (imageEffectID != mCtx->imageEffectID) ) |
|
311 { |
|
312 g_object_set(G_OBJECT(balanceElement), "saturation", (gdouble)tempImageEffect, NULL); |
|
313 mCtx->imageEffectID = imageEffectID; |
|
314 } |
|
315 } |
|
316 |
|
317 if ( videoPP ) |
|
318 { |
|
319 gst_object_unref( videoPP ); |
|
320 } |
|
321 } |
|
322 } |
|
323 |
|
324 if ( balanceElement ) |
|
325 { |
|
326 gst_object_unref(balanceElement); |
|
327 } |
|
328 |
|
329 DEBUG_API("<-XAImageEffectsItfAdapt_EnableImageEffect") |
|
330 return ret; |
|
331 } |
|
332 |
|
333 /* |
|
334 * XAresult XAImageEffectsItfAdapt_DisableImageEffect(XAAdaptationGstCtx *bCtx, |
|
335 * XAuint32 imageEffectID) |
|
336 */ |
|
337 XAresult XAImageEffectsItfAdapt_DisableImageEffect(XAAdaptationGstCtx *bCtx, |
|
338 XAuint32 imageEffectID) |
|
339 { |
|
340 XAresult ret = XA_RESULT_SUCCESS; |
|
341 XAuint32 tempImageEffect = 0; |
|
342 GstElement *balanceElement = NULL; |
|
343 DEBUG_API("->XAImageEffectsItfAdapt_DisableImageEffect") |
|
344 |
|
345 if(!bCtx || (bCtx->baseObj.ctxId != XAMediaPlayerAdaptation && bCtx->baseObj.ctxId != XAMediaRecorderAdaptation |
|
346 && bCtx->baseObj.ctxId != XACameraAdaptation)) |
|
347 { |
|
348 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
349 DEBUG_API("<-XAImageEffectsItfAdapt_DisableImageEffect") |
|
350 return XA_RESULT_PARAMETER_INVALID; |
|
351 } |
|
352 |
|
353 /* check which effect is disabled (STUB for player and recorder - all effect are done |
|
354 * via videobalance plugin. Used saturation default value to disabling effects). */ |
|
355 if(bCtx->baseObj.ctxId == XAMediaPlayerAdaptation || bCtx->baseObj.ctxId == XAMediaRecorderAdaptation) |
|
356 { |
|
357 switch( imageEffectID ) |
|
358 { |
|
359 case XA_IMAGEEFFECT_MONOCHROME: |
|
360 case XA_IMAGEEFFECT_NEGATIVE: |
|
361 case XA_IMAGEEFFECT_SEPIA: |
|
362 case XA_IMAGEEFFECT_EMBOSS: |
|
363 case XA_IMAGEEFFECT_PAINTBRUSH: |
|
364 case XA_IMAGEEFFECT_SOLARIZE: |
|
365 case XA_IMAGEEFFECT_CARTOON: |
|
366 tempImageEffect = NO_IMAGEEFFECT; |
|
367 break; |
|
368 default: |
|
369 { |
|
370 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED") |
|
371 DEBUG_API("<-XAImageEffectsItfAdapt_DisableImageEffect") |
|
372 return XA_RESULT_FEATURE_UNSUPPORTED; |
|
373 } |
|
374 } |
|
375 |
|
376 if(bCtx->baseObj.ctxId == XAMediaPlayerAdaptation) |
|
377 { |
|
378 XAMediaPlayerAdaptationCtx* mCtx = (XAMediaPlayerAdaptationCtx*) bCtx; |
|
379 |
|
380 balanceElement = gst_bin_get_by_name( GST_BIN(mCtx->baseObj.bin), "pp_balance"); |
|
381 |
|
382 if( balanceElement ) |
|
383 { |
|
384 g_object_set(G_OBJECT(balanceElement), "saturation", (gdouble)GST_NO_IMAGEEFFECT, NULL); |
|
385 mCtx->imageEffectID = tempImageEffect; |
|
386 ret = XAImageEffectsItfAdapt_HandleImageType(bCtx); |
|
387 } |
|
388 } |
|
389 |
|
390 if(bCtx->baseObj.ctxId == XAMediaRecorderAdaptation) |
|
391 { |
|
392 XAMediaRecorderAdaptationCtx* mCtx = (XAMediaRecorderAdaptationCtx*) bCtx; |
|
393 |
|
394 balanceElement = gst_bin_get_by_name( GST_BIN(mCtx->baseObj.bin), "pp_balance"); |
|
395 |
|
396 if( balanceElement ) |
|
397 { |
|
398 g_object_set(G_OBJECT(balanceElement), "saturation", (gdouble)GST_NO_IMAGEEFFECT, NULL); |
|
399 mCtx->imageEffectID = tempImageEffect; |
|
400 } |
|
401 } |
|
402 } |
|
403 |
|
404 if(bCtx->baseObj.ctxId == XACameraAdaptation) |
|
405 { |
|
406 XACameraAdaptationCtx* mCtx = (XACameraAdaptationCtx*) bCtx; |
|
407 |
|
408 if(GST_IS_PHOTOGRAPHY(mCtx->baseObj.bin)) |
|
409 { |
|
410 switch( imageEffectID ) |
|
411 { |
|
412 case XA_IMAGEEFFECT_NEGATIVE: |
|
413 case XA_IMAGEEFFECT_SEPIA: |
|
414 case XA_IMAGEEFFECT_SOLARIZE: |
|
415 { |
|
416 /* Set color tone to normal */ |
|
417 if( !gst_photography_set_colour_tone_mode( GST_PHOTOGRAPHY(mCtx->baseObj.bin), |
|
418 GST_PHOTOGRAPHY_COLOUR_TONE_MODE_NORMAL ) ) |
|
419 { |
|
420 DEBUG_ERR("XA_RESULT_INTERNAL_ERROR"); |
|
421 DEBUG_API("<-XAImageEffectsItfAdapt_EnableImageEffect") |
|
422 return XA_RESULT_INTERNAL_ERROR; |
|
423 } |
|
424 mCtx->imageEffectID = NO_IMAGEEFFECT; |
|
425 break; |
|
426 } |
|
427 default: |
|
428 { |
|
429 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED") |
|
430 DEBUG_API("<-XAImageEffectsItfAdapt_DisableImageEffect") |
|
431 return XA_RESULT_FEATURE_UNSUPPORTED; |
|
432 } |
|
433 } |
|
434 } |
|
435 else |
|
436 { |
|
437 GstElement *videoPP = NULL; |
|
438 /* stubbed camera values */ |
|
439 switch( imageEffectID ) |
|
440 { |
|
441 case XA_IMAGEEFFECT_MONOCHROME: |
|
442 case XA_IMAGEEFFECT_NEGATIVE: |
|
443 case XA_IMAGEEFFECT_SEPIA: |
|
444 case XA_IMAGEEFFECT_EMBOSS: |
|
445 case XA_IMAGEEFFECT_PAINTBRUSH: |
|
446 case XA_IMAGEEFFECT_SOLARIZE: |
|
447 case XA_IMAGEEFFECT_CARTOON: |
|
448 mCtx->imageEffectID = NO_IMAGEEFFECT; |
|
449 break; |
|
450 default: |
|
451 { |
|
452 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED") |
|
453 DEBUG_API("<-XAImageEffectsItfAdapt_DisableImageEffect") |
|
454 return XA_RESULT_FEATURE_UNSUPPORTED; |
|
455 } |
|
456 } |
|
457 |
|
458 videoPP = gst_bin_get_by_name( GST_BIN(mCtx->baseObj.bin), "videopp_camera"); |
|
459 if ( !videoPP ) |
|
460 { |
|
461 DEBUG_ERR("Could not receive videopp from camerabin!"); |
|
462 } |
|
463 else |
|
464 { |
|
465 /* Get camera balance element */ |
|
466 balanceElement = gst_bin_get_by_name( GST_BIN(videoPP), "pp_balance"); |
|
467 |
|
468 if( balanceElement && (imageEffectID != mCtx->imageEffectID) ) |
|
469 { |
|
470 g_object_set(G_OBJECT(balanceElement), "saturation", (gdouble)GST_NO_IMAGEEFFECT, NULL); |
|
471 mCtx->imageEffectID = tempImageEffect; |
|
472 } |
|
473 } |
|
474 if ( videoPP ) |
|
475 { |
|
476 gst_object_unref(videoPP); |
|
477 } |
|
478 } |
|
479 } |
|
480 |
|
481 if ( balanceElement ) |
|
482 { |
|
483 gst_object_unref(balanceElement); |
|
484 } |
|
485 |
|
486 DEBUG_API("<-XAImageEffectsItfAdapt_DisableImageEffect") |
|
487 return ret; |
|
488 } |
|
489 |
|
490 /* |
|
491 * XAresult XAImageEffectsItfAdapt_IsImageEffectEnabled(XAAdaptationGstCtx *bCtx, |
|
492 * XAuint32 imageEffectID, |
|
493 * XAboolean *pEnabled) |
|
494 */ |
|
495 XAresult XAImageEffectsItfAdapt_IsImageEffectEnabled(XAAdaptationGstCtx *bCtx, |
|
496 XAuint32 imageEffectID, |
|
497 XAboolean *pEnabled) |
|
498 { |
|
499 XAresult ret = XA_RESULT_SUCCESS; |
|
500 XAuint32 tempImageEffect = 0; |
|
501 DEBUG_API("->XAImageEffectsItfAdapt_IsImageEffectEnabled") |
|
502 |
|
503 if(!bCtx || (bCtx->baseObj.ctxId != XAMediaPlayerAdaptation && bCtx->baseObj.ctxId != XAMediaRecorderAdaptation |
|
504 && bCtx->baseObj.ctxId != XACameraAdaptation) || !pEnabled) |
|
505 { |
|
506 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
507 DEBUG_API("<-XAImageEffectsItfAdapt_IsImageEffectEnabled") |
|
508 return XA_RESULT_PARAMETER_INVALID; |
|
509 } |
|
510 |
|
511 if(bCtx->baseObj.ctxId == XAMediaPlayerAdaptation) |
|
512 { |
|
513 XAMediaPlayerAdaptationCtx* mCtx = (XAMediaPlayerAdaptationCtx*) bCtx; |
|
514 tempImageEffect = mCtx->imageEffectID; |
|
515 } |
|
516 |
|
517 if(bCtx->baseObj.ctxId == XAMediaRecorderAdaptation) |
|
518 { |
|
519 XAMediaRecorderAdaptationCtx* mCtx = (XAMediaRecorderAdaptationCtx*) bCtx; |
|
520 tempImageEffect = mCtx->imageEffectID; |
|
521 } |
|
522 |
|
523 /* check is effect enabled for player and recorder */ |
|
524 if(bCtx->baseObj.ctxId == XAMediaPlayerAdaptation || bCtx->baseObj.ctxId == XAMediaRecorderAdaptation) |
|
525 { |
|
526 switch( imageEffectID ) |
|
527 { |
|
528 case XA_IMAGEEFFECT_MONOCHROME: |
|
529 case XA_IMAGEEFFECT_NEGATIVE: |
|
530 case XA_IMAGEEFFECT_SEPIA: |
|
531 case XA_IMAGEEFFECT_EMBOSS: |
|
532 case XA_IMAGEEFFECT_PAINTBRUSH: |
|
533 case XA_IMAGEEFFECT_SOLARIZE: |
|
534 case XA_IMAGEEFFECT_CARTOON: |
|
535 { |
|
536 /* Check is wanted effect currently enabled */ |
|
537 if( tempImageEffect == imageEffectID ) |
|
538 { |
|
539 *pEnabled = XA_BOOLEAN_TRUE; |
|
540 } |
|
541 else |
|
542 { |
|
543 *pEnabled = XA_BOOLEAN_FALSE; |
|
544 } |
|
545 break; |
|
546 } |
|
547 default: |
|
548 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
549 break; |
|
550 } |
|
551 } |
|
552 |
|
553 if(bCtx->baseObj.ctxId == XACameraAdaptation) |
|
554 { |
|
555 XACameraAdaptationCtx* mCtx = (XACameraAdaptationCtx*) bCtx; |
|
556 |
|
557 if(GST_IS_PHOTOGRAPHY(mCtx->baseObj.bin)) |
|
558 { |
|
559 switch( imageEffectID ) |
|
560 { |
|
561 case XA_IMAGEEFFECT_NEGATIVE: |
|
562 case XA_IMAGEEFFECT_SEPIA: |
|
563 case XA_IMAGEEFFECT_SOLARIZE: |
|
564 { |
|
565 /* Check is wanted effect currently enabled */ |
|
566 if( mCtx->imageEffectID == imageEffectID ) |
|
567 { |
|
568 *pEnabled = XA_BOOLEAN_TRUE; |
|
569 } |
|
570 else |
|
571 { |
|
572 *pEnabled = XA_BOOLEAN_FALSE; |
|
573 } |
|
574 break; |
|
575 } |
|
576 default: |
|
577 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
578 break; |
|
579 } |
|
580 } |
|
581 else |
|
582 { |
|
583 /* stubbed camera values */ |
|
584 switch( imageEffectID ) |
|
585 { |
|
586 case XA_IMAGEEFFECT_MONOCHROME: |
|
587 case XA_IMAGEEFFECT_NEGATIVE: |
|
588 case XA_IMAGEEFFECT_SEPIA: |
|
589 case XA_IMAGEEFFECT_EMBOSS: |
|
590 case XA_IMAGEEFFECT_PAINTBRUSH: |
|
591 case XA_IMAGEEFFECT_SOLARIZE: |
|
592 case XA_IMAGEEFFECT_CARTOON: |
|
593 { |
|
594 /* Check is wanted effect currently enabled */ |
|
595 if( mCtx->imageEffectID == imageEffectID ) |
|
596 { |
|
597 *pEnabled = XA_BOOLEAN_TRUE; |
|
598 } |
|
599 else |
|
600 { |
|
601 *pEnabled = XA_BOOLEAN_FALSE; |
|
602 } |
|
603 break; |
|
604 } |
|
605 default: |
|
606 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
607 break; |
|
608 } |
|
609 } |
|
610 } |
|
611 |
|
612 DEBUG_API("<-XAImageEffectsItfAdapt_IsImageEffectEnabled"); |
|
613 return ret; |
|
614 } |
|
615 /* |
|
616 * XAresult XAImageEffectsItfAdapt_HandleImageType(XAAdaptationGstCtx *bCtx) |
|
617 * Description: this run gstreamer for image type |
|
618 * |
|
619 */ |
|
620 XAresult XAImageEffectsItfAdapt_HandleImageType(XAAdaptationGstCtx *bCtx) |
|
621 { |
|
622 XAresult ret = XA_RESULT_SUCCESS; |
|
623 XADataSource *dataSrc = NULL; |
|
624 GstStateChangeReturn gstRet = GST_STATE_CHANGE_SUCCESS; |
|
625 GstState gstOrigState = GST_STATE_PLAYING; |
|
626 GstState gstTmpState = GST_STATE_PLAYING; |
|
627 XAMediaPlayerAdaptationCtx* mCtx = NULL; |
|
628 DEBUG_API("->XAImageEffectsItfAdapt_HandleImageType"); |
|
629 |
|
630 if( !bCtx || (bCtx->baseObj.ctxId != XAMediaPlayerAdaptation) ) |
|
631 { |
|
632 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
633 DEBUG_API("<-XAImageEffectsItfAdapt_HandleImageType") |
|
634 return XA_RESULT_PARAMETER_INVALID; |
|
635 } |
|
636 |
|
637 mCtx = (XAMediaPlayerAdaptationCtx*) bCtx; |
|
638 |
|
639 dataSrc = mCtx->xaSource; |
|
640 |
|
641 if( dataSrc ) |
|
642 { |
|
643 XAMediaType mediaType; |
|
644 ret = XACommon_CheckDataSource(dataSrc, &mediaType); |
|
645 if( ret == XA_RESULT_SUCCESS && mediaType == XA_MEDIATYPE_IMAGE ) |
|
646 { |
|
647 gstOrigState = GST_STATE(bCtx->bin); |
|
648 |
|
649 DEBUG_INFO_A1("Sending change state request to state %d", GST_STATE_READY); |
|
650 gstRet = gst_element_set_state( GST_ELEMENT(bCtx->bin), GST_STATE_READY); |
|
651 gstTmpState = GST_STATE(bCtx->bin); |
|
652 if(gstRet == GST_STATE_CHANGE_SUCCESS && gstTmpState == GST_STATE_READY) |
|
653 { |
|
654 DEBUG_INFO_A1("Sending change state request to state %d", gstOrigState); |
|
655 gstRet = gst_element_set_state( GST_ELEMENT(bCtx->bin), gstOrigState); |
|
656 } |
|
657 } |
|
658 } |
|
659 DEBUG_API("<-XAImageEffectsItfAdapt_HandleImageType"); |
|
660 return ret; |
|
661 } |
|