Tizen 2.1 base
[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
115
116 #define DEFAULT_WIN_ANGLE (270)
117
118 #define CAM_FILE_PATH_MAX 1024
119 #define EFL_TEMP_CODE
120 /* #define USE_CAMERA_APP_SHUTTER_SOUND 1 */
121 #define ENABLE_CAPTURE_ANIMATION
122
123 struct appdata {
124         Evas *evas;
125         Ecore_Evas *ee;
126         Evas_Object *ug_base;
127         Evas_Object *win_main;
128         Ecore_X_Window main_xid;
129         Ecore_Pipe *main_pipe;
130         CamUgState ug_state;
131
132         app_device_orientation_e rot_current;
133         app_device_orientation_e rot_previous;
134
135         int angle_pre;
136         int angle;
137         int rotate_angle;
138         gboolean is_rotating;
139         gboolean is_processing; /*note: programm busy flag, now just used for bust shot processing popup*/
140         gboolean is_capture_animation_processing;
141
142         int camcorder_rotate;
143
144         Evas_Object *gesture;           /* gesture layout */
145
146 #ifdef ENABLE_CAPTURE_ANIMATION
147         Evas_Object *shutter_screen;
148         CamRectangle shutter_src_rect;
149         CamRectangle shutter_des_rect;
150         Evas_Object *rect_image;
151 #endif
152
153         int win_width;
154         int win_height;
155
156         int camfw_video_width;
157         int camfw_video_height;
158
159         double af_start_x;      /* area start coordination */
160         double af_start_y;      /* area start coordination */
161         int af_x;
162         int af_y;
163         double camera_focus_w;  /* size of focus image */
164         double camera_focus_h;  /* size of focus image */
165
166         int touch_lcd_x;        /* lcd x */
167         int touch_lcd_y;        /* lcd y */
168
169         int preview_offset_x;
170         int preview_offset_y;
171         int preview_w;
172         int preview_h;
173
174         int target_direction;
175         Evas_Object *toolbar_edje;
176
177         Evas_Object *toolbar_edje_landscape;
178         Evas_Object *toolbar_edje_portrait;
179         Evas_Object *toolbar_edje_landscape_inverse;
180         Evas_Object *toolbar_edje_portrait_inverse;
181         char *toolbar_edj_file;
182         struct {
183                 struct {
184                         Evas_Object *edje;
185                         Evas_Object *edje_landscape;
186                         Evas_Object *edje_portrait;
187                         Evas_Object *edje_landscape_inverse;
188                         Evas_Object *edje_portrait_inverse;
189
190                         Evas_Object *thumbnail_image;
191                 } quickview_item;
192
193         } toolbar;
194
195         cam_menubar_data toolbar_menu_arrays[CAM_MENU_BAR_LEFT_MAX_NUM];
196
197
198
199         Evas_Object *shutterbtn;
200         Evas_Object *shutterbtn_camera_icon;
201         Evas_Object *recordingbtn;
202         Evas_Object *recording_stop_btn;
203         Evas_Object *backbtn;
204         Evas_Object *caf_button;
205
206         Evas_Object *focus_edje;
207         Evas_Object *indicator_edje;
208         Evas_Object *ev_edje;
209         Evas_Object *ev_icon_minus_edje;
210         Evas_Object *ev_icon_plus_edje;
211         Evas_Object *pinch_edje;
212         Evas_Object *zoom_edje;
213         Evas_Object *zoom_text_min_edje;
214         Evas_Object *zoom_text_max_edje;
215         Evas_Object *recording_edje;
216         Evas_Object *capturebtn_edje;
217
218         Evas_Object *guideline_edje;
219
220         Evas_Object *progressbar_edje;
221         Evas_Object *progressbar;
222
223         Evas_Object *gps_radio; /* radio button */
224         Evas_Object *guideline_radio;   /* radio button */
225         Evas_Object *autocontrast_radio;
226         Evas_Object *antishake_radio;
227         Evas_Object *outdoor_visibility_radio;
228         Evas_Object *burst_shot_mode_radio;
229         Evas_Object *capture_by_voice_radio;
230         Evas_Object *save_as_flip_radio;
231         Elm_Object_Item *setting_select_item;
232
233         Evas_Object *genlist;
234         Evas_Object *sub_genlist;
235         Evas_Object *sub_menu_group;
236         int sub_menu_type;
237         int sub_menu_index;
238
239         bool show_setting_popup_after_rotate;
240         bool show_edit_shortcuts_popup_after_rotate;
241
242         Evas_Object *toolbar_setting_popup;
243         Evas_Object *toolbar_setting_popup_area;
244
245         Evas_Object *setting_ctxpopup;
246         Evas_Object *ctxpopup_area;
247
248         Evas_Object *edit_shortcuts_popup;
249         Evas_Object *edit_shortcuts_popup_ctx;
250         Evas_Object *edit_shortcuts_popup_scroll;
251         Evas_Object *edit_shortcuts_popup_description;/*note: text part*/
252
253         Evas_Object *tip_popup;
254         int     tip_popup_type;
255
256         /* continous */
257         struct {
258                 Evas_Object *layout_edje;
259                 Evas_Object *gengrid;
260                 Eina_List *item_list;
261         } conti_review;
262
263         /* panorama */
264         Evas_Object *progress_popup;
265         Evas_Object *progress_popup_bar;
266
267         Ecore_Event_Handler *key_up;
268         Ecore_Event_Handler *key_down;
269         Ecore_Event_Handler *mouse_up;
270         Ecore_Event_Handler *mouse_down;
271
272         Ecore_Idler *recording_commit;
273
274         /* Idle handler of capture callback. wh01.cho@samsung.com. 2010-12-15. */
275         Ecore_Idler *still_captured_idle;
276         Ecore_Idler *capture_idle;
277         GList *capture_cb_list;
278
279         Ecore_Timer *rec_icon_updater;
280         Ecore_Timer *rec_time_updater;
281         Ecore_Timer *rec_pause_timer;
282
283         Ecore_Timer *check_af_timer;
284         Ecore_Timer *continuous_shot_timer;
285         Ecore_Timer *shutter_long_tap_timer;    /*long tap timer for AF*/
286         gboolean emit_continuous_shutter;               /*record: continous have been emitted*/
287         gboolean continuous_shot_by_hard_key;   /* continuous shot triggered by hard key */
288
289         Evas_Object *waring_popup;
290         Evas_Object *confirm_popup;
291         int recording_state;
292
293         /* auto shot */
294         Ecore_Idler *auto_shot_idle;
295
296         /* best shot */
297
298         Evas_Object *bestshot_thumbnails_edje;
299
300         /* general */
301         Ecore_Timer *timeout_checker;
302         Ecore_Timer *setting_toolbar_hide_timer;
303
304         Ecore_Timer *gps_animation_timer;
305         Ecore_Timer *battery_animation_timer;
306
307         Ecore_Timer *continuous_af_timer;
308         Ecore_Timer *focus_guide_hide_timer;
309
310         int toolbar_hided;
311
312         bool timer_activated;
313         Ecore_Timer *timer_timer;
314         int timer_count;
315         Evas_Object *timer_icon_edje;
316
317         CamAppData *camapp_handle;
318         ShortCutData *shortcut_data; /*save now moving or touch shortcut*/
319         ShortCutData *swap_data; /*save now covering shortcuts*/
320
321         /* Launching Mode */
322         int launching_mode;
323         /* ug service mime type*/
324         char *service_mime;
325         /* exe args */
326         CamExeArgs *exe_args;
327
328         /* Thread for file register */
329         pthread_t file_reg_thread;
330         pthread_mutex_t file_reg_mutex;
331         pthread_cond_t file_reg_cond;
332         GQueue *file_reg_queue;
333
334         pthread_t camera_start_thread;
335
336         ui_gadget_h camera_ug;
337
338         ui_gadget_h imageviewer_ug;
339         gboolean ug_is_deleting_process; /*note: now ug is deleting process, and run into camera preview process*/
340         service_h imageviewer_service;
341
342         ui_gadget_h location_ug;
343
344         int mm_state;
345         gboolean isGrabed;
346
347         Ecore_Idler *update_thumbnail_idler;
348
349         Ecore_Timer *longpress_timer;
350         gboolean up_key;
351
352         int cancel_key_press;
353         int is_recording;
354
355         gboolean path_in_return;
356         int displayed_setting_popup;
357         int enable_mode_change;
358         int stop_continuous_shot;
359         /*check out low battery */
360         gboolean battery_status;
361         /*check torch light*/
362         gboolean torchlight_on;
363
364         gboolean is_calling;
365
366         int fw_error_type;
367 #ifdef USE_CAMERA_APP_SHUTTER_SOUND
368         int play_rec_sound;
369 #endif
370         int last_camera_zoom_mode;
371
372         /* guide screen */
373         Evas_Object *shot_mode_guide_popup;
374
375         service_h service_handle;
376         cam_menu_composer* setting_menu_composer;
377         cam_menu_composer* sub_menu_composer;
378
379         /*note: remained_count*/
380         int remained_count;
381         sensor_h sensor;
382         CamErrorType error_type;
383 };
384
385
386
387 extern void *handle;
388 gboolean open_cam_ext_handle();
389 void close_cam_ext_handle();
390 gboolean cam_toolbar_menu_config_init(void *data, int mode);
391 gboolean cam_toolbar_menu_config_update(void *data);
392
393 #endif                          /* __DEF_CAM_H__ */