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 "xacameraitf.h" |
21 #include "xacameraitf.h" |
22 #ifdef _GSTREAMER_BACKEND_ |
22 |
23 #include "XACameraItfAdaptation.h" |
23 #include "xacameraitfadaptation.h" |
24 #endif |
24 |
25 #include "xathreadsafety.h" |
25 #include "xathreadsafety.h" |
26 |
26 |
27 /* XACameraItfImpl* GetImpl(XACameraItf self) |
27 /* XACameraItfImpl* GetImpl(XACameraItf self) |
28 * Description: Validate interface pointer and cast it to implementation pointer. |
28 * Description: Validate interface pointer and cast it to implementation pointer. |
29 */ |
29 */ |
96 } |
96 } |
97 |
97 |
98 /* check is flash mode changed */ |
98 /* check is flash mode changed */ |
99 if( impl->flashMode != flashMode ) |
99 if( impl->flashMode != flashMode ) |
100 { |
100 { |
101 #ifdef _GSTREAMER_BACKEND_ |
101 if(impl->adapCtx->fwtype == FWMgrFWGST) |
102 ret = XACameraItfAdapt_SetFlashMode( impl->adapCtx, flashMode ); |
102 { |
103 #endif |
103 ret = XACameraItfAdapt_SetFlashMode( (XAAdaptationGstCtx*)impl->adapCtx, flashMode ); |
104 if ( ret == XA_RESULT_SUCCESS ) |
104 } |
|
105 else |
|
106 { |
|
107 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
108 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
109 } |
|
110 if ( ret == XA_RESULT_SUCCESS ) |
105 { |
111 { |
106 impl->flashMode = flashMode; |
112 impl->flashMode = flashMode; |
107 } |
113 } |
108 /* wait for adaptation */ |
114 /* wait for adaptation */ |
109 impl->flashReady = XA_BOOLEAN_FALSE; |
115 impl->flashReady = XA_BOOLEAN_FALSE; |
187 } |
193 } |
188 |
194 |
189 /* check is focus mode changed */ |
195 /* check is focus mode changed */ |
190 if( impl->focusMode != focusMode ) |
196 if( impl->focusMode != focusMode ) |
191 { |
197 { |
192 #ifdef _GSTREAMER_BACKEND_ |
198 if(impl->adapCtx->fwtype == FWMgrFWGST) |
193 ret = XACameraItfAdapt_SetFocusMode( impl->adapCtx, focusMode, manualSetting, macroEnabled ); |
199 { |
194 #endif |
200 ret = XACameraItfAdapt_SetFocusMode( (XAAdaptationGstCtx*)impl->adapCtx, focusMode, manualSetting, macroEnabled ); |
195 if ( ret == XA_RESULT_SUCCESS ) |
201 } |
|
202 else |
|
203 { |
|
204 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
205 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
206 } |
|
207 if ( ret == XA_RESULT_SUCCESS ) |
196 { |
208 { |
197 impl->focusMode = focusMode; |
209 impl->focusMode = focusMode; |
198 impl->focusManualSetting = manualSetting; |
210 impl->focusManualSetting = manualSetting; |
199 impl->macroEnabled = macroEnabled; |
211 impl->macroEnabled = macroEnabled; |
200 } |
212 } |
269 } |
281 } |
270 |
282 |
271 /* check is focus pattern changed */ |
283 /* check is focus pattern changed */ |
272 if( focusPattern == impl->focusPattern ) |
284 if( focusPattern == impl->focusPattern ) |
273 { |
285 { |
274 #ifdef _GSTREAMER_BACKEND_ |
286 if(impl->adapCtx->fwtype == FWMgrFWGST) |
275 ret = XACameraItfAdapt_SetFocusRegionPattern( impl->adapCtx, focusPattern, activePoints1, activePoints2 ); |
287 { |
276 #endif |
288 ret = XACameraItfAdapt_SetFocusRegionPattern( (XAAdaptationGstCtx*)impl->adapCtx, focusPattern, activePoints1, activePoints2 ); |
277 if (ret == XA_RESULT_SUCCESS) |
289 } |
|
290 else |
|
291 { |
|
292 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
293 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
294 } |
|
295 if (ret == XA_RESULT_SUCCESS) |
278 { |
296 { |
279 impl->focusPattern = focusPattern; |
297 impl->focusPattern = focusPattern; |
280 if( !(impl->focusMode & XA_CAMERA_FOCUSMODE_MANUAL) ) |
298 if( !(impl->focusMode & XA_CAMERA_FOCUSMODE_MANUAL) ) |
281 { |
299 { |
282 impl->activePoints1 = activePoints1; |
300 impl->activePoints1 = activePoints1; |
347 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
365 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
348 DEBUG_API("<-XACameraItfImpl_GetFocusRegionPositions"); |
366 DEBUG_API("<-XACameraItfImpl_GetFocusRegionPositions"); |
349 /* invalid parameter */ |
367 /* invalid parameter */ |
350 return XA_RESULT_PARAMETER_INVALID; |
368 return XA_RESULT_PARAMETER_INVALID; |
351 } |
369 } |
352 |
370 if(impl->adapCtx->fwtype == FWMgrFWGST) |
353 #ifdef _GSTREAMER_BACKEND_ |
371 { |
354 ret = XACameraItfAdapt_GetFocusRegionPositions( impl->adapCtx, pNumPositionEntries, |
372 ret = XACameraItfAdapt_GetFocusRegionPositions( (XAAdaptationGstCtx*)impl->adapCtx, pNumPositionEntries, |
355 pFocusPosition ); |
373 pFocusPosition ); |
356 #endif |
374 } |
|
375 else |
|
376 { |
|
377 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
378 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
379 } |
357 DEBUG_API("<-XACameraItfImpl_GetFocusRegionPositions"); |
380 DEBUG_API("<-XACameraItfImpl_GetFocusRegionPositions"); |
358 return ret; |
381 return ret; |
359 } |
382 } |
360 |
383 |
361 /** |
384 /** |
405 XA_IMPL_THREAD_SAFETY_EXIT(XATSCamera); |
428 XA_IMPL_THREAD_SAFETY_EXIT(XATSCamera); |
406 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
429 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
407 DEBUG_API("<-XACameraItfImpl_SetMeteringMode"); |
430 DEBUG_API("<-XACameraItfImpl_SetMeteringMode"); |
408 return XA_RESULT_PARAMETER_INVALID; |
431 return XA_RESULT_PARAMETER_INVALID; |
409 } |
432 } |
410 #ifdef _GSTREAMER_BACKEND_ |
433 if(impl->adapCtx->fwtype == FWMgrFWGST) |
411 ret = XACameraItfAdapt_SetMeteringMode( impl->adapCtx, meteringMode ); |
434 { |
412 #endif |
435 ret = XACameraItfAdapt_SetMeteringMode( (XAAdaptationGstCtx*)impl->adapCtx, meteringMode ); |
|
436 } |
|
437 else |
|
438 { |
|
439 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
440 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
441 } |
413 if ( ret == XA_RESULT_SUCCESS ) |
442 if ( ret == XA_RESULT_SUCCESS ) |
414 { |
443 { |
415 impl->meteringMode = meteringMode; |
444 impl->meteringMode = meteringMode; |
416 } |
445 } |
417 |
446 |
468 } |
497 } |
469 |
498 |
470 /* check is focus mode changed */ |
499 /* check is focus mode changed */ |
471 if( impl->exposureMode != exposure || impl->compensation != compensation ) |
500 if( impl->exposureMode != exposure || impl->compensation != compensation ) |
472 { |
501 { |
473 #ifdef _GSTREAMER_BACKEND_ |
502 if(impl->adapCtx->fwtype == FWMgrFWGST) |
474 ret = XACameraItfAdapt_SetExposureMode( impl->adapCtx, exposure, exposure ); |
503 { |
475 #endif |
504 ret = XACameraItfAdapt_SetExposureMode( (XAAdaptationGstCtx*)impl->adapCtx, exposure, exposure ); |
476 if ( ret == XA_RESULT_SUCCESS ) |
505 } |
|
506 else |
|
507 { |
|
508 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
509 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
510 } |
|
511 if ( ret == XA_RESULT_SUCCESS ) |
477 { |
512 { |
478 impl->exposureMode = exposure; |
513 impl->exposureMode = exposure; |
479 impl->compensation = compensation; |
514 impl->compensation = compensation; |
480 } |
515 } |
481 } |
516 } |
537 } |
572 } |
538 |
573 |
539 /* check is focus mode changed */ |
574 /* check is focus mode changed */ |
540 if( impl->isoSensitivity != isoSensitivity || impl->isoManualSetting != manualSetting ) |
575 if( impl->isoSensitivity != isoSensitivity || impl->isoManualSetting != manualSetting ) |
541 { |
576 { |
542 #ifdef _GSTREAMER_BACKEND_ |
577 if(impl->adapCtx->fwtype == FWMgrFWGST) |
543 ret = XACameraItfAdapt_SetISOSensitivity( impl->adapCtx, isoSensitivity, manualSetting ); |
578 { |
544 #endif |
579 ret = XACameraItfAdapt_SetISOSensitivity((XAAdaptationGstCtx*)impl->adapCtx, isoSensitivity, manualSetting ); |
545 if ( ret == XA_RESULT_SUCCESS ) |
580 } |
|
581 else |
|
582 { |
|
583 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
584 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
585 } |
|
586 if ( ret == XA_RESULT_SUCCESS ) |
546 { |
587 { |
547 impl->isoSensitivity = isoSensitivity; |
588 impl->isoSensitivity = isoSensitivity; |
548 impl->isoManualSetting = manualSetting; |
589 impl->isoManualSetting = manualSetting; |
549 } |
590 } |
550 } |
591 } |
614 } |
655 } |
615 |
656 |
616 /* check is aperture mode or value changed */ |
657 /* check is aperture mode or value changed */ |
617 if( impl->aperture != aperture || impl->apertureManualSetting != manualSetting ) |
658 if( impl->aperture != aperture || impl->apertureManualSetting != manualSetting ) |
618 { |
659 { |
619 #ifdef _GSTREAMER_BACKEND_ |
660 if(impl->adapCtx->fwtype == FWMgrFWGST) |
620 ret = XACameraItfAdapt_SetAperture( impl->adapCtx, aperture, manualSetting ); |
661 { |
621 #endif |
662 ret = XACameraItfAdapt_SetAperture( (XAAdaptationGstCtx*)impl->adapCtx, aperture, manualSetting ); |
622 if ( ret == XA_RESULT_SUCCESS ) |
663 } |
|
664 else |
|
665 { |
|
666 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
667 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
668 } |
|
669 if ( ret == XA_RESULT_SUCCESS ) |
623 { |
670 { |
624 impl->aperture = aperture; |
671 impl->aperture = aperture; |
625 impl->apertureManualSetting = manualSetting; |
672 impl->apertureManualSetting = manualSetting; |
626 } |
673 } |
627 } |
674 } |
687 XA_IMPL_THREAD_SAFETY_EXIT(XATSCamera); |
734 XA_IMPL_THREAD_SAFETY_EXIT(XATSCamera); |
688 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
735 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
689 DEBUG_API("<-XACameraItfImpl_SetShutterSpeed"); |
736 DEBUG_API("<-XACameraItfImpl_SetShutterSpeed"); |
690 return XA_RESULT_PARAMETER_INVALID; |
737 return XA_RESULT_PARAMETER_INVALID; |
691 } |
738 } |
692 |
739 if(impl->adapCtx->fwtype == FWMgrFWGST) |
693 #ifdef _GSTREAMER_BACKEND_ |
740 { |
694 ret = XACameraItfAdapt_SetShutterSpeed( impl->adapCtx, shutterSpeed, manualSetting ); |
741 ret = XACameraItfAdapt_SetShutterSpeed( (XAAdaptationGstCtx*)impl->adapCtx, shutterSpeed, manualSetting ); |
695 #endif |
742 } |
|
743 else |
|
744 { |
|
745 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
746 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
747 } |
696 if ( ret == XA_RESULT_SUCCESS ) |
748 if ( ret == XA_RESULT_SUCCESS ) |
697 { |
749 { |
698 impl->shutterManualSetting = manualSetting; |
750 impl->shutterManualSetting = manualSetting; |
699 impl->shutterSpeed = shutterSpeed; |
751 impl->shutterSpeed = shutterSpeed; |
700 } |
752 } |
764 } |
816 } |
765 |
817 |
766 /* check is whitebalance mode or value changed */ |
818 /* check is whitebalance mode or value changed */ |
767 if( impl->whiteBalance != whiteBalance || impl->whiteBalManualSetting != manualSetting ) |
819 if( impl->whiteBalance != whiteBalance || impl->whiteBalManualSetting != manualSetting ) |
768 { |
820 { |
769 #ifdef _GSTREAMER_BACKEND_ |
821 if(impl->adapCtx->fwtype == FWMgrFWGST) |
770 ret = XACameraItfAdapt_SetWhiteBalance( impl->adapCtx, whiteBalance, manualSetting ); |
822 { |
771 #endif |
823 ret = XACameraItfAdapt_SetWhiteBalance( (XAAdaptationGstCtx*)impl->adapCtx, whiteBalance, manualSetting ); |
772 if ( ret == XA_RESULT_SUCCESS ) |
824 } |
|
825 else |
|
826 { |
|
827 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
828 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
829 } |
|
830 if ( ret == XA_RESULT_SUCCESS ) |
773 { |
831 { |
774 impl->whiteBalance = whiteBalance; |
832 impl->whiteBalance = whiteBalance; |
775 impl->whiteBalManualSetting = manualSetting; |
833 impl->whiteBalManualSetting = manualSetting; |
776 } |
834 } |
777 } |
835 } |
834 DEBUG_API("<-XACameraItfImpl_SetAutoLocks"); |
892 DEBUG_API("<-XACameraItfImpl_SetAutoLocks"); |
835 /* invalid parameter */ |
893 /* invalid parameter */ |
836 return XA_RESULT_PARAMETER_INVALID; |
894 return XA_RESULT_PARAMETER_INVALID; |
837 } |
895 } |
838 |
896 |
839 #ifdef _GSTREAMER_BACKEND_ |
897 if(impl->adapCtx->fwtype == FWMgrFWGST) |
840 ret = XACameraItfAdapt_SetAutoLocks( impl->adapCtx, locks ); |
898 { |
841 #endif |
899 ret = XACameraItfAdapt_SetAutoLocks( (XAAdaptationGstCtx*)impl->adapCtx, locks ); |
|
900 |
|
901 } |
|
902 else |
|
903 { |
|
904 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
905 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
906 } |
|
907 |
842 if ( ret == XA_RESULT_SUCCESS ) |
908 if ( ret == XA_RESULT_SUCCESS ) |
843 { |
909 { |
844 impl->locks = locks; |
910 impl->locks = locks; |
845 } |
911 } |
846 |
912 |
897 XA_IMPL_THREAD_SAFETY_EXIT(XATSCamera); |
963 XA_IMPL_THREAD_SAFETY_EXIT(XATSCamera); |
898 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
964 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
899 DEBUG_API("<-XACameraItfImpl_SetZoom"); |
965 DEBUG_API("<-XACameraItfImpl_SetZoom"); |
900 return XA_RESULT_PARAMETER_INVALID; |
966 return XA_RESULT_PARAMETER_INVALID; |
901 } |
967 } |
902 |
968 if(impl->adapCtx->fwtype == FWMgrFWGST) |
903 #ifdef _GSTREAMER_BACKEND_ |
969 { |
904 ret = XACameraItfAdapt_SetZoom( impl->adapCtx, zoom, digitalEnabled, speed, async ); |
970 ret = XACameraItfAdapt_SetZoom( (XAAdaptationGstCtx*)impl->adapCtx, zoom, digitalEnabled, speed, async ); |
905 #endif |
971 |
|
972 } |
|
973 else |
|
974 { |
|
975 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
976 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
977 } |
|
978 |
906 if ( ret == XA_RESULT_SUCCESS ) |
979 if ( ret == XA_RESULT_SUCCESS ) |
907 { |
980 { |
908 impl->zoom = zoom; |
981 impl->zoom = zoom; |
909 impl->digitalEnabled = digitalEnabled; |
982 impl->digitalEnabled = digitalEnabled; |
910 impl->speed = speed; |
983 impl->speed = speed; |
950 *****************************************************************************/ |
1023 *****************************************************************************/ |
951 |
1024 |
952 /* XACameraItfImpl* XACameraItfImpl_Create() |
1025 /* XACameraItfImpl* XACameraItfImpl_Create() |
953 * Description: Allocate and initialize CameraItfImpl |
1026 * Description: Allocate and initialize CameraItfImpl |
954 */ |
1027 */ |
955 #ifdef _GSTREAMER_BACKEND_ |
|
956 |
1028 |
957 XACameraItfImpl* XACameraItfImpl_Create( XAAdaptationBaseCtx *adapCtx ) |
1029 XACameraItfImpl* XACameraItfImpl_Create( XAAdaptationBaseCtx *adapCtx ) |
958 { |
1030 { |
959 XACameraItfImpl* self = (XACameraItfImpl*) |
1031 XACameraItfImpl* self = (XACameraItfImpl*) |
960 calloc(1,sizeof(XACameraItfImpl)); |
1032 calloc(1,sizeof(XACameraItfImpl)); |
992 |
1064 |
993 /* init variables */ |
1065 /* init variables */ |
994 self->flashReady = XA_BOOLEAN_TRUE; |
1066 self->flashReady = XA_BOOLEAN_TRUE; |
995 self->adapCtx = adapCtx; |
1067 self->adapCtx = adapCtx; |
996 self->cbPtrToSelf = NULL; |
1068 self->cbPtrToSelf = NULL; |
997 #ifdef _GSTREAMER_BACKEND_ |
|
998 XAAdaptationBase_AddEventHandler( adapCtx, &XACameraItfImp_AdaptCb, XA_CAMERAITFEVENTS, self ); |
1069 XAAdaptationBase_AddEventHandler( adapCtx, &XACameraItfImp_AdaptCb, XA_CAMERAITFEVENTS, self ); |
999 #endif |
|
1000 self->self = self; |
1070 self->self = self; |
1001 } |
1071 } |
1002 |
1072 |
1003 DEBUG_API("<-XACameraItfImpl_Create"); |
1073 DEBUG_API("<-XACameraItfImpl_Create"); |
1004 return self; |
1074 return self; |
1005 } |
1075 } |
1006 |
1076 |
1007 #endif |
1077 |
1008 /* void XACameraItfImpl_Free(XACameraItfImpl* self) |
1078 /* void XACameraItfImpl_Free(XACameraItfImpl* self) |
1009 * Description: Free all resources reserved at XACameraItfImpl_Create |
1079 * Description: Free all resources reserved at XACameraItfImpl_Create |
1010 */ |
1080 */ |
1011 void XACameraItfImpl_Free(XACameraItfImpl* self) |
1081 void XACameraItfImpl_Free(XACameraItfImpl* self) |
1012 { |
1082 { |
1013 DEBUG_API("->XACameraItfImpl_Free"); |
1083 DEBUG_API("->XACameraItfImpl_Free"); |
1014 assert( self==self->self ); |
1084 assert( self==self->self ); |
1015 #ifdef _GSTREAMER_BACKEND_ |
|
1016 XAAdaptationBase_RemoveEventHandler( self->adapCtx, &XACameraItfImp_AdaptCb ); |
1085 XAAdaptationBase_RemoveEventHandler( self->adapCtx, &XACameraItfImp_AdaptCb ); |
1017 #endif |
|
1018 free( self ); |
1086 free( self ); |
1019 DEBUG_API("<-XACameraItfImpl_Free"); |
1087 DEBUG_API("<-XACameraItfImpl_Free"); |
1020 } |
1088 } |
1021 |
1089 |
1022 #ifdef _GSTREAMER_BACKEND_ |
|
1023 /* void XACameraItfAdapt_AdaptCb( void *pHandlerCtx, XAAdaptEvent *event ) |
1090 /* void XACameraItfAdapt_AdaptCb( void *pHandlerCtx, XAAdaptEvent *event ) |
1024 * @param void *pHandlerCtx - pointer to cb context (XACameraItfImpl) |
1091 * @param void *pHandlerCtx - pointer to cb context (XACameraItfImpl) |
1025 * @param XAAdaptEvent *event - Event |
1092 * @param XAAdaptEvent *event - Event |
1026 * Description: Event handler for adaptation events |
1093 * Description: Event handler for adaptation events |
1027 */ |
1094 */ |