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)
21 #include <dpl/foreach.h>
22 #include "CameraManager.h"
23 #include <Commons/Exception.h>
24 #include <API/Camera/EventGetCameras.h>
25 #include <API/Camera/ICamera.h>
28 namespace WrtDeviceApis {
31 void CameraManager::OnRequestReceived(
32 const Api::EventGetCamerasPtr &event)
34 LogDebug(__FUNCTION__);
37 if (m_cameras.empty()) {
38 DPL::Mutex::ScopedLock lock(&m_accessMutex);
40 if (m_cameras.empty()) {
41 Commons::IWrtCameraManager::WrtCamerasPtr cameras;
45 getCameraManagerInterface()->
50 Api::ICameraSharedPtr icamera(new Camera(*it));
51 m_cameras.push_back(icamera);
55 event->setCamerasRef(m_cameras,0);
56 LogDebug("Nr of cameras: " << m_cameras.size());
58 catch(const Commons::Exception &exc)
60 LogError("Exception has occurred: " << std::hex << exc.getCode());
61 event->setExceptionCode(exc.getCode());