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 Karol Majewski (k.majewski@samsung.com)
22 #include "CameraManager.h"
23 #include "mm_camcorder.h"
24 #include <commons/Exception.h>
25 #include <API/Camera/EventGetCameras.h>
26 #include <API/Camera/ICamera.h>
29 namespace WrtPlugins {
32 //.............................................................................
33 void CameraManager::OnRequestReceived(
34 const Api::Camera::EventGetCamerasPtr &event)
36 LogDebug(__FUNCTION__);
39 DPL::Mutex::ScopedLock lock(&m_accessMutex);
41 if (m_cameras.empty()) {
42 for (int i = (MM_VIDEO_DEVICE_NONE + 1);
43 i < MM_VIDEO_DEVICE_NUM;
46 "current camera i=" << i <<
47 " (mm_video_device_num: " << MM_VIDEO_DEVICE_NUM);
49 cam_info.videodev_type = static_cast<MMVideoDeviceType>(i);
50 Camera *icamera = new Camera();
51 m_cameras.push_back(Api::Camera::ICameraSharedPtr(icamera));
52 icamera->init(cam_info);
55 event->setCamerasRef(m_cameras, MM_VIDEO_DEVICE_CAMERA0);
57 LogDebug("Nr of cameras: " << m_cameras.size());
60 catch (Commons::Exception &exc)
62 LogError("Exception has occurred: " << std::hex << exc.getCode());
63 event->setExceptionCode(exc.getCode());
66 //.............................................................................