Updating INI configuration file to work with most cameras.
[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
119 /*#define ENABLE_CAM_POWER_CONTROL*/
120
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 *win_main;
128         Ecore_X_Window main_xid;
129         Ecore_Pipe *main_pipe;
130         CamLaunchType launch_type;
131         CamAppCoreState appcore_state;
132
133
134         app_device_orientation_e rot_current;
135         app_device_orientation_e rot_previous;
136
137
138         int angle_pre;
139         int angle;
140         int rotate_angle;
141         int previous_win_rotate_angle;
142         gboolean is_rotating;
143
144         int camcorder_rotate;
145
146         Evas_Object *layout_main;       /* layout widget based on EDJ */
147         Evas_Object *black_screen;
148
149 #ifdef ENABLE_CAPTURE_ANIMATION
150         Evas_Object *shutter_screen;
151         Evas_Object *shutter_move_image;
152
153         CamRectangle shutter_src_rect;
154         CamRectangle shutter_des_rect;
155 #endif
156
157         int win_width;
158         int win_height;
159
160         int camfw_video_width;
161         int camfw_video_height;
162
163         double af_start_x;      /* area start coordination */
164         double af_start_y;      /* area start coordination */
165         int af_outside;
166         int af_x;
167         int af_y;
168         double camera_focus_w;  /* size of focus image */
169         double camera_focus_h;  /* size of focus image */
170
171         int touch_lcd_x;        /* lcd x */
172         int touch_lcd_y;        /* lcd y */
173
174         int preview_offset_x;
175         int preview_offset_y;
176         int preview_w;
177         int preview_h;
178
179         int target_direction;
180         Evas_Object *toolbar_edje;
181
182         Evas_Object *toolbar_edje_landscape;
183         Evas_Object *toolbar_edje_portrait;
184         Evas_Object *toolbar_edje_landscape_inverse;
185         Evas_Object *toolbar_edje_portrait_inverse;
186         char *toolbar_edj_file;
187         struct {
188
189                 struct {
190                         Evas_Object *edje_landscape;
191                         Evas_Object *edje_portrait;
192                         Evas_Object *edje_landscape_inverse;
193                         Evas_Object *edje_portrait_inverse;
194
195                         Evas_Object *edje;
196                         Evas_Object *camera_icon;
197                         Evas_Object *camcorder_icon;
198                         bool is_dimmed;
199                 } mode_item;
200
201                 struct {
202                         Evas_Object *edje;
203                         Evas_Object *edje_landscape;
204                         Evas_Object *edje_portrait;
205                         Evas_Object *edje_landscape_inverse;
206                         Evas_Object *edje_portrait_inverse;
207
208                         Evas_Object *thumbnail_image;
209                 } quickview_item;
210
211                 Ecore_Timer *conti_shot_timer;
212         } toolbar;
213
214         Evas_Object *toolbar_0_icon; /*setting icon*/
215         Evas_Object *toolbar_1_icon;
216         Evas_Object *toolbar_2_icon;
217         Evas_Object *toolbar_3_icon;
218         Evas_Object *toolbar_4_icon;
219
220         int toolbar_0_type;
221         int toolbar_1_type;
222         int toolbar_2_type;
223         int toolbar_3_type;
224         int toolbar_4_type;
225
226         Evas_Object *shutterbtn;
227         Evas_Object *shutterbtn_camera_icon;
228         Evas_Object *shutterbtn_camcorder_icon;
229
230         Evas_Object *backbtn;
231
232         Evas_Object *focus_edje;
233         Evas_Object *indicator_edje;
234         Evas_Object *zoom_edje;
235         Evas_Object *zoom_text_min_edje;
236         Evas_Object *zoom_text_max_edje;
237         Evas_Object *recording_edje;
238         Evas_Object *capturebtn_edje;
239
240
241 #ifdef GUIDE_LINE_ENALBE
242         Evas_Object *guideline_edje;
243 #endif
244
245         Evas_Object *progressbar_edje;
246         Evas_Object *progressbar;
247
248         Elm_Object_Item *timer_item;
249         Elm_Object_Item *setting_select_item;
250
251         Evas_Object *radio;     /* radio button */
252         Evas_Object *guideline_radio;   /* radio button */
253         Evas_Object *timer_radio;
254         Evas_Object *genlist;
255
256         int effect_radio_index;
257         int timer_radio_index;
258
259         Evas_Object *toolbar_popup; /*I think this evas_object have no use,fix me*/
260         Evas_Object *toolbar_setting_popup;
261         Evas_Object *toolbar_setting_ctxpopup;
262         Evas_Object *toolbar_setting_popup_content;
263         bool toolbar_show_setting_popup;
264         Ecore_Idler *toolbar_setting_popup_idler;
265
266         bool toolbar_show_edit_shortcuts_popup;
267
268         Evas_Object *setting_ctxpopup;
269         Evas_Object *ctxpopup_area;
270         Evas_Object *setting_ctxpopup_area;
271
272         Evas_Object *edit_shortcuts_popup;
273         Evas_Object *edit_shortcuts_popup_ctx;
274         Evas_Object *edit_shortcuts_popup_scroll;
275         Evas_Object *edit_shortcuts_popup_description;/*note: text part*/
276         /* continous */
277         struct {
278                 Evas_Object *layout_edje;
279                 Evas_Object *gengrid;
280                 Eina_List *item_list;
281         } conti_review;
282
283         Evas_Object *progress_popup;
284         Evas_Object *progress_popup_bar;
285
286         Ecore_Event_Handler *key_up;
287         Ecore_Event_Handler *key_down;
288         Ecore_Event_Handler *mouse_up;
289         Ecore_Event_Handler *mouse_down;
290         Ecore_Event_Handler *mouse_move;
291
292         Ecore_Idler *recording_commit;
293
294         /* Idle handler of capture callback. wh01.cho@samsung.com. 2010-12-15. */
295         Ecore_Idler *still_captured_idle;
296         Ecore_Idler *capture_idle;
297         GList *capture_cb_list;
298 #ifdef ENABLE_CAPTURE_ANIMATION
299         MMCamcorderCaptureDataType capture_datatype;
300 #endif
301
302         Ecore_Timer *rec_icon_updater;
303         Ecore_Timer *rec_time_updater;
304         Ecore_Timer *rec_pause_timer;
305
306         Ecore_Timer *popup_timer;
307         Evas_Object *waring_popup;
308         Evas_Object *confirm_popup;
309         int recording_state;
310
311         /* auto shot */
312         Ecore_Idler *auto_shot_idle;
313
314         /* general */
315         Ecore_Timer *timeout_checker;
316         Ecore_Timer *auto_close_timer;
317         Ecore_Timer *setting_toolbar_hide_timer;
318
319         Ecore_Timer *continuous_af_timer;
320
321         Ecore_Timer *toolbar_toggle_timer;
322         int toolbar_hided;
323
324         bool timer_activated;
325         Ecore_Timer *timer_timer;
326         int timer_count;
327         Evas_Object *timer_icon_edje;
328
329         CamAppData *camapp_handle;
330         ShortCutData *shortcut_data; /*save now moving or touch shortcut*/
331
332         /* Launching Mode */
333         int launching_mode;
334         /*app service mime type*/
335         char *aul_service_mime;
336         /*camera app is called by this app using app service */
337         char *appsvc_caller;
338         /* exe args */
339         CamExeArgs *exe_args;
340
341         /* Thread for file register */
342 #ifdef USE_FILE_REG_THREAD
343         pthread_t file_reg_thread;
344         pthread_mutex_t file_reg_mutex;
345         pthread_cond_t file_reg_cond;
346         GQueue *file_reg_queue;
347 #endif
348
349         ui_gadget_h imageviewer_ug;
350         gboolean ug_is_deleting_process; /*note: now ug is deleting process, and run into camera preview process*/
351         service_h imageviewer_service;
352
353         int mm_state;
354         gboolean isGrabed;
355
356         Ecore_Idler *update_thumbnail_idler;
357         Ecore_Timer *thumbnail_hide_timer;
358
359         Ecore_Timer *longpress_timer;
360         gboolean up_key;
361         gboolean shutter_move;
362         /*checking exist result snapshot popup*/
363         gboolean is_showing_snapshot_popup;
364
365         int cancel_key_press;
366         int is_recording;
367
368         gboolean path_in_return;
369         int show_menu;
370         int displayed_setting_popup;
371         int enable_mode_change;
372         int stop_continuous_shot;
373         /*check out low battery */
374         gboolean battery_status;
375         /*check torch light*/
376         gboolean torchlight_on;
377
378         /* during the call */
379         int is_calling;
380         int foucs_out_from_quickview;
381 #ifdef USE_CAMERA_APP_SHUTTER_SOUND
382         int play_rec_sound;
383 #endif
384         Evas_Object *auto_close_popup;
385         Evas_Object *restore_default_popup;
386         Evas_Object *zoom_warring_popup;
387         int auto_close_count;
388
389         int last_camera_zoom_mode;
390
391         /* guide screen */
392         Evas_Object *shot_mode_guide_popup;
393
394         service_h service_handle;
395         cam_menu_composer* setting_menu_composer;
396
397         /*note: remained_count*/
398         int remained_count;
399 };
400
401
402
403 extern void *handle;
404 gboolean open_cam_ext_handle();
405 gboolean open_cam_handle(void* data);
406 void close_cam_ext_handle();
407 gboolean cam_toolbar_menu_config_init(void *data, int mode);
408 gboolean cam_toolbar_menu_config_update(void *data);
409
410 int update_ts_main(void *data);
411
412 #endif                          /* __DEF_CAM_H__ */