Update camera code
[profile/ivi/camera.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://www.tizenopensource.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
38
39 #define DISABLE_FOR_DEMO 0
40
41 #ifdef USE_FIFO_THREAD
42 #define CAM_FIFO_PATH "/tmp/cam_cmd_fifo"
43
44 #define CAM_FIFO_CMD_EXIT      "EXIT"
45 #define CAM_FIFO_CMD_START     "START"
46
47 #define CAM_CAPTURE_AUTO_START "CAPTURE_AUTO_START"
48
49 #define MAX_NUM_OF_FIFO_TOKEN  6
50 #endif
51
52 #ifndef PREFIX
53 #  define PREFIX                                                "/opt/apps/org.tizen.camera-app/"
54 #endif
55
56 #define PACKAGE                                                 "camera"
57 #define GRP_MAIN                                                "main"
58 #define LOCALEDIR                                               PREFIX"/res/locale"
59
60 #define EDJ_PATH                                                PREFIX"/res/edje"
61 #define CAM_IMAGE_PATH                                  PREFIX"/res/images/"
62
63 #define CAM_MAIN_LAYOUT_EDJ_NAME                                                EDJ_PATH"/cam_main_layout.edj"
64
65 #define CAM_RECORDING_EDJ_NAME                                                  EDJ_PATH"/cam_recording_edje.edj"
66 #define CAM_RECORDING_INVERSE_EDJ_NAME                                  EDJ_PATH"/cam_recording_edje_inverse.edj"
67 #define CAM_RECORDING_VERTICAL_EDJ_NAME                                 EDJ_PATH"/cam_recording_edje_vertical.edj"
68 #define CAM_RECORDING_VERTICAL_INVERSE_EDJ_NAME                 EDJ_PATH"/cam_recording_edje_vertical_inverse.edj"
69
70 #define CAM_TOOLBAR_LAYOUT_EDJ_NAME                                             EDJ_PATH"/cam_toolbar_layout.edj"
71 #define CAM_TOOLBAR_LAYOUT_INVERSE_EDJ_NAME                             EDJ_PATH"/cam_toolbar_layout_inverse.edj"
72 #define CAM_TOOLBAR_LAYOUT_VERTICAL_EDJ_NAME                    EDJ_PATH"/cam_toolbar_layout_vertical.edj"
73 #define CAM_TOOLBAR_LAYOUT_VERTICAL_INVERSE_EDJ_NAME    EDJ_PATH"/cam_toolbar_layout_vertical_inverse.edj"
74
75 #define CAM_SETTING_POPUP_STYLE_EDJ_NAME                                EDJ_PATH"/style_ctxpopup_camera.edj"
76 #define CAM_SETTING_POPUP_STYLE_WITH_RADIO_EDJ_NAME             EDJ_PATH"/style_ctxpopup_camera_with_radio.edj"
77 #define CAM_SETTING_POPUP_LAYOUT_EDJ_NAME                               EDJ_PATH"/cam_setting_popup_layout.edj"
78 #define CAM_SLIDER_STYLE_EDJ_NAME                                               EDJ_PATH"/style_slider_camera.edj"
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 #define CAM_ZOOM_EDJ_NAME                                                               EDJ_PATH"/cam_zoom_layout.edj"
84 #define CAM_ZOOM_EDJ_INVERSE_NAME                                               EDJ_PATH"/cam_zoom_layout_inverse.edj"
85 #define CAM_ZOOM_EDJ_VERTICAL_NAME                                              EDJ_PATH"/cam_zoom_layout_vertical.edj"
86 #define CAM_ZOOM_EDJ_VERTICAL_INVERSE_NAME                              EDJ_PATH"/cam_zoom_layout_vertical_inverse.edj"
87
88 #define IMAGE_VIEWER_VIEW_MODE_KEY_NAME "View Mode"
89 #define IMAGE_VIEWER_FILE_PATH_KEY_NAME "Path"
90 #define IMAGE_VIEWER_SET_AS_TYPE "Setas type"
91 #define IMAGE_VIEWER_UG_NAME "image-viewer-efl"
92
93 #define AF_FAIL                                                 PREFIX"/share/camera/sounds/af_fail.wav"
94 #define SHUTTER                                                 PREFIX"/share/camera/sounds/Shutter_02.wav"
95 #define RECORD_START_SOUND  PREFIX"/share/camera/sounds/cam_start_01.wav"
96 #define RECORD_STOP_SOUND   PREFIX"/share/camera/sounds/cam_stop_01.wav"
97
98 #define PICTURE_PATH                            PREFIX"/share/camera/pictures"
99 #define VIDEO_PATH                                      PREFIX"/share/camera/videos"
100
101 #define PREVIEW_WIDTH                           640
102 #define PREVIEW_HEIGHT                  480
103
104 #define WINDOW_W                                        640     /* 400 */ /*1280*/
105 #define WINDOW_H                                        480     /* 240 */ /*720*/
106
107 #define AUL_SERVICE_MIME_TYPE_IMAGE     "image/jpg"
108 #define AUL_SERVICE_MIME_TYPE_VIDEO     "video/3gp"
109 #define APP_SERVICE_DEFAULT_CALLER_NAME "3rd_Party_App"
110 #define APP_SERVICE_MESSAGE_APP "message"
111
112 #define FAKE_IMAGE_PKG_NAME     "org.tizen.camera"
113
114 #define DEFAULT_WIN_ANGLE (270)
115
116 #define CAM_FILE_PATH_MAX 1024
117 #define EFL_TEMP_CODE
118 /* #define USE_CAMERA_APP_SHUTTER_SOUND 1 */
119 /* #define ENABLE_CAPTURE_ANIMATION */
120
121 struct appdata {
122         Evas *evas;
123         Ecore_Evas *ee;
124         Evas_Object *win_main;
125         Ecore_X_Window main_xid;
126         Ecore_Pipe *main_pipe;
127         CamLaunchType launch_type;
128         CamAppCoreState appcore_state;
129
130
131         app_device_orientation_e rot_current;
132         app_device_orientation_e rot_previous;
133
134
135         int angle_pre;
136         int angle;
137         int rotate_angle;
138         int previous_win_rotate_angle;
139         gboolean is_rotating;
140
141         int camcorder_rotate;
142
143         Evas_Object *layout_main;       /* layout widget based on EDJ */
144         Evas_Object *black_screen;
145
146 #ifdef ENABLE_CAPTURE_ANIMATION
147         Evas_Object *shutter_screen;
148         Evas_Object *shutter_move_image;
149
150         CamRectangle shutter_src_rect;
151         CamRectangle shutter_des_rect;
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_outside;
163         int af_x;
164         int af_y;
165         double camera_focus_w;  /* size of focus image */
166         double camera_focus_h;  /* size of focus image */
167
168         int touch_lcd_x;        /* lcd x */
169         int touch_lcd_y;        /* lcd y */
170
171         int preview_offset_x;
172         int preview_offset_y;
173         int preview_w;
174         int preview_h;
175
176         int target_direction;
177         Evas_Object *toolbar_edje;
178
179         Evas_Object *toolbar_edje_landscape;
180         Evas_Object *toolbar_edje_portrait;
181         Evas_Object *toolbar_edje_landscape_inverse;
182         Evas_Object *toolbar_edje_portrait_inverse;
183         char *toolbar_edj_file;
184         struct {
185
186                 struct {
187                         Evas_Object *edje_landscape;
188                         Evas_Object *edje_portrait;
189                         Evas_Object *edje_landscape_inverse;
190                         Evas_Object *edje_portrait_inverse;
191
192                         Evas_Object *edje;
193                         Evas_Object *camera_icon;
194                         Evas_Object *camcorder_icon;
195                         bool is_dimmed;
196                 } mode_item;
197
198                 struct {
199                         Evas_Object *edje;
200                         Evas_Object *edje_landscape;
201                         Evas_Object *edje_portrait;
202                         Evas_Object *edje_landscape_inverse;
203                         Evas_Object *edje_portrait_inverse;
204
205                         Evas_Object *thumbnail_image;
206                 } quickview_item;
207
208                 Ecore_Timer *conti_shot_timer;
209         } toolbar;
210
211         Evas_Object *toolbar_0_icon; /*setting icon*/
212         Evas_Object *toolbar_1_icon;
213         Evas_Object *toolbar_2_icon;
214         Evas_Object *toolbar_3_icon;
215         Evas_Object *toolbar_4_icon;
216
217         int toolbar_0_type;
218         int toolbar_1_type;
219         int toolbar_2_type;
220         int toolbar_3_type;
221         int toolbar_4_type;
222
223         Evas_Object *shutterbtn;
224         Evas_Object *shutterbtn_camera_icon;
225         Evas_Object *shutterbtn_camcorder_icon;
226
227         Evas_Object *backbtn;
228
229         Evas_Object *focus_edje;
230         Evas_Object *indicator_edje;
231         Evas_Object *zoom_edje;
232         Evas_Object *zoom_text_min_edje;
233         Evas_Object *zoom_text_max_edje;
234         Evas_Object *recording_edje;
235         Evas_Object *capturebtn_edje;
236
237
238 #ifdef GUIDE_LINE_ENALBE
239         Evas_Object *guideline_edje;
240 #endif
241
242         Evas_Object *progressbar_edje;
243         Evas_Object *progressbar;
244
245         Elm_Object_Item *timer_item;
246         Elm_Object_Item *setting_select_item;
247
248         Evas_Object *radio;     /* radio button */
249         Evas_Object *guideline_radio;   /* radio button */
250         Evas_Object *timer_radio;
251         Evas_Object *genlist;
252
253         int effect_radio_index;
254         int timer_radio_index;
255
256         Evas_Object *toolbar_popup; /*I think this evas_object have no use,fix me*/
257         Evas_Object *toolbar_setting_popup;
258         Evas_Object *toolbar_setting_ctxpopup;
259         Evas_Object *toolbar_setting_popup_content;
260         bool toolbar_show_setting_popup;
261         Ecore_Idler *toolbar_setting_popup_idler;
262
263         bool toolbar_show_edit_shortcuts_popup;
264
265         Evas_Object *setting_ctxpopup;
266         Evas_Object *ctxpopup_area;
267         Evas_Object *setting_ctxpopup_area;
268
269         Evas_Object *edit_shortcuts_popup;
270         Evas_Object *edit_shortcuts_popup_ctx;
271         Evas_Object *edit_shortcuts_popup_scroll;
272         Evas_Object *edit_shortcuts_popup_description;/*note: text part*/
273         /* continous */
274         struct {
275                 Evas_Object *layout_edje;
276                 Evas_Object *gengrid;
277                 Eina_List *item_list;
278         } conti_review;
279
280         Evas_Object *progress_popup;
281         Evas_Object *progress_popup_bar;
282
283         Ecore_Event_Handler *key_up;
284         Ecore_Event_Handler *key_down;
285         Ecore_Event_Handler *mouse_up;
286         Ecore_Event_Handler *mouse_down;
287         Ecore_Event_Handler *mouse_move;
288
289         Ecore_Idler *recording_commit;
290
291         /* Idle handler of capture callback. wh01.cho@samsung.com. 2010-12-15. */
292         Ecore_Idler *still_captured_idle;
293         Ecore_Idler *capture_idle;
294         GList *capture_cb_list;
295 #ifdef ENABLE_CAPTURE_ANIMATION
296         MMCamcorderCaptureDataType capture_datatype;
297 #endif
298
299         Ecore_Timer *rec_icon_updater;
300         Ecore_Timer *rec_time_updater;
301         Ecore_Timer *rec_pause_timer;
302
303         Ecore_Timer *popup_timer;
304         Evas_Object *waring_popup;
305         Evas_Object *confirm_popup;
306         int recording_state;
307
308         /* auto shot */
309         Ecore_Idler *auto_shot_idle;
310
311         /* general */
312         Ecore_Timer *timeout_checker;
313         Ecore_Timer *auto_close_timer;
314         Ecore_Timer *setting_toolbar_hide_timer;
315
316         Ecore_Timer *continuous_af_timer;
317
318         Ecore_Timer *toolbar_toggle_timer;
319         int toolbar_hided;
320
321         bool timer_activated;
322         Ecore_Timer *timer_timer;
323         int timer_count;
324         Evas_Object *timer_icon_edje;
325
326         CamAppData *camapp_handle;
327         ShortCutData *shortcut_data; /*save now moving or touch shortcut*/
328
329         /* Launching Mode */
330         int launching_mode;
331         /*app service mime type*/
332         char *aul_service_mime;
333         /*camera app is called by this app using app service */
334         char *appsvc_caller;
335         /* exe args */
336         CamExeArgs *exe_args;
337
338         /* Thread for file register */
339 #ifdef USE_FILE_REG_THREAD
340         pthread_t file_reg_thread;
341         pthread_mutex_t file_reg_mutex;
342         pthread_cond_t file_reg_cond;
343         GQueue *file_reg_queue;
344 #endif
345
346         pthread_t camera_start_thread;
347
348         ui_gadget_h imageviewer_ug;
349         gboolean ug_is_deleting_process; /*note: now ug is deleting process, and run into camera preview process*/
350         service_h imageviewer_service;
351
352         int mm_state;
353         gboolean isGrabed;
354
355         Ecore_Idler *update_thumbnail_idler;
356         Ecore_Timer *thumbnail_hide_timer;
357
358         Ecore_Timer *longpress_timer;
359         gboolean up_key;
360         gboolean shutter_move;
361         /*checking exist result snapshot popup*/
362         gboolean is_showing_snapshot_popup;
363
364         int cancel_key_press;
365         int is_recording;
366
367         gboolean path_in_return;
368         int show_menu;
369         int displayed_setting_popup;
370         int enable_mode_change;
371         int stop_continuous_shot;
372         /*check out low battery */
373         gboolean battery_status;
374         /*check torch light*/
375         gboolean torchlight_on;
376
377         /* during the call */
378         int is_calling;
379         int foucs_out_from_quickview;
380 #ifdef USE_CAMERA_APP_SHUTTER_SOUND
381         int play_rec_sound;
382 #endif
383         Evas_Object *auto_close_popup;
384         Evas_Object *restore_default_popup;
385         Evas_Object *zoom_warring_popup;
386         int auto_close_count;
387
388         int last_camera_zoom_mode;
389
390         /* guide screen */
391         Evas_Object *shot_mode_guide_popup;
392
393         service_h service_handle;
394         cam_menu_composer* setting_menu_composer;
395
396         /*note: remained_count*/
397         int remained_count;
398 };
399
400
401
402 extern void *handle;
403 gboolean open_cam_ext_handle();
404 gboolean open_cam_handle(void* data);
405 void close_cam_ext_handle();
406 gboolean cam_toolbar_menu_config_init(void *data, int mode);
407 gboolean cam_toolbar_menu_config_update(void *data);
408
409 int update_ts_main(void *data);
410
411 #endif                          /* __DEF_CAM_H__ */