tizen beta release
[framework/web/wrt-plugins-common.git] / src / modules / API / Camera / ICamera.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /*
17  * @author      Karol Majewski (k.majewski@samsung.com)
18  * @version     0.1
19  * @brief
20  */
21
22 #ifndef WRTDEVICEAPIS_CAMERA_API_ICAMERA_H_
23 #define WRTDEVICEAPIS_CAMERA_API_ICAMERA_H_
24
25 #include <string>
26 #include <unistd.h>
27 #include <dpl/shared_ptr.h>
28 #include <Commons/ThreadPool.h>
29 #include <Commons/EventReceiver.h>
30 #include <Commons/IExternEventCanceler.h>
31 #include "EventBeginRecording.h"
32 #include "EventEndRecording.h"
33 #include "EventTakePicture.h"
34 #include "EventGetPreviewNode.h"
35
36
37 namespace WrtDeviceApis {
38 namespace Camera {
39 namespace Api {
40
41 typedef Commons::EventRequestReceiver<EventTakePicture>
42     EventSupportTakePicture;
43 typedef Commons::EventRequestReceiver<EventBeginRecording>
44     EventSupportBeginRecording;
45 typedef Commons::EventRequestReceiver<EventEndRecording>
46     EventSupportEndRecording;
47 typedef Commons::EventRequestReceiver<EventGetPreviewNode>
48     EventSupportGetPreviewNode;
49
50 typedef Commons::IExternEventCanceler<EventBeginRecording>
51     SupportCancelRecording;
52 typedef Commons::IExternEventCanceler<EventTakePicture>
53     SupportCancelTakePicture;
54 typedef Commons::IExternEventCanceler<EventGetPreviewNode>
55     SupportCancelGetPreview;
56 typedef Commons::ThreadEnum Thread;
57
58 class ICamera : public EventSupportTakePicture,
59                 public EventSupportBeginRecording,
60                 public EventSupportEndRecording,
61                 public EventSupportGetPreviewNode,
62                 public SupportCancelRecording,
63                 public SupportCancelTakePicture,
64                 public SupportCancelGetPreview
65 {
66 public:
67     ICamera() :
68         EventSupportTakePicture(Thread::CAMERA_THREAD),
69         EventSupportBeginRecording(Thread::CAMERA_THREAD),
70         EventSupportEndRecording(Thread::CAMERA_THREAD),
71         EventSupportGetPreviewNode(Thread::CAMERA_THREAD)
72     {
73     }
74
75     virtual std::string getDescription() const
76     {
77         return "";
78     }
79
80     /**
81      * Takes picture
82      */
83     void takePicture(const EventTakePictureSharedPtr &event)
84     {
85         EventSupportTakePicture::PostRequest(event);
86     }
87
88     /**
89      * Begins recording
90      */
91     virtual void beginRecording(const EventBeginRecordingSharedPtr &event)
92     {
93         EventSupportBeginRecording::PostRequest(event);
94     }
95
96     /**
97      * Ends recording
98      */
99     virtual void endRecording(const EventEndRecordingSharedPtr &event,
100                               double delay = 0.0)
101     {
102         EventSupportEndRecording::PostRequest(event,delay);
103     }
104
105     /**
106      * Requests preview window
107      */
108     void createPreview(const EventGetPreviewNodeSharedPtr &event)
109     {
110         EventSupportGetPreviewNode::PostRequest(event);
111     }
112
113     virtual void OnCancelEvent(const EventBeginRecordingSharedPtr& /*event*/) {}
114     virtual void OnCancelEvent(const EventTakePictureSharedPtr& /*event*/) {}
115     virtual void OnCancelEvent(const EventGetPreviewNodeSharedPtr& /*event*/) {}
116
117     virtual void OnRequestReceived(
118             const EventTakePictureSharedPtr &event) = 0;
119     virtual void OnRequestReceived(
120             const EventBeginRecordingSharedPtr &event) = 0;
121     virtual void OnRequestReceived(
122             const EventEndRecordingSharedPtr &event) = 0;
123     virtual void OnRequestReceived(
124             const EventGetPreviewNodeSharedPtr &event) = 0;
125
126     virtual ~ICamera()
127     {
128     }
129 };
130
131 typedef DPL::SharedPtr<ICamera> ICameraSharedPtr;
132
133 }
134 }
135 }
136 #endif /* */