• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012, Collabora Ltd.
3  * Copyright (C) 2012, Cisco Systems, Inc.
4  *   Author: Youness Alaoui <youness.alaoui@collabora.co.uk>
5  *
6  * Copyright (C) 2015, Collabora Ltd.
7  *   Author: Justin Kim <justin.kim@collabora.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation
12  * version 2.1 of the License.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
22  *
23  */
24 
25 #ifndef __GST_ANDROID_HARDWARE_CAMERA_H__
26 #define __GST_ANDROID_HARDWARE_CAMERA_H__
27 
28 #include <gst/gst.h>
29 #include <jni.h>
30 
31 #include "gst-android-graphics-imageformat.h"
32 #include "jni/gstamcsurfacetexture-jni.h"
33 
34 G_BEGIN_DECLS
35 
36 typedef struct _GstAHCamera GstAHCamera;
37 typedef struct _GstAHCCameraInfo GstAHCCameraInfo;
38 typedef struct _GstAHCSize GstAHCSize;
39 typedef struct _GstAHCParameters GstAHCParameters;
40 
41 /* android.hardware.Camera */
42 struct _GstAHCamera
43 {
44   /* < private > */
45   jobject object;               /* global reference */
46 };
47 
48 /* android.hardware.Camera.CameraInfo */
49 struct _GstAHCCameraInfo
50 {
51   gint facing;
52   gint orientation;
53 };
54 extern gint CameraInfo_CAMERA_FACING_BACK;
55 extern gint CameraInfo_CAMERA_FACING_FRONT;
56 
57 /* android.hardware.Camera.Size */
58 struct _GstAHCSize
59 {
60   gint width;
61   gint height;
62 };
63 
64 /* android.hardware.Camera.Parameters */
65 struct _GstAHCParameters
66 {
67   /* < private > */
68   jobject object;               /* global reference */
69 };
70 extern const gchar *Parameters_WHITE_BALANCE_AUTO;
71 extern const gchar *Parameters_WHITE_BALANCE_INCANDESCENT;
72 extern const gchar *Parameters_WHITE_BALANCE_FLUORESCENT;
73 extern const gchar *Parameters_WHITE_BALANCE_WARM_FLUORESCENT;
74 extern const gchar *Parameters_WHITE_BALANCE_DAYLIGHT;
75 extern const gchar *Parameters_WHITE_BALANCE_CLOUDY_DAYLIGHT;
76 extern const gchar *Parameters_WHITE_BALANCE_TWILIGHT;
77 extern const gchar *Parameters_WHITE_BALANCE_SHADE;
78 extern const gchar *Parameters_EFFECT_NONE;
79 extern const gchar *Parameters_EFFECT_MONO;
80 extern const gchar *Parameters_EFFECT_NEGATIVE;
81 extern const gchar *Parameters_EFFECT_SOLARIZE;
82 extern const gchar *Parameters_EFFECT_SEPIA;
83 extern const gchar *Parameters_EFFECT_POSTERIZE;
84 extern const gchar *Parameters_EFFECT_WHITEBOARD;
85 extern const gchar *Parameters_EFFECT_BLACKBOARD;
86 extern const gchar *Parameters_EFFECT_AQUA;
87 /* EMBOSS, SKETCH and NEON are not standard Android API
88  * but are available only on some Qualcomm devices */
89 extern const gchar *Parameters_EFFECT_EMBOSS;
90 extern const gchar *Parameters_EFFECT_SKETCH;
91 extern const gchar *Parameters_EFFECT_NEON;
92 extern const gchar *Parameters_ANTIBANDING_AUTO;
93 extern const gchar *Parameters_ANTIBANDING_50HZ;
94 extern const gchar *Parameters_ANTIBANDING_60HZ;
95 extern const gchar *Parameters_ANTIBANDING_OFF;
96 extern const gchar *Parameters_FLASH_MODE_OFF;
97 extern const gchar *Parameters_FLASH_MODE_AUTO;
98 extern const gchar *Parameters_FLASH_MODE_ON;
99 extern const gchar *Parameters_FLASH_MODE_RED_EYE;
100 extern const gchar *Parameters_FLASH_MODE_TORCH;
101 extern const gchar *Parameters_SCENE_MODE_AUTO;
102 extern const gchar *Parameters_SCENE_MODE_ACTION;
103 extern const gchar *Parameters_SCENE_MODE_PORTRAIT;
104 extern const gchar *Parameters_SCENE_MODE_LANDSCAPE;
105 extern const gchar *Parameters_SCENE_MODE_NIGHT;
106 extern const gchar *Parameters_SCENE_MODE_NIGHT_PORTRAIT;
107 extern const gchar *Parameters_SCENE_MODE_THEATRE;
108 extern const gchar *Parameters_SCENE_MODE_BEACH;
109 extern const gchar *Parameters_SCENE_MODE_SNOW;
110 extern const gchar *Parameters_SCENE_MODE_SUNSET;
111 extern const gchar *Parameters_SCENE_MODE_STEADYPHOTO;
112 extern const gchar *Parameters_SCENE_MODE_FIREWORKS;
113 extern const gchar *Parameters_SCENE_MODE_SPORTS;
114 extern const gchar *Parameters_SCENE_MODE_PARTY;
115 extern const gchar *Parameters_SCENE_MODE_CANDLELIGHT;
116 extern const gchar *Parameters_SCENE_MODE_BARCODE;
117 /* BACKLIGHT, FLOWERS and AR are not standard Android API
118  * but are available only on some Qualcomm devices. */
119 extern const gchar *Parameters_SCENE_MODE_BACKLIGHT;
120 extern const gchar *Parameters_SCENE_MODE_FLOWERS;
121 extern const gchar *Parameters_SCENE_MODE_AR;
122 /* HDR is available in API 17+ (Android 4.2) */
123 extern const gchar *Parameters_SCENE_MODE_HDR;
124 extern const gchar *Parameters_FOCUS_MODE_AUTO;
125 extern const gchar *Parameters_FOCUS_MODE_INFINITY;
126 extern const gchar *Parameters_FOCUS_MODE_MACRO;
127 extern const gchar *Parameters_FOCUS_MODE_FIXED;
128 extern const gchar *Parameters_FOCUS_MODE_EDOF;
129 extern const gchar *Parameters_FOCUS_MODE_CONTINUOUS_VIDEO;
130 extern const gchar *Parameters_FOCUS_MODE_CONTINUOUS_PICTURE;
131 
132 /* android.hardware.Camera.ErrorCallback */
133 typedef void (*GstAHCErrorCallback) (gint error, gpointer user_data);
134 
135 /* android.hardware.Camera.PreviewCallback */
136 typedef void (*GstAHCPreviewCallback) (jbyteArray data, gpointer user_data);
137 
138 /* android.hardware.Camera.AutoFocusCallback */
139 typedef void (*GstAHCAutoFocusCallback) (gboolean success, gpointer user_data);
140 
141 gboolean gst_android_hardware_camera_init (void);
142 void gst_android_hardware_camera_deinit (void);
143 
144 /* android.hardware.Camera */
145 void gst_ah_camera_add_callback_buffer (GstAHCamera * self, jbyteArray buffer);
146 gboolean gst_ah_camera_auto_focus (GstAHCamera * self,
147     GstAHCAutoFocusCallback cb, gpointer user_data);
148 gboolean gst_ah_camera_cancel_auto_focus (GstAHCamera * self);
149 gboolean gst_ah_camera_get_camera_info (gint camera_id,
150     GstAHCCameraInfo * camera_info);
151 gint gst_ah_camera_get_number_of_cameras (void);
152 GstAHCParameters *gst_ah_camera_get_parameters (GstAHCamera * self);
153 gboolean gst_ah_camera_lock (GstAHCamera * self);
154 GstAHCamera *gst_ah_camera_open (gint camera_id);
155 gboolean gst_ah_camera_reconnect (GstAHCamera * self);
156 void gst_ah_camera_release (GstAHCamera * self);
157 void gst_ah_camera_free (GstAHCamera * self);
158 gboolean gst_ah_camera_set_parameters (GstAHCamera * self,
159     GstAHCParameters * params);
160 gboolean gst_ah_camera_set_error_callback (GstAHCamera * self,
161     GstAHCErrorCallback cb, gpointer user_data);
162 gboolean gst_ah_camera_set_preview_callback_with_buffer (GstAHCamera * self,
163     GstAHCPreviewCallback cb, gpointer user_data);
164 void gst_ah_camera_set_preview_texture (GstAHCamera * self,
165     GstAmcSurfaceTextureJNI * surfaceTexture);
166 gboolean gst_ah_camera_start_preview (GstAHCamera * self);
167 gboolean gst_ah_camera_start_smooth_zoom (GstAHCamera * self, gint value);
168 gboolean gst_ah_camera_stop_preview (GstAHCamera * self);
169 gboolean gst_ah_camera_stop_smooth_zoom (GstAHCamera * self);
170 gboolean gst_ah_camera_unlock (GstAHCamera * self);
171 
172 /* android.hardware.Camera.Size */
173 GstAHCSize *gst_ahc_size_new (gint width, gint height);
174 void gst_ahc_size_free (GstAHCSize * self);
175 
176 /* android.hardware.Camera.Parameters */
177 gchar *gst_ahc_parameters_flatten (GstAHCParameters * self);
178 const gchar *gst_ahc_parameters_get_antibanding (GstAHCParameters * self);
179 const gchar *gst_ahc_parameters_get_color_effect (GstAHCParameters * self);
180 gint gst_ahc_parameters_get_exposure_compensation (GstAHCParameters * self);
181 gfloat gst_ahc_parameters_get_exposure_compensation_step (GstAHCParameters
182     * self);
183 const gchar *gst_ahc_parameters_get_flash_mode (GstAHCParameters * self);
184 gfloat gst_ahc_parameters_get_focal_length (GstAHCParameters * self);
185 const gchar *gst_ahc_parameters_get_focus_mode (GstAHCParameters * self);
186 gfloat gst_ahc_parameters_get_horizontal_view_angle (GstAHCParameters * self);
187 gint gst_ahc_parameters_get_max_exposure_compensation (GstAHCParameters * self);
188 gint gst_ahc_parameters_get_max_zoom (GstAHCParameters * self);
189 gint gst_ahc_parameters_get_min_exposure_compensation (GstAHCParameters * self);
190 gint gst_ahc_parameters_get_preview_format (GstAHCParameters * self);
191 gboolean gst_ahc_parameters_get_preview_fps_range (GstAHCParameters * self,
192     gint * min, gint * max);
193 GstAHCSize *gst_ahc_parameters_get_preview_size (GstAHCParameters * self);
194 const gchar *gst_ahc_parameters_get_scene_mode (GstAHCParameters * self);
195 /* GList <const gchar *> */
196 GList *gst_ahc_parameters_get_supported_antibanding (GstAHCParameters * self);
197 void gst_ahc_parameters_supported_antibanding_free (GList * list);
198 /* GList <const gchar *> */
199 GList *gst_ahc_parameters_get_supported_color_effects (GstAHCParameters * self);
200 void gst_ahc_parameters_supported_color_effects_free (GList * list);
201 /* GList <const gchar *> */
202 GList *gst_ahc_parameters_get_supported_flash_modes (GstAHCParameters * self);
203 void gst_ahc_parameters_supported_flash_modes_free (GList * list);
204 /* GList <const gchar *> */
205 GList *gst_ahc_parameters_get_supported_focus_modes (GstAHCParameters * self);
206 void gst_ahc_parameters_supported_focus_modes_free (GList * list);
207 /* GList <int> */
208 GList *gst_ahc_parameters_get_supported_preview_formats (GstAHCParameters
209     * self);
210 void gst_ahc_parameters_supported_preview_formats_free (GList * list);
211 /* GList <int [2]> */
212 GList *gst_ahc_parameters_get_supported_preview_fps_range (GstAHCParameters
213     * self);
214 void gst_ahc_parameters_supported_preview_fps_range_free (GList * list);
215 /* GList <GstAHCSize *> */
216 GList *gst_ahc_parameters_get_supported_preview_sizes (GstAHCParameters * self);
217 void gst_ahc_parameters_supported_preview_sizes_free (GList * list);
218 /* GList <const gchar *> */
219 GList *gst_ahc_parameters_get_supported_scene_modes (GstAHCParameters * self);
220 void gst_ahc_parameters_supported_scene_modes_free (GList * list);
221 /* GList <const gchar *> */
222 GList *gst_ahc_parameters_get_supported_white_balance (GstAHCParameters * self);
223 void gst_ahc_parameters_supported_white_balance_free (GList * list);
224 gfloat gst_ahc_parameters_get_vertical_view_angle (GstAHCParameters * self);
225 gboolean gst_ahc_parameters_get_video_stabilization (GstAHCParameters * self);
226 const gchar *gst_ahc_parameters_get_white_balance (GstAHCParameters * self);
227 gint gst_ahc_parameters_get_zoom (GstAHCParameters * self);
228 /* GList <int> */
229 GList *gst_ahc_parameters_get_zoom_ratios (GstAHCParameters * self);
230 void gst_ahc_parameters_zoom_ratios_free (GList * list);
231 gboolean gst_ahc_parameters_is_smooth_zoom_supported (GstAHCParameters * self);
232 gboolean gst_ahc_parameters_is_video_stabilization_supported (
233     GstAHCParameters * self);
234 gboolean gst_ahc_parameters_is_zoom_supported (GstAHCParameters * self);
235 gboolean gst_ahc_parameters_set_antibanding (GstAHCParameters * self,
236     const gchar * antibanding);
237 gboolean gst_ahc_parameters_set_color_effect (GstAHCParameters * self,
238     const gchar * value);
239 gboolean gst_ahc_parameters_set_exposure_compensation (GstAHCParameters * self,
240     gint value);
241 gboolean gst_ahc_parameters_set_flash_mode (GstAHCParameters * self,
242     const gchar * value);
243 gboolean gst_ahc_parameters_set_focus_mode (GstAHCParameters * self,
244     const gchar * value);
245 gboolean gst_ahc_parameters_set_preview_format (GstAHCParameters * self,
246     gint format);
247 gboolean gst_ahc_parameters_set_preview_fps_range (GstAHCParameters * self,
248     gint min, gint max);
249 gboolean gst_ahc_parameters_set_preview_size (GstAHCParameters * self,
250     gint width, gint height);
251 gboolean gst_ahc_parameters_set_scene_mode (GstAHCParameters * self,
252     const gchar * value);
253 gboolean gst_ahc_parameters_set_white_balance (GstAHCParameters * self,
254     const gchar * value);
255 gboolean gst_ahc_parameters_set_video_stabilization (GstAHCParameters * self,
256     gboolean toggle);
257 gboolean gst_ahc_parameters_set_zoom (GstAHCParameters * self, gint value);
258 gboolean gst_ahc_parameters_unflatten (GstAHCParameters * self,
259     const gchar * flattened);
260 void gst_ahc_parameters_free (GstAHCParameters * self);
261 
262 G_END_DECLS
263 
264 #endif /* __GST_ANDROID_HARDWARE_CAMERA_H__ */
265