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 #ifndef WRTPLUGINSCAMERA_H_
23 #define WRTPLUGINSCAMERA_H_
28 #include <mm_camcorder.h>
29 #include <dpl/log/log.h>
30 #include <dpl/generic_event.h>
31 #include <dpl/event/controller.h>
32 #include <dpl/type_list.h>
33 #include <API/Camera/ICamera.h>
34 #include <API/Camera/ICaptureOptions.h>
35 #include <API/Camera/EventTakePicture.h>
36 #include <API/Camera/EventBeginRecording.h>
37 #include <API/Camera/EventEndRecording.h>
38 #include <API/Camera/EventRequestLiveVideo.h>
39 #include <platform/commons/Dimension.h>
41 namespace WrtPlugins {
44 DECLARE_GENERIC_EVENT_0(JobDoneEvent)
45 //=============================================================================
46 class Camera : public Api::Camera::ICamera,
47 public DPL::Event::Controller<DPL::TypeListDecl<JobDoneEvent>::Type >
52 IDLE, //camera is ready to take action
53 PROCESSING, //camera object is under destruction or performing some inner operations - can't change the state
54 CAPTURING_IMAGE, //image capture is in progress
55 CAPTURING_VIDEO //video capture is in progress
59 typedef Dimension Resolution;
63 /*setting some default attributes for camcorder*/
64 void setDefaultAttributes();
66 * Sets camcorder attributes based on capture options
68 void setCaptureOptions(
69 const Api::Camera::ICaptureOptionsPtr &captureOptions);
72 * checks if given error code means invalid parameter
74 void tryIsInvalidParameterError(int errorCode);
76 MMCamPreset m_camcorderPreset;
78 MMHandleType m_camcorderHandle;
81 * Current camera state
88 pthread_mutex_t m_stateMutex;
90 int reInitializeCamcorderForPicture(
91 const Api::Camera::ICaptureOptionsPtr &captureOptions);
93 int reInitializeCamcorderForVideo(
94 const Api::Camera::ICaptureOptionsPtr &captureOptions);
97 * Wrapper for realizing camcorder
99 bool realizeCamcoder();
102 * Wrapper for unrealizing camcorder
104 int unRealizeCamcoder();
106 /* Body of the callback function msg_callback */
107 static int camcorderMessageCallback(int msg_type,
111 static int camcorderVideoCaptureCallback(MMCamcorderCaptureDataType *src,
112 MMCamcorderCaptureDataType *thumb,
115 CameraState getState() const
120 void setState(CameraState newState)
125 static int lockCameraMutex(Camera *camera);
127 static void unlockCameraMutex(Camera *camera);
129 /* logs current camcorder state*/
130 void logCamcorderState();
132 Resolution getCaptureResolution(bool low) const;
134 Api::Camera::EventTakePictureSharedPtr m_eventTakePicture;
135 Api::Camera::EventBeginRecordingSharedPtr m_eventBeginRecording;
136 Api::Camera::EventEndRecordingSharedPtr m_eventEndRecording;
137 Api::Camera::EventRequestLiveVideoSharedPtr m_eventRequestLiveVideo;
141 void init(MMCamPreset preset);
144 virtual void OnRequestReceived(
145 const Api::Camera::EventTakePictureSharedPtr &event);
146 virtual void OnRequestReceived(
147 const Api::Camera::EventBeginRecordingSharedPtr &event);
148 virtual void OnRequestReceived(
149 const Api::Camera::EventEndRecordingSharedPtr &event);
150 virtual void OnRequestReceived(
151 const Api::Camera::EventRequestLiveVideoSharedPtr &event);
152 virtual void OnEventReceived(const JobDoneEvent &event);
154 virtual std::string getDescription() const;
156 //=============================================================================
160 #endif /* WRTPLUGINSCAMERA_H_ */