|
1 /* GStreamer |
|
2 * |
|
3 * Copyright (C) 2008 Nokia Corporation <multimedia@maemo.org> |
|
4 * |
|
5 * photography.c: photography interface for digital imaging |
|
6 * |
|
7 * |
|
8 * This library is free software; you can redistribute it and/or |
|
9 * modify it under the terms of the GNU Library General Public |
|
10 * License as published by the Free Software Foundation; either |
|
11 * version 2 of the License, or (at your option) any later version. |
|
12 * |
|
13 * This library is distributed in the hope that it will be useful, |
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 * Library General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU Library General Public |
|
19 * License along with this library; if not, write to the |
|
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
21 * Boston, MA 02111-1307, USA. |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include "config.h" |
|
26 #endif |
|
27 |
|
28 #include "photography.h" |
|
29 |
|
30 /** |
|
31 * SECTION:photography |
|
32 * @short_description: Interface for elements having digital imaging controls |
|
33 * |
|
34 * The interface allows access to some common digital imaging controls |
|
35 */ |
|
36 |
|
37 static void gst_photography_iface_init (GstPhotographyInterface * iface); |
|
38 |
|
39 EXPORT_C GType |
|
40 gst_photography_get_type (void) |
|
41 { |
|
42 static GType gst_photography_type = 0; |
|
43 |
|
44 if (!gst_photography_type) { |
|
45 static const GTypeInfo gst_photography_info = { |
|
46 sizeof (GstPhotographyInterface), |
|
47 (GBaseInitFunc) gst_photography_iface_init, |
|
48 NULL, |
|
49 NULL, |
|
50 NULL, |
|
51 NULL, |
|
52 0, |
|
53 0, |
|
54 NULL, |
|
55 }; |
|
56 |
|
57 gst_photography_type = g_type_register_static (G_TYPE_INTERFACE, |
|
58 "GstPhotography", &gst_photography_info, 0); |
|
59 g_type_interface_add_prerequisite (gst_photography_type, |
|
60 GST_TYPE_IMPLEMENTS_INTERFACE); |
|
61 } |
|
62 |
|
63 return gst_photography_type; |
|
64 } |
|
65 |
|
66 static void |
|
67 gst_photography_iface_init (GstPhotographyInterface * iface) |
|
68 { |
|
69 /* default virtual functions */ |
|
70 iface->get_ev_compensation = NULL; |
|
71 iface->get_iso_speed = NULL; |
|
72 iface->get_aperture = NULL; |
|
73 iface->get_exposure = NULL; |
|
74 iface->get_white_balance_mode = NULL; |
|
75 iface->get_colour_tone_mode = NULL; |
|
76 iface->get_scene_mode = NULL; |
|
77 iface->get_flash_mode = NULL; |
|
78 iface->get_zoom = NULL; |
|
79 |
|
80 iface->set_ev_compensation = NULL; |
|
81 iface->set_iso_speed = NULL; |
|
82 iface->set_aperture = NULL; |
|
83 iface->set_exposure = NULL; |
|
84 iface->set_white_balance_mode = NULL; |
|
85 iface->set_colour_tone_mode = NULL; |
|
86 iface->set_scene_mode = NULL; |
|
87 iface->set_flash_mode = NULL; |
|
88 iface->set_zoom = NULL; |
|
89 |
|
90 iface->get_capabilities = NULL; |
|
91 iface->prepare_for_capture = NULL; |
|
92 iface->set_autofocus = NULL; |
|
93 } |
|
94 |
|
95 #define GST_PHOTOGRAPHY_FUNC_TEMPLATE(function_name, param_type) \ |
|
96 EXPORT_C gboolean \ |
|
97 gst_photography_set_ ## function_name (GstPhotography * photo, param_type param) \ |
|
98 { \ |
|
99 GstPhotographyInterface *iface; \ |
|
100 g_return_val_if_fail (photo != NULL, FALSE); \ |
|
101 iface = GST_PHOTOGRAPHY_GET_IFACE (photo); \ |
|
102 if (iface->set_ ## function_name) { \ |
|
103 return iface->set_ ## function_name (photo, param); \ |
|
104 } \ |
|
105 return FALSE; \ |
|
106 } \ |
|
107 EXPORT_C gboolean \ |
|
108 gst_photography_get_ ## function_name (GstPhotography * photo, param_type * param) \ |
|
109 { \ |
|
110 GstPhotographyInterface *iface; \ |
|
111 g_return_val_if_fail (photo != NULL, FALSE); \ |
|
112 iface = GST_PHOTOGRAPHY_GET_IFACE (photo); \ |
|
113 if (iface->get_ ## function_name) { \ |
|
114 return iface->get_ ## function_name (photo, param); \ |
|
115 } \ |
|
116 return FALSE; \ |
|
117 } |
|
118 |
|
119 |
|
120 /** |
|
121 * gst_photography_set_ev_compensation: |
|
122 * @photo: #GstPhotography interface of a #GstElement |
|
123 * @ev_comp: ev compensation value to set |
|
124 * |
|
125 * Set the ev compensation value for the #GstElement |
|
126 * |
|
127 * Returns: %TRUE if setting the value succeeded, %FALSE otherwise |
|
128 */ |
|
129 /** |
|
130 * gst_photography_get_ev_compensation: |
|
131 * @photo: #GstPhotography interface of a #GstElement |
|
132 * @ev_comp: ev compensation value to get |
|
133 * |
|
134 * Get the ev compensation value for the #GstElement |
|
135 * |
|
136 * Returns: %TRUE if getting the value succeeded, %FALSE otherwise |
|
137 */ |
|
138 GST_PHOTOGRAPHY_FUNC_TEMPLATE (ev_compensation, gfloat); |
|
139 |
|
140 /** |
|
141 * gst_photography_set_iso_speed: |
|
142 * @photo: #GstPhotography interface of a #GstElement |
|
143 * @iso_speed: ISO speed value to set |
|
144 * |
|
145 * Set the ISO value (light sensivity) for the #GstElement |
|
146 * |
|
147 * Returns: %TRUE if setting the value succeeded, %FALSE otherwise |
|
148 */ |
|
149 /** |
|
150 * gst_photography_get_iso_speed: |
|
151 * @photo: #GstPhotography interface of a #GstElement |
|
152 * @iso_speed: ISO speed value to get |
|
153 * |
|
154 * Get the ISO value (light sensivity) for the #GstElement |
|
155 * |
|
156 * Returns: %TRUE if getting the value succeeded, %FALSE otherwise |
|
157 */ |
|
158 GST_PHOTOGRAPHY_FUNC_TEMPLATE (iso_speed, guint); |
|
159 |
|
160 /** |
|
161 * gst_photography_set_aperture: |
|
162 * @photo: #GstPhotography interface of a #GstElement |
|
163 * @aperture: aperture value to set |
|
164 * |
|
165 * Set the aperture value for the #GstElement |
|
166 * |
|
167 * Returns: %TRUE if setting the value succeeded, %FALSE otherwise |
|
168 */ |
|
169 /** |
|
170 * gst_photography_get_aperture: |
|
171 * @photo: #GstPhotography interface of a #GstElement |
|
172 * @aperture: aperture value to get |
|
173 * |
|
174 * Get the aperture value for the #GstElement |
|
175 * |
|
176 * Returns: %TRUE if getting the value succeeded, %FALSE otherwise |
|
177 */ |
|
178 GST_PHOTOGRAPHY_FUNC_TEMPLATE (aperture, guint); |
|
179 |
|
180 /** |
|
181 * gst_photography_set_exposure: |
|
182 * @photo: #GstPhotography interface of a #GstElement |
|
183 * @exposure: exposure time to set |
|
184 * |
|
185 * Set the fixed exposure time (in us) for the #GstElement |
|
186 * |
|
187 * Returns: %TRUE if setting the value succeeded, %FALSE otherwise |
|
188 */ |
|
189 /** |
|
190 * gst_photography_get_exposure: |
|
191 * @photo: #GstPhotography interface of a #GstElement |
|
192 * @exposure: exposure time to get |
|
193 * |
|
194 * Get the fixed exposure time (in us) for the #GstElement |
|
195 * |
|
196 * Returns: %TRUE if getting the value succeeded, %FALSE otherwise |
|
197 */ |
|
198 GST_PHOTOGRAPHY_FUNC_TEMPLATE (exposure, guint32); |
|
199 |
|
200 /** |
|
201 * gst_photography_set_white_balance_mode: |
|
202 * @photo: #GstPhotography interface of a #GstElement |
|
203 * @wb_mode: #GstWhiteBalanceMode to set |
|
204 * |
|
205 * Set the white balance mode for the #GstElement |
|
206 * |
|
207 * Returns: %TRUE if setting the value succeeded, %FALSE otherwise |
|
208 */ |
|
209 /** |
|
210 * gst_photography_get_white_balance_mode: |
|
211 * @photo: #GstPhotography interface of a #GstElement |
|
212 * @wb_mode: #GstWhiteBalanceMode to get |
|
213 * |
|
214 * Get the white balance mode for the #GstElement |
|
215 * |
|
216 * Returns: %TRUE if getting the value succeeded, %FALSE otherwise |
|
217 */ |
|
218 GST_PHOTOGRAPHY_FUNC_TEMPLATE (white_balance_mode, GstWhiteBalanceMode); |
|
219 |
|
220 /** |
|
221 * gst_photography_set_colour_tone_mode: |
|
222 * @photo: #GstPhotography interface of a #GstElement |
|
223 * @tone_mode: #GstColourToneMode to set |
|
224 * |
|
225 * Set the colour tone mode for the #GstElement |
|
226 * |
|
227 * Returns: %TRUE if setting the value succeeded, %FALSE otherwise |
|
228 */ |
|
229 /** |
|
230 * gst_photography_get_colour_tone_mode: |
|
231 * @photo: #GstPhotography interface of a #GstElement |
|
232 * @tone_mode: #GstColourToneMode to get |
|
233 * |
|
234 * Get the colour tone mode for the #GstElement |
|
235 * |
|
236 * Returns: %TRUE if getting the value succeeded, %FALSE otherwise |
|
237 */ |
|
238 GST_PHOTOGRAPHY_FUNC_TEMPLATE (colour_tone_mode, GstColourToneMode); |
|
239 |
|
240 /** |
|
241 * gst_photography_set_scene_mode: |
|
242 * @photo: #GstPhotography interface of a #GstElement |
|
243 * @scene_mode: #GstSceneMode to set |
|
244 * |
|
245 * Set the scene mode for the #GstElement |
|
246 * |
|
247 * Returns: %TRUE if setting the value succeeded, %FALSE otherwise |
|
248 */ |
|
249 /** |
|
250 * gst_photography_get_scene_mode: |
|
251 * @photo: #GstPhotography interface of a #GstElement |
|
252 * @scene_mode: #GstSceneMode to get |
|
253 * |
|
254 * Get the scene mode for the #GstElement |
|
255 * |
|
256 * Returns: %TRUE if getting the value succeeded, %FALSE otherwise |
|
257 */ |
|
258 GST_PHOTOGRAPHY_FUNC_TEMPLATE (scene_mode, GstSceneMode); |
|
259 |
|
260 /** |
|
261 * gst_photography_set_flash_mode: |
|
262 * @photo: #GstPhotography interface of a #GstElement |
|
263 * @flash_mode: #GstFlashMode to set |
|
264 * |
|
265 * Set the flash mode for the #GstElement |
|
266 * |
|
267 * Returns: %TRUE if setting the value succeeded, %FALSE otherwise |
|
268 */ |
|
269 /** |
|
270 * gst_photography_get_flash_mode: |
|
271 * @photo: #GstPhotography interface of a #GstElement |
|
272 * @flash_mode: #GstFlashMode to get |
|
273 * |
|
274 * Get the flash mode for the #GstElement |
|
275 * |
|
276 * Returns: %TRUE if getting the value succeeded, %FALSE otherwise |
|
277 */ |
|
278 GST_PHOTOGRAPHY_FUNC_TEMPLATE (flash_mode, GstFlashMode); |
|
279 |
|
280 /** |
|
281 * gst_photography_set_zoom: |
|
282 * @photo: #GstPhotography interface of a #GstElement |
|
283 * @zoom: zoom value to set |
|
284 * |
|
285 * Set the zoom value for the #GstElement. |
|
286 * E.g. 1.0 to get original image and 3.0 for 3x zoom and so on. |
|
287 * |
|
288 * Returns: %TRUE if setting the value succeeded, %FALSE otherwise |
|
289 */ |
|
290 /** |
|
291 * gst_photography_get_zoom: |
|
292 * @photo: #GstPhotography interface of a #GstElement |
|
293 * @zoom: zoom value to get |
|
294 * |
|
295 * Get the zoom value for the #GstElement |
|
296 * |
|
297 * Returns: %TRUE if getting the value succeeded, %FALSE otherwise |
|
298 */ |
|
299 GST_PHOTOGRAPHY_FUNC_TEMPLATE (zoom, gfloat); |
|
300 |
|
301 /** |
|
302 * gst_photography_get_capabilities: |
|
303 * @photo: #GstPhotography interface of a #GstElement |
|
304 * |
|
305 * Get #GstPhotoCaps bitmask value that indicates what photography |
|
306 * interface features the #GstElement supports |
|
307 * |
|
308 * Returns: #GstPhotoCaps value |
|
309 */ |
|
310 EXPORT_C |
|
311 GstPhotoCaps |
|
312 gst_photography_get_capabilities (GstPhotography * photo) |
|
313 { |
|
314 GstPhotographyInterface *iface; |
|
315 g_return_val_if_fail (photo != NULL, GST_PHOTOGRAPHY_CAPS_NONE); |
|
316 |
|
317 iface = GST_PHOTOGRAPHY_GET_IFACE (photo); |
|
318 if (iface->get_capabilities) { |
|
319 return iface->get_capabilities (photo); |
|
320 } else { |
|
321 return GST_PHOTOGRAPHY_CAPS_NONE; |
|
322 } |
|
323 } |
|
324 |
|
325 /** |
|
326 * gst_photography_prepare_for_capture: |
|
327 * @photo: #GstPhotography interface of a #GstElement |
|
328 * @func: callback that is called after capturing has been prepared |
|
329 * @user_data: user data that will be passed to the callback @func |
|
330 * |
|
331 * Start preparations for capture. @func callback is called after |
|
332 * preparations are done. |
|
333 */ |
|
334 EXPORT_C |
|
335 void |
|
336 gst_photography_prepare_for_capture (GstPhotography * photo, |
|
337 GstPhotoCapturePrepared func, gpointer user_data) |
|
338 { |
|
339 GstPhotographyInterface *iface; |
|
340 g_return_if_fail (photo != NULL); |
|
341 |
|
342 iface = GST_PHOTOGRAPHY_GET_IFACE (photo); |
|
343 if (iface->prepare_for_capture) { |
|
344 iface->prepare_for_capture (photo, func, user_data); |
|
345 } |
|
346 } |
|
347 |
|
348 /** |
|
349 * gst_photography_set_autofocus: |
|
350 * @photo: #GstPhotography interface of a #GstElement |
|
351 * @on: %TRUE to start autofocusing, %FALSE to stop autofocusing |
|
352 * |
|
353 * Start or stop autofocusing. %GST_PHOTOGRAPHY_AUTOFOCUS_DONE |
|
354 * message is posted to bus when autofocusing has finished. |
|
355 */ |
|
356 EXPORT_C |
|
357 void |
|
358 gst_photography_set_autofocus (GstPhotography * photo, gboolean on) |
|
359 { |
|
360 GstPhotographyInterface *iface; |
|
361 g_return_if_fail (photo != NULL); |
|
362 |
|
363 iface = GST_PHOTOGRAPHY_GET_IFACE (photo); |
|
364 if (iface->set_autofocus) { |
|
365 iface->set_autofocus (photo, on); |
|
366 } |
|
367 } |