2 * Copyright 2012 Samsung Electronics Co., Ltd
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
8 * http://www.tizenopensource.org/license
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.
18 #include <X11/keysymdef.h>
24 #include <syspopup_caller.h>
28 #include "edc_string.h"
29 #include "cam_sound.h"
32 #include "cam_error.h"
33 #include "cam_config.h"
36 #include "cam_devman.h"
37 #include "cam_popup.h"
39 #include "cam_common_edc_callback.h"
40 #include "cam_indicator_edc_callback.h"
41 #include "cam_recording_edc_callback.h"
42 #include "cam_toolbar_edc_callback.h"
43 #include "cam_zoom_edc_callback.h"
44 #include "camera_utils.h"
46 #include "cam_ui_effect_utils.h"
47 #include "cam_ui_rotate_utils.h"
49 #include "cam_menu_composer.h"
50 #include "cam_device_capacity.h"
53 #ifdef ENABLE_CAPTURE_ANIMATION
54 #include "cam_animation.h"
57 #define ZSL_MAX_REL (1280*720) /* 1m wide */
58 #define FOCUS_FOCUSED_TIME_OUT 3
59 #define FOCUS_FAILED_TIME_OUT 2
60 #define THUMBNAIL_UPDATE_WAIT_TIME (100*1000)
64 /* #define ZSL_5M_TEST (2560*1920) */
68 static CamAppData *cam_handle = NULL;
69 static struct appdata *app_handle = NULL;
71 /* static Ecore_Idler *spy_rotation_idler=NULL; */
73 #define TEMP_SAVE_PATH "/tmp/temp_image.jpg" /* not used maybe... */
74 #define SELF_SHOT_TEMP_SAVE_PATH "/tmp/self_temp_shot.jpg"
76 #define LONG_PRESS_INTERVAL 0.5 /* sec */
78 #define INAGE_FILE_NAME "IMAGE"
79 #define VIDEO_FILE_NAME "VIDEO"
80 #define TEMP_FILE_NAME ".camera_result"
81 #define IMAGE_FILE_EXTENSION ".jpg"
82 #define VIDEO_FILE_EXTENSION ".3gp"
84 #define SHUTTER_W_RATIO 0.1
85 #define SHUTTER_H_RATIO 0.34
86 #define SCREEN_RATIO 1.0
87 #define AUTO_CLOSE_COUNT 10
88 /* #define CAMAPP_SIG_HANDLING */
90 /* #define ENABLE_CHECK_CAM_STATUS //provent camera hang, */
92 #ifdef ENABLE_CHECK_CAM_STATUS
93 #define CAM_CHECK_STATUS_INTERVAL_TIME 10
94 #ifndef CAMAPP_SIG_HANDLING
95 #define CAMAPP_SIG_HANDLING
100 static int cam_app_start_rotate(struct appdata *ad, bool bInitial);
101 static void cam_app_get_win_size(struct appdata *ad);
102 #ifdef ENABLE_CHECK_CAM_STATUS
103 static void cam_app_check_status();
106 #ifndef DISABLE_TOOLBAR_TOGGLE
107 static Eina_Bool _cam_app_toolbar_toggle_timer(void *data);
110 static gboolean cam_power_key_press(void *data);
111 static gboolean cam_app_return_ext_app(void *data, const char *r_file_path);
113 /* vconf changed cb */
114 static void cam_app_battery_update_cb(keynode_t *key, void *data);
115 static void cam_app_battery_status_cb(keynode_t *key, void *data);
116 static void cam_mmc_state_change_cb(keynode_t *key, void *data);
117 static void cam_idle_lockstate_change_cb(keynode_t *key, void *data);
118 static void cam_usb_state_change_cb(keynode_t *key, void *data);
119 static void cam_torchlight_update_cb(keynode_t *key, void *data);
121 void cam_app_preview_start_coordinate(CamVideoRectangle src,
122 CamVideoRectangle dst,
123 CamVideoRectangle *result);
124 void cam_app_timeout_notice_response_cb(void *data, Evas_Object *obj, void *event_info);
125 static void cam_app_capture_error_popup_response_cb(void *data, Evas_Object *obj, void *event_info);
126 Eina_Bool cam_app_launch_after_preview_began(void *data);
128 static void cam_app_auto_close_popup_response_cancel_cb(void *data, Evas_Object *obj, void *event_info);
129 static void cam_app_auto_close_popup_response_ok_cb(void *data, Evas_Object *obj, void *event_info);
130 static void cam_app_timer_update_count(void *data);
133 /* video streamming */
134 static gboolean video_stream_skip_flag = false;
136 /* thumbnail image check count */
137 static int g_thumbnail_image_check_count = 0;
140 gboolean g_blocking_popup = false;
142 void cam_app_set_blocking_popup()
144 g_blocking_popup = true;
147 void cam_app_free_blocking_popup()
149 g_blocking_popup = false;
152 gboolean cam_app_check_blocking_popup()
154 return !g_blocking_popup;
157 struct noti_callback {
159 void (*noti_func) (keynode_t *, void *);
162 #define CAMERA_NOTI_MAX 7
163 struct noti_callback notis[CAMERA_NOTI_MAX] = {
164 {VCONFKEY_SYSMAN_BATTERY_CAPACITY, *cam_app_battery_update_cb},
165 {VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, *cam_app_battery_update_cb},
166 {VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, *cam_app_battery_status_cb},
167 {VCONFKEY_SYSMAN_MMC_STATUS, *cam_mmc_state_change_cb},
168 {VCONFKEY_IDLE_LOCK_STATE, *cam_idle_lockstate_change_cb},
169 {VCONFKEY_SYSMAN_USB_STATUS, *cam_usb_state_change_cb},
170 {VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, *cam_torchlight_update_cb}
173 #ifdef CAMAPP_SIG_HANDLING
175 static struct sigaction cam_app_act;
176 static struct sigaction cam_app_act_old;
178 static void cam_app_register_sigsegv(void);
179 static void cam_app_sigsegv_handler(int signal_no, siginfo_t *info,
183 static void cam_app_pipe_handler(void *data, void *buffer, unsigned int nbyte);
184 static int cam_app_state_manager(int previous, int current, gboolean by_asm);
185 static void cam_app_close_ug(void *data);
186 Eina_Bool __ug_destory_postprocessing(void *data);
189 static gboolean cam_app_timeout_checker_update();
190 static Eina_Bool cam_app_timeout_checker_cb(void *data);
192 gdouble _get_current_time(void)
195 gettimeofday(&tv, NULL);
196 return (gdouble) tv.tv_sec + (gdouble) tv.tv_usec / 1E6;
198 void cam_app_zoom_warring_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
201 evas_object_del(obj);
205 void cam_app_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
208 evas_object_del(obj);
213 void cam_app_snapshot_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
215 struct appdata *ad = data;
216 cam_retm_if(ad == NULL, "appdata is NULL");
219 evas_object_del(obj);
222 ad->is_showing_snapshot_popup = FALSE;
223 DEBUG_TRACE("ad->is_showing_snapshot_popup = FALSE");
226 static Eina_Bool cam_delay_popup(void *data)
229 cam_app_notice_popup(data,_("IDS_CAM_POP_UNABLE_TO_START_CAMERA_DURING_CALL"),
230 cam_app_timeout_notice_response_cb);
234 static void cam_add_longpress_key_timer(void *data)
236 struct appdata *ad = (struct appdata *)data;
237 cam_retm_if(ad == NULL, "appdata is NULL");
238 if (!ad->longpress_timer) {
239 ad->longpress_timer =
240 ecore_timer_add(LONG_PRESS_INTERVAL, cam_volume_key_press, ad);
244 static void cam_del_longpress_key_timer(void *data)
246 struct appdata *ad = (struct appdata *)data;
247 cam_retm_if(ad == NULL, "appdata is NULL");
248 if (ad->longpress_timer) {
249 ecore_timer_del(ad->longpress_timer);
250 ad->longpress_timer = 0;
254 Eina_Bool _message_popup_destroy_and_exit(void *data)
256 Evas_Object *obj = (Evas_Object *)data;
257 cam_popup_remove(obj);
260 return ECORE_CALLBACK_CANCEL;
263 Eina_Bool cam_app_real_exit(void *data)
265 struct appdata *ad = (struct appdata *)data;
267 debug_fenter(LOG_UI);
268 cam_retvm_if(ad == NULL, -1, "appdata is NULL");
270 if (ad->timeout_checker) {
271 ecore_timer_del(ad->timeout_checker);
272 ad->timeout_checker = NULL;
275 cam_app_key_event_deinit(ad);
282 void cam_win_transparent_set(void *data)
284 struct appdata *ad = (struct appdata *)data;
285 cam_ret_if(ad == NULL);
289 int width =0, height=0;
290 evas_object_geometry_get(ad->win_main, NULL, NULL, &height, &width);
291 evas = evas_object_evas_get(ad->win_main);
292 rect = evas_object_rectangle_add(evas);
293 evas_object_color_set(rect, 0, 0, 0, 0);
294 evas_object_render_op_set(rect, EVAS_RENDER_COPY);
295 if (width >= height) {
296 evas_object_resize(rect, width, width);
298 evas_object_resize(rect, height, height);
300 evas_object_show(rect);
303 void cam_set_orient_value(void *data)
305 struct appdata *ad = (struct appdata *)data;
306 cam_retm_if(ad == NULL, "appdata is NULL");
307 int orient_value = 0;
309 CamAppData *camapp = ad->camapp_handle;
310 if (camapp->shooting_mode == CAM_SELF_MODE) {
311 switch (ad->rot_current) {
312 case APPCORE_RM_PORTRAIT_NORMAL:
314 DEBUG_TRACE("rot_cuttent=%d orient_value=%d\n",
315 ad->rot_current, orient_value);
317 case APPCORE_RM_PORTRAIT_REVERSE:
319 DEBUG_TRACE("rot_cuttent=%d orient_value=%d\n",
320 ad->rot_current, orient_value);
322 case APPCORE_RM_LANDSCAPE_NORMAL:
324 DEBUG_TRACE("rot_cuttent=%d orient_value=%d\n",
325 ad->rot_current, orient_value);
327 case APPCORE_RM_LANDSCAPE_REVERSE:
329 DEBUG_TRACE("rot_cuttent=%d orient_value=%d\n",
330 ad->rot_current, orient_value);
337 switch (ad->rot_current) {
338 case APP_DEVICE_ORIENTATION_0:
340 DEBUG_TRACE("rot_cuttent=%d orient_value=%d\n",
341 ad->rot_current, orient_value);
343 case APP_DEVICE_ORIENTATION_180:
345 DEBUG_TRACE("rot_cuttent=%d orient_value=%d\n",
346 ad->rot_current, orient_value);
348 case APP_DEVICE_ORIENTATION_90:
350 DEBUG_TRACE("rot_cuttent=%d orient_value=%d\n",
351 ad->rot_current, orient_value);
353 case APP_DEVICE_ORIENTATION_270:
355 DEBUG_TRACE("rot_cuttent=%d orient_value=%d\n",
356 ad->rot_current, orient_value);
362 /*orient_value = CAMERA_ATTR_TAG_ORIENTATION_TOP_LEFT;*/
364 if (cam_mm_set_tag_img_orient(orient_value))
365 DEBUG_TRACE("set image orient succeed %d", orient_value);
367 DEBUG_TRACE("set image orient failed %d", orient_value);
371 int cam_noti_init(void *data)
373 struct appdata *ad = (struct appdata *)data;
376 debug_fenter(LOG_UI);
378 cam_retvm_if(ad == NULL, EXIT_FAILURE, "appdata is NULL");
382 for (i = 0; i < CAMERA_NOTI_MAX; i++) {
384 vconf_notify_key_changed(notis[i].setting_key,
385 notis[i].noti_func, ad)) {
386 cam_critical(LOG_SYS,
387 "vconf_notify_key_changed() failed. count=%d ",
394 int cam_noti_deinit(void *data)
397 struct appdata *ad = (struct appdata *)data;
399 debug_fenter(LOG_SYS);
401 cam_retvm_if(ad == NULL, EXIT_FAILURE, "appdata is NULL");
406 for (i = 0; i < CAMERA_NOTI_MAX; i++) {
407 vconf_ignore_key_changed(notis[i].setting_key,
414 void *cam_appdata_get(void)
422 static void cam_app_get_win_size(struct appdata *ad)
426 cam_ret_if(ad == NULL || ad->win_main == NULL);
427 evas_object_geometry_get(ad->win_main, NULL, NULL, &(ad->win_height),
430 cam_debug(LOG_UI, "main window ----- win_width, win_height: [%d, %d]",
431 ad->win_width, ad->win_height);
434 int cam_appdata_init(void *data)
436 struct appdata *ad = (struct appdata *)data;
437 cam_retvm_if(ad == NULL, 0, "appdata is NULL");
442 ad->main_pipe = ecore_pipe_add(cam_app_pipe_handler, ad);
443 ad->rot_current = app_get_device_orientation();
444 ad->rot_previous = ad->rot_current;
446 cam_app_get_win_size(ad);
448 CAM_TA_ACUM_ITEM_BEGIN(" cam_handle_create", 0);
449 if (!cam_handle_create(data)) {
450 cam_critical(LOG_CAM, "cam_handle_create failed");
453 CAM_TA_ACUM_ITEM_END(" cam_handle_create", 0);
455 ad->last_camera_zoom_mode = 1;
460 int cam_appdata_fini(void *data)
462 struct appdata *ad = (struct appdata *)data;
464 cam_retvm_if(ad == NULL, 0, "appdata is NULL");
466 cam_layout_del_all(ad);
468 if (ad->imageviewer_service) {
469 service_destroy(ad->imageviewer_service);
470 ad->imageviewer_service = NULL;
472 if (ad->timeout_checker) {
473 ecore_timer_del(ad->timeout_checker);
474 ad->timeout_checker = NULL;
477 ecore_event_handler_del(ad->key_down);
481 ecore_event_handler_del(ad->key_up);
485 ecore_event_handler_del(ad->mouse_up);
488 if (ad->mouse_down) {
489 ecore_event_handler_del(ad->mouse_down);
490 ad->mouse_down = NULL;
492 if (ad->recording_commit) {
493 ecore_idler_del(ad->recording_commit);
494 ad->recording_commit = NULL;
496 if (ad->still_captured_idle) {
497 ecore_idler_del(ad->still_captured_idle);
498 ad->still_captured_idle = NULL;
500 if (ad->capture_idle) {
501 ecore_idler_del(ad->capture_idle);
502 ad->capture_idle = NULL;
504 /* Remove Idle handler of capture callback. wh01.cho@samsung.com. 2010-12-15. */
505 if (ad->capture_cb_list) {
506 cam_utils_remove_idler_all(ad);
508 if (ad->auto_shot_idle) {
509 ecore_idler_del(ad->auto_shot_idle);
510 ad->auto_shot_idle = NULL;
512 if (ad->update_thumbnail_idler) {
513 ecore_idler_del(ad->update_thumbnail_idler);
514 ad->update_thumbnail_idler = NULL;
516 if (ad->timer_timer) {
517 ecore_timer_del(ad->timer_timer);
518 ad->timer_timer = NULL;
520 if (ad->timeout_checker) {
521 ecore_timer_del(ad->timeout_checker);
522 ad->timeout_checker = NULL;
524 if (ad->rec_icon_updater) {
525 ecore_timer_del(ad->rec_icon_updater);
526 ad->rec_icon_updater = NULL;
528 if (ad->rec_time_updater) {
529 ecore_timer_del(ad->rec_time_updater);
530 ad->rec_time_updater = NULL;
532 if( ad->setting_menu_composer != NULL){
533 cam_compose_free(ad->setting_menu_composer);
535 if (ad->camapp_handle) {
539 if (ad->exe_args->caller) {
540 free(ad->exe_args->caller);
541 ad->exe_args->caller = NULL;
546 #ifdef USE_FILE_REG_THREAD
548 if (ad->file_reg_thread) {
549 pthread_join(ad->file_reg_thread, NULL);
552 if (ad->file_reg_queue) {
553 while (!g_queue_is_empty(ad->file_reg_queue)) {
554 char *filename = NULL;
555 filename = g_queue_pop_head(ad->file_reg_queue);
557 cam_critical(LOG_FILE, "[%s] didn't processed",
560 if (!strcmp(REG_THREAD_EXIT, filename)) {
563 __cam_single_shot_reg_file(filename);
565 cam_debug(LOG_FILE, " register done.");
568 g_queue_free(ad->file_reg_queue);
569 ad->file_reg_queue = NULL;
574 ecore_pipe_del(ad->main_pipe);
575 ad->main_pipe = NULL;
577 /* init global handle */
583 CamAppData *cam_handle_get(void)
591 gboolean cam_app_init(void *data)
593 struct appdata *ad = (struct appdata *)data;
594 GError *error = NULL;
596 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
598 CAM_TA_ACUM_ITEM_BEGIN(" cam_appdata_init", 0);
599 if (!cam_appdata_init(ad)) {
600 cam_critical(LOG_CAM, "cam_appdata_init failed");
603 CAM_TA_ACUM_ITEM_END(" cam_appdata_init", 0);
605 cam_retvm_if(ad->camapp_handle == NULL, FALSE, "camapp_handle is NULL");
607 CAM_TA_ACUM_ITEM_BEGIN(" cam_config_init", 0);
608 if (!cam_config_init(&error)) {
609 cam_critical(LOG_SYS, "cam_config_init failed");
611 cam_critical(LOG_SYS, "cam_config_init error [%s]",
618 CAM_TA_ACUM_ITEM_END(" cam_config_init", 0);
620 CAM_TA_ACUM_ITEM_BEGIN(" cam_noti_init", 0);
621 if (EXIT_FAILURE == cam_noti_init(ad)) {
622 cam_critical(LOG_CAM, "cam_noti_init failed");
624 CAM_TA_ACUM_ITEM_END(" cam_noti_init", 0);
626 CAM_TA_ACUM_ITEM_BEGIN(" cam_file_init", 0);
627 if (!cam_file_init(&error)) {
628 cam_critical(LOG_FILE, "cam_file_init failed");
630 cam_critical(LOG_FILE, "cam_file_init error [%s]",
637 CAM_TA_ACUM_ITEM_END(" cam_file_init", 0);
638 CAM_TA_ACUM_ITEM_BEGIN(" cam_sound_init", 0);
639 if (!cam_sound_init(&error)) {
640 cam_critical(LOG_SND, "cam_sound_init failed");
642 cam_critical(LOG_SND, "cam_sound_init error [%s]",
649 CAM_TA_ACUM_ITEM_END(" cam_sound_init", 0);
651 #ifdef USE_FILE_REG_THREAD
652 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_create_file_register_thread", 0);
653 if (!cam_app_create_file_register_thread(ad)) {
654 cam_critical(LOG_SYS,
655 " cam_app_create_file_register_thread failed");
658 CAM_TA_ACUM_ITEM_END(" cam_app_create_file_register_thread", 0);
661 #ifdef CAMAPP_SIG_HANDLING
662 /* register singal handler */
663 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_create_file_register_thread", 0);
664 cam_app_register_sigsegv();
665 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_create_file_register_thread", 0);
669 CAM_TA_ACUM_ITEM_BEGIN(" cam_devman_init", 0);
670 if (!cam_devman_init(ad)) {
671 cam_critical(LOG_SYS, " cam_devman_init failed");
674 CAM_TA_ACUM_ITEM_END(" cam_devman_init", 0);
677 if(media_content_connect() == MEDIA_CONTENT_ERROR_NONE) {
678 DEBUG_TRACE("connection is success");
680 cam_critical(LOG_SYS, " media_content_connect failed");
691 gboolean cam_app_start(void *data)
693 CAM_TA_ACUM_ITEM_BEGIN("#########cam_app_start", 0);
695 struct appdata *ad = (struct appdata *)data;
696 CamAppData *camapp = NULL;
697 /*int session_type;*/
699 debug_fenter(LOG_CAM);
701 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
702 camapp = ad->camapp_handle;
703 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
705 /*init guideline value*/
706 #ifdef GUIDE_LINE_ENALBE
707 camapp->guideline = FALSE;
710 CAM_TA_ACUM_ITEM_BEGIN(" cam_mm_create", 0);
711 if (cam_mm_is_created() == FALSE) {
712 if (!cam_mm_create(CAM_DEVICE_MEGA, camapp->camera_mode)) {
713 cam_critical(LOG_MM, "cam_mm_create failed");
714 cam_app_notice_popup(ad, "UNABLE TO LAUNCH CAMERA", cam_app_timeout_notice_response_cb);
718 CAM_TA_ACUM_ITEM_END(" cam_mm_create", 0);
720 CAM_TA_ACUM_ITEM_BEGIN(" cam_callback_init", 0);
721 if (!cam_callback_init(ad)) {
722 cam_critical(LOG_CAM, "cam_init_mm_callback failed");
723 cam_app_notice_popup(ad, "UNABLE TO START PREVIEW", cam_app_timeout_notice_response_cb);
726 CAM_TA_ACUM_ITEM_END(" cam_callback_init", 0);
728 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_init_attribute", 0);
729 if (!cam_app_init_attribute(ad, camapp->camera_mode)) {
730 cam_critical(LOG_MM, "cam_app_init_attribute failed");
733 CAM_TA_ACUM_ITEM_END(" cam_app_init_attribute", 0);
735 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_preview_start", 0);
738 * TODO: this func dealt with efl ui api, but cam_app_start is called in thread.
739 * We should consider it carefully.
741 cam_continuous_af_start(ad);
742 if (!cam_app_preview_start(ad)) {
743 if (ad->is_calling == CAMERA_ERROR_SOUND_POLICY ||ad->is_calling == RECORDER_ERROR_SOUND_POLICY) {
744 DEBUG_TRACE(" MM CAMCARORDER ERROR\n");
745 cam_app_black_screen_show(ad, 2);
746 ecore_timer_add(0.01, cam_delay_popup, (void *)ad);
750 cam_critical(LOG_MM, "cam_app_preview_start failed");
751 cam_app_notice_popup(ad, "UNABLE TO START PREVIEW", cam_app_timeout_notice_response_cb);
754 CAM_TA_ACUM_ITEM_END(" cam_app_preview_start", 0);
756 if(!cam_key_grab_init(ad))
757 DEBUG_TRACE("cam_key_grab_init fail");
758 cam_app_key_event_init(ad);
759 cam_app_timeout_checker_init(ad);
761 #ifdef ENABLE_CHECK_CAM_STATUS
762 alarm(CAM_CHECK_STATUS_INTERVAL_TIME); /* start alarm */
764 CAM_TA_ACUM_ITEM_END("#########cam_app_start", 0);
769 gboolean cam_app_pause(void *data)
771 DEBUG_TRACE("#############cam_app_pause - START #############\n");
772 struct appdata *ad = (struct appdata *)data;
773 CamAppData *camapp = NULL;
774 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
775 camapp = ad->camapp_handle;
776 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
779 mm_state = cam_mm_get_state();
781 if (ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
782 if ((ad->exe_args->caller) && (strcmp(ad->exe_args->caller, "contacts") == 0)) {
783 DEBUG_TRACE(" contact is paused ");
785 service_create(&reply);
786 service_add_extra_data(reply, "camera_end", "1");
787 service_reply_to_launch_request(reply, ad->service_handle, SERVICE_RESULT_CANCELED);
788 service_destroy(reply);
792 if ((mm_state == RECORDER_STATE_RECORDING
793 || mm_state == RECORDER_STATE_PAUSED)
794 &&(camapp->camera_mode == CAM_CAMCORDER_MODE)) {
795 int shutter_sound_state = 0;
796 /* get current sound */
797 cam_mm_get_shutter_sound(&shutter_sound_state);
798 /* disable shutter sound */
799 cam_mm_set_shutter_sound(FALSE);
801 cam_video_record_stop(ad);
802 /*restore shutter sound */
803 cam_mm_set_shutter_sound(shutter_sound_state);
804 } else if (mm_state == CAMERA_STATE_CAPTURING
805 && (camapp->camera_mode == CAM_CAMERA_MODE)) {
806 cam_mm_capture_stop(TRUE, CAM_CAMERA_MODE);
809 if (ad->imageviewer_ug) { /* image viewer is running and camera app is fous out */
810 ad->foucs_out_from_quickview = TRUE;
812 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_preview_stop", 0);
813 if (!cam_app_preview_stop()) {
814 cam_critical(LOG_MM, "cam_app_preview_stop fail");
816 CAM_TA_ACUM_ITEM_END(" cam_app_preview_stop", 0);
818 cam_app_key_event_deinit(ad);
819 if (!cam_key_grab_deinit(ad)) {
820 DEBUG_TRACE("cam_key_grab_deinit fail");
823 cam_app_timeout_checker_init(ad);
825 DEBUG_TRACE("#############cam_app_pause - END #############\n");
829 gboolean cam_app_resume(void *data)
831 struct appdata *ad = (struct appdata *)data;
832 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
834 CamAppData *camapp = NULL;
835 camapp = ad->camapp_handle;
836 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
839 debug_fenter(LOG_CAM);
841 if (!cam_condition_check_to_start_camera(ad)) {
842 cam_critical(LOG_CAM, "cannot start camera");
843 return ECORE_CALLBACK_CANCEL;
846 cam_app_timeout_checker_init(ad);
848 if (ad->imageviewer_ug == NULL) { /* home key destory imageviewer_ug */
849 elm_win_indicator_mode_set(ad->win_main, ELM_WIN_INDICATOR_HIDE);
850 cam_state = cam_mm_get_state();
851 cam_app_get_preview_offset_coordinate(ad);
853 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_preview_start", 0);
854 if (!cam_app_preview_start(ad)) {
855 if (ad->is_calling == CAMERA_ERROR_SOUND_POLICY || ad->is_calling == RECORDER_ERROR_SOUND_POLICY) {
856 DEBUG_TRACE(" MM CAMCARORDER ERROR\n");
857 cam_app_black_screen_show(ad, 2);
858 ecore_timer_add(0.01, cam_delay_popup, (void *)ad);
862 cam_critical(LOG_MM, "cam_app_preview_start failed");
863 cam_app_notice_popup(ad,
864 "PREVIEW START FAILED !!",
865 cam_app_timeout_notice_response_cb);
868 CAM_TA_ACUM_ITEM_END(" cam_app_preview_start", 0);
871 CAM_TA_ACUM_ITEM_BEGIN(" cam_key_grab_init", 0);
873 if (!ad->imageviewer_ug) {
874 if (!cam_key_grab_init(ad))
875 DEBUG_TRACE("cam_key_grab_init fail");
876 CAM_TA_ACUM_ITEM_END(" cam_key_grab_init", 0);
877 cam_app_key_event_init(ad);
879 #ifdef ENABLE_CHECK_CAM_STATUS
880 alarm(CAM_CHECK_STATUS_INTERVAL_TIME); /* start alarm */
886 Eina_Bool cam_app_stop(void *data)
888 struct appdata *ad = (struct appdata *)data;
889 CamAppData *camapp = NULL;
891 char *filename = NULL;
892 debug_fenter(LOG_CAM);
893 cam_retvm_if(ad == NULL, EXIT_FAILURE, "appdata is NULL");
895 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_stop", 0);
897 camapp = ad->camapp_handle;
898 cam_retvm_if(camapp == NULL, EXIT_FAILURE, "camapp_handle is NULL");
900 /* return aul result path */
901 if (ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
902 if (ad->exe_args == NULL) {
903 DEBUG_TRACE("ad->exe_args is NULL");
906 if (ad->path_in_return) {
907 if ((ad->exe_args->caller) && (strcmp(ad->exe_args->caller, "contacts") == 0)) {
908 DEBUG_TRACE("contacts -not need sending result");
910 if (ad->appcore_state != CAM_APPCORE_PAUSE_STATE) {
911 if (camapp->filename != NULL) {
912 filename = strdup(camapp->filename);
913 cam_app_return_ext_app(ad, filename);
918 cam_app_return_ext_app(ad, filename);
922 if (ad->imageviewer_ug) {
923 cam_app_close_ug(ad);
926 cam_popup_remove_all();
927 cam_toolbar_destroy(ad);
928 cam_app_clear_engine_data(ad, true);
930 if (ad->timer_activated) {
931 ad->timer_activated = false;
933 DEL_EVAS_OBJECT(ad->timer_icon_edje);
934 REMOVE_TIMER(ad->timer_timer);
936 REMOVE_TIMER(ad->toolbar_toggle_timer);
937 cam_app_timeout_checker_remove();
938 if (ad->auto_close_timer) {
939 ecore_timer_del(ad->auto_close_timer);
940 ad->auto_close_timer = NULL;
943 if (EXIT_FAILURE == cam_noti_deinit(ad)) {
944 cam_critical(LOG_UI, "cam_noti_deinit failed");
947 cam_app_key_event_deinit(ad);
948 if(!cam_key_grab_deinit(ad))
949 DEBUG_TRACE("cam_key_grab_deinit fail");
951 /* destory camcorder */
952 if (cam_mm_is_created()) {
954 state = cam_mm_get_state();
955 if (camapp->camera_mode == CAM_CAMERA_MODE) {
957 case CAMERA_STATE_NONE:
958 case CAMERA_STATE_CREATED:
960 case CAMERA_STATE_PREVIEW:
962 case CAMERA_STATE_CAPTURING:
963 cam_mm_capture_stop(TRUE, CAM_CAMERA_MODE);
965 case CAMERA_STATE_CAPTURED:
968 /*g_assert_not_reached();*/
971 }else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
973 case RECORDER_STATE_NONE:
974 case RECORDER_STATE_CREATED:
976 case RECORDER_STATE_READY:
978 case RECORDER_STATE_RECORDING:
979 case RECORDER_STATE_PAUSED:
980 cam_video_record_stop(ad);
983 /*g_assert_not_reached();*/
988 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_preview_stop", 0);
989 if (!cam_app_preview_stop()) {
990 cam_critical(LOG_MM, "cam_app_preview_stop faild");
992 CAM_TA_ACUM_ITEM_END(" cam_app_preview_stop", 0);
993 CAM_TA_ACUM_ITEM_BEGIN(" cam_mm_destory", 0);
994 if (!cam_mm_destory()) {
995 cam_critical(LOG_MM, "cam_mm_destory faild");
997 CAM_TA_ACUM_ITEM_END(" cam_mm_destory", 0);
1001 ad->toolbar_hided = FALSE;
1002 cam_app_toggle_indicator(ad, FALSE);
1003 cam_app_toggle_toolbar(ad, FALSE);
1005 /* Idler of capture callback management. wh01.cho@samsung.com. 2010-12-15. */
1006 cam_app_destroy_progressbar(ad);
1007 cam_utils_remove_idler_all(ad);
1009 if (filename != NULL) {
1014 CAM_TA_ACUM_ITEM_END(" cam_app_stop", 0);
1016 CAM_TA_ACUM_ITEM_SHOW_RESULT_TO(CAM_TA_SHOW_FILE);
1019 return EXIT_SUCCESS;
1023 gboolean cam_app_quit(void *data)
1025 struct appdata *ad = (struct appdata *)data;
1026 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1028 if (cam_mm_is_created()) {
1029 /*TODO: new logic will be add for save file while camera process is killed*/
1032 state = cam_mm_get_state();
1033 if (ad->camapp_handle) {
1034 if (ad->camapp_handle->camera_mode == CAM_CAMCORDER_MODE) {
1036 case RECORDER_STATE_NONE:
1037 case RECORDER_STATE_CREATED:
1039 case RECORDER_STATE_READY:
1041 case RECORDER_STATE_RECORDING:
1042 case RECORDER_STATE_PAUSED:
1043 cam_video_record_stop(ad);
1046 /*g_assert_not_reached();*/
1052 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_preview_stop", 0);
1053 if (!cam_app_preview_stop()) {
1054 cam_critical(LOG_MM, "cam_app_preview_stop failed");
1056 CAM_TA_ACUM_ITEM_END(" cam_app_preview_stop", 0);
1058 CAM_TA_ACUM_ITEM_BEGIN(" cam_mm_destory", 0);
1059 if (!cam_mm_destory()) {
1060 cam_critical(LOG_MM, "cam_mm_destory failed");
1062 CAM_TA_ACUM_ITEM_END(" cam_mm_destory", 0);
1065 cam_devman_deinit();
1068 if (EXIT_FAILURE == cam_noti_deinit(ad)) {
1069 cam_critical(LOG_UI, "cam_noti_deinit failed");
1071 /* crear data & engine */
1072 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_clear_engine_data", 0);
1073 cam_app_clear_engine_data(data, true);
1074 CAM_TA_ACUM_ITEM_END(" cam_app_clear_engine_data", 0);
1075 CAM_TA_ACUM_ITEM_BEGIN(" cam_file_finalize", 0);
1076 cam_file_finalize();
1077 CAM_TA_ACUM_ITEM_END(" cam_file_finalize", 0);
1078 CAM_TA_ACUM_ITEM_BEGIN(" cam_sound_finalize", 0);
1079 cam_sound_finalize();
1080 CAM_TA_ACUM_ITEM_END(" cam_sound_finalize", 0);
1082 CAM_TA_ACUM_ITEM_BEGIN(" cam_config_finalize", 0);
1083 cam_config_finalize();
1084 CAM_TA_ACUM_ITEM_END(" cam_config_finalize", 0);
1086 /* disconnect media content */
1087 CAM_TA_ACUM_ITEM_BEGIN(" media_content_disconnect", 0);
1089 if(media_content_disconnect() == MEDIA_CONTENT_ERROR_NONE) {
1090 DEBUG_TRACE("dis connection is success");
1092 cam_critical(LOG_SYS, " media_content_disconnect failed");
1095 CAM_TA_ACUM_ITEM_END(" media_content_disconnect", 0);
1097 /* cam_handle_free(ad); */
1098 cam_appdata_fini(ad);
1103 gboolean cam_app_preview_start(void *data)
1105 CAM_TA_ACUM_ITEM_BEGIN("----cam_app_preview_start", 0);
1107 ("------------------------------START---------------------------------");
1109 struct appdata *ad = (struct appdata *)data;
1110 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1111 CamAppData *camapp = ad->camapp_handle;
1112 cam_retvm_if(camapp == NULL, FALSE, "camapp is NULL");
1114 int state = cam_mm_get_state();
1115 DEBUG_TRACE("state: %d ", state);
1117 if (state < CAMERA_STATE_NONE || state < RECORDER_STATE_NONE)
1120 if (camapp->camera_mode == CAM_CAMERA_MODE) {
1122 case CAMERA_STATE_CREATED:
1123 case CAMERA_STATE_CAPTURED:
1125 CAM_TA_ACUM_ITEM_BEGIN(" cam_mm_preview_start", 0);
1126 if (!cam_mm_preview_start(camapp->camera_mode)) {
1127 cam_critical(LOG_MM, "cam_mm_preview_start failed");
1130 CAM_TA_ACUM_ITEM_END(" cam_mm_preview_start", 0);
1133 case CAMERA_STATE_CAPTURING:
1135 if (cam_mm_capture_stop(FALSE, camapp->camera_mode) == FALSE) {
1136 cam_critical(LOG_MM, "cam_mm_capture_stop failed");
1144 }else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
1146 case RECORDER_STATE_CREATED:
1147 case RECORDER_STATE_PAUSED:
1149 if (!cam_mm_preview_start(camapp->camera_mode)) {
1150 cam_critical(LOG_MM, "cam_mm_preview_start failed");
1161 CAM_TA_ACUM_ITEM_END("----cam_app_preview_start", 0);
1165 gboolean cam_app_preview_stop(void)
1167 struct appdata *ad = (struct appdata *)cam_appdata_get();
1170 CamAppData *camapp = ad->camapp_handle;
1173 if (!cam_mm_preview_stop(camapp->camera_mode)) {
1174 cam_critical(LOG_MM, "cam_mm_preview_stop failed");
1181 _main_layout_click_cb(void *data, Evas_Object *obj, void *event_info)
1183 struct appdata *ad = (struct appdata *)data;
1188 unload_zoom_edje(ad);
1190 if (ad->setting_ctxpopup || ad->toolbar_popup) {
1191 /* destroy toolbar popup and setting popup */
1192 ad->show_menu = FALSE;
1193 ad->displayed_setting_popup = DISPLAY_NONE_POPUP;
1194 cam_toolbar_and_setting_popup_del(ad);
1195 if (ad->shot_mode_guide_popup)
1196 toolbar_shot_guide_popup_create(ad, ad->camapp_handle->shooting_mode);
1197 } else if (ad->toolbar_show_setting_popup == TRUE) {
1198 ad->displayed_setting_popup = DISPLAY_NONE_POPUP;
1199 ad->show_menu = FALSE;
1200 toolbar_hide_setting_popup(ad);
1201 if (ad->toolbar_show_edit_shortcuts_popup == TRUE) {
1202 toolbar_destroy_shortcuts_popup(ad);
1203 ad->toolbar_show_edit_shortcuts_popup = FALSE;
1205 } else if (ad->toolbar_show_edit_shortcuts_popup == TRUE) {
1206 toolbar_destroy_shortcuts_popup(ad);
1207 ad->toolbar_show_edit_shortcuts_popup = FALSE;
1209 if (ad->camapp_handle->enable_touch_af == TRUE) {
1210 REMOVE_TIMER(ad->continuous_af_timer);
1211 cam_camera_touch_af_press(ad);
1218 static void cam_app_timer_icon_rotate(void *data)
1220 struct appdata *ad = (struct appdata *)data;
1221 cam_retm_if(ad == NULL, "appdata is NULL");
1223 DEL_EVAS_OBJECT(ad->timer_icon_edje);
1224 cam_app_timer_update_count(ad);
1227 static int cam_app_start_rotate(struct appdata *ad, bool bInitial)
1229 cam_retvm_if(ad == NULL, -1, "appdata is NULL");
1231 cam_debug(LOG_UI, "rotated : %d, window rotation angle=%d", ad->rot_current); /*, elm_win_rotation_get(ad->win_main)); */
1236 switch (ad->rot_current) {
1237 case APP_DEVICE_ORIENTATION_0:
1238 ad->camcorder_rotate = CAMERA_ROTATION_90;
1239 ad->target_direction = CAM_TARGET_DIRECTION_PORTRAIT;
1243 case APP_DEVICE_ORIENTATION_180:
1244 ad->camcorder_rotate = CAMERA_ROTATION_270;
1245 ad->target_direction = CAM_TARGET_DIRECTION_PORTRAIT_INVERSE;
1249 case APP_DEVICE_ORIENTATION_270:
1250 ad->camcorder_rotate = CAMERA_ROTATION_NONE;
1251 ad->target_direction = CAM_TARGET_DIRECTION_LANDSCAPE;
1255 case APP_DEVICE_ORIENTATION_90:
1256 ad->camcorder_rotate = CAMERA_ROTATION_180;
1257 ad->target_direction = CAM_TARGET_DIRECTION_LANDSCAPE_INVERSE;
1265 ad->angle_pre = ad->angle;
1268 ////////////////////////////////////////////////////////////////////////////
1269 if (ad->toolbar_edj_file) {
1270 free(ad->toolbar_edj_file);
1271 ad->toolbar_edj_file = NULL;
1273 /*ad->angle = 270;*/
1274 switch (ad->angle) {
1276 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_EDJ_NAME);
1279 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_VERTICAL_EDJ_NAME);
1282 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_INVERSE_EDJ_NAME);
1285 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_VERTICAL_INVERSE_EDJ_NAME);
1288 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_EDJ_NAME);
1293 elm_win_rotation_with_resize_set(ad->win_main, ad->angle);
1295 /* cam_app_get_win_size(ad); */
1296 cam_app_get_preview_offset_coordinate(ad);
1299 if (ad->toolbar_edje)
1300 cam_toolbar_rotate(ad);
1302 if (ad->indicator_edje)
1303 cam_indicator_rotate(ad);
1305 if (ad->recording_edje)
1306 cam_recording_rotate(ad);
1308 if (ad->timer_icon_edje)
1309 cam_app_timer_icon_rotate(ad);
1311 if (ad->zoom_edje) {
1312 unload_zoom_edje(ad);
1316 #ifdef GUIDE_LINE_ENALBE
1317 if (ad->guideline_edje)
1318 settings_guideline_refresh(ad);
1325 gboolean cam_layout_init(void *data)
1327 DEBUG_TRACE("START");
1329 struct appdata *ad = (struct appdata *)data;
1330 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1332 if (ad->win_main == NULL) {
1333 cam_critical(LOG_UI, "win_main is NULL");
1337 elm_win_indicator_mode_set(ad->win_main, ELM_WIN_INDICATOR_HIDE);
1339 cam_app_start_rotate(ad, TRUE);
1340 DEBUG_TRACE("ad->angle = %d", ad->angle);
1341 /*elm_win_rotation_with_resize_set(ad->win_main, 270);*/
1342 cam_app_get_preview_offset_coordinate(ad);
1343 elm_theme_extension_add(NULL, CAM_SETTING_POPUP_STYLE_EDJ_NAME);
1344 elm_theme_extension_add(NULL, CAM_SETTING_POPUP_STYLE_WITH_RADIO_EDJ_NAME);
1345 elm_theme_extension_add(NULL, CAM_SLIDER_STYLE_EDJ_NAME);
1347 CAM_TA_ACUM_ITEM_BEGIN(" layout_main load", 0);
1348 if (ad->layout_main == NULL) {
1350 cam_app_load_edj(ad->win_main, CAM_MAIN_LAYOUT_EDJ_NAME,
1352 if (ad->layout_main == NULL) {
1353 CAM_TA_ACUM_ITEM_END(" layout_main load", 0);
1354 cam_critical(LOG_UI, "layout_main load failed ");
1358 #ifndef CAMERA_MACHINE_I686
1359 evas_object_smart_callback_del(_EDJ(ad->layout_main),
1361 _main_layout_click_cb);
1363 evas_object_smart_callback_add(_EDJ(ad->layout_main),
1365 _main_layout_click_cb, ad);
1367 define_mouse_callback(_EDJ(ad->layout_main),
1368 _EDJ(ad->layout_main));
1371 CAM_TA_ACUM_ITEM_END(" layout_main load", 0);
1373 cam_app_focus_guide_create(ad);
1375 CAM_TA_ACUM_ITEM_BEGIN(" load_toolbar_edje", 0);
1376 if (cam_toolbar_create(ad)) {
1377 CAM_TA_ACUM_ITEM_END(" load_toolbar_edje", 0);
1378 cam_critical(LOG_UI, " load_toolbar_edje failed ");
1381 CAM_TA_ACUM_ITEM_END(" load_toolbar_edje", 0);
1383 #ifndef DISABLE_INDICATOR
1384 CAM_TA_ACUM_ITEM_BEGIN(" cam_indicator_create", 0);
1385 if (ad->indicator_edje) {
1386 evas_object_hide(ad->indicator_edje);
1387 cam_indicator_destory(ad);
1389 if (cam_indicator_create(ad)) {
1390 CAM_TA_ACUM_ITEM_END(" cam_indicator_create", 0);
1391 cam_critical(LOG_UI, "cam_indicator_create failed ");
1394 CAM_TA_ACUM_ITEM_END(" cam_indicator_create", 0);
1397 cam_app_update_quickview_icon(ad);
1404 gboolean cam_handle_create(void *data)
1406 CAM_TA_ACUM_ITEM_BEGIN("------cam_handle_create", 0);
1407 struct appdata *ad = (struct appdata *)data;
1408 CamAppData *camapp = NULL;
1410 debug_fenter(LOG_CAM);
1411 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1413 if (ad->camapp_handle && cam_handle) {
1414 cam_handle_free(ad);
1417 camapp = (CamAppData *)malloc(sizeof(CamAppData));
1418 cam_retv_if(camapp == NULL, FALSE);
1419 memset(camapp, 0x00, sizeof(CamAppData));
1421 cam_handle = camapp;
1422 ad->camapp_handle = camapp;
1423 CAM_TA_ACUM_ITEM_END("------cam_handle_create", 0);
1428 gboolean cam_handle_free(void *data)
1430 struct appdata *ad = (struct appdata *)data;
1431 CamAppData *camapp = NULL;
1433 debug_fenter(LOG_CAM);
1434 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1435 camapp = ad->camapp_handle;
1436 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
1440 if (camapp && cam_handle) {
1441 if (camapp->battery_ani_timer) {
1442 ecore_timer_del(camapp->battery_ani_timer);
1443 camapp->battery_ani_timer = NULL;
1446 if (camapp->filename) {
1447 free(camapp->filename);
1448 camapp->filename = NULL;
1451 if (camapp->thumbnail_name) {
1452 free(camapp->thumbnail_name);
1453 camapp->thumbnail_name = NULL;
1461 ad->camapp_handle = NULL;
1468 gboolean cam_toolbar_menu_config_init(void *data, int mode) {
1469 struct appdata *ad = (struct appdata *)data;
1470 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1471 ad->toolbar_1_type = cam_config_get_int( PROP_TOOLBAR_1_TYPE_NAME, CAM_MENU_EMPTY);
1472 ad->toolbar_2_type = cam_config_get_int( PROP_TOOLBAR_2_TYPE_NAME, CAM_MENU_EMPTY);
1473 ad->toolbar_3_type = cam_config_get_int( PROP_TOOLBAR_3_TYPE_NAME, CAM_MENU_EMPTY);
1474 ad->toolbar_4_type = cam_config_get_int( PROP_TOOLBAR_4_TYPE_NAME, CAM_MENU_EMPTY);
1475 DEBUG_TRACE("ad->toolbar_1_type= %d", ad->toolbar_1_type);
1476 DEBUG_TRACE("ad->toolbar_2_type= %d", ad->toolbar_2_type);
1477 DEBUG_TRACE("ad->toolbar_3_type= %d", ad->toolbar_3_type);
1478 DEBUG_TRACE("ad->toolbar_4_type= %d", ad->toolbar_4_type);
1483 gboolean cam_toolbar_menu_config_update(void *data)
1485 struct appdata *ad = (struct appdata *)data;
1486 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1493 toolbar_1_type = cam_config_get_int( PROP_TOOLBAR_1_TYPE_NAME, CAM_MENU_EMPTY);
1494 toolbar_2_type = cam_config_get_int( PROP_TOOLBAR_2_TYPE_NAME, CAM_MENU_EMPTY);
1495 toolbar_3_type = cam_config_get_int( PROP_TOOLBAR_3_TYPE_NAME, CAM_MENU_EMPTY);
1496 toolbar_4_type = cam_config_get_int( PROP_TOOLBAR_4_TYPE_NAME, CAM_MENU_EMPTY);
1498 if (toolbar_1_type != ad->toolbar_1_type)
1499 cam_config_set_int(PROP_TOOLBAR_1_TYPE_NAME, ad->toolbar_1_type);
1500 if (toolbar_2_type != ad->toolbar_2_type)
1501 cam_config_set_int(PROP_TOOLBAR_2_TYPE_NAME, ad->toolbar_2_type);
1502 if (toolbar_3_type != ad->toolbar_3_type)
1503 cam_config_set_int(PROP_TOOLBAR_3_TYPE_NAME, ad->toolbar_3_type);
1504 if (toolbar_4_type != ad->toolbar_4_type)
1505 cam_config_set_int(PROP_TOOLBAR_4_TYPE_NAME, ad->toolbar_4_type);
1511 gboolean cam_handle_init(void *data, int mode)
1513 struct appdata *ad = data;
1514 CamAppData *camapp = NULL;
1517 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1519 camapp = ad->camapp_handle;
1520 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
1522 cam_info(LOG_UI, "mode : %d ", mode);
1523 camapp->camera_mode = mode;
1525 cam_info(LOG_UI, "camera_mode = %d ", camapp->camera_mode);
1527 cam_config_set_int_by_type(CAM_CONFIG_TYPE_COMMON, PROP_MODE_NAME, mode);
1529 cam_app_set_config_group(camapp->camera_mode);
1531 #ifdef USE_CAM_STORAGE_SETTING
1532 camapp->storage = cam_config_get_int( PROP_STORAGE_NAME, CAM_STORAGE_INTERNAL);
1534 vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT, &(camapp->storage));
1537 /* use shot mode as default value */
1538 camapp->recording_mode = RECMODE_DEFAULT;
1539 camapp->shooting_mode = SHOTMODE_DEFAULT;
1541 camapp->af_mode = AF_DEFAULT;
1543 if (camapp->camera_mode == CAM_CAMERA_MODE) {
1544 camapp->flash = cam_config_get_int(PROP_FLASH_NAME, FLASH_DEFAULT);
1546 camapp->flash = cam_config_get_int(PROP_FLASH_NAME, REC_FLASH_DEFAULT);
1549 #ifdef GUIDE_LINE_ENALBE
1550 camapp->guideline = cam_config_get_boolean(PROP_GUIDELINE_NAME, GUIDE_LINE_DEFAULT);
1551 DEBUG_TRACE("camapp->guideline = %d" ,camapp->guideline);
1554 camapp->effect = EFFECT_DEFAULT;
1556 if (camapp->camera_mode == CAM_CAMERA_MODE)
1557 DEBUG_TRACE("default resolution will be got from FW API");
1559 camapp->resolution = cam_config_get_int(PROP_RESOLUTION_NAME, REC_RESOLUTION_DEFAULT);
1561 camapp->image_quality = cam_config_get_int(PROP_IMAGE_QUALITY_NAME, QUALITY_DEFAULT);
1562 camapp->video_quality = cam_config_get_int(PROP_VIDEO_QUALITY_NAME, QUALITY_DEFAULT);
1563 camapp->audio_recording = AUDIOREC_DEFAULT;
1564 camapp->review = cam_config_get_boolean(PROP_REVIEW_NAME, FALSE);
1566 camapp->battery_level = cam_utils_get_battery_level();
1567 charging = cam_utils_get_charging_status();
1569 camapp->battery_charging = charging;
1571 camapp->battery_charging = 0;
1573 #ifdef USE_CAMERA_APP_SHUTTER_SOUND
1574 camapp->shutter_sound =
1575 cam_config_get_int(PROP_SHUTTER_SOUND_NAME, SHUTTER_SOUND_DEFAULT);
1578 cam_mm_set_shutter_sound(SOUND_DEFAULT);
1579 camapp->shutter_sound = SHUTTER_SOUND_DEFAULT; /* on */
1581 /* below item had been saved in ini file */
1582 camapp->zoom_mode = 1;
1583 camapp->image_count = IMAGE_COUNT_DEFAULT;
1584 camapp->size_limit_type = CAM_MM_SIZE_LIMIT_TYPE_BYTE;
1585 camapp->size_limit = REC_SIZE_LIMIT_DEFAULT;
1586 camapp->timer = TIMER_DEFAULT;
1587 camapp->fps = FPS_DEFAULT;
1589 camapp->enable_touch_af = TRUE;
1590 camapp->key_lock = FALSE;
1592 /*init toolbar menu config */
1593 cam_toolbar_menu_config_init((void*)ad, mode);
1598 gboolean cam_handle_value_set(void *data, int type, const GValue *value)
1600 struct appdata *ad = (struct appdata *)data;
1601 CamAppData *camapp = NULL;
1603 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1604 camapp = ad->camapp_handle;
1605 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
1607 cam_debug(LOG_CAM, "type : %d", type);
1613 gint tempval = g_value_get_int(value);
1615 current = camapp->camera_mode;
1616 if (!cam_mode_change(ad, tempval)) {
1617 cam_critical(LOG_CAM,
1618 "MODE CHANGE IS FAILED by MIDDLE WARE");
1619 cam_app_notice_popup(data,
1620 "MODE CHANGE FAILED !!",
1621 cam_app_timeout_notice_response_cb);
1626 case PROP_SHOT_MODE:
1628 gint tempval = g_value_get_int(value);
1629 gint cur_mode = camapp->shooting_mode;
1631 camapp->shooting_mode = tempval;
1633 if (!cam_shooting_mode_change(ad)) {
1634 cam_critical(LOG_UI, "shot mode set fail");
1635 camapp->shooting_mode = cur_mode;
1638 printf(" ##### %s %d tempval = %d\n", __FUNCTION__,
1640 cam_config_set_int(PROP_SHOT_MODE_NAME, tempval);
1641 cam_app_focus_guide_update(ad);
1646 gint tempval = g_value_get_int(value);
1647 /* set recording mode */
1648 camapp->recording_mode = tempval;
1649 cam_config_set_int(PROP_REC_MODE_NAME, tempval);
1651 if (!cam_recording_mode_change(ad, tempval)) {
1652 cam_critical(LOG_UI, "rec mode change fail - mode[%d]", tempval);
1658 case PROP_RESOLUTION:
1660 gint tempval = g_value_get_int(value);
1661 /* int af_x,af_y; */
1664 ("*******************************************************");
1665 DEBUG_TRACE("value set : PROP_RESOLUTION setting");
1666 DEBUG_TRACE(" tempval = %d ", tempval);
1668 ("CAM_RESOLUTION_W = %d ,CAM_RESOLUTION_H=%d ",
1669 CAM_RESOLUTION_W(tempval),
1670 CAM_RESOLUTION_H(tempval));
1672 ("*******************************************************");
1675 cam_critical(LOG_FILE, "1111111111");
1677 if (!cam_app_reset_resolution(ad, CAM_RESOLUTION_W(tempval), CAM_RESOLUTION_H(tempval))) {
1678 cam_warning(LOG_UI, "resolution set fail");
1681 #ifdef GUIDE_LINE_ENALBE
1682 settings_guideline_refresh(ad);
1684 camapp->resolution = tempval;
1685 cam_critical(LOG_FILE, " camapp->resolution %d", camapp->resolution);
1687 if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
1688 cam_app_set_video_quality(ad, camapp->video_quality);
1689 /* cam_mm_set_video_quality(camapp->recording_mode, camapp->video_quality); */
1692 if ((camapp->camera_mode == CAM_CAMERA_MODE
1693 && camapp->shooting_mode == CAM_SINGLE_MODE)
1694 || (camapp->camera_mode == CAM_CAMCORDER_MODE
1695 && camapp->recording_mode == CAM_RECORD_NORMAL)) {
1697 "resolution saved : [%d]x[%d]",
1698 CAM_RESOLUTION_W(tempval),
1699 CAM_RESOLUTION_H(tempval));
1700 cam_config_set_int(PROP_RESOLUTION_NAME,
1703 cam_app_get_preview_offset_coordinate(ad);
1704 ad->remained_count = cam_system_get_still_count_by_resolution(ad);
1708 { /* fps may not set it alone */
1709 gint tempval = g_value_get_int(value);
1711 if (!cam_mm_set_fps(tempval)) {
1712 cam_warning(LOG_UI, "fps set fail");
1715 camapp->fps = tempval;
1720 gint tempval = g_value_get_int(value);
1721 if (!cam_mm_set_effect(tempval)) {
1722 cam_warning(LOG_UI, "effect set fail : %d",
1726 camapp->effect = tempval;
1727 cam_config_set_int(PROP_EFFECT_NAME, tempval);
1732 gint tempval = g_value_get_int(value);
1733 gint oldval = cam_config_get_int(PROP_AF_NAME, CAM_FOCUS_AUTO);
1735 if ((tempval == CAM_FOCUS_AUTO)
1736 || (tempval == CAM_FOCUS_MACRO)) {
1737 if (!cam_mm_set_focus_mode(tempval)) {
1738 cam_warning(LOG_UI, "af mode set fail");
1743 cam_warning(LOG_UI, "unknow af mode : %d",
1747 camapp->af_mode = tempval;
1748 cam_app_focus_guide_update(ad);
1749 if (camapp->camera_mode == CAM_CAMERA_MODE
1750 && camapp->shooting_mode == CAM_SINGLE_MODE) {
1751 cam_config_set_int(PROP_AF_NAME, tempval);
1757 gint tempval = g_value_get_int(value);
1758 if (!cam_mm_set_flash(tempval)) {
1759 cam_warning(LOG_UI, "flash set fail");
1762 camapp->flash = tempval;
1763 /*fix me ,why only when in camera single mode ,
1764 save the FLASH setting value to config file*/
1765 if ((camapp->camera_mode == CAM_CAMERA_MODE
1766 && camapp->shooting_mode == CAM_SINGLE_MODE)
1767 || camapp->camera_mode == CAM_CAMCORDER_MODE) {
1768 cam_config_set_int(PROP_FLASH_NAME, tempval);
1774 gint tempval = g_value_get_int(value);
1776 camapp->timer = tempval;
1779 case PROP_IMAGE_QUALITY:
1781 gint tempval = g_value_get_int(value);
1782 if (!cam_mm_set_image_enc_quality(tempval)) {
1784 "image quality[%d] set fail",
1789 camapp->image_quality = tempval;
1790 cam_config_set_int(PROP_IMAGE_QUALITY_NAME, tempval);
1793 case PROP_VIDEO_QUALITY:
1795 gint tempval = g_value_get_int(value);
1796 if (!cam_app_set_video_quality(ad, tempval)) {
1798 "video quality[%d] set fail",
1803 camapp->video_quality = tempval;
1804 cam_config_set_int(PROP_VIDEO_QUALITY_NAME, tempval);
1807 case PROP_AUDIO_REC:
1809 gboolean tempval = g_value_get_boolean(value);
1810 if (!cam_mm_set_audio_recording(tempval)) {
1811 cam_warning(LOG_UI, "audio_recording set fail");
1814 camapp->audio_recording = tempval;
1815 cam_config_set_boolean(PROP_AUDIO_REC_NAME, tempval);
1819 case PROP_AUDIO_QUALITY:
1821 gint tempval = g_value_get_int(value);
1822 /* set audio quality */
1823 camapp->audio_quality = tempval;
1824 cam_config_set_int(PROP_AUDIO_QUALITY_NAME, tempval);
1827 case PROP_BATTERY_CHARG:
1829 gint tempval_charging = g_value_get_int(value);
1831 DEBUG_TRACE("charging = %d", tempval_charging);
1832 camapp->battery_charging = tempval_charging;
1833 camapp->battery_level = cam_utils_get_battery_level();
1834 indicator_update_battery(ad, camapp->battery_level);
1837 case PROP_BATTERY_LEVEL:
1839 gint tempval = g_value_get_int(value);
1840 camapp->battery_charging = cam_utils_get_charging_status();
1841 camapp->battery_level = tempval;
1842 indicator_update_battery(ad, camapp->battery_level);
1848 gint tempval = g_value_get_int(value);
1849 if (!cam_mm_set_zoom(tempval)) {
1850 cam_warning(LOG_UI, "zoom set fail");
1853 camapp->zoom = tempval;
1858 gint tempval = g_value_get_int(value);
1860 camapp->storage = tempval;
1861 cam_config_set_int(PROP_STORAGE_NAME, tempval);
1864 case PROP_GUIDELINE:
1866 gboolean tempval = g_value_get_boolean(value);
1868 camapp->guideline = tempval;
1869 cam_config_set_boolean(PROP_GUIDELINE_NAME, tempval);
1874 gboolean tempval = g_value_get_boolean(value);
1875 camapp->review = tempval;
1876 cam_config_set_boolean(PROP_REVIEW_NAME, tempval);
1879 case PROP_IMAGE_COUNT:
1881 gint tempval = g_value_get_int(value);
1882 if (!cam_mm_set_image_count(tempval)) {
1883 cam_warning(LOG_UI, "image_count set fail");
1886 camapp->image_count = tempval;
1889 case PROP_SHUTTER_SOUND:
1891 gint tempval = g_value_get_int(value);
1892 camapp->shutter_sound = tempval;
1893 cam_config_set_int(PROP_SHUTTER_SOUND_NAME, tempval);
1896 case PROP_SIZE_LIMIT:
1898 gint tempval = g_value_get_int(value);
1899 if (!cam_app_set_size_limit
1900 (tempval, camapp->size_limit_type)) {
1901 cam_warning(LOG_UI, "size_limit set fail");
1904 camapp->size_limit = tempval;
1907 case PROP_SIZE_LIMIT_TYPE:
1909 gint tempval = g_value_get_int(value);
1910 camapp->size_limit_type = tempval;
1915 guint tempval = g_value_get_uint(value);
1916 camapp->rec_elapsed = tempval;
1919 case PROP_REC_FILE_SIZE:
1921 guint tempval = g_value_get_uint(value);
1922 camapp->rec_filesize = tempval;
1926 cam_warning(LOG_UI, "unknow type :%d ", type);
1930 /* indicator should be updated here!!! */
1931 /* change_indicator_mode_icons(ad); */
1935 gboolean cam_mode_change(void *data, int to_mode)
1937 struct appdata *ad = (struct appdata *)data;
1938 cam_retv_if(ad == NULL, FALSE);
1939 CamAppData *camapp = ad->camapp_handle;
1940 cam_retv_if(camapp == NULL, FALSE);
1943 debug_fenter(LOG_UI);
1945 cam_elm_cache_flush();
1947 evas_object_hide(ad->timer_icon_edje);
1948 REMOVE_TIMER(ad->timer_timer);
1949 ad->timer_activated = false;
1950 DEL_EVAS_OBJECT(ad->timer_icon_edje);
1951 #ifdef GUIDE_LINE_ENALBE
1952 DEL_EVAS_OBJECT(ad->guideline_edje);
1953 camapp->guideline = FALSE;
1955 cam_app_timeout_checker_remove();
1956 /* draw to_mode icon in preview area */
1957 #ifdef USE_CAMERA_APP_SHUTTER_SOUND
1958 if (ad->play_rec_sound != 0)
1961 /*cam_app_black_screen_show(ad, to_mode);*/
1963 if (cam_mm_get_state() == CAMERA_STATE_CAPTURING
1964 && (camapp->camera_mode == CAM_CAMERA_MODE)) {
1965 cam_mm_capture_stop(true, CAM_CAMERA_MODE);
1968 /* stop preview and destory mmfw handle */
1969 if (!cam_app_preview_stop()) {
1970 cam_critical(LOG_MM, "cam_app_preview_stop faild");
1971 goto MODE_CHANGE_FAILED;
1975 if (!cam_mm_destory()) {
1976 cam_critical(LOG_MM, "cam_mm_destory faild");
1977 cam_app_notice_popup(data,
1978 "cam_mm_destory faild BY MIDDLE WARE",
1979 cam_app_timeout_notice_response_cb);
1983 if (to_mode == CAM_CAMERA_MODE) {
1984 DEBUG_TRACE("session_type :SOUND_SESSION_TYPE_SHARE");
1985 session_type = SOUND_SESSION_TYPE_SHARE;
1987 DEBUG_TRACE("session_type :SOUND_SESSION_TYPE_EXCLUSIVE");
1988 session_type = SOUND_SESSION_TYPE_EXCLUSIVE;
1990 if (!cam_mm_session_init(session_type)) {
1991 cam_critical(LOG_MM, "cam_mm_session_init faild");
1992 goto MODE_CHANGE_FAILED;
1995 if (!cam_mm_create(CAM_DEVICE_MEGA, to_mode)) {
1996 cam_critical(LOG_MM, "cam_mm_create failed");
1997 goto MODE_CHANGE_FAILED;
2000 /* Idler of capture callback management. wh01.cho@samsung.com. 2010-12-15. */
2001 cam_utils_remove_idler_all(ad);
2003 if (to_mode == CAM_CAMCORDER_MODE) {
2004 ad->last_camera_zoom_mode = camapp->zoom_mode;
2007 if (!cam_handle_create(ad)) {
2008 cam_critical(LOG_CAM, "cam_handle_create faild");
2009 goto MODE_CHANGE_FAILED;
2013 if (!cam_handle_init(ad, to_mode)) {
2014 cam_critical(LOG_CAM, "cam_handle_init faild");
2015 goto MODE_CHANGE_FAILED;
2019 else if (to_mode == CAM_CAMERA_MODE) {
2020 camapp->zoom_mode = ad->last_camera_zoom_mode;
2022 if (!cam_callback_init(ad)) {
2023 cam_critical(LOG_MM, "cam_init_mm_callback failed");
2024 goto MODE_CHANGE_FAILED;
2027 DEBUG_TRACE("camera mode = %d", to_mode);
2028 if (!cam_app_init_attribute(ad, to_mode)) {
2029 cam_critical(LOG_MM, "cam_app_init_attribute failed");
2030 // goto MODE_CHANGE_FAILED;
2033 cam_app_get_preview_offset_coordinate(ad);
2035 cam_continuous_af_start(ad);
2036 if (!cam_app_preview_start(ad)) {
2037 cam_critical(LOG_MM, "cam_app_preview_start failed");
2038 goto MODE_CHANGE_FAILED;
2041 cam_app_timeout_checker_init(ad);
2044 /*update toolbar shortcuts*/
2045 cam_toolbar_destroy(ad);
2046 cam_toolbar_create(ad);
2047 cam_app_update_quickview_icon((void *)ad);
2052 cam_app_notice_popup(ad, "PREVIEW START FAILED !!", cam_app_timeout_notice_response_cb);
2056 gboolean cam_recording_mode_change(void *data, int rec_mode)
2058 struct appdata *ad = (struct appdata *)data;
2059 CamAppData *camapp = NULL;
2060 CamDeviceType device_type = CAM_DEVICE_MEGA;
2061 GValue value = { 0 };
2063 gboolean cam_reset = FALSE;
2065 debug_fenter(LOG_CAM);
2067 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
2068 camapp = ad->camapp_handle;
2069 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
2071 cam_app_timeout_checker_remove();
2073 g_value_init(&value, G_TYPE_INT);
2075 cam_mm_get_video_device(&video_dev);
2076 if (((camapp->recording_mode == CAM_RECORD_SELF || camapp->recording_mode == CAM_RECORD_SELF_MMS )&& video_dev == CAM_DEVICE_MEGA)
2077 || ((camapp->recording_mode != CAM_RECORD_SELF || camapp->recording_mode == CAM_RECORD_SELF_MMS) && video_dev == CAM_DEVICE_VGA)) {
2079 /* stop preview and destory mmfw handle */
2081 if (!cam_app_preview_stop()) {
2082 cam_critical(LOG_MM, "cam_app_preview_stop faild");
2085 if (!cam_mm_destory()) {
2086 cam_critical(LOG_MM, "cam_mm_destory faild");
2089 if (camapp->recording_mode == CAM_RECORD_SELF ||camapp->recording_mode == CAM_RECORD_SELF_MMS ) {
2090 device_type = CAM_DEVICE_VGA;
2092 device_type = CAM_DEVICE_MEGA;
2095 if (!cam_mm_create(device_type, camapp->camera_mode)) {
2096 cam_critical(LOG_MM, "cam_mm_create failed");
2097 cam_app_notice_popup(ad, "cam_app_preview_start failed", cam_app_timeout_notice_response_cb);
2100 cam_mm_get_video_size( &camapp->default_preview_width, &camapp->default_preview_height);
2101 DEBUG_TRACE("default_width = %d,default_height = %d", camapp->default_preview_width, camapp->default_preview_height);
2104 if (!cam_app_preview_stop()) {
2105 cam_critical(LOG_MM, "cam_app_preview_stop faild");
2110 ad->camapp_handle->enable_touch_af = TRUE;
2112 if(rec_mode == CAM_RECORD_SELF) {
2114 ad->camapp_handle->enable_touch_af = FALSE;
2115 g_value_set_int(&value, FPS_SLOW);
2116 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2117 cam_critical(LOG_UI, "fps set fail");
2121 g_value_set_int(&value, CAM_RESOLUTION_VGA);
2122 if (!cam_handle_value_set(ad, PROP_RESOLUTION, &value)) {
2123 cam_critical(LOG_UI, "resolution set fail");
2127 g_value_set_int(&value, REC_SIZE_LIMIT_DEFAULT);
2128 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2129 cam_critical(LOG_UI, "size limit set fail");
2133 if (!cam_mm_reset_recording_motion_fps()) {
2134 cam_critical(LOG_UI,
2135 "slow motion fps set fail");
2138 camapp->recording_mode = CAM_RECORD_SELF;
2139 } else if (rec_mode == CAM_RECORD_MMS ||rec_mode == CAM_RECORD_SELF_MMS ) {
2140 g_value_set_int(&value, FPS_SLOW);
2141 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2142 cam_critical(LOG_UI, "fps set fail");
2146 g_value_set_int(&value, CAM_RESOLUTION_QCIF);
2147 if (!cam_handle_value_set(ad, PROP_RESOLUTION, &value)) {
2148 cam_critical(LOG_UI, "resolution set fail");
2152 g_value_set_int(&value, CAM_REC_MMS_MAX_SIZE);
2153 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2154 cam_critical(LOG_UI, "size limit set fail");
2158 if (!cam_mm_reset_recording_motion_fps()) {
2159 cam_critical(LOG_UI,
2160 "slow motion fps set fail");
2163 if (rec_mode == CAM_RECORD_MMS)
2164 camapp->recording_mode = CAM_RECORD_MMS;
2166 camapp->recording_mode = CAM_RECORD_SELF_MMS;
2170 cam_config_get_int(PROP_RESOLUTION_NAME, REC_RESOLUTION_DEFAULT);
2172 g_value_set_int(&value, FPS_DEFAULT);
2173 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2174 cam_critical(LOG_UI, "fps set fail");
2178 g_value_set_int(&value, resolution_n);
2179 if (!cam_handle_value_set(ad, PROP_RESOLUTION, &value)) {
2180 cam_critical(LOG_UI, "resolution set fail");
2184 g_value_set_int(&value, REC_SIZE_LIMIT_DEFAULT);
2185 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2186 cam_critical(LOG_UI, "size limit set fail");
2190 if (!cam_mm_reset_recording_motion_fps()) {
2191 cam_critical(LOG_UI,
2192 "slow motion fps set fail");
2195 camapp->recording_mode = CAM_RECORD_NORMAL;
2199 if (!cam_app_init_attribute(ad, camapp->camera_mode)) {
2200 cam_critical(LOG_MM, "cam_app_init_attribute failed");
2204 if (!cam_app_set_recording_mode(ad, rec_mode)) {
2205 DEBUG_TRACE("cam_app_set_recording_mode failed");
2210 cam_app_get_preview_offset_coordinate(ad);
2212 if (!cam_callback_init(ad)) {
2213 cam_critical(LOG_MM, "cam_init_mm_callback failed");
2214 cam_app_notice_popup(ad, "PREVIEW START FAILED !!", cam_app_timeout_notice_response_cb);
2218 cam_continuous_af_start(ad);
2219 if (!cam_app_preview_start(ad)) {
2220 cam_critical(LOG_MM, "cam_app_preview_start failed");
2221 cam_app_notice_popup(ad, "PREVIEW START FAILED !!", cam_app_timeout_notice_response_cb);
2225 cam_app_timeout_checker_init(ad);
2231 static gboolean cam_app_set_capture_format_shooting_mode(int mode)
2234 case CAM_SINGLE_MODE:
2236 if (!cam_mm_set_capture_format(CAMERA_PIXEL_FORMAT_JPEG))
2244 "\n################# shooting mode set return success : %d\n",
2250 static void cam_shooting_mode_reset(void *data)
2255 gboolean cam_shooting_mode_change(void *data)
2257 struct appdata *ad = (struct appdata *)data;
2258 CamAppData *camapp = NULL;
2259 CamDeviceType device_type = CAM_DEVICE_MEGA;
2260 GValue value = { 0 };
2262 gboolean cam_reset = FALSE;
2264 debug_fenter(LOG_CAM);
2266 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
2267 camapp = ad->camapp_handle;
2268 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
2270 cam_elm_cache_flush();
2272 cam_app_stop_video_stream();
2273 cam_app_timeout_checker_remove();
2274 cam_shooting_mode_reset(ad);
2275 cam_mm_get_video_device(&video_dev);
2277 if ((camapp->shooting_mode == CAM_SELF_MODE && video_dev == CAM_DEVICE_MEGA)
2278 || (camapp->shooting_mode != CAM_SELF_MODE && video_dev == CAM_DEVICE_VGA)) {
2279 /* stop preview and destory mmfw handle */
2281 if (!cam_app_preview_stop()) {
2282 cam_critical(LOG_MM, "cam_app_preview_stop faild");
2285 if (!cam_mm_destory()) {
2286 cam_critical(LOG_MM, "cam_mm_destory faild");
2289 if (camapp->shooting_mode == CAM_SELF_MODE) {
2290 device_type = CAM_DEVICE_VGA;
2292 device_type = CAM_DEVICE_MEGA;
2294 DEBUG_TRACE("device_type = %d" ,device_type);
2295 if (!cam_mm_create(device_type, camapp->camera_mode)) {
2296 cam_critical(LOG_MM, "cam_mm_create failed");
2297 cam_app_notice_popup(ad, "cam_app_preview_start faild ", cam_app_timeout_notice_response_cb);
2300 cam_mm_get_video_size( &camapp->default_preview_width, &camapp->default_preview_height);
2301 DEBUG_TRACE("default_width = %d,default_height = %d", camapp->default_preview_width, camapp->default_preview_height);
2303 cam_continuous_af_start(ad);
2306 g_value_init(&value, G_TYPE_INT);
2308 cam_debug(LOG_CAM, "Shooting mode = %d ", camapp->shooting_mode);
2310 if (ad->shot_mode_guide_popup)
2311 toolbar_shot_guide_popup_destory(ad);
2313 switch (camapp->shooting_mode) {
2314 case CAM_SINGLE_MODE:
2316 int resolution = 0, flash = 0, auto_focus = 0;
2317 resolution = cam_config_get_int(PROP_RESOLUTION_NAME, IMAGE_RESOLUTION_DEFAULT);
2319 cam_config_get_int(PROP_FLASH_NAME, FLASH_DEFAULT);
2321 cam_config_get_int(PROP_AF_NAME, AF_DEFAULT);
2322 /* set resolution */
2323 g_value_set_int(&value, resolution);
2324 cam_handle_value_set(ad, PROP_RESOLUTION, &value);
2327 g_value_set_int(&value, flash);
2328 cam_handle_value_set(ad, PROP_FLASH, &value);
2330 /* set auto focus */
2331 g_value_set_int(&value, auto_focus);
2332 cam_handle_value_set(ad, PROP_AF_MODE, &value);
2334 /* set capture count */
2335 g_value_set_int(&value, IMAGE_COUNT_DEFAULT);
2336 cam_handle_value_set(ad, PROP_IMAGE_COUNT, &value);
2341 /* set resolution */
2342 g_value_set_int(&value, CAM_RESOLUTION_VGA);
2343 cam_handle_value_set(ad, PROP_RESOLUTION, &value);
2346 g_value_set_int(&value, CAM_FLASH_OFF);
2347 cam_handle_value_set(ad, PROP_FLASH, &value);
2349 /* set auto focus */
2350 g_value_set_int(&value, CAM_FOCUS_AUTO);
2351 cam_handle_value_set(ad, PROP_AF_MODE, &value);
2353 /* set capture count */
2354 g_value_set_int(&value, IMAGE_COUNT_DEFAULT);
2355 cam_handle_value_set(ad, PROP_IMAGE_COUNT, &value);
2362 if (!cam_app_init_attribute(ad, camapp->camera_mode)) {
2363 cam_critical(LOG_MM, "cam_app_init_attribute failed");
2366 /* cam_app_set_source_format_shooting_mode(camapp->shooting_mode); */
2367 cam_app_set_capture_format_shooting_mode(camapp->shooting_mode);
2370 cam_app_get_preview_offset_coordinate(ad);
2372 if (!cam_callback_init(ad)) {
2373 cam_critical(LOG_MM, "cam_init_mm_callback failed");
2374 cam_app_notice_popup(ad, "PREVIEW START FAILED !!", cam_app_timeout_notice_response_cb);
2378 if (!cam_app_preview_start(ad)) {
2379 cam_critical(LOG_MM, "cam_app_preview_start failed");
2380 cam_app_notice_popup(ad, "PREVIEW START FAILED !!", cam_app_timeout_notice_response_cb);
2383 cam_app_timeout_checker_init(ad);
2387 gboolean __cam_single_shot_reg_file(char *file_path)
2389 GError *error = NULL;
2392 DEBUG_TRACE("register file : %s", file_path);
2394 if (!cam_file_register(file_path, &error)) {
2395 cam_critical(LOG_FILE, "cam_file_register fail");
2396 if (error != NULL) {
2397 if (error->message != NULL) {
2398 cam_critical(LOG_FILE,
2399 "cam_file_register error [%s]",
2402 cam_critical(LOG_FILE,
2403 "cam_file_register error but error message is NULL");
2405 g_error_free(error);
2410 cam_warning(LOG_FILE, " file path is NULL...");
2418 static void cam_app_timer_update_count(void *data)
2420 struct appdata *ad = (struct appdata *)data;
2421 char count_string[3] = "";
2423 cam_retm_if(ad == NULL, "appdata is NULL");
2425 cam_debug(LOG_UI, "timer count ... [ %d ]", ad->timer_count);
2427 if (ad->timer_icon_edje == NULL) {
2428 switch (ad->target_direction) {
2429 case CAM_TARGET_DIRECTION_LANDSCAPE:
2430 case CAM_TARGET_DIRECTION_LANDSCAPE_INVERSE:
2431 ad->timer_icon_edje = cam_app_load_edj(ad->win_main, CAM_UTILS_EDJ_NAME, "timer_icon_landscape");
2433 case CAM_TARGET_DIRECTION_PORTRAIT:
2434 case CAM_TARGET_DIRECTION_PORTRAIT_INVERSE:
2435 ad->timer_icon_edje = cam_app_load_edj(ad->win_main, CAM_UTILS_EDJ_NAME, "timer_icon_portrait");
2438 DEBUG_TRACE("Invalid direction type!!!");
2441 cam_ret_if(ad->timer_icon_edje == NULL);
2444 snprintf(count_string, sizeof(count_string), "%d", ad->timer_count);
2446 edje_object_part_text_set(_EDJ(ad->timer_icon_edje), "text", count_string);
2448 evas_object_show(ad->timer_icon_edje);
2453 static Eina_Bool cam_app_timer_cb(void *data)
2455 struct appdata *ad = (struct appdata *)data;
2456 cam_retv_if(ad == NULL, ECORE_CALLBACK_CANCEL);
2458 CamAppData *camapp = NULL;
2460 camapp = ad->camapp_handle;
2461 if (camapp == NULL) {
2462 cam_critical(LOG_UI, "camapp_handle is NULL");
2463 ad->timer_timer = NULL;
2464 return ECORE_CALLBACK_CANCEL;
2467 ad->timer_count = ad->timer_count - 1;
2469 if (ad->timer_count > 0) {
2470 cam_debug(LOG_UI, "timer continue ... ");
2471 cam_app_timer_update_count(ad);
2472 if (camapp->shutter_sound != CAM_SETTINGS_SOUND_OFF)
2473 cam_sound_play(CAM_SOUND_EFFECT_TICK, ad);
2474 return ECORE_CALLBACK_RENEW;
2476 cam_debug(LOG_UI, "timer terminated ...");
2478 ad->timer_activated = false;
2480 if (ad->timer_icon_edje != NULL) {
2481 evas_object_del(ad->timer_icon_edje);
2482 ad->timer_icon_edje = NULL;
2485 cam_toolbar_update(ad);
2487 if (camapp->camera_mode == CAM_CAMERA_MODE) {
2488 cam_set_orient_value(ad);
2489 cam_image_capture_start(ad);
2491 cam_video_record_start(ad);
2494 ad->timer_timer = NULL;
2495 return ECORE_CALLBACK_CANCEL;
2499 static void cam_app_start_timer(void *data)
2501 struct appdata *ad = (struct appdata *)data;
2503 cam_retm_if(ad == NULL, "appdata is NULL");
2505 ad->timer_activated = true;
2507 switch (ad->camapp_handle->timer) {
2508 case CAM_SETTINGS_TIMER_2SEC:
2509 ad->timer_count = 2;
2511 case CAM_SETTINGS_TIMER_5SEC:
2512 ad->timer_count = 5;
2514 case CAM_SETTINGS_TIMER_10SEC:
2515 ad->timer_count = 10;
2518 case CAM_SETTINGS_TIMER_OFF:
2520 CAM_UI_LOG("can not reach here");
2524 cam_toolbar_update(ad);
2526 cam_app_timer_update_count(ad);
2528 if (ad->timer_timer != NULL) {
2529 ecore_timer_del(ad->timer_timer);
2530 ad->timer_timer = NULL;
2533 ad->timer_timer = ecore_timer_add(1.0, cam_app_timer_cb, ad);
2536 void cam_app_cancel_timer(void *data)
2538 struct appdata *ad = (struct appdata *)data;
2540 ad->timer_activated = FALSE;
2542 REMOVE_TIMER(ad->timer_timer);
2543 DEL_EVAS_OBJECT(ad->timer_icon_edje);
2545 cam_toolbar_update(ad);
2548 static void _popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
2550 /* cam_app_free_blocking_popup(); */
2551 Evas_Object *notify = (Evas_Object *)data;
2552 cam_popup_remove(notify);
2553 /* evas_object_del(notify); */
2556 gboolean cam_image_capture_start(void *data)
2558 struct appdata *ad = (struct appdata *)data;
2559 CamAppData *camapp = NULL;
2561 gboolean ret = TRUE;
2563 debug_fenter(LOG_UI);
2565 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
2566 camapp = ad->camapp_handle;
2567 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
2568 CAM_TA_ACUM_ITEM_BEGIN(" cam_image_capture_start", 0);
2570 remain = cam_system_get_still_count_by_resolution(ad);
2572 cam_set_orient_value(ad);
2574 switch (camapp->shooting_mode) {
2576 case CAM_SINGLE_MODE:
2577 ret = cam_mm_capture_start(camapp->capture_cb, camapp->capture_completed_cb, (void*)ad);
2578 #ifdef USE_CAMERA_APP_SHUTTER_SOUND
2579 cam_sound_play(camapp->shutter_sound, ad);
2580 #ifdef ENABLE_CAPTURE_ANIMATION
2581 cam_app_shutter_screen_show(ad);
2587 ret = cam_mm_capture_start(camapp->capture_cb, camapp->capture_completed_cb, (void*)ad); /*capture on recoring */
2591 CAM_TA_ACUM_ITEM_END(" cam_image_capture_start", 0);
2592 CAM_TA_ACUM_ITEM_BEGIN(" capture_start to capturecallback", 0);
2596 static gboolean cam_image_capture_stop(void *data)
2598 struct appdata *ad = (struct appdata *)data;
2599 CamAppData *camapp = NULL;
2601 debug_fenter(LOG_UI);
2602 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
2603 camapp = ad->camapp_handle;
2604 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
2609 Eina_Bool cam_image_capture_handle_idler(void *itm)
2611 CamIdlerItem *item = (CamIdlerItem *) itm;
2612 struct appdata *ad = NULL;
2613 cam_retvm_if(!item, ECORE_CALLBACK_CANCEL, "CamIdlerItem is NULL");
2615 ad = (struct appdata *)item->data;
2616 cam_retvm_if(!ad, ECORE_CALLBACK_CANCEL, "appdata is NULL");
2618 cam_info(LOG_UI, "call idler[ %p] ", item->idler);
2619 ad->capture_cb_list = g_list_remove(ad->capture_cb_list, item->idler);
2621 ecore_idler_del(item->idler);
2627 #ifdef ENABLE_CAPTURE_ANIMATION
2628 __cam_save_captured_file(ad);
2631 return cam_image_capture_handle(ad);
2633 Eina_Bool cam_capture_on_recording_handle(void *data)
2635 struct appdata *ad = (struct appdata *)data;
2636 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
2637 CamAppData *camapp = NULL;
2638 camapp = ad->camapp_handle;
2639 cam_retvm_if(camapp == NULL, ECORE_CALLBACK_CANCEL,
2640 "camapp_handle is NULL");
2641 gboolean preview_skip = FALSE;
2643 char popup_str[256] = { 0 };
2646 if (camapp->filename) {
2647 #ifdef USE_FILE_REG_THREAD
2649 "#########camapp->filename=%s",
2651 CAM_TA_ACUM_ITEM_BEGIN
2652 (" send signal to register thread",
2654 g_queue_push_tail(ad->file_reg_queue,
2656 (camapp->filename));
2657 pthread_cond_signal(&ad->file_reg_cond);
2658 CAM_TA_ACUM_ITEM_END(" send signal to register thread", 0);
2660 __cam_single_shot_reg_file(camapp->filename);
2663 cam_app_notice_popup(ad,
2664 "Your storage have trouble ",
2665 cam_app_popup_response_cb);
2667 if (!cam_mm_capture_stop (preview_skip, CAM_CAMERA_MODE)) {
2668 cam_critical(LOG_MM, " cam_mm_capture_stop error ");
2670 str = strrchr(camapp->filename, '/');
2671 snprintf(popup_str, sizeof(popup_str), "%s %s", (str+1), _("IDS_CAM_POP_SAVED"));
2672 cam_app_snapshot_popup(ad, popup_str, cam_app_snapshot_popup_response_cb);
2674 return ECORE_CALLBACK_CANCEL;
2677 Eina_Bool cam_image_capture_handle(void *data)
2679 struct appdata *ad = (struct appdata *)data;
2680 CamAppData *camapp = NULL;
2681 /* gboolean last_capture = FALSE; */
2682 gboolean bClosedEyesFoundFlag = FALSE;
2683 gboolean preview_skip = FALSE;
2685 debug_fenter(LOG_UI);
2687 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
2688 camapp = ad->camapp_handle;
2689 cam_retvm_if(camapp == NULL, ECORE_CALLBACK_CANCEL,
2690 "camapp_handle is NULL");
2692 CAM_TA_ACUM_ITEM_END(" captured message to cam_image_capture_handle",
2694 CAM_TA_ACUM_ITEM_BEGIN(" cam_image_capture_handle", 0);
2696 switch (camapp->shooting_mode) {
2697 case CAM_SINGLE_MODE:
2700 cam_app_destroy_progressbar(ad);
2702 if (!bClosedEyesFoundFlag) {
2703 if (camapp->review) {
2704 if (camapp->filename) {
2705 __cam_single_shot_reg_file
2707 /* run media browser. */
2708 cam_app_black_screen_show(ad, -1); /* after capture , to hide preview screen , The hide is in preview_start */
2710 cam_app_notice_popup(ad,
2711 "Your storage have trouble ",
2712 cam_app_popup_response_cb);
2714 if (!cam_mm_capture_stop(TRUE, camapp->camera_mode)) {
2715 cam_critical(LOG_MM, "cam_mm_capture_stop error ");
2717 /* del mouse down event - image viewer bug */
2718 cam_app_mouse_event_deinit(ad);
2719 if (!cam_app_run_image_viewer_ug
2720 (ad, camapp->filename)) {
2721 cam_app_mouse_event_init(ad);
2722 return ECORE_CALLBACK_CANCEL;
2725 if (camapp->filename) {
2726 #ifdef USE_FILE_REG_THREAD
2728 "#########camapp->filename=%s",
2730 CAM_TA_ACUM_ITEM_BEGIN
2731 (" send signal to register thread",
2733 g_queue_push_tail(ad->file_reg_queue,
2735 (camapp->filename));
2736 pthread_cond_signal(&ad->file_reg_cond);
2737 CAM_TA_ACUM_ITEM_END(" send signal to register thread", 0);
2738 cam_app_update_thumbnail();
2741 __cam_single_shot_reg_file(camapp->filename);
2744 cam_app_notice_popup(ad,
2745 "Your storage have trouble ",
2746 cam_app_popup_response_cb);
2749 if (ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
2750 if(!((ad->exe_args->caller) && (strcmp(ad->exe_args->caller, "gallery") == 0))) {
2751 preview_skip = TRUE;
2755 if (!cam_mm_capture_stop (preview_skip, camapp->camera_mode)) {
2756 cam_critical(LOG_MM,"cam_mm_capture_stop error ");
2758 CAM_TA_ACUM_ITEM_BEGIN
2759 (" capture stop to preview", 0);
2761 if (ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
2762 if (ad->appcore_state == CAM_APPCORE_PAUSE_STATE) {
2764 return ECORE_CALLBACK_CANCEL;
2766 /* view image select page */
2767 if(!((ad->exe_args->caller) && (strcmp(ad->exe_args->caller, "gallery") == 0))) {
2768 cam_app_mouse_event_deinit(ad);
2769 if (!cam_app_run_image_viewer_ug(ad, camapp->filename)) {
2770 cam_app_mouse_event_init(ad);
2771 return ECORE_CALLBACK_CANCEL;
2778 cam_app_toggle_indicator(ad, ad->toolbar_hided);
2779 cam_app_toggle_toolbar(ad, ad->toolbar_hided);
2780 cam_app_get_preview_offset_coordinate(ad);
2785 cam_debug(LOG_UI, " Not matched shooting mode [%d]",
2786 camapp->shooting_mode);
2789 ad->remained_count--;
2790 CAM_TA_ACUM_ITEM_END(" cam_image_capture_handle", 0);
2792 return ECORE_CALLBACK_CANCEL;
2795 gboolean cam_camera_touch_af_press(void *data)
2797 struct appdata *ad = (struct appdata *)data;
2798 CamAppData *camapp = NULL;
2799 debug_fenter(LOG_UI);
2800 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
2801 camapp = ad->camapp_handle;
2802 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
2803 camapp->focus_mode = 0;
2804 if (ad->af_outside == TRUE) {
2805 DEBUG_TRACE("########## out if af area !!");
2808 if (CAM_CAMERA_MODE == camapp->camera_mode) {
2809 camapp->focus_mode = CAM_FOCUS_MODE_TOUCH_AUTO;
2812 camapp->focus_mode = CAM_FOCUS_MODE_CONTINUOUS;
2815 cam_app_draw_af_box(ad);
2816 evas_object_show(ad->focus_edje);
2817 cam_ui_effect_utils_set_zoom_effect(ad->focus_edje,
2818 CAM_FOCUS_EDJE_ZOOM_EFFECT_END_RATE,
2819 CAM_FOCUS_EDJE_ZOOM_EFFECT_START_RATE,
2820 CAM_FOCUS_EDJE_ZOOM_EFFECT_DURATION);
2822 if (!ad->camapp_handle->key_lock) {
2823 ad->camapp_handle->key_lock = TRUE;
2824 if (!cam_camera_key_half_press(ad)) {
2825 DEBUG_TRACE("cam_camera_key_half_press failed");
2828 ad->camapp_handle->key_lock = FALSE;
2834 gboolean cam_camera_key_half_press(void *data)
2836 struct appdata *ad = (struct appdata *)data;
2837 CamAppData *camapp = NULL;
2839 debug_fenter(LOG_UI);
2840 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
2841 camapp = ad->camapp_handle;
2842 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
2844 REMOVE_TIMER(ad->toolbar_toggle_timer);
2845 #ifndef CAMERA_MACHINE_I686
2846 if (camapp->camera_mode == CAM_CAMERA_MODE
2847 && camapp->shooting_mode != CAM_SELF_MODE)
2849 if (camapp->camera_mode == CAM_CAMERA_MODE
2850 && camapp->shooting_mode != CAM_SELF_MODE
2854 if (camapp->camera_mode == CAM_CAMERA_MODE) {
2855 camapp->focus_state = CAM_FOCUS_STATUS_RELEASED;
2856 cam_app_focus_guide_update(ad);
2858 if (!cam_mm_set_af_area(ad->af_x, ad->af_y, ad->camera_focus_w, ad->camera_focus_h)) {
2859 DEBUG_TRACE("cam_mm_set_af_area failed");
2862 DEBUG_TRACE("focus mode = %d", camapp->focus_mode);
2863 if (!cam_mm_start_focusing(camapp->focus_mode)) {
2864 cam_critical(LOG_MM, " cam_mm_start_focusing error " );
2872 gboolean cam_camera_key_half_release(void *data)
2874 struct appdata *ad = (struct appdata *)data;
2875 CamAppData *camapp = NULL;
2877 debug_fenter(LOG_UI);
2879 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
2880 camapp = ad->camapp_handle;
2881 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
2882 #ifndef CAMERA_MACHINE_I686
2883 if (camapp->camera_mode == CAM_CAMERA_MODE
2884 && camapp->shooting_mode != CAM_SELF_MODE)
2886 if (camapp->camera_mode == CAM_CAMERA_MODE
2887 && camapp->shooting_mode != CAM_SELF_MODE
2891 camapp->focus_state = CAM_FOCUS_STATUS_RELEASED;
2892 cam_app_focus_guide_update(ad);
2898 gboolean cam_camera_key_press(void *data)
2900 struct appdata *ad = (struct appdata *)data;
2901 CamAppData *camapp = NULL;
2904 debug_fenter(LOG_UI);
2906 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
2907 if (ad->is_rotating)
2908 return FALSE;/*note: now is rotating*/
2909 camapp = ad->camapp_handle;
2910 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
2911 CAM_TA_ACUM_ITEM_BEGIN(" cam_camera_key_press", 0);
2913 if (camapp->camera_mode == CAM_CAMERA_MODE) {
2914 state = cam_mm_get_state();
2915 cam_debug(LOG_UI, " state = %d", state);
2917 case CAMERA_STATE_PREVIEW:
2918 case CAMERA_STATE_CAPTURED:
2919 cam_app_toggle_indicator(ad, TRUE);
2920 cam_app_toggle_toolbar(ad, TRUE);
2921 if (ad->timer_activated) {
2922 CAM_UI_LOG("timer activated!");
2923 } else if (camapp->timer >
2924 CAM_SETTINGS_TIMER_OFF) {
2925 CAM_UI_LOG("timer start");
2926 cam_app_start_timer(ad);
2927 } else if (!cam_image_capture_start(ad)) {
2932 case CAMERA_STATE_CAPTURING:
2933 cam_debug(LOG_UI, "capturing state");
2936 case CAMERA_STATE_NONE:
2937 case CAMERA_STATE_CREATED:
2945 } else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
2946 state = cam_mm_get_state();
2947 cam_debug(LOG_UI, " state = %d", state);
2949 case RECORDER_STATE_READY:
2951 if (ad->timer_activated) {
2952 CAM_UI_LOG("timer activated!");
2953 } else if (camapp->timer >
2954 CAM_SETTINGS_TIMER_OFF) {
2955 CAM_UI_LOG("timer start");
2956 cam_app_start_timer(ad);
2957 } else if (!cam_video_record_start(ad)) {
2962 case RECORDER_STATE_RECORDING:
2964 camapp->rec_stop_type = CAM_REC_STOP_NORMAL;
2965 if (!cam_video_record_stop(ad)) {
2971 case RECORDER_STATE_NONE:
2972 case RECORDER_STATE_CREATED:
2973 case RECORDER_STATE_PAUSED:
2982 cam_critical(LOG_MM, "Unknow camera mode");
2985 CAM_TA_ACUM_ITEM_END(" cam_camera_key_press", 0);
2989 gboolean cam_camera_key_release(void *data)
2991 struct appdata *ad = (struct appdata *)data;
2992 CamAppData *camapp = NULL;
2995 debug_fenter(LOG_UI);
2997 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
2998 camapp = ad->camapp_handle;
2999 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
3001 if (camapp->camera_mode == CAM_CAMERA_MODE) {
3003 state = cam_mm_get_state();
3004 cam_debug(LOG_UI, " state = %d", state);
3006 case CAMERA_STATE_CAPTURING:
3007 if (!cam_image_capture_stop(ad)) {
3012 case CAMERA_STATE_PREVIEW:
3013 case CAMERA_STATE_CREATED:
3014 case CAMERA_STATE_NONE:
3015 case CAMERA_STATE_CAPTURED:
3023 } else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
3025 state = cam_mm_get_state();
3027 case MM_CAMCORDER_STATE_PREPARE:
3028 if (!cam_video_record_start(ad)) {
3032 case MM_CAMCORDER_STATE_RECORDING:
3033 if (!cam_video_record_stop(ad)) {
3038 case MM_CAMCORDER_STATE_NONE:
3039 case MM_CAMCORDER_STATE_NULL:
3040 case MM_CAMCORDER_STATE_READY:
3041 case MM_CAMCORDER_STATE_CAPTURING:
3042 case MM_CAMCORDER_STATE_PAUSED:
3052 cam_critical(LOG_MM, "Unknow camera mode");
3059 Eina_Bool cam_continuous_af_start(void *data)
3062 struct appdata *ad = (struct appdata *)data;
3063 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
3065 CamAppData *camapp = NULL;
3066 camapp = ad->camapp_handle;
3067 cam_retvm_if(camapp == NULL, ECORE_CALLBACK_CANCEL, "camapp_handle is NULL");
3069 DEBUG_TRACE("cam_continuous_af_start");
3072 ad->af_x = (ad->win_width / 2) - ad->preview_offset_x;
3073 ad->af_y = (ad->win_height / 2) - ad->preview_offset_y;
3075 ad->af_x = (ad->af_x * ad->camfw_video_width) / ad->preview_w;
3076 ad->af_y = (ad->af_y * ad->camfw_video_height) / ad->preview_h;
3078 ad->touch_lcd_x = (ad->win_height / 2);
3079 ad->touch_lcd_y = (ad->win_width / 2);
3081 cam_app_draw_af_box(ad);
3082 camapp->focus_state = CAM_FOCUS_STATUS_RELEASED;
3083 cam_app_focus_guide_update(ad);
3085 evas_object_show(ad->focus_edje);
3087 camapp->focus_mode = CAM_FOCUS_MODE_CONTINUOUS;
3089 /* cam_mm_set_af_area include init focusing */
3090 DEBUG_TRACE("start continuous AF");
3091 if (cam_mm_set_af_area(ad->af_x, ad->af_y, ad->camera_focus_w, ad->camera_focus_h)) {
3092 DEBUG_TRACE("cam_mm_set_af_area success!");
3093 /*focus guide update*/
3095 DEBUG_TRACE("cam_mm_set_af_area error!");
3097 if (!cam_mm_start_focusing(camapp->focus_mode)) {
3098 cam_critical(LOG_MM, "cam_mm_start_focusing error");
3100 return ECORE_CALLBACK_CANCEL;
3103 Eina_Bool cam_volume_key_press(void *data)
3105 struct appdata *ad = (struct appdata *)data;
3106 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
3108 CamAppData *camapp = NULL;
3109 camapp = ad->camapp_handle;
3110 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
3112 if (ad->cancel_key_press == TRUE)
3113 return ECORE_CALLBACK_CANCEL;
3116 gboolean up_key = ad->up_key;
3117 debug_fenter(LOG_UI);
3119 state = cam_mm_get_state();
3120 cam_debug(LOG_UI, " state = %d", state);
3121 if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
3123 case RECORDER_STATE_RECORDING:
3124 case RECORDER_STATE_PAUSED:
3125 case RECORDER_STATE_READY:
3127 if (!camapp->zoom_lock) {
3128 zoom_in(ad, up_key);
3132 case RECORDER_STATE_NONE:
3133 case RECORDER_STATE_CREATED:
3138 } else if(camapp->camera_mode == CAM_CAMERA_MODE) {
3140 case CAMERA_STATE_PREVIEW:
3141 case CAMERA_STATE_CAPTURED:
3143 if (!camapp->zoom_lock) {
3144 zoom_in(ad, up_key);
3148 case CAMERA_STATE_NONE:
3149 case CAMERA_STATE_CREATED:
3150 case CAMERA_STATE_CAPTURING:
3158 return ECORE_CALLBACK_RENEW;
3161 static gboolean cam_power_key_press(void *data)
3163 struct appdata *ad = (struct appdata *)data;
3164 CamAppData *camapp = NULL;
3166 power_lock_state(POWER_STATE_SCREEN_OFF, 0);
3168 debug_fenter(LOG_UI);
3170 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
3171 camapp = ad->camapp_handle;
3172 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
3174 if (ad->mm_state < CAMERA_STATE_PREVIEW) {
3176 } else if (ad->mm_state == CAMERA_STATE_PREVIEW) {
3178 } else if (ad->mm_state > CAMERA_STATE_PREVIEW) {
3179 if (camapp->camera_mode == CAM_CAMERA_MODE) {
3180 DEBUG_TRACE("camera mode");
3182 camapp->rec_stop_type = CAM_REC_STOP_POWER_KEY;
3183 if (!cam_video_record_stop(ad)) {
3184 DEBUG_TRACE("record stop fail");
3191 power_unlock_state(POWER_STATE_SCREEN_OFF);
3196 static gboolean __cam_end_key_grab_init(void *data)
3198 struct appdata *ad = (struct appdata *)data;
3199 Ecore_X_Display *disp = NULL;
3201 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
3202 cam_retvm_if(ad->main_xid <= 0, FALSE, "main_xid <= 0");
3204 disp = ecore_x_display_get();
3205 cam_retvm_if(disp == NULL, FALSE, "ecore_x_display_get fail");
3207 if (utilx_grab_key(disp, ad->main_xid, KEY_END, SHARED_GRAB) == -1) {
3208 cam_critical(LOG_SYS, "%s key grap fail", KEY_END);
3214 gboolean cam_key_grab_init(void *data)
3216 struct appdata *ad = (struct appdata *)data;
3217 Ecore_X_Display *disp = NULL;
3219 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
3220 cam_retvm_if(ad->main_xid <= 0, FALSE, "main_xid <= 0");
3227 DEBUG_TRACE("key_grab_init############################");
3229 ad->cancel_key_press = FALSE;
3231 disp = ecore_x_display_get();
3232 cam_retvm_if(disp == NULL, FALSE, "ecore_x_display_get fail");
3235 if (utilx_grab_key(disp, ad->main_xid, KEY_VOLUMEUP, TOP_POSITION_GRAB) != success) {
3236 cam_critical(LOG_SYS, "%s key grap fail", KEY_VOLUMEUP);
3239 if (utilx_grab_key(disp, ad->main_xid, KEY_VOLUMEDOWN, TOP_POSITION_GRAB) != success) {
3240 cam_critical(LOG_SYS, "%s key grap fail", KEY_VOLUMEDOWN);
3244 if (utilx_grab_key(disp, ad->main_xid, KEY_CAMERA, TOP_POSITION_GRAB) != success) {
3245 cam_critical(LOG_SYS, "%s key grap fail", KEY_CAMERA);
3248 if (utilx_grab_key(disp, ad->main_xid, KEY_CONFIG, TOP_POSITION_GRAB) != success) {
3249 cam_critical(LOG_SYS, "%s key grap fail", KEY_CONFIG);
3253 if (utilx_grab_key(disp, ad->main_xid, KEY_POWER, SHARED_GRAB) != success) {
3254 cam_critical(LOG_SYS, "%s key grap fail", KEY_POWER);
3259 if (utilx_grab_key(disp, ad->main_xid, KEY_SEND, SHARED_GRAB) != success) {
3260 cam_critical(LOG_SYS, "%s key grap fail", KEY_SEND);
3263 if (utilx_grab_key(disp, ad->main_xid, KEY_END, SHARED_GRAB) != success) {
3264 cam_critical(LOG_SYS, "%s key grap fail", KEY_END);
3268 ad->isGrabed = TRUE;
3272 gboolean cam_key_grab_deinit(void *data)
3274 struct appdata *ad = (struct appdata *)data;
3275 Ecore_X_Display *disp = NULL;
3279 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
3280 cam_retvm_if(ad->main_xid <= 0, FALSE, "main_xid <= 0");
3284 DEBUG_TRACE("key_grab_deinit############################");
3286 disp = ecore_x_display_get();
3287 cam_retvm_if(disp == NULL, FALSE, "ecore_x_display_get fail");
3290 if (utilx_ungrab_key(disp, ad->main_xid, KEY_VOLUMEUP) != success){
3291 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_VOLUMEUP);
3294 if (utilx_ungrab_key(disp, ad->main_xid, KEY_VOLUMEDOWN) != success){
3295 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_VOLUMEDOWN);
3300 if (utilx_ungrab_key(disp, ad->main_xid, KEY_CAMERA) != success){
3301 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_CAMERA);
3305 if (utilx_ungrab_key(disp, ad->main_xid, KEY_CONFIG) != success){
3306 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_CONFIG);
3311 if (utilx_ungrab_key(disp, ad->main_xid, KEY_POWER) != success){
3312 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_POWER);
3315 if (utilx_ungrab_key(disp, ad->main_xid, KEY_PAUSE) != success){
3316 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_PAUSE);
3321 if (utilx_ungrab_key(disp, ad->main_xid, KEY_SEND) != success){
3322 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_SEND);
3325 if (utilx_ungrab_key(disp, ad->main_xid, KEY_SELECT) != success){
3326 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_SELECT);
3329 if (utilx_ungrab_key(disp, ad->main_xid, KEY_END) != success){
3330 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_END);
3334 ad->isGrabed = FALSE;
3338 gboolean cam_app_mouse_event_init(void *data)
3340 struct appdata *ad = (struct appdata *)data;
3342 cam_critical(LOG_UI, "appdata is NULL, maybe not created");
3345 #if ENABLE_MOUSE_CONTROL
3346 if (ad->mouse_down == NULL) {
3348 ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
3349 cam_mouse_button_down, ad);
3352 if (ad->mouse_up == NULL) {
3354 ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP,
3355 cam_mouse_button_up, ad);
3359 if (ad->mouse_move == NULL) {
3361 ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE,
3362 cam_mouse_move, ad);
3370 gboolean cam_app_mouse_event_deinit(void *data)
3372 struct appdata *ad = (struct appdata *)data;
3374 cam_critical(LOG_UI, "appdata is NULL, maybe not created");
3377 if (ad->mouse_down) {
3378 ecore_event_handler_del(ad->mouse_down);
3379 ad->mouse_down = NULL;
3382 ecore_event_handler_del(ad->mouse_up);
3383 ad->mouse_up = NULL;
3385 if (ad->mouse_move) {
3386 ecore_event_handler_del(ad->mouse_move);
3387 ad->mouse_move = NULL;
3393 gboolean cam_app_key_event_init(void *data)
3395 struct appdata *ad = (struct appdata *)data;
3397 DEBUG_TRACE("cam_app_key_event_init");
3400 cam_critical(LOG_UI, "appdata is NULL, maybe not created");
3403 if (ad->key_down == NULL) {
3405 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
3406 cam_hard_key_down, ad);
3408 if (ad->key_up == NULL) {
3410 ecore_event_handler_add(ECORE_EVENT_KEY_UP, cam_hard_key_up,
3413 #if ENABLE_MOUSE_CONTROL
3414 if (ad->mouse_down == NULL) {
3416 ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
3417 cam_mouse_button_down, ad);
3420 if (ad->mouse_up == NULL) {
3422 ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP,
3423 cam_mouse_button_up, ad);
3427 if (ad->mouse_move == NULL) {
3429 ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE,
3430 cam_mouse_move, ad);
3438 gboolean cam_app_key_event_deinit(void *data)
3440 struct appdata *ad = (struct appdata *)data;
3442 DEBUG_TRACE("cam_app_key_event_deinit");
3445 cam_critical(LOG_UI, "appdata is NULL, maybe not created");
3449 ecore_event_handler_del(ad->key_down);
3450 ad->key_down = NULL;
3453 ecore_event_handler_del(ad->key_up);
3456 if (ad->mouse_down) {
3457 ecore_event_handler_del(ad->mouse_down);
3458 ad->mouse_down = NULL;
3461 ecore_event_handler_del(ad->mouse_up);
3462 ad->mouse_up = NULL;
3464 if (ad->mouse_move) {
3465 ecore_event_handler_del(ad->mouse_move);
3466 ad->mouse_move = NULL;
3472 Eina_Bool cam_hard_key_down(void *data, int type, void *event_info)
3474 struct appdata *ad = (struct appdata *)data;
3475 CamAppData *camapp = NULL;
3478 Ecore_Event_Key *kd = (Ecore_Event_Key *) event_info;
3480 cam_retvm_if(ad == NULL, -1, "appdata is NULL");
3482 cam_debug(LOG_UI, "Key name : %s", kd->keyname);
3484 camapp = ad->camapp_handle;
3485 cam_retvm_if(camapp == NULL, -1, "camapp_handle is NULL");
3487 ad->show_menu = FALSE;
3488 ad->displayed_setting_popup = DISPLAY_NONE_POPUP;
3489 cam_toolbar_and_setting_popup_del(ad);
3491 cam_app_timeout_checker_update();
3493 /* Camera key Press */
3494 if (0 == strcmp(kd->keyname, KEY_CANCEL)) {
3495 ad->cancel_key_press = TRUE;
3497 if (0 == strcmp(kd->keyname, KEY_CONFIG)) { /* camera key - full */
3498 if (!camapp->key_lock) {
3499 camapp->key_lock = TRUE;
3500 CAM_TA_ACUM_ITEM_BEGIN("Total capture time", 0);
3501 CAM_TA_ACUM_ITEM_BEGIN
3502 (" camera key to capture start", 0);
3503 if (!cam_camera_key_press(ad)) {
3505 "cam_camera_key_press failed");
3507 camapp->key_lock = FALSE;
3510 /* Camera key HALF press */
3511 else if (0 == strcmp(kd->keyname, KEY_CAMERA)) { /* camera key - half */
3512 if (!camapp->key_lock) {
3513 camapp->key_lock = TRUE;
3514 ad->displayed_setting_popup = DISPLAY_NONE_POPUP;
3515 ad->show_menu = FALSE;
3516 cam_toolbar_and_setting_popup_del(ad);
3518 if (!cam_camera_key_half_press(ad)) {
3520 "cam_camera_key_half_press failed");
3522 camapp->key_lock = FALSE;
3524 } else if (0 == strcmp(kd->keyname, KEY_VOLUMEUP)) {
3525 if (!camapp->key_lock) {
3526 camapp->key_lock = TRUE;
3528 cam_add_longpress_key_timer(ad);
3529 camapp->key_lock = FALSE;
3531 } else if (0 == strcmp(kd->keyname, KEY_VOLUMEDOWN)) {
3532 if (!camapp->key_lock) {
3533 camapp->key_lock = TRUE;
3535 cam_add_longpress_key_timer(ad);
3536 camapp->key_lock = FALSE;
3538 } else if (0 == strcmp(kd->keyname, KEY_SELECT)) {
3540 } else if ((0 == strcmp(kd->keyname, KEY_SELECT))
3541 && ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
3542 if (!camapp->key_lock) {
3543 camapp->key_lock = TRUE;
3545 } else if (0 == strcmp(kd->keyname, KEY_POWER)) {
3546 if (!camapp->key_lock) {
3547 camapp->key_lock = TRUE;
3548 power_unlock_state(POWER_STATE_NORMAL);
3549 cam_power_key_press(ad);
3550 camapp->key_lock = FALSE;
3558 Eina_Bool cam_hard_key_up(void *data, int type, void *event_info)
3560 struct appdata *ad = (struct appdata *)data;
3561 CamAppData *camapp = NULL;
3563 Ecore_Event_Key *kd = (Ecore_Event_Key *) event_info;
3564 cam_retv_if(ad == NULL, ECORE_CALLBACK_CANCEL);
3566 cam_debug(LOG_UI, "Key name : %s", kd->keyname);
3568 camapp = ad->camapp_handle;
3569 cam_retv_if(camapp == NULL, ECORE_CALLBACK_CANCEL);
3571 cam_app_timeout_checker_update();
3573 if (0 == strcmp(kd->keyname, KEY_CANCEL)) {
3574 ad->cancel_key_press = FALSE;
3577 if(ad->cancel_key_press == TRUE) {
3578 if (ad->longpress_timer) { /*volume key long press */
3579 cam_del_longpress_key_timer(ad);
3580 cam_volume_key_press(ad);
3586 if (0 == strcmp(kd->keyname, KEY_CONFIG)) { /* camera key - full */
3587 if (!camapp->key_lock) {
3588 camapp->key_lock = TRUE;
3589 if (!cam_camera_key_release(ad)) {
3591 "cam_camera_key_release failed");
3593 camapp->key_lock = FALSE;
3595 } else if (0 == strcmp(kd->keyname, KEY_CAMERA)) { /* camera key - half */
3596 if (!camapp->key_lock) {
3597 camapp->key_lock = TRUE;
3598 if (!cam_camera_key_half_release(ad)) {
3600 "cam_camera_key_release failed");
3602 camapp->key_lock = FALSE;
3604 } else if (0 == strcmp(kd->keyname, KEY_VOLUMEUP)
3605 || 0 == strcmp(kd->keyname, KEY_VOLUMEDOWN)) {
3606 if (!camapp->key_lock) {
3607 camapp->key_lock = TRUE;
3608 cam_del_longpress_key_timer(ad);
3609 cam_volume_key_press(ad);
3610 camapp->key_lock = FALSE;
3612 } else if (0 == strcmp(kd->keyname, KEY_END)
3613 || 0 == strcmp(kd->keyname, KEY_SELECT)) {
3615 DEBUG_TRACE("camapp->key_lock = %d", camapp->key_lock);
3616 if (!camapp->key_lock) {
3617 camapp->key_lock = TRUE;
3619 if ( ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
3622 mm_state = cam_mm_get_state();
3623 ad->appcore_state = CAM_APPCORE_PAUSE_STATE;
3624 if (mm_state < CAMERA_STATE_CAPTURING) {
3630 if (ad->imageviewer_ug) {
3631 DEBUG_TRACE("destory imageviewer");
3632 cam_app_close_ug(ad);
3633 cam_app_start_rotate(ad, false);
3634 cam_app_key_event_deinit(ad);
3635 if(!cam_key_grab_deinit(ad))
3636 DEBUG_TRACE("cam_key_grab_deinit fail");
3637 ad->foucs_out_from_quickview = FALSE;
3639 if ((ad->mm_state == RECORDER_STATE_RECORDING
3640 || ad->mm_state == RECORDER_STATE_PAUSED)
3641 &&camapp->camera_mode == CAM_CAMCORDER_MODE) {
3642 camapp->rec_stop_type = CAM_REC_STOP_NORMAL;
3643 ad->recording_commit = ecore_idler_add(cam_video_idler_record_stop, ad);
3644 camapp->key_lock = FALSE;
3646 } else if (ad->mm_state == CAMERA_STATE_CAPTURING
3647 &&camapp->camera_mode == CAM_CAMERA_MODE) {
3648 camapp->key_lock = FALSE;
3650 } else if ((ad->mm_state == RECORDER_STATE_READY
3651 &&camapp->camera_mode == CAM_CAMERA_MODE)
3652 ||(ad->mm_state == CAMERA_STATE_PREVIEW
3653 &&camapp->camera_mode == CAM_CAMCORDER_MODE)) {
3656 if (0 == strcmp(kd->keyname, KEY_END)) {
3657 cam_debug(LOG_UI, " Key up : END Key");
3658 /*cam_app_exit(ad);*/
3659 /*camapp->key_lock = FALSE;*/
3661 camapp->key_lock = FALSE;
3664 cam_debug(LOG_UI, "key lock status = %d",
3672 /*note: focus edje zoom in*/
3673 static void __cam_app_set_focus_zoom_in_effect(void *data)
3675 struct appdata *ad = (struct appdata *)data;
3676 cam_retm_if(ad == NULL, "appdata is NULL");
3678 if (ad->camapp_handle->enable_touch_af == TRUE) {
3679 REMOVE_TIMER(ad->continuous_af_timer);
3680 cam_camera_touch_af_press(ad);
3682 cam_app_draw_af_box(ad);
3683 evas_object_show(ad->focus_edje);
3684 cam_ui_effect_utils_set_zoom_effect(ad->focus_edje,
3685 CAM_FOCUS_EDJE_ZOOM_EFFECT_START_RATE,
3686 CAM_FOCUS_EDJE_ZOOM_EFFECT_END_RATE,
3687 CAM_FOCUS_EDJE_ZOOM_EFFECT_DURATION);
3691 /*note: focus edje zoom out*/
3692 static void __cam_app_set_focus_zoom_out_effect(void *data)
3694 struct appdata *ad = (struct appdata *)data;
3695 cam_retm_if(ad == NULL, "appdata is NULL");
3697 if (ad->camapp_handle->enable_touch_af == TRUE) {
3698 REMOVE_TIMER(ad->continuous_af_timer);
3699 cam_camera_touch_af_press(ad);
3701 cam_app_draw_af_box(ad);
3702 evas_object_show(ad->focus_edje);
3703 cam_ui_effect_utils_set_zoom_effect(ad->focus_edje,
3704 CAM_FOCUS_EDJE_ZOOM_EFFECT_END_RATE,
3705 CAM_FOCUS_EDJE_ZOOM_EFFECT_START_RATE,
3706 CAM_FOCUS_EDJE_ZOOM_EFFECT_DURATION);
3710 #if ENABLE_MOUSE_CONTROL
3711 Eina_Bool cam_mouse_button_down(void *data, int type, void *event_info)
3713 struct appdata *ad = (struct appdata *)data;
3714 cam_retvm_if(ad == NULL, EINA_FALSE, "appdata is NULL");
3715 CamAppData *camapp = ad->camapp_handle;
3716 cam_retvm_if(camapp == NULL, EINA_FALSE, "camapp_handle is NULL");
3719 || ad->setting_ctxpopup
3720 || (ad->toolbar_show_setting_popup == TRUE)
3721 || (ad->toolbar_show_edit_shortcuts_popup == TRUE)) {
3722 cam_debug(LOG_UI, "ignore touch event");
3723 ad->af_outside = TRUE;
3726 int toolbar_width = TOOLBAR_W;
3728 Ecore_Event_Mouse_Button *md = (Ecore_Event_Mouse_Button *) event_info;
3729 cam_debug(LOG_UI, "mouse button down[%d, %d]", md->root.x, md->root.y);
3731 ad->touch_lcd_x = md->root.x; /* LCD x */
3732 ad->touch_lcd_y = md->root.y; /* LCD y */
3734 ad->af_outside = FALSE;
3737 if (ad->touch_lcd_y < toolbar_width
3738 || ad->touch_lcd_y > (ad->win_width - toolbar_width)) {
3739 ad->af_outside = TRUE;
3741 ad->af_x = ad->touch_lcd_y - ad->preview_offset_x;
3744 if (ad->touch_lcd_x < ad->preview_offset_y
3745 || ad->touch_lcd_x > (ad->preview_h + ad->preview_offset_y)) {
3746 ad->af_outside = TRUE;
3748 ad->af_y = ad->preview_h - ad->touch_lcd_x;
3751 ad->af_x = (ad->af_x * ad->camfw_video_width) / ad->preview_w;
3752 ad->af_y = (ad->af_y * ad->camfw_video_height) / ad->preview_h;
3754 ("*************************************************************************************");
3755 DEBUG_TRACE("touched lcd x,y=[%d,%d] af x,y=[%d,%d]\n", ad->touch_lcd_x,
3756 ad->touch_lcd_y, ad->af_x, ad->af_y);
3758 ("*************************************************************************************");
3759 if (ad->af_outside == FALSE) {
3760 __cam_app_set_focus_zoom_in_effect((void *)ad);
3762 cam_app_timeout_checker_update();
3763 cam_setting_toolbar_execution_time_checker_update(ad);
3768 Eina_Bool cam_mouse_button_up(void *data, int type, void *event_info)
3770 struct appdata *ad = (struct appdata *)data;
3771 CamAppData *camapp = NULL;
3774 || ad->setting_ctxpopup
3775 || (ad->toolbar_show_setting_popup == TRUE)
3776 || (ad->toolbar_show_edit_shortcuts_popup == TRUE)) {
3777 cam_debug(LOG_UI, "ignore touch event");
3778 ad->af_outside = TRUE;
3782 Ecore_Event_Mouse_Button *md = (Ecore_Event_Mouse_Button *) event_info;
3783 if (ad->shutter_move == TRUE) {
3786 double shutter_h_ratio = SHUTTER_H_RATIO;
3787 double shutter_w_ratio = SHUTTER_W_RATIO;
3788 double screen_ratio = SCREEN_RATIO;
3790 y_gap = (double)md->root.y /(double)ad->win_width;
3791 x_gap = (double)md->root.x /(double)ad->win_height;
3793 if (x_gap > (screen_ratio -shutter_h_ratio) || x_gap < shutter_h_ratio) {
3794 if (!cam_camera_key_half_release(ad)) {
3795 DEBUG_TRACE("cam_camera_key_half_release");
3797 } else if (ad->angle == 90 ||ad->angle == 180) {
3798 if (y_gap > shutter_w_ratio) {
3799 if (!cam_camera_key_half_release(ad)) {
3800 DEBUG_TRACE("cam_camera_key_half_release");
3804 if (y_gap < screen_ratio -shutter_w_ratio) {
3805 if (!cam_camera_key_half_release(ad)) {
3806 DEBUG_TRACE("cam_camera_key_half_release");
3812 cam_retvm_if(ad == NULL, EINA_FALSE, "appdata is NULL");
3813 cam_debug(LOG_UI, "mouse button up[%d, %d]", md->root.x, md->root.y);
3814 if (ad->af_outside == FALSE) {
3815 __cam_app_set_focus_zoom_out_effect((void *)ad);
3817 camapp = ad->camapp_handle;
3818 if (camapp == NULL) {
3819 cam_warning(LOG_UI, "camapp_handle is NULL, maybe not created");
3825 Eina_Bool cam_mouse_move(void *data, int type, void *event_info)
3827 struct appdata *ad = (struct appdata *)data;
3828 CamAppData *camapp = NULL;
3830 Ecore_Event_Mouse_Move *md = (Ecore_Event_Mouse_Move *) event_info;
3832 cam_retvm_if(ad == NULL, -1, "appdata is NULL");
3833 cam_debug(LOG_UI, "mouse move[%d, %d]", md->root.x, md->root.y);
3834 cam_debug(LOG_UI, "mouse move angle[%lf]", md->multi.angle);
3835 cam_debug(LOG_UI, "mouse move pressure[%lf]", md->multi.pressure);
3836 camapp = ad->camapp_handle;
3837 if (camapp == NULL) {
3838 cam_warning(LOG_UI, "camapp_handle is NULL, maybe not created");
3841 cam_app_timeout_checker_update();
3847 void cam_app_set_config_group(gint mode)
3849 cam_debug(LOG_UI, "mode : %d", mode);
3851 if (mode == CAM_CAMERA_MODE) {
3852 cam_config_set_group_name(CAM_CONFIG_TYPE_PREVIEW, "still");
3854 cam_config_set_group_name(CAM_CONFIG_TYPE_PREVIEW, "video");
3857 debug_fleave(LOG_UI);
3862 int cam_app_get_latest_mode(void)
3864 cam_config_set_group_name(CAM_CONFIG_TYPE_COMMON, "common");
3866 cam_config_get_int_by_type(CAM_CONFIG_TYPE_COMMON, "mode",
3869 debug_msg(LOG_UI, "last mode:%d", last_mode);
3873 const gchar *cam_app_get_target_path(void)
3875 CamAppData *camapp = NULL;
3877 camapp = cam_handle_get();
3881 const gchar *default_path = NULL;
3882 switch (camapp->storage) {
3883 case CAM_STORAGE_INTERNAL:
3885 (camapp->camera_mode == CAM_CAMCORDER_MODE) ?
3886 cam_file_get_internal_video_path() :
3887 cam_file_get_internal_image_path();
3889 case CAM_STORAGE_EXTERNAL:
3891 (camapp->camera_mode == CAM_CAMCORDER_MODE) ?
3892 cam_file_get_external_video_path() :
3893 cam_file_get_external_image_path();
3896 cam_critical(LOG_UI, "Unknow storage type : %d",
3901 cam_debug(LOG_UI, "target path : [%s]", default_path);
3902 return default_path;
3904 cam_critical(LOG_UI, "camapp handle is NULL");
3909 gchar *cam_app_get_last_filename(void)
3911 CamAppData *camapp = NULL;
3912 gchar *last_file_path = NULL;
3913 struct appdata *ad = (struct appdata *)cam_appdata_get();
3914 cam_retvm_if(ad == NULL, NULL, "appdata is NULL");
3916 camapp = cam_handle_get();
3917 cam_retvm_if(camapp == NULL, NULL, "cam_handle is NULL");
3919 last_file_path = cam_file_get_last_file_path(ad, cam_app_get_target_path());
3921 if (last_file_path) {
3922 cam_debug(LOG_UI, "last_file_path : %s", last_file_path);
3924 cam_critical(LOG_UI, "last_file_path is NULL");
3927 return last_file_path;
3930 gchar *cam_app_get_next_filename(void)
3933 CamAppData *camapp = NULL;
3934 gchar *new_filename = NULL;
3935 struct appdata *ad = (struct appdata *)cam_appdata_get();
3936 cam_retvm_if(ad == NULL, NULL, "appdata is NULL");
3938 camapp = cam_handle_get();
3939 cam_retvm_if(camapp == NULL, NULL, "cam_handle is NULL");
3941 mm_state = cam_mm_get_state();
3943 if (mm_state == RECORDER_STATE_RECORDING
3944 &&camapp->camera_mode == CAM_CAMCORDER_MODE) {
3945 new_filename = cam_file_get_next_filename(cam_app_get_target_path(), INAGE_FILE_NAME, IMAGE_FILE_EXTENSION);
3947 new_filename = cam_file_get_next_filename(cam_app_get_target_path(),
3948 (camapp->camera_mode ==
3952 (camapp->camera_mode ==
3954 IMAGE_FILE_EXTENSION :
3955 VIDEO_FILE_EXTENSION);
3959 cam_debug(LOG_UI, "next filename : %s", new_filename);
3961 cam_critical(LOG_UI, "new_filename is NULL");
3964 return new_filename;
3967 static void __cam_preview_cb(void *stream_buffer, int buffer_size, int width,
3968 int height, camera_pixel_format_e format, void *user_data)
3971 cam_retm_if(user_data == NULL, "data is null");
3972 struct appdata *ad = (struct appdata *)user_data;
3974 CamAppData *camapp = ad->camapp_handle;
3975 cam_retm_if(camapp == NULL, "camapp is null");
3979 static void __cam_state_change_cb(camera_state_e previous, camera_state_e current,
3980 bool by_policy, void *user_data)
3982 struct appdata *ad = NULL;
3983 CamAppData *camapp = NULL;
3984 ad = (struct appdata *)user_data;
3985 cam_retm_if(ad == NULL, "camapp is null");
3986 camapp = ad->camapp_handle;
3987 cam_retm_if(camapp == NULL, "camapp is null");
3988 DEBUG_TRACE("current= %d, previous = %d, ad->enable_mode_change = %d",
3989 current, previous, ad->enable_mode_change);
3990 if (current == CAMERA_STATE_PREVIEW) {
3991 ad->enable_mode_change = TRUE;
3993 ad->enable_mode_change = FALSE;
3995 DEBUG_TRACE("current= %d, previous = %d, ad->enable_mode_change = %d",
3996 current, previous, ad->enable_mode_change);
3997 cam_app_state_manager(previous, current, by_policy);
4001 static void __cam_focus_cb(camera_focus_state_e state, void *user_data) {
4003 struct appdata *ad = NULL;
4004 CamAppData *camapp = NULL;
4006 ad = (struct appdata *)user_data;
4007 cam_retm_if(ad == NULL, "appdata is NULL");
4010 * TODO: perhaps we have to consider: in thread, we should not use any efl api.
4012 * try not to operation the global evas object in asynchronous
4013 * callback or thread. Some bs perhaps caused by this.
4016 /*note: while rotating, return. */
4017 if (ad->is_rotating) return;/*note: while rotating, return. */
4018 camapp = ad->camapp_handle;
4019 cam_retm_if(camapp == NULL, "camapp is NULL");
4022 cam_debug(LOG_MM, " Focus state changed to [%d]", state);
4024 if(ad->appcore_state == CAM_APPCORE_PAUSE_STATE)
4027 if (camapp->camera_mode == CAM_CAMERA_MODE) {
4028 camapp->focus_state = state ;
4029 cam_app_focus_guide_update(ad);
4031 camapp->focus_state = CAM_FOCUS_STATUS_RELEASED;
4034 case CAMERA_FOCUS_STATE_ONGOING:
4036 case CAMERA_FOCUS_STATE_FOCUSED:
4037 if (ad->mm_state < CAMERA_STATE_CAPTURING) {
4038 if (camapp->shutter_sound != CAM_SETTINGS_SOUND_OFF
4039 && camapp->camera_mode == CAM_CAMERA_MODE )
4040 cam_sound_play (CAM_SOUND_EFFECT_AF_OK, ad);
4042 if (camapp->focus_mode == CAM_FOCUS_MODE_TOUCH_AUTO){
4043 REMOVE_TIMER(ad->continuous_af_timer);
4044 DEBUG_TRACE("start caf");
4045 cam_app_focus_guide_create(ad);
4046 cam_app_focus_guide_update(ad);
4047 ad->continuous_af_timer= ecore_timer_add(FOCUS_FOCUSED_TIME_OUT, cam_continuous_af_start, ad);
4051 case CAMERA_FOCUS_STATE_FAILED:
4052 if (ad->mm_state < CAMERA_STATE_CAPTURING) {
4053 if (camapp->shutter_sound != CAM_SETTINGS_SOUND_OFF
4054 && camapp->camera_mode == CAM_CAMERA_MODE)
4055 cam_sound_play (CAM_SOUND_EFFECT_AF_FAIL, ad);
4057 if (camapp->focus_mode == CAM_FOCUS_MODE_TOUCH_AUTO) {
4058 REMOVE_TIMER(ad->continuous_af_timer);
4059 DEBUG_TRACE("start caf");
4060 cam_app_focus_guide_create(ad);
4061 cam_app_focus_guide_update(ad);
4062 ad->continuous_af_timer= ecore_timer_add(FOCUS_FAILED_TIME_OUT, cam_continuous_af_start, ad);
4073 static void __cam_capture_cb(camera_image_data_s* image,
4074 camera_image_data_s* postview,
4075 camera_image_data_s* thumbnail,
4078 struct appdata *ad = (struct appdata *)user_data;
4079 cam_retm_if(ad == NULL, "appdata is NULL");
4080 CamAppData *camapp = NULL;
4081 camapp = ad->camapp_handle;
4082 cam_retm_if(camapp == NULL, "camapp is NULL");
4084 gchar *filename = NULL;
4086 if ((image->format == CAMERA_PIXEL_FORMAT_YUYV)
4087 || (image->format == CAMERA_PIXEL_FORMAT_NV12)) {
4089 "got raw data - format [%d] data [%p], length [%d], width [%d], height [%d]",
4090 image->format, image->data, image->size, image->width,
4093 /* MMImageJpegEncodeToFile(filename, src->data, src->width,src->height, src->format, 90); */
4094 } else if (image->format == CAMERA_PIXEL_FORMAT_JPEG) {
4096 "got JPEG data - data [%p], length [%d], width [%d], height [%d]",
4097 image->data, image->size, image->width, image->height);
4100 filename = cam_app_get_next_filename();
4101 if (filename == NULL) {
4102 cam_critical(LOG_SYS, " Get next filename FAILED");
4106 fp = fopen(filename, "w+");
4108 cam_critical(LOG_SYS, "FileOPEN error!!");
4111 cam_debug(LOG_SYS, "FileOPEN success");
4112 if (fwrite(image->data, image->size, 1, fp) != 1) {
4113 cam_critical(LOG_SYS, "File write error!!");
4117 /*fsync(fp->_fileno);*/
4118 /*block for increasing formance of shot-to-shot */
4119 cam_debug(LOG_SYS, "File write success");
4122 if (camapp->filename)
4123 free(camapp->filename);
4124 camapp->filename = strdup(filename);
4130 static void __cam_capture_completed_cb(void *user_data)
4132 /* camera_error_e e;*/
4134 struct appdata *ad = NULL;
4135 CamAppData *camapp = NULL;
4137 ad = (struct appdata *)user_data;
4138 camapp = ad->camapp_handle;
4140 if (camapp->camera_mode == CAM_CAMERA_MODE) {
4141 #ifndef ENABLE_CAPTURE_ANIMATION
4143 /* Idler of capture callback management. wh01.cho@samsung.com. 2010-12-15. */
4144 CamIdlerItem *item = NULL;
4145 item = (CamIdlerItem *)
4146 g_malloc(sizeof(CamIdlerItem));
4151 item->data = user_data;
4152 item->idler = ecore_idler_add(cam_image_capture_handle_idler, item);
4155 ad->capture_cb_list = g_list_append(ad->capture_cb_list, item->idler);
4157 cam_info(LOG_UI, "image capture idler add : %p ", item->idler);
4161 if (!cam_app_preview_start(ad)) {
4162 cam_critical(LOG_MM, "cam_app_preview_start failed");
4163 cam_app_notice_popup(ad, "cam_app_preview_start faild ",
4164 cam_app_timeout_notice_response_cb);
4167 }else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
4169 DEBUG_TRACE("MM_MESSAGE_CAMCORDER_VIDEO_SNAPSHOT_CAPTURED");
4170 ecore_idler_add(cam_capture_on_recording_handle, ad);
4174 static void __cam_interrupted_cb(camera_policy_e policy, camera_state_e previous, camera_state_e current, void *data)
4176 struct appdata *ad = (struct appdata *)data;
4177 CamAppData *camapp = NULL;
4178 cam_retm_if(ad == NULL, "appdata is NULL");
4179 camapp = ad->camapp_handle;
4180 cam_retm_if(camapp == NULL, "cam_handle is NULL");
4181 DEBUG_TRACE("policy is [%d]",policy);
4183 case CAMERA_POLICY_SOUND:
4185 cam_app_black_screen_show(ad, 2);
4186 ecore_timer_add(0.01, cam_delay_popup, (void *)ad);
4189 case CAMERA_POLICY_SECURITY:
4190 cam_app_mdm_syspopup(ad);
4197 static void __rec_interrupted_cb(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *data)
4199 struct appdata *ad = (struct appdata *)data;
4200 CamAppData *camapp = NULL;
4201 cam_retm_if(ad == NULL, "appdata is NULL");
4202 camapp = ad->camapp_handle;
4203 cam_retm_if(camapp == NULL, "cam_handle is NULL");
4204 DEBUG_TRACE("policy is [%d]",policy);
4207 case RECORDER_POLICY_SOUND:
4209 cam_app_black_screen_show(ad, 2);
4210 ecore_timer_add(0.01, cam_delay_popup, (void *)ad);
4213 case RECORDER_POLICY_SECURITY:
4214 cam_app_mdm_syspopup(ad);
4221 static void __cam_error_cb(int error, camera_state_e current_state, void *user_data)
4223 struct appdata *ad = NULL;
4224 CamAppData *camapp = NULL;
4226 ad = (struct appdata *)user_data;
4227 cam_retm_if(ad == NULL, "appdata is NULL");
4228 camapp = ad->camapp_handle;
4229 cam_retm_if(camapp == NULL, "camapp is NULL");
4232 state = current_state;
4234 "MM ERROR occurs : code [%x], state [%d]",
4238 case CAMERA_ERROR_DEVICE:
4239 cam_critical(LOG_SYS,
4240 " MM CAMCARORDER ERROR ");
4241 if (state < CAMERA_STATE_CAPTURING) {
4242 cam_app_notice_popup(ad,
4243 _("IDS_CAM_POP_UNABLE_TO_START_CAMERA"),
4244 cam_app_timeout_notice_response_cb);
4246 cam_app_notice_popup(ad,
4247 _("IDS_CAM_POP_CAPTURE_TIME_EXCEEDED_START_AGAIN"),
4248 cam_app_timeout_notice_response_cb);
4251 case CAMERA_ERROR_INVALID_PARAMETER:
4252 if (state == CAMERA_STATE_CAPTURING) {
4253 cam_app_notice_popup(ad,
4254 _("IDS_CAM_POP_CAPTURE_ERROR"),
4255 cam_app_timeout_notice_response_cb);
4258 case CAMERA_ERROR_SOUND_POLICY:
4260 DEBUG_TRACE(" MM CAMCARORDER ERROR\n");
4261 cam_app_black_screen_show(ad, 2);
4262 ecore_timer_add(0.01, cam_delay_popup,
4266 case CAMERA_ERROR_INVALID_OPERATION:
4268 DEBUG_TRACE(" Internal error\n");
4269 cam_app_black_screen_show(ad, 2);
4270 ecore_timer_add(0.01, cam_delay_popup,
4274 case CAMERA_ERROR_OUT_OF_MEMORY:
4276 DEBUG_TRACE(" Out of memory\n");
4277 cam_app_black_screen_show(ad, 2);
4278 ecore_timer_add(0.01, cam_delay_popup,
4284 DEBUG_TRACE(" MM CAMCARORDER ERROR error code =%x \n", error);
4285 if (state == CAMERA_STATE_CAPTURING
4286 && camapp->camera_mode == CAM_CAMERA_MODE) {
4287 cam_app_notice_popup(ad, _("IDS_CAM_POP_CAPTURE_ERROR"),
4288 cam_app_capture_error_popup_response_cb);
4296 static void __recorder_state_cb(recorder_state_e previous , recorder_state_e current , bool by_policy, void *user_data)
4298 struct appdata *ad = NULL;
4299 CamAppData *camapp = NULL;
4301 ad = (struct appdata *)user_data;
4302 cam_retm_if(ad == NULL, "appdata is NULL");
4303 camapp = ad->camapp_handle;
4304 cam_retm_if(camapp == NULL, "camapp is NULL");
4305 if (current == RECORDER_STATE_READY) {
4306 ad->enable_mode_change = TRUE;
4308 ad->enable_mode_change = FALSE;
4310 cam_app_state_manager(previous, current, by_policy);
4313 void __recording_status_cb(int elapsed_time, int file_size, void *user_data)
4315 struct appdata *ad = NULL;
4316 CamAppData *camapp = NULL;
4317 ad = (struct appdata *)user_data;
4318 cam_retm_if(ad == NULL, "appdata is NULL");
4319 camapp = ad->camapp_handle;
4320 cam_retm_if(camapp == NULL, "camapp is NULL");
4321 /* update current time */
4325 elapsed = elapsed_time / 1000;
4326 filesize = file_size;
4327 if (camapp->rec_elapsed < elapsed) {
4328 GValue value = { 0, };
4330 cam_debug(LOG_UI, "time updated: %u ", elapsed);
4331 CAM_GVALUE_SET_UINT(value, elapsed);
4332 cam_handle_value_set(ad, PROP_REC_TIME, &value);
4334 if (camapp->rec_filesize < filesize) {
4335 GValue value = { 0, };
4337 cam_debug(LOG_UI, "filesize updated: %u ", filesize);
4338 CAM_GVALUE_SET_UINT(value, filesize);
4339 cam_handle_value_set(ad, PROP_REC_FILE_SIZE, &value);
4343 void __recording_limit_reached_cb(recorder_recording_limit_type_e type, void *user_data)
4345 struct appdata *ad = NULL;
4346 CamAppData *camapp = NULL;
4347 ad = (struct appdata *)user_data;
4348 cam_retm_if(ad == NULL, "appdata is NULL");
4349 camapp = ad->camapp_handle;
4350 cam_retm_if(camapp == NULL, "camapp is NULL");
4352 if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
4353 camapp->rec_stop_type = type;/*CAM_REC_STOP_TIME_LIMIT;*/
4354 ad->recording_commit =
4355 ecore_idler_add(cam_video_idler_record_stop, ad);
4359 gboolean cam_callback_init(void *data)
4361 struct appdata *ad = (struct appdata *)data;
4362 CamAppData *camapp = NULL;
4364 debug_fenter(LOG_UI);
4366 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4367 camapp = ad->camapp_handle;
4368 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
4369 camapp->error_cb = __cam_error_cb;
4370 camapp->focus_cb = __cam_focus_cb;
4371 camapp->state_cb = __cam_state_change_cb;
4372 camapp->preview_cb = __cam_preview_cb;
4373 camapp->capture_completed_cb = __cam_capture_completed_cb;
4374 camapp->cam_interrupted_cb = __cam_interrupted_cb;
4376 camapp->recording_status_cb = __recording_status_cb;
4377 camapp->recording_state_changed_cb = __recorder_state_cb;
4378 camapp->recording_limit_reached_cb = __recording_limit_reached_cb;
4379 camapp->rec_interrupted_cb = __rec_interrupted_cb;
4381 if (camapp->camera_mode == CAM_CAMERA_MODE) {
4382 switch (camapp->shooting_mode) {
4383 case CAM_SINGLE_MODE:
4385 camapp->capture_cb = (camera_capturing_cb)
4392 camapp->capture_cb = __cam_capture_cb;
4396 if (camapp->camera_mode == CAM_CAMERA_MODE) {
4397 /*ret &= cam_mm_recorder_unset_state_changed_cb();*/
4398 ret &= cam_mm_set_preview_cb(camapp->preview_cb, (void*)ad);
4399 ret &= cam_mm_set_focus_changed_cb(camapp->focus_cb, (void*)ad);
4400 ret &= cam_mm_set_state_changed_cb(camapp->state_cb, (void*)ad);
4401 ret &= cam_mm_set_error_cb(camapp->error_cb, (void*)ad);
4402 ret &= cam_mm_set_camera_interrupted_cb(camapp->cam_interrupted_cb, (void*)ad);
4403 } else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
4404 ret &= cam_mm_unset_state_changed_cb();
4405 /*ret &= cam_mm_unset_preview_cb();*/
4406 /*ret &= cam_mm_unset_state_changed_cb();*/
4407 /*ret &= cam_mm_unset_error_cb();*/
4408 ret &= cam_mm_recorder_set_state_changed_cb(camapp->recording_state_changed_cb, (void*)ad);
4409 ret &= cam_mm_recorder_set_recording_status_cb(camapp->recording_status_cb, (void*)ad);
4410 ret &= cam_mm_recorder_set_recording_limit_reached_cb(camapp->recording_limit_reached_cb, (void*)ad);
4411 ret &= cam_mm_set_recorder_interrupted_cb(camapp->rec_interrupted_cb, (void*)ad);
4418 static void cam_app_close_ug(void *data)
4420 cam_debug(LOG_UI, " ");
4421 struct appdata *ad = (struct appdata *)data;
4424 cam_info(LOG_UI, "ad->imageviewer_ug : %p", ad->imageviewer_ug);
4425 if (ad->imageviewer_ug) {
4426 ug_destroy(ad->imageviewer_ug);
4427 ad->imageviewer_ug = NULL;
4429 cam_file_init(NULL);
4433 static void __ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
4435 cam_debug(LOG_UI, " ");
4437 struct appdata *ad = (struct appdata *)priv;
4443 base = ug_get_layout(ug);
4448 case UG_MODE_FULLVIEW:
4449 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
4451 elm_win_resize_object_add(ad->win_main, base);
4452 evas_object_show(base);
4459 void __ug_result_cb(ui_gadget_h ug, service_h result, void *priv)
4462 cam_debug(LOG_UI, " ");
4464 struct appdata *ad = (struct appdata *)priv;
4467 CamAppData *camapp = NULL;
4469 cam_retm_if(ad == NULL, "appdata is NULL");
4470 camapp = ad->camapp_handle;
4471 cam_retm_if(camapp == NULL, "cam_handle is NULL");
4473 if (ad->imageviewer_ug) {
4474 if (ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
4475 if (result == NULL) {
4476 ad->path_in_return = false;
4480 if ((ad->exe_args->caller) && (strcmp(ad->exe_args->caller, "contacts") == 0)) {
4482 service_create(&reply);
4484 service_get_extra_data(result, "crop_image_path", &val);
4485 service_add_extra_data(reply, "crop_image_path", val);
4486 service_get_extra_data(result, "image_path", &val);
4487 service_add_extra_data(reply, "image_path", val);
4489 service_reply_to_launch_request(reply, ad->service_handle, SERVICE_RESULT_SUCCEEDED);
4490 service_destroy(reply);
4492 ad->path_in_return = true;
4495 /* get result value. */
4496 service_get_extra_data(result, "Result", &val);
4498 if (strcmp(val, "Ok") == 0) {
4499 ad->path_in_return = true;
4502 else if (strcmp(val, "Cancel") == 0) {
4503 ad->path_in_return = false;
4510 void __ug_destroy_cb(ui_gadget_h ug, void *priv)
4512 cam_debug(LOG_UI, " ");
4517 struct appdata *ad = (struct appdata *)priv;
4519 cam_retm_if(ad == NULL, "appdata is NULL");
4520 ad->ug_is_deleting_process = TRUE;
4522 cam_app_timeout_checker_init(ad);
4524 /* add mouse down event - image viewer bug */
4525 if (ad->black_screen) {
4526 DEL_EVAS_OBJECT(ad->black_screen);
4527 ad->black_screen = NULL;
4530 if (ad->imageviewer_ug) {
4531 ug_destroy(ad->imageviewer_ug);
4532 ad->imageviewer_ug = NULL;
4535 elm_win_indicator_mode_set(ad->win_main, 0);
4536 cam_app_start_rotate(ad, false);
4538 ecore_idler_add(__ug_destory_postprocessing, ad);
4543 Eina_Bool __ug_destory_postprocessing(void *data)
4545 struct appdata *ad = data;
4546 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4547 ad->ug_is_deleting_process = TRUE;
4548 CamAppData *camapp = NULL;
4549 camapp = ad->camapp_handle;
4550 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
4552 cam_app_mouse_event_init(ad);
4554 show_toolbar_edje(ad);
4556 if (!cam_file_check_exists(camapp->filename)) {
4557 free(camapp->filename);
4558 camapp->filename = NULL;
4560 if (!cam_app_preview_start(ad)) {
4561 cam_app_notice_popup(ad,
4562 "PREVIEW START FAIL !!",
4563 cam_app_timeout_notice_response_cb);
4566 if (!cam_key_grab_init(ad))
4567 DEBUG_TRACE("cam_key_grab_init fail");
4568 cam_app_key_event_init(ad);
4569 /* update thumbnail to quickview after return from image viewer */
4570 cam_app_update_quickview_icon(ad);
4571 cam_file_init(NULL);
4572 ad->ug_is_deleting_process = FALSE;
4573 return ECORE_CALLBACK_CANCEL;
4578 gboolean cam_app_run_image_viewer_ug(void *data, char *file_path)
4580 DEBUG_TRACE("START");
4582 struct appdata *ad = (struct appdata *)data;
4584 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4585 cam_retvm_if(file_path == NULL, FALSE, "file_path is NULL");
4587 if (ad->ug_is_deleting_process) /*NOTE:before old ug is not deleted completely, should not create new ug*/
4590 cam_debug(LOG_UI, " ");
4591 cam_debug(LOG_UI, "path :%s", file_path);
4593 if (ad->imageviewer_ug) {
4594 return FALSE;/*NOTE: ug is login, not create ug again.*/
4599 opt = UG_OPT_INDICATOR_LANDSCAPE_ONLY | UG_OPT_INDICATOR_DISABLE;
4600 UG_INIT_EFL(ad->win_main, opt);
4602 struct ug_cbs cbs = { 0, };
4604 cbs.layout_cb = __ug_layout_cb;
4605 cbs.result_cb = __ug_result_cb;
4606 cbs.destroy_cb = __ug_destroy_cb;
4607 cbs.priv = (void *)data;
4610 if (ad->imageviewer_service)
4611 service_destroy(ad->imageviewer_service);
4613 service_create(&ad->imageviewer_service);
4615 if (ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
4616 if ((ad->exe_args->caller) && (strcmp(ad->exe_args->caller, "contacts") == 0)) {
4617 service_add_extra_data(ad->imageviewer_service, IMAGE_VIEWER_VIEW_MODE_KEY_NAME, "SETAS");
4618 service_add_extra_data(ad->imageviewer_service, IMAGE_VIEWER_SET_AS_TYPE, "CallerID");
4620 service_add_extra_data(ad->imageviewer_service, IMAGE_VIEWER_VIEW_MODE_KEY_NAME, "DISPLAY");
4622 } else if (ad->launching_mode == CAM_LAUNCHING_MODE_NORMAL) {
4623 service_add_extra_data(ad->imageviewer_service, IMAGE_VIEWER_VIEW_MODE_KEY_NAME, "CAMERA");
4625 service_add_extra_data(ad->imageviewer_service, IMAGE_VIEWER_FILE_PATH_KEY_NAME, file_path);
4627 switch (ad->rot_current) {
4628 case APP_DEVICE_ORIENTATION_0:
4629 elm_win_rotation_with_resize_set(ad->win_main, 0);
4631 case APP_DEVICE_ORIENTATION_270:
4632 case APP_DEVICE_ORIENTATION_180:
4634 case APP_DEVICE_ORIENTATION_90:
4635 elm_win_rotation_with_resize_set(ad->win_main, 90);
4641 /* Create UI gadget */
4642 ad->imageviewer_ug =
4643 ug_create(NULL, IMAGE_VIEWER_UG_NAME, UG_MODE_FULLVIEW,
4644 ad->imageviewer_service, &cbs);
4646 if (!ad->imageviewer_ug) {
4647 cam_critical(LOG_SYS, "image viewer UI Gadget create fail...");
4651 if (ad->imageviewer_ug) {
4652 cam_app_key_event_deinit(ad);
4653 if(!cam_key_grab_deinit(ad)){
4654 DEBUG_TRACE("cam_key_grab_deinit fail");
4656 cam_app_preview_stop();
4657 power_unlock_state(POWER_STATE_NORMAL);
4659 cam_warning(LOG_UI, "Cannot create imageviewer ug");
4660 cam_file_init(NULL);
4670 gboolean cam_app_run_media_browser(void *data, gchar *filename)
4672 cam_debug(LOG_UI, "filename = %s", filename);
4673 struct appdata *ad = (struct appdata *)data;
4674 CamAppData *camapp = NULL;
4677 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4678 camapp = ad->camapp_handle;
4679 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
4681 debug_fenter(LOG_UI);
4682 ad->launch_type = CAM_LAUNCH_IS_ALREADY_RUNNING;
4683 DEBUG_TRACE("ad->launch_type = %d", ad->launch_type);
4684 state = cam_mm_get_state();
4685 if (state > CAMERA_STATE_PREVIEW) {
4686 cam_warning(LOG_MM, "Invaild state : %d", state);
4689 toolbar_hide_setting_popup(ad);
4690 ad->foucs_out_from_quickview = FALSE;
4692 /* del mouse down event - image viewer bug */
4693 cam_app_mouse_event_deinit(ad);
4694 if (!cam_app_run_image_viewer_ug(ad, cam_app_get_last_filename())) {
4695 DEBUG_TRACE("cam_app_run_image_viewer_ug failed");
4696 cam_app_mouse_event_init(ad);
4700 if (camapp->thumbnail_name) { /* Some image is deleted from image viewer and galler -> BS */
4701 free(camapp->thumbnail_name);
4702 camapp->thumbnail_name = NULL;
4705 cam_app_timeout_checker_remove();
4709 gboolean cam_app_clear_engine_data(void *data, gboolean release)
4714 gboolean cam_app_check_wide_resolution(int id)
4717 gfloat get_value = (HIWORD(id) * 3.0) / (LOWORD(id) * 4.0);
4718 if (ABS(get_value - 1.0) < CAM_EPSINON
4719 || ABS((gfloat)((HIWORD(id) * 25.0) / (LOWORD(id) * 36.0)) - 1.0) < CAM_EPSINON) {
4727 gboolean cam_app_is_skip_video_stream()
4728 { /*if true , must finish function in stream callback function */
4729 return video_stream_skip_flag;
4732 void cam_app_stop_video_stream()
4734 video_stream_skip_flag = TRUE;
4737 void cam_app_run_video_stream()
4739 video_stream_skip_flag = FALSE;
4742 Eina_Bool _auto_shot_idle_cb(void *data)
4744 debug_fenter(LOG_CAM);
4745 struct appdata *ad = (struct appdata *)data;
4746 CamAppData *camapp = NULL;
4748 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4749 camapp = ad->camapp_handle;
4750 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
4752 if (ad->auto_shot_idle) {
4753 ecore_idler_del(ad->auto_shot_idle);
4754 ad->auto_shot_idle = NULL;
4757 debug_fleave(LOG_CAM);
4759 return ECORE_CALLBACK_CANCEL;
4762 gboolean cam_app_create_progressbar(void *data)
4764 struct appdata *ad = (struct appdata *)(data);
4765 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4767 cam_debug(LOG_UI, "");
4769 cam_app_destroy_progressbar(ad);
4771 ad->progressbar = elm_progressbar_add(ad->win_main);
4772 cam_retvm_if(ad->progressbar == NULL, FALSE,
4773 "Cannot create progressbar object\n");
4775 elm_object_style_set(ad->progressbar, "list_progress");
4776 evas_object_size_hint_align_set(ad->progressbar, EVAS_HINT_FILL,
4779 evas_object_show(ad->progressbar);
4784 gboolean cam_app_set_progressbar_value(void *data, double value)
4786 struct appdata *ad = (struct appdata *)(data);
4787 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4789 cam_debug(LOG_UI, " value [%f]", value);
4791 if (ad->progressbar)
4792 elm_progressbar_value_set(ad->progressbar, value);
4797 gboolean cam_app_set_progressbar_text(void *data, const char *text)
4799 struct appdata *ad = (struct appdata *)(data);
4800 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4802 cam_retv_if(text == NULL, FALSE);
4804 if (ad->progressbar_edje)
4805 edje_object_part_text_set(_EDJ(ad->progressbar_edje),
4806 "progressbar_text", text);
4811 gboolean cam_app_destroy_progressbar(void *data)
4813 struct appdata *ad = (struct appdata *)(data);
4814 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4816 cam_debug(LOG_UI, " start");
4817 if (ad->progressbar)
4818 DEL_EVAS_OBJECT(ad->progressbar);
4819 if (ad->progressbar_edje)
4820 DEL_EVAS_OBJECT(ad->progressbar_edje);
4822 cam_debug(LOG_UI, " done");
4829 cam_app_haptic_cb(void *data, Evas_Object *o, const char *emission,
4832 debug_fenter(LOG_UI);
4833 cam_devman_haptic_play(100);
4834 /* haptic_oneshot(100); */
4838 static gboolean cam_app_timeout_checker_update()
4840 struct appdata *ad = NULL;
4841 CamAppData *camapp = NULL;
4842 gdouble c_time = 0.0;
4843 cam_debug(LOG_UI, "");
4845 ad = (struct appdata *)cam_appdata_get();
4846 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4847 camapp = ad->camapp_handle;
4848 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
4850 if (ad->timeout_checker) {
4851 c_time = _get_current_time();
4852 ecore_timer_delay(ad->timeout_checker,
4853 (c_time - camapp->last_time));
4854 camapp->last_time = c_time;
4859 void cam_app_zoom_warring_popup(void *data, const char *msg,
4860 void (*func) (void *data, Evas_Object *obj, void *event_info))
4862 struct appdata *ad = (struct appdata *)(data);
4863 ad->zoom_warring_popup = elm_popup_add(ad->win_main);
4864 evas_object_size_hint_weight_set(ad->zoom_warring_popup, EVAS_HINT_EXPAND,
4866 elm_object_text_set(ad->zoom_warring_popup, msg);
4867 elm_popup_timeout_set(ad->zoom_warring_popup, 3.0);
4868 evas_object_smart_callback_add(ad->zoom_warring_popup, "timeout", func, data);
4869 evas_object_show(ad->zoom_warring_popup);
4871 void cam_app_mdm_syspopup(void *data){
4872 struct appdata *ad = (struct appdata *)(data);
4873 cam_retm_if(ad == NULL, " appdata is NULL");
4875 b = bundle_create();
4877 bundle_add(b, "_SYSPOPUP_CONTENT_", _("IDS_CAM_POP_SECURITY_POLICY_RESTRICTS_USE_OF_CAMERA"));
4878 syspopup_launch("mdm-syspopup", b);
4881 ecore_idler_add(cam_app_stop,ad);
4886 void cam_app_notice_popup(void *data, const char *msg,
4887 void (*func) (void *data,
4892 struct appdata *ad = (struct appdata *)(data);
4893 cam_retm_if(ad == NULL, " appdata is NULL");
4894 cam_retm_if(ad->win_main == NULL, " ad->win_main is NULL");
4895 Evas_Object *popup = NULL;
4896 popup = elm_popup_add(ad->win_main);
4899 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
4901 elm_object_text_set(popup, msg);
4902 /*elm_popup_mode_set(popup, ELM_POPUP_TYPE_ALERT);*/
4903 elm_popup_timeout_set(popup, 3.0);
4904 evas_object_smart_callback_add(popup, "timeout", func, data);
4905 ad->waring_popup = popup;
4906 evas_object_show(popup);
4908 void cam_app_snapshot_popup(void *data, const char *msg,
4909 void (*func) (void *data, Evas_Object *obj, void *event_info))
4911 struct appdata *ad = (struct appdata *)(data);
4912 cam_retm_if(ad == NULL, " appdata is NULL");
4913 cam_retm_if(ad->win_main == NULL, " ad->win_main is NULL");
4914 Evas_Object *popup = NULL;
4915 popup = elm_popup_add(ad->win_main);
4918 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
4920 elm_object_text_set(popup, msg);
4921 /*elm_popup_mode_set(popup, ELM_POPUP_TYPE_ALERT);*/
4922 elm_popup_timeout_set(popup, 1.5);
4923 evas_object_smart_callback_add(popup, "timeout", func, data);
4924 ad->is_showing_snapshot_popup = TRUE; /*result popup is showing*/
4925 DEBUG_TRACE("ad->is_showing_snapshot_popup = TRUE");
4926 evas_object_show(popup);
4929 static void cam_app_capture_error_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
4931 struct appdata *ad = (struct appdata *)cam_appdata_get();
4932 cam_retm_if(ad == NULL, " appdata is NULL");
4933 CamAppData *camapp = ad->camapp_handle;
4934 cam_retm_if(camapp == NULL, " camapp is NULL");
4936 evas_object_del(obj);
4938 cam_mm_capture_stop(FALSE, camapp->camera_mode);
4942 void cam_app_timeout_notice_response_cb(void *data, Evas_Object *obj,
4945 struct appdata *ad = (struct appdata *)cam_appdata_get();
4946 cam_retm_if(ad == NULL, " appdata is NULL");
4948 evas_object_del(obj);
4954 void cam_close_flash_feature(void *data)
4956 struct appdata *ad = (struct appdata *)data;
4957 cam_retm_if(ad == NULL, " appdata is NULL");
4958 CamAppData *camapp = ad->camapp_handle;
4959 cam_retm_if(camapp == NULL, " appdata is NULL");
4960 if (camapp->flash > CAM_FLASH_OFF) {
4961 GValue value = { 0 };
4962 CAM_GVALUE_SET_INT(value, CAM_FLASH_OFF);
4963 gint tempval = g_value_get_int(&value);
4964 if (!cam_mm_set_flash(tempval)) {
4965 cam_warning(LOG_UI, "flash set fail");
4968 camapp->flash = tempval;
4971 /*lowbattery callback*/
4972 void cam_app_lowbattery_close_flash_cb(void *data, Evas_Object *obj, void *event_info)
4974 struct appdata *ad = (struct appdata *)cam_appdata_get();
4975 cam_retm_if(ad == NULL, " appdata is NULL");
4977 evas_object_del(obj);
4979 cam_close_flash_feature(ad);
4981 cam_toolbar_update(ad);
4984 static void cam_app_auto_close_popup_response_ok_cb(void *data, Evas_Object *obj,
4988 struct appdata *ad = (struct appdata *)cam_appdata_get();
4989 cam_retm_if(ad == NULL, " appdata is NULL");
4991 if (ad->auto_close_timer) {
4992 ecore_timer_del(ad->auto_close_timer);
4993 ad->auto_close_timer = NULL;
4995 cam_app_timeout_checker_remove();
4996 if (ad->auto_close_popup)
4997 evas_object_del(ad->auto_close_popup);
4998 ad->auto_close_popup = NULL;
5003 static void cam_app_auto_close_popup_response_cancel_cb(void *data, Evas_Object *obj,
5007 struct appdata *ad = (struct appdata *)cam_appdata_get();
5008 cam_retm_if(ad == NULL, " appdata is NULL");
5009 if (ad->auto_close_timer) {
5010 ecore_timer_del(ad->auto_close_timer);
5011 ad->auto_close_timer = NULL;
5013 if (ad->auto_close_popup)
5014 evas_object_del(ad->auto_close_popup);
5015 ad->auto_close_popup = NULL;
5016 cam_app_timeout_checker_init(ad);
5019 void cam_app_auto_close_popup(void *data, const char *msg,
5020 void (*func) (void *data, Evas_Object *obj,
5023 struct appdata *ad = (struct appdata *)(data);
5024 cam_retm_if(ad == NULL, " appdata is NULL");
5025 if (ad->auto_close_popup) {
5026 evas_object_del(ad->auto_close_popup);
5027 ad->auto_close_popup = NULL;
5029 ad->auto_close_popup = elm_popup_add(ad->win_main);
5030 if (ad->auto_close_popup == NULL)
5032 evas_object_size_hint_weight_set(ad->auto_close_popup, EVAS_HINT_EXPAND,
5034 elm_popup_timeout_set(ad->auto_close_popup, 9.0);
5035 elm_object_text_set(ad->auto_close_popup, msg);
5036 Evas_Object *btn1 = elm_button_add(ad->auto_close_popup);
5038 evas_object_del(ad->auto_close_popup);
5039 ad->auto_close_popup = NULL;
5042 elm_object_text_set(btn1, dgettext("sys_string", "IDS_COM_SK_OK"));
5043 elm_object_part_content_set(ad->auto_close_popup, "button1", btn1);
5044 evas_object_smart_callback_add(btn1, "clicked", cam_app_auto_close_popup_response_ok_cb, (void*)ad);
5045 Evas_Object *btn2 = elm_button_add(ad->auto_close_popup);
5047 evas_object_del(ad->auto_close_popup);
5048 ad->auto_close_popup = NULL;
5052 elm_object_text_set(btn2, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
5053 elm_object_part_content_set(ad->auto_close_popup, "button2", btn2);
5054 evas_object_smart_callback_add(btn2, "clicked", cam_app_auto_close_popup_response_cancel_cb, (void*)ad);
5056 evas_object_show(ad->auto_close_popup);
5061 static Eina_Bool cam_app_auto_close_task(void *data)
5066 char *msg = _("IDS_CAM_POP_CLOSE_CAMERA_IN_PD_SECONDS");
5067 num = 1+ snprintf(NULL, 0, msg, AUTO_CLOSE_COUNT);
5068 DEBUG_TRACE("%d",num);
5069 str = (char *)malloc(num);
5071 memset(str, 0x00, num);
5072 snprintf(str, num, msg, AUTO_CLOSE_COUNT);
5073 DEBUG_TRACE("%s",str);
5074 cam_app_auto_close_popup(data, str, NULL);
5079 return ECORE_CALLBACK_CANCEL;
5083 static Eina_Bool cam_app_auto_close_timer_cb(void *data)
5085 struct appdata *ad = (struct appdata *)(data);
5086 CamAppData *camapp = NULL;
5090 cam_retvm_if(ad == NULL, 0, "appdata is NULL");
5091 camapp = ad->camapp_handle;
5092 cam_retvm_if(camapp == NULL, 0, "cam_handle is NULL");
5094 diff = _get_current_time() - camapp->last_time;
5096 ad->auto_close_count++;
5098 count = count - ad->auto_close_count;
5100 if ((cam_mm_get_state() == CAMERA_STATE_PREVIEW)
5101 && (diff >= CAMERA_APP_TIMEOUT + 10)) {
5103 "Quit camera application !!! diff time : [%lf]",
5105 cam_app_timeout_checker_remove();
5109 return ECORE_CALLBACK_CANCEL;
5111 cam_debug(LOG_UI, "####diff time : [%lf]", diff);
5117 static Eina_Bool cam_app_timeout_checker_cb(void *data)
5119 struct appdata *ad = (struct appdata *)(data);
5120 CamAppData *camapp = NULL;
5123 cam_retvm_if(ad == NULL, 0, "appdata is NULL");
5124 camapp = ad->camapp_handle;
5125 cam_retvm_if(camapp == NULL, 0, "cam_handle is NULL");
5127 diff = _get_current_time() - camapp->last_time;
5129 if ((cam_mm_get_state() == CAMERA_STATE_PREVIEW)
5130 && (diff >= CAMERA_APP_TIMEOUT)) {
5132 "auto close popup is closeed after 10 secondes !!! diff time : [%lf]",
5134 ad->auto_close_count = 0;
5135 ad->auto_close_timer =
5136 ecore_timer_add(1, cam_app_auto_close_timer_cb, ad);
5137 // ecore_idler_add(cam_app_auto_close_task, ad);
5140 cam_debug(LOG_UI, "diff time : [%lf]", diff);
5144 gboolean cam_app_timeout_checker_init(void *data)
5146 struct appdata *ad = (struct appdata *)(data);
5147 CamAppData *camapp = NULL;
5149 debug_fenter(LOG_CAM);
5151 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5152 camapp = ad->camapp_handle;
5153 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
5155 if (ad->timeout_checker) {
5156 ecore_timer_del(ad->timeout_checker);
5157 ad->timeout_checker = NULL;
5159 if (ad->auto_close_timer) {
5160 ecore_timer_del(ad->auto_close_timer);
5161 ad->auto_close_timer = NULL;
5163 if (ad->auto_close_popup) {
5164 evas_object_del(ad->auto_close_popup);
5165 ad->auto_close_popup = NULL;
5167 if (ad->timer_timer) {
5168 ad->timer_activated = false;
5169 DEL_EVAS_OBJECT(ad->timer_icon_edje);
5170 REMOVE_TIMER(ad->timer_timer);
5172 ad->timeout_checker =
5173 ecore_timer_add(CAMERA_APP_TIMEOUT / 2, cam_app_timeout_checker_cb,
5175 camapp->last_time = _get_current_time();
5180 gboolean cam_app_timeout_checker_remove(void)
5182 struct appdata *ad = NULL;
5183 CamAppData *camapp = NULL;
5185 debug_fenter(LOG_CAM);
5187 ad = (struct appdata *)cam_appdata_get();
5188 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5189 camapp = ad->camapp_handle;
5190 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
5192 if (ad->timeout_checker) {
5193 ecore_timer_del(ad->timeout_checker);
5194 ad->timeout_checker = NULL;
5196 camapp->last_time = 0;
5201 #ifdef USE_FIFO_THREAD
5202 void *cam_app_FIFO_thread_run(void *data)
5204 struct appdata *ad = (struct appdata *)data;
5208 char buf[128] = { '\0', };
5210 cam_retvm_if(ad == NULL, NULL, "appdata is NULL");
5212 if (!access(CAM_FIFO_PATH, F_OK)) {
5213 unlink(CAM_FIFO_PATH);
5216 if (-1 == mkfifo(CAM_FIFO_PATH, 0666)) {
5217 cam_critical(LOG_SYS, " Make CamApp FIFO failed.");
5221 fd = open(CAM_FIFO_PATH, O_RDWR);
5223 cam_critical(LOG_SYS, " Open CamApp FIFO failed.");
5227 cam_debug(LOG_SYS, "Open CamApp FIFO [%s] success", CAM_FIFO_PATH);
5230 memset(buf, 0x00, 128);
5232 cam_debug(LOG_SYS, " Wait CamApp FIFO write...");
5234 int count = read(fd, buf, 128);
5236 cam_debug(LOG_SYS, " read error occur!");
5238 cam_debug(LOG_SYS, " Read from CamApp FIFO : [%s]", buf);
5240 if (!strcmp(buf, CAM_CAPTURE_AUTO_START)) {
5241 cam_debug(LOG_SYS, " #### Start _auto_shot_idle_cb");
5242 _auto_shot_idle_cb(data);
5243 } else if (!strcmp(buf, CAM_FIFO_CMD_EXIT)) {
5247 cam_warning(LOG_SYS, " Skip this...");
5252 unlink(CAM_FIFO_PATH);
5254 cam_debug(LOG_SYS, " Exit CamApp FIFO thread...");
5259 void cam_app_FIFO_thread_exit()
5261 int fd = open(CAM_FIFO_PATH, O_WRONLY);
5262 char *str_write = CAM_FIFO_CMD_EXIT;
5265 cam_critical(LOG_SYS, " Open CammApp FIFO file[%s] failed",
5268 int count = write(fd, str_write, strlen(str_write));
5270 cam_debug(LOG_SYS, " write error occur! ");
5273 cam_debug(LOG_SYS, " Write [%s] to FIFO Done.", str_write);
5279 #ifdef USE_FILE_REG_THREAD
5281 gboolean cam_app_create_file_register_thread(void *data)
5283 struct appdata *ad = (struct appdata *)data;
5286 cam_debug(LOG_SYS, "");
5288 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5290 err = pthread_mutex_init(&(ad->file_reg_mutex), NULL);
5292 cam_critical(LOG_CAM,
5293 "Create Camera file register mutex failed");
5297 err = pthread_cond_init(&(ad->file_reg_cond), NULL);
5299 cam_critical(LOG_CAM,
5300 "Create Camera file register cond failed");
5304 ad->file_reg_queue = g_queue_new();
5305 if (ad->file_reg_queue == NULL) {
5306 cam_critical(LOG_CAM,
5307 "Create Camera file register queue failed");
5312 pthread_create(&(ad->file_reg_thread), NULL,
5313 cam_app_file_register_thread_run, (void *)ad);
5315 cam_critical(LOG_CAM,
5316 "Create Camera file register thread failed");
5323 void *cam_app_file_register_thread_run(void *data)
5325 struct appdata *ad = (struct appdata *)data;
5326 gboolean Exit_loop = FALSE;
5328 cam_debug(LOG_FILE, "");
5330 pthread_mutex_lock(&ad->file_reg_mutex);
5332 while (!Exit_loop) {
5333 cam_debug(LOG_FILE, " wait signal...");
5335 pthread_cond_wait(&ad->file_reg_cond, &ad->file_reg_mutex);
5337 cam_debug(LOG_FILE, " signal received");
5339 while (!g_queue_is_empty(ad->file_reg_queue)) {
5340 char *filename = NULL;
5341 filename = g_queue_pop_head(ad->file_reg_queue);
5343 if (!strcmp(REG_THREAD_EXIT, filename)) {
5348 __cam_single_shot_reg_file(filename);
5350 cam_debug(LOG_FILE, " register done.");
5355 pthread_mutex_unlock(&ad->file_reg_mutex);
5357 pthread_mutex_destroy(&ad->file_reg_mutex);
5358 pthread_cond_destroy(&ad->file_reg_cond);
5360 cam_debug(LOG_SYS, " thread exit...");
5365 void cam_app_file_register_thread_exit(void *data)
5367 struct appdata *ad = (struct appdata *)data;
5368 char *exit_cmd = NULL;
5370 if (ad->file_reg_queue != NULL) {
5371 exit_cmd = strdup(REG_THREAD_EXIT);
5372 g_queue_push_tail(ad->file_reg_queue, exit_cmd);
5373 pthread_cond_signal(&ad->file_reg_cond);
5378 gboolean cam_app_init_with_args(void *data)
5380 struct appdata *ad = (struct appdata *)data;
5381 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5382 cam_retvm_if(ad->camapp_handle == NULL, FALSE, "camapp is NULL");
5384 cam_debug(LOG_SYS, "");
5385 if (ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
5386 ad->camapp_handle->camera_mode = ad->exe_args->cam_mode;
5387 if (CAM_CAMCORDER_MODE == ad->camapp_handle->camera_mode) {
5388 if (ad->exe_args->resolution == CAM_RESOLUTION_QCIF) {
5389 ad->camapp_handle->recording_mode = CAM_RECORD_MMS;
5390 ad->camapp_handle->resolution = CAM_RESOLUTION_QCIF;
5391 ad->camapp_handle->fps = FPS_SLOW;
5392 if (ad->exe_args->size_limit <= 0) {
5393 ad->camapp_handle->size_limit = CAM_REC_MMS_MAX_SIZE;
5395 ad->camapp_handle->size_limit = ad->exe_args->size_limit;
5397 ad->camapp_handle->size_limit_type = CAM_MM_SIZE_LIMIT_TYPE_BYTE;
5399 ad->camapp_handle->recording_mode = CAM_RECORD_NORMAL;
5400 ad->camapp_handle->resolution = ad->exe_args->resolution;
5401 ad->camapp_handle->fps = FPS_DEFAULT;
5404 ad->camapp_handle->shooting_mode = CAM_SINGLE_MODE;
5405 if (ad->exe_args->width <= 0
5406 || ad->exe_args->height <= 0) {
5407 ad->camapp_handle->resolution = CAM_RESOLUTION_VGA;
5409 ad->camapp_handle->resolution = CAM_RESOLUTION(ad->exe_args->width, ad->exe_args->height);
5411 ad->camapp_handle->review = ad->exe_args->review;
5414 cam_debug(LOG_SYS, " camera launch mode is normal.");
5418 cam_debug(LOG_SYS, " done");
5423 Eina_Bool cam_app_focus_guide_create(void *data)
5425 struct appdata *ad = (struct appdata *)data;
5426 cam_retv_if(ad == NULL, EINA_FALSE);
5428 DEL_EVAS_OBJECT(ad->focus_edje);
5431 cam_app_load_edj(ad->layout_main, CAM_UTILS_EDJ_NAME, "focus_image");
5432 if (ad->focus_edje == NULL) {
5433 cam_critical(LOG_UI, "focus_edje load failed ");
5437 evas_object_resize(ad->focus_edje, ad->camera_focus_w, ad->camera_focus_h);
5438 DEBUG_TRACE("#######################################\n");
5439 DEBUG_TRACE(" MOVE FOCUS_EDJE : %f, %f", ad->af_start_x, ad->af_start_y);
5440 evas_object_move(ad->focus_edje, ad->af_start_x, ad->af_start_y);
5441 evas_object_show(ad->focus_edje);
5442 DEBUG_TRACE("#######################################\n");
5444 #ifdef CAMERA_MACHINE_I686
5445 evas_object_hide(ad->focus_edje);
5451 Eina_Bool cam_app_focus_guide_update(void *data)
5453 #ifndef CAMERA_MACHINE_I686
5454 struct appdata *ad = (struct appdata *)data;
5455 cam_retv_if(ad == NULL, EINA_FALSE);
5457 CamAppData *camapp = NULL;
5459 if (ad->focus_edje == NULL) {
5463 /*note: relocation the focus edje*/
5464 evas_object_resize(ad->focus_edje, ad->camera_focus_w, ad->camera_focus_h);
5465 evas_object_move(ad->focus_edje, ad->af_start_x, ad->af_start_y);
5466 evas_object_show(ad->focus_edje);
5468 if (ad->setting_ctxpopup
5469 || (ad->toolbar_show_setting_popup == TRUE)
5470 || (ad->toolbar_show_edit_shortcuts_popup == TRUE)) {
5471 cam_debug(LOG_UI, "do not need to update focus");
5472 edje_object_signal_emit(_EDJ(ad->focus_edje), "focus,hide", "program");
5476 camapp = ad->camapp_handle;
5477 if (camapp == NULL) {
5480 if (ad->mm_state == CAMERA_STATE_CAPTURING
5481 && camapp->camera_mode == CAM_CAMERA_MODE) {
5484 if (ad->mm_state < CAMERA_STATE_PREVIEW || FALSE) {
5485 edje_object_signal_emit(_EDJ(ad->focus_edje), "focus,hide", "program");
5488 DEBUG_TRACE("focus-state = %d, shooting-mode = %d", camapp->focus_state, camapp->shooting_mode);
5489 if (camapp->recording_mode == CAM_RECORD_SELF
5490 || camapp->recording_mode == CAM_RECORD_SELF_MMS
5491 || camapp->shooting_mode == CAM_SELF_MODE) {
5492 edje_object_signal_emit(_EDJ(ad->focus_edje), "focus,hide", "program");
5494 char signame[30] = { '\0', };
5495 const char *focus_state_name[4] = {
5502 snprintf(signame, sizeof(signame), "%s,%s", "focus", focus_state_name[camapp->focus_state]);
5504 cam_debug(LOG_UI, "emit signal : %s", signame);
5505 edje_object_signal_emit(_EDJ(ad->focus_edje), signame, "program");
5512 static int cam_app_state_manager(int previous, int current, gboolean by_asm)
5514 struct appdata *ad = NULL;
5515 CamAppData *camapp = NULL;
5517 cam_info(LOG_UI, "STATE_CHANGED : %d -> %d ", previous, current);
5519 ad = (struct appdata *)cam_appdata_get();
5520 cam_retv_if(ad == NULL, FALSE);
5522 camapp = ad->camapp_handle;
5523 cam_retv_if(camapp == NULL, FALSE);
5525 ad->mm_state = current;
5527 if (camapp->camera_mode == CAM_CAMERA_MODE) {
5528 if (current == CAMERA_STATE_PREVIEW) {
5529 if (previous == CAMERA_STATE_CAPTURING) {
5530 CAM_TA_ACUM_ITEM_END(" capture stop to preview", 0);
5531 CAM_TA_ACUM_ITEM_END("Total capture time", 0);
5532 cam_debug(LOG_MM, "capture end, preview start");
5536 if (previous == CAMERA_STATE_CREATED && current == CAMERA_STATE_PREVIEW) {
5537 cam_info(LOG_UI, "!!!!Preview Began");
5538 #ifndef CAMERA_MACHINE_I686
5539 if (ad->toolbar_setting_popup == NULL) {
5540 if ((camapp->shooting_mode == CAM_SELF_MODE)
5541 ||(camapp->recording_mode == CAM_RECORD_SELF)
5542 ||(camapp->recording_mode == CAM_RECORD_SELF_MMS) ) {
5543 DEBUG_TRACE("Not need to make setting menu");
5545 ecore_idler_add(cam_app_launch_after_preview_began, ad);
5550 } else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
5551 if (((previous == RECORDER_STATE_RECORDING)
5552 && (current != RECORDER_STATE_PAUSED))
5553 ||((previous == RECORDER_STATE_PAUSED)
5554 && (current != RECORDER_STATE_RECORDING))) {/*finished recording*/
5556 cam_info(LOG_UI, "Set gamma NORMAL");
5557 CamIdlerItem *item = NULL;
5558 item = (CamIdlerItem *)g_malloc(sizeof(CamIdlerItem));
5563 if (camapp->filename)
5564 free(camapp->filename);
5565 cam_mm_get_filename(&camapp->filename,0);/*file size not used,so set to 0*/
5566 cam_info(LOG_UI, "Recorded file name [%s] ", camapp->filename);
5569 item->data = (void*)ad;
5570 item->idler = ecore_idler_add(cam_video_capture_handle_idler, item);
5573 ad->capture_cb_list = g_list_append(ad->capture_cb_list, item->idler);
5575 cam_info(LOG_UI, "video capture idler add : %p ", item->idler);
5580 if (previous == RECORDER_STATE_CREATED && current == RECORDER_STATE_READY) {
5581 cam_info(LOG_UI, "!!!!Preview Began");
5582 #ifndef CAMERA_MACHINE_I686
5583 if (ad->toolbar_setting_popup == NULL) {
5584 if ((camapp->shooting_mode == CAM_SELF_MODE)
5585 ||(camapp->recording_mode == CAM_RECORD_SELF)
5586 ||(camapp->recording_mode == CAM_RECORD_SELF_MMS) ) {
5587 DEBUG_TRACE("Not need to make setting menu");
5589 ecore_idler_add(cam_app_launch_after_preview_began, ad);
5595 cam_app_focus_guide_update(ad);
5597 if (ad->main_pipe) {
5598 char *buffer = strdup("STATE_CHANGED");
5599 ecore_pipe_write(ad->main_pipe, buffer, strlen(buffer) + 1);
5606 gboolean cam_app_exit(void *data)
5609 struct appdata *ad = (struct appdata *)data;
5610 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5618 static void cam_mmc_state_change_cb(keynode_t *key, void *data)
5620 struct appdata *ad = (struct appdata *)data;
5621 CamAppData *camapp = NULL;
5622 int mmc_state = vconf_keynode_get_int(key);
5624 cam_retm_if(ad == NULL, "appdata is NULL");
5625 camapp = ad->camapp_handle;
5626 cam_retm_if(camapp == NULL, "camapp_handle is NULL");
5628 cam_debug(LOG_SYS, " start");
5630 if (mmc_state == VCONFKEY_SYSMAN_MMC_REMOVED
5631 && camapp->storage == CAM_STORAGE_EXTERNAL) {
5632 #ifdef USE_CAM_STORAGE_SETTING
5633 GValue value = { 0 };
5635 int mm_state = cam_mm_get_state();
5637 if ((mm_state == RECORDER_STATE_RECORDING
5638 || mm_state == RECORDER_STATE_PAUSED)
5639 &&camapp->camera_mode == CAM_CAMCORDER_MODE) {
5640 cam_video_record_cancel(ad);
5641 cam_app_notice_popup(ad,
5642 _("IDS_CAM_POP_REMOVE_MMC_RECORDING"),
5643 cam_app_popup_response_cb);
5645 #ifndef CAMERA_MACHINE_I686
5646 else if (mm_state != CAMERA_STATE_CAPTURING
5647 &&camapp->camera_mode == CAM_CAMERA_MODE) {
5648 if (cam_app_check_blocking_popup()) {
5649 cam_app_notice_popup(ad,
5650 _("IDS_CAM_POP_MEMORY_CARD_REMOVED"),
5651 cam_app_popup_response_cb);
5656 #ifdef USE_CAM_STORAGE_SETTING
5657 CAM_GVALUE_SET_INT(value, CAM_STORAGE_INTERNAL);
5658 cam_handle_value_set(ad, PROP_STORAGE, &value);
5660 cam_info(LOG_UI, "MMC card is removed");
5665 #ifdef CAMAPP_SIG_HANDLING
5667 * This function registers a user space signal handler for the signal SIGSEGV (Signal #11)
5671 static void cam_app_register_sigsegv(void)
5673 debug_fenter(LOG_SYS);
5675 /* cam_app_act.sa_flags = SA_SIGINFO | SA_NOCLDSTOP; */
5676 cam_app_act.sa_flags = SA_SIGINFO;
5677 cam_app_act.sa_handler = (void *)cam_app_sigsegv_handler;
5678 sigemptyset(&cam_app_act.sa_mask);
5680 #ifdef ENABLE_CHECK_CAM_STATUS
5681 sigaction(SIGALRM, &cam_app_act, &cam_app_act_old); /* register an action with a previous action */
5683 sigaction(SIGABRT, &cam_app_act, &cam_app_act_old);
5684 sigaction(SIGSEGV, &cam_app_act, &cam_app_act_old);
5685 sigaction(SIGILL, &cam_app_act, &cam_app_act_old);
5687 debug_fleave(LOG_SYS);
5691 cam_app_sigsegv_handler(int signal_no, siginfo_t *info, void *context)
5693 debug_fenter(LOG_SYS);
5695 cam_debug(LOG_SYS, "signal_no = %d", signal_no);
5697 if (signal_no == SIGALRM) { /* if alarm, check the camera status. */
5698 #ifdef ENABLE_CHECK_CAM_STATUS
5699 cam_app_check_status();
5700 alarm(CAM_CHECK_STATUS_INTERVAL_TIME);
5704 sigaction(signal_no, &cam_app_act_old, NULL); /* register the previous action */
5708 debug_fleave(LOG_SYS);
5713 gboolean cam_app_black_screen_show(void *data, int mode)
5715 struct appdata *ad = (struct appdata *)data;
5716 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5717 Evas_Coord witdh = 0, height = 0;
5719 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_black_screen_show", 0);
5721 cam_debug(LOG_UI, "~~~~~~~~~~~ mode :%d", mode);
5722 if (ad->black_screen) {
5723 evas_object_del(ad->black_screen);
5724 ad->black_screen = NULL;
5727 cam_app_load_edj(ad->win_main, CAM_MAIN_LAYOUT_EDJ_NAME,
5729 if (ad->black_screen == NULL) {
5730 cam_critical(LOG_UI, "black_screen load failed ");
5731 CAM_TA_ACUM_ITEM_END(" cam_app_black_screen_show",
5736 evas_object_geometry_get(ad->win_main, NULL, NULL, &witdh, &height);
5737 evas_object_resize(ad->black_screen, witdh, height);
5739 evas_object_raise(ad->black_screen);
5740 evas_object_show(ad->black_screen);
5741 evas_object_show(ad->win_main);
5742 evas_render(ad->evas);
5744 CAM_TA_ACUM_ITEM_END(" cam_app_black_screen_show", 0);
5748 gboolean cam_app_black_screen_hide(void *data)
5750 struct appdata *ad = (struct appdata *)data;
5751 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5752 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_black_screen_hide", 0);
5753 if (ad->black_screen) {
5754 evas_object_del(ad->black_screen);
5755 ad->black_screen = NULL;
5756 edje_file_cache_flush();
5758 /* evas_render(ad->evas); */
5759 CAM_TA_ACUM_ITEM_END(" cam_app_black_screen_hide", 0);
5763 #ifdef ENABLE_CAPTURE_ANIMATION
5765 static void __cam_app_shutter_animation_finished(void *data, Evas_Object *obj,
5766 const char *emission,
5769 cam_debug(LOG_MM, " __cam_app_shutter_animation_finished \n\n ");
5771 struct appdata *ad = (struct appdata *)data;
5773 DEL_EVAS_OBJECT(ad->shutter_screen);
5777 static gboolean cam_app_shutter_screen_show(void *data)
5779 struct appdata *ad = (struct appdata *)data;
5780 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5781 Evas_Coord witdh = 0, height = 0;
5783 char *group_name = "shutter_image";
5785 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_shutter_screen_show", 0);
5787 if (ad->shutter_screen) {
5788 evas_object_del(ad->shutter_screen);
5789 ad->shutter_screen = NULL;
5792 ad->shutter_screen =
5793 cam_app_load_edj(ad->win_main, CAM_MAIN_LAYOUT_EDJ_NAME,
5795 if (ad->shutter_screen == NULL) {
5796 cam_critical(LOG_UI, "shutter_screen load failed ");
5797 CAM_TA_ACUM_ITEM_END(" cam_app_shutter_screen_show", 0);
5801 evas_object_geometry_get(ad->win_main, NULL, NULL, &witdh, &height);
5802 evas_object_resize(ad->shutter_screen, witdh, height);
5803 /* evas_object_resize(ad->black_screen, ad->win_width, ad->win_height); */
5805 /*evas_object_lower(ad->shutter_screen);*/
5806 evas_object_show(ad->shutter_screen);
5807 evas_object_show(ad->win_main);
5808 /* evas_render(ad->evas); */
5810 edje_object_signal_emit(_EDJ(ad->shutter_screen), "start_animation",
5813 edje_object_signal_callback_add(_EDJ(ad->shutter_screen),
5814 "animation_finish", "*",
5815 __cam_app_shutter_animation_finished,
5818 /* ecore_timer_add(0.1, cam_app_shutter_timer_cb, ad); */
5820 CAM_TA_ACUM_ITEM_END(" cam_app_shutter_screen_show", 0);
5824 #ifdef ENABLE_CHECK_CAM_STATUS
5826 static void cam_app_check_status()
5828 cam_debug(LOG_SYS, "check status");
5830 #endif /* ENABLE_CHECK_CAM_STATUS */
5832 static int cam_app_preview_unlock(void *data)
5834 struct appdata *ad = (struct appdata *)data;
5835 CamAppData *camapp = NULL;
5836 cam_retv_if(ad == NULL, FALSE);
5838 camapp = ad->camapp_handle;
5839 if (camapp == NULL) {
5840 cam_critical(LOG_UI, "handle is NULL");
5844 elm_win_indicator_mode_set(ad->win_main, 0);
5849 static int cam_app_preview_lock(void *data)
5851 struct appdata *ad = (struct appdata *)data;
5854 cam_critical(LOG_UI, "handle is NULL");
5858 evas_object_hide(ad->timer_icon_edje);
5859 REMOVE_TIMER(ad->timer_timer);
5860 ad->timer_activated = false;
5861 DEL_EVAS_OBJECT(ad->timer_icon_edje);
5862 cam_app_timeout_checker_remove();
5863 if(!cam_key_grab_deinit(ad))
5864 DEBUG_TRACE("cam_key_grab_deinit fail");
5865 cam_app_key_event_deinit(ad);
5870 static void cam_idle_lockstate_change_cb(keynode_t *key, void *data)
5872 struct appdata *ad = (struct appdata *)data;
5873 CamAppData *camapp = NULL;
5875 int lock_state = vconf_keynode_get_int(key);
5876 cam_retm_if(ad == NULL, "appdata is NULL");
5877 camapp = ad->camapp_handle;
5878 cam_retm_if(camapp == NULL, "camapp_handle is NULL");
5880 cam_debug(LOG_SYS, "#################IDLE LOCK state changed : %d",
5882 cam_state = cam_mm_get_state();
5886 cam_app_preview_lock(ad);
5887 } else if (!lock_state) {
5889 cam_app_preview_unlock(ad);
5894 static void cam_usb_state_change_cb(keynode_t *key, void *data)
5896 struct appdata *ad = (struct appdata *)data;
5897 CamAppData *camapp = NULL;
5898 int usb_state = vconf_keynode_get_int(key);
5899 int mm_state = cam_mm_get_state();
5901 cam_retm_if(ad == NULL, "appdata is NULL");
5902 camapp = ad->camapp_handle;
5903 cam_retm_if(camapp == NULL, "camapp_handle is NULL");
5905 if (usb_state > VCONFKEY_SYSMAN_USB_DISCONNECTED
5906 && (mm_state == RECORDER_STATE_RECORDING
5907 || mm_state == RECORDER_STATE_PAUSED)
5908 &&camapp->camera_mode == CAM_CAMCORDER_MODE) {
5909 camapp->rec_stop_type = CAM_REC_STOP_USB_CONN;
5910 cam_video_record_stop(ad);
5915 #ifndef DISABLE_TOOLBAR_TOGGLE
5916 static Eina_Bool _cam_app_toolbar_toggle_timer(void *data)
5918 struct appdata *ad = (struct appdata *)data;
5922 if (ad->mm_state != CAMERA_STATE_PREVIEW) {
5926 ad->toolbar_hided = TRUE;
5927 cam_app_toggle_indicator(ad, TRUE);
5928 cam_app_toggle_toolbar(ad, TRUE);
5931 if (ad->toolbar_toggle_timer)
5932 ecore_timer_del(ad->toolbar_toggle_timer);
5933 ad->toolbar_toggle_timer = NULL;
5938 void cam_app_toggle_indicator(void *data, gboolean hide)
5940 #ifndef DISABLE_INDICATOR
5941 struct appdata *ad = (struct appdata *)data;
5943 cam_retm_if(ad == NULL, "appdata is NULL");
5945 if (ad->toolbar_toggle_timer) {
5946 REMOVE_TIMER(ad->toolbar_toggle_timer);
5949 indicator_toggle(ad, hide);
5954 void cam_app_toggle_toolbar(void *data, gboolean hide)
5956 #ifndef DISABLE_TOOLBAR_TOGGLE
5957 struct appdata *ad = (struct appdata *)data;
5959 cam_retm_if(ad == NULL, "appdata is NULL");
5961 if (ad->toolbar_toggle_timer) {
5962 REMOVE_TIMER(ad->toolbar_toggle_timer);
5966 /* toolbar_hide_all_popup(ad); */
5967 unload_settings_edje(ad);
5968 hide_toolbar_edje(ad);
5970 show_toolbar_edje(ad);
5977 cam_app_reset_settings_launch_cb(void *data, Evas_Object *obj, void *event_info)
5979 Evas_Object *notify = (Evas_Object *)data;
5980 GValue i_value = { 0, };
5981 GValue b_value = { 0, };
5982 struct appdata *ad = (struct appdata *)cam_appdata_get();
5983 CamAppData *camapp = NULL;
5985 cam_debug(LOG_CAM, "!!!!!!!!!cam_app_reset_settings_launch_cb");
5987 cam_retm_if(ad == NULL, " appdata is NULL");
5988 camapp = ad->camapp_handle;
5989 cam_retm_if(camapp == NULL, " cam_handle is NULL");
5991 cam_popup_remove(notify);
5992 hide_toolbar_edje(ad);
5994 cam_mm_preview_stop(camapp->camera_mode); /* stop preview */
5996 g_value_init(&i_value, G_TYPE_INT);
5997 g_value_init(&b_value, G_TYPE_BOOLEAN);
6001 g_value_set_int(&i_value, AF_DEFAULT);
6002 cam_handle_value_set(ad, PROP_AF_MODE, &i_value);
6005 g_value_set_int(&i_value, TIMER_DEFAULT);
6006 cam_handle_value_set(ad, PROP_TIMER, &i_value);
6009 g_value_set_int(&i_value, EFFECT_DEFAULT);
6010 cam_handle_value_set(ad, PROP_EFFECT, &i_value);
6013 g_value_set_int(&i_value, QUALITY_DEFAULT);
6014 cam_handle_value_set(ad, PROP_IMAGE_QUALITY, &i_value);
6017 g_value_set_int(&i_value, QUALITY_DEFAULT);
6018 cam_handle_value_set(ad, PROP_VIDEO_QUALITY, &i_value);
6021 g_value_set_boolean(&b_value, FALSE);
6022 cam_handle_value_set(ad, PROP_GUIDELINE, &b_value);
6023 #ifdef GUIDE_LINE_ENALBE
6024 settings_guideline_refresh(ad);
6027 g_value_set_boolean(&b_value, FALSE);
6028 cam_handle_value_set(ad, PROP_REVIEW, &b_value);
6031 g_value_set_int(&i_value, SHUTTER_SOUND_DEFAULT);
6032 cam_handle_value_set(ad, PROP_SHUTTER_SOUND, &i_value);
6034 /* audio recording */
6035 g_value_set_boolean(&b_value, TRUE);
6036 cam_handle_value_set(ad, PROP_AUDIO_REC, &b_value);
6039 g_value_set_int(&i_value, STORAGE_DEFAULT);
6040 cam_handle_value_set(ad, PROP_STORAGE, &i_value);
6043 if (camapp->camera_mode == CAM_CAMERA_MODE) {
6044 g_value_set_int(&i_value, IMAGE_RESOLUTION_DEFAULT);
6046 g_value_set_int(&i_value, REC_RESOLUTION_DEFAULT);
6049 cam_handle_value_set(ad, PROP_RESOLUTION, &i_value);
6050 #ifndef DISABLE_INDICATOR
6051 if (ad->indicator_edje) {
6052 /* delete indicator */
6053 evas_object_hide(ad->indicator_edje);
6054 cam_indicator_destory(ad);
6056 cam_indicator_create(ad);
6058 show_toolbar_edje(ad);
6059 cam_app_preview_start(ad);
6062 void cam_app_reset_settings(void *data)
6064 struct appdata *ad = (struct appdata *)data;
6065 cam_retm_if(ad == NULL, "appdata is NULL");
6066 cam_popup_question_add(ad->win_main,
6067 _("IDS_CAM_POP_RESET_CAMERA_SETTINGS"),
6068 dgettext("sys_string", "IDS_COM_SK_YES"),
6069 cam_app_reset_settings_launch_cb,
6070 dgettext("sys_string", "IDS_COM_SK_NO"),
6075 static gboolean __cam_toolbar_new_thumbnail_create(Evas_Object **obj,
6077 Evas_Coord *thumbnail_x,
6078 Evas_Coord *thumbnail_y,
6079 Evas_Coord *thumbnail_w,
6080 Evas_Coord *thumbnail_h)
6082 cam_retv_if(ad == NULL, FALSE);
6083 CamAppData *camapp = ad->camapp_handle;
6084 cam_retv_if(camapp == NULL, FALSE);
6085 cam_retv_if(obj == NULL, FALSE);
6086 cam_retv_if(ad->evas == NULL, FALSE);
6087 cam_retv_if(ad->toolbar.quickview_item.edje == NULL, FALSE);
6089 if(camapp->thumbnail_name == NULL) {
6093 Evas_Object *new_thumbnail_img = elm_icon_add(ad->toolbar.quickview_item.edje);
6094 Evas_Coord x = 0, y = 0, w = 0, h = 0;
6095 Evas_Object *layout = NULL;
6096 Evas_Object *thumbnail_area = NULL;
6098 cam_retv_if(new_thumbnail_img == NULL, FALSE);
6099 elm_icon_file_set(new_thumbnail_img, camapp->thumbnail_name, NULL);
6100 elm_icon_aspect_fixed_set(new_thumbnail_img, EINA_FALSE);
6101 elm_icon_resizable_set(new_thumbnail_img, EINA_TRUE, EINA_TRUE);
6103 layout = elm_layout_edje_get(ad->toolbar.quickview_item.edje);
6104 thumbnail_area = (Evas_Object *) edje_object_part_object_get(layout,"thumbnail_area");
6105 cam_retv_if(thumbnail_area == NULL, FALSE);
6106 evas_object_geometry_get(thumbnail_area, &x, &y, &w, &h);
6112 evas_object_resize(new_thumbnail_img, 0, 0);
6113 evas_object_move(new_thumbnail_img, x, y);
6114 evas_object_show(new_thumbnail_img);
6115 *obj = new_thumbnail_img;
6119 static void cam_app_pipe_handler(void *data, void *buffer, unsigned int nbyte)
6122 struct appdata *ad = (struct appdata *)data;
6123 cam_retm_if(ad == NULL, "appdata is NULL");
6127 /* DO NOT free buffer in here */
6128 /* buffer is freed by ecore */
6130 int main_pipe_type = *((int *)buffer);
6131 DEBUG_TRACE("main_pipe_type %d", main_pipe_type);
6132 switch (main_pipe_type) {
6133 case CAM_MAIN_PIPE_OP_TYPE_UPDATE_THUMBNAIL: {
6134 Evas_Object *new_thumbnail_image = NULL;
6135 Evas_Coord x = 0, y = 0, w = 0, h = 0;
6136 gboolean ret = FALSE;
6137 ret = __cam_toolbar_new_thumbnail_create(&new_thumbnail_image, ad, &x, &y, &w, &h);
6138 if (ret == FALSE || !new_thumbnail_image) {
6139 if (!new_thumbnail_image && ret) {
6140 DEL_EVAS_OBJECT(ad->toolbar.quickview_item.thumbnail_image);
6144 cam_ui_effect_utils_set_thumbnail_effect(new_thumbnail_image,
6149 CAM_THUMBNAIL_ANTIMATION_EFFECT_DURATION);
6152 case CAM_MAIN_PIPE_OP_TYPE_ROTATE_ANIMATOR: {
6153 ad->is_rotating = TRUE;
6154 cam_ui_rotate_utils_rotate_start(ad, CAM_ROTATE_ICONS_ANTIMATION_DURATION);
6165 void cam_focus_edje_rotate(void *data)
6167 struct appdata *ad = (struct appdata *)data;
6168 cam_retm_if(ad == NULL, "appdata is NULL");
6170 DEL_EVAS_OBJECT(ad->focus_edje);
6171 ad->focus_edje = cam_app_load_edj(ad->layout_main, CAM_UTILS_EDJ_NAME, "focus_image");
6173 cam_retm_if(ad->focus_edje == NULL, "focus_edje load failed");
6175 evas_object_resize(ad->focus_edje, ad->camera_focus_w, ad->camera_focus_h);
6176 evas_object_move(ad->focus_edje, ad->af_start_x, ad->af_start_y);
6177 evas_object_show(ad->focus_edje);
6179 cam_app_draw_af_box(ad);
6180 cam_app_focus_guide_update(ad);
6184 Eina_Bool cam_screen_rotate(void *data)
6186 struct appdata *ad = (struct appdata *)data;
6187 cam_retvm_if(ad == NULL, -1, "appdata is NULL");
6189 /*cam_app_get_preview_offset_coordinate(ad);*/
6192 cam_focus_edje_rotate(ad);
6194 if (ad->timer_icon_edje)
6195 cam_app_timer_icon_rotate(ad);
6197 if (ad->toolbar_edje)
6198 cam_toolbar_rotate(ad);
6200 if (ad->recording_edje)
6201 cam_recording_rotate(ad);
6203 if (ad->indicator_edje) {
6204 cam_debug(LOG_CAM, "indicator_edje rotate start");
6205 cam_indicator_rotate(ad);
6208 if (ad->zoom_edje) {
6209 unload_zoom_edje(ad);
6213 #ifdef GUIDE_LINE_ENALBE
6214 if (ad->guideline_edje)
6215 settings_guideline_refresh(ad);
6218 /*update thumbnail*/
6219 toolbar_update_quickview_thumbnail_no_animation(ad);
6221 if ((ad->show_menu == TRUE ) ||
6222 (ad->show_menu == FALSE && ad->displayed_setting_popup != DISPLAY_NONE_POPUP )
6223 || (ad->toolbar_show_edit_shortcuts_popup == TRUE)
6224 || (ad->toolbar_show_setting_popup == TRUE)) {
6225 /*ecore_idler_add(cam_show_setting_menu, ad);*/
6226 /*note: use timer to delay creating the popup*/
6227 ecore_timer_add(0.1, cam_show_setting_menu, ad);
6229 ad->is_rotating = FALSE;
6232 return ECORE_CALLBACK_CANCEL;
6235 static Ecore_Idler *rotate_delay_idler = NULL;
6236 Eina_Bool cam_app_screen_rotate_idler(void *data)
6238 if (rotate_delay_idler) {
6239 ecore_idler_del(rotate_delay_idler);
6240 rotate_delay_idler = NULL;
6242 struct appdata *ad = (struct appdata *)data;
6243 cam_retv_if(ad == NULL, ECORE_CALLBACK_CANCEL);
6244 if (ad->appcore_state == CAM_APPCORE_TERMINATE_STATE
6245 || ad->appcore_state == CAM_APPCORE_PAUSE_STATE) {
6246 ad->is_rotating = FALSE;
6247 return ECORE_CALLBACK_CANCEL;
6249 /*cam_toolbar_rotate(ad);*/
6250 cam_screen_rotate(ad);
6251 return ECORE_CALLBACK_CANCEL;
6254 void cam_app_screen_rotate(void *data)
6256 struct appdata *ad = (struct appdata *)data;
6257 cam_ret_if(ad == NULL);
6258 if (ad->appcore_state == CAM_APPCORE_TERMINATE_STATE
6259 || ad->appcore_state == CAM_APPCORE_PAUSE_STATE) {
6260 ad->is_rotating = FALSE;
6263 CamAppData *cam_handle = ad->camapp_handle;
6264 cam_ret_if(cam_handle == NULL);
6267 if (ad->toolbar_edje) {
6268 rotate_delay_idler = ecore_idler_add(cam_app_screen_rotate_idler, data);
6271 /*cam_app_get_preview_offset_coordinate(ad);*/
6274 gboolean cam_app_get_resolution(int *width, int *height)
6276 cam_retv_if(width == NULL || height == NULL, FALSE);
6278 struct appdata *ad = (struct appdata *)cam_appdata_get();
6279 cam_retvm_if(ad == NULL, FALSE, "ad is NULL");
6282 CamAppData *camapp = ad->camapp_handle;
6284 if (camapp != NULL) {
6285 *width = CAM_RESOLUTION_W(camapp->resolution);
6286 *height = CAM_RESOLUTION_H(camapp->resolution);
6295 gboolean cam_app_reset_resolution(void *data, int width, int height)
6297 struct appdata *ad = (struct appdata *)data;
6298 CamAppData *camapp = NULL;
6300 gboolean need_change_state = FALSE;
6301 gboolean ret = TRUE;
6303 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
6304 camapp = ad->camapp_handle;
6305 cam_retvm_if(camapp == NULL, FALSE, "camapp is NULL");
6307 state = cam_mm_get_state();
6308 if (state > CAMERA_STATE_CREATED)
6309 need_change_state = TRUE;
6312 " reset resolution = [%d x %d], current state = [%d], need_change_state = [%d]",
6313 width, height, state, need_change_state);
6315 if (camapp->camera_mode == CAM_CAMERA_MODE) {
6317 if (camapp->shooting_mode == CAM_SINGLE_MODE
6318 && (width * height == ZSL_5M_TEST))
6320 if (0) /* camapp->shooting_mode == CAM_SINGLE_MODE && (width*height <= ZSL_MAX_REL)) */
6323 cam_info(LOG_MM, " set real resolution [%dx%d] for zsl",
6326 ret &= cam_mm_set_image_size(width, height);
6328 if (need_change_state) {
6329 ret &= cam_mm_preview_stop(camapp->camera_mode);
6330 ret &= cam_mm_unrealize();
6331 ret &= cam_mm_set_video_size(width, height);
6332 ret &= cam_mm_realize();
6333 ret &= cam_app_preview_start(ad);
6335 ret &= cam_mm_set_video_size(width, height);
6338 if (camapp->shooting_mode == CAM_SELF_MODE) {
6339 if (need_change_state) {
6340 ret &= cam_mm_preview_stop(CAM_CAMERA_MODE);
6341 ret &= cam_mm_set_image_size(width, height);
6342 ret &= cam_mm_set_video_size(width, height);
6343 ret &= cam_app_preview_start(ad);
6345 ret &= cam_mm_set_image_size(width, height);
6346 ret &= cam_mm_set_video_size(width, height);
6349 int p_width = 0; /* preview width */
6350 int p_height = 0; /* preview height */
6352 ret &= cam_mm_get_video_size(&p_width, &p_height);
6353 DEBUG_TRACE("get video size [%d]x[%d]", p_width,
6355 if (p_height == camapp->default_preview_height && (p_width == camapp->default_preview_width || p_width == PREVIEW_WIDE_W)) {
6356 /* assume that last mode is normal capture mode */
6359 int temp_width = camapp->default_preview_width;
6360 int temp_height = camapp->default_preview_height;
6361 gboolean cur_is_wide = FALSE;
6362 gboolean next_is_wide = FALSE;
6364 ret &= cam_mm_get_image_size(&cur_width, &cur_height);
6365 cur_is_wide = cam_utils_check_wide_resolution(cur_width, cur_height);
6367 "current image Resolution[w] : [%d]x[%d][%d]",
6368 cur_width, cur_height,
6371 next_is_wide = cam_utils_check_wide_resolution(width, height);
6373 "next image Resolution[w] : [%d]x[%d][%d]",
6374 width, height, next_is_wide);
6377 temp_width = PREVIEW_WIDE_W;
6379 ret &= cam_mm_set_image_size(width, height);
6381 if ((cur_is_wide != next_is_wide)
6382 || (temp_width != p_width)) {
6383 if (need_change_state) {
6385 ret &= cam_mm_preview_stop(camapp->camera_mode);
6386 ret &= cam_mm_set_video_size(temp_width, temp_height);
6387 ret &= cam_app_preview_start(ad);
6389 ret &= cam_mm_set_video_size(temp_width, temp_height);
6393 /* assume that last mode is zero system lag capture mode */
6394 int temp_width = camapp->default_preview_width;
6395 int temp_height = camapp->default_preview_height;
6396 #ifdef CAMERA_MACHINE_I686
6400 if (cam_utils_check_wide_resolution(width, height))
6401 temp_width = PREVIEW_WIDE_W;
6403 ret &= cam_mm_set_image_size(width, height);
6405 if (need_change_state) {
6406 ret &= cam_mm_preview_stop(camapp->camera_mode);
6407 ret &= cam_mm_set_video_size(temp_width, temp_height);
6408 ret &= cam_app_preview_start(ad);
6411 cam_mm_set_video_size(temp_width, temp_height);
6416 } else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
6417 if (need_change_state) {
6418 ret &= cam_mm_preview_stop(CAM_CAMCORDER_MODE);
6419 ret &= cam_mm_set_video_size(width, height);
6420 ret &= cam_app_preview_start(ad);
6422 ret &= cam_mm_set_video_size(width, height);
6430 int cam_app_get_aenc_bitrate(void *data)
6432 struct appdata *ad = (struct appdata *)data;
6433 CamAppData *camapp = NULL;
6436 cam_retvm_if(ad == NULL, 0, "appdata is NULL");
6437 camapp = ad->camapp_handle;
6438 cam_retvm_if(camapp == NULL, 0, "camapp is NULL");
6440 if ((camapp->recording_mode == CAM_RECORD_MMS) ||(camapp->recording_mode == CAM_RECORD_SELF_MMS)) {
6441 bitrate = CAM_AUDIO_BITRATE_MMS;
6443 bitrate = CAM_AUDIO_BITRATE_NORMAL;
6449 int cam_app_get_venc_bitrate(void *data, int quality)
6451 struct appdata *ad = (struct appdata *)data;
6452 CamAppData *camapp = NULL;
6455 cam_retvm_if(ad == NULL, 0, "appdata is NULL");
6456 camapp = ad->camapp_handle;
6457 cam_retvm_if(camapp == NULL, 0, "camapp is NULL");
6459 if ((camapp->recording_mode == CAM_RECORD_MMS) ||(camapp->recording_mode == CAM_RECORD_SELF_MMS)) {
6461 case CAM_QUALITY_HIGH:
6462 case CAM_QUALITY_BEST:
6466 case CAM_QUALITY_MEDIUM:
6470 case CAM_QUALITY_LOW:
6475 cam_critical(LOG_MM, "INVALID QUAILTY");
6479 switch (camapp->resolution) {
6480 case CAM_RESOLUTION_FULLHD:
6483 case CAM_QUALITY_HIGH:
6484 case CAM_QUALITY_BEST:
6485 return_val = 8000000;
6488 case CAM_QUALITY_MEDIUM:
6489 return_val = 4000000;
6492 case CAM_QUALITY_LOW:
6493 return_val = 2000000;
6497 cam_critical(LOG_MM, "INVALID QUAILTY");
6502 case CAM_RESOLUTION_HD:
6505 case CAM_QUALITY_HIGH:
6506 case CAM_QUALITY_BEST:
6507 return_val = 10000000;
6510 case CAM_QUALITY_MEDIUM:
6511 return_val = 4000000;
6514 case CAM_QUALITY_LOW:
6515 return_val = 2000000;
6519 cam_critical(LOG_MM, "INVALID QUAILTY");
6525 case CAM_RESOLUTION_WVGA:
6526 case CAM_RESOLUTION_WVGA2:
6529 case CAM_QUALITY_HIGH:
6530 case CAM_QUALITY_BEST:
6531 return_val = 4000000;
6534 case CAM_QUALITY_MEDIUM:
6535 return_val = 2000000;
6538 case CAM_QUALITY_LOW:
6539 return_val = 1000000;
6543 cam_critical(LOG_MM, "INVALID QUAILTY");
6549 case CAM_RESOLUTION_VGA:
6553 case CAM_QUALITY_HIGH:
6554 case CAM_QUALITY_BEST:
6555 return_val = 3000000;
6558 case CAM_QUALITY_MEDIUM:
6559 return_val = 1500000;
6562 case CAM_QUALITY_LOW:
6563 return_val = 500000;
6567 cam_critical(LOG_MM, "INVALID QUAILTY");
6573 case CAM_RESOLUTION_WQVGA:
6576 case CAM_QUALITY_HIGH:
6577 case CAM_QUALITY_BEST:
6578 return_val = 2000000;
6581 case CAM_QUALITY_MEDIUM:
6582 return_val = 1000000;
6585 case CAM_QUALITY_LOW:
6586 return_val = 500000;
6590 cam_critical(LOG_MM, "INVALID QUAILTY");
6596 case CAM_RESOLUTION_QVGA:
6599 case CAM_QUALITY_HIGH:
6600 case CAM_QUALITY_BEST:
6601 return_val = 384000;
6604 case CAM_QUALITY_MEDIUM:
6605 return_val = 192000;
6608 case CAM_QUALITY_LOW:
6613 cam_critical(LOG_MM, "INVALID QUAILTY");
6619 case CAM_RESOLUTION_QCIF:
6622 case CAM_QUALITY_HIGH:
6623 case CAM_QUALITY_BEST:
6624 return_val = 384000;
6627 case CAM_QUALITY_MEDIUM:
6628 return_val = 192000;
6631 case CAM_QUALITY_LOW:
6636 cam_critical(LOG_MM, "INVALID QUAILTY");
6643 cam_critical(LOG_MM, "INVALID QUAILTY");
6648 cam_debug(LOG_MM, "videoenc bit rate = %d, current quilty = %d",
6649 return_val, quality);
6653 gboolean cam_app_set_video_quality(void *data, int quality)
6655 struct appdata *ad = (struct appdata *)data;
6656 CamAppData *camapp = NULL;
6659 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
6660 camapp = ad->camapp_handle;
6661 cam_retvm_if(camapp == NULL, FALSE, "camapp is NULL");
6663 v_bitrate = cam_app_get_venc_bitrate(ad, quality);
6664 if (v_bitrate > 0) {
6665 cam_mm_set_video_encoder_bitrate(v_bitrate);
6672 /*TODO:temporily define this*/
6673 #define AUDIO_FORMAT_PCM_S16_LE 2
6674 #define AUDIO_CODEC_VORBIS 36
6675 #define VIDEO_CODEC_THEORA 27
6677 gboolean cam_app_set_recording_mode(void *data, int mode)
6679 struct appdata *ad = (struct appdata *)data;
6680 CamAppData *camapp = NULL;
6681 int video_codec = 0, audio_codec = 0, sample_rate = 0;
6682 int format = AUDIO_FORMAT_PCM_S16_LE;
6686 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
6687 camapp = ad->camapp_handle;
6688 cam_retvm_if(camapp == NULL, FALSE, "camapp is NULL");
6689 DEBUG_TRACE("mode = %d" , mode);
6690 if (mode == CAM_RECORD_MMS || mode == CAM_RECORD_SELF_MMS) {
6691 DEBUG_TRACE("mode = %d" , mode);
6692 video_codec = RECORDER_VIDEO_CODEC_H263;
6693 audio_codec = RECORDER_AUDIO_CODEC_AMR;
6695 format = AUDIO_FORMAT_PCM_S16_LE;
6698 DEBUG_TRACE("mode = %d" , mode);
6699 video_codec = RECORDER_VIDEO_CODEC_MPEG4;
6700 audio_codec = RECORDER_AUDIO_CODEC_AAC;
6701 sample_rate = 44100;
6702 format = AUDIO_FORMAT_PCM_S16_LE;
6705 #ifdef CAMERA_MACHINE_I686
6706 video_codec = VIDEO_CODEC_THEORA;
6707 audio_codec = AUDIO_CODEC_VORBIS;
6710 if (!cam_mm_set_codec(audio_codec, video_codec))
6713 if (!cam_mm_set_audio_source(sample_rate, format, channel))
6716 a_bitrate = cam_app_get_aenc_bitrate(ad);
6717 if (a_bitrate > 0) {
6718 cam_mm_set_audio_encoder_bitrate(a_bitrate);
6723 if (!cam_app_set_video_quality(ad, camapp->video_quality))
6729 gboolean cam_app_set_size_limit(int max_val, int size_limit_type)
6733 switch (size_limit_type) {
6734 case CAM_MM_SIZE_LIMIT_TYPE_BYTE:
6735 ret = cam_mm_set_max_size(max_val);
6739 case CAM_MM_SIZE_LIMIT_TYPE_SECOND:
6740 ret = cam_mm_set_max_size(0);
6745 g_assert_not_reached();
6750 gboolean cam_app_init_attribute(void *data, CamMode mode)
6752 struct appdata *ad = (struct appdata *)data;
6753 CamAppData *camapp = NULL;
6754 gboolean ret = TRUE;
6758 int rotate = CAMERA_ROTATION_270;
6759 int camera_rotate = CAMERA_ROTATION_NONE;
6761 int capture_video_format = -1;
6762 #ifdef TODO_SURRPORT
6763 int recording_video_format = -1;
6766 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
6767 camapp = ad->camapp_handle;
6768 cam_retvm_if(camapp == NULL, FALSE, "camapp is NULL");
6770 state = cam_mm_get_state();
6772 if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
6773 if (state != RECORDER_STATE_CREATED) {
6776 } else if(camapp->camera_mode == CAM_CAMERA_MODE) {
6777 if (state != CAMERA_STATE_CREATED) {
6782 cam_mm_get_video_size( &camapp->default_preview_width, &camapp->default_preview_height);
6783 DEBUG_TRACE("default_width = %d,default_height = %d", camapp->default_preview_width, camapp->default_preview_height);
6785 if (ad->launching_mode == CAM_LAUNCHING_MODE_NORMAL) {
6786 /* get proper resolution */
6787 cam_mm_get_image_size(&width, &height);
6788 if (camapp->camera_mode == CAM_CAMERA_MODE) {
6789 camapp->resolution = CAM_RESOLUTION(width, height);
6792 width = CAM_RESOLUTION_W(camapp->resolution);
6793 height = CAM_RESOLUTION_H(camapp->resolution);
6795 #ifdef CAMERA_MACHINE_I686
6800 if (CAM_CAMERA_MODE == mode) {
6801 ret &= cam_mm_set_image_size(width, height);
6802 ret &= cam_mm_set_image_count(camapp->image_count);
6803 #ifdef CAMERA_MACHINE_I686
6804 ret &= cam_mm_set_fps(CAMERA_ATTR_FPS_15);
6805 ret &= cam_mm_set_video_source_format(CAMERA_PIXEL_FORMAT_I420);
6807 ret &= cam_mm_set_fps(CAMERA_ATTR_FPS_AUTO);
6809 cam_mm_get_video_source_format
6811 &capture_video_format);
6812 ret &= cam_mm_set_video_source_format(capture_video_format);
6815 cam_app_set_capture_format_shooting_mode
6816 (camapp->shooting_mode);
6818 } else if (CAM_CAMCORDER_MODE == mode) {
6819 ret &= cam_mm_set_video_profile();
6820 #ifdef CAMERA_MACHINE_I686
6821 ret &= cam_mm_set_fps(CAMERA_ATTR_FPS_15);
6822 ret &= cam_mm_set_video_source_format(CAMERA_PIXEL_FORMAT_I420);
6824 ret &= cam_mm_set_fps(camapp->fps);
6825 ret &= cam_mm_get_video_source_format(NULL, &recording_video_format);
6826 ret &= cam_mm_set_video_source_format(recording_video_format);
6828 ret &= cam_mm_set_audio_recording(camapp->audio_recording);
6829 ret &= cam_app_set_recording_mode(ad, camapp->recording_mode);
6830 DEBUG_TRACE("camapp->size_limit = %d" , camapp->size_limit);
6831 DEBUG_TRACE("camapp->size_limit_type = %d" , camapp->size_limit_type);
6832 ret &= cam_app_set_size_limit(camapp->size_limit, camapp->size_limit_type);
6836 cam_mm_get_video_device(&video_dev);
6837 DEBUG_TRACE("video_dev = %d",video_dev);
6838 if (video_dev == CAM_DEVICE_VGA) {
6840 cam_mm_get_front_cam_display_rotate_value(&value, &rotate);
6842 DEBUG_TRACE("get front camera rotate %d value = %d", rotate, value);
6844 #ifdef TODO_SURRPORT
6845 rotate = CAMERA_ROTATION_270;
6846 #endif /*TODO:if new capi will released, this could be removed,but take care.*/
6849 cam_mm_get_zoom_valid_intrange(&camapp->zoom_min,&camapp->zoom_max);
6850 DEBUG_TRACE("Zoom range [%d - %d]",camapp->zoom_min, camapp->zoom_max);
6852 ret &= cam_mm_set_display_device(CAMERA_DISPLAY_TYPE_X11, GET_DISPLAY(ad->main_xid));
6853 ret &= cam_mm_set_camera_rotate(camera_rotate);
6854 ret &= cam_mm_set_display_rotate(rotate);
6855 ret &= cam_mm_set_display_geometry_method(CAMERA_DISPLAY_MODE_LETTER_BOX);
6856 #ifndef USE_CAMERA_APP_SHUTTER_SOUND
6857 ret &= cam_mm_set_shutter_sound(TRUE);
6859 ret &= cam_app_reset_resolution(ad, width, height);
6860 ret &= cam_mm_set_zoom(camapp->zoom_min);
6861 ret &= cam_mm_set_effect(camapp->effect);
6862 ret &= cam_mm_set_flash(camapp->flash);
6863 if (camapp->af_mode == CAM_FOCUS_AUTO
6864 || camapp->af_mode == CAM_FOCUS_MACRO) {
6865 ret &= cam_mm_set_focus_mode(camapp->af_mode);
6868 ret &= cam_mm_set_tag_enable(TRUE);
6870 ad->enable_mode_change = TRUE;
6871 ad->is_recording = FALSE;
6876 static gboolean cam_app_return_ext_app(void *data, const char *r_file_path)
6878 struct appdata *ad = (struct appdata *)data;
6880 service_create(&reply);
6882 if (ad->aul_service_mime != NULL){
6883 if(r_file_path == NULL){
6884 service_add_extra_data(reply, SERVICE_DATA_SELECTED, "exit");
6885 service_reply_to_launch_request(reply, ad->service_handle, SERVICE_RESULT_FAILED);
6887 service_add_extra_data(reply, SERVICE_DATA_SELECTED, r_file_path);
6888 service_reply_to_launch_request(reply, ad->service_handle, SERVICE_RESULT_SUCCEEDED);
6892 service_destroy(reply);
6896 static void cam_app_battery_status_cb(keynode_t *key, void *data)
6898 struct appdata *ad = (struct appdata *)data;
6900 debug_fenter(LOG_UI);
6901 cam_retm_if(ad == NULL, "appdata is NULL");
6903 int low_status = -1;
6905 if (!vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &low_status)) {
6906 cam_debug(LOG_UI, "battery status low = %d", low_status);
6907 if (low_status <= VCONFKEY_SYSMAN_BAT_WARNING_LOW) {
6908 ad->battery_status = LOW_BATTERY_CRITICAL_STATUS;
6909 cam_app_notice_popup(ad,
6910 dgettext("sys_string", "IDS_COM_BODY_LOW_BATTERY"),
6911 cam_app_timeout_notice_response_cb);
6913 ad->battery_status = NORMAL_BATTERY_STATUS;
6919 /*if torch light vconf key value is changed, this cb is called*/
6920 static void cam_torchlight_update_cb(keynode_t *key, void *data)
6922 struct appdata *ad = (struct appdata *)data;
6923 cam_retm_if(ad == NULL, "appdata is NULL");
6924 int key_value = vconf_keynode_get_bool(key); /* -1: error, 1:True, 0:False */
6925 if (key_value == -1) {
6926 DEBUG_TRACE("vconf_keynode_get_bool failed");
6929 DEBUG_TRACE("VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT is changed to %d", key_value);
6931 /* disable flash icon */
6932 ad->torchlight_on = TRUE;
6935 /* enable flash icon */
6936 ad->torchlight_on = FALSE;
6938 cam_toolbar_update(ad); /*update flash icon*/
6942 static void cam_app_battery_update_cb(keynode_t *key, void *data)
6944 struct appdata *ad = (struct appdata *)data;
6945 CamAppData *camapp = NULL;
6946 char *keyname = NULL;
6948 debug_fenter(LOG_UI);
6950 cam_retm_if(ad == NULL, "appdata is NULL");
6951 camapp = ad->camapp_handle;
6952 cam_retm_if(camapp == NULL, "camapp_handle is NULL");
6954 keyname = vconf_keynode_get_name(key);
6956 if (!strcmp(keyname, VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW)) {
6957 GValue value = { 0 };
6958 gint charging = vconf_keynode_get_int(key);
6959 DEBUG_TRACE("charging = %d", charging);
6960 CAM_GVALUE_SET_INT(value, charging);
6961 cam_handle_value_set(ad, PROP_BATTERY_CHARG, &value);
6963 } else if (!strcmp(keyname, VCONFKEY_SYSMAN_BATTERY_CAPACITY)) {
6964 GValue value = { 0 };
6965 int battery_level = vconf_keynode_get_int(key);
6966 CAM_GVALUE_SET_INT(value, battery_level);
6967 cam_handle_value_set(ad, PROP_BATTERY_LEVEL, &value);
6972 Evas_Object *cam_app_create_win(const char *name)
6974 Evas_Object *eo = NULL;
6976 #ifdef CAMERA_MACHINE_I686
6977 ecore_evas_app_comp_sync_set(EINA_FALSE);
6978 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
6979 ecore_evas_app_comp_sync_set(1);
6981 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
6984 elm_win_title_set(eo, name);
6985 elm_win_borderless_set(eo, EINA_TRUE);
6986 ecore_x_window_size_get(ecore_x_window_root_first_get(),
6988 evas_object_resize(eo, w, h);
6995 Evas_Object *cam_screen_load_edj(Evas_Object *parent, const char *file,
7001 eo = elm_layout_add(parent);
7003 r = elm_layout_file_set(eo, file, group);
7005 evas_object_del(eo);
7009 evas_object_size_hint_weight_set(eo,
7013 /* //if(!strcmp((const char *)elm_widget_type_get(parent), "win")) { */
7014 elm_win_resize_object_add(parent, eo);
7021 Evas_Object *cam_app_load_edj(Evas_Object *parent, const char *file,
7024 Evas_Object *eo = NULL;
7027 eo = elm_layout_add(parent);
7029 r = elm_layout_file_set(eo, file, group);
7031 evas_object_del(eo);
7035 evas_object_size_hint_weight_set(eo,
7039 elm_win_resize_object_add(parent, eo);
7040 evas_object_show(eo);
7046 void cam_app_update_ts(Evas_Object *parent, struct text_part *tp)
7049 int size = sizeof(tp) / sizeof(tp[0]);
7050 Evas_Object *eo = elm_layout_edje_get(parent);
7052 if (eo == NULL || tp == NULL || size < 0)
7055 for (i = 0; i < size; i++) {
7056 if (tp[i].part && tp[i].msgid)
7057 edje_object_part_text_set(eo,
7058 tp[i].part, _(tp[i].msgid));
7062 Eina_Bool __cam_app_update_thumbnail_idler(void *data)
7064 struct appdata *ad = (struct appdata *)data;
7066 return ECORE_CALLBACK_CANCEL;
7068 CamAppData *camapp = ad->camapp_handle;
7071 REMOVE_IDLER(ad->update_thumbnail_idler);
7072 return ECORE_CALLBACK_CANCEL;
7077 if (!g_file_test(camapp->filename,G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
7078 DEBUG_TRACE( "The captured File is not existed");
7079 REMOVE_IDLER(ad->update_thumbnail_idler);
7080 return ECORE_CALLBACK_CANCEL;;
7083 gboolean ret = FALSE;
7085 if (ad->imageviewer_ug) { /*review on */
7086 DEBUG_TRACE("Image viewer was LAUNCHED. skip this...");
7087 REMOVE_IDLER(ad->update_thumbnail_idler);
7088 return ECORE_CALLBACK_CANCEL;;
7091 if (camapp->thumbnail_name != NULL) {
7092 free (camapp->thumbnail_name);
7093 camapp->thumbnail_name = NULL;
7097 ret = cam_file_get_cam_file_thumbnail_path(camapp->filename, &camapp->thumbnail_name);
7098 DEBUG_TRACE("ret[0:success] = [%d] camapp->filename: [%s]",
7099 ret, camapp->filename);
7100 DEBUG_TRACE("ret[0:success] = [%d] camapp->thumbnail_name: [%s]",
7101 ret, camapp->thumbnail_name);
7102 if (!g_file_test(camapp->thumbnail_name, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
7104 if (g_thumbnail_image_check_count > 10) {
7105 REMOVE_IDLER(ad->update_thumbnail_idler);
7106 return ECORE_CALLBACK_CANCEL;
7109 DEBUG_TRACE("The thumbnail File is not existed,try the %d nums", g_thumbnail_image_check_count);
7110 g_thumbnail_image_check_count++;
7111 usleep(THUMBNAIL_UPDATE_WAIT_TIME);
7112 /*REMOVE_IDLER(ad->update_thumbnail_idler);*//*note:renew, do not delete idler*/
7113 return ECORE_CALLBACK_RENEW;
7115 #ifndef ENABLE_CAPTURE_ANIMATION
7117 DEBUG_TRACE("thumbnail image check count=[%d]", g_thumbnail_image_check_count);
7118 toolbar_update_quickview_thumbnail(ad);
7121 else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
7122 toolbar_update_quickview_thumbnail(ad);
7125 DEBUG_TRACE("NOT REACHED CODES REACHED!");
7128 REMOVE_IDLER(ad->update_thumbnail_idler);
7129 return ECORE_CALLBACK_CANCEL;
7131 /* update thumbnail to quickview after first launching or return from image viewer */
7132 void cam_app_update_quickview_icon(void *data)
7134 #ifdef CAMERA_MACHINE_I686
7137 struct appdata *ad = (struct appdata *)data;
7138 cam_ret_if(ad == NULL);
7139 cam_ret_if(ad->camapp_handle == NULL);
7140 gchar *filename = NULL;
7143 /*To update quickview image, get last filename*/
7144 filename = cam_app_get_last_filename();
7145 if (ad->camapp_handle->filename) {
7146 free(ad->camapp_handle->filename);
7147 ad->camapp_handle->filename = NULL;
7149 if (filename != NULL) {
7150 if (ad->camapp_handle->filename) {
7151 free(ad->camapp_handle->filename);
7152 ad->camapp_handle->filename = NULL;
7154 ad->camapp_handle->filename = strdup(filename);
7157 if (ad->camapp_handle->thumbnail_name) {
7158 free(ad->camapp_handle->thumbnail_name);
7159 ad->camapp_handle->thumbnail_name = NULL;
7161 /*update quickview area */
7162 if (cam_file_get_cam_file_thumbnail_path(ad->camapp_handle->filename,
7163 &ad->camapp_handle->thumbnail_name))
7164 toolbar_update_quickview_thumbnail_no_animation(ad);
7171 void cam_app_update_thumbnail()
7173 #ifdef CAMERA_MACHINE_I686
7176 struct appdata *ad = (struct appdata *)cam_appdata_get();
7177 cam_ret_if(ad == NULL);
7178 CamAppData *camapp = ad->camapp_handle;
7179 cam_ret_if(camapp == NULL);
7181 DEBUG_TRACE("cam_app_update_thumbnail");
7183 if (CAM_LAUNCHING_MODE_NORMAL == ad->launching_mode && camapp->filename) {
7185 g_thumbnail_image_check_count = 0;
7186 if (!ad->update_thumbnail_idler)
7187 ad->update_thumbnail_idler = ecore_idler_add(__cam_app_update_thumbnail_idler, ad);
7193 gboolean cam_app_parse_args(CamExeArgs *args, service_h service)
7195 struct appdata *ad = (struct appdata *)cam_appdata_get();
7196 cam_retv_if(ad == NULL, FALSE);
7198 ad->aul_service_mime = NULL;
7200 int ret = service_get_mime(service, &ad->aul_service_mime);
7201 if (ret != SERVICE_ERROR_NONE)
7203 cam_debug(LOG_UI, "service_get_mime is error ");
7207 if(ad->aul_service_mime != NULL){
7209 if(strcmp(ad->aul_service_mime, AUL_SERVICE_MIME_TYPE_IMAGE) == 0){
7210 cam_debug(LOG_UI, "CAM_CAMERA_MODE");
7211 args->cam_mode = CAM_CAMERA_MODE;
7212 }else if(strcmp(ad->aul_service_mime, AUL_SERVICE_MIME_TYPE_VIDEO) == 0){
7213 cam_debug(LOG_UI, "CAM_CAMCORDER_MODE");
7214 args->cam_mode = CAM_CAMCORDER_MODE;
7218 const char *val = NULL;
7219 /* get caller appl. */
7220 service_get_extra_data(service, "CALLER", (char **)&val);
7222 cam_debug(LOG_UI, "CALLER %s", val);
7223 args->caller = strdup(val);
7225 args->caller = NULL;
7230 service_get_extra_data(service, "RESOLUTION", (char **)&val);
7232 cam_debug(LOG_UI, "RESOLUTION %s", val);
7236 if (args->cam_mode == CAM_CAMERA_MODE) {
7237 if (0 == strcmp(val, CAM_CAPTURE_RES_BIG))
7238 res = CAM_RESOLUTION_3264x2448;
7239 else if (0 == strcmp(val, CAM_CAPTURE_RES_BIG_WIDE))
7240 res = CAM_RESOLUTION_3264x1836;
7241 else if (0 == strcmp(val, CAM_CAPTURE_RES_MIDDLE))
7242 res = CAM_RESOLUTION_2560x1920;
7243 else if (0 == strcmp(val, CAM_CAPTURE_RES_MIDDLE_WIDE))
7244 res = CAM_RESOLUTION_2560x1536;
7245 else if (0 == strcmp(val, CAM_CAPTURE_RES_SMALL))
7246 res = CAM_RESOLUTION_2560x1920;
7247 else if (0 == strcmp(val, CAM_CAPTURE_RES_SMALL_WIDE))
7248 res = CAM_RESOLUTION_1280x720;
7249 else if (0 == strcmp(val, CAM_CAPTURE_RES_VGA))
7250 res = CAM_RESOLUTION_VGA;
7252 res = CAM_RESOLUTION_3264x2448;
7254 if (0 == strcmp(val, CAM_RECORDING_RES_HD))
7255 res = CAM_RESOLUTION_HD;
7256 else if (0 == strcmp(val, CAM_RECORDING_RES_VGA))
7257 res = CAM_RESOLUTION_VGA;
7258 else if (0 == strcmp(val, CAM_RECORDING_RES_QCIF))
7259 res = CAM_RESOLUTION_QCIF;
7261 res = CAM_RESOLUTION_VGA;
7264 args->width = CAM_RESOLUTION_W(res);
7265 args->height = CAM_RESOLUTION_H(res);
7266 args->resolution = res;
7271 service_get_extra_data(service, "LIMIT", (char **)&val);
7273 cam_debug(LOG_UI, "LIMIT %s", val);
7274 args->size_limit = atoi(val);
7276 args->size_limit = 0;
7281 service_get_extra_data(service, "REVIEW", (char **)&val);
7283 if (0 == strcmp(val, "TRUE"))
7284 args->review = TRUE;
7286 args->review = FALSE;
7288 args->review = FALSE;
7291 /* print exe args */
7292 cam_debug(LOG_SYS, "############### exe args ###############");
7293 cam_debug(LOG_SYS, "mode =%d", args->cam_mode);
7294 cam_debug(LOG_SYS, "caller =%s", args->caller);
7295 cam_debug(LOG_SYS, "width =%d", args->width);
7296 cam_debug(LOG_SYS, "height =%d", args->height);
7297 cam_debug(LOG_SYS, "limit =%d", args->size_limit);
7298 cam_debug(LOG_SYS, "review =%d", args->review);
7299 cam_debug(LOG_SYS, "############### end ###############");
7305 void cam_app_draw_af_box(void *data)
7308 cam_retm_if(data == NULL, "data is null");
7309 struct appdata *ad = (struct appdata *)data;
7313 switch (ad->rot_current) {
7314 case APP_DEVICE_ORIENTATION_0:
7316 ad->af_start_x = ad->touch_lcd_x;
7317 ad->af_start_y = ad->touch_lcd_y;
7320 case APP_DEVICE_ORIENTATION_180:
7322 ad->af_start_x = ad->win_height - ad->touch_lcd_x;
7323 ad->af_start_y = ad->win_width - ad->touch_lcd_y;
7326 case APP_DEVICE_ORIENTATION_270:
7328 ad->af_start_x = ad->touch_lcd_y;
7329 ad->af_start_y = ad->win_height - ad->touch_lcd_x;
7332 case APP_DEVICE_ORIENTATION_90:
7334 ad->af_start_x = ad->win_width - ad->touch_lcd_y;
7335 ad->af_start_y = ad->touch_lcd_x;
7343 DEBUG_TRACE("ad->af_start_x=%f, ad->af_start_y=%f", ad->af_start_x,
7345 ad->camera_focus_w = CAMERA_FOCUS_W * elm_config_scale_get();
7346 ad->camera_focus_h = CAMERA_FOCUS_H * elm_config_scale_get();
7347 DEBUG_TRACE("ad->camera_focus_w=%f, ad->camera_focus_h=%f",
7348 ad->camera_focus_w, ad->camera_focus_h);
7350 ad->af_start_x = ad->af_start_x - (ad->camera_focus_w / 2);
7351 ad->af_start_y = ad->af_start_y - (ad->camera_focus_h / 2);
7352 DEBUG_TRACE("af area box start x,y =[%f,%f]\n", ad->af_start_x,
7355 if (ad->rot_current == APP_DEVICE_ORIENTATION_270
7356 || ad->rot_current == APP_DEVICE_ORIENTATION_90) {
7357 if (ad->af_start_x < ad->preview_offset_x) {
7358 ad->af_start_x = ad->preview_offset_x;
7360 if (ad->af_start_y < ad->preview_offset_y) {
7361 ad->af_start_y = ad->preview_offset_y;
7363 if ((ad->af_start_x + ad->camera_focus_w) >
7364 (ad->preview_w + ad->preview_offset_x)) {
7366 (ad->preview_w + ad->preview_offset_x) -
7369 if ((ad->af_start_y + ad->camera_focus_h) >
7370 (ad->preview_h + ad->preview_offset_y)) {
7372 (ad->preview_h + ad->preview_offset_y) -
7377 if (ad->af_start_y < ad->preview_offset_x) {
7378 ad->af_start_y = ad->preview_offset_x;
7380 if (ad->af_start_x < ad->preview_offset_y) {
7381 ad->af_start_x = ad->preview_offset_y;
7383 if ((ad->af_start_y + ad->camera_focus_h) >
7384 (ad->preview_w + ad->preview_offset_x)) {
7386 (ad->preview_w + ad->preview_offset_x) -
7389 if ((ad->af_start_x + ad->camera_focus_w) >
7390 (ad->preview_h + ad->preview_offset_y)) {
7392 (ad->preview_h + ad->preview_offset_y) -
7396 if (ad->focus_edje) {
7398 ("####################################################");
7399 DEBUG_TRACE("af area start ,ad->af_start_x,y =[%f,%f]\n",
7400 ad->af_start_x, ad->af_start_y);
7402 ("####################################################");
7403 evas_object_move(ad->focus_edje, ad->af_start_x,
7405 DEBUG_TRACE(" MOVE FOCUS_EDJE : %f,%f", ad->af_start_x,
7412 /* get preview start x,y coordinate */
7413 void cam_app_get_preview_offset_coordinate(void *data)
7416 cam_retm_if(data == NULL, "data is null");
7417 struct appdata *ad = (struct appdata *)data;
7419 CamAppData *camapp = ad->camapp_handle;
7420 cam_retm_if(camapp == NULL, "camapp is null");
7424 CamVideoRectangle result; /* result ractangle */
7425 CamVideoRectangle window; /* target window ractangle */
7426 CamVideoRectangle preview; /* target preview rectangle */
7427 /*wow,now, the MMHandleType is not created*/
7428 cam_mm_get_video_size(&width, &height);
7430 ad->camfw_video_width = width;
7431 ad->camfw_video_height = height;
7434 DEBUG_TRACE("************************************************");
7435 DEBUG_TRACE("preview.w =%d, preview.h=%d", preview.w, preview.h);
7437 window.h = ad->win_height;
7438 window.w = ad->win_width;
7439 DEBUG_TRACE("window.w =%d, window.h=%d\n", window.w, window.h);
7440 DEBUG_TRACE("************************************************");
7441 cam_app_preview_start_coordinate(preview, window, &result);
7443 ad->preview_offset_x = result.x;
7444 ad->preview_offset_y = result.y;
7445 ad->preview_w = result.w;
7446 ad->preview_h = result.h;
7448 DEBUG_TRACE("************************************************");
7449 DEBUG_TRACE("ad->preview_offset_x = %d, ad->preview_offset_y = %d",
7450 ad->preview_offset_x, ad->preview_offset_y);
7451 DEBUG_TRACE("*************************************************");
7453 camapp->focus_state = CAM_FOCUS_STATUS_RELEASED;
7454 cam_app_focus_guide_update(ad);
7457 ad->af_x = (ad->win_width / 2) - ad->preview_offset_x;
7458 ad->af_y = (ad->win_height / 2) - ad->preview_offset_y;
7460 ad->af_x = (ad->af_x * ad->camfw_video_width) / ad->preview_w;
7461 ad->af_y = (ad->af_y * ad->camfw_video_height) / ad->preview_h;
7463 ad->touch_lcd_x = (ad->win_height / 2);
7464 ad->touch_lcd_y = (ad->win_width / 2);
7466 DEBUG_TRACE("*************************************************");
7467 DEBUG_TRACE(" ad->af_x=%d, ad->af_y=%d", ad->af_x, ad->af_y);
7468 DEBUG_TRACE(" ad->af_start_x=%d, ad->af_start_y=%d", ad->af_start_x, ad->af_start_y);
7469 DEBUG_TRACE(" ad->touch_lcd_x=%d, ad->touch_lcd_y=%d", ad->touch_lcd_x,
7471 DEBUG_TRACE("*************************************************");
7473 cam_app_draw_af_box(ad);
7474 camapp->focus_mode = CAM_FOCUS_MODE_CONTINUOUS;
7477 evas_object_show(ad->focus_edje);
7480 void cam_app_preview_start_coordinate(CamVideoRectangle src,
7481 CamVideoRectangle dst,
7482 CamVideoRectangle *result)
7484 /* src is target preview rectangle */
7485 /* dst is target window rectangle */
7486 g_return_if_fail(result != NULL);
7487 gdouble src_ratio, dst_ratio;
7488 src_ratio = (gdouble) src.w / src.h;
7489 dst_ratio = (gdouble) dst.w / dst.h;
7490 if (src_ratio > dst_ratio) {
7491 DEBUG_TRACE("#### case 1\n");
7493 result->h = dst.w / src_ratio;
7495 result->y = (dst.h - result->h) / 2;
7496 } else if (src_ratio < dst_ratio) {
7497 DEBUG_TRACE("#### case 2\n");
7498 result->w = dst.h * src_ratio;
7500 result->x = (dst.w - result->w) / 2;
7503 DEBUG_TRACE("#### case 3\n");
7510 ("************************************************************");
7512 ("source is %dx%d dest is %dx%d, result window size is %dx%d result offset x= %dx y=%d",
7513 src.w, src.h, dst.w, dst.h, result->w, result->h, result->x,
7516 ("************************************************************");
7520 void cam_remove_tmp_file()
7522 const gchar *default_path = NULL;
7523 char tmpfile_name[256] = { 0 };
7525 default_path = cam_file_get_internal_video_path();
7526 DEBUG_TRACE(" video = %s", default_path);
7527 snprintf(tmpfile_name, sizeof(tmpfile_name), "%s%s", default_path,
7529 if (g_file_test(tmpfile_name, G_FILE_TEST_EXISTS)) {
7530 DEBUG_TRACE("REMOVE tmp file");
7531 unlink(tmpfile_name);
7533 default_path = cam_file_get_external_video_path();
7534 DEBUG_TRACE(" video = %s", default_path);
7535 snprintf(tmpfile_name, sizeof(tmpfile_name), "%s%s", default_path,
7538 if (g_file_test(tmpfile_name, G_FILE_TEST_EXISTS)) {
7539 DEBUG_TRACE("REMOVE tmp file");
7540 unlink(tmpfile_name);
7545 Eina_Bool cam_app_launch_after_preview_began(void *data)
7547 struct appdata *ad = (struct appdata *)data;
7548 cam_retv_if(ad == NULL, FALSE);
7550 cam_debug(LOG_UI, "cam_app_launch_after_preview_began");
7552 int state = cam_mm_get_state();
7554 if (state != RECORDER_STATE_RECORDING) {
7555 cam_debug(LOG_UI, "remove previous file");
7556 cam_remove_tmp_file();
7559 cam_app_get_preview_offset_coordinate(data);
7560 cam_toolbar_setting_popup_create(data);
7561 return ECORE_CALLBACK_CANCEL;
7564 void cam_utils_remove_idler_all(void *data)
7566 struct appdata *ad = (struct appdata *)data;
7568 Ecore_Idler *idler = NULL;
7570 debug_fenter(LOG_UI);
7572 cam_retm_if(ad == NULL, "appdata is NULL");
7575 In fact, a Lock is needed here. However, because all related functions are working main loop, practically it may not be needed. */
7577 if (!ad->capture_cb_list) {
7578 cam_debug(LOG_UI, "No idler is remained.");
7580 list = ad->capture_cb_list;
7587 "Fail to remove idler. The idler is NULL");
7589 cam_debug(LOG_UI, "Remove idler[%p].", idler);
7590 ecore_idler_del(idler);
7592 ad->capture_cb_list =
7593 g_list_remove(ad->capture_cb_list, idler);
7596 list = g_list_next(list);
7599 g_list_free(ad->capture_cb_list);
7600 ad->capture_cb_list = NULL;
7604 debug_fleave(LOG_UI);
7608 Eina_Bool cam_elm_cache_flush()
7610 /*Make the canvas discard as much data as possible used by the engine at runtime.*/
7611 DEBUG_TRACE("start");
7612 struct appdata *ad = (struct appdata *)cam_appdata_get();
7615 evas_render_idle_flush(ad->evas);
7618 elm_cache_all_flush();
7623 gboolean cam_condition_check_to_start_camera(void *data)
7625 struct appdata *ad = (struct appdata *)data;
7626 cam_retvm_if(ad == NULL, EINA_FALSE, "appdata is NULL");
7629 if (cam_utils_check_battery_critical_low()) {
7630 ad->battery_status = LOW_BATTERY_CRITICAL_STATUS;
7631 cam_app_notice_popup(ad, dgettext("sys_string", "IDS_COM_BODY_LOW_BATTERY"), cam_app_timeout_notice_response_cb);
7634 } else if (cam_utils_check_battery_warning_low()) {
7635 ad->battery_status = LOW_BATTERY_WARNING_STATUS;
7637 ad->battery_status = NORMAL_BATTERY_STATUS;