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