Tizen 2.0 Release
[framework/osp/media.git] / src / FMedia_CameraCapability.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FMedia_CameraCapability.cpp
20  * @brief               This file contains the implementation of camera/recorder capability header file FMedia_CameraCapability.h
21  */
22
23 #include <pthread.h>
24 #include <unique_ptr.h>
25 #include <FBaseSysLog.h>
26 #include <FBaseInteger.h>
27 #include <FBaseColArrayList.h>
28 #include "FMedia_CameraCoordinator.h"
29 #include "FMedia_CameraCapability.h"
30 #include "FMedia_CameraCapabilitySession.h"
31 #include "FMedia_CameraUtil.h"
32 #include "FMedia_CamPtrUtil.h"
33
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Graphics;
37
38 namespace Tizen { namespace Media
39 {
40
41 _CameraCapabilitySafeHashMapT* _CameraCapability::__pMap = null;
42
43 _CameraCapabilitySafeHashMapT::_CameraCapabilitySafeHashMapT(void)
44 {
45 }
46
47 _CameraCapabilitySafeHashMapT::~_CameraCapabilitySafeHashMapT(void)
48 {
49         RemoveItems();
50         _CameraCapability::__pMap = null;
51 }
52
53 void
54 _CameraCapabilitySafeHashMapT::RemoveItems(void)
55 {
56         result r = E_SUCCESS;
57
58         std::unique_ptr<IListT<_CameraDeviceType>, _ListPtrUtil::Remover> pList (GetKeysN(), _ListPtrUtil::remover);
59         SysTryReturn(NID_MEDIA, pList.get() != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] There is no instance.");
60
61         for (int i = 0; i < GetCount(); i++)
62         {
63                 _CameraDeviceType deviceType = _CAMERA_DEVICE_NONE;
64                 r = pList->GetAt(i, deviceType);
65                 if (IsFailed(r) && deviceType == _CAMERA_DEVICE_NONE)
66                 {
67                         continue;
68                 }
69
70                 _CameraCapability* pCapability = null;
71                 r = GetValue(deviceType, pCapability);
72                 if (IsFailed(r) && pCapability == null)
73                 {
74                         continue;
75                 }
76                 delete pCapability;
77         }
78         RemoveAll();
79 }
80
81 const _CameraCapability::keyServiceMap _CameraCapability::__SERVICE_MAP[] =
82 {
83         {
84                 _COP_NONE, _CAMERA_DEVICE_PRIMARY, null
85         },
86         {
87                 _COP_PRIMARY_CAPTURE_FORMAT, _CAMERA_DEVICE_PRIMARY, GetSupportedCaptureFormatN
88         },
89         {
90                 _COP_PRIMARY_CAPTURE_RESOLUTION, _CAMERA_DEVICE_PRIMARY, GetSupportedCaptureResolutionN
91         },
92         {
93                 _COP_PRIMARY_DIRECTION, _CAMERA_DEVICE_PRIMARY, GetDirectionN
94         },
95         {
96                 _COP_PRIMARY_EFFECT, _CAMERA_DEVICE_PRIMARY, GetSupportedEffectTypeN
97         },
98         {
99                 _COP_PRIMARY_ISO_LEVEL, _CAMERA_DEVICE_PRIMARY, GetSupportedIsoLevelN
100         },
101         {
102                 _COP_PRIMARY_PREVIEW_FORMAT, _CAMERA_DEVICE_PRIMARY, GetSupportedPreviewFormatN
103         },
104         {
105                 _COP_PRIMARY_PREVIEW_FRAMERATE, _CAMERA_DEVICE_PRIMARY, GetSupportedPreviewFrameRateN
106         },
107         {
108                 _COP_PRIMARY_PREVIEW_RESOLUTION, _CAMERA_DEVICE_PRIMARY, GetSupportedPreviewResolutionN
109         },
110         {
111                 _COP_PRIMARY_RECORDING_RESOLUTION, _CAMERA_DEVICE_PRIMARY, GetSupportedRecordingResolutionN
112         },
113         {
114                 _COP_PRIMARY_ROTATION, _CAMERA_DEVICE_PRIMARY, GetPhysicalRotationN
115         },
116         {
117                 _COP_PRIMARY_BRIGHTNESS, _CAMERA_DEVICE_PRIMARY, GetSupportedBrightnessN
118         },
119         {
120                 _COP_PRIMARY_CONTRAST, _CAMERA_DEVICE_PRIMARY, GetSupportedContrastN
121         },
122         {
123                 _COP_PRIMARY_EXPOSURE, _CAMERA_DEVICE_PRIMARY, GetSupportedExposureN
124         },
125         {
126                 _COP_PRIMARY_FLASH_MODE, _CAMERA_DEVICE_PRIMARY, GetSupportedFlashModeN
127         },
128         {
129                 _COP_PRIMARY_FOCUS_MODE, _CAMERA_DEVICE_PRIMARY, GetSupportedFocusModeN
130         },
131         {
132                 _COP_PRIMARY_METERING_MODE, _CAMERA_DEVICE_PRIMARY, GetSupportedMeteringModeN
133         },
134         {
135                 _COP_PRIMARY_WHITE_BALANCE, _CAMERA_DEVICE_PRIMARY, GetSupportedWhiteBalanceN
136         },
137         {
138                 _COP_PRIMARY_ZOOM_TYPE, _CAMERA_DEVICE_PRIMARY, null
139         },
140         {
141                 _COP_PRIMARY_FLIP, _CAMERA_DEVICE_PRIMARY, null
142         },
143         {
144                 _COP_PRIMARY_PREVIEW_ROTATION, _CAMERA_DEVICE_PRIMARY, null
145         },
146         {
147                 _COP_PRIMARY_ZERO_SHUTTER_LAG, _CAMERA_DEVICE_PRIMARY, GetZeroShutterLagN
148         },
149         {
150                 _COP_PRIMARY_ZOOM_LEVEL, _CAMERA_DEVICE_PRIMARY, GetSupportedZoomLevelN
151         },
152         {
153                 _COP_PRIMARY_MAX_FRAMERATE, _CAMERA_DEVICE_PRIMARY, GetSupportedMaxRecordingFrameRateN
154         },
155         {
156                 _COP_SECONDARY_CAPTURE_FORMAT, _CAMERA_DEVICE_SECONDARY, GetSupportedCaptureFormatN
157         },
158         {
159                 _COP_SECONDARY_CAPTURE_RESOLUTION, _CAMERA_DEVICE_SECONDARY, GetSupportedCaptureResolutionN
160         },
161         {
162                 _COP_SECONDARY_DIRECTION, _CAMERA_DEVICE_SECONDARY, GetDirectionN
163         },
164         {
165                 _COP_SECONDARY_EFFECT, _CAMERA_DEVICE_SECONDARY, GetSupportedEffectTypeN
166         },
167         {
168                 _COP_SECONDARY_ISO_LEVEL, _CAMERA_DEVICE_SECONDARY, GetSupportedIsoLevelN
169         },
170         {
171                 _COP_SECONDARY_PREVIEW_FORMAT, _CAMERA_DEVICE_SECONDARY, GetSupportedPreviewFormatN
172         },
173         {
174                 _COP_SECONDARY_PREVIEW_FRAMERATE, _CAMERA_DEVICE_SECONDARY, GetSupportedPreviewFrameRateN
175         },
176         {
177                 _COP_SECONDARY_PREVIEW_RESOLUTION, _CAMERA_DEVICE_SECONDARY, GetSupportedPreviewResolutionN
178         },
179         {
180                 _COP_SECONDARY_RECORDING_RESOLUTION, _CAMERA_DEVICE_SECONDARY, GetSupportedRecordingResolutionN
181         },
182         {
183                 _COP_SECONDARY_ROTATION, _CAMERA_DEVICE_SECONDARY, GetPhysicalRotationN
184         },
185         {
186                 _COP_SECONDARY_BRIGHTNESS, _CAMERA_DEVICE_SECONDARY, GetSupportedBrightnessN
187         },
188         {
189                 _COP_SECONDARY_CONTRAST, _CAMERA_DEVICE_SECONDARY, GetSupportedContrastN
190         },
191         {
192                 _COP_SECONDARY_EXPOSURE, _CAMERA_DEVICE_SECONDARY, GetSupportedExposureN
193         },
194         {
195                 _COP_SECONDARY_FLASH_MODE, _CAMERA_DEVICE_SECONDARY, GetSupportedFlashModeN
196         },
197         {
198                 _COP_SECONDARY_FOCUS_MODE, _CAMERA_DEVICE_SECONDARY, GetSupportedFocusModeN
199         },
200         {
201                 _COP_SECONDARY_METERING_MODE, _CAMERA_DEVICE_SECONDARY, GetSupportedMeteringModeN
202         },
203         {
204                 _COP_SECONDARY_WHITE_BALANCE, _CAMERA_DEVICE_SECONDARY, GetSupportedWhiteBalanceN
205         },
206         {
207                 _COP_SECONDARY_ZOOM_TYPE, _CAMERA_DEVICE_SECONDARY, null
208         },
209         {
210                 _COP_SECONDARY_FLIP, _CAMERA_DEVICE_SECONDARY, null
211         },
212         {
213                 _COP_SECONDARY_PREVIEW_ROTATION, _CAMERA_DEVICE_SECONDARY, null
214         },
215         {
216                 _COP_SECONDARY_ZERO_SHUTTER_LAG, _CAMERA_DEVICE_SECONDARY, GetZeroShutterLagN
217         },
218         {
219                 _COP_SECONDARY_ZOOM_LEVEL, _CAMERA_DEVICE_SECONDARY, GetSupportedZoomLevelN
220         },
221         {
222                 _COP_SECONDARY_MAX_FRAMERATE, _CAMERA_DEVICE_SECONDARY, GetSupportedMaxRecordingFrameRateN
223         },
224         {
225                 _COP_MAX, _CAMERA_DEVICE_SECONDARY, null
226         },
227 };
228
229 _CameraCapability::_CameraCapability(void)
230         : __device(_CAMERA_DEVICE_NONE)
231         , __handle(MM_INVALID_HANDLE)
232         , __initPreviewWidth(0)
233         , __initPreviewHeight(0)
234         , __initCaptureWidth(0)
235         , __initCaptureHeight(0)
236         , __initPreviewFormat(::CAMERA_PIXEL_FORMAT_INVALID)
237         , __initCaptureFormat(::CAMERA_PIXEL_FORMAT_INVALID)
238         , __initFlashMode(::CAMERA_ATTR_FLASH_MODE_OFF)
239         , __initEffectMode(::CAMERA_ATTR_EFFECT_NONE)
240         , __initFps(::CAMERA_ATTR_FPS_AUTO)
241         , __initIsoLevel(::CAMERA_ATTR_ISO_AUTO)
242         , __initWb(::CAMERA_ATTR_WHITE_BALANCE_NONE)
243         , __initSceneMode(::CAMERA_ATTR_SCENE_MODE_NORMAL)
244         , __initMeteringMode(::CAMERA_ATTR_EXPOSURE_MODE_OFF)
245         , __initAfMode(::CAMERA_ATTR_AF_NONE)
246 {
247 }
248
249 _CameraCapability::~_CameraCapability(void)
250 {
251         _CameraCoordinator::Release(__device);
252         SysLog(NID_MEDIA, "Destroyed");
253 }
254
255 result
256 _CameraCapability::Construct(_CameraDeviceType cameraDevice)
257 {
258         int err = MM_SUCCESS;
259         result r = E_SUCCESS;
260         _CameraCoordinator* pCameraCoordinator = null;
261         SysLog(NID_MEDIA, "Enter. camera device:%d", cameraDevice);
262
263         pCameraCoordinator = _CameraCoordinator::AddInstance(cameraDevice);
264         r = GetLastResult();
265         SysTryReturn(NID_MEDIA, pCameraCoordinator !=null && r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
266
267         __handle = pCameraCoordinator->GetCameraHandle();
268         __device = cameraDevice;
269
270         err = camera_get_preview_resolution(__handle, &__initPreviewWidth, &__initPreviewHeight);
271         SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the preview resolution error.");
272
273         err = camera_get_capture_resolution(__handle, &__initCaptureWidth, &__initCaptureHeight);
274         SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the capture resolution error.");
275
276         err = camera_get_preview_format(__handle, &__initPreviewFormat);
277         SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the preview format error.");
278
279         err = camera_get_capture_format(__handle, &__initCaptureFormat);
280         SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the capture format error.");
281
282         err = camera_attr_get_flash_mode(__handle, &__initFlashMode);
283         SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the flash mode error.");
284
285         err = camera_attr_get_effect(__handle, &__initEffectMode);
286         SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the effect mode error.");
287
288         err = camera_attr_get_preview_fps(__handle, &__initFps);
289         SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the fps error.");
290
291         err = camera_attr_get_iso(__handle, &__initIsoLevel);
292         SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the iso error.");
293
294         err = camera_attr_get_whitebalance(__handle, &__initWb);
295         SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the white balance.");
296
297         err = camera_attr_get_scene_mode(__handle, &__initSceneMode);
298         SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the scene mode error.");
299
300         err = camera_attr_get_exposure_mode(__handle, &__initMeteringMode);
301         SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the exposure error.");
302
303         err = camera_attr_get_af_mode(__handle, &__initAfMode);
304         SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the AF mode error.");
305
306         return r;
307 }
308
309 void
310 _CameraCapability::InitSafeHashMapInst()
311 {
312         static _CameraCapabilitySafeHashMapT map;
313         result r = E_SUCCESS;
314
315         r = map.Construct();
316         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
317
318         __pMap = &map;
319         return;
320 CATCH:
321         __pMap = null;
322 }
323
324 _CameraCapability*
325 _CameraCapability::AddInstance(_CameraDeviceType cameraDevice)
326 {
327         result r = E_SUCCESS;
328         bool out = false;
329         ClearLastResult();
330
331         _CameraCapability* pCapability = null;
332
333         SysTryReturn(NID_MEDIA, cameraDevice > _CAMERA_DEVICE_NONE && cameraDevice < _CAMERA_DEVICE_MAX,
334                                 null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument. camderDevice:%d.", cameraDevice);
335
336         static pthread_once_t once_block = PTHREAD_ONCE_INIT;
337
338         if (!__pMap)
339         {
340                 pthread_once(&once_block, InitSafeHashMapInst);
341                 r = GetLastResult();
342                 SysTryCatch(NID_MEDIA, __pMap != null, , r, "[%s] Propagating.", GetErrorMessage(r));
343         }
344
345         r = __pMap->ContainsKey(cameraDevice, out);
346         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
347
348         if (out)
349         {
350                 r = __pMap->GetValue(cameraDevice, pCapability);
351                 SysTryCatch(NID_MEDIA, r == E_SUCCESS && pCapability != null, , r, "[%s] Propagating.", GetErrorMessage(r));
352         }
353         else
354         {
355                 pCapability = new (std::nothrow) _CameraCapability();
356                 SysTryCatch(NID_MEDIA, pCapability !=null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
357
358                 r = pCapability->Construct(cameraDevice);
359                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
360
361                 r = __pMap->Add(cameraDevice, pCapability);
362                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
363         }
364
365         pCapability->AddRefCount();
366         return pCapability;
367
368 CATCH:
369         if (pCapability != null)
370         {
371                 delete pCapability;
372         }
373         return null;
374 }
375
376 void
377 _CameraCapability::Release(_CameraDeviceType cameraDevice)
378 {
379         result r = E_SUCCESS;
380
381         if (__pMap != null)
382         {
383                 _CameraCapability* pCameraCapability = null;
384                 r = __pMap->GetValue(cameraDevice, pCameraCapability);
385                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
386
387                 if (pCameraCapability->ReleaseRefCount() == 0)
388                 {
389                         delete pCameraCapability;
390                         r = __pMap->Remove(cameraDevice);
391                         SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
392                 }
393         }
394 }
395
396 Tizen::Base::Collection::ArrayList*
397 _CameraCapability::GetListN(_CameraOperationType key, _ResultType& itemType)
398 {
399         //check key boundary condition
400         SysTryReturn(NID_MEDIA, (key > _COP_NONE && key < _COP_MAX), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument. key :%d", key);
401
402         _CameraDeviceType deviceType = __SERVICE_MAP[key].deviceType;
403         _CameraQueryFunc serviceRoutine = __SERVICE_MAP[key].serviceRoutine;
404
405         //check service handler for a given key
406         SysTryReturn(NID_MEDIA, serviceRoutine != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The query function is not found.");
407
408         std::unique_ptr<ArrayList, _ListPtrUtil::Remover> pList (null, _ListPtrUtil::remover);
409         Object* pObj = serviceRoutine(deviceType, _QUERY_LIST, itemType);
410         switch (itemType)
411         {
412         case _RESULT_INTEGER_LIST:
413                 //fall through
414         case _RESULT_PAIR_INTEGER_LIST:
415                 //fall through
416         case _RESULT_DIMENSION_LIST:
417                 //fall through
418         case _RESULT_DOUBLE_LIST:
419                 //fall through
420         case _RESULT_STRING_LIST:
421         {
422                 pList.reset(dynamic_cast<ArrayList*>(pObj));
423                 SysTryCatch(NID_MEDIA, pList.get() != null, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
424                 SysTryCatch(NID_MEDIA, pList->GetCount() > 0, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Empty data returned for key = [%d]", key);
425                 SysLog(NID_MEDIA, "Valid data returned for key = %d count = %d", key, pList->GetCount());
426         }
427                 break;
428
429         default:
430                 SysLogException(NID_MEDIA, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Supported List is not retrieved. key = [%d]", key);
431                 goto CATCH;
432                 break;
433         }
434         return pList.release();
435
436 CATCH:
437         return null;
438 }
439
440 bool
441 _CameraCapability::IsSupported(_CameraOperationType key)
442 {
443         //check key boundary condition
444         SysTryReturn(NID_MEDIA, (key > _COP_NONE && key < _COP_MAX), false, E_INVALID_ARG, "[E_INVALID_ARG] The key:%d is invalid.", key);
445
446         _CameraDeviceType deviceType = __SERVICE_MAP[key].deviceType;
447         _CameraQueryFunc serviceRoutine = __SERVICE_MAP[key].serviceRoutine;
448         _ResultType itemType = _RESULT_NONE;
449
450         //check service handler for a given key
451         SysTryReturn(NID_MEDIA, serviceRoutine != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
452
453         std::unique_ptr<ArrayList, _ListPtrUtil::Remover> pList (null, _ListPtrUtil::remover);
454         Object* pObj = serviceRoutine(deviceType, _QUERY_LIST, itemType);
455         switch (itemType)
456         {
457         case _RESULT_INTEGER_LIST:
458                 //fall through
459         case _RESULT_DIMENSION_LIST:
460                 //fall through
461         case _RESULT_DOUBLE_LIST:
462                 //fall through
463         case _RESULT_STRING_LIST:
464         {
465                 pList.reset(dynamic_cast<ArrayList*>(pObj));
466                 SysTryCatch(NID_MEDIA, pList.get() != null, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
467                 SysTryCatch(NID_MEDIA, pList->GetCount()>0, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no valid data in key = [%d].", key);
468         }
469                 break;
470
471         case _RESULT_PAIR_INTEGER_LIST:
472         {
473                 pList.reset(dynamic_cast<ArrayList*>(pObj));
474                 SysTryCatch(NID_MEDIA, pList.get() != null, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
475                 {
476                         Integer* pInteger = null;
477                         pInteger = dynamic_cast<Integer*>(pList->GetAt(1));              // Get max value;
478                         SysTryCatch(NID_MEDIA, pInteger != null, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Max value is null for key = [%d].", key);
479                         SysTryCatch(NID_MEDIA, pInteger->ToInt() > 0, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Max value is %d for key = [%d].", pInteger->ToInt(), key);
480                 }
481         }
482                 break;
483
484         default:
485                 SysLogException(NID_MEDIA, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
486                 goto CATCH;
487                 break;
488         }
489         SysLog(NID_MEDIA, "Valid data returned for key = %d count = %d", key, pList->GetCount());
490         return true;
491
492 CATCH:
493         return false;
494 }
495
496 Tizen::Base::Object*
497 _CameraCapability::GetValueN(_CameraOperationType key, _QueryType queryType, _ResultType& itemType)
498 {
499         Tizen::Base::Object* pValue = null;
500
501         //check key boundary condition
502         SysTryReturn(NID_MEDIA, (key > _COP_NONE && key < _COP_MAX), null, E_INVALID_ARG, "[E_INVALID_ARG] The key:%d is invalid.", key);
503         SysTryReturn(NID_MEDIA, (queryType >= _QUERY_DEFAULT_VALUE && queryType < _QUERY_MAX), null, E_INVALID_ARG, "[E_INVALID_ARG] The query:%d is invalid.", queryType);
504
505         _CameraDeviceType deviceType = __SERVICE_MAP[key].deviceType;
506         _CameraQueryFunc serviceRoutine = __SERVICE_MAP[key].serviceRoutine;
507
508         //check service handler for a given key
509         SysTryReturn(NID_MEDIA, serviceRoutine != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The query function is not found.");
510
511         Object* pObj = serviceRoutine(deviceType, queryType, itemType);
512
513         switch (itemType)
514         {
515         case _RESULT_INTEGER:
516         {
517                 pValue = dynamic_cast<Integer*>(pObj);
518                 SysTryReturn(NID_MEDIA, null != pValue, null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
519         }
520                 break;
521
522         case _RESULT_DIMENSION:
523         {
524                 pValue = dynamic_cast<Dimension*>(pObj);
525                 SysTryReturn(NID_MEDIA, null != pValue, null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
526         }
527                 break;
528
529         case _RESULT_INTEGER_LIST:
530                 //fall through
531         case _RESULT_PAIR_INTEGER_LIST:
532                 //fall through
533         case _RESULT_DIMENSION_LIST:
534                 //fall through
535         case _RESULT_DOUBLE_LIST:
536                 //fall through
537         case _RESULT_STRING_LIST:
538                 //fall through
539         default:
540                 SysLogException(NID_MEDIA, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Default value cannot be retrived. key = [%d], itemType:%d", key, itemType);
541                 goto CATCH;
542                 break;
543         }
544         SysLog(NID_MEDIA, "Valid data returned for key = %d", key);
545         return pValue;
546
547 CATCH:
548         return null;
549 }
550
551 _CameraHandle
552 _CameraCapability::GetHandle(void) const
553 {
554         return __handle;
555 }
556
557 _CameraDeviceType
558 _CameraCapability::GetDevice(void) const
559 {
560         return __device;
561 }
562
563 void
564 _CameraCapability::GetInitResolution(AttributeResType opType, int &width, int &height) const
565 {
566         switch (opType)
567         {
568         case ATTR_RES_PREVIEW:
569         {
570                 width = __initPreviewWidth;
571                 height = __initPreviewHeight;
572         }
573                 break;
574
575         case ATTR_RES_CAPTURE:
576         {
577                 width = __initCaptureWidth;
578                 height = __initCaptureHeight;
579         }
580                 break;
581
582         default:
583                 break;
584         }
585 }
586
587 void
588 _CameraCapability::GetInitValue(AttributeType opType, int& mmAttr) const
589 {
590         switch (opType)
591         {
592         case ATTR_PREVIEW_FORMAT:
593         {
594                 mmAttr = __initPreviewFormat;
595         }
596                 break;
597
598         case ATTR_CAPTURE_FORMAT:
599         {
600                 mmAttr = __initCaptureFormat;
601         }
602                 break;
603
604         case ATTR_FLASH_MODE:
605         {
606                 mmAttr = __initFlashMode;
607         }
608                 break;
609
610         case ATTR_EFFECT_MODE:
611         {
612                 mmAttr = __initEffectMode;
613         }
614                 break;
615
616         case ATTR_FPS:
617         {
618                 mmAttr = __initFps;
619         }
620                 break;
621
622         case ATTR_ISO_LEVEL:
623         {
624                 mmAttr = __initIsoLevel;
625         }
626                 break;
627
628         case ATTR_WHITE_BALANCE:
629         {
630                 mmAttr = __initWb;
631         }
632                 break;
633
634         case ATTR_SCENE_MODE:
635         {
636                 mmAttr = __initSceneMode;
637         }
638                 break;
639
640         case ATTR_EXPOSURE_MODE:
641         {
642                 mmAttr = __initMeteringMode;
643         }
644                 break;
645
646         case ATTR_AUTO_FOCUS_MODE:
647         {
648                 mmAttr = __initAfMode;
649         }
650                 break;
651
652         default:
653                 break;
654         }
655 }
656
657 Tizen::Base::Object*
658 _CameraCapability::GetSupportedPreviewResolutionN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
659 {
660         Object* pResolution = null;
661         int err = MM_SUCCESS;
662         result r = E_SUCCESS;
663
664         _CameraCapabilitySession cameraCapbilitySession;
665         r = cameraCapbilitySession.Construct(deviceType);
666         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
667
668         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
669         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
670
671         _CameraHandle cameraHandle = pCapability->GetHandle();
672         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
673
674         if (queryType == _QUERY_LIST)
675         {
676                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pResolutionList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
677                 SysTryReturn(NID_MEDIA, pResolutionList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
678
679                 err = camera_foreach_supported_preview_resolution(cameraHandle, SupportedCameraPreviewResolutionCb, pResolutionList.get());
680                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
681
682                 itemType = _RESULT_DIMENSION_LIST;
683                 pResolution = pResolutionList.release();
684         }
685         else if (queryType == _QUERY_DEFAULT_VALUE)
686         {
687                 int width = 0;
688                 int height = 0;
689                 pCapability->GetInitResolution(_CameraCapability::ATTR_RES_PREVIEW, width, height);
690
691                 std::unique_ptr<Dimension> pDimResolution (new (std::nothrow) Dimension(width, height));
692                 SysTryReturn(NID_MEDIA, pDimResolution.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
693
694                 itemType = _RESULT_DIMENSION;
695                 pResolution = pDimResolution.release();
696         }
697
698         return pResolution;
699 }
700
701 Tizen::Base::Object*
702 _CameraCapability::GetSupportedCaptureResolutionN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
703 {
704         Object* pResolution = null;
705         int err = MM_SUCCESS;
706         result r = E_SUCCESS;
707
708         _CameraCapabilitySession cameraCapbilitySession;
709         r = cameraCapbilitySession.Construct(deviceType);
710         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
711
712         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
713         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
714
715         _CameraHandle cameraHandle = pCapability->GetHandle();
716         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
717
718         if (queryType == _QUERY_LIST)
719         {
720                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pResolutionList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
721                 SysTryReturn(NID_MEDIA, pResolutionList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
722
723                 err = camera_foreach_supported_capture_resolution(cameraHandle, SupportedCameraCaptureResolutionCb, pResolutionList.get());
724                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
725
726                 itemType = _RESULT_DIMENSION_LIST;
727                 pResolution = pResolutionList.release();
728         }
729         else if (queryType == _QUERY_DEFAULT_VALUE)
730         {
731                 int width = 0;
732                 int height = 0;
733                 pCapability->GetInitResolution(_CameraCapability::ATTR_RES_CAPTURE, width, height);
734
735                 std::unique_ptr<Dimension> pDimResolution (new (std::nothrow) Dimension(width, height));
736                 SysTryReturn(NID_MEDIA, pDimResolution.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
737
738                 itemType = _RESULT_DIMENSION;
739                 pResolution = pDimResolution.release();
740         }
741
742         return pResolution;
743 }
744
745 Tizen::Base::Object*
746 _CameraCapability::GetSupportedRecordingResolutionN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
747 {
748         Object* pResolution = null;
749         int err = MM_SUCCESS;
750         result r = E_SUCCESS;
751
752         _CameraCapabilitySession cameraCapbilitySession;
753         r = cameraCapbilitySession.Construct(deviceType);
754         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
755
756         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
757         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
758
759         _CameraHandle cameraHandle = pCapability->GetHandle();
760         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
761
762         if (queryType == _QUERY_LIST)
763         {
764                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pResolutionList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
765                 SysTryReturn(NID_MEDIA, pResolutionList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
766
767                 err = camera_foreach_supported_preview_resolution(cameraHandle, SupportedCameraPreviewResolutionCb, pResolutionList.get());
768                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
769
770                 itemType = _RESULT_DIMENSION_LIST;
771                 pResolution = pResolutionList.release();
772         }
773         else if (queryType == _QUERY_DEFAULT_VALUE)
774         {
775                 int width = 0;
776                 int height = 0;
777                 pCapability->GetInitResolution(_CameraCapability::ATTR_RES_PREVIEW, width, height);
778
779                 std::unique_ptr<Dimension> pDimResolution (new (std::nothrow) Dimension(width, height));
780                 SysTryReturn(NID_MEDIA, pDimResolution.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
781
782                 itemType = _RESULT_DIMENSION;
783                 pResolution = pDimResolution.release();
784         }
785
786         return pResolution;
787 }
788
789 Tizen::Base::Object*
790 _CameraCapability::GetSupportedPreviewFormatN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
791 {
792         Object* pFormat = null;
793         int err = MM_SUCCESS;
794         result r = E_SUCCESS;
795
796         _CameraCapabilitySession cameraCapbilitySession;
797         r = cameraCapbilitySession.Construct(deviceType);
798         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
799
800         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
801         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
802
803         _CameraHandle cameraHandle = pCapability->GetHandle();
804         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
805
806         if (queryType == _QUERY_LIST)
807         {
808 //from here
809                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pFormatList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
810                 SysTryReturn(NID_MEDIA, pFormatList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
811
812                 err = camera_foreach_supported_preview_format(cameraHandle, SupportedCameraPreviewFormatCb, pFormatList.get());
813                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
814
815                 itemType = _RESULT_INTEGER_LIST;
816                 pFormat = pFormatList.release();
817         }
818         else if (queryType == _QUERY_DEFAULT_VALUE)
819         {
820                 PixelFormat value = PIXEL_FORMAT_YCbCr420_PLANAR;
821
822 // Camera's PowerOn should be called to initialize the default value with capability's return value.
823                 result r = E_SUCCESS;
824                 int mmAttr = ::CAMERA_PIXEL_FORMAT_INVALID;
825                 pCapability->GetInitValue(_CameraCapability::ATTR_PREVIEW_FORMAT, mmAttr);
826
827                 r = _CameraUtil::GetOspGrpPixelFormat((camera_pixel_format_e)mmAttr, value);
828                 //SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
829                 //This is temporary code because PIXEL_FORMAT_YUYV is not in the Graphics's PIXEL_FORMAT list.
830                 if (r  != E_SUCCESS)
831                 {
832                         value = PIXEL_FORMAT_YCbCr420_PLANAR;
833                         SysLog(NID_MEDIA, "YCbCr420 will be used instead of device default value.");
834                 }
835
836                 std::unique_ptr<Integer> pFormatValue (new (std::nothrow) Integer((int)value));
837                 SysTryReturn(NID_MEDIA, pFormatValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
838
839                 itemType = _RESULT_INTEGER;
840                 pFormat = pFormatValue.release();
841         }
842
843         return pFormat;
844 }
845
846 Tizen::Base::Object*
847 _CameraCapability::GetSupportedCaptureFormatN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
848 {
849         Object* pFormat = null;
850         int err = MM_SUCCESS;
851         result r = E_SUCCESS;
852
853         _CameraCapabilitySession cameraCapbilitySession;
854         r = cameraCapbilitySession.Construct(deviceType);
855         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
856
857         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
858         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
859
860         _CameraHandle cameraHandle = pCapability->GetHandle();
861         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
862
863         if (queryType == _QUERY_LIST)
864         {
865                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pFormatList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
866                 SysTryReturn(NID_MEDIA, pFormatList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
867
868                 err = camera_foreach_supported_capture_format(cameraHandle, SupportedCameraCaptureFormatCb, pFormatList.get());
869                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
870
871                 itemType = _RESULT_INTEGER_LIST;
872                 pFormat = pFormatList.release();
873         }
874         else if (queryType == _QUERY_DEFAULT_VALUE)
875         {
876                 PixelFormat value = PIXEL_FORMAT_JPEG;
877
878 // This means that the real device's default value is different from the capability's return value.
879 // Camera's PowerOn should be called to initialize the default value with capability's return value.
880 //              result r = E_SUCCESS;
881 //              int mmAttr = ::CAMERA_PIXEL_FORMAT_INVALID;
882 //              pCapability->GetInitValue(_CameraCapability::ATTR_CAPTURE_FORMAT, mmAttr);
883 //
884 //              r = _CameraUtil::GetOspGrpPixelFormat((camera_pixel_format_e)mmAttr, value);
885 //              SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
886
887                 std::unique_ptr<Integer> pFormatValue (new (std::nothrow) Integer((int)value));
888                 SysTryReturn(NID_MEDIA, pFormatValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
889
890                 itemType = _RESULT_INTEGER;
891                 pFormat = pFormatValue.release();
892         }
893
894         return pFormat;
895 }
896
897 Tizen::Base::Object*
898 _CameraCapability::GetSupportedFlashModeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
899 {
900         Object* pFlash = null;
901         int err = MM_SUCCESS;
902         result r = E_SUCCESS;
903
904         _CameraCapabilitySession cameraCapbilitySession;
905         r = cameraCapbilitySession.Construct(deviceType);
906         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
907
908         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
909         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
910
911         _CameraHandle cameraHandle = pCapability->GetHandle();
912         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
913
914         if (queryType == _QUERY_LIST)
915         {
916                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pFlashList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
917                 SysTryReturn(NID_MEDIA, pFlashList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
918
919                 err = camera_attr_foreach_supported_flash_mode(cameraHandle, SupportedCameraAttrFlashModeCb, pFlashList.get());
920                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
921
922                 itemType = _RESULT_INTEGER_LIST;
923                 pFlash = pFlashList.release();
924         }
925         else if (queryType == _QUERY_DEFAULT_VALUE)
926         {
927                 int mmAttr = ::CAMERA_ATTR_FLASH_MODE_OFF;
928                 CameraFlashMode value = CAMERA_FLASH_MODE_OFF;
929
930                 pCapability->GetInitValue(_CameraCapability::ATTR_FLASH_MODE, mmAttr);
931                 r = _CameraUtil::GetOspFlashMode((camera_attr_flash_mode_e)mmAttr, value);
932                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
933
934                 std::unique_ptr<Integer> pFlashValue (new (std::nothrow) Integer((int)value));
935                 SysTryReturn(NID_MEDIA, pFlashValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
936
937                 itemType = _RESULT_INTEGER;
938                 pFlash = pFlashValue.release();
939         }
940
941         return pFlash;
942 }
943
944 Tizen::Base::Object*
945 _CameraCapability::GetSupportedEffectTypeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
946 {
947         Object* pEffect = null;
948         int err = MM_SUCCESS;
949         result r = E_SUCCESS;
950
951         _CameraCapabilitySession cameraCapbilitySession;
952         r = cameraCapbilitySession.Construct(deviceType);
953         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
954
955         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
956         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
957
958         _CameraHandle cameraHandle = pCapability->GetHandle();
959         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
960
961         if (queryType == _QUERY_LIST)
962         {
963                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pEffectList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
964                 SysTryReturn(NID_MEDIA, pEffectList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
965
966                 err = camera_attr_foreach_supported_effect(cameraHandle, SupportedCameraAttrEffectCb, pEffectList.get());
967                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
968
969                 // In the case of including only NONE effect, delete the NONE capability for the application's usability.
970                 if (pEffectList->GetCount() == 1)
971                 {
972                         Integer* pInteger = null;
973                         pInteger = dynamic_cast<Integer*>(pEffectList->GetAt(0));
974                         SysTryReturn(NID_MEDIA, pInteger != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Integer instance is not available.");
975
976                         if (pInteger->ToInt() == (int)CAMERA_EFFECT_NONE)
977                         {
978                                 pEffectList->RemoveAll(true);
979                         }
980                 }
981                 itemType = _RESULT_INTEGER_LIST;
982                 pEffect = pEffectList.release();
983         }
984         else if (queryType == _QUERY_DEFAULT_VALUE)
985         {
986                 int mmAttr = ::CAMERA_ATTR_EFFECT_NONE;
987                 CameraEffect value = CAMERA_EFFECT_NONE;
988
989                 pCapability->GetInitValue(_CameraCapability::ATTR_EFFECT_MODE, mmAttr);
990                 r = _CameraUtil::GetOspEffect((camera_attr_effect_mode_e)mmAttr, value);
991                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
992
993                 std::unique_ptr<Integer> pEffectValue (new (std::nothrow) Integer((int)value));
994                 SysTryReturn(NID_MEDIA, pEffectValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
995
996                 itemType = _RESULT_INTEGER;
997                 pEffect = pEffectValue.release();
998         }
999
1000         return pEffect;
1001 }
1002
1003
1004 Tizen::Base::Object*
1005 _CameraCapability::GetSupportedPreviewFrameRateN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1006 {
1007         Object* pFps = null;
1008         int err = MM_SUCCESS;
1009         result r = E_SUCCESS;
1010
1011         _CameraCapabilitySession cameraCapbilitySession;
1012         r = cameraCapbilitySession.Construct(deviceType);
1013         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1014
1015         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
1016         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
1017
1018         _CameraHandle cameraHandle = pCapability->GetHandle();
1019         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
1020
1021         if (queryType == _QUERY_LIST)
1022         {
1023                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pFpsList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
1024                 SysTryReturn(NID_MEDIA, pFpsList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1025
1026                 err = camera_attr_foreach_supported_fps(cameraHandle, SupportedCameraAttrFpsCb, pFpsList.get());
1027                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
1028
1029                 itemType = _RESULT_INTEGER_LIST;
1030                 pFps = pFpsList.release();
1031         }
1032         else if (queryType == _QUERY_DEFAULT_VALUE)
1033         {
1034                 int mmAttr = ::CAMERA_ATTR_FPS_AUTO;
1035                 int value = 0;
1036
1037                 pCapability->GetInitValue(_CameraCapability::ATTR_FPS, mmAttr);
1038                 r = _CameraUtil::GetOspFps((camera_attr_fps_e)mmAttr, value);
1039                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1040
1041                 std::unique_ptr<Integer> pFpsValue (new (std::nothrow) Integer((int)value));
1042                 SysTryReturn(NID_MEDIA, pFpsValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1043
1044                 itemType = _RESULT_INTEGER;
1045                 pFps = pFpsValue.release();
1046         }
1047
1048         return pFps;
1049 }
1050
1051 Tizen::Base::Object*
1052 _CameraCapability::GetSupportedPreviewFrameRateN(_CameraDeviceType deviceType, _QueryType queryType, const Tizen::Graphics::Dimension &dim, _ResultType& itemType)
1053 {
1054         SysLog(NID_MEDIA, "Dim's width : %d, height : %d", dim.width, dim.height);
1055         return GetSupportedPreviewFrameRateN(deviceType, queryType, itemType);
1056 }
1057
1058
1059 Tizen::Base::Object*
1060 _CameraCapability::GetSupportedMaxRecordingFrameRateN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1061 {
1062         SysLog(NID_MEDIA, "_QueryType is : %d, will be ignored", queryType);
1063
1064         Object* pPreviewObj = GetSupportedPreviewFrameRateN(deviceType, _QUERY_LIST, itemType);
1065         SysTryReturn(NID_MEDIA, pPreviewObj != null, null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Preview is not supported.");
1066
1067         std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pFpsList (dynamic_cast<_MediaSafeArrayList*>(pPreviewObj), _ListPtrUtil::remover);
1068         SysTryReturn(NID_MEDIA, pFpsList.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  List is wrong.");
1069
1070         //the last time of the list shall be the maximum value of the fps
1071
1072         int count = pFpsList->GetCount();
1073         SysTryReturn(NID_MEDIA, count > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  List is wrong.");
1074
1075         Integer* pItemObj = (Integer*) (pFpsList->GetAt(count - 1));
1076         itemType = _RESULT_INTEGER;
1077
1078         std::unique_ptr<Integer> pIntegerObj (new (std::nothrow) Integer(*pItemObj));
1079         SysTryReturn(NID_MEDIA, pIntegerObj.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  out of memory");
1080
1081         return pIntegerObj.release();
1082 }
1083
1084
1085 Tizen::Base::Object*
1086 _CameraCapability::GetSupportedIsoLevelN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1087 {
1088         Object* pIsoLevel = null;
1089         int err = MM_SUCCESS;
1090         result r = E_SUCCESS;
1091
1092         _CameraCapabilitySession cameraCapbilitySession;
1093         r = cameraCapbilitySession.Construct(deviceType);
1094         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1095
1096         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
1097         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
1098
1099         _CameraHandle cameraHandle = pCapability->GetHandle();
1100         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
1101
1102         if (queryType == _QUERY_LIST)
1103         {
1104                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pIsoLevelList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
1105                 SysTryReturn(NID_MEDIA, pIsoLevelList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1106
1107                 err = camera_attr_foreach_supported_iso(cameraHandle, SupportedCameraAttrIsoCb, pIsoLevelList.get());
1108                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
1109
1110                 // In the case of including only NONE IsoLevel, delete the NONE capability for the application's usability.
1111                 if (pIsoLevelList->GetCount() == 1)
1112                 {
1113                         Integer* pInteger = null;
1114                         pInteger = dynamic_cast<Integer*>(pIsoLevelList->GetAt(0));
1115                         SysTryReturn(NID_MEDIA, pInteger != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Integer instance is not available. (0) item is not found.");
1116
1117                         if (pInteger->ToInt() == (int)CAMERA_ISO_AUTO)
1118                         {
1119                                 pIsoLevelList->RemoveAll(true);
1120                         }
1121                 }
1122                 itemType = _RESULT_INTEGER_LIST;
1123                 pIsoLevel = pIsoLevelList.release();
1124         }
1125         else if (queryType == _QUERY_DEFAULT_VALUE)
1126         {
1127                 int mmAttr = ::CAMERA_ATTR_ISO_AUTO;
1128                 CameraIsoLevel value = CAMERA_ISO_AUTO;
1129
1130                 pCapability->GetInitValue(_CameraCapability::ATTR_ISO_LEVEL, mmAttr);
1131                 r = _CameraUtil::GetOspIso((camera_attr_iso_e)mmAttr, value);
1132                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1133
1134                 std::unique_ptr<Integer> pIsoLevelValue (new (std::nothrow) Integer((int)value));
1135                 SysTryReturn(NID_MEDIA, pIsoLevelValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1136
1137                 itemType = _RESULT_INTEGER;
1138                 pIsoLevel = pIsoLevelValue.release();
1139         }
1140
1141         return pIsoLevel;
1142 }
1143
1144 Tizen::Base::Object*
1145 _CameraCapability::GetSupportedWhiteBalanceN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1146 {
1147         Object* pWb = null;
1148         int err = MM_SUCCESS;
1149         result r = E_SUCCESS;
1150
1151         _CameraCapabilitySession cameraCapbilitySession;
1152         r = cameraCapbilitySession.Construct(deviceType);
1153         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1154
1155         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
1156         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
1157
1158         _CameraHandle cameraHandle = pCapability->GetHandle();
1159         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
1160
1161         if (queryType == _QUERY_LIST)
1162         {
1163                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pWbList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
1164                 SysTryReturn(NID_MEDIA, pWbList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1165
1166                 err = camera_attr_foreach_supported_whitebalance(cameraHandle, SupportedCameraAttrWhitebalanceCb, pWbList.get());
1167                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
1168
1169                 itemType = _RESULT_INTEGER_LIST;
1170                 pWb = pWbList.release();
1171         }
1172         else if (queryType == _QUERY_DEFAULT_VALUE)
1173         {
1174                 int mmAttr = ::CAMERA_ATTR_WHITE_BALANCE_NONE;
1175                 CameraWhiteBalance value = CAMERA_WHITE_BALANCE_AUTO;
1176
1177                 pCapability->GetInitValue(_CameraCapability::ATTR_WHITE_BALANCE, mmAttr);
1178                 r = _CameraUtil::GetOspWhiteBalance((camera_attr_whitebalance_e)mmAttr, value);
1179                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1180
1181                 std::unique_ptr<Integer> pWbValue (new (std::nothrow) Integer((int)value));
1182                 SysTryReturn(NID_MEDIA, pWbValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1183
1184                 itemType = _RESULT_INTEGER;
1185                 pWb = pWbValue.release();
1186         }
1187
1188         return pWb;
1189 }
1190
1191 // This feature is not implemented. It will be implemented based on the request.
1192 Tizen::Base::Object*
1193 _CameraCapability::GetSupportedShutterSpeedN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1194 {
1195         SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
1196         return null;
1197 }
1198
1199 Tizen::Base::Object*
1200 _CameraCapability::GetSupportedSceneN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1201 {
1202         Object* pScene = null;
1203         int err = MM_SUCCESS;
1204         result r = E_SUCCESS;
1205
1206         _CameraCapabilitySession cameraCapbilitySession;
1207         r = cameraCapbilitySession.Construct(deviceType);
1208         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1209
1210         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
1211         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
1212
1213         _CameraHandle cameraHandle = pCapability->GetHandle();
1214         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
1215
1216         if (queryType == _QUERY_LIST)
1217         {
1218                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pSceneList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
1219                 SysTryReturn(NID_MEDIA, pSceneList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1220
1221                 err = camera_attr_foreach_supported_scene_mode(cameraHandle, SupportedCameraAttrSceneModeCb, pSceneList.get());
1222                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
1223
1224                 itemType = _RESULT_INTEGER_LIST;
1225                 pScene = pSceneList.release();
1226         }
1227         else if (queryType == _QUERY_DEFAULT_VALUE)
1228         {
1229                 int mmAttr = ::CAMERA_ATTR_SCENE_MODE_NORMAL;
1230                 _CameraSceneMode value = CAMERA_SCENE_NONE;
1231
1232                 pCapability->GetInitValue(_CameraCapability::ATTR_SCENE_MODE, mmAttr);
1233                 r = _CameraUtil::GetOspScene((camera_attr_scene_mode_e)mmAttr, value);
1234                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1235
1236                 std::unique_ptr<Integer> pSceneValue (new (std::nothrow) Integer((int)value));
1237                 SysTryReturn(NID_MEDIA, pSceneValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1238
1239                 itemType = _RESULT_INTEGER;
1240                 pScene = pSceneValue.release();
1241         }
1242
1243         return pScene;
1244 }
1245
1246 // This feature is not implemented. It will be implemented based on the request.
1247 Tizen::Base::Object*
1248 _CameraCapability::GetSupportedMeteringN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1249 {
1250         SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
1251         return null;
1252 }
1253
1254
1255 // This feature is not implemented. It will be implemented based on the request.
1256 Tizen::Base::Object*
1257 _CameraCapability::GetSupportedApertureN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1258 {
1259         SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
1260         return null;
1261 }
1262
1263 Tizen::Base::Object*
1264 _CameraCapability::GetSupportedExposureN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1265 {
1266         Object* pExposure = null;
1267         int err = MM_SUCCESS;
1268         result r = E_SUCCESS;
1269
1270         _CameraCapabilitySession cameraCapbilitySession;
1271         r = cameraCapbilitySession.Construct(deviceType);
1272         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1273
1274         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
1275         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
1276
1277         _CameraHandle cameraHandle = pCapability->GetHandle();
1278         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
1279
1280         if (queryType == _QUERY_LIST)
1281         {
1282                 int mmMin = 0;
1283                 int mmMax = 0;
1284
1285                 err = camera_attr_get_exposure_range(cameraHandle, &mmMin, &mmMax);
1286                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
1287                 SysTryReturn(NID_MEDIA, mmMax - mmMin > 0, null, E_UNSUPPORTED_OPERATION,
1288                         "[E_UNSUPPORTED_OPERATION] This operation is not supported");
1289
1290                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pExposureList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
1291                 SysTryReturn(NID_MEDIA, pExposureList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1292
1293                 std::unique_ptr<Object> pMin (new (std::nothrow) Integer(0));
1294                 SysTryReturn(NID_MEDIA, pMin.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1295
1296                 r = pExposureList->AddPtr(std::move(pMin));
1297                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1298
1299                 std::unique_ptr<Object> pMax (new (std::nothrow) Integer(9));
1300                 SysTryReturn(NID_MEDIA, pMax.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1301
1302                 r = pExposureList->AddPtr(std::move(pMax));
1303                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1304
1305                 itemType = _RESULT_PAIR_INTEGER_LIST;
1306                 pExposure = pExposureList.release();
1307         }
1308         else if (queryType == _QUERY_DEFAULT_VALUE)
1309         {
1310                 std::unique_ptr<Integer> pExposureValue (new (std::nothrow) Integer(5));
1311                 SysTryReturn(NID_MEDIA, pExposureValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1312
1313                 itemType = _RESULT_INTEGER;
1314                 pExposure = pExposureValue.release();
1315         }
1316
1317         return pExposure;
1318 }
1319
1320 Tizen::Base::Object*
1321 _CameraCapability::GetSupportedMeteringModeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1322 {
1323         Object* pMeteringMode = null;
1324         int err = MM_SUCCESS;
1325         result r = E_SUCCESS;
1326
1327         _CameraCapabilitySession cameraCapbilitySession;
1328         r = cameraCapbilitySession.Construct(deviceType);
1329         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1330
1331         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
1332         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
1333
1334         _CameraHandle cameraHandle = pCapability->GetHandle();
1335         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
1336
1337         if (queryType == _QUERY_LIST)
1338         {
1339                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pMeteringModeList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
1340                 SysTryReturn(NID_MEDIA, pMeteringModeList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] out of memory");
1341
1342                 err = camera_attr_foreach_supported_exposure_mode(cameraHandle, SupportedCameraAttrMeteringModeCb, pMeteringModeList.get());
1343                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
1344
1345                 itemType = _RESULT_INTEGER_LIST;
1346                 pMeteringMode = pMeteringModeList.release();
1347         }
1348         else if (queryType == _QUERY_DEFAULT_VALUE)
1349         {
1350                 int mmAttr = ::CAMERA_ATTR_EXPOSURE_MODE_OFF;
1351                 CameraMeteringMode value = CAMERA_METERING_MODE_NONE;
1352
1353                 pCapability->GetInitValue(_CameraCapability::ATTR_EXPOSURE_MODE, mmAttr);
1354                 r = _CameraUtil::GetOspMeteringMode((camera_attr_exposure_mode_e)mmAttr, value);
1355                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1356
1357                 std::unique_ptr<Integer> pMeteringModeValue (new (std::nothrow) Integer((int)value));
1358                 SysTryReturn(NID_MEDIA, pMeteringModeValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] out of memory");
1359
1360                 itemType = _RESULT_INTEGER;
1361                 pMeteringMode = pMeteringModeValue.release();
1362         }
1363
1364         return pMeteringMode;
1365 }
1366
1367 Tizen::Base::Object*
1368 _CameraCapability::GetSupportedFocusModeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1369 {
1370         Object* pAutoFocus = null;
1371         int err = MM_SUCCESS;
1372         result r = E_SUCCESS;
1373
1374         _CameraCapabilitySession cameraCapbilitySession;
1375         r = cameraCapbilitySession.Construct(deviceType);
1376         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1377
1378         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
1379         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
1380
1381         _CameraHandle cameraHandle = pCapability->GetHandle();
1382         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
1383
1384         if (queryType == _QUERY_LIST)
1385         {
1386                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pAutoFocusRangeList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
1387                 SysTryReturn(NID_MEDIA, pAutoFocusRangeList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1388
1389                 err = camera_attr_foreach_supported_af_mode(cameraHandle, SupportedCameraAttrAfModeCb, pAutoFocusRangeList.get());
1390                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
1391
1392                 itemType = _RESULT_INTEGER_LIST;
1393                 pAutoFocus = pAutoFocusRangeList.release();
1394         }
1395         else if (queryType == _QUERY_DEFAULT_VALUE)
1396         {
1397                 int mmAttr = ::CAMERA_ATTR_AF_NONE;
1398                 CameraFocusMode value = CAMERA_FOCUS_MODE_NONE;
1399
1400                 pCapability->GetInitValue(_CameraCapability::ATTR_AUTO_FOCUS_MODE, mmAttr);
1401                 r = _CameraUtil::GetOspFocusMode((camera_attr_af_mode_e)mmAttr, value);
1402                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1403
1404                 std::unique_ptr<Integer> pAutoFocusRange (new (std::nothrow) Integer((int)value));
1405                 SysTryReturn(NID_MEDIA, pAutoFocusRange.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1406
1407                 itemType = _RESULT_INTEGER;
1408                 pAutoFocus = pAutoFocusRange.release();
1409         }
1410
1411         return pAutoFocus;
1412 }
1413
1414 Tizen::Base::Object*
1415 _CameraCapability::GetSupportedZoomTypeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1416 {
1417         SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
1418         return null;
1419 }
1420
1421 Tizen::Base::Object*
1422 _CameraCapability::GetSupportedFlipTypeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1423 {
1424         SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
1425         return null;
1426 }
1427
1428 Tizen::Base::Object*
1429 _CameraCapability::GetSupportedPreviewRotationN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1430 {
1431         SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
1432         return null;
1433 }
1434
1435 Tizen::Base::Object*
1436 _CameraCapability::GetZeroShutterLagN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1437 {
1438         Object* pZeroShutterLag = null;
1439         result r = E_SUCCESS;
1440
1441         _CameraCapabilitySession cameraCapbilitySession;
1442         r = cameraCapbilitySession.Construct(deviceType);
1443         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1444
1445         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
1446         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
1447
1448         _CameraHandle cameraHandle = pCapability->GetHandle();
1449         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
1450
1451         if (queryType == _QUERY_LIST)
1452         {
1453                 SysLogException(NID_MEDIA, E_INVALID_ARG, "[E_INVALID_ARG] This key doesn't give the list.");
1454                 itemType = _RESULT_NONE;
1455                 pZeroShutterLag = null;
1456         }
1457         else if (queryType == _QUERY_DEFAULT_VALUE)
1458         {
1459                 bool supported = false;
1460                 supported = camera_is_supported_zero_shutter_lag(cameraHandle);
1461
1462                 std::unique_ptr<Integer> pInteger (new (std::nothrow) Integer((int)supported));
1463                 SysTryReturn(NID_MEDIA, pInteger.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] out of memory");
1464
1465                 itemType = _RESULT_INTEGER;
1466                 pZeroShutterLag = pInteger.release();
1467         }
1468
1469         return pZeroShutterLag;
1470 }
1471
1472 Tizen::Base::Object*
1473 _CameraCapability::GetSupportedContrastN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1474 {
1475         Object* pContrast = null;
1476         int err = MM_SUCCESS;
1477         result r = E_SUCCESS;
1478
1479         _CameraCapabilitySession cameraCapbilitySession;
1480         r = cameraCapbilitySession.Construct(deviceType);
1481         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1482
1483         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
1484         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
1485
1486         _CameraHandle cameraHandle = pCapability->GetHandle();
1487         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
1488
1489         if (queryType == _QUERY_LIST)
1490         {
1491                 int mmMin = 0;
1492                 int mmMax = 0;
1493
1494                 err = camera_attr_get_contrast_range(cameraHandle, &mmMin, &mmMax);
1495                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
1496                 SysTryReturn(NID_MEDIA, mmMax - mmMin > 0, null, E_UNSUPPORTED_OPERATION,
1497                         "[E_UNSUPPORTED_OPERATION] This operation is not supported");
1498
1499                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pContrastList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
1500                 SysTryReturn(NID_MEDIA, pContrastList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1501
1502                 std::unique_ptr<Object> pMin (new (std::nothrow) Integer(0));
1503                 SysTryReturn(NID_MEDIA, pMin.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1504
1505                 r = pContrastList->AddPtr(std::move(pMin));
1506                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1507
1508                 std::unique_ptr<Object> pMax (new (std::nothrow) Integer(9));
1509                 SysTryReturn(NID_MEDIA, pMax.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1510
1511                 r = pContrastList->AddPtr(std::move(pMax));
1512                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1513
1514                 itemType = _RESULT_PAIR_INTEGER_LIST;
1515                 pContrast = pContrastList.release();
1516         }
1517         else if (queryType == _QUERY_DEFAULT_VALUE)
1518         {
1519                 std::unique_ptr<Integer> pContrastValue (new (std::nothrow) Integer(5));
1520                 SysTryReturn(NID_MEDIA, pContrastValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1521
1522                 itemType = _RESULT_INTEGER;
1523                 pContrast = pContrastValue.release();
1524         }
1525
1526         return pContrast;
1527 }
1528
1529 Tizen::Base::Object*
1530 _CameraCapability::GetSupportedBrightnessN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1531 {
1532         Object* pBrightness = null;
1533         int err = MM_SUCCESS;
1534         result r = E_SUCCESS;
1535
1536         _CameraCapabilitySession cameraCapbilitySession;
1537         r = cameraCapbilitySession.Construct(deviceType);
1538         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1539
1540         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
1541         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
1542
1543         _CameraHandle cameraHandle = pCapability->GetHandle();
1544         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
1545
1546         if (queryType == _QUERY_LIST)
1547         {
1548                 int mmMin = 0;
1549                 int mmMax = 0;
1550
1551                 err = camera_attr_get_brightness_range(cameraHandle, &mmMin, &mmMax);
1552                 SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
1553                 SysTryReturn(NID_MEDIA, mmMax - mmMin > 0, null, E_UNSUPPORTED_OPERATION,
1554                         "[E_UNSUPPORTED_OPERATION] This operation is not supported");
1555
1556                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pBrightnessList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
1557                 SysTryReturn(NID_MEDIA, pBrightnessList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1558
1559                 std::unique_ptr<Object> pMin (new (std::nothrow) Integer(0));
1560                 SysTryReturn(NID_MEDIA, pMin.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1561
1562                 r = pBrightnessList->AddPtr(std::move(pMin));
1563                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1564
1565                 std::unique_ptr<Object> pMax (new (std::nothrow) Integer(9));
1566                 SysTryReturn(NID_MEDIA, pMax.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1567
1568                 r = pBrightnessList->AddPtr(std::move(pMax));
1569                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1570
1571                 itemType = _RESULT_PAIR_INTEGER_LIST;
1572                 pBrightness = pBrightnessList.release();
1573         }
1574         else if (queryType == _QUERY_DEFAULT_VALUE)
1575         {
1576                 std::unique_ptr<Integer> pBrightnessValue (new (std::nothrow) Integer(5));
1577                 SysTryReturn(NID_MEDIA, pBrightnessValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1578
1579                 itemType = _RESULT_INTEGER;
1580                 pBrightness = pBrightnessValue.release();
1581         }
1582
1583         return pBrightness;
1584 }
1585
1586 Tizen::Base::Object*
1587 _CameraCapability::GetSupportedZoomLevelN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1588 {
1589         Object* pZoom = null;
1590         int err = MM_SUCCESS;
1591         int mmMin = 0;
1592         int mmMax = 0;
1593         result r = E_SUCCESS;
1594
1595         _CameraCapabilitySession cameraCapbilitySession;
1596         r = cameraCapbilitySession.Construct(deviceType);
1597         SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1598
1599         _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
1600         SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
1601
1602         _CameraHandle cameraHandle = pCapability->GetHandle();
1603         SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
1604
1605         err = camera_attr_get_zoom_range(cameraHandle, &mmMin, &mmMax);
1606         SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
1607         SysTryReturn(NID_MEDIA, mmMax - mmMin > 0, null, E_UNSUPPORTED_OPERATION,
1608                 "[E_UNSUPPORTED_OPERATION] This operation is not supported");
1609
1610         if (queryType == _QUERY_LIST)
1611         {
1612                 std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pZoomList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
1613                 SysTryReturn(NID_MEDIA, pZoomList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1614
1615                 std::unique_ptr<Object> pMin (new (std::nothrow) Integer(mmMin));
1616                 SysTryReturn(NID_MEDIA, pMin.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1617
1618                 r = pZoomList->AddPtr(std::move(pMin));
1619                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1620
1621                 std::unique_ptr<Object> pMax (new (std::nothrow) Integer(mmMax));
1622                 SysTryReturn(NID_MEDIA, pMax.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1623
1624                 r = pZoomList->AddPtr(std::move(pMax));
1625                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1626
1627                 itemType = _RESULT_PAIR_INTEGER_LIST;
1628                 pZoom = pZoomList.release();
1629         }
1630         else if (queryType == _QUERY_DEFAULT_VALUE)
1631         {
1632                 std::unique_ptr<Integer> pZoomValue (new (std::nothrow) Integer(mmMin));
1633                 SysTryReturn(NID_MEDIA, pZoomValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1634
1635                 itemType = _RESULT_INTEGER;
1636                 pZoom = pZoomValue.release();
1637         }
1638
1639         return pZoom;
1640 }
1641
1642 Tizen::Base::Object*
1643 _CameraCapability::GetDirectionN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1644 {
1645         SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
1646         return null;
1647 }
1648
1649 // Camera direction
1650 Tizen::Base::Object*
1651 _CameraCapability::GetPhysicalRotationN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
1652 {
1653         SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
1654         return null;
1655 }
1656
1657 bool
1658 _CameraCapability::SupportedCameraPreviewResolutionCb(int width, int height, void* pUserData)
1659 {
1660         result r = E_SUCCESS;
1661
1662 //In Redwood Target, If both width and height are lager than 1088, Video Recordingis not  supported because of MFC limmitation.
1663         if (width >= 1088 && height >= 1088)
1664         {
1665                 return true;
1666         }
1667 //If Preview resolution ratio is not same Capture resolution ratio, Capture do not performed because of camera hw module's limmitation in RedWood target.
1668         if ((width == 176 && height == 144) || (width == 1280 && height == 720))
1669         {
1670                 return true;
1671         }
1672
1673         _MediaSafeArrayList* pResolutionList = static_cast<_MediaSafeArrayList*>(pUserData);
1674         SysTryReturn(NID_MEDIA, pResolutionList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
1675
1676         std::unique_ptr<Object> pDim (new (std::nothrow) Dimension(width, height));
1677         SysTryReturn(NID_MEDIA, pDim.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1678
1679         r = pResolutionList->AddPtr(std::move(pDim));
1680         SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1681         return true;
1682 }
1683
1684 bool
1685 _CameraCapability::SupportedCameraCaptureResolutionCb(int width, int height, void* pUserData)
1686 {
1687         result r = E_SUCCESS;
1688
1689 // This means that 1080 HD resolution capture is not supported.
1690 // In Redwood Target, 1392X1392 Resolution is not  supported because of MFC limmitation.
1691         if ((height == 1080) || (width == 1392 && height == 1392))
1692         {
1693                 return true;
1694         }
1695
1696         _MediaSafeArrayList* pResolutionList = static_cast<_MediaSafeArrayList*>(pUserData);
1697         SysTryReturn(NID_MEDIA, pResolutionList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
1698
1699         std::unique_ptr<Object> pDim (new (std::nothrow) Dimension(width, height));
1700         SysTryReturn(NID_MEDIA, pDim.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1701
1702         r = pResolutionList->AddPtr(std::move(pDim));
1703         SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1704
1705         return true;
1706 }
1707
1708 bool
1709 _CameraCapability::SupportedCameraPreviewFormatCb(camera_pixel_format_e format, void *pUserData)
1710 {
1711         result r = E_SUCCESS;
1712         Tizen::Graphics::PixelFormat previewPixelValue = (Tizen::Graphics::PixelFormat)MEDIA_INVALID_VALUE;
1713
1714         _MediaSafeArrayList* pFormatList = static_cast<_MediaSafeArrayList*>(pUserData);
1715         SysTryReturn(NID_MEDIA, pFormatList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
1716
1717         r = _CameraUtil::GetOspGrpPixelFormat(format, previewPixelValue);
1718         if (r == E_SUCCESS)
1719         {
1720                 std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(previewPixelValue));
1721                 SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1722
1723                 r = pFormatList->AddPtr(std::move(pInteger));
1724                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1725         }
1726         return true;
1727 }
1728
1729 bool
1730 _CameraCapability::SupportedCameraCaptureFormatCb(camera_pixel_format_e format, void *pUserData)
1731 {
1732         result r = E_SUCCESS;
1733         Tizen::Graphics::PixelFormat capturePixelValue = (Tizen::Graphics::PixelFormat)MEDIA_INVALID_VALUE;
1734
1735 // This means that the raw format capture is not supported yet.
1736         if ( format == ::CAMERA_PIXEL_FORMAT_I420 || format == ::CAMERA_PIXEL_FORMAT_YUYV )
1737         {
1738                 return true;
1739         }
1740
1741         _MediaSafeArrayList* pFormatList = static_cast<_MediaSafeArrayList*>(pUserData);
1742         SysTryReturn(NID_MEDIA, pFormatList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
1743
1744         r = _CameraUtil::GetOspGrpPixelFormat(format, capturePixelValue);
1745         if (r == E_SUCCESS)
1746         {
1747                 std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(capturePixelValue));
1748                 SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1749
1750                 r = pFormatList->AddPtr(std::move(pInteger));
1751                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1752         }
1753         return true;
1754 }
1755
1756 bool
1757 _CameraCapability::SupportedCameraAttrFlashModeCb(camera_attr_flash_mode_e mode, void *pUserData)
1758 {
1759         result r = E_SUCCESS;
1760         CameraFlashMode flashMode = (CameraFlashMode)MEDIA_INVALID_VALUE;
1761
1762 // This means that the flash-off mode is not included to the supported list.
1763         if ( mode == ::CAMERA_ATTR_FLASH_MODE_OFF )
1764         {
1765                 return true;
1766         }
1767
1768         _MediaSafeArrayList* pFlashList = static_cast<_MediaSafeArrayList*>(pUserData);
1769         SysTryReturn(NID_MEDIA, pFlashList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
1770
1771         r = _CameraUtil::GetOspFlashMode(mode, flashMode);
1772         if (r == E_SUCCESS)
1773         {
1774                 std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(flashMode));
1775                 SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1776
1777                 r = pFlashList->AddPtr(std::move(pInteger));
1778                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1779         }
1780
1781         return true;
1782  }
1783
1784 bool
1785 _CameraCapability::SupportedCameraAttrEffectCb(camera_attr_effect_mode_e effect, void *pUserData)
1786 {
1787         result r = E_SUCCESS;
1788         CameraEffect effectValue = (CameraEffect)MEDIA_INVALID_VALUE;
1789
1790         _MediaSafeArrayList* pEffectList = static_cast<_MediaSafeArrayList*>(pUserData);
1791         SysTryReturn(NID_MEDIA, pEffectList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
1792
1793         r = _CameraUtil::GetOspEffect(effect, effectValue);
1794         if (r == E_SUCCESS)
1795         {
1796                 std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(effectValue));
1797                 SysTryReturn(NID_MEDIA, pInteger.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1798
1799                 r = pEffectList->AddPtr(std::move(pInteger));
1800                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1801         }
1802         return true;
1803 }
1804
1805 bool
1806 _CameraCapability::SupportedCameraAttrFpsCb(camera_attr_fps_e fps, void *pUserData)
1807 {
1808         result r = E_SUCCESS;
1809         int framePerSec = 0;
1810
1811         _MediaSafeArrayList* pfpsList = static_cast<_MediaSafeArrayList*>(pUserData);
1812         SysTryReturn(NID_MEDIA, pfpsList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
1813
1814         r = _CameraUtil::GetOspFps(fps, framePerSec);
1815         if (r == E_SUCCESS)
1816         {
1817                 std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(framePerSec));
1818                 SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1819
1820                 r = pfpsList->AddPtr(std::move(pInteger));
1821                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1822         }
1823
1824         return true;
1825 }
1826
1827 bool
1828 _CameraCapability::SupportedCameraAttrWhitebalanceCb(camera_attr_whitebalance_e wb, void *pUserData)
1829 {
1830         result r = E_SUCCESS;
1831         CameraWhiteBalance wbValue = (CameraWhiteBalance)MEDIA_INVALID_VALUE;
1832
1833         _MediaSafeArrayList* pWhitebalanceList = static_cast<_MediaSafeArrayList*>(pUserData);
1834         SysTryReturn(NID_MEDIA, pWhitebalanceList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
1835
1836         r = _CameraUtil::GetOspWhiteBalance(wb, wbValue);
1837         if (r == E_SUCCESS)
1838         {
1839                 std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(wbValue));
1840                 SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1841
1842                 r = pWhitebalanceList->AddPtr(std::move(pInteger));
1843                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1844         }
1845         return true;
1846 }
1847
1848 bool
1849 _CameraCapability::SupportedCameraAttrSceneModeCb(camera_attr_scene_mode_e mode, void *pUserData)
1850 {
1851         result r = E_SUCCESS;
1852         _CameraSceneMode sceneModeValue = (_CameraSceneMode)MEDIA_INVALID_VALUE;
1853
1854         _MediaSafeArrayList* pSceneList = static_cast<_MediaSafeArrayList*>(pUserData);
1855         SysTryReturn(NID_MEDIA, pSceneList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
1856
1857         r = _CameraUtil::GetOspScene(mode, sceneModeValue);
1858         if (r == E_SUCCESS)
1859         {
1860                 std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(sceneModeValue));
1861                 SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1862
1863                 r = pSceneList->AddPtr(std::move(pInteger));
1864                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1865         }
1866         return true;
1867 }
1868
1869 bool
1870 _CameraCapability::SupportedCameraAttrIsoCb(camera_attr_iso_e iso, void *pUserData)
1871 {
1872         result r = E_SUCCESS;
1873         CameraIsoLevel isoValue = (CameraIsoLevel)MEDIA_INVALID_VALUE;
1874
1875         _MediaSafeArrayList* pIsoLevelList = static_cast<_MediaSafeArrayList*>(pUserData);
1876         SysTryReturn(NID_MEDIA, pIsoLevelList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
1877
1878         r = _CameraUtil::GetOspIso(iso, isoValue);
1879         if (r == E_SUCCESS)
1880         {
1881                 std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(isoValue));
1882                 SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1883
1884                 r = pIsoLevelList->AddPtr(std::move(pInteger));
1885                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1886         }
1887         return true;
1888 }
1889
1890 bool
1891 _CameraCapability::SupportedCameraAttrMeteringModeCb(camera_attr_exposure_mode_e mode, void *pUserData)
1892 {
1893         result r = E_SUCCESS;
1894         CameraMeteringMode exposureModeValue = (CameraMeteringMode)MEDIA_INVALID_VALUE;
1895
1896         _MediaSafeArrayList* pExposureList = static_cast<_MediaSafeArrayList*>(pUserData);
1897         SysTryReturn(NID_MEDIA, pExposureList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
1898
1899         r = _CameraUtil::GetOspMeteringMode(mode,exposureModeValue);
1900         if (r == E_SUCCESS)
1901         {
1902                 std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(exposureModeValue));
1903                 SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1904
1905                 r = pExposureList->AddPtr(std::move(pInteger));
1906                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1907         }
1908         return true;
1909 }
1910
1911 bool
1912 _CameraCapability::SupportedCameraAttrAfModeCb(camera_attr_af_mode_e mode, void *pUserData)
1913 {
1914         result r = E_SUCCESS;
1915         CameraFocusMode afModeValue = CAMERA_FOCUS_MODE_NONE;
1916         bool additionalMode = false;
1917         CameraFocusMode additionalAfModeValue = CAMERA_FOCUS_MODE_NONE;
1918
1919         _MediaSafeArrayList* pAutoFocusList = static_cast<_MediaSafeArrayList*>(pUserData);
1920         SysTryReturn(NID_MEDIA, pAutoFocusList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
1921
1922         r = _CameraUtil::GetOspFocusMode(mode,afModeValue, additionalMode, additionalAfModeValue);
1923         if (r == E_SUCCESS)
1924         {
1925                 std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(afModeValue));
1926                 SysTryReturn(NID_MEDIA, pInteger.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1927
1928                 r = pAutoFocusList->AddPtr(std::move(pInteger));
1929                 SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1930
1931                 //if there is any specific Osp mode which is not defined in the mm layer, add the additional value to the list based on the mm mode.
1932                 //For example, CAMERA_FOCUS_MODE_NORMAL and CAMERA_FOCUS_MODE_CONTINUOUS_AUTO are from mm's ::CAMERA_ATTR_AF_NORMAL.
1933                 if (additionalMode)
1934                 {
1935                         std::unique_ptr<Object> pInteger2 (new (std::nothrow) Integer(additionalAfModeValue));
1936                         SysTryReturn(NID_MEDIA, pInteger2.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1937
1938                         r = pAutoFocusList->AddPtr(std::move(pInteger2));
1939                         SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1940                 }
1941         }
1942         return true;
1943 }
1944
1945 }}