enable dual camera
[platform/framework/native/media.git] / src / FMedia_CapabilityImpl.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_CapabilityImpl.cpp
20  * @brief               This file contains the implementation for header file FMedia_CapabilityImpl.h
21  *
22  */
23
24 #include <unique_ptr.h>
25 #include <pthread.h>
26 #include <libxml/parser.h>
27 #include <libxml/tree.h>
28 #include <FBaseInteger.h>
29 #include <FBaseSysLog.h>
30 #include <FBaseColIList.h>
31 #include <FBaseColHashMap.h>
32 #include <FIoFile.h>
33 #include <FGrpDimension.h>
34 #include <FGrpPixelFormat.h>
35 #include <FSys_EnvironmentImpl.h>
36 #include <FSys_SystemInfoImpl.h>
37 #include <FMediaTypes.h>
38 #include <FMediaCapabilityTypes.h>
39 #include <FMediaCameraTypes.h>
40 #include <FMediaAudioTypes.h>
41 #include "FMedia_CapabilityImpl.h"
42 #include "FMedia_CameraCapability.h"
43 #include "FMedia_CameraCapabilitySession.h"
44 #include "FMedia_CameraUtil.h"
45 #include "FMedia_RecorderCapability.h"
46 #include "FMedia_RecorderSession.h"
47
48 using namespace Tizen::Base;
49 using namespace Tizen::Base::Collection;
50 using namespace Tizen::Graphics;
51 using namespace Tizen::Base::Utility;
52 using namespace Tizen::System;
53 using namespace Tizen::Io;
54
55 namespace Tizen { namespace Media
56 {
57 const wchar_t* const AUDIORECORDER_CODEC_TYPE = L"AudioRecorder.AudioCodecType";
58 const wchar_t* const AUDIORECORDER_MEDIA_CONTAINER_TYPE = L"AudioRecorder.MediaContainerType";
59 const wchar_t* const VIDEORECORDER_AUDIO_CODEC_TYPE = L"VideoRecorder.AudioCodecType";
60 const wchar_t* const VIDEORECORDER_VIDEO_CODEC_TYPE = L"VideoRecorder.VideoCodecType";
61 const wchar_t* const VIDEORECORDER_MEDIA_CONTAINER_TYPE = L"VideoRecorder.MediaContainerType";
62 const wchar_t* const VIDEORECORDER_CODEC = L"VideoRecorder.Codec";
63
64 const wchar_t* const CAMERA_PRIMARY_ZOOM_LEVEL = L"Camera.Primary.ZoomLevel";
65 const wchar_t* const CAMERA_SECONDARY_ZOOM_LEVEL = L"Camera.Secondary.ZoomLevel";
66
67 const wchar_t* const AUDIORECORDER_DEVICE_FPS = L"AudioRecorder.AudioFps";
68 const wchar_t* const VIDEORECORDER_DEVICE_FPS = L"VideoRecorder.AudioFps";
69
70 _CapabilityImpl* _CapabilityImpl::__pCapabilityImplInst = null;
71
72 void
73 _CapabilityImpl::InitSingleton(void)
74 {
75         result r = E_SUCCESS;
76         std::unique_ptr <_CapabilityImpl> pCapabilityImpl (new (std::nothrow) _CapabilityImpl());
77         SysTryReturnVoidResult(NID_MEDIA, pCapabilityImpl.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
78
79         r = pCapabilityImpl->Construct();
80         SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Capability resource creation failed.");
81
82         __pCapabilityImplInst = pCapabilityImpl.release();
83         std::atexit(DestroySingleton);
84 }
85
86 void
87 _CapabilityImpl::DestroySingleton(void)
88 {
89         delete __pCapabilityImplInst;
90 }
91
92 _CapabilityImpl*
93 _CapabilityImpl::GetInstance(void)
94 {
95         static pthread_once_t once_block = PTHREAD_ONCE_INIT;
96
97         if (!__pCapabilityImplInst)
98         {
99                 pthread_once(&once_block, InitSingleton);
100                 SysTryReturn(NID_MEDIA, __pCapabilityImplInst != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The instance is not found.");
101         }
102
103         return __pCapabilityImplInst;
104 }
105
106 _CapabilityImpl::_CapabilityImpl(void)
107         : __pMap(null)
108         , __cameraCount(0)
109         , __primaryCameraDone(false)
110         , __secondaryCameraDone(false)
111         , __videoRecorderDone(false)
112         , __audioRecorderDone(false)
113 {
114 }
115
116
117 _CapabilityImpl::~_CapabilityImpl(void)
118 {
119 }
120
121 result
122 _CapabilityImpl::Construct(void)
123 {
124         result r = E_SUCCESS;
125         long long length = 0;
126         int readLen = 0;
127         FileAttributes attributes;
128         File fileObj;
129         const String mediaCapabilityFilePath(L"/usr/etc/media-capability.xml");
130         SysLog(NID_MEDIA, "Enter ");
131
132         std::unique_ptr <HashMap> pMap (new (std::nothrow) HashMap(SingleObjectDeleter));
133
134         pMap.reset(new (std::nothrow) HashMap(SingleObjectDeleter));
135         SysTryReturn(NID_MEDIA, null != pMap.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. ");
136
137         r = pMap->Construct();
138         SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
139
140         __pMap.reset(pMap.release());
141
142         SysSecureLog(NID_MEDIA, "Capability XML path:%ls", mediaCapabilityFilePath.GetPointer());
143
144         r = File::GetAttributes( mediaCapabilityFilePath, attributes);
145         SysSecureTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. File path is %ls", GetErrorMessage(r), mediaCapabilityFilePath.GetPointer());
146
147         length = attributes.GetFileSize();
148         SysTryReturn(NID_MEDIA, length > 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Propagating.");
149
150         std::unique_ptr<char[]> pXmlBuffer (new (std::nothrow) char[length]);
151         SysTryReturn(NID_MEDIA, null != pXmlBuffer.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. ");
152
153         r = fileObj.Construct(mediaCapabilityFilePath, L"r");
154         SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
155
156 //      read the capability xml file content as parse the capability
157         readLen = fileObj.Read(pXmlBuffer.get(), length);
158         SysTryReturn(NID_MEDIA, readLen == length, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Propagating. length:%d, readLen:%d", length,
159                            readLen);
160
161 //      parse the capability file buffer all the parse key value pair shall be added in __pMap object
162         r = ParseCapability(pXmlBuffer.get(), readLen);
163         SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
164
165         //      Get the camera count
166         int cameraCount = 0;
167         bool flag = false;
168
169         r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/camera.back", flag);
170         SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
171         if (flag)
172         {
173                 cameraCount++;
174         }
175
176         r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/camera.front", flag);
177         SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
178         if (flag)
179         {
180                 cameraCount++;
181         }
182         __cameraCount = cameraCount;
183         return r;
184 }
185
186 typedef void (_CapabilityImpl::* KeyConvertFunc)(const String& key, String& newKey);
187 typedef result (*_ValueCopyFunc)(int type, Object* pObj, void* value);
188
189 typedef struct
190 {
191         const wchar_t* pKey;
192         _ValueCopyFunc copy;
193         _MediaCapCategoryType category;
194 } _CapabilityCopyMap;
195
196
197 result
198 _CapabilityImpl::CopyListInteger(int type, Object* pObj, void* value)
199 {
200         result r = E_SUCCESS;
201
202         SysTryReturn(NID_MEDIA, type == _MEDIA_CAP_VALUE_TYPE_LIST, E_INVALID_ARG, E_INVALID_ARG,
203                                 "[E_INVALID_ARG] Invalid argument(Type) is used. type:%d",
204                                 type);
205
206         IList* pSrc = dynamic_cast <IList*>(pObj);
207         IList* pDst = static_cast <IList*>(value);
208
209         SysTryReturn(NID_MEDIA, pSrc != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pSrc is null.");
210         SysTryReturn(NID_MEDIA, pDst != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pDest is null.");
211         SysTryReturn(NID_MEDIA,
212                                 pSrc->GetCount() > 0, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pSrc->GetCount() is %d", pSrc->GetCount());
213
214         for (int i = 0; i < pSrc->GetCount(); i++)
215         {
216                 Integer* pInt = (Integer*) pSrc->GetAt(i);
217                 if (pInt)
218                 {
219                         Integer* pInteger = null;
220
221                         pInteger = new (std::nothrow) Integer(*pInt);
222                         SysTryReturn(NID_MEDIA, pInteger !=null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
223
224                         r = pDst->Add(*pInteger);
225                         SysTryReturn(NID_MEDIA, E_SUCCESS == r, r, r, "[%s] Propagating.");
226                 }
227         }
228
229         return E_SUCCESS;
230 }
231
232 result
233 _CapabilityImpl::CopyListString(int type, Object* pObj, void* value)
234 {
235         result r = E_SUCCESS;
236
237         SysTryReturn(NID_MEDIA, type == _MEDIA_CAP_VALUE_TYPE_LIST, E_INVALID_ARG, E_INVALID_ARG,
238                                 "[E_INVALID_ARG] Invalid argument(Type) is used. type:%d",
239                                 type);
240
241         IList* pSrc = dynamic_cast <IList*>(pObj);
242         IList* pDst = static_cast <IList*>(value);
243
244         SysTryReturn(NID_MEDIA, pSrc != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pSrc is null.");
245         SysTryReturn(NID_MEDIA, pDst != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pDest is null.");
246         SysTryReturn(NID_MEDIA,
247                                 pSrc->GetCount() > 0, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pSrc->GetCount() is %d", pSrc->GetCount());
248
249         for (int i = 0; i < pSrc->GetCount(); i++)
250         {
251                 String* pStr = (String*) pSrc->GetAt(i);
252                 if (pStr)
253                 {
254                         String* pString = null;
255
256                         pString = new (std::nothrow) String(*pStr);
257                         SysTryReturn(NID_MEDIA, pString !=null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
258
259                         r = pDst->Add(*pString);
260                         SysTryReturn(NID_MEDIA, E_SUCCESS == r, r, r, "[%s] Propagating.");
261                 }
262         }
263         return E_SUCCESS;
264 }
265
266
267 result
268 _CapabilityImpl::CopyListDimension(int type, Object* pObj, void* value)
269 {
270         result r = E_SUCCESS;
271
272         SysTryReturn(NID_MEDIA, type == _MEDIA_CAP_VALUE_TYPE_LIST, E_INVALID_ARG, E_INVALID_ARG,
273                                 "[E_INVALID_ARG] Invalid argument(Type) is used. type:%d",
274                                 type);
275
276         IList* pSrc = dynamic_cast <IList*>(pObj);
277         IList* pDst = static_cast <IList*>(value);
278
279         SysTryReturn(NID_MEDIA, pSrc != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pSrc is null.");
280         SysTryReturn(NID_MEDIA, pDst != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pDest is null.");
281         SysTryReturn(NID_MEDIA,
282                                 pSrc->GetCount() > 0, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pSrc->GetCount() is %d", pSrc->GetCount());
283
284         for (int i = 0; i < pSrc->GetCount(); i++)
285         {
286                 Dimension* pDim = (Dimension*) pSrc->GetAt(i);
287                 if (pDim)
288                 {
289                         Dimension* pDimension = null;
290
291                         pDimension = new (std::nothrow) Dimension(*pDim);
292                         SysTryReturn(NID_MEDIA, pDimension !=null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
293
294                         r = pDst->Add(*pDimension);
295                         SysTryReturn(NID_MEDIA, E_SUCCESS == r, r, r, "[%s] Propagating.");
296                 }
297         }
298         return E_SUCCESS;
299 }
300
301 result
302 _CapabilityImpl::CopyInteger(int type, Object* pObj, void* value)
303 {
304         SysTryReturn(NID_MEDIA, type == _MEDIA_CAP_VALUE_TYPE_INT, E_INVALID_ARG, E_INVALID_ARG,
305                                 "[E_INVALID_ARG] Invalid argument(Type) is used. type:%d",
306                                 type);
307
308         Integer* pSrc = dynamic_cast <Integer*>(pObj);
309         int* pDst = (int*) value;
310
311         SysTryReturn(NID_MEDIA, pSrc != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Integer instance is not available. pSrc is null.");
312
313         *pDst = pSrc->ToInt();
314
315         return E_SUCCESS;
316 }
317
318 result
319 _CapabilityImpl::CopyBool(int type, Object* pObj, void* value)
320 {
321         SysTryReturn(NID_MEDIA, type == _MEDIA_CAP_VALUE_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG,
322                                 "[E_INVALID_ARG] Invalid argument(Type) is used. type:%d",
323                                 type);
324
325         Integer* pSrc = dynamic_cast <Integer*>(pObj);
326         bool* pDst = (bool*) value;
327
328         SysTryReturn(NID_MEDIA, pSrc != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Integer instance is not available. pSrc is null.");
329
330         *pDst = (pSrc->ToInt()) ? true : false;
331
332         return E_SUCCESS;
333 }
334
335 static _CapabilityCopyMap _COPY_MAP[] =
336 {
337         { AUDIOIN_SAMPLE_RATE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO},
338         { AUDIOIN_SAMPLE_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO },
339
340         { AUDIOOUT_COUNT_MAX, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_AUDIO },
341         { AUDIOOUT_SAMPLE_RATE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO },
342         { AUDIOOUT_SAMPLE_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO },
343
344         { AUDIORECORDER_FORMAT, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_AUDIO_RECORDER },
345         { AUDIORECORDER_CODEC_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO_RECORDER },
346         { AUDIORECORDER_MEDIA_CONTAINER_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO_RECORDER },
347         { AUDIORECORDER_DEVICE_FPS, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_AUDIO_RECORDER },
348
349         { CAMERA_COUNT, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
350
351         { CAMERA_PRIMARY_CAPTURE_FORMAT, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
352         { CAMERA_PRIMARY_CAPTURE_RESOLUTION, _CapabilityImpl::CopyListDimension, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
353         { CAMERA_PRIMARY_DIRECTION, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
354         { CAMERA_PRIMARY_EFFECT, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
355         { CAMERA_PRIMARY_ISO_LEVEL, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
356         { CAMERA_PRIMARY_PREVIEW_FORMAT, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
357         { CAMERA_PRIMARY_PREVIEW_FRAMERATE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
358         { CAMERA_PRIMARY_PREVIEW_RESOLUTION, _CapabilityImpl::CopyListDimension, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
359         { CAMERA_PRIMARY_RECORDING_RESOLUTION, _CapabilityImpl::CopyListDimension, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
360         { CAMERA_PRIMARY_ROTATION, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
361         { CAMERA_PRIMARY_SUPPORT_BRIGHTNESS, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
362         { CAMERA_PRIMARY_SUPPORT_CAPTURE, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
363         { CAMERA_PRIMARY_SUPPORT_CONTRAST, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
364         { CAMERA_PRIMARY_SUPPORT_EXPOSURE, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
365         { CAMERA_PRIMARY_SUPPORT_FLASH, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
366         { CAMERA_PRIMARY_SUPPORT_FOCUS, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
367         { CAMERA_PRIMARY_SUPPORT_PREVIEW, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
368         { CAMERA_PRIMARY_SUPPORT_RECORDING, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
369         { CAMERA_PRIMARY_SUPPORT_ZOOM, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
370         { CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
371         { CAMERA_PRIMARY_WHITE_BALANCE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
372         { CAMERA_PRIMARY_ZOOM_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
373         { CAMERA_PRIMARY_FOCUS_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
374         { CAMERA_PRIMARY_FLIP, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
375         { CAMERA_PRIMARY_PREVIEW_ROTATION, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
376         { CAMERA_PRIMARY_FOCUS_POINT, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
377         { CAMERA_PRIMARY_FLASH_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
378         { CAMERA_PRIMARY_DEFAULT_PREVIEW_FORMAT, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
379         { CAMERA_PRIMARY_METERING_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
380         { CAMERA_PRIMARY_SCENE_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
381
382         { CAMERA_SECONDARY_CAPTURE_FORMAT, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
383         { CAMERA_SECONDARY_CAPTURE_RESOLUTION, _CapabilityImpl::CopyListDimension, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
384         { CAMERA_SECONDARY_DIRECTION, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
385         { CAMERA_SECONDARY_EFFECT, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
386         { CAMERA_SECONDARY_ISO_LEVEL, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
387         { CAMERA_SECONDARY_PREVIEW_FORMAT, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
388         { CAMERA_SECONDARY_PREVIEW_FRAMERATE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
389         { CAMERA_SECONDARY_PREVIEW_RESOLUTION, _CapabilityImpl::CopyListDimension, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
390         { CAMERA_SECONDARY_RECORDING_RESOLUTION, _CapabilityImpl::CopyListDimension, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
391         { CAMERA_SECONDARY_ROTATION, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
392         { CAMERA_SECONDARY_SUPPORT_BRIGHTNESS, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
393         { CAMERA_SECONDARY_SUPPORT_CAPTURE, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
394         { CAMERA_SECONDARY_SUPPORT_CONTRAST, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
395         { CAMERA_SECONDARY_SUPPORT_EXPOSURE, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
396         { CAMERA_SECONDARY_SUPPORT_FLASH, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
397         { CAMERA_SECONDARY_SUPPORT_FOCUS, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
398         { CAMERA_SECONDARY_SUPPORT_PREVIEW, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
399         { CAMERA_SECONDARY_SUPPORT_RECORDING, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
400         { CAMERA_SECONDARY_SUPPORT_ZOOM, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
401         { CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
402         { CAMERA_SECONDARY_WHITE_BALANCE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
403         { CAMERA_SECONDARY_ZOOM_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
404         { CAMERA_SECONDARY_FOCUS_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
405         { CAMERA_SECONDARY_FLIP, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
406         { CAMERA_SECONDARY_PREVIEW_ROTATION, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
407         { CAMERA_SECONDARY_FOCUS_POINT, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
408         { CAMERA_SECONDARY_FLASH_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
409         { CAMERA_SECONDARY_DEFAULT_PREVIEW_FORMAT, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
410         { CAMERA_SECONDARY_METERING_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
411         { CAMERA_SECONDARY_SCENE_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
412
413         { PLAYER_AUDIO_CODEC, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_PLAYER },
414         { PLAYER_COUNT_MAX, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PLAYER },
415         { PLAYER_PROTOCOL, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_PLAYER },
416         { PLAYER_VIDEO_CODEC, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_PLAYER },
417         { PLAYER_VIDEO_HEIGHT, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PLAYER },
418         { PLAYER_VIDEO_WIDTH, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PLAYER },
419
420         { VIDEORECORDER_CODEC, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_CODEC },
421
422         { VIDEORECORDER_AUDIO_CODEC, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
423         { VIDEORECORDER_FORMAT, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
424         { VIDEORECORDER_VIDEO_CODEC, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
425         { VIDEORECORDER_AUDIO_CODEC_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
426         { VIDEORECORDER_VIDEO_CODEC_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
427         { VIDEORECORDER_MEDIA_CONTAINER_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
428         { VIDEORECORDER_DEVICE_FPS, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
429 };
430
431 result
432 _CapabilityImpl::GetValue(const Tizen::Base::String& key, int type, void* value)
433 {
434         result r = E_SUCCESS;
435         bool found = false;
436
437         for (int i = 0; i < (int)sizeof(_COPY_MAP) / (int)sizeof(_COPY_MAP[0]); i++)
438         {
439                 _CapabilityCopyMap* pInfo = (_CapabilityCopyMap*) &(_COPY_MAP[i]);
440
441                 if (pInfo == 0)
442                 {
443                         continue;
444                 }
445                 //check for valid key value and then get the corresponding value from the hash map
446                 if (key.Equals(pInfo->pKey, true))
447                 {
448                         // Get the value
449                         Object* pObj = __pMap->GetValue(key);
450
451                         // If not yet retrieved
452                         if ( pObj == null )
453                         {
454                                 ClearLastResult();
455                                 //Set the value
456                                 switch (pInfo->category)
457                                 {
458                                         case _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA:
459                                                 if (!__primaryCameraDone && __cameraCount > 0)
460                                                 {
461                                                         r = ParseCapability(_MEDIA_CAP_CATEGORY_PRIMARY_CAMERA);
462                                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
463                                                         __primaryCameraDone = true;
464                                                 }
465                                                 break;
466
467                                         case _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA:
468                                                 if (!__secondaryCameraDone && __cameraCount > 1)
469                                                 {
470                                                         r = ParseCapability(_MEDIA_CAP_CATEGORY_SECONDARY_CAMERA);
471                                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
472                                                         __secondaryCameraDone = true;
473                                                 }
474                                                 break;
475
476                                         case _MEDIA_CAP_CATEGORY_VIDEO_RECORDER:
477                                                 if (!__videoRecorderDone)
478                                                 {
479                                                         r = ParseCapability(_MEDIA_CAP_CATEGORY_VIDEO_RECORDER);
480                                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
481                                                         __videoRecorderDone = true;
482                                                 }
483                                                 break;
484
485                                         case _MEDIA_CAP_CATEGORY_AUDIO_RECORDER:
486                                                 if (!__audioRecorderDone)
487                                                 {
488                                                         r = ParseCapability(_MEDIA_CAP_CATEGORY_AUDIO_RECORDER);
489                                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
490                                                         __audioRecorderDone = true;
491                                                 }
492                                                 break;
493
494                                         default:
495                                                 break;
496                                 }
497                                 // Retrieve again.
498                                 pObj = __pMap->GetValue(key);
499                                 SysTryReturn(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object instance is not available. Value is not found. key:%ls", key.GetPointer());
500                         }
501                         SysTryReturn(NID_MEDIA, pInfo->copy != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Copy function is not found.");
502
503                         r = (pInfo->copy)(type, pObj, value);
504                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. key:%ls", GetErrorMessage(r), key.GetPointer());
505
506                         found = true;
507                         break;
508                 }
509         }
510         SysTryCatch(NID_MEDIA, found, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] String instance is not available. key is not found. key:%ls", key.GetPointer());
511         return r;
512
513 CATCH:
514         return r;
515 }
516
517 result
518 _CapabilityImpl::GetValue(const Tizen::Base::String& key, bool& value)
519 {
520         return GetValue(key, _MEDIA_CAP_VALUE_TYPE_BOOL, (void*) &value);
521 }
522
523
524 result
525 _CapabilityImpl::GetValue(const Tizen::Base::String& key, int& value)
526 {
527         return GetValue(key, _MEDIA_CAP_VALUE_TYPE_INT, (void*) &value);
528 }
529
530
531 result
532 _CapabilityImpl::GetValue(const Tizen::Base::String& key, long long& value)
533 {
534         return GetValue(key, _MEDIA_CAP_VALUE_TYPE_LONG_LONG, (void*) &value);
535 }
536
537 result
538 _CapabilityImpl::GetValue(const Tizen::Base::String& key, double& value)
539 {
540         return GetValue(key, _MEDIA_CAP_VALUE_TYPE_DOUBLE, (void*) &value);
541 }
542
543 result
544 _CapabilityImpl::GetValue(const Tizen::Base::String& key, Tizen::Base::String& value)
545 {
546         return GetValue(key, _MEDIA_CAP_VALUE_TYPE_STRING, (void*) &value);
547 }
548
549 result
550 _CapabilityImpl::GetValueN(const Tizen::Base::String& key, Tizen::Base::Collection::IList& value)
551 {
552         return GetValue(key, _MEDIA_CAP_VALUE_TYPE_LIST, (void*) &value);
553 }
554
555 typedef Tizen::Base::Object* (*_ValueConvertFunc)(const char* input, Object* pObj, const void* param);
556
557 typedef struct
558 {
559         const char* pKey;
560         int value;
561 } _CharToEnumMap;
562
563 static const _CharToEnumMap _AUDIO_SAMPLE_TYPE_MAP[] =
564 {
565         { "PCM_U8", AUDIO_TYPE_PCM_U8 },
566         { "PCM_S8", AUDIO_TYPE_PCM_S8 },
567         { "PCM_U16_LE", AUDIO_TYPE_PCM_U16_LE },
568         { "PCM_U16_BE", AUDIO_TYPE_PCM_U16_BE },
569         { "PCM_S16_LE", AUDIO_TYPE_PCM_S16_LE },
570         { "PCM_S16_BE", AUDIO_TYPE_PCM_S16_BE },
571         { 0, 0 }
572 };
573 /*
574 static const _CharToEnumMap _PIXEL_FORMAT_MAP[] =
575 {
576         { "RGB565", PIXEL_FORMAT_RGB565 },
577         { "ARGB8888", PIXEL_FORMAT_ARGB8888 },
578         { "R8G8B8A8", PIXEL_FORMAT_R8G8B8A8 },
579         { "YUV420", PIXEL_FORMAT_YCbCr420_PLANAR },
580         { "JPEG", PIXEL_FORMAT_JPEG },
581         { 0, 0 },
582 };
583 */
584 static const _CharToEnumMap _CAMERA_DIRECTION_MAP[] =
585 {
586         { "Front", CAMERA_DIRECTION_FRONT },
587         { "Back", CAMERA_DIRECTION_BACK },
588         { 0, 0 },
589 };
590
591 static const _CharToEnumMap _CAMERA_ZOOM_TYPE_MAP[] =
592 {
593         { "Digital", CAMERA_ZOOM_TYPE_DIGITAL },
594         { "Smart", CAMERA_ZOOM_TYPE_SMART },
595         { 0, 0 },
596 };
597 /*
598 static const _CharToEnumMap _CAMERA_FOCUS_MODE_MAP[] =
599 {
600         { "None", CAMERA_FOCUS_MODE_NONE },
601         { "Normal", CAMERA_FOCUS_MODE_NORMAL },
602         { "Macro", CAMERA_FOCUS_MODE_MACRO },
603         { "ContinuousAuto", CAMERA_FOCUS_MODE_CONTINUOUS_AUTO },
604         { "Infinite", CAMERA_FOCUS_MODE_INFINITE },
605         { 0, 0 },
606 };
607 */
608 static const _CharToEnumMap _CAMERA_FLIP_TYPE_MAP[] =
609 {
610         { "None", CAMERA_FLIP_NONE },
611         { "Horizontal", CAMERA_FLIP_HORIZONTAL },
612         { "Vertical", CAMERA_FLIP_VERTICAL },
613         { 0, 0 },
614 };
615 /*
616 static const _CharToEnumMap _CAMERA_EFFECT_MAP[] =
617 {
618         { "COLOR", CAMERA_EFFECT_COLOR},
619         { "BW", CAMERA_EFFECT_BW},
620         { "SEPIA", CAMERA_EFFECT_SEPIA},
621         { "SOLARIZE", CAMERA_EFFECT_SOLARIZE},
622         { "NEGATIVE", CAMERA_EFFECT_NEGATIVE},
623         { "NIGHT", CAMERA_EFFECT_NIGHT},
624         { 0, 0 },
625 };
626
627 static const _CharToEnumMap _CAMERA_ISO_LEVEL_MAP[] =
628 {
629         { "AUTO", CAMERA_ISO_AUTO},
630         { "50", CAMERA_ISO_50},
631         { "100", CAMERA_ISO_100},
632         { "200", CAMERA_ISO_200},
633         { "400", CAMERA_ISO_400},
634         { "800", CAMERA_ISO_800},
635         { "1600", CAMERA_ISO_1600},
636         { 0, 0 },
637 };
638 */
639 static const _CharToEnumMap _CAMERA_ROTATION_MAP[] =
640 {
641         { "0", CAMERA_ROTATION_NONE},
642         { "90", CAMERA_ROTATION_90},
643         { "180", CAMERA_ROTATION_180},
644         { "270", CAMERA_ROTATION_270},
645         { 0, 0 },
646 };
647 /*
648 static const _CharToEnumMap _CAMERA_WB_MAP[] =
649 {
650         { "AUTO", CAMERA_WHITE_BALANCE_AUTO},
651         { "SUNNY", CAMERA_WHITE_BALANCE_SUNNY},
652         { "CLOUDY", CAMERA_WHITE_BALANCE_CLOUDY},
653         { "FLUORESCENT", CAMERA_WHITE_BALANCE_FLUORESCENT},
654         { "TUNGSTEN", CAMERA_WHITE_BALANCE_TUNGSTEN},
655         { 0, 0 },
656 };
657
658 static const _CharToEnumMap _BOOL_MAP[] =
659 {
660         { "true", true },
661         { "false", false },
662         { 0, 0 },
663 };
664
665 static const _CharToEnumMap _CODEC_TYPE_MAP[] =
666 {
667         { "LPCM", CODEC_LPCM },
668         { "ALAW", CODEC_ALAW },
669         { "uLAW", CODEC_ULAW },
670         { "IMAD", CODEC_IMA_ADPCM },
671         { "MSAD", CODEC_MS_ADPCM },
672         { "AMR", CODEC_AMR_NB },
673         { "FLAC", CODEC_FLAC },
674         { "MP3", CODEC_MP3 },
675         { "AAC", CODEC_AAC },
676         { "AACH", CODEC_HEAAC },
677         { "AACP", CODEC_HEAAC_V2 },
678         { "AC-3", CODEC_AC3 },
679         { "VORB", CODEC_VORBIS },
680         { "WMA", CODEC_WMA },
681         { "MIDI", CODEC_MIDI },
682         { "H263", CODEC_H263 },
683         { "MPG4", CODEC_MPEG4 },
684         { "H264", CODEC_H264 },
685         { "THRA", CODEC_THEORA },
686         { "WMV", CODEC_WMV },
687         { 0, 0 }
688 };
689
690 static const _CharToEnumMap _MEDIA_CONTAINER_TYPE_MAP[] =
691 {
692         { "WAV", MEDIA_CONTAINER_WAV },
693         { "AMR", MEDIA_CONTAINER_AMR },
694         { "AAC", MEDIA_CONTAINER_AAC },
695         { "MP3", MEDIA_CONTAINER_MP3 },
696         { "FLAC", MEDIA_CONTAINER_FLAC },
697         { "3GP", MEDIA_CONTAINER_3GP },
698         { "MP4", MEDIA_CONTAINER_MP4 },
699         { "AVI", MEDIA_CONTAINER_AVI },
700         { "ASF", MEDIA_CONTAINER_ASF },
701         { "MKV", MEDIA_CONTAINER_MKV },
702         { "MOV", MEDIA_CONTAINER_MOV },
703         { "OGG", MEDIA_CONTAINER_OGG },
704         { 0, 0 }
705 };
706 */
707
708 typedef Tizen::Base::Object* (*_ValueParsingFunc)(xmlNode* pRoot, Tizen::Base::Object* pObj, _ValueConvertFunc func,
709                                                                                            const void* param);
710
711 typedef struct
712 {
713         const wchar_t* pKey;
714         _ValueParsingFunc parser;
715         _ValueConvertFunc convert;
716         const void* param;
717 } _SectionParsingInfo;
718
719 Tizen::Base::Object*
720 _CapabilityImpl::ConvertCharToInteger(const char* input, Object* pObj, const void* param)
721 {
722         Tizen::Base::String str(input);
723         Integer* pInt = 0;
724         int i = 0;
725         result res = E_SUCCESS;
726 //      bool integerCreated = false;
727
728         res = Tizen::Base::Integer::Parse(str, i);
729         SysTryReturn(NID_MEDIA, res == E_SUCCESS, pInt, res, "[%s] Propagating.", res);
730
731         if (pObj)
732         {
733                 pInt = dynamic_cast <Integer*>(pObj);
734         }
735         else
736         {
737                 pInt = new (std::nothrow) Integer();
738 //              integerCreated = true;
739         }
740
741         SysTryCatch(NID_MEDIA, null != pInt, res = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Integer is null");
742
743         *pInt = i;
744
745         return pInt;
746
747 CATCH:
748         return null;
749 }
750
751 Tizen::Base::Object*
752 _CapabilityImpl::ConvertCharToString(const char* input, Object* pObj, const void* param)
753 {
754         String* pStr = pObj ? (String*) pObj : new (std::nothrow) String();
755         SysTryReturn(NID_MEDIA, pStr !=null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
756
757         *pStr = input;
758
759         return pStr;
760 }
761
762
763 Tizen::Base::Object*
764 _CapabilityImpl::ConvertCharToEnum(const char* input, Object* pObj, const void* param)
765 {
766         Tizen::Base::String str(input);
767         Integer* pInt = null;
768         _CharToEnumMap* pMap = (_CharToEnumMap*) param;
769         bool found = false;
770         bool integerCreated = false;
771
772         if (pObj != null)
773         {
774                 pInt = (Integer*) pObj;
775         }
776         else
777         {
778                 pInt = new (std::nothrow) Integer();
779                 integerCreated = true;
780         }
781
782         SysTryCatch(NID_MEDIA, null != pInt, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Integer is null");
783
784         while (pMap != null && pMap->pKey)
785         {
786                 if (str.Equals(pMap->pKey, false))
787                 {
788                         *pInt = pMap->value;
789                         found = true;
790                         break;
791                 }
792                 pMap++;
793         }
794
795         if (found)
796         {
797                 return pInt;
798         }
799         else
800         {
801                 SysLog(NID_MEDIA, "Failed : %s pMap=0x%x", input, param);
802                 if (integerCreated)
803                 {
804                         delete pInt;
805                 }
806
807                 return 0;
808         }
809
810 CATCH:
811         return null;
812 }
813
814 Tizen::Base::Object*
815 _CapabilityImpl::ConvertCharToDimension(const char* input, Object* pObj, const void* param)
816 {
817         Tizen::Base::String str;
818         Dimension* pDim = null;
819         StringTokenizer tok(input, L" x");
820         int w = 0;
821         int h = 0;
822         int count = 0;
823         result res = E_SUCCESS;
824
825         pDim = pObj ? (Dimension*) pObj : new (std::nothrow) Dimension();
826         SysTryReturn(NID_MEDIA, pDim !=null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
827
828         count = tok.GetTokenCount();
829         SysTryReturn(NID_MEDIA, count == 2, pDim, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Token should be two, token count:%d", count);
830
831         tok.GetNextToken(str);
832         res = Tizen::Base::Integer::Parse(str, w);
833         SysTryReturn(NID_MEDIA, res == E_SUCCESS, pDim, res, "[%s] Propagating.");
834
835         tok.GetNextToken(str);
836         res = Tizen::Base::Integer::Parse(str, h);
837         SysTryReturn(NID_MEDIA, res == E_SUCCESS, pDim, res, "[%s] Propagating.");
838
839         pDim->width = w;
840         pDim->height = h;
841
842         return pDim;
843 }
844
845 Tizen::Base::Object*
846 ParseValueList(xmlNode* pRoot, Tizen::Base::Object* pObj, _ValueConvertFunc func, const void* param)
847 {
848         xmlNode* pNode = null;
849         xmlNode* pChild = null;
850         _MediaSafeArrayList* pList = null;
851
852         pList = pObj ? (_MediaSafeArrayList*) pObj : new (std::nothrow) _MediaSafeArrayList();
853         SysTryReturn(NID_MEDIA, pList !=null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
854
855         for (pNode = pRoot->children; pNode; pNode = pNode->next)
856         {
857                 if (pNode->type == XML_ELEMENT_NODE && pNode->children)
858                 {
859                         pChild = pNode->children;
860
861                         if (pChild->type == XML_TEXT_NODE && pChild->content)
862                         {
863                                 Object* pRet = func((const char*) pChild->content, 0, param);
864                                 if (pRet)
865                                 {
866                                         pList->Add(*pRet);
867                                 }
868                         }
869                 }
870         }
871
872         return pList;
873 }
874
875 Tizen::Base::Object*
876 ParseContent(xmlNode* pRoot, Tizen::Base::Object* pObj, _ValueConvertFunc func, const void* param)
877 {
878         xmlNode* pNode = null;
879
880         for (pNode = pRoot->children; pNode; pNode = pNode->next)
881         {
882                 if (pNode->type == XML_TEXT_NODE && pNode->content)
883                 {
884                         pObj = func((const char*) pNode->content, pObj, param);
885                 }
886         }
887
888         return pObj;
889 }
890
891 //key to corresponding value conversion function map
892 static _SectionParsingInfo _PARSING_INFO[] =
893 {
894         { AUDIOIN_SAMPLE_RATE, ParseValueList, _CapabilityImpl::ConvertCharToInteger, 0 },
895         { AUDIOIN_SAMPLE_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _AUDIO_SAMPLE_TYPE_MAP },
896
897         { AUDIOOUT_COUNT_MAX, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
898         { AUDIOOUT_SAMPLE_RATE, ParseValueList, _CapabilityImpl::ConvertCharToInteger, 0 },
899         { AUDIOOUT_SAMPLE_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _AUDIO_SAMPLE_TYPE_MAP },
900
901         { AUDIORECORDER_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
902         { AUDIORECORDER_DEVICE_FPS, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
903
904 //      { AUDIORECORDER_CODEC_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CODEC_TYPE_MAP},
905 //      { AUDIORECORDER_MEDIA_CONTAINER_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _MEDIA_CONTAINER_TYPE_MAP},
906
907 //      { CAMERA_PRIMARY_CAPTURE_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _PIXEL_FORMAT_MAP },
908 //      { CAMERA_PRIMARY_CAPTURE_RESOLUTION, ParseValueList, _CapabilityImpl::ConvertCharToDimension, 0 },
909         { CAMERA_PRIMARY_DIRECTION, ParseContent, _CapabilityImpl::ConvertCharToEnum, _CAMERA_DIRECTION_MAP },
910 //      { CAMERA_PRIMARY_EFFECT, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_EFFECT_MAP },
911 //      { CAMERA_PRIMARY_ISO_LEVEL, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ISO_LEVEL_MAP },
912 //      { CAMERA_PRIMARY_PREVIEW_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _PIXEL_FORMAT_MAP },
913 //      { CAMERA_PRIMARY_PREVIEW_FRAMERATE, ParseValueList, _CapabilityImpl::ConvertCharToInteger, 0 },
914 //      { CAMERA_PRIMARY_PREVIEW_RESOLUTION, ParseValueList, _CapabilityImpl::ConvertCharToDimension, 0 },
915         { CAMERA_PRIMARY_ROTATION, ParseContent, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ROTATION_MAP },
916 //      { CAMERA_PRIMARY_SUPPORT_BRIGHTNESS, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
917 //      { CAMERA_PRIMARY_SUPPORT_CAPTURE, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
918 //      { CAMERA_PRIMARY_SUPPORT_CONTRAST, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
919 //      { CAMERA_PRIMARY_SUPPORT_EXPOSURE, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
920 //      { CAMERA_PRIMARY_SUPPORT_FLASH, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
921 //      { CAMERA_PRIMARY_SUPPORT_FOCUS, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
922 //      { CAMERA_PRIMARY_SUPPORT_PREVIEW, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
923 //      { CAMERA_PRIMARY_SUPPORT_RECORDING, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
924 //      { CAMERA_PRIMARY_SUPPORT_ZOOM, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
925 //      { CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
926 //      { CAMERA_PRIMARY_WHITE_BALANCE, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
927         { CAMERA_PRIMARY_ZOOM_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ZOOM_TYPE_MAP },
928 //      { CAMERA_PRIMARY_RECORDING_RESOLUTION, ParseValueList, _CapabilityImpl::ConvertCharToDimension, 0},
929 //      { CAMERA_PRIMARY_FOCUS_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_FOCUS_MODE_MAP },
930         { CAMERA_PRIMARY_FLIP, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_FLIP_TYPE_MAP },
931         { CAMERA_PRIMARY_PREVIEW_ROTATION, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ROTATION_MAP },
932 //      { CAMERA_PRIMARY_ZOOM_LEVEL, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0},
933         { CAMERA_PRIMARY_FOCUS_POINT, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
934 //      { CAMERA_PRIMARY_FLASH_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_FLASH_MODE_MAP },
935 //      { CAMERA_PRIMARY_DEFAULT_PREVIEW_FORMAT, ParseContent, _CapabilityImpl::ConvertCharToEnum, _PIXEL_FORMAT_MAP },
936 //      { CAMERA_PRIMARY_METERING_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_METERING_MODE_MAP },
937 //      { CAMERA_PRIMARY_SCENE_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_SCENE_MODE_MAP },
938
939 //      { CAMERA_SECONDARY_CAPTURE_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _PIXEL_FORMAT_MAP },
940 //      { CAMERA_SECONDARY_CAPTURE_RESOLUTION, ParseValueList, _CapabilityImpl::ConvertCharToDimension, 0 },
941         { CAMERA_SECONDARY_DIRECTION, ParseContent, _CapabilityImpl::ConvertCharToEnum, _CAMERA_DIRECTION_MAP },
942 //      { CAMERA_SECONDARY_EFFECT, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_EFFECT_MAP },
943 //      { CAMERA_SECONDARY_ISO_LEVEL, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ISO_LEVEL_MAP },
944 //      { CAMERA_SECONDARY_PREVIEW_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _PIXEL_FORMAT_MAP },
945 //      { CAMERA_SECONDARY_PREVIEW_FRAMERATE, ParseValueList, _CapabilityImpl::ConvertCharToInteger, 0 },
946 //      { CAMERA_SECONDARY_PREVIEW_RESOLUTION, ParseValueList, _CapabilityImpl::ConvertCharToDimension, 0 },
947         { CAMERA_SECONDARY_ROTATION, ParseContent, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ROTATION_MAP },
948 //      { CAMERA_SECONDARY_SUPPORT_BRIGHTNESS, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
949 //      { CAMERA_SECONDARY_SUPPORT_CAPTURE, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
950 //      { CAMERA_SECONDARY_SUPPORT_CONTRAST, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
951 //      { CAMERA_SECONDARY_SUPPORT_EXPOSURE, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
952 //      { CAMERA_SECONDARY_SUPPORT_FLASH, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
953 //      { CAMERA_SECONDARY_SUPPORT_FOCUS, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
954 //      { CAMERA_SECONDARY_SUPPORT_PREVIEW, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
955 //      { CAMERA_SECONDARY_SUPPORT_RECORDING, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
956 //      { CAMERA_SECONDARY_SUPPORT_ZOOM, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
957 //      { CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
958 //      { CAMERA_SECONDARY_WHITE_BALANCE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_WB_MAP },
959         { CAMERA_SECONDARY_ZOOM_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ZOOM_TYPE_MAP },
960 //      { CAMERA_SECONDARY_RECORDING_RESOLUTION, ParseValueList, _CapabilityImpl::ConvertCharToDimension, 0},
961 //      { CAMERA_SECONDARY_FOCUS_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_FOCUS_MODE_MAP },
962         { CAMERA_SECONDARY_FLIP, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_FLIP_TYPE_MAP },
963         { CAMERA_SECONDARY_PREVIEW_ROTATION, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ROTATION_MAP },
964 //      { CAMERA_SECONDARY_ZOOM_LEVEL, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0},
965         { CAMERA_SECONDARY_FOCUS_POINT, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
966 //      { CAMERA_SECONDARY_FLASH_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_FLASH_MODE_MAP },
967 //      { CAMERA_SECONDARY_DEFAULT_PREVIEW_FORMAT, ParseContent, _CapabilityImpl::ConvertCharToEnum, _PIXEL_FORMAT_MAP },
968 //      { CAMERA_SECONDARY_METERING_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_METERING_MODE_MAP },
969 //      { CAMERA_SECONDARY_SCENE_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_SCENE_MODE_MAP },
970
971         { PLAYER_AUDIO_CODEC, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
972         { PLAYER_COUNT_MAX, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
973         { PLAYER_PROTOCOL, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
974         { PLAYER_VIDEO_CODEC, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
975         { PLAYER_VIDEO_HEIGHT, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
976         { PLAYER_VIDEO_WIDTH, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
977
978         { VIDEORECORDER_CODEC, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
979
980         { VIDEORECORDER_AUDIO_CODEC, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
981         { VIDEORECORDER_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
982         { VIDEORECORDER_VIDEO_CODEC, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
983         { VIDEORECORDER_DEVICE_FPS, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
984
985 //      { VIDEORECORDER_AUDIO_CODEC_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CODEC_TYPE_MAP},
986 //      { VIDEORECORDER_VIDEO_CODEC_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CODEC_TYPE_MAP},
987 //      { VIDEORECORDER_MEDIA_CONTAINER_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _MEDIA_CONTAINER_TYPE_MAP},
988 };
989
990
991 void
992 _CapabilityImpl::ParseSection(xmlNode* pRoot, const String& section)
993 {
994         xmlNode* pNode = null;
995         result r = E_SUCCESS;
996
997         //capability xml buffer parsing loop
998         for (pNode = pRoot->children; pNode; pNode = pNode->next)
999         {
1000                 if (pNode->type == XML_ELEMENT_NODE)
1001                 {
1002                         String name((char*) pNode->name);
1003                         String key(section);
1004                         Object* pValue = 0;
1005                         key += "." + name;
1006
1007                         if (key.Equals(L"Camera.Primary", true) || key.Equals(L"Camera.Secondary", true))
1008                         {
1009                                 ParseSection(pNode, key);
1010                         }
1011                         else
1012                         {
1013                                 pValue = __pMap->GetValue(key);
1014
1015                                 for (int i = 0; i < (int)sizeof(_PARSING_INFO) / (int)sizeof(_PARSING_INFO[0]); i++)
1016                                 {
1017                                         if (key.Equals(_PARSING_INFO[i].pKey, true))
1018                                         {
1019                                                 Object* pRet = (_PARSING_INFO[i].parser)(pNode, pValue, _PARSING_INFO[i].convert, _PARSING_INFO[i].param);
1020                                                 if (pValue == null)
1021                                                 {
1022                                                         String* pKey = null;
1023                                                         pKey = new (std::nothrow) Tizen::Base::String(key);
1024                                                         SysTryReturnVoidResult(NID_MEDIA, pKey !=null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1025                                                         r = __pMap->Add(*pKey, *pRet);
1026                                                         SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1027                                                 }
1028                                                 break;
1029                                         }
1030                                 }
1031                         }
1032                 }
1033         }
1034 }
1035
1036 result
1037 _CapabilityImpl::ParseCapability(const char* pXmlBuffer, int length)
1038 {
1039         xmlDoc* pDoc = null;
1040         xmlNode* pRoot = null;
1041         xmlNode* pNode = null;
1042         result r = E_SUCCESS;
1043         String name;
1044
1045         pDoc = xmlParseMemory(pXmlBuffer, length);
1046         SysTryCatch(NID_MEDIA, pDoc != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. xmlParseMemory failed %s %d", pXmlBuffer, length);
1047
1048         pRoot = xmlDocGetRootElement(pDoc);
1049         SysTryCatch(NID_MEDIA, pRoot != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. xmlDocGetRootElement failed : %d %d", pDoc, pRoot);
1050
1051         name = (const char*) (pRoot->name);
1052         SysTryCatch(NID_MEDIA, name.Equals("MediaCapability", true), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid Root Name %ls", name.GetPointer());
1053
1054         for (pNode = pRoot->children; pNode; pNode = pNode->next)
1055         {
1056                 String countryName;
1057
1058                 if (pNode->type == XML_ELEMENT_NODE)
1059                 {
1060                         String name((char*) pNode->name);
1061                         ParseSection(pNode, name);
1062                 }
1063         }
1064
1065         xmlFreeDoc(pDoc);
1066         return E_SUCCESS;
1067
1068 CATCH:
1069         if (pDoc != null)
1070         {
1071                 xmlFreeDoc(pDoc);
1072         }
1073
1074         return r;
1075 }
1076
1077 result _CapabilityImpl::ParseCapability(_MediaCapCategoryType category)
1078 {
1079         result r = E_SUCCESS;
1080         SysTryCatch(NID_MEDIA, category > _MEDIA_CAP_CATEGORY_NONE && category <= _MEDIA_CAP_CATEGORY_CODEC
1081                 , r = E_INVALID_ARG, r, "[E_INVALID_ARG] Invalid argument(category) is used. category:%d", category);
1082         SysLog(NID_MEDIA, "Enter. category : %d", category);
1083
1084         switch(category)
1085         {
1086                 case _MEDIA_CAP_CATEGORY_AUDIO:
1087                         break;
1088
1089                 case _MEDIA_CAP_CATEGORY_IMAGE:
1090                         break;
1091
1092                 case _MEDIA_CAP_CATEGORY_PLAYER:
1093                         break;
1094
1095                 case _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA:
1096                 {
1097                         // For the performance, prevent the repeat camera object creation and deletion.
1098                         // This session will hold the ref count +1.
1099                         _ResultType itemType = _RESULT_NONE;
1100                         _CameraCapabilitySession cameraSession;
1101                         r = cameraSession.Construct(_CAMERA_DEVICE_PRIMARY);
1102                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1103
1104                         {
1105                                         String* pKey = null;
1106                                         Integer* pInteger = null;
1107
1108                                         pKey = new (std::nothrow) String(CAMERA_COUNT);
1109                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1110
1111                                         pInteger = new (std::nothrow) Integer(__cameraCount);
1112                                         SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1113
1114                                         r = __pMap->Add(*pKey, *pInteger);
1115                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1116                         }
1117
1118                         {
1119                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_CAPTURE_FORMAT, itemType);
1120                                 if (pList)
1121                                 {
1122                                         String* pKey = null;
1123                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_CAPTURE_FORMAT);
1124                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1125
1126                                         r = __pMap->Add(*pKey, *pList);
1127                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1128                                 }
1129                                 if (pList == null || pList->GetCount() == 0)
1130                                 {
1131                                         String* pKey = null;
1132                                         Integer* pInteger = null;
1133
1134                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_CAPTURE);
1135                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1136
1137                                         pInteger = new (std::nothrow) Integer(false);
1138                                         SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1139
1140                                         r = __pMap->Add(*pKey, *pInteger);
1141                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1142                                 }
1143                                 else
1144                                 {
1145                                         String* pKey = null;
1146                                         Integer* pInteger = null;
1147
1148                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_CAPTURE);
1149                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1150
1151                                         pInteger = new (std::nothrow) Integer(true);
1152                                         SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1153
1154                                         r = __pMap->Add(*pKey, *pInteger);
1155                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1156                                 }
1157                         }
1158
1159                         {
1160                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_CAPTURE_RESOLUTION, itemType);
1161                                 if (pList)
1162                                 {
1163                                         String* pKey = null;
1164                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_CAPTURE_RESOLUTION);
1165                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1166
1167                                         r = __pMap->Add(*pKey, *pList);
1168                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1169                                 }
1170                         }
1171
1172                         {
1173                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_EFFECT, itemType);
1174                                 if (pList)
1175                                 {
1176                                         String* pKey = null;
1177                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_EFFECT);
1178                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1179
1180                                         r = __pMap->Add(*pKey, *pList);
1181                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1182                                 }
1183                         }
1184
1185                         {
1186                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_ISO_LEVEL, itemType);
1187                                 if (pList)
1188                                 {
1189                                         String* pKey = null;
1190                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_ISO_LEVEL);
1191                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1192
1193                                         r = __pMap->Add(*pKey, *pList);
1194                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1195                                 }
1196                         }
1197
1198                         {
1199                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_PREVIEW_FORMAT, itemType);
1200                                 if (pList)
1201                                 {
1202                                         String* pKey = null;
1203                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_PREVIEW_FORMAT);
1204                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1205
1206                                         r = __pMap->Add(*pKey, *pList);
1207                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1208                                 }
1209                                 if (pList == null || pList->GetCount() == 0)
1210                                 {
1211                                         String* pKey = null;
1212                                         Integer* pInteger = null;
1213
1214                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_PREVIEW);
1215                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1216
1217                                         pInteger = new (std::nothrow) Integer(false);
1218                                         SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1219
1220                                         r = __pMap->Add(*pKey, *pInteger);
1221                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1222                                 }
1223                                 else
1224                                 {
1225                                         String* pKey = null;
1226                                         Integer* pInteger = null;
1227
1228                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_PREVIEW);
1229                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1230
1231                                         pInteger = new (std::nothrow) Integer(true);
1232                                         SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1233
1234                                         r = __pMap->Add(*pKey, *pInteger);
1235                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1236                                 }
1237                         }
1238
1239                         {
1240                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_PREVIEW_FRAMERATE, itemType);
1241                                 if (pList)
1242                                 {
1243                                         String* pKey = null;
1244                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_PREVIEW_FRAMERATE);
1245                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1246
1247                                         r = __pMap->Add(*pKey, *pList);
1248                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1249                                 }
1250                         }
1251
1252                         {
1253                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_PREVIEW_RESOLUTION, itemType);
1254                                 if (pList)
1255                                 {
1256                                         String* pKey = null;
1257                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_PREVIEW_RESOLUTION);
1258                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1259
1260                                         r = __pMap->Add(*pKey, *pList);
1261                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1262                                 }
1263                         }
1264
1265                         {
1266                                 String* pKey = null;
1267                                 Integer *pInteger = null;
1268
1269                                 pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_FLASH);
1270                                 SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1271
1272                                 pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_PRIMARY_FLASH_MODE));
1273                                 SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1274
1275                                 r = __pMap->Add(*pKey, *pInteger);
1276                                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1277                         }
1278
1279                         {
1280                                 String* pKey = null;
1281                                 Integer *pInteger = null;
1282
1283                                 pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_FOCUS);
1284                                 SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1285
1286                                 pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_PRIMARY_FOCUS_MODE));
1287                                 SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1288
1289                                 r = __pMap->Add(*pKey, *pInteger);
1290                                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1291                         }
1292
1293                         {
1294                                 String* pKey = null;
1295                                 Integer* pInteger = null;
1296
1297                                 pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_BRIGHTNESS);
1298                                 SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1299
1300                                 pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_PRIMARY_BRIGHTNESS));
1301                                 SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1302
1303                                 r = __pMap->Add(*pKey, *pInteger);
1304                                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1305                         }
1306
1307                         {
1308                                 String* pKey = null;
1309                                 Integer* pInteger = null;
1310
1311                                 pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_CONTRAST);
1312                                 SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1313
1314                                 pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_PRIMARY_CONTRAST));
1315                                 SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1316
1317                                 r = __pMap->Add(*pKey, *pInteger);
1318                                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1319                         }
1320
1321                         {
1322                                 String* pKey = null;
1323                                 Integer* pInteger = null;
1324
1325                                 pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_EXPOSURE);
1326                                 SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1327
1328                                 pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_PRIMARY_EXPOSURE));
1329                                 SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1330
1331                                 r = __pMap->Add(*pKey, *pInteger);
1332                                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1333                         }
1334 #if 0
1335                         {
1336                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_ZOOM_TYPE, itemType);
1337                                 if (pList)
1338                                 {
1339                                         String* pKey = null;
1340
1341                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_ZOOM_TYPE);
1342                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1343
1344                                         r = __pMap->Add(*pKey, *pList);
1345                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1346                                 }
1347                         }
1348 #endif
1349                         {
1350                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_FOCUS_MODE, itemType);
1351                                 if (pList)
1352                                 {
1353                                         String* pKey = null;
1354
1355                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_FOCUS_MODE);
1356                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1357
1358                                         r = __pMap->Add(*pKey, *pList);
1359                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1360                                 }
1361                         }
1362
1363                         {
1364                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_FLASH_MODE, itemType);
1365                                 if (pList)
1366                                 {
1367                                         String* pKey = null;
1368                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_FLASH_MODE);
1369                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1370
1371                                         r = __pMap->Add(*pKey, *pList);
1372                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1373                                 }
1374                         }
1375
1376                         {
1377                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_METERING_MODE, itemType);
1378                                 if (pList)
1379                                 {
1380                                         String* pKey = null;
1381
1382                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_METERING_MODE);
1383                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
1384
1385                                         r = __pMap->Add(*pKey, *pList);
1386                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1387                                 }
1388                         }
1389
1390                         {
1391                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_SCENE_MODE, itemType);
1392                                 if (pList)
1393                                 {
1394                                         String* pKey = null;
1395
1396                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_SCENE_MODE);
1397                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
1398
1399                                         r = __pMap->Add(*pKey, *pList);
1400                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1401                                 }
1402                         }
1403
1404                         {
1405                                 Object* pObj = _CameraCapability::GetValueN(_COP_PRIMARY_PREVIEW_FORMAT, _QUERY_DEFAULT_VALUE, itemType);
1406                                 if (pObj != null)
1407                                 {
1408                                         String* pKey = null;
1409                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_DEFAULT_PREVIEW_FORMAT);
1410                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
1411
1412                                         r = __pMap->Add(*pKey, *pObj);
1413                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1414                                 }
1415                         }
1416
1417                         {
1418                                 String* pKey = null;
1419                                 Integer* pInteger = null;
1420
1421                                 pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_ZOOM);
1422                                 SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1423
1424                                 pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_PRIMARY_ZOOM_LEVEL));
1425                                 SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1426
1427                                 r = __pMap->Add(*pKey, *pInteger);
1428                                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1429                         }
1430
1431                         {
1432                                 Object* pObj = _CameraCapability::GetValueN(_COP_PRIMARY_ZERO_SHUTTER_LAG, _QUERY_DEFAULT_VALUE, itemType);
1433                                 if (pObj != null)
1434                                 {
1435                                         String* pKey = null;
1436                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG);
1437                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
1438
1439                                         r = __pMap->Add(*pKey, *pObj);
1440                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1441                                 }
1442                         }
1443
1444                         {
1445                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_WHITE_BALANCE, itemType);
1446                                 if (pList)
1447                                 {
1448                                         String* pKey = null;
1449                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_WHITE_BALANCE);
1450                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1451
1452                                         r = __pMap->Add(*pKey, *pList);
1453                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1454                                 }
1455                         }
1456
1457                         {
1458                                 bool exist = false;
1459                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_RECORDING_RESOLUTION, itemType);
1460
1461                                 if (pList)
1462                                 {
1463                                         String* pKey = null;
1464                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_RECORDING_RESOLUTION);
1465                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1466
1467                                         r = __pMap->Add(*pKey, *pList);
1468                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1469                                         exist = true;
1470                                 }
1471
1472                                 if (exist)
1473                                 {
1474                                         String* pKey = null;
1475                                         Integer* pInteger = null;
1476
1477                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_RECORDING);
1478                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1479
1480                                         pInteger = new (std::nothrow) Integer(true);
1481                                         SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1482
1483                                         r = __pMap->Add(*pKey, *pInteger);
1484                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1485                                 }
1486                                 else
1487                                 {
1488                                         String* pKey = null;
1489                                         Integer* pInteger = null;
1490
1491                                         pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_RECORDING);
1492                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1493
1494                                         pInteger = new (std::nothrow) Integer(false);
1495                                         SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1496
1497                                         r = __pMap->Add(*pKey, *pInteger);
1498                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1499                                 }
1500                         }
1501                 }
1502                         break;
1503
1504                 case _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA:
1505                 {
1506                         // For the performance, prevent the repeat camera object creation and deletion.
1507                         // This session will hold the ref count +1.
1508                         _ResultType itemType = _RESULT_NONE;
1509                         _CameraCapabilitySession cameraSession;
1510                         r = cameraSession.Construct(_CAMERA_DEVICE_SECONDARY);
1511                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1512
1513                         {
1514                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_CAPTURE_FORMAT, itemType);
1515                                 if (pList)
1516                                 {
1517                                         String* pKey = null;
1518                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_CAPTURE_FORMAT);
1519                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1520
1521                                         r = __pMap->Add(*pKey, *pList);
1522                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1523                                 }
1524                                 if (pList == null || pList->GetCount() == 0)
1525                                 {
1526                                         String* pKey = null;
1527                                         Integer* pInteger = null;
1528
1529                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_CAPTURE);
1530                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1531
1532                                         pInteger = new (std::nothrow) Integer(false);
1533                                         SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1534
1535                                         r = __pMap->Add(*pKey, *pInteger);
1536                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1537                                 }
1538                                 else
1539                                 {
1540                                         String* pKey = null;
1541                                         Integer* pInteger = null;
1542
1543                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_CAPTURE);
1544                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1545
1546                                         pInteger = new (std::nothrow) Integer(true);
1547                                         SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1548
1549                                         r = __pMap->Add(*pKey, *pInteger);
1550                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1551                                 }
1552                         }
1553
1554                         {
1555                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_CAPTURE_RESOLUTION, itemType);
1556                                 if (pList)
1557                                 {
1558                                         String* pKey = null;
1559                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_CAPTURE_RESOLUTION);
1560                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1561
1562                                         r = __pMap->Add(*pKey, *pList);
1563                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1564                                 }
1565                         }
1566
1567                         {
1568                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_EFFECT, itemType);
1569                                 if (pList)
1570                                 {
1571                                         String* pKey = null;
1572                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_EFFECT);
1573                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1574
1575                                         r = __pMap->Add(*pKey, *pList);
1576                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1577                                 }
1578                         }
1579
1580                         {
1581                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_ISO_LEVEL, itemType);
1582                                 if (pList)
1583                                 {
1584                                         String* pKey = null;
1585                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_ISO_LEVEL);
1586                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1587
1588                                         r = __pMap->Add(*pKey, *pList);
1589                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1590                                 }
1591                         }
1592
1593                         {
1594                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_PREVIEW_FORMAT, itemType);
1595                                 if (pList)
1596                                 {
1597                                         String* pKey = null;
1598                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_PREVIEW_FORMAT);
1599                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1600
1601                                         r = __pMap->Add(*pKey, *pList);
1602                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1603                                 }
1604                                 if (pList == null || pList->GetCount() == 0)
1605                                 {
1606                                         String* pKey = null;
1607                                         Integer* pInteger = null;
1608
1609                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_PREVIEW);
1610                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1611
1612                                         pInteger = new (std::nothrow) Integer(false);
1613                                         SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1614
1615                                         r = __pMap->Add(*pKey, *pInteger);
1616                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1617                                 }
1618                                 else
1619                                 {
1620                                         String* pKey = null;
1621                                         Integer* pInteger = null;
1622
1623                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_PREVIEW);
1624                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1625
1626                                         pInteger = new (std::nothrow) Integer(true);
1627                                         SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1628
1629                                         r = __pMap->Add(*pKey, *pInteger);
1630                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1631                                 }
1632                         }
1633
1634                         {
1635                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_PREVIEW_FRAMERATE, itemType);
1636                                 if (pList)
1637                                 {
1638                                         String* pKey = null;
1639                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_PREVIEW_FRAMERATE);
1640                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1641
1642                                         r = __pMap->Add(*pKey, *pList);
1643                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1644                                 }
1645                         }
1646
1647                         {
1648                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_PREVIEW_RESOLUTION, itemType);
1649                                 if (pList)
1650                                 {
1651                                         String* pKey = null;
1652                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_PREVIEW_RESOLUTION);
1653                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1654
1655                                         r = __pMap->Add(*pKey, *pList);
1656                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1657                                 }
1658                         }
1659
1660                         {
1661                                 String* pKey = null;
1662                                 Integer *pInteger = null;
1663
1664                                 pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_FLASH);
1665                                 SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1666
1667                                 pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_SECONDARY_FLASH_MODE));
1668                                 SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1669
1670                                 r = __pMap->Add(*pKey, *pInteger);
1671                                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1672                         }
1673
1674                         {
1675                                 String* pKey = null;
1676                                 Integer *pInteger = null;
1677
1678                                 pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_FOCUS);
1679                                 SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1680
1681                                 pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_SECONDARY_FOCUS_MODE));
1682                                 SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1683
1684                                 r = __pMap->Add(*pKey, *pInteger);
1685                                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1686                         }
1687
1688                         {
1689                                 String* pKey = null;
1690                                 Integer* pInteger = null;
1691
1692                                 pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_BRIGHTNESS);
1693                                 SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1694
1695                                 pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_SECONDARY_BRIGHTNESS));
1696                                 SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1697
1698                                 r = __pMap->Add(*pKey, *pInteger);
1699                                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1700                         }
1701
1702                         {
1703                                 String* pKey = null;
1704                                 Integer* pInteger = null;
1705
1706                                 pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_CONTRAST);
1707                                 SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1708
1709                                 pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_SECONDARY_CONTRAST));
1710                                 SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1711
1712                                 r = __pMap->Add(*pKey, *pInteger);
1713                                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1714                         }
1715
1716                         {
1717                                 String* pKey = null;
1718                                 Integer* pInteger = null;
1719
1720                                 pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_EXPOSURE);
1721                                 SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1722
1723                                 pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_SECONDARY_EXPOSURE));
1724                                 SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1725
1726                                 r = __pMap->Add(*pKey, *pInteger);
1727                                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1728                         }
1729
1730                         {
1731                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_FOCUS_MODE, itemType);
1732                                 if (pList)
1733                                 {
1734                                         String* pKey = null;
1735
1736                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_FOCUS_MODE);
1737                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1738
1739                                         r = __pMap->Add(*pKey, *pList);
1740                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1741                                 }
1742                         }
1743
1744                         {
1745                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_FLASH_MODE, itemType);
1746                                 if (pList)
1747                                 {
1748                                         String* pKey = null;
1749                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_FLASH_MODE);
1750                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1751
1752                                         r = __pMap->Add(*pKey, *pList);
1753                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1754                                 }
1755                         }
1756
1757                         {
1758                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_METERING_MODE, itemType);
1759                                 if (pList)
1760                                 {
1761                                         String* pKey = null;
1762
1763                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_METERING_MODE);
1764                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
1765
1766                                         r = __pMap->Add(*pKey, *pList);
1767                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1768                                 }
1769                         }
1770
1771                         {
1772                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_SCENE_MODE, itemType);
1773                                 if (pList)
1774                                 {
1775                                         String* pKey = null;
1776
1777                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_SCENE_MODE);
1778                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
1779
1780                                         r = __pMap->Add(*pKey, *pList);
1781                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1782                                 }
1783                         }
1784
1785                         {
1786                                 Object* pObj = _CameraCapability::GetValueN(_COP_SECONDARY_PREVIEW_FORMAT, _QUERY_DEFAULT_VALUE, itemType);
1787                                 if (pObj != null)
1788                                 {
1789                                         String* pKey = null;
1790                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_DEFAULT_PREVIEW_FORMAT);
1791                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
1792
1793                                         r = __pMap->Add(*pKey, *pObj);
1794                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1795                                 }
1796                         }
1797
1798                         {
1799                                 String* pKey = null;
1800                                 Integer* pInteger = null;
1801
1802                                 pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_ZOOM);
1803                                 SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1804
1805                                 pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_SECONDARY_ZOOM_LEVEL));
1806                                 SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1807
1808                                 r = __pMap->Add(*pKey, *pInteger);
1809                                 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1810                         }
1811
1812                         {
1813                                 Object* pObj = _CameraCapability::GetValueN(_COP_SECONDARY_ZERO_SHUTTER_LAG, _QUERY_DEFAULT_VALUE, itemType);
1814                                 if (pObj != null)
1815                                 {
1816                                         String* pKey = null;
1817                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG);
1818                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
1819
1820                                         r = __pMap->Add(*pKey, *pObj);
1821                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1822                                 }
1823                         }
1824
1825                         {
1826                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_WHITE_BALANCE, itemType);
1827                                 if (pList)
1828                                 {
1829                                         String* pKey = null;
1830                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_WHITE_BALANCE);
1831                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1832
1833                                         r = __pMap->Add(*pKey, *pList);
1834                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1835                                 }
1836                         }
1837
1838                         {
1839                                 bool exist = false;
1840                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_RECORDING_RESOLUTION, itemType);
1841
1842                                 if (pList)
1843                                 {
1844                                         String* pKey = null;
1845                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_RECORDING_RESOLUTION);
1846                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1847
1848                                         r = __pMap->Add(*pKey, *pList);
1849                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1850                                         exist = true;
1851                                 }
1852
1853                                 if (exist)
1854                                 {
1855                                         String* pKey = null;
1856                                         Integer* pInteger = null;
1857
1858                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_RECORDING);
1859                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1860
1861                                         pInteger = new (std::nothrow) Integer(true);
1862                                         SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1863
1864                                         r = __pMap->Add(*pKey, *pInteger);
1865                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1866                                 }
1867                                 else
1868                                 {
1869                                         String* pKey = null;
1870                                         Integer* pInteger = null;
1871
1872                                         pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_RECORDING);
1873                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1874
1875                                         pInteger = new (std::nothrow) Integer(false);
1876                                         SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
1877
1878                                         r = __pMap->Add(*pKey, *pInteger);
1879                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1880                                 }
1881                         }
1882                 }
1883                         break;
1884
1885                 case _MEDIA_CAP_CATEGORY_VIDEO_RECORDER:
1886                 {
1887                         _ResultType itemType = _RESULT_NONE;
1888                         {
1889                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _RecorderCapability::GetListN(_VROP_FILE_FORMAT, itemType);
1890
1891                                 if (pList)
1892                                 {
1893                                         String* pKey = null;
1894
1895                                         pKey = new (std::nothrow) String(VIDEORECORDER_MEDIA_CONTAINER_TYPE);
1896                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1897
1898                                         r = __pMap->Add(*pKey, *pList);
1899                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1900                                 }
1901                         }
1902
1903                         {
1904                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _RecorderCapability::GetListN(_VROP_VIDEO_ENCODER, itemType);
1905
1906                                 if (pList)
1907                                 {
1908                                         String* pKey = null;
1909
1910                                         pKey = new (std::nothrow) String(VIDEORECORDER_VIDEO_CODEC_TYPE);
1911                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1912
1913                                         r = __pMap->Add(*pKey, *pList);
1914                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1915                                 }
1916                         }
1917
1918                         {
1919                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _RecorderCapability::GetListN(_VROP_AUDIO_ENCODER, itemType);
1920
1921                                 if (pList)
1922                                 {
1923                                         String* pKey = null;
1924
1925                                         pKey = new (std::nothrow) String(VIDEORECORDER_AUDIO_CODEC_TYPE);
1926                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1927
1928                                         r = __pMap->Add(*pKey, *pList);
1929                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1930                                 }
1931                         }
1932                 }
1933                         break;
1934
1935                 case _MEDIA_CAP_CATEGORY_AUDIO_RECORDER:
1936                 {
1937                         _ResultType itemType = _RESULT_NONE;
1938                         _RecorderSession recorderSession;
1939                         r = recorderSession.Construct(_RECORDER_SOURCE_AUDIO);
1940                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1941
1942                         {
1943                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _RecorderCapability::GetListN(_AROP_FILE_FORMAT, itemType);
1944
1945                                 if (pList)
1946                                 {
1947                                         String* pKey = null;
1948
1949                                         pKey = new (std::nothrow) String(AUDIORECORDER_MEDIA_CONTAINER_TYPE);
1950                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1951
1952                                         r = __pMap->Add(*pKey, *pList);
1953                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1954                                 }
1955                         }
1956
1957                         {
1958                                 _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _RecorderCapability::GetListN(_AROP_AUDIO_ENCODER, itemType);
1959
1960                                 if (pList)
1961                                 {
1962                                         String* pKey = null;
1963
1964                                         pKey = new (std::nothrow) String(AUDIORECORDER_CODEC_TYPE);
1965                                         SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
1966
1967                                         r = __pMap->Add(*pKey, *pList);
1968                                         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1969                                 }
1970                         }
1971                 }
1972                         break;
1973
1974                 case _MEDIA_CAP_CATEGORY_CODEC:
1975                         break;
1976
1977                 default:
1978                         break;
1979         }
1980
1981         return r;
1982 CATCH:
1983         return r;
1984 }
1985
1986 }}// Tizen::Media
1987