2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
22 #include "WrtCameraManager.h"
23 #include <dpl/log/log.h>
24 #include <Commons/Exception.h>
25 #include "WrtCamera.h"
27 namespace WrtDeviceApis {
30 WrtCameraManager::WrtCameraManager(int widgetId,
31 const engine_interface_t* interface)
32 : m_widgetId(widgetId)
37 LogError("Pointer to interface is NULL");
40 m_cameras = WrtCamerasPtr(new WrtCameras);
44 IWrtCameraManager::WrtCamerasPtr WrtCameraManager::getCameras()
46 static bool initialized = initialize();
52 bool WrtCameraManager::initialize()
55 !m_wrt->wrt_camera_get_cameras ||
56 !m_wrt->wrt_camera_free_webkit_cameras)
58 LogError("Error: Security error");
59 Throw(SecurityException);
62 webkit_cameras_array *array = m_wrt->wrt_camera_get_cameras(m_widgetId);
64 LogError("Error: Platform error when get_cameras");
65 Throw(PlatformException);
68 for (size_t i = 0; i < array->size; ++i) {
70 IWrtCameraPtr(new WrtCamera(m_widgetId,
72 array->webkit_cameras[i].camera,
73 array->webkit_cameras[i].type)));
83 } // WrtDeviceApisCommon