6a6fc44dd2ca06437cbbd73aed9c6cc20fa0bc1d
[framework/web/wrt-plugins-common.git] / src / modules / API / Camera / ICaptureOptions.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_ICAPTUREOPTIONS_H_
23 #define WRTDEVICEAPIS_CAMERA_API_ICAPTUREOPTIONS_H_
24
25 #include <string>
26 #include <dpl/shared_ptr.h>
27
28 namespace WrtDeviceApis {
29 namespace Camera {
30 namespace Api {
31
32 class ICaptureOptions
33 {
34   public:
35
36     /**
37      * Available attributes
38      */
39     enum AttributesFlags
40     {
41         SETTED_WIDTH = 1 << 0,
42         SETTED_HEIGHT = 1 << 1,
43         SETTED_FRAME_RATE = 1 << 2,
44         SETTED_MAX_BITRATE = 1 << 3,
45         SETTED_FILE_NAME = 1 << 4,
46         SETTED_IMAGE_RESOLUTION = 1 << 5
47     };
48
49     /**
50      * Available picture details levels
51      */
52     enum ImageResolution
53     {
54         IMAGE_RESOLUTION_HIGH,
55         IMAGE_RESOLUTION_LOW,
56         IMAGE_RESOLUTION_DEFAULT
57     };
58
59     ICaptureOptions() :
60         m_settedFlags(0),
61         m_width(0),
62         m_height(0),
63         m_frameRate(0.0),
64         m_imageResolution(IMAGE_RESOLUTION_DEFAULT),
65         m_maximumBitrate(0),
66         m_overwrite(true)
67     {
68     }
69
70     virtual ~ICaptureOptions()
71     {
72     }
73
74     /**
75      * Check for attribute correctness
76      */
77     bool isAttributeValid(const AttributesFlags flag) const
78     {
79         return (flag & m_settedFlags) == flag;
80     }
81
82     /**
83      * Gets frame rate
84      */
85     float getFrameRate() const
86     {
87         return m_frameRate;
88     }
89
90     /**
91      * Gets height
92      */
93     unsigned short getHeight() const
94     {
95         return m_height;
96     }
97
98     /**
99      * Gets video maximum bitrate
100      */
101     unsigned long getMaximumBitrate() const
102     {
103         return m_maximumBitrate;
104     }
105
106     /**
107      * Gets image resolution
108      */
109     ImageResolution getImageResolution() const
110     {
111         return m_imageResolution;
112     }
113
114     /**
115      * Gets filename
116      */
117     std::string getFileName() const
118     {
119         return m_capturedFileName;
120     }
121
122     /**
123      * Gets width
124      */
125     unsigned short getWidth() const
126     {
127         return m_width;
128     }
129
130     /**
131      * Gets whether output file should be overwritten if already exists.
132      * @return True if should be overwritten, false otherwise.
133      */
134     bool getOverwrite() const
135     {
136         return m_overwrite;
137     }
138
139     /**
140      * Sets video frame rate
141      */
142     void setFrameRate(float frameRate)
143     {
144         this->m_frameRate = frameRate;
145         setFlag(SETTED_FRAME_RATE);
146     }
147
148     /**
149      * Sets height
150      */
151     void setHeight(unsigned short height)
152     {
153         this->m_height = height;
154         setFlag(SETTED_HEIGHT);
155     }
156
157     /**
158      * Sets video maximum bitrate
159      */
160     void setMaximumBitrate(unsigned long maximumBitrate)
161     {
162         this->m_maximumBitrate = maximumBitrate;
163         setFlag(SETTED_MAX_BITRATE);
164     }
165
166     /**
167      * Sets image resolution
168      */
169     void setImageResolution(ImageResolution imageResolution)
170     {
171         this->m_imageResolution = imageResolution;
172         setFlag(SETTED_IMAGE_RESOLUTION);
173     }
174
175     /**
176      * Sets filename
177      */
178     void setFileName(const std::string &fileName)
179     {
180         this->m_capturedFileName = fileName;
181         setFlag(SETTED_FILE_NAME);
182     }
183
184     /**
185      * Sets width
186      */
187     void setWidth(unsigned short width)
188     {
189         this->m_width = width;
190         setFlag(SETTED_WIDTH);
191     }
192
193     /**
194      * Sets if output file should be overwritten if already exists.
195      * @param overwrite
196      */
197     void setOverwrite(bool overwrite)
198     {
199         m_overwrite = overwrite;
200     }
201
202   private:
203
204     unsigned short m_settedFlags;
205
206     void setFlag(AttributesFlags flag)
207     {
208         m_settedFlags = m_settedFlags | flag;
209     }
210
211     //The desired width of the video or picture
212     unsigned short m_width;
213
214     //The desired height of the video or picture.
215     unsigned short m_height;
216
217     //The desired frame rate for video records.
218     float m_frameRate;
219
220     //The desired resolution of a picture.
221     ImageResolution m_imageResolution;
222
223     //The desired name of file with captured data
224     std::string m_capturedFileName;
225
226     //The desired maximum bit rate of the recorded video media.
227     unsigned long m_maximumBitrate;
228
229     /**
230      * Indicates whether file should be overwritten if already exists.
231      */
232     bool m_overwrite;
233 };
234
235 typedef DPL::SharedPtr<ICaptureOptions> ICaptureOptionsPtr;
236
237 }
238 }
239 }
240 #endif /* WRTPLUGINSICAPTUREOPTIONS_H_ */