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 "WrtCamera.h"
23 #include <dpl/log/log.h>
24 #include <Commons/Exception.h>
26 namespace WrtDeviceApis {
29 WrtCamera::WrtCamera(int widgetId,
30 const engine_interface_t* interface,
31 CameraInstance camera,
32 camera_type /*type*/) :
38 LogError("Pointer to interface is NULL");
42 void WrtCamera::createPreviewNode(CameraPreviewSuccessCb successCallback,
43 CameraErrorCb errorCallback,
44 SetPendingOperationCb setPendingOperationCb,
48 !m_wrt->wrt_camera_create_preview_node)
50 LogError("Error: Security error");
51 Throw(SecurityException);
54 if (m_wrt->wrt_camera_create_preview_node(
59 setPendingOperationCb,
62 LogError("Error: Platform error when create_preview_node");
63 Throw(PlatformException);
67 void WrtCamera::captureImage(const std::string& filename,
69 CameraCaptureSuccessCb successCallback,
70 CameraErrorCb errorCallback,
71 SetPendingOperationCb setPendingOperationCb,
75 !m_wrt->wrt_camera_capture_image)
77 LogError("Error: Security error");
78 Throw(SecurityException);
81 if (m_wrt->wrt_camera_capture_image(
88 setPendingOperationCb,
91 LogError("Error: Platform error when capture_image");
92 Throw(PlatformException);
96 void WrtCamera::startVideoCapture(const std::string& filename,
98 CameraCaptureSuccessCb successCallback,
99 CameraErrorCb errorCallback,
100 SetPendingOperationCb setPendingOperationCb,
104 !m_wrt->wrt_camera_start_video_capture)
106 LogError("Error: Security error");
107 Throw(SecurityException);
110 if (m_wrt->wrt_camera_start_video_capture(
117 setPendingOperationCb,
120 LogError("Error: Platform error when start video");
121 Throw(PlatformException);
125 void WrtCamera::stopVideoCapture()
128 !m_wrt->wrt_camera_stop_video_capture)
130 LogError("Error: Security error");
131 Throw(SecurityException);
134 if (m_wrt->wrt_camera_stop_video_capture(m_widgetId, m_camera)) {
135 LogError("Error: Platform error when start video");
136 Throw(PlatformException);
140 void WrtCamera::cancelAsyncOperation (
141 const IWrtCamera::CameraPendingOperation& pendingOperation)
144 !m_wrt->wrt_camera_cancel_async_operation)
146 LogError("Error: Security error");
147 Throw(SecurityException);
150 if (m_wrt->wrt_camera_cancel_async_operation(m_widgetId,
154 LogError("Error: Platform error when start video");
155 Throw(PlatformException);
159 WrtCamera::~WrtCamera()
162 !m_wrt->wrt_camera_remove_camera)
164 LogError("Error: Security error");
165 Throw(SecurityException);
168 if (m_wrt->wrt_camera_remove_camera(m_widgetId, m_camera)) {
169 LogError("Error: Platform error when removing camera");
171 // Throw(PlatformException);
174 LogDebug("Camera instance removed");
178 } // WrtDeviceApisCommon