5ff90582018d87759d8a3ffb87a6d91aa9aa7229
[apps/core/preloaded/ug-camera-efl.git] / include / cam.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.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://floralicense.org/license/
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
18 #ifndef __DEF_CAM_H__
19 #define __DEF_CAM_H__
20
21
22 #include <Elementary.h>
23 #include <Ecore.h>
24 #include <Ecore_X.h>
25 #include <dlfcn.h>
26 #include <utilX.h>
27
28 #include "cam_property.h"
29 #include "cam_app.h"
30 #include "edc_string.h"
31 #include <fcntl.h>
32
33 #include <vconf.h>
34 #include <ui-gadget.h>
35 #include <app.h>
36 #include <media_content.h>
37 #include <sensors.h>
38
39
40 #define DISABLE_FOR_DEMO 0
41
42 #ifdef USE_FIFO_THREAD
43 #define CAM_FIFO_PATH "/tmp/cam_cmd_fifo"
44
45 #define CAM_FIFO_CMD_EXIT      "EXIT"
46 #define CAM_FIFO_CMD_START     "START"
47
48 #define CAM_CAPTURE_AUTO_START "CAPTURE_AUTO_START"
49
50 #define MAX_NUM_OF_FIFO_TOKEN  6
51 #endif
52
53 #define PACKAGE                                                 "ug-camera-efl"
54 #define GRP_MAIN                                                "main"
55
56 #define EDJ_PATH                                                "/usr/ug/res/edje/"PACKAGE
57 #define CAM_IMAGE_PATH                                  "/usr/ug/res/images/"PACKAGE"/src_images/"
58
59 #define CAM_MAIN_LAYOUT_EDJ_NAME                                                EDJ_PATH"/cam_main_layout.edj"
60
61 #define CAM_RECORDING_EDJ_NAME                                                  EDJ_PATH"/cam_recording_edje.edj"
62 #define CAM_RECORDING_INVERSE_EDJ_NAME                                  EDJ_PATH"/cam_recording_edje_inverse.edj"
63 #define CAM_RECORDING_VERTICAL_EDJ_NAME                                 EDJ_PATH"/cam_recording_edje_vertical.edj"
64 #define CAM_RECORDING_VERTICAL_INVERSE_EDJ_NAME                 EDJ_PATH"/cam_recording_edje_vertical_inverse.edj"
65
66 #define CAM_TOOLBAR_LAYOUT_EDJ_NAME                                             EDJ_PATH"/cam_toolbar_layout.edj"
67 #define CAM_TOOLBAR_LAYOUT_INVERSE_EDJ_NAME                             EDJ_PATH"/cam_toolbar_layout_inverse.edj"
68 #define CAM_TOOLBAR_LAYOUT_VERTICAL_EDJ_NAME                    EDJ_PATH"/cam_toolbar_layout_vertical.edj"
69 #define CAM_TOOLBAR_LAYOUT_VERTICAL_INVERSE_EDJ_NAME    EDJ_PATH"/cam_toolbar_layout_vertical_inverse.edj"
70
71 #define CAM_SETTING_POPUP_STYLE_EDJ_NAME                                EDJ_PATH"/style_ctxpopup_camera.edj"
72 #define CAM_SETTING_POPUP_STYLE_WITH_RADIO_EDJ_NAME             EDJ_PATH"/style_ctxpopup_camera_with_radio.edj"
73 #define CAM_SETTING_POPUP_LAYOUT_EDJ_NAME                               EDJ_PATH"/cam_setting_popup_layout.edj"
74 #define CAM_SLIDER_STYLE_EDJ_NAME                                               EDJ_PATH"/style_slider_camera.edj"
75 #define CAM_LABEL_STYLE_EDJ_NAME                                                EDJ_PATH"/style_label_camera.edj"
76 #define CAM_BUTTON_STYLE_EDJ_NAME                                               EDJ_PATH"/style_button_camera.edj"
77
78
79 #define CAM_SHOTCUTS_EDIT_CTXPOPUP_EDJ_NAME                             EDJ_PATH"/cam_ctxpopup_shortcuts.edj"
80
81 #define CAM_UTILS_EDJ_NAME                                                              EDJ_PATH"/cam_utils.edj"
82 #define CAM_INDICATOR_EDJ_NAME                                                  EDJ_PATH"/cam_indicator_layout.edj"
83
84 #define CAM_EV_EDJ_NAME                                                                 EDJ_PATH"/cam_ev_layout.edj"
85 #define CAM_EV_EDJ_INVERSE_NAME                                                 EDJ_PATH"/cam_ev_layout_inverse.edj"
86 #define CAM_EV_EDJ_VERTICAL_NAME                                                EDJ_PATH"/cam_ev_layout_vertical.edj"
87 #define CAM_EV_EDJ_VERTICAL_INVERSE_NAME                                EDJ_PATH"/cam_ev_layout_vertical_inverse.edj"
88
89 #define CAM_ZOOM_EDJ_NAME                                                               EDJ_PATH"/cam_zoom_layout.edj"
90 #define CAM_ZOOM_EDJ_INVERSE_NAME                                               EDJ_PATH"/cam_zoom_layout_inverse.edj"
91 #define CAM_ZOOM_EDJ_VERTICAL_NAME                                              EDJ_PATH"/cam_zoom_layout_vertical.edj"
92 #define CAM_ZOOM_EDJ_VERTICAL_INVERSE_NAME                              EDJ_PATH"/cam_zoom_layout_vertical_inverse.edj"
93
94 #define CAM_IMAGE_EDJ_NAME                                                              EDJ_PATH"/cam_images.edj"
95
96 #define IMAGE_VIEWER_VIEW_MODE_KEY_NAME                                 "View Mode"
97 #define IMAGE_VIEWER_FILE_PATH_KEY_NAME                                 "Path"
98 #define IMAGE_VIEWER_SET_AS_TYPE                                                "Setas type"
99 #define IMAGE_VIEWER_RESOLUTION                                                 "Resolution"
100 #define IMAGE_VIEWER_UG_NAME                                                    "image-viewer-efl"
101
102 #define LOCATION_UG_NAME                                                                "setting-location-efl"
103
104 #define PREVIEW_WIDTH                           640
105 #define PREVIEW_HEIGHT                          480
106
107 #define WINDOW_W                                        640     /* 400 */ /*1280*/
108 #define WINDOW_H                                        480     /* 240 */ /*720*/
109
110 #define SERVICE_MIME_TYPE_IMAGE_1                                               "image/jpg"
111 #define SERVICE_MIME_TYPE_IMAGE_2                                               "image/jpeg"
112 #define SERVICE_MIME_TYPE_VIDEO_1                                               "video/3gp"
113 #define SERVICE_MIME_TYPE_VIDEO_2                                               "video/3gpp"
114 #define SERVICE_OPTIONAL_KEY_ALLOW_SWITCH                               "http://tizen.org/appcontrol/data/camera/allow_switch"
115
116
117 #define DEFAULT_WIN_ANGLE (270)
118
119 #define CAM_FILE_PATH_MAX 1024
120 #define EFL_TEMP_CODE
121 /* #define USE_CAMERA_APP_SHUTTER_SOUND 1 */
122 #define ENABLE_CAPTURE_ANIMATION
123
124 struct appdata {
125         Evas *evas;
126         Ecore_Evas *ee;
127         Evas_Object *ug_base;
128         Evas_Object *win_main;
129         Ecore_X_Window main_xid;
130         Ecore_Pipe *main_pipe;
131         CamUgState ug_state;
132
133         app_device_orientation_e rot_current;
134         app_device_orientation_e rot_previous;
135
136         int angle_pre;
137         int angle;
138         int rotate_angle;
139         gboolean is_rotating;
140         gboolean is_processing; /*note: programm busy flag, now just used for bust shot processing popup*/
141         gboolean is_capture_animation_processing;
142
143         int camcorder_rotate;
144
145         Evas_Object *gesture;           /* gesture layout */
146
147 #ifdef ENABLE_CAPTURE_ANIMATION
148         Evas_Object *shutter_screen;
149         CamRectangle shutter_src_rect;
150         CamRectangle shutter_des_rect;
151         Evas_Object *rect_image;
152 #endif
153
154         int win_width;
155         int win_height;
156
157         int camfw_video_width;
158         int camfw_video_height;
159
160         double af_start_x;      /* area start coordination */
161         double af_start_y;      /* area start coordination */
162         int af_x;
163         int af_y;
164         double camera_focus_w;  /* size of focus image */
165         double camera_focus_h;  /* size of focus image */
166
167         int touch_lcd_x;        /* lcd x */
168         int touch_lcd_y;        /* lcd y */
169
170         int preview_offset_x;
171         int preview_offset_y;
172         int preview_w;
173         int preview_h;
174
175         int target_direction;
176         Evas_Object *toolbar_edje;
177
178         Evas_Object *toolbar_edje_landscape;
179         Evas_Object *toolbar_edje_portrait;
180         Evas_Object *toolbar_edje_landscape_inverse;
181         Evas_Object *toolbar_edje_portrait_inverse;
182         char *toolbar_edj_file;
183         struct {
184                 struct {
185                         Evas_Object *edje;
186                         Evas_Object *edje_landscape;
187                         Evas_Object *edje_portrait;
188                         Evas_Object *edje_landscape_inverse;
189                         Evas_Object *edje_portrait_inverse;
190
191                         Evas_Object *thumbnail_image;
192                 } quickview_item;
193
194         } toolbar;
195
196         cam_menubar_data toolbar_menu_arrays[CAM_MENU_BAR_LEFT_MAX_NUM];
197
198
199
200         Evas_Object *shutterbtn;
201         Evas_Object *shutterbtn_camera_icon;
202         Evas_Object *recordingbtn;
203         Evas_Object *recording_stop_btn;
204         Evas_Object *backbtn;
205         Evas_Object *caf_button;
206
207         Evas_Object *focus_edje;
208         Evas_Object *indicator_edje;
209         Evas_Object *ev_edje;
210         Evas_Object *ev_icon_minus_edje;
211         Evas_Object *ev_icon_plus_edje;
212         Evas_Object *pinch_edje;
213         Evas_Object *zoom_edje;
214         Evas_Object *zoom_text_min_edje;
215         Evas_Object *zoom_text_max_edje;
216         Evas_Object *recording_edje;
217         Evas_Object *capturebtn_edje;
218
219         Evas_Object *guideline_edje;
220
221         Evas_Object *progressbar_edje;
222         Evas_Object *progressbar;
223
224         Evas_Object *gps_radio; /* radio button */
225         Evas_Object *guideline_radio;   /* radio button */
226         Evas_Object *autocontrast_radio;
227         Evas_Object *antishake_radio;
228         Evas_Object *outdoor_visibility_radio;
229         Evas_Object *burst_shot_mode_radio;
230         Evas_Object *capture_by_voice_radio;
231         Evas_Object *save_as_flip_radio;
232         Elm_Object_Item *setting_select_item;
233
234         Evas_Object *genlist;
235         Evas_Object *sub_genlist;
236         Evas_Object *sub_menu_group;
237         int sub_menu_type;
238         int sub_menu_index;
239
240         bool show_setting_popup_after_rotate;
241         bool show_edit_shortcuts_popup_after_rotate;
242
243         Evas_Object *toolbar_setting_popup;
244         Evas_Object *toolbar_setting_popup_area;
245
246         Evas_Object *setting_ctxpopup;
247         Evas_Object *ctxpopup_area;
248
249         Evas_Object *edit_shortcuts_popup;
250         Evas_Object *edit_shortcuts_popup_ctx;
251         Evas_Object *edit_shortcuts_popup_scroll;
252         Evas_Object *edit_shortcuts_popup_description;/*note: text part*/
253
254         Evas_Object *tip_popup;
255         int     tip_popup_type;
256
257         /* continous */
258         struct {
259                 Evas_Object *layout_edje;
260                 Evas_Object *gengrid;
261                 Eina_List *item_list;
262         } conti_review;
263
264         /* panorama */
265         Evas_Object *progress_popup;
266         Evas_Object *progress_popup_bar;
267
268         Ecore_Event_Handler *key_up;
269         Ecore_Event_Handler *key_down;
270         Ecore_Event_Handler *mouse_up;
271         Ecore_Event_Handler *mouse_down;
272
273         Ecore_Idler *recording_commit;
274
275         /* Idle handler of capture callback. wh01.cho@samsung.com. 2010-12-15. */
276         Ecore_Idler *still_captured_idle;
277         Ecore_Idler *capture_idle;
278         GList *capture_cb_list;
279
280         Ecore_Timer *rec_icon_updater;
281         Ecore_Timer *rec_time_updater;
282         Ecore_Timer *rec_pause_timer;
283
284         Ecore_Timer *check_af_timer;
285         Ecore_Timer *continuous_shot_timer;
286         Ecore_Timer *shutter_long_tap_timer;    /*long tap timer for AF*/
287         gboolean emit_continuous_shutter;               /*record: continous have been emitted*/
288         gboolean continuous_shot_by_hard_key;   /* continuous shot triggered by hard key */
289
290         Evas_Object *waring_popup;
291         Evas_Object *confirm_popup;
292         int recording_state;
293
294         /* auto shot */
295         Ecore_Idler *auto_shot_idle;
296
297         /* best shot */
298
299         Evas_Object *bestshot_thumbnails_edje;
300
301         /* general */
302         Ecore_Timer *timeout_checker;
303         Ecore_Timer *setting_toolbar_hide_timer;
304
305         Ecore_Timer *gps_animation_timer;
306         Ecore_Timer *battery_animation_timer;
307
308         Ecore_Timer *continuous_af_timer;
309         Ecore_Timer *focus_guide_hide_timer;
310
311         int toolbar_hided;
312
313         bool timer_activated;
314         Ecore_Timer *timer_timer;
315         int timer_count;
316         Evas_Object *timer_icon_edje;
317
318         CamAppData *camapp_handle;
319         ShortCutData *shortcut_data; /*save now moving or touch shortcut*/
320         ShortCutData *swap_data; /*save now covering shortcuts*/
321
322         /* Launching Mode */
323         int launching_mode;
324         /* ug service mime type*/
325         char *service_mime;
326         /* exe args */
327         CamExeArgs *exe_args;
328
329         /* Thread for file register */
330         pthread_t file_reg_thread;
331         pthread_mutex_t file_reg_mutex;
332         pthread_cond_t file_reg_cond;
333         GQueue *file_reg_queue;
334
335         pthread_t camera_start_thread;
336
337         ui_gadget_h camera_ug;
338
339         ui_gadget_h imageviewer_ug;
340         gboolean ug_is_deleting_process; /*note: now ug is deleting process, and run into camera preview process*/
341         service_h imageviewer_service;
342
343         ui_gadget_h location_ug;
344
345         int mm_state;
346         gboolean isGrabed;
347
348         Ecore_Idler *update_thumbnail_idler;
349
350         Ecore_Timer *longpress_timer;
351         gboolean up_key;
352
353         int cancel_key_press;
354         int is_recording;
355
356         gboolean path_in_return;
357         int displayed_setting_popup;
358         int enable_mode_change;
359         int stop_continuous_shot;
360         /*check out low battery */
361         gboolean battery_status;
362         /*check torch light*/
363         gboolean torchlight_on;
364
365         gboolean is_calling;
366
367         int fw_error_type;
368 #ifdef USE_CAMERA_APP_SHUTTER_SOUND
369         int play_rec_sound;
370 #endif
371         int last_camera_zoom_mode;
372
373         /* guide screen */
374         Evas_Object *shot_mode_guide_popup;
375
376         service_h service_handle;
377         cam_menu_composer* setting_menu_composer;
378         cam_menu_composer* sub_menu_composer;
379
380         /*note: remained_count*/
381         int remained_count;
382         sensor_h sensor;
383         CamErrorType error_type;
384 };
385
386
387
388 extern void *handle;
389 gboolean open_cam_ext_handle();
390 void close_cam_ext_handle();
391 gboolean cam_toolbar_menu_config_init(void *data, int mode);
392 gboolean cam_toolbar_menu_config_update(void *data);
393
394 #endif                          /* __DEF_CAM_H__ */