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://floralicense.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.
19 #include <X11/keysymdef.h>
25 #include <syspopup_caller.h>
26 #include <ui-gadget.h>
27 #include <ui-gadget-module.h>
31 #include "edc_string.h"
32 #include "cam_sound.h"
33 #include "cam_continuous_shot.h"
36 #include "cam_error.h"
37 #include "cam_config.h"
41 #include "cam_popup.h"
43 #include "cam_common_edc_callback.h"
44 #include "cam_indicator_edc_callback.h"
45 #include "cam_recording_edc_callback.h"
46 #include "cam_toolbar_edc_callback.h"
47 #include "cam_zoom_edc_callback.h"
48 #include "cam_ev_edc_callback.h"
49 #include "camera_utils.h"
51 #include "cam_face_detection_focus.h"
52 #include "cam_ui_effect_utils.h"
53 #include "cam_ui_rotate_utils.h"
55 #include "cam_menu_composer.h"
56 #include "cam_device_capacity.h"
58 #ifdef ENABLE_CAPTURE_ANIMATION
59 #include "cam_animation.h"
61 #define GPS_TIME_OUT 220
62 #define ZSL_MAX_REL (1280*720) /* 1m wide */
63 #define FOCUS_FOCUSED_TIME_OUT 2
64 #define THUMBNAIL_UPDATE_WAIT_TIME (100*1000)
68 /* #define ZSL_5M_TEST (2560*1920) */
73 static CamAppData *cam_handle = NULL;
74 static struct appdata *app_handle = NULL;
76 /* static Ecore_Idler *spy_rotation_idler=NULL; */
78 #define TEMP_SAVE_PATH "/tmp/temp_image.jpg" /* not used maybe... */
79 #define SELF_SHOT_TEMP_SAVE_PATH "/tmp/self_temp_shot.jpg"
81 #define ZOOM_LONG_PRESS_INTERVAL 0.05 /* sec */
83 #define INAGE_FILE_NAME "IMAGE"
84 #define VIDEO_FILE_NAME "VIDEO"
85 #define TEMP_FILE_NAME ".camera_result"
86 #define IMAGE_FILE_EXTENSION ".jpg"
87 #define VIDEO_FILE_EXTENSION_3GP ".3gp"
88 #define VIDEO_FILE_EXTENSION_MP4 ".mp4"
90 #define SHUTTER_W_RATIO 0.1
91 #define SHUTTER_H_RATIO 0.34
92 #define SCREEN_RATIO 1.0
93 /* #define CAMAPP_SIG_HANDLING */
95 /* #define ENABLE_CHECK_CAM_STATUS //provent camera hang, */
97 #ifdef ENABLE_CHECK_CAM_STATUS
98 #define CAM_CHECK_STATUS_INTERVAL_TIME 10
99 #ifndef CAMAPP_SIG_HANDLING
100 #define CAMAPP_SIG_HANDLING
105 static int cam_app_start_rotate(struct appdata *ad, bool bInitial);
107 #ifdef ENABLE_CHECK_CAM_STATUS
108 static void cam_app_check_status();
111 static gboolean cam_power_key_press(void *data);
112 static void cam_app_update_gps_level(void *data, int gps_level);
113 static gboolean cam_app_return_ext_app(void *data, const char *r_file_path);
115 /* vconf changed cb */
116 static void cam_app_battery_update_cb(keynode_t *key, void *data);
117 static void cam_app_battery_status_cb(keynode_t *key, void *data);
118 static void cam_mmc_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 Eina_Bool cam_app_gps_timer_cb(void *data);
129 static void cam_app_timer_update_count(void *data);
130 static Eina_Bool __focus_guide_destroy(void *data);
131 static void __cam_capture_cb(camera_image_data_s* image,
132 camera_image_data_s* postview, camera_image_data_s* thumbnail,void *user_data);
133 static Eina_Bool __cam_ug_destroy(void *data);
134 static Eina_Bool __cam_app_display_error_popup_idler(void *data);
135 static Eina_Bool __cam_continuous_af_timer_cb(void *data);
138 /* video streamming */
139 static gboolean video_stream_skip_flag = false;
141 /* thumbnail image check count */
142 static int g_thumbnail_image_check_count = 0;
145 gboolean g_blocking_popup = false;
147 void cam_app_set_blocking_popup()
149 g_blocking_popup = true;
152 void cam_app_free_blocking_popup()
154 g_blocking_popup = false;
157 gboolean cam_app_check_blocking_popup()
159 return !g_blocking_popup;
162 struct noti_callback {
164 void (*noti_func) (keynode_t *, void *);
167 #define CAMERA_NOTI_MAX 5
168 struct noti_callback notis[CAMERA_NOTI_MAX] = {
169 {VCONFKEY_SYSMAN_BATTERY_CAPACITY, *cam_app_battery_update_cb},
170 {VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, *cam_app_battery_update_cb},
171 {VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, *cam_app_battery_status_cb},
172 {VCONFKEY_SYSMAN_MMC_STATUS, *cam_mmc_state_change_cb},
173 {VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, *cam_torchlight_update_cb}
176 #ifdef CAMAPP_SIG_HANDLING
178 static struct sigaction cam_app_act;
179 static struct sigaction cam_app_act_old;
181 static void cam_app_register_sigsegv(void);
182 static void cam_app_sigsegv_handler(int signal_no, siginfo_t *info,
186 static void cam_app_pipe_handler(void *data, void *buffer, unsigned int nbyte);
187 static int cam_app_camera_state_manager(int previous, int current, gboolean by_asm);
188 static int cam_app_recorder_state_manager(int previous, int current, gboolean by_asm);
190 static void cam_app_close_ug(void *data);
191 Eina_Bool __ug_destory_postprocessing(void *data);
193 static Eina_Bool cam_app_timeout_checker_cb(void *data);
195 gdouble _get_current_time(void)
198 gettimeofday(&tv, NULL);
199 return (gdouble) tv.tv_sec + (gdouble) tv.tv_usec / 1E6;
202 void cam_app_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
205 evas_object_del(obj);
210 void cam_app_gps_popup_response_ok_cb(void *data, Evas_Object *obj, void *event_info)
212 struct appdata *ad = (struct appdata *)data;
213 cam_retm_if(ad == NULL, "appdata is NULL");
214 cam_ret_if(obj == NULL);
216 DEBUG_TRACE("show location ug");
218 if (ad->confirm_popup) {
219 evas_object_del(ad->confirm_popup);
220 ad->confirm_popup = NULL;
223 if (!cam_app_run_location_ug(data)) {
224 DEBUG_TRACE("cam_app_run_location_ug() fail");
225 GValue b_value = { 0, };
226 g_value_init(&b_value, G_TYPE_BOOLEAN);
227 g_value_set_boolean(&b_value, FALSE);
228 cam_handle_value_set(ad, PROP_GPS, &b_value);
230 cam_app_notice_popup(data, ("Location Setting launch fail"),
231 cam_app_popup_response_cb);
236 void cam_app_gps_popup_response_cancel_cb(void *data, Evas_Object *obj, void *event_info)
238 struct appdata *ad = (struct appdata *)data;
239 cam_retm_if(ad == NULL, "appdata is NULL");
240 cam_ret_if(obj == NULL);
241 if (!cam_app_lbs_stop(ad))
242 DEBUG_TRACE("cam_app_lbs_stop failed");
243 if (ad->confirm_popup) {
244 evas_object_del(ad->confirm_popup);
245 ad->confirm_popup = NULL;
249 static Eina_Bool cam_delay_popup(void *data)
252 cam_app_notice_popup(data, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_START_CAMERA_DURING_CALL"),
253 cam_app_timeout_notice_response_cb);
254 return ECORE_CALLBACK_CANCEL;
257 static void cam_add_longpress_key_timer(void *data)
259 struct appdata *ad = (struct appdata *)data;
260 cam_retm_if(ad == NULL, "appdata is NULL");
261 if (!ad->longpress_timer) {
262 ad->longpress_timer = ecore_timer_add(0.5, cam_volume_key_press, ad);
266 static void cam_del_longpress_key_timer(void *data)
268 struct appdata *ad = (struct appdata *)data;
269 cam_retm_if(ad == NULL, "appdata is NULL");
270 if (ad->longpress_timer) {
271 ecore_timer_del(ad->longpress_timer);
272 ad->longpress_timer = 0;
277 void cam_win_transparent_set(void *data)
279 struct appdata *ad = (struct appdata *)data;
280 cam_ret_if(ad == NULL);
284 evas = evas_object_evas_get(ad->win_main);
285 rect = evas_object_rectangle_add(evas);
286 evas_object_color_set(rect, 0, 0, 0, 0);
287 evas_object_render_op_set(rect, EVAS_RENDER_COPY);
288 evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
289 evas_object_show(rect);
290 elm_object_part_content_set(ad->ug_base, "transparent_layout", rect);
294 void cam_set_orient_value(void *data)
296 struct appdata *ad = (struct appdata *)data;
297 cam_retm_if(ad == NULL, "appdata is NULL");
298 CamAppData *camapp = NULL;
299 camapp = ad->camapp_handle;
300 cam_retm_if(camapp == NULL, "camapp_handle is NULL");
302 int orient_value = 0;
303 gboolean save_as_flip = FALSE;
305 if (cam_is_enabled_menu(ad, CAM_MENU_SAVE_AS_FLIP) && camapp->save_as_flip == TRUE)
308 switch (ad->rot_current) {
309 case APP_DEVICE_ORIENTATION_0:
311 if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
314 if (camapp->self_portrait == TRUE)
320 if (camapp->self_portrait == TRUE)
326 case APP_DEVICE_ORIENTATION_180:
328 if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
331 if (camapp->self_portrait == TRUE)
337 if (camapp->self_portrait == TRUE)
343 case APP_DEVICE_ORIENTATION_90:
344 if (save_as_flip && camapp->camera_mode == CAM_CAMCORDER_MODE)
349 case APP_DEVICE_ORIENTATION_270:
350 if (save_as_flip && camapp->camera_mode == CAM_CAMCORDER_MODE)
359 DEBUG_TRACE("rot_cuttent=%d orient_value=%d\n", ad->rot_current, orient_value);
361 if (cam_mm_set_tag_img_orient(orient_value))
362 DEBUG_TRACE("set image orient succeed %d", orient_value);
364 DEBUG_TRACE("set image orient failed %d", orient_value);
367 int cam_noti_init(void *data)
369 struct appdata *ad = (struct appdata *)data;
372 debug_fenter(LOG_UI);
374 cam_retvm_if(ad == NULL, EXIT_FAILURE, "appdata is NULL");
377 for (i = 0; i < CAMERA_NOTI_MAX; i++) {
378 if (0 != vconf_notify_key_changed(notis[i].setting_key, notis[i].noti_func, ad)) {
379 cam_critical(LOG_SYS, "vconf_notify_key_changed() failed. count=%d ", i);
386 int cam_noti_deinit(void *data)
389 struct appdata *ad = (struct appdata *)data;
391 debug_fenter(LOG_SYS);
393 cam_retvm_if(ad == NULL, EXIT_FAILURE, "appdata is NULL");
395 for (i = 0; i < CAMERA_NOTI_MAX; i++) {
396 vconf_ignore_key_changed(notis[i].setting_key, notis[i].noti_func);
402 void *cam_appdata_get(void)
410 void cam_app_get_win_size(void* data)
412 struct appdata *ad = (struct appdata *)data;
413 cam_retm_if(ad == NULL, "appdata is NULL");
415 ecore_x_window_size_get(ad->main_xid, &(ad->win_height), &(ad->win_width));
417 cam_debug(LOG_UI, "main window ----- win_width, win_height: [%d, %d]", ad->win_width, ad->win_height);
420 int cam_appdata_init(void *data)
422 struct appdata *ad = (struct appdata *)data;
423 cam_retvm_if(ad == NULL, 0, "appdata is NULL");
427 ad->main_pipe = ecore_pipe_add(cam_app_pipe_handler, ad);
428 ad->rot_current = app_get_device_orientation();
429 ad->rot_previous = ad->rot_current;
431 cam_app_get_win_size(ad);
433 CAM_TA_ACUM_ITEM_BEGIN(" cam_handle_create", 0);
434 if (!cam_handle_create(data)) {
435 cam_critical(LOG_CAM, "cam_handle_create failed");
438 CAM_TA_ACUM_ITEM_END(" cam_handle_create", 0);
440 ad->last_camera_zoom_mode = 1;
445 int cam_appdata_fini(void *data)
447 struct appdata *ad = (struct appdata *)data;
449 cam_retvm_if(ad == NULL, 0, "appdata is NULL");
451 cam_layout_del_all(ad);
453 if (ad->service_handle) {
454 service_destroy(ad->service_handle);
455 ad->service_handle = NULL;
457 if (ad->imageviewer_service) {
458 service_destroy(ad->imageviewer_service);
459 ad->imageviewer_service = NULL;
462 ecore_event_handler_del(ad->key_down);
466 ecore_event_handler_del(ad->key_up);
470 ecore_event_handler_del(ad->mouse_up);
473 if (ad->mouse_down) {
474 ecore_event_handler_del(ad->mouse_down);
475 ad->mouse_down = NULL;
477 /* Remove Idle handler of capture callback. wh01.cho@samsung.com. 2010-12-15. */
478 if (ad->capture_cb_list) {
479 cam_utils_remove_idler_all(ad);
482 REMOVE_IDLER(ad->recording_commit);
483 REMOVE_IDLER(ad->still_captured_idle);
484 REMOVE_IDLER(ad->capture_idle);
485 REMOVE_IDLER(ad->auto_shot_idle);
486 REMOVE_IDLER(ad->update_thumbnail_idler);
488 REMOVE_TIMER(ad->rec_icon_updater);
489 REMOVE_TIMER(ad->rec_time_updater);
490 REMOVE_TIMER(ad->rec_pause_timer);
491 REMOVE_TIMER(ad->check_af_timer);
492 REMOVE_TIMER(ad->continuous_shot_timer);
493 REMOVE_TIMER(ad->shutter_long_tap_timer);
494 REMOVE_TIMER(ad->timeout_checker);
495 REMOVE_TIMER(ad->setting_toolbar_hide_timer);
496 REMOVE_TIMER(ad->gps_animation_timer);
497 REMOVE_TIMER(ad->battery_animation_timer);
498 REMOVE_TIMER(ad->continuous_af_timer);
499 REMOVE_TIMER(ad->timer_timer);
500 REMOVE_TIMER(ad->longpress_timer);
501 REMOVE_TIMER(ad->focus_guide_hide_timer);
503 if( ad->setting_menu_composer != NULL){
504 cam_compose_free(ad->setting_menu_composer);
505 ad->setting_menu_composer = NULL;
507 if( ad->sub_menu_composer != NULL){
508 cam_compose_free(ad->sub_menu_composer);
509 ad->sub_menu_composer = NULL;
511 if (ad->camapp_handle) {
515 if (ad->exe_args->caller) {
516 free(ad->exe_args->caller);
517 ad->exe_args->caller = NULL;
523 if (ad->file_reg_thread) {
524 pthread_join(ad->file_reg_thread, NULL);
527 if (ad->file_reg_queue) {
528 while (!g_queue_is_empty(ad->file_reg_queue)) {
529 char *filename = NULL;
530 filename = g_queue_pop_head(ad->file_reg_queue);
532 cam_critical(LOG_FILE, "[%s] didn't processed",
535 if (!strcmp(REG_THREAD_EXIT, filename)) {
538 __cam_single_shot_reg_file(filename);
541 cam_debug(LOG_FILE, " register done.");
544 g_queue_free(ad->file_reg_queue);
545 ad->file_reg_queue = NULL;
548 /* disconnect media content */
549 CAM_TA_ACUM_ITEM_BEGIN(" media_content_disconnect", 0);
551 if(media_content_disconnect() == MEDIA_CONTENT_ERROR_NONE) {
552 DEBUG_TRACE("dis connection is success");
554 cam_critical(LOG_SYS, " media_content_disconnect failed");
557 CAM_TA_ACUM_ITEM_END(" media_content_disconnect", 0);
559 cam_popup_delete(ad);
562 ecore_pipe_del(ad->main_pipe);
563 ad->main_pipe = NULL;
565 /* init global handle */
571 CamAppData *cam_handle_get(void)
579 gboolean cam_app_init(void *data)
581 struct appdata *ad = (struct appdata *)data;
582 GError *error = NULL;
584 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
586 cam_face_detection_focus_init();
588 CAM_TA_ACUM_ITEM_BEGIN(" cam_appdata_init", 0);
589 if (!cam_appdata_init(ad)) {
590 cam_critical(LOG_CAM, "cam_appdata_init failed");
593 CAM_TA_ACUM_ITEM_END(" cam_appdata_init", 0);
595 cam_retvm_if(ad->camapp_handle == NULL, FALSE, "camapp_handle is NULL");
597 CAM_TA_ACUM_ITEM_BEGIN(" cam_config_init", 0);
598 if (!cam_config_init(&error)) {
599 cam_critical(LOG_SYS, "cam_config_init failed");
601 cam_critical(LOG_SYS, "cam_config_init error [%s]",
608 CAM_TA_ACUM_ITEM_END(" cam_config_init", 0);
610 CAM_TA_ACUM_ITEM_BEGIN(" cam_noti_init", 0);
611 if (EXIT_FAILURE == cam_noti_init(ad)) {
612 cam_critical(LOG_CAM, "cam_noti_init failed");
614 CAM_TA_ACUM_ITEM_END(" cam_noti_init", 0);
616 CAM_TA_ACUM_ITEM_BEGIN(" cam_file_init", 0);
617 if (!cam_file_init(&error)) {
618 cam_critical(LOG_FILE, "cam_file_init failed");
620 cam_critical(LOG_FILE, "cam_file_init error [%s]",
627 CAM_TA_ACUM_ITEM_END(" cam_file_init", 0);
628 CAM_TA_ACUM_ITEM_BEGIN(" cam_sound_init", 0);
629 if (!cam_sound_init(&error)) {
630 cam_critical(LOG_SND, "cam_sound_init failed");
632 cam_critical(LOG_SND, "cam_sound_init error [%s]",
639 CAM_TA_ACUM_ITEM_END(" cam_sound_init", 0);
640 CAM_TA_ACUM_ITEM_BEGIN(" cam_lbs_init", 0);
641 if (!cam_lbs_init()) {
642 cam_critical(LOG_FWK, "cam_lbs_init is failed");
645 CAM_TA_ACUM_ITEM_END(" cam_lbs_init", 0);
647 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_create_file_register_thread", 0);
648 if (!cam_app_create_file_register_thread(ad)) {
649 cam_critical(LOG_SYS,
650 " cam_app_create_file_register_thread failed");
653 CAM_TA_ACUM_ITEM_END(" cam_app_create_file_register_thread", 0);
655 CAM_TA_ACUM_ITEM_BEGIN(" cam_continuous_shot_create_file_save_thread", 0);
656 if (!cam_continuous_shot_create_file_save_thread(ad)) {
657 cam_critical(LOG_SYS,
658 " cam_continuous_shot_create_file_save_thread failed");
661 CAM_TA_ACUM_ITEM_END(" cam_continuous_shot_create_file_save_thread", 0);
663 #ifdef CAMAPP_SIG_HANDLING
664 /* register singal handler */
665 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_create_file_register_thread", 0);
666 cam_app_register_sigsegv();
667 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_create_file_register_thread", 0);
670 if(media_content_connect() == MEDIA_CONTENT_ERROR_NONE) {
671 DEBUG_TRACE("connection is success");
673 cam_critical(LOG_SYS, " media_content_connect failed");
683 gboolean cam_app_start(void *data)
685 CAM_TA_ACUM_ITEM_BEGIN("#########cam_app_start", 0);
687 struct appdata *ad = (struct appdata *)data;
688 CamAppData *camapp = NULL;
690 debug_fenter(LOG_CAM);
692 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
693 camapp = ad->camapp_handle;
694 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
697 camapp->gps_level = CAM_LBS_STATE_DISABLE;
699 camapp->need_gps_on = FALSE;
701 /*init guideline value*/
702 camapp->guideline = FALSE;
704 CAM_TA_ACUM_ITEM_BEGIN(" cam_callback_init", 0);
705 if (!cam_callback_init(ad)) {
706 cam_critical(LOG_CAM, "cam_init_mm_callback failed");
709 CAM_TA_ACUM_ITEM_END(" cam_callback_init", 0);
711 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_init_attribute", 0);
712 if (!cam_app_init_attribute(ad, camapp->camera_mode)) {
713 cam_critical(LOG_MM, "cam_app_init_attribute failed");
715 CAM_TA_ACUM_ITEM_END(" cam_app_init_attribute", 0);
717 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_preview_start", 0);
719 cam_continuous_af_start(ad);
720 if (!cam_app_preview_start(ad)) {
721 cam_critical(LOG_MM, "cam_app_preview_start failed");
724 CAM_TA_ACUM_ITEM_END(" cam_app_preview_start", 0);
725 cam_mm_set_mdnie_mode(TRUE);
728 if(!cam_key_grab_init(ad))
729 DEBUG_TRACE("cam_key_grab_init fail");
730 cam_app_key_event_init(ad);
731 cam_app_timeout_checker_init(ad);
733 #ifdef ENABLE_CHECK_CAM_STATUS
734 alarm(CAM_CHECK_STATUS_INTERVAL_TIME); /* start alarm */
736 CAM_TA_ACUM_ITEM_END("#########cam_app_start", 0);
738 ad->displayed_setting_popup = FALSE;
743 gboolean cam_app_pause(void *data)
745 DEBUG_TRACE("#############cam_app_pause - START #############\n");
746 struct appdata *ad = (struct appdata *)data;
747 CamAppData *camapp = NULL;
748 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
749 camapp = ad->camapp_handle;
750 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
753 mm_state = cam_mm_get_state();
755 cam_mm_set_display_visible(FALSE);
757 if (ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
758 if ((ad->exe_args->caller) && (strcmp(ad->exe_args->caller, "contacts") == 0)) {
759 DEBUG_TRACE(" contact is paused ");
761 service_create(&reply);
762 service_add_extra_data(reply, "camera_end", "1");
763 service_reply_to_launch_request(reply, ad->service_handle, SERVICE_RESULT_CANCELED);
764 service_destroy(reply);
768 if ((mm_state == RECORDER_STATE_RECORDING
769 || mm_state == RECORDER_STATE_PAUSED)
770 &&(camapp->camera_mode == CAM_CAMCORDER_MODE)) {
771 int shutter_sound_state = 0;
772 /* get current sound */
773 cam_mm_get_shutter_sound(&shutter_sound_state);
774 /* disable shutter sound */
775 cam_mm_set_shutter_sound(FALSE);
777 cam_video_record_stop(ad);
778 /*restore shutter sound */
779 cam_mm_set_shutter_sound(shutter_sound_state);
782 cam_app_stop_capture(ad);
784 if(camapp->af_mode == CAM_FOCUS_FACE){
785 cam_face_detection_reset();
788 if (ad->timer_activated)
789 cam_app_cancel_timer(ad);
791 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_preview_stop", 0);
793 if (camapp->camera_mode == CAM_CAMERA_MODE) {
794 while (cam_mm_get_cam_state() == CAMERA_STATE_CAPTURING) {
795 cam_critical(LOG_CAM, "state is capturing");
797 cam_app_preview_start(ad);
800 cam_mm_set_mdnie_mode(FALSE);
802 if (camapp->outdoor_visibility)
803 cam_mm_set_outdoor_visibility(FALSE);
805 if (!cam_app_preview_stop()) {
806 cam_critical(LOG_MM, "cam_app_preview_stop fail");
808 CAM_TA_ACUM_ITEM_END(" cam_app_preview_stop", 0);
810 if (EXIT_FAILURE == cam_noti_deinit(ad))
811 cam_critical(LOG_UI, "cam_noti_deinit failed");
813 if(!cam_app_key_event_deinit(ad))
814 cam_critical(LOG_UI, "cam_app_key_event_deinit failed");
816 if(!cam_key_grab_deinit(ad))
817 cam_critical(LOG_UI, "cam_key_grab_deinit failed");
819 if (camapp->gps == TRUE) {
820 int gps_level =CAM_LBS_STATE_DISABLE;
821 gps_level = cam_lbs_get_state();
822 if (gps_level >=CAM_LBS_STATE_SERVICE_ENABLE)
823 camapp->need_gps_on= TRUE;
824 if (ad->gps_animation_timer)
825 REMOVE_TIMER(ad->gps_animation_timer);
826 if (cam_app_lbs_stop(ad))
827 DEBUG_TRACE("The LBS failed to stop");
830 cam_app_timeout_checker_remove();
831 DEBUG_TRACE("#############cam_app_pause - END #############\n");
835 gboolean cam_app_resume(void *data)
837 struct appdata *ad = (struct appdata *)data;
838 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
840 CamAppData *camapp = NULL;
841 camapp = ad->camapp_handle;
842 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
845 debug_fenter(LOG_CAM);
847 if (!cam_condition_check_to_start_camera(ad)) {
848 cam_critical(LOG_CAM, "cannot start camera");
849 return ECORE_CALLBACK_CANCEL;
852 if(ad->launching_mode == CAM_LAUNCHING_MODE_NORMAL) {
853 if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
854 GValue value = {0, };
855 CAM_GVALUE_SET_INT(value, CAM_CAMERA_MODE);
856 if (!cam_handle_value_set(ad, PROP_MODE, &value)) {
857 return ECORE_CALLBACK_CANCEL;
862 indicator_update_storage(ad);
863 cam_app_timeout_checker_init(ad);
865 if (ad->imageviewer_ug == NULL) { /* home key destory imageviewer_ug */
866 cam_state = cam_mm_get_state();
867 cam_app_get_preview_offset_coordinate(ad);
869 cam_continuous_af_start((void*)ad);
870 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_preview_start", 0);
872 if (ad->torchlight_on && camapp->flash != CAM_FLASH_OFF)
873 cam_mm_set_flash(CAM_FLASH_OFF);
876 cam_mm_set_zoom(camapp->zoom_min);
877 camapp->zoom_mode = camapp->zoom_min;
879 if (!cam_app_preview_start(ad)) {
880 if (ad->fw_error_type == CAMERA_ERROR_SOUND_POLICY || ad->fw_error_type == RECORDER_ERROR_SOUND_POLICY) {
881 DEBUG_TRACE(" MM CAMCARORDER ERROR\n");
882 ecore_timer_add(0.01, cam_delay_popup, (void *)ad);
886 cam_critical(LOG_MM, "cam_app_preview_start failed");
887 cam_app_notice_popup(ad,
888 "PREVIEW START FAILED !!",
889 cam_app_timeout_notice_response_cb);
892 CAM_TA_ACUM_ITEM_END(" cam_app_preview_start", 0);
893 cam_mm_set_mdnie_mode(TRUE);
895 if (camapp->outdoor_visibility)
896 cam_mm_set_outdoor_visibility(TRUE);
898 if (camapp->camera_mode == CAM_CAMERA_MODE) {
899 if(camapp->af_mode == CAM_FOCUS_FACE){
900 /*start face detection*/
901 if (cam_mm_is_supported_face_detection()) {
902 cam_mm_start_camera_face_detection(camapp->face_detect_cb, (void *)ad);
903 if (!cam_mm_set_preview_cb(cam_face_detection_focus_start_stream, (void*)ad)) {
904 DEBUG_TRACE("preview callback set error");
906 cam_app_run_video_stream();
908 DEBUG_TRACE("not support face detect mode");
913 CAM_TA_ACUM_ITEM_BEGIN(" cam_noti_init", 0);
914 if (EXIT_FAILURE == cam_noti_init(ad))
915 cam_critical(LOG_CAM, "cam_noti_init failed");
916 CAM_TA_ACUM_ITEM_END(" cam_noti_init", 0);
918 CAM_TA_ACUM_ITEM_BEGIN(" cam_key_grab_init", 0);
919 if (!cam_key_grab_init(ad))
920 DEBUG_TRACE("cam_key_grab_init fail");
921 CAM_TA_ACUM_ITEM_END(" cam_key_grab_init", 0);
923 cam_app_key_event_init(ad);
924 cam_app_update_quickview_icon(ad);
925 cam_toolbar_update(ad);
928 if (camapp->need_gps_on== TRUE) {
929 camapp->need_gps_popup = FALSE;
930 if (!cam_app_lbs_start(ad)) {
931 if (!cam_app_lbs_stop(ad))
932 DEBUG_TRACE("The LBS failed to stop");
936 #ifdef ENABLE_CHECK_CAM_STATUS
937 alarm(CAM_CHECK_STATUS_INTERVAL_TIME); /* start alarm */
943 gboolean cam_app_stop(void *data)
945 debug_fenter(LOG_CAM);
946 char *filename = NULL;
948 struct appdata *ad = (struct appdata *)data;
949 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
950 CamAppData *camapp = ad->camapp_handle;
951 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
953 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_stop", 0);
955 /* return aul result path */
956 if (ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
957 if (ad->exe_args == NULL) {
958 DEBUG_TRACE("ad->exe_args is NULL");
961 if (ad->path_in_return) {
962 if (((ad->exe_args->caller) && (strcmp(ad->exe_args->caller, "contacts") == 0))
963 || ((ad->exe_args->caller) && (strcmp(ad->exe_args->caller, "ug-setting-call-efl") == 0))) {
964 DEBUG_TRACE("contacts -not need sending result");
966 if (ad->ug_state != CAM_UG_PAUSE_STATE) {
967 if (camapp->filename != NULL) {
968 filename = strdup(camapp->filename);
969 cam_app_return_ext_app(ad, filename);
974 cam_app_return_ext_app(ad, filename);
978 if (cam_mm_is_created()) {
979 /*TODO: new logic will be add for save file while camera process is killed*/
982 state = cam_mm_get_state();
983 if (ad->camapp_handle) {
984 if (ad->camapp_handle->camera_mode == CAM_CAMCORDER_MODE) {
986 case RECORDER_STATE_NONE:
987 case RECORDER_STATE_CREATED:
989 case RECORDER_STATE_READY:
991 case RECORDER_STATE_RECORDING:
992 case RECORDER_STATE_PAUSED:
993 cam_video_record_stop(ad);
996 /*g_assert_not_reached();*/
1002 cam_mm_set_mdnie_mode(FALSE);
1004 if (camapp->outdoor_visibility)
1005 cam_mm_set_outdoor_visibility(FALSE);
1007 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_preview_stop", 0);
1008 if (!cam_app_preview_stop()) {
1009 cam_critical(LOG_MM, "cam_app_preview_stop failed");
1011 CAM_TA_ACUM_ITEM_END(" cam_app_preview_stop", 0);
1013 CAM_TA_ACUM_ITEM_BEGIN(" cam_mm_destory", 0);
1014 if (!cam_mm_destory()) {
1015 cam_critical(LOG_MM, "cam_mm_destory failed");
1017 CAM_TA_ACUM_ITEM_END(" cam_mm_destory", 0);
1020 if (ad->imageviewer_ug || ad->location_ug) {
1021 cam_app_close_ug(ad);
1024 cam_popup_remove_all();
1026 /* Idler of capture callback management. wh01.cho@samsung.com. 2010-12-15. */
1027 cam_utils_remove_idler_all(ad);
1029 if (EXIT_FAILURE == cam_noti_deinit(ad))
1030 cam_critical(LOG_UI, "cam_noti_deinit failed");
1032 if(!cam_app_key_event_deinit(ad))
1033 cam_critical(LOG_UI, "cam_app_key_event_deinit failed");
1035 if(!cam_key_grab_deinit(ad))
1036 cam_critical(LOG_UI, "cam_key_grab_deinit failed");
1038 /* crear data & engine */
1039 CAM_TA_ACUM_ITEM_BEGIN(" cam_app_clear_engine_data", 0);
1040 cam_app_clear_engine_data(data, true);
1041 CAM_TA_ACUM_ITEM_END(" cam_app_clear_engine_data", 0);
1043 CAM_TA_ACUM_ITEM_BEGIN(" cam_file_finalize", 0);
1044 cam_file_finalize();
1045 CAM_TA_ACUM_ITEM_END(" cam_file_finalize", 0);
1047 CAM_TA_ACUM_ITEM_BEGIN(" cam_sound_finalize", 0);
1048 cam_sound_finalize();
1049 CAM_TA_ACUM_ITEM_END(" cam_sound_finalize", 0);
1052 CAM_TA_ACUM_ITEM_BEGIN(" cam_config_finalize", 0);
1053 cam_config_finalize();
1054 CAM_TA_ACUM_ITEM_END(" cam_config_finalize", 0);
1057 CAM_TA_ACUM_ITEM_BEGIN(" cam_gps_finialize", 0);
1058 cam_lbs_finialize();
1059 CAM_TA_ACUM_ITEM_END(" cam_gps_finialize", 0);
1061 /* cam_handle_free(ad); */
1062 cam_face_detection_focus_finish();
1063 cam_appdata_fini(ad);
1065 if (filename != NULL) {
1070 CAM_TA_ACUM_ITEM_END(" cam_app_stop", 0);
1075 gboolean cam_app_preview_start(void *data)
1077 CAM_TA_ACUM_ITEM_BEGIN("----cam_app_preview_start", 0);
1079 ("------------------------------START---------------------------------");
1081 struct appdata *ad = (struct appdata *)data;
1082 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1083 CamAppData *camapp = ad->camapp_handle;
1084 cam_retvm_if(camapp == NULL, FALSE, "camapp is NULL");
1086 int state = cam_mm_get_state();
1087 DEBUG_TRACE("state: %d ", state);
1089 if (((camapp->camera_mode == CAM_CAMERA_MODE) && (state < CAMERA_STATE_NONE))
1090 || ((camapp->camera_mode == CAM_CAMCORDER_MODE) && (state < RECORDER_STATE_NONE)))
1093 if (camapp->camera_mode == CAM_CAMERA_MODE) {
1095 case CAMERA_STATE_CREATED:
1096 case CAMERA_STATE_CAPTURED:
1098 CAM_TA_ACUM_ITEM_BEGIN(" cam_mm_preview_start", 0);
1099 if (!cam_mm_preview_start(camapp->camera_mode)) {
1100 cam_critical(LOG_MM, "cam_mm_preview_start failed");
1103 CAM_TA_ACUM_ITEM_END(" cam_mm_preview_start", 0);
1106 case CAMERA_STATE_CAPTURING:
1108 if (cam_mm_capture_stop(FALSE, camapp->camera_mode) == FALSE) {
1109 cam_critical(LOG_MM, "cam_mm_capture_stop failed");
1117 }else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
1119 case RECORDER_STATE_CREATED:
1120 case RECORDER_STATE_PAUSED:
1122 if (!cam_mm_preview_start(camapp->camera_mode)) {
1123 cam_critical(LOG_MM, "cam_mm_preview_start failed");
1134 CAM_TA_ACUM_ITEM_END("----cam_app_preview_start", 0);
1138 gboolean cam_app_preview_stop(void)
1140 struct appdata *ad = (struct appdata *)cam_appdata_get();
1141 cam_retvm_if(ad == NULL, FALSE, "ad is NULL");
1142 CamAppData *camapp = ad->camapp_handle;
1143 cam_retvm_if(camapp == NULL, FALSE, "camapp is NULL");
1145 if (camapp->touch_af_state == CAM_TOUCH_AF_STATE_DOING
1146 || camapp->touch_af_state == CAM_TOUCH_AF_STATE_READY)
1147 camapp->touch_af_state = CAM_TOUCH_AF_STATE_NONE;
1149 if (!cam_mm_preview_stop(camapp->camera_mode)) {
1150 cam_critical(LOG_MM, "cam_mm_preview_stop failed");
1156 static void cam_app_timer_icon_rotate(void *data)
1158 struct appdata *ad = (struct appdata *)data;
1159 cam_retm_if(ad == NULL, "appdata is NULL");
1161 DEL_EVAS_OBJECT(ad->timer_icon_edje);
1162 cam_app_timer_update_count(ad);
1165 static int cam_app_start_rotate(struct appdata *ad, bool bInitial)
1167 cam_retvm_if(ad == NULL, -1, "appdata is NULL");
1169 cam_debug(LOG_UI, "rotated : %d, window rotation angle=%d", ad->rot_current); /*, elm_win_rotation_get(ad->win_main)); */
1174 switch (ad->rot_current) {
1175 case APP_DEVICE_ORIENTATION_0:
1176 ad->camcorder_rotate = CAMERA_ROTATION_90;
1177 ad->target_direction = CAM_TARGET_DIRECTION_PORTRAIT;
1181 case APP_DEVICE_ORIENTATION_180:
1182 ad->camcorder_rotate = CAMERA_ROTATION_270;
1183 ad->target_direction = CAM_TARGET_DIRECTION_PORTRAIT_INVERSE;
1187 case APP_DEVICE_ORIENTATION_270:
1188 ad->camcorder_rotate = CAMERA_ROTATION_NONE;
1189 ad->target_direction = CAM_TARGET_DIRECTION_LANDSCAPE;
1193 case APP_DEVICE_ORIENTATION_90:
1194 ad->camcorder_rotate = CAMERA_ROTATION_180;
1195 ad->target_direction = CAM_TARGET_DIRECTION_LANDSCAPE_INVERSE;
1203 ad->angle_pre = ad->angle;
1205 ////////////////////////////////////////////////////////////////////////////
1206 if (ad->toolbar_edj_file) {
1207 free(ad->toolbar_edj_file);
1208 ad->toolbar_edj_file = NULL;
1211 switch (ad->angle) {
1213 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_EDJ_NAME);
1216 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_VERTICAL_EDJ_NAME);
1219 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_INVERSE_EDJ_NAME);
1222 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_VERTICAL_INVERSE_EDJ_NAME);
1225 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_EDJ_NAME);
1230 if(elm_win_rotation_get(ad->win_main) != ad->angle)
1231 elm_win_rotation_with_resize_set(ad->win_main, ad->angle);
1233 cam_app_get_preview_offset_coordinate(ad);
1236 if (ad->toolbar_edje)
1237 cam_toolbar_rotate(ad);
1239 if (ad->indicator_edje)
1240 cam_indicator_rotate(ad);
1242 if (ad->recording_edje)
1243 cam_recording_rotate(ad);
1245 if (ad->timer_icon_edje)
1246 cam_app_timer_icon_rotate(ad);
1253 if (ad->zoom_edje) {
1254 unload_zoom_edje(ad);
1258 if (ad->guideline_edje)
1259 settings_guideline_refresh(ad);
1265 gboolean cam_layout_init(void *data)
1267 DEBUG_TRACE("START");
1269 struct appdata *ad = (struct appdata *)data;
1270 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1272 if (ad->win_main == NULL) {
1273 cam_critical(LOG_UI, "win_main is NULL");
1276 ad->pinch_edje = NULL;
1278 cam_app_start_rotate(ad, TRUE);
1279 DEBUG_TRACE("ad->angle = %d", ad->angle);
1281 elm_theme_extension_add(NULL, CAM_SETTING_POPUP_STYLE_EDJ_NAME);
1282 elm_theme_extension_add(NULL, CAM_SETTING_POPUP_STYLE_WITH_RADIO_EDJ_NAME);
1283 elm_theme_extension_add(NULL, CAM_SLIDER_STYLE_EDJ_NAME);
1284 elm_theme_extension_add(NULL, CAM_LABEL_STYLE_EDJ_NAME);
1285 elm_theme_extension_add(NULL, CAM_BUTTON_STYLE_EDJ_NAME);
1287 #ifndef CAMERA_MACHINE_I686
1288 define_mouse_callback(ad);
1291 CAM_TA_ACUM_ITEM_BEGIN(" load_toolbar_edje", 0);
1292 if (cam_toolbar_create(ad)) {
1293 CAM_TA_ACUM_ITEM_END(" load_toolbar_edje", 0);
1294 cam_critical(LOG_UI, " load_toolbar_edje failed ");
1297 CAM_TA_ACUM_ITEM_END(" load_toolbar_edje", 0);
1299 CAM_TA_ACUM_ITEM_BEGIN(" cam_indicator_create", 0);
1300 if (cam_indicator_create(ad)) {
1301 CAM_TA_ACUM_ITEM_END(" cam_indicator_create", 0);
1302 cam_critical(LOG_UI, "cam_indicator_create failed ");
1305 CAM_TA_ACUM_ITEM_END(" cam_indicator_create", 0);
1307 cam_app_focus_guide_create(ad);
1308 cam_app_update_quickview_icon(ad);
1309 settings_guideline_refresh(ad);
1312 /*reading from ini: whether need show popup tip*/
1313 gboolean show_popup_tip = FALSE;
1314 show_popup_tip = cam_config_get_boolean_by_type(CAM_CONFIG_TYPE_SHORTCUTS, PROP_SHOW_POP_TIP, POP_TIP_DEFAULT);
1315 if (show_popup_tip) {
1316 cam_tip_popup_create(ad, CAM_TIP_POPUP_BURSTSHOT_HELP);
1319 if (ad->battery_status == LOW_BATTERY_CRITICAL_STATUS
1320 || ad->battery_status == LOW_BATTERY_WARNING_STATUS
1321 || ad->is_calling == TRUE ){
1322 ecore_idler_add(__cam_app_display_error_popup_idler, ad);
1330 gboolean cam_handle_create(void *data)
1332 CAM_TA_ACUM_ITEM_BEGIN("------cam_handle_create", 0);
1333 struct appdata *ad = (struct appdata *)data;
1334 CamAppData *camapp = NULL;
1336 debug_fenter(LOG_CAM);
1337 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1339 if (ad->camapp_handle && cam_handle) {
1340 cam_handle_free(ad);
1343 camapp = (CamAppData *)malloc(sizeof(CamAppData));
1344 cam_retv_if(camapp == NULL, FALSE);
1345 memset(camapp, 0x00, sizeof(CamAppData));
1347 cam_handle = camapp;
1348 ad->camapp_handle = camapp;
1349 CAM_TA_ACUM_ITEM_END("------cam_handle_create", 0);
1354 gboolean cam_handle_free(void *data)
1356 struct appdata *ad = (struct appdata *)data;
1357 CamAppData *camapp = NULL;
1359 debug_fenter(LOG_CAM);
1360 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1361 camapp = ad->camapp_handle;
1362 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
1366 if (camapp && cam_handle) {
1367 if (camapp->conti_image) {
1368 evas_object_del(camapp->conti_image);
1369 camapp->conti_image = NULL;
1372 if (camapp->filename) {
1373 free(camapp->filename);
1374 camapp->filename = NULL;
1377 if (camapp->thumbnail_name) {
1378 free(camapp->thumbnail_name);
1379 camapp->thumbnail_name = NULL;
1381 cam_continuous_shot_data_free(ad);
1388 ad->camapp_handle = NULL;
1395 gboolean cam_toolbar_menu_config_init(void *data, int mode) {
1396 struct appdata *ad = (struct appdata *)data;
1397 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1400 #ifdef CAMERA_MACHINE_I686
1401 for (i = CAM_MENU_BAR_LEFT_1; i < CAM_MENU_BAR_LEFT_MAX_NUM; i++) {
1402 char buf[16+1] = { '\0', };
1403 snprintf(buf, 16, "toolbar_%d", i);
1404 ad->toolbar_menu_arrays[i].menu_type = CAM_MENU_EMPTY;
1407 for (i = CAM_MENU_BAR_LEFT_1; i < CAM_MENU_BAR_LEFT_MAX_NUM; i++) {
1408 char buf[16+1] = { '\0', };
1409 snprintf(buf, 16, "toolbar_%d", i);
1410 ad->toolbar_menu_arrays[i].menu_type = cam_config_get_int(buf, CAM_MENU_EMPTY);
1412 if (ad->toolbar_menu_arrays[i].menu_type == CAM_MENU_SELF_PORTRAIT) {
1413 if (cam_mm_is_support_front_camera() == FALSE)
1414 ad->toolbar_menu_arrays[i].menu_type = CAM_MENU_EMPTY;
1422 gboolean cam_toolbar_menu_config_update(void *data)
1424 struct appdata *ad = (struct appdata *)data;
1425 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1427 for (i = CAM_MENU_BAR_LEFT_1; i < CAM_MENU_BAR_LEFT_MAX_NUM; i++) {
1428 char buf[16+1] = { '\0', };
1429 snprintf(buf, 16, "toolbar_%d", i);
1430 int tmp_type = cam_config_get_int(buf, CAM_MENU_EMPTY);
1431 if (ad->toolbar_menu_arrays[i].menu_type != tmp_type) {
1432 cam_config_set_int(buf, ad->toolbar_menu_arrays[i].menu_type);
1438 gboolean cam_handle_init(void *data, int mode)
1440 struct appdata *ad = data;
1441 CamAppData *camapp = NULL;
1444 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1445 camapp = ad->camapp_handle;
1446 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
1448 cam_info(LOG_UI, "mode : %d ", mode);
1449 camapp->camera_mode = mode;
1450 cam_config_set_int_by_type(CAM_CONFIG_TYPE_COMMON, PROP_MODE_NAME, mode);
1452 cam_app_set_config_group(camapp->camera_mode);
1453 /* load init value from ini file */
1454 /* camapp->camera_mode = cam_config_get_int(PROP_MODE_NAME, MODE_DEFAULT); */
1456 vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT, &(camapp->storage));
1458 camapp->anti_shake = cam_config_get_int(PROP_AHS_NAME, AHS_DEFAULT);
1460 camapp->self_portrait = FALSE;
1462 /* use shot mode as default value */
1463 camapp->recording_mode = RECMODE_DEFAULT;
1464 camapp->shooting_mode = SHOTMODE_DEFAULT;
1466 camapp->scene_mode = cam_config_get_int(PROP_SCENE_MODE_NAME, PG_MODE_DEFAULT);
1467 camapp->iso = cam_config_get_int(PROP_ISO_NAME, ISO_DEFAULT);
1468 /*camapp->af_mode = cam_config_get_int(PROP_AF_NAME, AF_DEFAULT); */
1469 camapp->af_mode = AF_DEFAULT;
1470 /* camapp->white_balance = cam_config_get_int(PROP_WB_NAME, WB_DEFAULT); */
1471 camapp->white_balance = WB_DEFAULT;
1473 camapp->flash = cam_config_get_int(PROP_FLASH_NAME, FLASH_DEFAULT);
1476 if (cam_utils_check_battery_warning_low()) {
1477 camapp->flash = CAM_FLASH_OFF;
1479 camapp->guideline = cam_config_get_boolean(PROP_GUIDELINE_NAME, GUIDE_LINE_DEFAULT);
1480 DEBUG_TRACE("camapp->guideline = %d" ,camapp->guideline);
1481 camapp->effect = EFFECT_DEFAULT;
1483 camapp->wdr = cam_config_get_int(PROP_WDR_NAME, WDR_DEFAULT);
1484 camapp->auto_exposure = cam_config_get_int(PROP_METERING_NAME, AE_DEFAULT);
1486 camapp->photo_resolution = cam_config_get_int(PROP_PHOTO_RESOLUTION_NAME, IMAGE_RESOLUTION_DEFAULT);
1487 camapp->video_resolution = cam_config_get_int(PROP_VIDEO_RESOLUTION_NAME, REC_RESOLUTION_DEFAULT);
1489 camapp->auto_contrast = FALSE;
1490 camapp->image_quality = QUALITY_DEFAULT;
1491 camapp->video_quality = QUALITY_DEFAULT;
1492 camapp->audio_recording = AUDIOREC_DEFAULT;
1493 camapp->review = cam_config_get_boolean(PROP_REVIEW_NAME, FALSE);
1495 camapp->battery_level = cam_utils_get_battery_level();
1496 charging = cam_utils_get_charging_status();
1498 camapp->battery_charging = charging;
1500 camapp->battery_charging = 0;
1502 #ifdef USE_CAMERA_APP_SHUTTER_SOUND
1503 camapp->shutter_sound = SHUTTER_SOUND_DEFAULT;
1507 cam_mm_set_shutter_sound(SOUND_DEFAULT);
1508 camapp->shutter_sound = SHUTTER_SOUND_DEFAULT; /* on */
1510 /* below item had been saved in ini file */
1511 camapp->zoom_mode = ZOOM_DEFAULT;
1512 camapp->image_count = IMAGE_COUNT_DEFAULT;
1513 camapp->size_limit_type = CAM_MM_SIZE_LIMIT_TYPE_BYTE;
1514 camapp->size_limit = REC_SIZE_LIMIT_DEFAULT;
1515 camapp->timer = TIMER_DEFAULT;
1516 camapp->fps = FPS_DEFAULT;
1518 camapp->continuous_shot_data = NULL;
1520 camapp->enable_touch_af = TRUE;
1522 camapp->outdoor_visibility = FALSE;
1524 camapp->burst_shot = cam_config_get_boolean(PROP_BURST_SHOT_NAME, BURST_SHOT_DEFAULT);
1526 camapp->device_type = CAM_DEVICE_MEGA;
1528 camapp->volume_key = cam_config_get_int(PROP_VOLUME_KEY_NAME, CAM_VOLUME_KEY_ZOOM);
1530 camapp->save_as_flip = FALSE;
1532 /*init toolbar menu config */
1533 cam_toolbar_menu_config_init((void*)ad, mode);
1535 /* init reserved setting data */
1536 camapp->reserved_setting_data.front_photo_resolution = cam_config_get_int(PROP_SELF_PHOTO_RESOLUTION_NAME, SELF_IMAGE_RESOLUTION_DEFAULT);
1537 camapp->reserved_setting_data.front_video_resolution = cam_config_get_int(PROP_SELF_VIDEO_RESOLUTION_NAME, SELF_REC_RESOLUTION_DEFAULT);
1538 camapp->reserved_setting_data.rear_photo_resolution = cam_config_get_int(PROP_PHOTO_RESOLUTION_NAME, IMAGE_RESOLUTION_DEFAULT);
1539 camapp->reserved_setting_data.rear_video_resolution = cam_config_get_int(PROP_VIDEO_RESOLUTION_NAME, REC_RESOLUTION_DEFAULT);
1540 camapp->reserved_setting_data.front_shooting_mode = CAM_SELF_SINGLE_MODE;
1541 camapp->reserved_setting_data.front_recording_mode = CAM_RECORD_SELF;
1542 camapp->reserved_setting_data.rear_shooting_mode = SHOTMODE_DEFAULT;
1543 camapp->reserved_setting_data.rear_recording_mode = RECMODE_DEFAULT;
1544 camapp->reserved_setting_data.front_effect = EFFECT_DEFAULT;
1545 camapp->reserved_setting_data.rear_effect = EFFECT_DEFAULT;
1546 camapp->reserved_setting_data.front_wb = WB_DEFAULT;
1547 camapp->reserved_setting_data.rear_wb = WB_DEFAULT;
1552 gboolean cam_handle_value_set(void *data, int type, const GValue *value)
1554 struct appdata *ad = (struct appdata *)data;
1555 CamAppData *camapp = NULL;
1557 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
1558 camapp = ad->camapp_handle;
1559 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
1561 cam_debug(LOG_CAM, "type : %d", type);
1567 gint tempval = g_value_get_int(value);
1569 current = camapp->camera_mode;
1571 //camapp->camera_mode = tempval;
1572 if (!cam_mode_change(ad, tempval)) {
1573 cam_critical(LOG_CAM, "MODE CHANGE IS FAILED by MIDDLE WARE");
1574 camapp->camera_mode = current;
1575 cam_app_notice_popup(data, "MODE CHANGE FAILED !!", cam_app_timeout_notice_response_cb);
1580 case PROP_SELF_PORTRAIT:
1582 GValue set_value = { 0 };
1583 gboolean tempval = g_value_get_boolean(value);
1585 /* stop preview and destory mmfw handle */
1586 if (!cam_app_preview_stop()) {
1587 cam_critical(LOG_MM, "cam_app_preview_stop faild");
1591 if (!cam_mm_destory()) {
1592 cam_critical(LOG_MM, "cam_mm_destory faild");
1596 if (camapp->self_portrait == TRUE) {
1597 camapp->device_type = CAM_DEVICE_VGA;
1599 camapp->device_type = CAM_DEVICE_MEGA;
1602 DEBUG_TRACE("device_type = %d", camapp->device_type);
1604 cam_config_set_boolean(PROP_SELF_PORTRAIT_NAME, tempval);
1606 if (!cam_mm_create(camapp->device_type, camapp->camera_mode)) {
1607 cam_critical(LOG_MM, "cam_mm_create failed");
1608 cam_app_notice_popup(ad, "cam_app_preview_start faild ", cam_app_timeout_notice_response_cb);
1613 define_mouse_callback(ad);
1615 /* get reserved setting value */
1616 if (camapp->self_portrait == FALSE) {
1617 camapp->photo_resolution = camapp->reserved_setting_data.rear_photo_resolution;
1618 camapp->video_resolution = camapp->reserved_setting_data.rear_video_resolution;
1619 camapp->shooting_mode = camapp->reserved_setting_data.rear_shooting_mode;
1620 camapp->recording_mode = camapp->reserved_setting_data.rear_recording_mode;
1622 camapp->photo_resolution = camapp->reserved_setting_data.front_photo_resolution;
1623 camapp->video_resolution = camapp->reserved_setting_data.front_video_resolution;
1624 camapp->shooting_mode = camapp->reserved_setting_data.front_shooting_mode;
1625 camapp->recording_mode = camapp->reserved_setting_data.front_recording_mode;
1628 /* set shot, rec mode */
1629 CAM_GVALUE_SET_INT(set_value, camapp->shooting_mode);
1630 cam_handle_value_set(ad, PROP_SHOT_MODE, &set_value);
1631 CAM_GVALUE_SET_INT(set_value, camapp->recording_mode);
1632 cam_handle_value_set(ad, PROP_REC_MODE, &set_value);
1634 camapp->zoom_mode = ZOOM_DEFAULT;
1637 if (!cam_app_init_attribute(ad, camapp->camera_mode)) {
1638 cam_critical(LOG_MM, "cam_app_init_attribute failed");
1641 cam_continuous_af_start(ad);
1642 if (!cam_app_preview_start(ad)) {
1643 cam_critical(LOG_MM, "cam_app_preview_start failed");
1644 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_START_CAMERA"), cam_app_timeout_notice_response_cb);
1648 settings_guideline_refresh(ad);
1650 if(camapp->af_mode == CAM_FOCUS_FACE){
1651 /*start face detection*/
1652 if (cam_mm_is_supported_face_detection()) {
1653 cam_mm_start_camera_face_detection(camapp->face_detect_cb, (void *)ad);
1654 if (!cam_mm_set_preview_cb(cam_face_detection_focus_start_stream, (void*)ad)) {
1655 DEBUG_TRACE("preview callback set error");
1657 cam_app_run_video_stream();
1659 DEBUG_TRACE("not support face detect mode");
1665 case PROP_SHOT_MODE:
1667 gint tempval = g_value_get_int(value);
1668 gint cur_mode = camapp->shooting_mode;
1670 camapp->shooting_mode = tempval;
1672 if (!cam_shooting_mode_change(ad)) {
1673 cam_critical(LOG_UI, "shot mode set fail");
1674 camapp->shooting_mode = cur_mode;
1678 if (camapp->self_portrait == FALSE) {
1679 camapp->reserved_setting_data.rear_shooting_mode = tempval;
1681 camapp->reserved_setting_data.front_shooting_mode = tempval;
1684 cam_app_focus_guide_update(ad);
1689 gint tempval = g_value_get_int(value);
1690 int video_resolution = 0;
1691 GValue set_value = { 0, };
1692 g_value_init(&set_value, G_TYPE_INT);
1694 camapp->recording_mode = tempval;
1696 if (camapp->self_portrait == FALSE) {
1697 camapp->reserved_setting_data.rear_recording_mode = tempval;
1699 camapp->reserved_setting_data.front_recording_mode = tempval;
1702 if (camapp->recording_mode == CAM_RECORD_NORMAL) {
1703 video_resolution = cam_config_get_int(PROP_VIDEO_RESOLUTION_NAME, REC_RESOLUTION_DEFAULT);
1704 g_value_set_int(&set_value, video_resolution);
1705 } else if (camapp->recording_mode == CAM_RECORD_SLOW || camapp->recording_mode == CAM_RECORD_FAST) {
1706 g_value_set_int(&set_value, CAM_RESOLUTION_QVGA);
1707 } else if (camapp->recording_mode == CAM_RECORD_SELF) {
1708 video_resolution = cam_config_get_int(PROP_SELF_VIDEO_RESOLUTION_NAME, SELF_REC_RESOLUTION_DEFAULT);
1709 g_value_set_int(&set_value, video_resolution);
1710 } else if (camapp->recording_mode == CAM_RECORD_MMS || camapp->recording_mode == CAM_RECORD_SELF_MMS) {
1711 g_value_set_int(&set_value, CAM_RESOLUTION_QCIF);
1714 cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &set_value);
1716 if (!cam_recording_mode_change(ad, tempval)) {
1717 cam_critical(LOG_UI, "rec mode change fail - mode[%d]", tempval);
1723 case PROP_SCENE_MODE:
1725 gint tempval = g_value_get_int(value);
1726 if (!cam_mm_set_program_mode(tempval)) {
1727 cam_warning(LOG_UI, "program mode set fail");
1730 camapp->scene_mode = tempval;
1733 int flash = CAM_FLASH_OFF;
1734 if(camapp->scene_mode == CAM_SCENE_NONE){
1735 flash = cam_config_get_int(PROP_SCENE_MODE_NAME, PG_MODE_DEFAULT);
1736 }else if(camapp->scene_mode == CAM_SCENE_CANDLELIGHT){
1737 flash = CAM_FLASH_ON;
1739 flash = CAM_FLASH_OFF;
1741 GValue set_value = { 0, };
1742 g_value_init(&set_value, G_TYPE_INT);
1743 g_value_set_int(&set_value, flash);
1744 cam_handle_value_set(ad, PROP_FLASH, &set_value);
1748 case PROP_PHOTO_RESOLUTION:
1750 gint tempval = g_value_get_int(value);
1752 DEBUG_TRACE("*******************************************************");
1753 DEBUG_TRACE("value set : PROP_RESOLUTION setting");
1754 DEBUG_TRACE(" tempval = %d ", tempval);
1755 DEBUG_TRACE("CAM_RESOLUTION_W = %d ,CAM_RESOLUTION_H=%d ", CAM_RESOLUTION_W(tempval), CAM_RESOLUTION_H(tempval));
1756 DEBUG_TRACE("*******************************************************");
1758 if (!cam_app_reset_resolution(ad, CAM_RESOLUTION_W(tempval), CAM_RESOLUTION_H(tempval), FALSE)) {
1759 cam_warning(LOG_UI, "resolution set fail");
1763 settings_guideline_refresh(ad);
1765 camapp->photo_resolution = tempval;
1767 if (camapp->self_portrait == FALSE) {
1768 camapp->reserved_setting_data.rear_photo_resolution = tempval;
1769 if (camapp->camera_mode == CAM_CAMERA_MODE) {
1770 cam_config_set_int(PROP_PHOTO_RESOLUTION_NAME, tempval);
1773 camapp->reserved_setting_data.front_photo_resolution = tempval;
1774 cam_config_set_int(PROP_SELF_PHOTO_RESOLUTION_NAME, tempval);
1777 cam_app_get_preview_offset_coordinate(ad);
1778 ad->remained_count = cam_system_get_still_count_by_resolution(ad);
1779 indicator_update_remain_count(ad);
1782 case PROP_VIDEO_RESOLUTION:
1784 gint tempval = g_value_get_int(value);
1786 camapp->video_resolution = tempval;
1788 if (camapp->self_portrait == FALSE) {
1789 camapp->reserved_setting_data.rear_video_resolution = tempval;
1790 if (camapp->recording_mode == CAM_RECORD_NORMAL) {
1791 cam_config_set_int(PROP_VIDEO_RESOLUTION_NAME, tempval);
1794 camapp->reserved_setting_data.front_video_resolution = tempval;
1795 if (camapp->recording_mode == CAM_RECORD_SELF) {
1796 cam_config_set_int(PROP_SELF_VIDEO_RESOLUTION_NAME, tempval);
1802 { /* fps may not set it alone */
1803 gint tempval = g_value_get_int(value);
1804 if (!cam_mm_set_fps(tempval)) {
1805 cam_warning(LOG_UI, "fps set fail");
1808 camapp->fps = tempval;
1811 case PROP_BRIGHTNESS:
1813 gint tempval = g_value_get_int(value);
1814 if (!cam_mm_set_brightness(tempval)) {
1815 cam_warning(LOG_UI, "brightness set fail");
1818 camapp->brightness = tempval;
1823 gint tempval = g_value_get_int(value);
1824 if (!cam_mm_set_white_balance(tempval)) {
1826 "white balance set fail: %d",
1831 camapp->white_balance = tempval;
1833 if (camapp->self_portrait)
1834 camapp->reserved_setting_data.front_wb = tempval;
1836 camapp->reserved_setting_data.rear_wb = tempval;
1842 gint tempval = g_value_get_int(value);
1843 if (!cam_mm_set_iso(tempval)) {
1844 cam_warning(LOG_UI, "iso set fail");
1847 camapp->iso = tempval;
1848 cam_config_set_int(PROP_ISO_NAME, tempval);
1851 case PROP_AUTO_CONTRAST:
1853 gboolean tempval = g_value_get_boolean(value);
1854 if (!cam_mm_enable_auto_contrast(tempval)) {
1855 cam_warning(LOG_UI, "contrast set fail");
1858 camapp->auto_contrast = tempval;
1859 cam_config_set_int(PROP_AUTO_CONTRAST_NAME, tempval);
1864 gint tempval = g_value_get_int(value);
1865 if (!cam_mm_set_auto_exposure(tempval)) {
1866 cam_warning(LOG_UI, "auto_exposure set fail");
1869 camapp->auto_exposure = tempval;
1870 cam_config_set_int(PROP_METERING_NAME, tempval);
1875 gint tempval = g_value_get_int(value);
1876 if (!cam_mm_set_effect(tempval)) {
1877 cam_warning(LOG_UI, "effect set fail : %d",
1881 camapp->effect = tempval;
1883 if (camapp->self_portrait == FALSE) {
1884 camapp->reserved_setting_data.rear_effect = tempval;
1886 camapp->reserved_setting_data.front_effect = tempval;
1892 gint tempval = g_value_get_int(value);
1893 gint oldval = cam_config_get_int(PROP_AF_NAME, CAM_FOCUS_AUTO);
1894 if (oldval == CAM_FOCUS_FACE && tempval != CAM_FOCUS_FACE) {
1895 cam_mm_stop_camera_face_detection();
1896 cam_app_stop_video_stream();
1899 if (tempval == CAM_FOCUS_FACE) {
1900 if (!cam_mm_set_focus_mode(CAMERA_ATTR_AF_NORMAL)) {
1901 cam_warning(LOG_UI, "detect mode set fail");
1905 /*start face detection*/
1906 if (cam_mm_is_supported_face_detection()) {
1907 cam_mm_start_camera_face_detection(camapp->face_detect_cb, (void *)ad);
1908 if (!cam_mm_set_preview_cb(cam_face_detection_focus_start_stream, (void*)ad)) {
1909 DEBUG_TRACE("preview callback set error");
1911 cam_app_run_video_stream();
1913 DEBUG_TRACE("not support face detect mode");
1917 } else if ((tempval == CAM_FOCUS_AUTO) || (tempval == CAM_FOCUS_MACRO)) {
1918 if (!cam_mm_set_focus_mode(tempval)) {
1919 cam_warning(LOG_UI, "af mode set fail");
1923 if (!cam_mm_set_preview_cb(camapp->preview_cb, (void*)ad)) {
1924 DEBUG_TRACE("preview callback set error");
1928 cam_warning(LOG_UI, "unknow af mode : %d", tempval);
1931 camapp->af_mode = tempval;
1932 cam_app_focus_guide_update(ad);
1933 if (camapp->camera_mode == CAM_CAMERA_MODE && camapp->shooting_mode == CAM_SINGLE_MODE){
1934 cam_config_set_int(PROP_AF_NAME, tempval);
1940 gboolean tempval = g_value_get_boolean(value);
1942 if (!cam_mm_set_anti_hand_shake(tempval)) {
1943 cam_warning(LOG_UI, "anti_shake set fail");
1947 camapp->anti_shake = tempval;
1948 cam_config_set_int(PROP_AHS_NAME, tempval);
1951 case PROP_WDR:/*auto contrast*/
1953 gint tempval = g_value_get_int(value);
1954 if (!cam_mm_set_wdr(tempval)) {
1955 cam_warning(LOG_UI, "wdr set fail");
1958 camapp->wdr = tempval;
1959 cam_config_set_int(PROP_WDR_NAME, tempval);
1964 gint tempval = g_value_get_int(value);
1965 if (!cam_mm_set_flash(tempval)) {
1966 cam_warning(LOG_UI, "flash set fail");
1969 camapp->flash = tempval;
1970 /*fix me ,why only when in camera single mode ,
1971 save the FLASH setting value to config file*/
1972 if ((camapp->camera_mode == CAM_CAMERA_MODE
1973 && camapp->shooting_mode == CAM_SINGLE_MODE)
1974 || camapp->camera_mode == CAM_CAMCORDER_MODE) {
1975 cam_config_set_int(PROP_FLASH_NAME, tempval);
1981 gint tempval = g_value_get_int(value);
1982 camapp->timer = tempval;
1985 case PROP_IMAGE_QUALITY:
1987 gint tempval = g_value_get_int(value);
1988 if (!cam_mm_set_image_enc_quality(tempval)) {
1990 "image quality[%d] set fail",
1994 camapp->image_quality = tempval;
1997 case PROP_VIDEO_QUALITY:
1999 gint tempval = g_value_get_int(value);
2000 if (!cam_app_set_video_quality(ad, tempval)) {
2002 "video quality[%d] set fail",
2006 camapp->video_quality = tempval;
2009 case PROP_AUDIO_REC:
2011 gboolean tempval = g_value_get_boolean(value);
2012 if (!cam_mm_set_audio_recording(tempval)) {
2013 cam_warning(LOG_UI, "audio_recording set fail");
2016 camapp->audio_recording = tempval;
2019 case PROP_AUDIO_QUALITY:
2021 gint tempval = g_value_get_int(value);
2022 camapp->audio_quality = tempval;
2025 case PROP_BATTERY_CHARG:
2027 gint tempval_charging = g_value_get_int(value);
2029 DEBUG_TRACE("charging = %d", tempval_charging);
2030 camapp->battery_charging = tempval_charging;
2031 camapp->battery_level = cam_utils_get_battery_level();
2032 indicator_update_battery(ad, camapp->battery_level);
2035 case PROP_BATTERY_LEVEL:
2037 gint tempval = g_value_get_int(value);
2038 camapp->battery_charging = cam_utils_get_charging_status();
2039 camapp->battery_level = tempval;
2040 indicator_update_battery(ad, camapp->battery_level);
2046 gint tempval = g_value_get_int(value);
2047 DEBUG_TRACE("tempval:%d", tempval);
2048 if (!cam_mm_set_zoom(tempval)) {
2049 cam_warning(LOG_UI, "zoom set fail");
2052 /*camapp->zoom_mode = tempval;*/ /*note: zoom_mode is zoom level, is not same this value*/
2057 gint tempval = g_value_get_int(value);
2059 camapp->storage = tempval;
2061 vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT, camapp->storage);
2062 // cam_config_set_int(PROP_STORAGE_NAME, tempval);
2064 indicator_update_storage(ad);
2067 case PROP_GUIDELINE:
2069 gboolean tempval = g_value_get_boolean(value);
2071 camapp->guideline = tempval;
2072 cam_config_set_boolean(PROP_GUIDELINE_NAME, tempval);
2077 gboolean tempval = g_value_get_boolean(value);
2080 camapp->need_gps_popup = TRUE;
2081 if (!cam_app_lbs_start(ad))
2086 if (ad->gps_animation_timer)
2087 REMOVE_TIMER(ad->gps_animation_timer);
2088 if (!cam_app_lbs_stop(ad))
2095 case PROP_GPS_LEVEL:
2097 gint tempval = g_value_get_int(value);
2099 camapp->gps_level = tempval;
2100 indicator_update_gps_level(ad);
2105 gboolean tempval = g_value_get_boolean(value);
2106 camapp->review = tempval;
2107 cam_config_set_boolean(PROP_REVIEW_NAME, tempval);
2110 case PROP_IMAGE_COUNT:
2112 gint tempval = g_value_get_int(value);
2113 if (!cam_mm_set_image_count(tempval)) {
2114 cam_warning(LOG_UI, "image_count set fail");
2117 camapp->image_count = tempval;
2120 case PROP_SHUTTER_SOUND:
2122 gint tempval = g_value_get_int(value);
2123 camapp->shutter_sound = tempval;
2126 case PROP_SIZE_LIMIT:
2128 gint tempval = g_value_get_int(value);
2129 if (!cam_app_set_size_limit(tempval, camapp->size_limit_type)) {
2130 cam_warning(LOG_UI, "size_limit set fail");
2133 camapp->size_limit = tempval;
2136 case PROP_SIZE_LIMIT_TYPE:
2138 gint tempval = g_value_get_int(value);
2139 camapp->size_limit_type = tempval;
2144 guint tempval = g_value_get_uint(value);
2145 camapp->rec_elapsed = tempval;
2148 case PROP_REC_FILE_SIZE:
2150 guint tempval = g_value_get_uint(value);
2151 camapp->rec_filesize = tempval;
2154 case PROP_OUTDOOR_VISIBILITY:
2156 gboolean tempval = g_value_get_boolean(value);
2157 cam_mm_set_outdoor_visibility(tempval);
2158 camapp->outdoor_visibility = tempval;
2161 case PROP_VOLUME_KEY:
2163 gint tempval = g_value_get_int(value);
2164 camapp->volume_key = tempval;
2165 cam_config_set_int(PROP_VOLUME_KEY_NAME, tempval);
2168 case PROP_SAVE_AS_FLIP:
2170 gboolean tempval = g_value_get_boolean(value);
2172 if (camapp->camera_mode == CAM_CAMERA_MODE) {
2173 cam_app_preview_stop();
2174 cam_mm_set_image_flip(tempval);
2175 cam_app_preview_start(ad);
2178 camapp->save_as_flip= tempval;
2181 case PROP_BURST_SHOT:
2183 gboolean tempval = g_value_get_boolean(value);
2185 camapp->burst_shot = tempval;
2186 cam_config_set_boolean(PROP_BURST_SHOT_NAME, tempval);
2190 cam_warning(LOG_UI, "unknow type :%d ", type);
2194 /* indicator should be updated here!!! */
2195 /* change_indicator_mode_icons(ad); */
2199 /*note: in this function ,just do data logic,please do not add any EFL code in it*/
2200 gboolean cam_app_mode_change(void *data, int to_mode)
2202 struct appdata *ad = (struct appdata *)data;
2203 cam_retv_if(ad == NULL, FALSE);
2204 CamAppData *camapp = ad->camapp_handle;
2205 cam_retv_if(camapp == NULL, FALSE);
2207 debug_fenter(LOG_UI);
2209 ad->timer_activated = FALSE;
2210 ad->emit_continuous_shutter = FALSE;;
2211 /*camapp->guideline = FALSE;*/
2212 cam_app_timeout_checker_remove();
2213 /* draw to_mode icon in preview area */
2214 #ifdef USE_CAMERA_APP_SHUTTER_SOUND
2215 if (ad->play_rec_sound != 0)
2219 if (cam_mm_get_state() == CAMERA_STATE_CAPTURING
2220 && (camapp->camera_mode == CAM_CAMERA_MODE)) {
2221 cam_mm_capture_stop(true, CAM_CAMERA_MODE);
2224 /* stop preview and destory mmfw handle */
2225 if (!cam_app_preview_stop()) {
2226 cam_critical(LOG_MM, "cam_app_preview_stop faild");
2227 goto MODE_CHANGE_FAILED;
2231 /* Idler of capture callback management. wh01.cho@samsung.com. 2010-12-15. */
2232 cam_utils_remove_idler_all(ad);
2234 if (to_mode == CAM_CAMCORDER_MODE) {
2236 camapp->camera_mode = CAM_CAMCORDER_MODE;
2238 GValue value = { 0, };
2239 g_value_init(&value, G_TYPE_INT);
2241 ad->last_camera_zoom_mode = camapp->zoom_mode;
2243 switch(camapp->recording_mode)
2245 case CAM_RECORD_SLOW:
2246 case CAM_RECORD_FAST:
2248 ad->camapp_handle->enable_touch_af = FALSE;
2249 camapp->video_resolution = CAM_RESOLUTION_QVGA;
2250 camapp->photo_resolution = cam_app_get_max_image_size_by_ratio(ad, camapp->video_resolution);
2254 if (camapp->recording_mode == CAM_RECORD_SLOW) {
2255 g_value_set_int(&value, SLOW_MOTION_REC_FPS);
2256 rate = SLOW_MOTION_PLAY_FPS;
2258 g_value_set_int(&value, FAST_MOTION_REC_FPS);
2259 rate = FAST_MOTION_PLAY_FPS;
2262 if (!cam_mm_set_recording_motion(rate)) {
2263 cam_critical(LOG_UI, "slow motion set fail");
2267 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2268 cam_critical(LOG_UI, "fps set fail");
2273 g_value_set_int(&value, CAM_RESOLUTION_QVGA);
2274 if (!cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &value)) {
2275 cam_critical(LOG_UI, "fps set fail");
2280 g_value_set_int(&value, REC_SIZE_LIMIT_DEFAULT);
2281 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2282 cam_critical(LOG_UI, "size limit set fail");
2286 if (camapp->zoom_mode != 1) {
2287 camapp->zoom_mode = 1;
2289 CAM_GVALUE_SET_INT(value, 10);
2290 if (!cam_handle_value_set(ad, PROP_ZOOM, &value)) {
2291 cam_critical(LOG_UI, "zoom set fail");
2297 case CAM_RECORD_SELF:
2299 ad->camapp_handle->enable_touch_af = FALSE;
2300 camapp->video_resolution = cam_config_get_int(PROP_SELF_VIDEO_RESOLUTION_NAME, SELF_REC_RESOLUTION_DEFAULT);
2301 camapp->photo_resolution = cam_app_get_max_image_size_by_ratio(ad, camapp->video_resolution);
2303 g_value_set_int(&value, FPS_DEFAULT);
2305 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2306 cam_critical(LOG_UI, "fps set fail");
2311 g_value_set_int(&value, CAM_RESOLUTION_VGA);
2312 if (!cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &value)) {
2313 cam_critical(LOG_UI, "resolution set fail");
2318 g_value_set_int(&value, REC_SIZE_LIMIT_DEFAULT);
2319 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2320 cam_critical(LOG_UI, "size limit set fail");
2324 if (!cam_mm_reset_recording_motion_fps()) {
2325 cam_critical(LOG_UI,
2326 "slow motion fps set fail");
2331 case CAM_RECORD_MMS:
2332 case CAM_RECORD_SELF_MMS:
2334 ad->camapp_handle->enable_touch_af = TRUE;
2335 camapp->video_resolution = CAM_RESOLUTION_QCIF;
2336 camapp->photo_resolution = cam_app_get_max_image_size_by_ratio(ad, camapp->video_resolution);
2338 g_value_set_int(&value, FPS_SLOW);
2339 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2340 cam_critical(LOG_UI, "fps set fail");
2345 g_value_set_int(&value, CAM_RESOLUTION_QCIF);
2346 if (!cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &value)) {
2347 cam_critical(LOG_UI, "resolution set fail");
2352 g_value_set_int(&value, CAM_REC_MMS_MAX_SIZE);
2353 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2354 cam_critical(LOG_UI, "size limit set fail");
2358 if (!cam_mm_reset_recording_motion_fps()) {
2359 cam_critical(LOG_UI,
2360 "slow motion fps set fail");
2365 case CAM_RECORD_NORMAL:
2367 ad->camapp_handle->enable_touch_af = TRUE;
2368 camapp->video_resolution = cam_config_get_int(PROP_VIDEO_RESOLUTION_NAME, REC_RESOLUTION_DEFAULT);
2369 camapp->photo_resolution = cam_app_get_max_image_size_by_ratio(ad, camapp->video_resolution);
2371 g_value_set_int(&value, FPS_DEFAULT);
2372 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2373 cam_critical(LOG_UI, "fps set fail");
2378 g_value_set_int(&value, resolution_n);
2379 if (!cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &value)) {
2380 cam_critical(LOG_UI, "resolution set fail");
2385 g_value_set_int(&value, REC_SIZE_LIMIT_DEFAULT);
2386 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2387 cam_critical(LOG_UI, "size limit set fail");
2391 if (!cam_mm_reset_recording_motion_fps()) {
2392 cam_critical(LOG_UI,
2393 "slow motion fps set fail");
2402 camapp->camera_mode = CAM_CAMERA_MODE;
2403 camapp->zoom_mode = ad->last_camera_zoom_mode;
2405 switch (camapp->shooting_mode) {
2406 case CAM_SINGLE_MODE:
2407 ad->camapp_handle->enable_touch_af = TRUE;
2408 camapp->photo_resolution = cam_config_get_int(PROP_PHOTO_RESOLUTION_NAME, IMAGE_RESOLUTION_DEFAULT);
2410 case CAM_SELF_SINGLE_MODE:
2411 ad->camapp_handle->enable_touch_af = FALSE;
2412 camapp->photo_resolution = cam_config_get_int(PROP_SELF_PHOTO_RESOLUTION_NAME, SELF_IMAGE_RESOLUTION_DEFAULT);
2419 if (!cam_callback_init(ad)) {
2420 cam_critical(LOG_MM, "cam_init_mm_callback failed");
2421 goto MODE_CHANGE_FAILED;
2424 DEBUG_TRACE("camera mode = %d", to_mode);
2425 if (!cam_app_init_attribute(ad, to_mode)) {
2426 cam_critical(LOG_MM, "cam_app_init_attribute failed");
2429 if (!cam_app_preview_start(ad)) {
2430 cam_critical(LOG_MM, "cam_app_preview_start failed");
2431 goto MODE_CHANGE_FAILED;
2434 cam_app_timeout_checker_init(ad);
2439 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_START_CAMERA"), cam_app_timeout_notice_response_cb);
2444 gboolean cam_mode_change(void *data, int to_mode)
2446 struct appdata *ad = (struct appdata *)data;
2447 cam_retv_if(ad == NULL, FALSE);
2448 CamAppData *camapp = ad->camapp_handle;
2449 cam_retv_if(camapp == NULL, FALSE);
2451 debug_fenter(LOG_UI);
2453 cam_elm_cache_flush();
2455 evas_object_hide(ad->timer_icon_edje);
2456 REMOVE_TIMER(ad->timer_timer);
2457 ad->timer_activated = FALSE;
2458 ad->emit_continuous_shutter = FALSE;
2459 DEL_EVAS_OBJECT(ad->timer_icon_edje);
2460 DEL_EVAS_OBJECT(ad->guideline_edje);
2461 /*camapp->guideline = FALSE;*/
2462 cam_app_timeout_checker_remove();
2463 /* draw to_mode icon in preview area */
2464 #ifdef USE_CAMERA_APP_SHUTTER_SOUND
2465 if (ad->play_rec_sound != 0)
2469 if (cam_mm_get_state() == CAMERA_STATE_CAPTURING
2470 && (camapp->camera_mode == CAM_CAMERA_MODE)) {
2471 cam_mm_capture_stop(true, CAM_CAMERA_MODE);
2474 cam_app_destroy_progressbar(ad);
2475 toolbar_shot_guide_popup_destory(ad);
2477 /* stop preview and destory mmfw handle */
2478 if (!cam_app_preview_stop()) {
2479 cam_critical(LOG_MM, "cam_app_preview_stop faild");
2480 goto MODE_CHANGE_FAILED;
2484 /* Idler of capture callback management. wh01.cho@samsung.com. 2010-12-15. */
2485 cam_utils_remove_idler_all(ad);
2487 if (to_mode == CAM_CAMCORDER_MODE) {
2489 camapp->camera_mode = CAM_CAMCORDER_MODE;
2491 GValue value = { 0, };
2492 g_value_init(&value, G_TYPE_INT);
2494 ad->last_camera_zoom_mode = camapp->zoom_mode;
2496 switch(camapp->recording_mode)
2498 case CAM_RECORD_SLOW:
2499 case CAM_RECORD_FAST:
2501 ad->camapp_handle->enable_touch_af = FALSE;
2502 camapp->video_resolution = CAM_RESOLUTION_QVGA;
2503 camapp->photo_resolution = cam_app_get_max_image_size_by_ratio(ad, camapp->video_resolution);
2507 if (camapp->recording_mode == CAM_RECORD_SLOW) {
2508 g_value_set_int(&value, SLOW_MOTION_REC_FPS);
2509 rate = SLOW_MOTION_PLAY_FPS;
2511 g_value_set_int(&value, FAST_MOTION_REC_FPS);
2512 rate = FAST_MOTION_PLAY_FPS;
2515 if (!cam_mm_set_recording_motion(rate)) {
2516 cam_critical(LOG_UI, "slow motion set fail");
2520 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2521 cam_critical(LOG_UI, "fps set fail");
2526 g_value_set_int(&value, CAM_RESOLUTION_QVGA);
2527 if (!cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &value)) {
2528 cam_critical(LOG_UI, "fps set fail");
2533 g_value_set_int(&value, REC_SIZE_LIMIT_DEFAULT);
2534 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2535 cam_critical(LOG_UI, "size limit set fail");
2539 if (camapp->zoom_mode != 1) {
2540 camapp->zoom_mode = 1;
2542 CAM_GVALUE_SET_INT(value, 10);
2543 if (!cam_handle_value_set(ad, PROP_ZOOM, &value)) {
2544 cam_critical(LOG_UI, "zoom set fail");
2550 case CAM_RECORD_SELF:
2552 ad->camapp_handle->enable_touch_af = FALSE;
2553 camapp->video_resolution = cam_config_get_int(PROP_SELF_VIDEO_RESOLUTION_NAME, SELF_REC_RESOLUTION_DEFAULT);
2554 camapp->photo_resolution = cam_app_get_max_image_size_by_ratio(ad, camapp->video_resolution);
2556 g_value_set_int(&value, FPS_DEFAULT);
2558 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2559 cam_critical(LOG_UI, "fps set fail");
2564 g_value_set_int(&value, CAM_RESOLUTION_VGA);
2565 if (!cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &value)) {
2566 cam_critical(LOG_UI, "resolution set fail");
2571 g_value_set_int(&value, REC_SIZE_LIMIT_DEFAULT);
2572 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2573 cam_critical(LOG_UI, "size limit set fail");
2577 if (!cam_mm_reset_recording_motion_fps()) {
2578 cam_critical(LOG_UI,
2579 "slow motion fps set fail");
2584 case CAM_RECORD_MMS:
2585 case CAM_RECORD_SELF_MMS:
2587 ad->camapp_handle->enable_touch_af = TRUE;
2588 camapp->video_resolution = CAM_RESOLUTION_QCIF;
2589 camapp->photo_resolution = cam_app_get_max_image_size_by_ratio(ad, camapp->video_resolution);
2591 g_value_set_int(&value, FPS_SLOW);
2592 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2593 cam_critical(LOG_UI, "fps set fail");
2598 g_value_set_int(&value, CAM_RESOLUTION_QCIF);
2599 if (!cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &value)) {
2600 cam_critical(LOG_UI, "resolution set fail");
2605 g_value_set_int(&value, CAM_REC_MMS_MAX_SIZE);
2606 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2607 cam_critical(LOG_UI, "size limit set fail");
2611 if (!cam_mm_reset_recording_motion_fps()) {
2612 cam_critical(LOG_UI,
2613 "slow motion fps set fail");
2618 case CAM_RECORD_NORMAL:
2620 ad->camapp_handle->enable_touch_af = TRUE;
2621 camapp->video_resolution = cam_config_get_int(PROP_VIDEO_RESOLUTION_NAME, REC_RESOLUTION_DEFAULT);
2622 camapp->photo_resolution = cam_app_get_max_image_size_by_ratio(ad, camapp->video_resolution);
2624 g_value_set_int(&value, FPS_DEFAULT);
2625 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2626 cam_critical(LOG_UI, "fps set fail");
2631 g_value_set_int(&value, resolution_n);
2632 if (!cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &value)) {
2633 cam_critical(LOG_UI, "resolution set fail");
2638 g_value_set_int(&value, REC_SIZE_LIMIT_DEFAULT);
2639 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2640 cam_critical(LOG_UI, "size limit set fail");
2644 if (!cam_mm_reset_recording_motion_fps()) {
2645 cam_critical(LOG_UI,
2646 "slow motion fps set fail");
2655 camapp->camera_mode = CAM_CAMERA_MODE;
2656 camapp->zoom_mode = ad->last_camera_zoom_mode;
2658 switch (camapp->shooting_mode) {
2659 case CAM_SINGLE_MODE:
2660 ad->camapp_handle->enable_touch_af = TRUE;
2661 camapp->photo_resolution = cam_config_get_int(PROP_PHOTO_RESOLUTION_NAME, IMAGE_RESOLUTION_DEFAULT);
2663 case CAM_SELF_SINGLE_MODE:
2664 ad->camapp_handle->enable_touch_af = FALSE;
2665 camapp->photo_resolution = cam_config_get_int(PROP_SELF_PHOTO_RESOLUTION_NAME, SELF_IMAGE_RESOLUTION_DEFAULT);
2672 if (!cam_callback_init(ad)) {
2673 cam_critical(LOG_MM, "cam_init_mm_callback failed");
2674 goto MODE_CHANGE_FAILED;
2677 DEBUG_TRACE("camera mode = %d", to_mode);
2678 if (!cam_app_init_attribute(ad, to_mode)) {
2679 cam_critical(LOG_MM, "cam_app_init_attribute failed");
2682 cam_app_get_preview_offset_coordinate(ad);
2684 cam_reset_focus_mode(ad);
2686 if (!cam_app_preview_start(ad)) {
2687 cam_critical(LOG_MM, "cam_app_preview_start failed");
2688 goto MODE_CHANGE_FAILED;
2691 cam_app_timeout_checker_init(ad);
2696 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_START_CAMERA"), cam_app_timeout_notice_response_cb);
2700 gboolean cam_recording_mode_change(void *data, int rec_mode)
2702 struct appdata *ad = (struct appdata *)data;
2703 CamAppData *camapp = NULL;
2704 //CamDeviceType device_type = CAM_DEVICE_MEGA;
2705 GValue value = { 0 };
2707 gboolean cam_reset = FALSE;
2709 debug_fenter(LOG_CAM);
2711 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
2712 camapp = ad->camapp_handle;
2713 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
2715 cam_app_timeout_checker_remove();
2717 g_value_init(&value, G_TYPE_INT);
2719 cam_mm_get_video_device(&video_dev);
2720 if (((camapp->recording_mode == CAM_RECORD_SELF || camapp->recording_mode == CAM_RECORD_SELF_MMS )&& video_dev == CAM_DEVICE_MEGA)
2721 || ((camapp->recording_mode != CAM_RECORD_SELF || camapp->recording_mode == CAM_RECORD_SELF_MMS) && video_dev == CAM_DEVICE_VGA)) {
2723 /* stop preview and destory mmfw handle */
2725 if (!cam_app_preview_stop()) {
2726 cam_critical(LOG_MM, "cam_app_preview_stop faild");
2729 if (!cam_mm_destory()) {
2730 cam_critical(LOG_MM, "cam_mm_destory faild");
2734 if (camapp->recording_mode == CAM_RECORD_SELF ||camapp->recording_mode == CAM_RECORD_SELF_MMS ) {
2735 device_type = CAM_DEVICE_VGA;
2737 device_type = CAM_DEVICE_MEGA;
2740 if (!cam_mm_create(camapp->device_type, camapp->camera_mode)) {
2741 cam_critical(LOG_MM, "cam_mm_create failed");
2742 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_START_CAMERA"), cam_app_timeout_notice_response_cb);
2745 cam_mm_get_video_size( &camapp->default_preview_width, &camapp->default_preview_height);
2746 DEBUG_TRACE("default_width = %d,default_height = %d", camapp->default_preview_width, camapp->default_preview_height);
2749 if (!cam_app_preview_stop()) {
2750 cam_critical(LOG_MM, "cam_app_preview_stop faild");
2754 if (rec_mode == CAM_RECORD_SLOW || rec_mode == CAM_RECORD_FAST) {
2755 ad->camapp_handle->enable_touch_af = FALSE;
2759 if (rec_mode == CAM_RECORD_SLOW) {
2760 g_value_set_int(&value, SLOW_MOTION_REC_FPS);
2761 rate = SLOW_MOTION_PLAY_FPS;
2763 g_value_set_int(&value, FAST_MOTION_REC_FPS);
2764 rate = FAST_MOTION_PLAY_FPS;
2767 if (!cam_mm_set_recording_motion(rate)) {
2768 cam_critical(LOG_UI, "slow motion set fail");
2772 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2773 cam_critical(LOG_UI, "fps set fail");
2777 g_value_set_int(&value, CAM_RESOLUTION_QVGA);
2778 if (!cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &value)) {
2779 cam_critical(LOG_UI, "resolution set fail");
2782 g_value_set_int(&value, REC_SIZE_LIMIT_DEFAULT);
2783 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2784 cam_critical(LOG_UI, "size limit set fail");
2788 if (camapp->zoom_mode != 1) {
2789 camapp->zoom_mode = 1;
2791 GValue value = { 0, };
2793 CAM_GVALUE_SET_INT(value, 10);
2794 if (!cam_handle_value_set(ad, PROP_ZOOM, &value)) {
2795 cam_critical(LOG_UI, "zoom set fail");
2800 camapp->recording_mode = rec_mode;
2803 ad->camapp_handle->enable_touch_af = TRUE;
2805 if(rec_mode == CAM_RECORD_SELF) {
2807 ad->camapp_handle->enable_touch_af = FALSE;
2808 g_value_set_int(&value, FPS_SLOW);
2809 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2810 cam_critical(LOG_UI, "fps set fail");
2814 int resolution = cam_config_get_int(PROP_SELF_VIDEO_RESOLUTION_NAME, SELF_REC_RESOLUTION_DEFAULT);
2816 g_value_set_int(&value, resolution);
2817 if (!cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &value)) {
2818 cam_critical(LOG_UI, "resolution set fail");
2822 g_value_set_int(&value, REC_SIZE_LIMIT_DEFAULT);
2823 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2824 cam_critical(LOG_UI, "size limit set fail");
2828 if (!cam_mm_reset_recording_motion_fps()) {
2829 cam_critical(LOG_UI,
2830 "slow motion fps set fail");
2833 camapp->recording_mode = CAM_RECORD_SELF;
2834 } else if (rec_mode == CAM_RECORD_MMS ||rec_mode == CAM_RECORD_SELF_MMS ) {
2835 g_value_set_int(&value, FPS_SLOW);
2836 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2837 cam_critical(LOG_UI, "fps set fail");
2841 g_value_set_int(&value, CAM_RESOLUTION_QCIF);
2842 if (!cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &value)) {
2843 cam_critical(LOG_UI, "resolution set fail");
2847 g_value_set_int(&value, CAM_REC_MMS_MAX_SIZE);
2848 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2849 cam_critical(LOG_UI, "size limit set fail");
2853 if (!cam_mm_reset_recording_motion_fps()) {
2854 cam_critical(LOG_UI,
2855 "slow motion fps set fail");
2858 if (rec_mode == CAM_RECORD_MMS)
2859 camapp->recording_mode = CAM_RECORD_MMS;
2861 camapp->recording_mode = CAM_RECORD_SELF_MMS;
2865 cam_config_get_int(PROP_VIDEO_RESOLUTION_NAME, REC_RESOLUTION_DEFAULT);
2867 g_value_set_int(&value, FPS_DEFAULT);
2868 if (!cam_handle_value_set(ad, PROP_FPS, &value)) {
2869 cam_critical(LOG_UI, "fps set fail");
2873 g_value_set_int(&value, resolution_n);
2874 if (!cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &value)) {
2875 cam_critical(LOG_UI, "resolution set fail");
2879 g_value_set_int(&value, REC_SIZE_LIMIT_DEFAULT);
2880 if (!cam_handle_value_set(ad, PROP_SIZE_LIMIT, &value)) {
2881 cam_critical(LOG_UI, "size limit set fail");
2885 if (!cam_mm_reset_recording_motion_fps()) {
2886 cam_critical(LOG_UI,
2887 "slow motion fps set fail");
2890 camapp->recording_mode = CAM_RECORD_NORMAL;
2894 if (!cam_app_init_attribute(ad, camapp->camera_mode)) {
2895 cam_critical(LOG_MM, "cam_app_init_attribute failed");
2899 if (!cam_app_set_recording_mode(ad, rec_mode)) {
2900 DEBUG_TRACE("cam_app_set_recording_mode failed");
2905 cam_app_get_preview_offset_coordinate(ad);
2907 if (!cam_callback_init(ad)) {
2908 cam_critical(LOG_MM, "cam_init_mm_callback failed");
2909 cam_app_notice_popup(ad, "PREVIEW START FAILED !!", cam_app_timeout_notice_response_cb);
2913 cam_continuous_af_start(ad);
2914 if (!cam_app_preview_start(ad)) {
2915 cam_critical(LOG_MM, "cam_app_preview_start failed");
2916 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_START_CAMERA"), cam_app_timeout_notice_response_cb);
2920 cam_app_timeout_checker_init(ad);
2926 static gboolean cam_app_set_capture_format_shooting_mode(int mode)
2929 case CAM_SINGLE_MODE:
2930 case CAM_SELF_SINGLE_MODE:
2931 if (!cam_mm_set_capture_format(CAMERA_PIXEL_FORMAT_JPEG))
2939 "\n################# shooting mode set return success : %d\n",
2945 static void cam_shooting_mode_reset(void *data)
2947 struct appdata *ad = (struct appdata *)data;
2948 CamAppData *camapp = NULL;
2950 debug_fenter(LOG_CAM);
2951 cam_retm_if(ad == NULL, "appdata is NULL");
2952 camapp = ad->camapp_handle;
2953 cam_retm_if(camapp == NULL, "camapp_handle is NULL");
2955 cam_app_destroy_progressbar(ad);
2960 gboolean cam_shooting_mode_change(void *data)
2962 struct appdata *ad = (struct appdata *)data;
2963 CamAppData *camapp = NULL;
2964 GValue value = { 0 };
2966 debug_fenter(LOG_CAM);
2968 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
2969 camapp = ad->camapp_handle;
2970 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
2972 cam_elm_cache_flush();
2974 cam_app_stop_video_stream();
2975 cam_app_timeout_checker_remove();
2976 cam_shooting_mode_reset(ad);
2978 g_value_init(&value, G_TYPE_INT);
2980 cam_debug(LOG_CAM, "Shooting mode = %d ", camapp->shooting_mode);
2982 cam_continuous_shot_data_free(ad);
2984 if (ad->shot_mode_guide_popup)
2985 toolbar_shot_guide_popup_destory(ad);
2986 ad->emit_continuous_shutter = FALSE;
2987 switch (camapp->shooting_mode) {
2988 case CAM_SINGLE_MODE:
2990 int resolution = 0, flash = 0, auto_focus = 0, scene_mode = 0, wb = 0, effect = 0;
2991 resolution = cam_config_get_int(PROP_PHOTO_RESOLUTION_NAME, IMAGE_RESOLUTION_DEFAULT);
2992 flash = cam_config_get_int(PROP_FLASH_NAME, FLASH_DEFAULT);
2993 auto_focus = cam_config_get_int(PROP_AF_NAME, AF_DEFAULT);
2994 scene_mode = cam_config_get_int(PROP_SCENE_MODE_NAME, PG_MODE_DEFAULT);
2995 wb = camapp->reserved_setting_data.rear_wb;
2996 effect = camapp->reserved_setting_data.rear_effect;
2998 /* set resolution */
2999 g_value_set_int(&value, resolution);
3000 cam_handle_value_set(ad, PROP_PHOTO_RESOLUTION, &value);
3003 g_value_set_int(&value, flash);
3004 cam_handle_value_set(ad, PROP_FLASH, &value);
3006 /* set auto focus */
3007 g_value_set_int(&value, auto_focus);
3008 cam_handle_value_set(ad, PROP_AF_MODE, &value);
3011 g_value_set_int(&value, scene_mode);
3012 cam_handle_value_set(ad, PROP_SCENE_MODE, &value);
3015 g_value_set_int(&value, wb);
3016 cam_handle_value_set(ad, PROP_WB, &value);
3019 g_value_set_int(&value, effect);
3020 cam_handle_value_set(ad, PROP_EFFECT, &value);
3022 /* set capture count */
3023 g_value_set_int(&value, IMAGE_COUNT_DEFAULT);
3024 cam_handle_value_set(ad, PROP_IMAGE_COUNT, &value);
3028 case CAM_SELF_SINGLE_MODE:
3030 int resolution, effect, wb = 0;
3032 resolution = cam_config_get_int(PROP_SELF_PHOTO_RESOLUTION_NAME, SELF_IMAGE_RESOLUTION_DEFAULT);
3033 effect = camapp->reserved_setting_data.front_effect;
3034 wb = camapp->reserved_setting_data.front_wb;
3036 /* set resolution */
3037 g_value_set_int(&value, resolution);
3038 cam_handle_value_set(ad, PROP_PHOTO_RESOLUTION, &value);
3041 g_value_set_int(&value, CAM_FLASH_OFF);
3042 cam_handle_value_set(ad, PROP_FLASH, &value);
3044 /* set auto focus */
3045 g_value_set_int(&value, CAM_FOCUS_AUTO);
3046 cam_handle_value_set(ad, PROP_AF_MODE, &value);
3048 /* set scene to NONE */
3049 g_value_set_int(&value, CAM_SCENE_NONE);
3050 cam_handle_value_set(ad, PROP_SCENE_MODE, &value);
3053 g_value_set_int(&value, effect);
3054 cam_handle_value_set(ad, PROP_EFFECT, &value);
3056 /* set capture count */
3057 g_value_set_int(&value, IMAGE_COUNT_DEFAULT);
3058 cam_handle_value_set(ad, PROP_IMAGE_COUNT, &value);
3061 g_value_set_int(&value, wb);
3062 cam_handle_value_set(ad, PROP_WB, &value);
3069 if (!cam_callback_init(ad)) {
3070 cam_critical(LOG_MM, "cam_init_mm_callback failed");
3071 cam_app_notice_popup(ad, "PREVIEW START FAILED !!", cam_app_timeout_notice_response_cb);
3075 cam_app_timeout_checker_init(ad);
3079 gboolean __cam_single_shot_reg_file(char *file_path)
3081 GError *error = NULL;
3084 DEBUG_TRACE("register file : %s", file_path);
3086 if (!cam_file_register(file_path, &error)) {
3087 cam_critical(LOG_FILE, "cam_file_register fail");
3088 if (error != NULL) {
3089 if (error->message != NULL) {
3090 cam_critical(LOG_FILE,
3091 "cam_file_register error [%s]",
3094 cam_critical(LOG_FILE,
3095 "cam_file_register error but error message is NULL");
3097 g_error_free(error);
3102 cam_warning(LOG_FILE, " file path is NULL...");
3110 static void cam_app_timer_update_count(void *data)
3112 struct appdata *ad = (struct appdata *)data;
3113 cam_retm_if(ad == NULL, "appdata is NULL");
3115 cam_debug(LOG_UI, "timer count ... [ %d ]", ad->timer_count);
3117 char count_string[3] = "";
3119 elm_object_part_content_unset(ad->ug_base, "timer_layout");
3121 if (ad->timer_icon_edje == NULL) {
3122 switch (ad->target_direction) {
3123 case CAM_TARGET_DIRECTION_LANDSCAPE:
3124 case CAM_TARGET_DIRECTION_LANDSCAPE_INVERSE:
3125 ad->timer_icon_edje = cam_app_load_edj(ad->ug_base, CAM_UTILS_EDJ_NAME, "timer_icon_landscape");
3127 case CAM_TARGET_DIRECTION_PORTRAIT:
3128 case CAM_TARGET_DIRECTION_PORTRAIT_INVERSE:
3129 ad->timer_icon_edje = cam_app_load_edj(ad->ug_base, CAM_UTILS_EDJ_NAME, "timer_icon_portrait");
3132 DEBUG_TRACE("Invalid direction type!!!");
3135 cam_retm_if(ad->timer_icon_edje == NULL, "timer_icon_edje is NULL");
3136 elm_object_part_content_set(ad->ug_base, "timer_layout", ad->timer_icon_edje);
3139 snprintf(count_string, sizeof(count_string), "%d", ad->timer_count);
3141 edje_object_part_text_set(_EDJ(ad->timer_icon_edje), "text", count_string);
3143 evas_object_show(ad->timer_icon_edje);
3147 static Eina_Bool cam_app_gps_timer_cb(void *data)
3150 struct appdata *ad = (struct appdata *)data;
3151 cam_retv_if(ad == NULL, ECORE_CALLBACK_CANCEL);
3152 CamAppData *camapp = ad->camapp_handle;
3153 if (camapp == NULL) {
3154 ad->gps_animation_timer = NULL;
3155 return ECORE_CALLBACK_CANCEL;
3158 int gps_level = CAM_LBS_STATE_DISABLE;
3159 static int count =0;
3161 gps_level = cam_lbs_get_state(); //real gps level
3162 if (gps_level >=CAM_LBS_STATE_SERVICE_ENABLE) {
3164 camapp->gps_level = cam_lbs_get_state();
3166 if (ad->gps_animation_timer)
3167 ad->gps_animation_timer = NULL;
3169 return ECORE_CALLBACK_CANCEL;
3172 indicator_update_gps_level(ad);
3173 if (camapp->gps_level == CAM_LBS_STATE_ACCURANCY_DETAILED ) {
3174 camapp->gps_level = CAM_LBS_STATE_SERVICE_START;
3177 if (count > GPS_TIME_OUT) {
3179 camapp->gps = FALSE;
3181 camapp->gps_level = cam_lbs_get_state();
3182 indicator_update_gps(ad); /* update gps icon */
3183 if(!cam_mm_remove_geo_tag())
3184 DEBUG_TRACE("cam_mm_remove_geo_tag failed");
3186 if (ad->gps_animation_timer)
3187 ad->gps_animation_timer = NULL;
3189 return ECORE_CALLBACK_CANCEL;
3191 camapp->gps_level ++;
3194 return ECORE_CALLBACK_RENEW;
3197 static Eina_Bool cam_app_timer_cb(void *data)
3199 struct appdata *ad = (struct appdata *)data;
3200 cam_retv_if(ad == NULL, ECORE_CALLBACK_CANCEL);
3202 CamAppData *camapp = NULL;
3204 camapp = ad->camapp_handle;
3205 if (camapp == NULL) {
3206 cam_critical(LOG_UI, "camapp_handle is NULL");
3208 if (ad->timer_timer)
3209 ad->timer_timer = NULL;
3210 return ECORE_CALLBACK_CANCEL;
3213 ad->timer_count = ad->timer_count - 1;
3215 if (ad->timer_count > 0) {
3216 cam_debug(LOG_UI, "timer continue ... ");
3217 cam_app_timer_update_count(ad);
3218 if (camapp->shutter_sound != CAM_SETTINGS_SOUND_OFF)
3219 cam_sound_play(CAM_SOUND_EFFECT_TICK, ad);
3220 return ECORE_CALLBACK_RENEW;
3222 cam_debug(LOG_UI, "timer terminated ...");
3224 ad->timer_activated = false;
3226 if (ad->timer_icon_edje != NULL) {
3227 evas_object_del(ad->timer_icon_edje);
3228 ad->timer_icon_edje = NULL;
3231 cam_toolbar_update(ad);
3233 if (camapp->camera_mode == CAM_CAMERA_MODE) {
3234 cam_set_orient_value(ad);
3235 if (!cam_image_capture_start(ad))
3236 cam_critical(LOG_UI, "cam_image_capture_start failed");
3238 if (!cam_video_record_start(ad))
3239 cam_critical(LOG_UI, "cam_video_record_start failed");
3242 if (ad->timer_timer)
3243 ad->timer_timer = NULL;
3245 return ECORE_CALLBACK_CANCEL;
3249 static void cam_app_start_timer(void *data)
3251 struct appdata *ad = (struct appdata *)data;
3252 cam_retm_if(ad == NULL, "appdata is NULL");
3253 CamAppData *camapp = ad->camapp_handle;
3254 cam_retm_if(camapp == NULL, "camapp_handle is NULL");
3256 ad->timer_activated = true;
3258 switch (camapp->timer) {
3259 case CAM_SETTINGS_TIMER_2SEC:
3260 ad->timer_count = 2;
3262 case CAM_SETTINGS_TIMER_5SEC:
3263 ad->timer_count = 5;
3265 case CAM_SETTINGS_TIMER_10SEC:
3266 ad->timer_count = 10;
3269 case CAM_SETTINGS_TIMER_OFF:
3271 CAM_UI_LOG("can not reach here");
3275 if (camapp->default_capture_mode == CAM_CAPTURE_BURST)
3278 cam_toolbar_update(ad);
3280 cam_app_timer_update_count(ad);
3282 if (ad->timer_timer != NULL) {
3283 ecore_timer_del(ad->timer_timer);
3284 ad->timer_timer = NULL;
3287 ad->timer_timer = ecore_timer_add(1.0, cam_app_timer_cb, ad);
3290 void cam_app_cancel_timer(void *data)
3292 struct appdata *ad = (struct appdata *)data;
3294 ad->timer_activated = FALSE;
3296 REMOVE_TIMER(ad->timer_timer);
3297 DEL_EVAS_OBJECT(ad->timer_icon_edje);
3299 cam_toolbar_update(ad);
3302 static void _popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
3304 /* cam_app_free_blocking_popup(); */
3305 Evas_Object *notify = (Evas_Object *)data;
3306 cam_popup_remove(notify);
3307 /* evas_object_del(notify); */
3310 gboolean cam_image_capture_start(void *data)
3312 struct appdata *ad = (struct appdata *)data;
3313 CamAppData *camapp = NULL;
3315 gboolean ret = TRUE;
3317 debug_fenter(LOG_UI);
3319 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
3320 camapp = ad->camapp_handle;
3321 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
3322 CAM_TA_ACUM_ITEM_BEGIN(" cam_image_capture_start", 0);
3323 if (camapp->af_mode == CAM_FOCUS_FACE) {
3324 cam_app_stop_video_stream();
3326 DEBUG_TRACE("camapp->burst_shot %d", camapp->burst_shot);
3327 DEBUG_TRACE("camapp->shooting_mode %d", camapp->shooting_mode);
3328 DEBUG_TRACE("camapp->default_capture_mode %d", camapp->default_capture_mode);
3329 remain = cam_system_get_still_count_by_resolution(ad);
3332 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_BODY_UNABLE_TO_SAVE_NOT_ENOUGH_MEMORY"), cam_app_popup_response_cb);
3333 CAM_TA_ACUM_ITEM_END(" cam_image_capture_start", 0);
3338 int gps_level = CAM_LBS_STATE_DISABLE;
3339 gps_level = cam_lbs_get_state();
3341 if (gps_level >=CAM_LBS_STATE_SERVICE_ENABLE) {
3342 double longitude = -1.0;
3343 double latitude = -1.0;
3344 double altitude = -1.0;
3345 time_t time_stamp = -1.0;
3346 if (cam_lbs_get_current_position(&longitude, &latitude, &altitude, &time_stamp)) {
3347 DEBUG_TRACE("GEO TAG [longitude = %d, latitude = %d, altitude = %d]", longitude, latitude, altitude);
3348 if (!cam_mm_set_gps_data(latitude, longitude, (double)altitude))
3349 DEBUG_TRACE("cam_mm_set_gps_data failed");
3353 cam_set_orient_value(ad);
3355 if (camapp->camera_mode == CAM_CAMERA_MODE) {
3356 switch (camapp->shooting_mode) {
3357 case CAM_SINGLE_MODE:
3358 case CAM_SELF_SINGLE_MODE:
3359 if (camapp->burst_shot == TRUE && camapp->default_capture_mode == CAM_CAPTURE_BURST) {
3360 camapp->capture_cb = (camera_capturing_cb)cam_continuous_shot_capture_callback;
3361 cam_continuous_shot_capture_start(ad);
3363 camapp->capture_cb = (camera_capturing_cb)__cam_capture_cb;
3364 ret = cam_mm_capture_start(camapp->capture_cb, camapp->capture_completed_cb, (void*)ad);
3368 ret = cam_mm_capture_start(camapp->capture_cb, camapp->capture_completed_cb, (void*)ad); /*capture on recoring */
3371 }else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
3372 ret = cam_mm_capture_start(camapp->capture_cb, camapp->capture_completed_cb, (void*)ad);
3375 CAM_TA_ACUM_ITEM_END(" cam_image_capture_start", 0);
3376 CAM_TA_ACUM_ITEM_BEGIN(" capture_start to capturecallback", 0);
3380 static gboolean cam_image_capture_stop(void *data)
3382 struct appdata *ad = (struct appdata *)data;
3383 CamAppData *camapp = NULL;
3385 debug_fenter(LOG_UI);
3386 ad->stop_continuous_shot = FALSE;
3387 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
3388 camapp = ad->camapp_handle;
3389 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
3391 if (camapp->shooting_mode == CAM_SINGLE_MODE && camapp->default_capture_mode == CAM_CAPTURE_BURST) {
3392 ad->stop_continuous_shot = TRUE;
3398 Eina_Bool cam_image_capture_handle_idler(void *itm)
3400 CamIdlerItem *item = (CamIdlerItem *) itm;
3401 struct appdata *ad = NULL;
3402 cam_retvm_if(!item, ECORE_CALLBACK_CANCEL, "CamIdlerItem is NULL");
3404 ad = (struct appdata *)item->data;
3405 cam_retvm_if(!ad, ECORE_CALLBACK_CANCEL, "appdata is NULL");
3407 cam_info(LOG_UI, "call idler[ %p] ", item->idler);
3408 ad->capture_cb_list = g_list_remove(ad->capture_cb_list, item->idler);
3410 ecore_idler_del(item->idler);
3415 return cam_image_capture_handle(ad);
3417 static Eina_Bool __cam_app_hide_rect_image(void *data)
3419 struct appdata *ad = (struct appdata *)data;
3420 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
3421 HIDE_EVAS_OBJECT(ad->rect_image);
3422 return ECORE_CALLBACK_CANCEL;
3425 Eina_Bool cam_capture_on_recording_handle(void *data)
3427 struct appdata *ad = (struct appdata *)data;
3428 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
3429 CamAppData *camapp = NULL;
3430 camapp = ad->camapp_handle;
3431 cam_retvm_if(camapp == NULL, ECORE_CALLBACK_CANCEL,
3432 "camapp_handle is NULL");
3433 gboolean preview_skip = FALSE;
3435 if (camapp->filename) {
3436 cam_debug(LOG_SYS, "#########camapp->filename=%s", camapp->filename);
3437 CAM_TA_ACUM_ITEM_BEGIN(" send signal to register thread", 0);
3438 g_queue_push_tail(ad->file_reg_queue, strdup(camapp->filename));
3439 pthread_cond_signal(&ad->file_reg_cond);
3440 CAM_TA_ACUM_ITEM_END(" send signal to register thread", 0);
3442 cam_app_notice_popup(ad, "Your storage have trouble ", cam_app_popup_response_cb);
3444 if (!cam_mm_capture_stop (preview_skip, CAM_CAMERA_MODE)) {
3445 cam_critical(LOG_MM, " cam_mm_capture_stop error ");
3447 ecore_timer_add(0.50, __cam_app_hide_rect_image, ad);
3449 return ECORE_CALLBACK_CANCEL;
3452 static Eina_Bool __cam_run_image_viewer_idler(void *data)
3454 struct appdata *ad = (struct appdata *)data;
3455 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
3456 CamAppData *camapp = ad->camapp_handle;
3457 cam_retv_if(camapp == NULL, ECORE_CALLBACK_CANCEL);
3459 gboolean launch_special_view = FALSE;
3461 if (!cam_app_run_image_viewer_ug(ad, camapp->filename, launch_special_view)) {
3462 cam_critical(LOG_UI, "cam_app_run_image_viewer_ug failed");
3465 return ECORE_CALLBACK_CANCEL;
3468 static void* __cam_run_image_viewer_thread_run(void *data)
3470 struct appdata *ad = (struct appdata *)data;
3476 CamAppData *camapp = ad->camapp_handle;
3483 while (ad->is_capture_animation_processing) {
3484 // DEBUG_TRACE("wait capture animation!");
3487 ecore_idler_add(__cam_run_image_viewer_idler, (void *)ad);
3493 static Ecore_Timer *progress_timer = NULL;
3495 Eina_Bool cam_image_capture_handle(void *data)
3497 struct appdata *ad = (struct appdata *)data;
3498 CamAppData *camapp = NULL;
3500 debug_fenter(LOG_UI);
3502 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
3503 camapp = ad->camapp_handle;
3504 cam_retvm_if(camapp == NULL, ECORE_CALLBACK_CANCEL, "camapp_handle is NULL");
3506 CAM_TA_ACUM_ITEM_END(" captured message to cam_image_capture_handle", 0);
3507 CAM_TA_ACUM_ITEM_BEGIN(" cam_image_capture_handle", 0);
3509 pthread_t run_image_viewer_thread;
3511 switch (camapp->shooting_mode) {
3513 case CAM_SINGLE_MODE:
3514 case CAM_SELF_SINGLE_MODE:
3515 DEBUG_TRACE("start single shot capture. capture mode %d", camapp->default_capture_mode);
3517 cam_critical(LOG_UI, "completed");
3519 if( camapp->default_capture_mode == CAM_CAPTURE_SINGLE ||camapp->burst_shot == FALSE) {
3520 if (camapp->filename) {
3521 cam_debug(LOG_SYS, "#########camapp->filename=%s", camapp->filename);
3522 CAM_TA_ACUM_ITEM_BEGIN(" send signal to register thread", 0);
3523 g_queue_push_tail(ad->file_reg_queue, strdup(camapp->filename));
3524 pthread_cond_signal(&ad->file_reg_cond);
3525 CAM_TA_ACUM_ITEM_END(" send signal to register thread", 0);
3526 cam_app_update_thumbnail();
3528 cam_app_notice_popup(ad, "Your storage have trouble ", cam_app_popup_response_cb);
3531 if (camapp->continuous_shot_data == NULL) {
3532 cam_critical(LOG_SYS, " continuous_shot_data is NULL");
3533 return ECORE_CALLBACK_CANCEL;
3538 camapp->continuous_shot_data->capture_status = CAM_CONTI_SHOT_STATUS_STOPPED;
3540 if (camapp->filename)
3541 free(camapp->filename);
3543 camapp->filename = strdup(camapp->continuous_shot_data->file_path[camapp->continuous_shot_data->shot_num - 1]);
3545 cam_app_destroy_progressbar(ad);
3546 if (camapp->continuous_shot_data->error != NULL) {
3547 cam_debug(LOG_SYS, " Start to unlink captured files");
3549 /* unlink all captured files */
3550 for (i = 0; i < camapp->continuous_shot_data->shot_num; i++) {
3551 if (camapp->continuous_shot_data->file_path[i]
3552 && !access(camapp->continuous_shot_data->file_path[i], F_OK)) {
3553 unlink(camapp->continuous_shot_data->file_path[i]);
3557 cam_debug(LOG_SYS, " Unlink done");
3558 cam_app_notice_popup(ad, camapp->continuous_shot_data->error->message, cam_app_popup_response_cb);
3560 cam_critical(LOG_UI, "start to register continuous shot");
3564 #if 1 /*TODO: need ui guide, for display popup*/
3565 elm_progressbar_value_set(ad->progress_popup_bar, 1.0);
3566 if (progress_timer) {
3567 ecore_timer_del(progress_timer);
3569 ad->is_processing = FALSE;
3570 cam_popup_delete(ad);
3573 cam_continuous_shot_data_free(ad);
3574 cam_toolbar_update(ad);
3575 cam_app_update_thumbnail();
3576 camapp->default_capture_mode = CAM_CAPTURE_SINGLE;
3577 cam_reset_focus_mode(ad);
3581 if (camapp->review) {
3582 if (pthread_create(&run_image_viewer_thread, NULL, __cam_run_image_viewer_thread_run, (void *)ad) < 0) {
3583 cam_critical(LOG_CAM, "create run_image_viewer_thread failed");
3584 return ECORE_CALLBACK_CANCEL;
3591 cam_debug(LOG_UI, " Not matched shooting mode [%d]",
3592 camapp->shooting_mode);
3595 ad->remained_count--;
3596 indicator_update_remain_count(ad);
3598 if (camapp->af_mode == CAM_FOCUS_FACE) { /*note: face focus mode, if start capture,stop draw rect*/
3599 cam_app_run_video_stream();
3602 CAM_TA_ACUM_ITEM_END(" cam_image_capture_handle", 0);
3604 return ECORE_CALLBACK_CANCEL;
3607 gboolean cam_camera_touch_af_press(void *data)
3609 struct appdata *ad = (struct appdata *)data;
3610 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
3611 CamAppData *camapp = ad->camapp_handle;
3612 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
3614 debug_fenter(LOG_UI);
3616 camapp->focus_mode = CAM_FOCUS_MODE_TOUCH_AUTO;
3618 if (!ad->camapp_handle->key_lock) {
3619 ad->camapp_handle->key_lock = TRUE;
3620 if (!cam_camera_key_half_press(ad)) {
3621 DEBUG_TRACE("cam_camera_key_half_press failed state");
3622 ad->camapp_handle->key_lock = FALSE;
3623 camapp->touch_af_state = CAM_TOUCH_AF_STATE_NONE;
3626 ad->camapp_handle->key_lock = FALSE;
3629 camapp->touch_af_state = CAM_TOUCH_AF_STATE_NONE;
3634 gboolean cam_camera_key_half_press(void *data)
3636 struct appdata *ad = (struct appdata *)data;
3637 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
3638 CamAppData *camapp = ad->camapp_handle;
3639 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
3641 debug_fenter(LOG_UI);
3643 unsigned int capacity;
3644 GetCamDevFuncCaps(&capacity, (void*)ad);
3646 if (!(capacity & CAM_CP_FUNC_FOCUS_MODE))
3649 if (camapp->af_mode != CAM_FOCUS_FACE) {
3650 cam_mm_stop_focusing();
3652 if (!cam_mm_set_af_area(ad->af_x, ad->af_y, ad->camera_focus_w, ad->camera_focus_h)) {
3653 DEBUG_TRACE("cam_mm_set_af_area failed");
3656 DEBUG_TRACE("focus mode = %d", camapp->focus_mode);
3658 if (!cam_mm_start_focusing(camapp->focus_mode)) {
3659 cam_critical(LOG_MM, " cam_mm_start_focusing error " );
3666 gboolean cam_camera_key_half_release(void *data)
3668 debug_fenter(LOG_UI);
3672 gboolean cam_do_capture(void* data)
3674 struct appdata *ad = (struct appdata *)data;
3675 CamAppData *camapp = NULL;
3678 debug_fenter(LOG_UI);
3680 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
3681 if (ad->is_rotating)
3682 return FALSE;/*note: now is rotating*/
3683 camapp = ad->camapp_handle;
3684 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
3685 CAM_TA_ACUM_ITEM_BEGIN(" cam_camera_key_press", 0);
3687 if (ad->continuous_af_timer) {
3688 REMOVE_TIMER(ad->continuous_af_timer);
3689 ad->continuous_af_timer = ecore_timer_add(FOCUS_FOCUSED_TIME_OUT, __cam_continuous_af_timer_cb, ad);
3692 if (camapp->camera_mode == CAM_CAMERA_MODE) {
3693 state = cam_mm_get_state();
3694 cam_debug(LOG_UI, " state = %d", state);
3696 case CAMERA_STATE_PREVIEW:
3697 case CAMERA_STATE_CAPTURED:
3698 if (ad->timer_activated) {
3699 CAM_UI_LOG("timer activated!");
3700 cam_app_cancel_timer(ad);
3701 if (!cam_image_capture_start(ad)) {
3704 } else if (camapp->timer > CAM_SETTINGS_TIMER_OFF) {
3705 CAM_UI_LOG("timer start");
3706 cam_app_start_timer(ad);
3707 } else if (!cam_image_capture_start(ad)) {
3712 case CAMERA_STATE_CAPTURING:
3713 cam_debug(LOG_UI, "capturing state");
3716 case CAMERA_STATE_NONE:
3717 case CAMERA_STATE_CREATED:
3725 } else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
3728 state = cam_mm_get_state();
3729 cam_debug(LOG_UI, " state = %d", state);
3731 case RECORDER_STATE_RECORDING:
3732 case RECORDER_STATE_PAUSED:
3733 if(!cam_image_capture_start(ad)) {
3734 HIDE_EVAS_OBJECT(ad->rect_image);
3738 case RECORDER_STATE_NONE:
3739 case RECORDER_STATE_CREATED:
3740 case RECORDER_STATE_READY:
3752 gboolean cam_do_record(void* data)
3754 struct appdata *ad = (struct appdata *)data;
3755 CamAppData *camapp = NULL;
3758 debug_fenter(LOG_UI);
3760 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
3761 if (ad->is_rotating)
3762 return FALSE;/*note: now is rotating*/
3763 camapp = ad->camapp_handle;
3764 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
3765 CAM_TA_ACUM_ITEM_BEGIN(" cam_camera_key_press", 0);
3767 if (ad->continuous_af_timer) {
3768 REMOVE_TIMER(ad->continuous_af_timer);
3769 ad->continuous_af_timer = ecore_timer_add(FOCUS_FOCUSED_TIME_OUT, __focus_guide_destroy, ad);
3772 if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
3773 state = cam_mm_get_state();
3774 cam_critical(LOG_UI, " state = %d", state);
3776 case RECORDER_STATE_READY:
3778 if (ad->timer_activated) {
3779 CAM_UI_LOG("timer activated!");
3780 cam_app_cancel_timer(ad);
3781 if (!cam_video_record_start(ad)) {
3784 } else if (camapp->timer > CAM_SETTINGS_TIMER_OFF) {
3785 CAM_UI_LOG("timer start");
3786 cam_app_start_timer(ad);
3787 } else if (!cam_video_record_start(ad)) {
3792 case RECORDER_STATE_RECORDING:
3793 cam_critical(LOG_UI, "RECORDER_STATE_NONE ");
3796 case RECORDER_STATE_NONE:
3797 cam_critical(LOG_UI, "RECORDER_STATE_NONE ");
3800 case RECORDER_STATE_CREATED:
3801 cam_critical(LOG_UI, "RECORDER_STATE_CREATED ");
3804 case RECORDER_STATE_PAUSED:
3805 cam_critical(LOG_UI, "RECORDER_STATE_PAUSED ");
3818 gboolean cam_camera_key_press(void *data)
3820 struct appdata *ad = (struct appdata *)data;
3821 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
3822 CamAppData *camapp = ad->camapp_handle;
3823 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
3825 debug_fenter(LOG_UI);
3829 if (ad->is_rotating)
3830 return FALSE;/*note: now is rotating*/
3832 CAM_TA_ACUM_ITEM_BEGIN(" cam_camera_key_press", 0);
3834 if (ad->continuous_af_timer) {
3835 REMOVE_TIMER(ad->continuous_af_timer);
3837 if (camapp->camera_mode == CAM_CAMCORDER_MODE)
3838 ad->continuous_af_timer = ecore_timer_add(FOCUS_FOCUSED_TIME_OUT, __focus_guide_destroy, ad);
3840 ad->continuous_af_timer = ecore_timer_add(FOCUS_FOCUSED_TIME_OUT, __cam_continuous_af_timer_cb, ad);
3843 if (camapp->camera_mode == CAM_CAMERA_MODE) {
3844 state = cam_mm_get_state();
3845 cam_debug(LOG_UI, " state = %d", state);
3847 case CAMERA_STATE_PREVIEW:
3848 case CAMERA_STATE_CAPTURED:
3849 if (ad->timer_activated) {
3850 CAM_UI_LOG("timer activated!");
3851 } else if (camapp->timer >
3852 CAM_SETTINGS_TIMER_OFF) {
3853 CAM_UI_LOG("timer start");
3854 cam_app_start_timer(ad);
3855 } else if (!cam_image_capture_start(ad)) {
3859 case CAMERA_STATE_CAPTURING:
3860 cam_debug(LOG_UI, "capturing state");
3863 case CAMERA_STATE_NONE:
3864 case CAMERA_STATE_CREATED:
3872 } else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
3873 state = cam_mm_get_state();
3874 cam_debug(LOG_UI, " state = %d", state);
3876 case RECORDER_STATE_READY:
3878 if (ad->timer_activated) {
3879 CAM_UI_LOG("timer activated!");
3880 } else if (camapp->timer >
3881 CAM_SETTINGS_TIMER_OFF) {
3882 CAM_UI_LOG("timer start");
3883 cam_app_start_timer(ad);
3884 } else if (!cam_video_record_start(ad)) {
3889 case RECORDER_STATE_RECORDING:
3891 camapp->rec_stop_type = CAM_REC_STOP_NORMAL;
3892 if (!cam_video_record_stop(ad)) {
3898 case RECORDER_STATE_NONE:
3899 case RECORDER_STATE_CREATED:
3900 case RECORDER_STATE_PAUSED:
3909 cam_critical(LOG_MM, "Unknow camera mode");
3912 CAM_TA_ACUM_ITEM_END(" cam_camera_key_press", 0);
3916 gboolean cam_camera_key_release(void *data)
3918 struct appdata *ad = (struct appdata *)data;
3919 CamAppData *camapp = NULL;
3922 debug_fenter(LOG_UI);
3924 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
3925 camapp = ad->camapp_handle;
3926 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
3928 if (camapp->camera_mode == CAM_CAMERA_MODE) {
3930 state = cam_mm_get_state();
3931 cam_debug(LOG_UI, " state = %d", state);
3933 case CAMERA_STATE_CAPTURING:
3934 if (!cam_image_capture_stop(ad)) {
3939 case CAMERA_STATE_PREVIEW:
3940 case CAMERA_STATE_CREATED:
3941 case CAMERA_STATE_NONE:
3942 case CAMERA_STATE_CAPTURED:
3950 } else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
3952 state = cam_mm_get_state();
3954 case MM_CAMCORDER_STATE_PREPARE:
3955 if (!cam_video_record_start(ad)) {
3959 case MM_CAMCORDER_STATE_RECORDING:
3960 if (!cam_video_record_stop(ad)) {
3965 case MM_CAMCORDER_STATE_NONE:
3966 case MM_CAMCORDER_STATE_NULL:
3967 case MM_CAMCORDER_STATE_READY:
3968 case MM_CAMCORDER_STATE_CAPTURING:
3969 case MM_CAMCORDER_STATE_PAUSED:
3979 cam_critical(LOG_MM, "Unknow camera mode");
3986 void cam_reset_focus_coordinate(void* data)
3988 struct appdata *ad = (struct appdata *)data;
3989 cam_retm_if(ad == NULL, "appdata is NULL");
3991 ad->af_x = (ad->win_width / 2) - ad->preview_offset_x;
3992 ad->af_y = (ad->win_height / 2) - ad->preview_offset_y;
3994 ad->af_x = (ad->af_x * ad->camfw_video_width) / ad->preview_w;
3995 ad->af_y = (ad->af_y * ad->camfw_video_height) / ad->preview_h;
3998 ad->touch_lcd_x = (ad->win_height / 2);
3999 ad->touch_lcd_y = (ad->win_width / 2);
4004 switch (ad->rot_current) {
4005 case APP_DEVICE_ORIENTATION_0:
4007 ad->af_start_x = ad->touch_lcd_x;
4008 ad->af_start_y = ad->touch_lcd_y;
4011 case APP_DEVICE_ORIENTATION_180:
4013 ad->af_start_x = ad->win_height - ad->touch_lcd_x;
4014 ad->af_start_y = ad->win_width - ad->touch_lcd_y;
4017 case APP_DEVICE_ORIENTATION_270:
4019 ad->af_start_x = ad->touch_lcd_y;
4020 ad->af_start_y = ad->win_height - ad->touch_lcd_x;
4023 case APP_DEVICE_ORIENTATION_90:
4025 ad->af_start_x = ad->win_width - ad->touch_lcd_y;
4026 ad->af_start_y = ad->touch_lcd_x;
4034 DEBUG_TRACE("ad->af_start_x=%f, ad->af_start_y=%f", ad->af_start_x, ad->af_start_y);
4036 ad->camera_focus_w = CAMERA_FOCUS_W * elm_config_scale_get();
4037 ad->camera_focus_h = CAMERA_FOCUS_H * elm_config_scale_get();
4038 DEBUG_TRACE("ad->camera_focus_w=%f, ad->camera_focus_h=%f", ad->camera_focus_w, ad->camera_focus_h);
4040 ad->af_start_x = ad->af_start_x - (ad->camera_focus_w / 2);
4041 ad->af_start_y = ad->af_start_y - (ad->camera_focus_h / 2);
4042 DEBUG_TRACE("af area box start x,y =[%f,%f]\n", ad->af_start_x, ad->af_start_y);
4044 if (ad->rot_current == APP_DEVICE_ORIENTATION_270
4045 || ad->rot_current == APP_DEVICE_ORIENTATION_90) {
4046 if (ad->af_start_x < ad->preview_offset_x) {
4047 ad->af_start_x = ad->preview_offset_x;
4049 if (ad->af_start_y < ad->preview_offset_y) {
4050 ad->af_start_y = ad->preview_offset_y;
4052 if ((ad->af_start_x + ad->camera_focus_w) >
4053 (ad->preview_w + ad->preview_offset_x)) {
4055 (ad->preview_w + ad->preview_offset_x) -
4058 if ((ad->af_start_y + ad->camera_focus_h) >
4059 (ad->preview_h + ad->preview_offset_y)) {
4061 (ad->preview_h + ad->preview_offset_y) -
4066 if (ad->af_start_y < ad->preview_offset_x) {
4067 ad->af_start_y = ad->preview_offset_x;
4069 if (ad->af_start_x < ad->preview_offset_y) {
4070 ad->af_start_x = ad->preview_offset_y;
4072 if ((ad->af_start_y + ad->camera_focus_h) >
4073 (ad->preview_w + ad->preview_offset_x)) {
4075 (ad->preview_w + ad->preview_offset_x) -
4078 if ((ad->af_start_x + ad->camera_focus_w) >
4079 (ad->preview_h + ad->preview_offset_y)) {
4081 (ad->preview_h + ad->preview_offset_y) -
4089 Eina_Bool cam_continuous_af_start(void *data)
4091 struct appdata *ad = (struct appdata *)data;
4092 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
4094 CamAppData *camapp = NULL;
4095 camapp = ad->camapp_handle;
4096 cam_retvm_if(camapp == NULL, ECORE_CALLBACK_CANCEL, "camapp_handle is NULL");
4098 /* cam_mm_set_af_area include init focusing */
4099 DEBUG_TRACE("start continuous AF");
4100 if (cam_mm_set_af_area(ad->af_x, ad->af_y, ad->camera_focus_w, ad->camera_focus_h)) {
4101 DEBUG_TRACE("cam_mm_set_af_area success!");
4102 /*focus guide update*/
4104 DEBUG_TRACE("cam_mm_set_af_area error!");
4107 camapp->focus_mode = CAM_FOCUS_MODE_CONTINUOUS;
4109 if (!cam_mm_start_focusing(camapp->focus_mode)) {
4110 cam_critical(LOG_MM, "cam_mm_start_focusing error");
4113 return ECORE_CALLBACK_CANCEL;
4116 Eina_Bool cam_volume_key_press(void *data)
4118 struct appdata *ad = (struct appdata *)data;
4119 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4121 CamAppData *camapp = NULL;
4122 camapp = ad->camapp_handle;
4123 if (camapp == NULL) {
4124 if (ad->longpress_timer)
4125 ad->longpress_timer = NULL;
4126 return ECORE_CALLBACK_CANCEL;
4129 if (ad->cancel_key_press == TRUE) {
4130 if (ad->longpress_timer)
4131 ad->longpress_timer = NULL;
4132 return ECORE_CALLBACK_CANCEL;
4135 if(ad->is_rotating){
4136 cam_critical(LOG_MM, "rotating...");
4137 if (ad->longpress_timer)
4138 ad->longpress_timer = NULL;
4139 return ECORE_CALLBACK_CANCEL;
4142 if (camapp->touch_af_state == CAM_TOUCH_AF_STATE_DOING) {
4143 cam_critical(LOG_UI, "touch_af_state is [%d], do not zoom", camapp->touch_af_state);
4144 return ECORE_CALLBACK_CANCEL;
4147 DEL_EVAS_OBJECT(ad->focus_edje);
4148 cam_mm_stop_focusing();
4151 gboolean up_key = ad->up_key;
4152 debug_fenter(LOG_UI);
4154 state = cam_mm_get_state();
4155 cam_debug(LOG_UI, " state = %d", state);
4156 if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
4158 case RECORDER_STATE_RECORDING:
4159 case RECORDER_STATE_PAUSED:
4160 case RECORDER_STATE_READY:
4162 if (!camapp->zoom_lock
4163 && camapp->recording_mode != CAM_RECORD_SLOW) {
4164 zoom_in(ad, up_key, 1);
4168 case RECORDER_STATE_NONE:
4169 case RECORDER_STATE_CREATED:
4174 } else if(camapp->camera_mode == CAM_CAMERA_MODE) {
4176 case CAMERA_STATE_PREVIEW:
4177 case CAMERA_STATE_CAPTURED:
4179 if (!camapp->zoom_lock
4180 && camapp->recording_mode != CAM_RECORD_SLOW) {
4181 zoom_in(ad, up_key, 1);
4186 case CAMERA_STATE_NONE:
4187 case CAMERA_STATE_CREATED:
4188 case CAMERA_STATE_CAPTURING:
4197 if (ad->longpress_timer)
4198 ecore_timer_interval_set(ad->longpress_timer, ZOOM_LONG_PRESS_INTERVAL);
4200 return ECORE_CALLBACK_RENEW;
4203 static gboolean cam_power_key_press(void *data)
4205 struct appdata *ad = (struct appdata *)data;
4206 CamAppData *camapp = NULL;
4208 power_lock_state(POWER_STATE_SCREEN_OFF, 0);
4210 debug_fenter(LOG_UI);
4212 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4213 camapp = ad->camapp_handle;
4214 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
4216 if (ad->mm_state < CAMERA_STATE_PREVIEW) {
4218 } else if (ad->mm_state == CAMERA_STATE_PREVIEW) {
4220 } else if (ad->mm_state > CAMERA_STATE_PREVIEW) {
4221 if (camapp->camera_mode == CAM_CAMERA_MODE) {
4222 DEBUG_TRACE("camera mode");
4224 camapp->rec_stop_type = CAM_REC_STOP_POWER_KEY;
4225 if (!cam_video_record_stop(ad)) {
4226 DEBUG_TRACE("record stop fail");
4233 power_unlock_state(POWER_STATE_SCREEN_OFF);
4238 static gboolean __cam_end_key_grab_init(void *data)
4240 struct appdata *ad = (struct appdata *)data;
4241 Ecore_X_Display *disp = NULL;
4243 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4244 cam_retvm_if(ad->main_xid <= 0, FALSE, "main_xid <= 0");
4246 disp = ecore_x_display_get();
4247 cam_retvm_if(disp == NULL, FALSE, "ecore_x_display_get fail");
4249 if (utilx_grab_key(disp, ad->main_xid, KEY_END, SHARED_GRAB) == -1) {
4250 cam_critical(LOG_SYS, "%s key grap fail", KEY_END);
4256 gboolean cam_key_grab_init(void *data)
4258 struct appdata *ad = (struct appdata *)data;
4259 Ecore_X_Display *disp = NULL;
4261 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4262 cam_retvm_if(ad->main_xid <= 0, FALSE, "main_xid <= 0");
4269 DEBUG_TRACE("key_grab_init############################");
4271 ad->cancel_key_press = FALSE;
4273 disp = ecore_x_display_get();
4274 cam_retvm_if(disp == NULL, FALSE, "ecore_x_display_get fail");
4277 if (utilx_grab_key(disp, ad->main_xid, KEY_VOLUMEUP, TOP_POSITION_GRAB) != success) {
4278 cam_critical(LOG_SYS, "%s key grap fail", KEY_VOLUMEUP);
4281 if (utilx_grab_key(disp, ad->main_xid, KEY_VOLUMEDOWN, TOP_POSITION_GRAB) != success) {
4282 cam_critical(LOG_SYS, "%s key grap fail", KEY_VOLUMEDOWN);
4287 if (vconf_set_int(VCONFKEY_STARTER_USE_VOLUME_KEY, 1))
4288 cam_critical(LOG_SYS, "VCONFKEY_STARTER_USE_VOLUME_KEY set fail");
4292 if (utilx_grab_key(disp, ad->main_xid, KEY_CAMERA, TOP_POSITION_GRAB) != success) {
4293 cam_critical(LOG_SYS, "%s key grap fail", KEY_CAMERA);
4296 if (utilx_grab_key(disp, ad->main_xid, KEY_CONFIG, TOP_POSITION_GRAB) != success) {
4297 cam_critical(LOG_SYS, "%s key grap fail", KEY_CONFIG);
4301 if (utilx_grab_key(disp, ad->main_xid, KEY_POWER, SHARED_GRAB) != success) {
4302 cam_critical(LOG_SYS, "%s key grap fail", KEY_POWER);
4307 if (utilx_grab_key(disp, ad->main_xid, KEY_SEND, SHARED_GRAB) != success) {
4308 cam_critical(LOG_SYS, "%s key grap fail", KEY_SEND);
4311 if (utilx_grab_key(disp, ad->main_xid, KEY_END, SHARED_GRAB) != success) {
4312 cam_critical(LOG_SYS, "%s key grap fail", KEY_END);
4316 ad->isGrabed = TRUE;
4320 gboolean cam_key_grab_deinit(void *data)
4322 struct appdata *ad = (struct appdata *)data;
4323 Ecore_X_Display *disp = NULL;
4327 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
4328 cam_retvm_if(ad->main_xid <= 0, FALSE, "main_xid <= 0");
4332 DEBUG_TRACE("key_grab_deinit############################");
4334 disp = ecore_x_display_get();
4335 cam_retvm_if(disp == NULL, FALSE, "ecore_x_display_get fail");
4338 if (utilx_ungrab_key(disp, ad->main_xid, KEY_VOLUMEUP) != success){
4339 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_VOLUMEUP);
4342 if (utilx_ungrab_key(disp, ad->main_xid, KEY_VOLUMEDOWN) != success){
4343 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_VOLUMEDOWN);
4348 if (utilx_ungrab_key(disp, ad->main_xid, KEY_CAMERA) != success){
4349 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_CAMERA);
4353 if (utilx_ungrab_key(disp, ad->main_xid, KEY_CONFIG) != success){
4354 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_CONFIG);
4359 if (utilx_ungrab_key(disp, ad->main_xid, KEY_POWER) != success){
4360 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_POWER);
4363 if (utilx_ungrab_key(disp, ad->main_xid, KEY_PAUSE) != success){
4364 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_PAUSE);
4369 if (utilx_ungrab_key(disp, ad->main_xid, KEY_SEND) != success){
4370 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_SEND);
4373 if (utilx_ungrab_key(disp, ad->main_xid, KEY_SELECT) != success){
4374 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_SELECT);
4377 if (utilx_ungrab_key(disp, ad->main_xid, KEY_END) != success){
4378 cam_critical(LOG_SYS, "%s key ungrap fail", KEY_END);
4382 ad->isGrabed = FALSE;
4386 gboolean cam_app_key_event_init(void *data)
4388 struct appdata *ad = (struct appdata *)data;
4390 DEBUG_TRACE("cam_app_key_event_init");
4393 cam_critical(LOG_UI, "appdata is NULL, maybe not created");
4396 if (ad->key_down == NULL) {
4398 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, cam_hard_key_down, ad);
4400 if (ad->key_up == NULL) {
4402 ecore_event_handler_add(ECORE_EVENT_KEY_UP, cam_hard_key_up, ad);
4408 gboolean cam_app_key_event_deinit(void *data)
4410 struct appdata *ad = (struct appdata *)data;
4412 DEBUG_TRACE("cam_app_key_event_deinit");
4415 cam_critical(LOG_UI, "appdata is NULL, maybe not created");
4419 ecore_event_handler_del(ad->key_down);
4420 ad->key_down = NULL;
4423 ecore_event_handler_del(ad->key_up);
4430 Eina_Bool cam_hard_key_down(void *data, int type, void *event_info)
4432 struct appdata *ad = (struct appdata *)data;
4433 cam_retvm_if(ad == NULL, ECORE_CALLBACK_DONE, "appdata is NULL");
4434 CamAppData *camapp = ad->camapp_handle;
4435 cam_retvm_if(camapp == NULL, ECORE_CALLBACK_DONE, "camapp_handle is NULL");
4437 Ecore_Event_Key *kd = (Ecore_Event_Key *) event_info;
4438 cam_debug(LOG_UI, "Key name : %s", kd->keyname);
4440 if (ad->confirm_popup) {
4441 cam_debug(LOG_UI, "confirm popup exist. ignore key event");
4442 return ECORE_CALLBACK_DONE;
4446 unload_zoom_edje(ad);
4451 if (ad->setting_ctxpopup || ad->toolbar_setting_popup) {
4452 ad->displayed_setting_popup = DISPLAY_NONE_POPUP;
4453 cam_toolbar_setting_popup_destroy(ad);
4456 if (ad->edit_shortcuts_popup)
4457 toolbar_destroy_shortcuts_popup(ad);
4459 cam_app_timeout_checker_update();
4461 /* Camera key Press */
4462 if (0 == strcmp(kd->keyname, KEY_CANCEL)) {
4463 ad->cancel_key_press = TRUE;
4465 if (0 == strcmp(kd->keyname, KEY_CONFIG)) { /* camera key - full */
4466 if (!camapp->key_lock) {
4467 camapp->key_lock = TRUE;
4468 CAM_TA_ACUM_ITEM_BEGIN("Total capture time", 0);
4469 CAM_TA_ACUM_ITEM_BEGIN
4470 (" camera key to capture start", 0);
4471 if (!cam_camera_key_press(ad)) {
4472 cam_warning(LOG_UI, "cam_camera_key_press failed");
4474 camapp->key_lock = FALSE;
4477 /* Camera key HALF press */
4478 else if (0 == strcmp(kd->keyname, KEY_CAMERA)) { /* camera key - half */
4479 if (!camapp->key_lock) {
4480 camapp->key_lock = TRUE;
4482 if (!cam_camera_key_half_press(ad)) {
4483 cam_warning(LOG_UI, "cam_camera_key_half_press failed");
4485 camapp->key_lock = FALSE;
4487 } else if (0 == strcmp(kd->keyname, KEY_VOLUMEUP)) {
4488 if (camapp->volume_key == CAM_VOLUME_KEY_ZOOM) {
4489 if (!camapp->key_lock) {
4490 camapp->key_lock = TRUE;
4492 cam_volume_key_press(ad);
4493 cam_add_longpress_key_timer(ad);
4494 camapp->key_lock = FALSE;
4497 cam_toolbar_shutter_button_cb(ad, NULL, "press_shutter_sig", "hard_key");
4499 } else if (0 == strcmp(kd->keyname, KEY_VOLUMEDOWN)) {
4500 if (camapp->volume_key == CAM_VOLUME_KEY_ZOOM) {
4501 if (!camapp->key_lock) {
4502 camapp->key_lock = TRUE;
4504 cam_volume_key_press(ad);
4505 cam_add_longpress_key_timer(ad);
4506 camapp->key_lock = FALSE;
4509 if (!ad->is_recording) {
4510 cam_toolbar_recording_button_cb(ad, NULL, "click_shutter_sig", "hard_key");
4512 cam_toolbar_recording_stop_button_cb(ad, NULL, "click_shutter_sig", "hard_key");
4515 } else if (0 == strcmp(kd->keyname, KEY_SELECT)) {
4517 } else if ((0 == strcmp(kd->keyname, KEY_SELECT))
4518 && ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
4519 if (!camapp->key_lock) {
4520 camapp->key_lock = TRUE;
4522 } else if (0 == strcmp(kd->keyname, KEY_POWER)) {
4524 if (!camapp->key_lock) {
4525 camapp->key_lock = TRUE;
4526 power_unlock_state(POWER_STATE_NORMAL);
4527 cam_power_key_press(ad);
4528 camapp->key_lock = FALSE;
4533 return ECORE_CALLBACK_DONE;
4536 Eina_Bool cam_hard_key_up(void *data, int type, void *event_info)
4538 struct appdata *ad = (struct appdata *)data;
4539 cam_retvm_if(ad == NULL, ECORE_CALLBACK_DONE, "appdata is NULL");
4540 CamAppData *camapp = ad->camapp_handle;
4541 cam_retvm_if(camapp == NULL, ECORE_CALLBACK_DONE, "camapp_handle is NULL");
4543 Ecore_Event_Key *kd = (Ecore_Event_Key *) event_info;
4544 cam_debug(LOG_UI, "Key name : %s", kd->keyname);
4546 if (ad->confirm_popup) {
4547 cam_debug(LOG_UI, "confirm popup exist. ignore key event");
4548 return ECORE_CALLBACK_DONE;
4551 cam_app_timeout_checker_update();
4553 if (0 == strcmp(kd->keyname, KEY_CANCEL)) {
4554 ad->cancel_key_press = FALSE;
4557 if(ad->cancel_key_press == TRUE) {
4558 if (ad->longpress_timer) { /*volume key long press */
4559 cam_del_longpress_key_timer(ad);
4561 return ECORE_CALLBACK_DONE;
4564 if (0 == strcmp(kd->keyname, KEY_CONFIG)) { /* camera key - full */
4565 if (!camapp->key_lock) {
4566 camapp->key_lock = TRUE;
4567 if (!cam_camera_key_release(ad)) {
4568 cam_warning(LOG_UI, "cam_camera_key_release failed");
4570 camapp->key_lock = FALSE;
4572 } else if (0 == strcmp(kd->keyname, KEY_CAMERA)) { /* camera key - half */
4573 if (!camapp->key_lock) {
4574 camapp->key_lock = TRUE;
4575 if (!cam_camera_key_half_release(ad)) {
4576 cam_warning(LOG_UI, "cam_camera_key_release failed");
4578 camapp->key_lock = FALSE;
4580 } else if (0 == strcmp(kd->keyname, KEY_VOLUMEUP)
4581 || 0 == strcmp(kd->keyname, KEY_VOLUMEDOWN)) {
4582 if (camapp->volume_key == CAM_VOLUME_KEY_ZOOM) {
4583 if (!camapp->key_lock) {
4584 camapp->key_lock = TRUE;
4585 cam_del_longpress_key_timer(ad);
4586 camapp->key_lock = FALSE;
4589 cam_toolbar_shutter_button_cb(ad, NULL, "release_shutter_sig", "hard_key");
4592 return ECORE_CALLBACK_DONE;
4595 Eina_Bool cam_mouse_button_down(void *data, void *event_info)
4597 struct appdata *ad = (struct appdata *)data;
4598 cam_retvm_if(ad == NULL, EINA_FALSE, "appdata is NULL");
4599 CamAppData *camapp = ad->camapp_handle;
4600 cam_retvm_if(camapp == NULL, EINA_FALSE, "camapp_handle is NULL");
4602 if (ad->pinch_edje) {
4604 edje_object_signal_emit(_EDJ(ad->focus_edje), "focus,hide", "program");
4608 Evas_Event_Mouse_Down *md = (Evas_Event_Mouse_Down *) event_info;
4610 switch (ad->rot_current) {
4611 case APP_DEVICE_ORIENTATION_0:
4613 ad->touch_lcd_x = md->canvas.x; /* LCD x */
4614 ad->touch_lcd_y = md->canvas.y; /* LCD y */
4617 case APP_DEVICE_ORIENTATION_180:
4619 ad->touch_lcd_x = ad->win_height - md->canvas.x; /* LCD x */
4620 ad->touch_lcd_y = ad->win_width - md->canvas.y; /* LCD y */
4623 case APP_DEVICE_ORIENTATION_270:
4625 ad->touch_lcd_x = ad->win_height - md->canvas.y; /* LCD x */
4626 ad->touch_lcd_y = md->canvas.x; /* LCD y */
4630 case APP_DEVICE_ORIENTATION_90:
4632 ad->touch_lcd_x = md->canvas.y; /* LCD x */
4633 ad->touch_lcd_y = ad->win_width - md->canvas.x; /* LCD y */
4640 ad->af_x = ad->touch_lcd_y - ad->preview_offset_x;
4641 ad->af_y = ad->preview_h - ad->touch_lcd_x;
4643 ad->af_x = (ad->af_x * ad->camfw_video_width) / ad->preview_w;
4644 ad->af_y = (ad->af_y * ad->camfw_video_height) / ad->preview_h;
4646 DEBUG_TRACE("*************************************************************************************");
4647 DEBUG_TRACE("touched lcd x,y=[%d,%d] af x,y=[%d,%d]\n", ad->touch_lcd_x, ad->touch_lcd_y, ad->af_x, ad->af_y);
4648 DEBUG_TRACE("*************************************************************************************");
4650 int state = cam_mm_get_state();
4651 if (!(camapp->camera_mode == CAM_CAMERA_MODE && state == CAMERA_STATE_CAPTURING) ){
4652 if (camapp->enable_touch_af == TRUE
4653 && camapp->touch_af_state == CAM_TOUCH_AF_STATE_NONE) {
4654 REMOVE_TIMER(ad->continuous_af_timer);
4655 cam_app_draw_af_box(ad);
4657 camapp->focus_state = CAM_FOCUS_STATUS_RELEASED;
4658 cam_app_focus_guide_create(ad);
4659 cam_app_focus_guide_update(ad);
4660 cam_ui_effect_utils_set_zoom_effect(ad->focus_edje,
4661 CAM_FOCUS_EDJE_ZOOM_EFFECT_START_RATE,
4662 CAM_FOCUS_EDJE_ZOOM_EFFECT_END_RATE,
4663 CAM_FOCUS_EDJE_ZOOM_EFFECT_DURATION);
4664 camapp->touch_af_state = CAM_TOUCH_AF_STATE_READY;
4667 DEBUG_TRACE("camera mode[%d], camera state[%d] not available focus",camapp->camera_mode,state);
4672 Eina_Bool cam_mouse_button_up(void *data, void *event_info)
4674 struct appdata *ad = (struct appdata *)data;
4675 cam_retvm_if(ad == NULL, EINA_FALSE, "appdata is NULL");
4676 CamAppData *camapp = ad->camapp_handle;
4677 cam_retvm_if(camapp == NULL, EINA_FALSE, "camapp is NULL");
4679 if (ad->pinch_edje) {
4681 edje_object_signal_emit(_EDJ(ad->focus_edje), "focus,hide", "program");
4685 if (camapp->touch_af_state == CAM_TOUCH_AF_STATE_READY) {
4686 camapp->touch_af_state = CAM_TOUCH_AF_STATE_DOING;
4687 cam_app_draw_af_box(ad);
4688 evas_object_show(ad->focus_edje);
4689 cam_ui_effect_utils_set_zoom_effect(ad->focus_edje,
4690 CAM_FOCUS_EDJE_ZOOM_EFFECT_END_RATE,
4691 CAM_FOCUS_EDJE_ZOOM_EFFECT_START_RATE,
4692 CAM_FOCUS_EDJE_ZOOM_EFFECT_DURATION);
4694 if (camapp->camera_mode == CAM_CAMCORDER_MODE && ad->is_recording) {
4696 cam_toolbar_show_cafbutton(ad, TRUE);
4699 cam_camera_touch_af_press(ad);
4704 void cam_app_set_config_group(gint mode)
4706 cam_debug(LOG_UI, "mode : %d", mode);
4708 if (mode == CAM_CAMERA_MODE) {
4709 cam_config_set_group_name(CAM_CONFIG_TYPE_PREVIEW, "still");
4711 cam_config_set_group_name(CAM_CONFIG_TYPE_PREVIEW, "video");
4714 debug_fleave(LOG_UI);
4719 int cam_app_get_latest_mode(void)
4721 cam_config_set_group_name(CAM_CONFIG_TYPE_COMMON, "common");
4723 cam_config_get_int_by_type(CAM_CONFIG_TYPE_COMMON, "mode",
4726 debug_msg(LOG_UI, "last mode:%d", last_mode);
4730 const gchar *cam_app_get_target_path(void)
4732 CamAppData *camapp = NULL;
4734 camapp = cam_handle_get();
4738 const gchar *default_path = NULL;
4739 switch (camapp->storage) {
4740 case CAM_STORAGE_INTERNAL:
4741 default_path = cam_file_get_internal_image_path();
4743 case CAM_STORAGE_EXTERNAL:
4744 default_path = cam_file_get_external_image_path();
4747 cam_critical(LOG_UI, "Unknow storage type : %d", camapp->storage);
4751 cam_debug(LOG_UI, "target path : [%s]", default_path);
4752 return default_path;
4754 cam_critical(LOG_UI, "camapp handle is NULL");
4759 gchar *cam_app_get_last_filename(void)
4761 CamAppData *camapp = NULL;
4762 gchar *last_file_path = NULL;
4763 struct appdata *ad = (struct appdata *)cam_appdata_get();
4764 cam_retvm_if(ad == NULL, NULL, "appdata is NULL");
4766 camapp = cam_handle_get();
4767 cam_retvm_if(camapp == NULL, NULL, "cam_handle is NULL");
4769 last_file_path = cam_file_get_last_file_path(ad, cam_app_get_target_path());
4771 if (last_file_path) {
4772 cam_debug(LOG_UI, "last_file_path : %s", last_file_path);
4774 cam_critical(LOG_UI, "last_file_path is NULL");
4777 return last_file_path;
4780 gchar *cam_app_get_next_filename(CamFileExtention extension)
4783 CamAppData *camapp = NULL;
4784 gchar *new_filename = NULL;
4785 struct appdata *ad = (struct appdata *)cam_appdata_get();
4786 cam_retvm_if(ad == NULL, NULL, "appdata is NULL");
4788 camapp = cam_handle_get();
4789 cam_retvm_if(camapp == NULL, NULL, "cam_handle is NULL");
4791 mm_state = cam_mm_get_state();
4793 if( extension == CAM_FILE_EXTENTION_IMAGE){
4794 new_filename = cam_file_get_next_filename(cam_app_get_target_path(), INAGE_FILE_NAME, IMAGE_FILE_EXTENSION);
4796 if ((camapp->recording_mode == CAM_RECORD_MMS)
4797 || (camapp->recording_mode == CAM_RECORD_SELF_MMS))
4798 new_filename = cam_file_get_next_filename(cam_app_get_target_path(), VIDEO_FILE_NAME, VIDEO_FILE_EXTENSION_3GP);
4800 new_filename = cam_file_get_next_filename(cam_app_get_target_path(), VIDEO_FILE_NAME, VIDEO_FILE_EXTENSION_MP4);
4804 cam_debug(LOG_UI, "next filename : %s", new_filename);
4806 cam_critical(LOG_UI, "new_filename is NULL");
4809 return new_filename;
4812 static void __cam_preview_cb(camera_preview_data_s *preview_frame, void *user_data)
4815 cam_retm_if(user_data == NULL, "data is null");
4816 struct appdata *ad = (struct appdata *)user_data;
4818 CamAppData *camapp = ad->camapp_handle;
4819 cam_retm_if(camapp == NULL, "camapp is null");
4822 static void __cam_state_change_cb(camera_state_e previous, camera_state_e current,
4823 bool by_policy, void *user_data)
4825 struct appdata *ad = NULL;
4826 CamAppData *camapp = NULL;
4827 ad = (struct appdata *)user_data;
4828 cam_retm_if(ad == NULL, "camapp is null");
4829 camapp = ad->camapp_handle;
4830 cam_retm_if(camapp == NULL, "camapp is null");
4831 DEBUG_TRACE("current= %d, previous = %d, ad->enable_mode_change = %d", current, previous, ad->enable_mode_change);
4833 if (current == CAMERA_STATE_PREVIEW) {
4834 ad->enable_mode_change = TRUE;
4836 ad->enable_mode_change = FALSE;
4839 DEBUG_TRACE("current= %d, previous = %d, ad->enable_mode_change = %d", current, previous, ad->enable_mode_change);
4840 cam_app_camera_state_manager(previous, current, by_policy);
4844 static void __cam_focus_cb(camera_focus_state_e state, void *user_data)
4846 struct appdata *ad = (struct appdata *)user_data;
4847 cam_retm_if(ad == NULL, "appdata is NULL");
4848 CamAppData *camapp = ad->camapp_handle;
4849 cam_retm_if(camapp == NULL, "camapp is NULL");
4851 cam_debug(LOG_MM, " Focus state changed to [%d]", state);
4853 if (ad->ug_state == CAM_UG_PAUSE_STATE)
4856 camapp->focus_state = state ;
4858 if (ad->is_rotating == FALSE) {
4859 if (evas_object_visible_get(ad->focus_edje) == TRUE)
4860 cam_app_focus_guide_update(ad);
4864 case CAMERA_FOCUS_STATE_RELEASED:
4865 cam_debug(LOG_MM, "release");
4867 case CAMERA_FOCUS_STATE_ONGOING:
4868 cam_debug(LOG_MM, "ongoing");
4870 case CAMERA_FOCUS_STATE_FOCUSED:
4871 cam_debug(LOG_MM, "focused");
4872 if (camapp->camera_mode == CAM_CAMERA_MODE && ad->mm_state < CAMERA_STATE_CAPTURING) {
4873 if ((camapp->focus_mode == CAM_FOCUS_MODE_TOUCH_AUTO
4874 || camapp->focus_mode == CAM_FOCUS_MODE_HALFSHUTTER)
4875 && camapp->shutter_sound != CAM_SETTINGS_SOUND_OFF)
4876 cam_sound_play (CAM_SOUND_EFFECT_AF_OK, ad);
4878 if (camapp->focus_mode == CAM_FOCUS_MODE_TOUCH_AUTO) {
4879 if (camapp->touch_af_state == CAM_TOUCH_AF_STATE_READY
4880 ||camapp->touch_af_state == CAM_TOUCH_AF_STATE_DOING)
4881 camapp->touch_af_state = CAM_TOUCH_AF_STATE_NONE;
4883 REMOVE_TIMER(ad->continuous_af_timer);
4884 ad->continuous_af_timer = ecore_timer_add(FOCUS_FOCUSED_TIME_OUT, __cam_continuous_af_timer_cb, ad);
4887 } else if (camapp->camera_mode == CAM_CAMCORDER_MODE && ad->mm_state <= RECORDER_STATE_RECORDING) {
4888 if (camapp->focus_mode == CAM_FOCUS_MODE_TOUCH_AUTO
4889 && camapp->shutter_sound != CAM_SETTINGS_SOUND_OFF
4890 && ad->mm_state != RECORDER_STATE_RECORDING)
4891 cam_sound_play (CAM_SOUND_EFFECT_AF_OK, ad);
4893 if (camapp->focus_mode == CAM_FOCUS_MODE_TOUCH_AUTO) {
4894 if (camapp->touch_af_state == CAM_TOUCH_AF_STATE_READY
4895 ||camapp->touch_af_state == CAM_TOUCH_AF_STATE_DOING)
4896 camapp->touch_af_state = CAM_TOUCH_AF_STATE_NONE;
4899 REMOVE_TIMER(ad->continuous_af_timer);
4901 if (ad->is_recording)
4902 ad->continuous_af_timer = ecore_timer_add(FOCUS_FOCUSED_TIME_OUT, __focus_guide_destroy, ad);
4904 camapp->touch_af_state = CAM_TOUCH_AF_STATE_NONE;
4907 case CAMERA_FOCUS_STATE_FAILED:
4908 cam_debug(LOG_MM, "failed");
4909 if (camapp->camera_mode == CAM_CAMERA_MODE && ad->mm_state < CAMERA_STATE_CAPTURING) {
4910 if ((camapp->focus_mode == CAM_FOCUS_MODE_TOUCH_AUTO
4911 || camapp->focus_mode == CAM_FOCUS_MODE_HALFSHUTTER)
4912 && camapp->shutter_sound != CAM_SETTINGS_SOUND_OFF)
4913 cam_sound_play (CAM_SOUND_EFFECT_AF_FAIL, ad);
4915 if (camapp->focus_mode == CAM_FOCUS_MODE_TOUCH_AUTO) {
4916 if (camapp->touch_af_state == CAM_TOUCH_AF_STATE_READY
4917 ||camapp->touch_af_state == CAM_TOUCH_AF_STATE_DOING)
4918 camapp->touch_af_state = CAM_TOUCH_AF_STATE_NONE;
4920 REMOVE_TIMER(ad->continuous_af_timer);
4921 ad->continuous_af_timer = ecore_timer_add(FOCUS_FOCUSED_TIME_OUT, __cam_continuous_af_timer_cb, ad);
4923 } else if (camapp->camera_mode == CAM_CAMCORDER_MODE && ad->mm_state <= RECORDER_STATE_RECORDING) {
4924 if (camapp->focus_mode == CAM_FOCUS_MODE_TOUCH_AUTO
4925 && camapp->shutter_sound != CAM_SETTINGS_SOUND_OFF
4926 && ad->mm_state != RECORDER_STATE_RECORDING)
4927 cam_sound_play (CAM_SOUND_EFFECT_AF_FAIL, ad);
4929 if (camapp->focus_mode == CAM_FOCUS_MODE_TOUCH_AUTO) {
4930 if (camapp->touch_af_state == CAM_TOUCH_AF_STATE_READY
4931 ||camapp->touch_af_state == CAM_TOUCH_AF_STATE_DOING)
4932 camapp->touch_af_state = CAM_TOUCH_AF_STATE_NONE;
4935 REMOVE_TIMER(ad->continuous_af_timer);
4937 if (ad->is_recording)
4938 ad->continuous_af_timer = ecore_timer_add(FOCUS_FOCUSED_TIME_OUT, __focus_guide_destroy, ad);
4940 camapp->touch_af_state = CAM_TOUCH_AF_STATE_NONE;
4948 static void __cam_capture_cb(camera_image_data_s* image,
4949 camera_image_data_s* postview,
4950 camera_image_data_s* thumbnail,
4953 struct appdata *ad = (struct appdata *)user_data;
4954 cam_retm_if(ad == NULL, "appdata is NULL");
4955 CamAppData *camapp = NULL;
4956 camapp = ad->camapp_handle;
4957 cam_retm_if(camapp == NULL, "camapp is NULL");
4958 if (camapp->af_mode == CAM_FOCUS_FACE) {
4959 cam_app_stop_video_stream();
4961 gchar *filename = NULL;
4963 if ((image->format == CAMERA_PIXEL_FORMAT_YUYV)
4964 || (image->format == CAMERA_PIXEL_FORMAT_NV12)) {
4966 "got raw data - format [%d] data [%p], length [%d], width [%d], height [%d]",
4967 image->format, image->data, image->size, image->width,
4970 /* MMImageJpegEncodeToFile(filename, src->data, src->width,src->height, src->format, 90); */
4971 } else if (image->format == CAMERA_PIXEL_FORMAT_JPEG) {
4973 "got JPEG data - data [%p], length [%d], width [%d], height [%d]",
4974 image->data, image->size, image->width, image->height);
4975 if (camapp->camera_mode == CAM_CAMERA_MODE
4976 && camapp->shooting_mode == CAM_SELF_SINGLE_MODE) {
4979 cam_app_create_screennail_and_start_animation(user_data);
4983 filename = cam_app_get_next_filename(CAM_FILE_EXTENTION_IMAGE);
4984 if (filename == NULL) {
4985 cam_critical(LOG_SYS, " Get next filename FAILED");
4989 fp = fopen(filename, "w+");
4991 cam_critical(LOG_SYS, "FileOPEN error!!");
4994 cam_debug(LOG_SYS, "FileOPEN success");
4995 if (fwrite(image->data, image->size, 1, fp) != 1) {
4996 cam_critical(LOG_SYS, "File write error!!");
5000 /*fsync(fp->_fileno);*/
5001 /*block for increasing formance of shot-to-shot */
5002 cam_debug(LOG_SYS, "File write success");
5005 if (camapp->filename)
5006 free(camapp->filename);
5007 camapp->filename = strdup(filename);
5013 void cam_app_create_capture_complete_ui_idlers(void *data)
5015 struct appdata *ad = (struct appdata *)data;
5016 cam_ret_if(ad == NULL);
5017 CamIdlerItem *item = NULL;
5018 item = (CamIdlerItem *)g_malloc(sizeof(CamIdlerItem));
5019 cam_ret_if(item == NULL);
5023 item->idler = ecore_idler_add(cam_image_capture_handle_idler, item);
5026 ad->capture_cb_list = g_list_append(ad->capture_cb_list, item->idler);
5028 cam_info(LOG_UI, "image capture idler add : %p ", item->idler);
5032 static Eina_Bool __cam_app_progressbar_timer(void *data)
5036 Evas_Object *progressbar = (Evas_Object*) data;
5037 if (progressbar == NULL) {
5038 progress_timer = NULL;
5039 return ECORE_CALLBACK_CANCEL;
5042 value = elm_progressbar_value_get(progressbar);
5043 if (value == 1.0) value = 0.0;
5044 value = value + 0.025;
5045 elm_progressbar_value_set(progressbar, value);
5047 return ECORE_CALLBACK_RENEW;
5051 void cam_app_create_burst_popup(void *data)
5053 #if 1/*TODO: need ui guide, for display popup*/
5054 struct appdata *ad = NULL;
5055 CamAppData *camapp = NULL;
5057 ad = (struct appdata *)data;
5058 cam_ret_if(ad == NULL);
5059 camapp = ad->camapp_handle;
5060 cam_ret_if(camapp == NULL);
5062 if (cam_is_enabled_menu((void*)ad, CAM_MENU_BURST_SHOT_MODE) &&
5063 (camapp->burst_shot == TRUE) && camapp->continuous_shot_data) {
5064 ad->is_processing = TRUE;
5065 REMOVE_TIMER(ad->continuous_af_timer);
5066 cam_mm_stop_focusing();
5067 cam_toolbar_update_shutter_button(ad, TOOLBAR_ITEM_STATE_DIM);
5069 if (!cam_popup_for_burst_create(ad)) {/*TODO: need ui guide for this popup*/
5070 cam_debug(LOG_UI, "cam_progress_popup_create() fail");
5074 if (!cam_popup_add_progress_bar(ad))
5075 cam_debug(LOG_UI, "cam_popup_add_progress_bar() fail");
5077 if (!cam_popup_set_text(ad, dgettext(PACKAGE, "IDS_CAM_BODY_PROCESSING_ING")))
5078 cam_debug(LOG_UI, "cam_progress_popup_set_text() fail");
5080 progress_timer = ecore_timer_add(0.01, __cam_app_progressbar_timer, ad->progress_popup_bar);
5085 static void __cam_capture_completed_cb(void *user_data)
5088 struct appdata *ad = (struct appdata *)user_data;
5089 cam_retm_if(ad == NULL, "appdata is NULL");
5090 CamAppData *camapp = ad->camapp_handle;
5091 cam_retm_if(camapp == NULL, "cam_handle is NULL");
5093 if (camapp->af_mode == CAM_FOCUS_FACE) {
5094 cam_app_run_video_stream();
5097 if (camapp->camera_mode == CAM_CAMERA_MODE) {
5098 if (cam_is_enabled_menu((void*)ad, CAM_MENU_BURST_SHOT_MODE) &&
5099 (camapp->burst_shot == TRUE) && camapp->continuous_shot_data) {
5100 cam_utils_request_main_pipe_handler(ad, NULL, CAM_MAIN_PIPE_OP_TYPE_BURST_SHOT_DISPLAY_POPUP);
5101 cam_continuous_shot_finish_save_image();
5103 cam_utils_request_main_pipe_handler(ad, NULL, CAM_MAIN_PIPE_OP_TYPE_BEST_SHOT_IMAGE_HANDLE);
5106 DEBUG_TRACE("camapp->focus_mode %d ", camapp->focus_mode);
5107 if (camapp->focus_mode == CAM_FOCUS_MODE_HALFSHUTTER) {
5108 REMOVE_TIMER(ad->continuous_af_timer);
5109 ad->continuous_af_timer = ecore_timer_add(FOCUS_FOCUSED_TIME_OUT, __cam_continuous_af_timer_cb, ad);
5111 DEBUG_TRACE("camapp->burst_shot %d ", camapp->burst_shot);
5112 DEBUG_TRACE("camapp->default_capture_mode %d ", camapp->default_capture_mode);
5113 DEBUG_TRACE("ad->stop_continuous_shot %d ", ad->stop_continuous_shot);
5115 if (cam_is_enabled_menu((void*)ad, CAM_MENU_BURST_SHOT_MODE)
5116 && camapp->burst_shot == TRUE
5117 && camapp->default_capture_mode == CAM_CAPTURE_BURST) {
5118 DEBUG_TRACE("TEST");
5121 if (ad->ug_state == CAM_UG_PAUSE_STATE){
5122 cam_critical(LOG_MM, "CAM_UG_PAUSE_STATE");
5126 if (!cam_app_preview_start(ad)) {
5127 cam_critical(LOG_MM, "cam_app_preview_start failed");
5128 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_START_CAMERA"), cam_app_timeout_notice_response_cb);
5131 }else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
5132 DEBUG_TRACE("MM_MESSAGE_CAMCORDER_VIDEO_SNAPSHOT_CAPTURED");
5133 ecore_idler_add(cam_capture_on_recording_handle, ad);
5137 static void __cam_interrupted_cb(camera_policy_e policy, camera_state_e previous, camera_state_e current, void *data)
5139 struct appdata *ad = (struct appdata *)data;
5140 cam_retm_if(ad == NULL, "appdata is NULL");
5142 DEBUG_TRACE("policy is [%d]",policy);
5145 case CAMERA_POLICY_SOUND:
5146 DEBUG_TRACE("occur incoming call");
5148 case CAMERA_POLICY_SECURITY:
5149 cam_app_mdm_syspopup(ad);
5156 static void __rec_interrupted_cb(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *data)
5158 struct appdata *ad = (struct appdata *)data;
5159 cam_retm_if(ad == NULL, "appdata is NULL");
5161 DEBUG_TRACE("policy is [%d]",policy);
5164 case RECORDER_POLICY_SOUND:
5165 DEBUG_TRACE("occur incoming call");
5167 case RECORDER_POLICY_SECURITY:
5168 cam_app_mdm_syspopup(ad);
5175 static void __cam_error_cb(int error, camera_state_e current_state, void *user_data)
5177 struct appdata *ad = NULL;
5178 CamAppData *camapp = NULL;
5180 ad = (struct appdata *)user_data;
5181 cam_retm_if(ad == NULL, "appdata is NULL");
5182 camapp = ad->camapp_handle;
5183 cam_retm_if(camapp == NULL, "camapp is NULL");
5186 state = current_state;
5187 cam_warning(LOG_MM,"MM ERROR occurs : code [%x], state [%d]",error, state);
5189 char msg[1024] = { '\0', };
5191 snprintf(msg, sizeof(msg), "Internal error %x", error);
5192 cam_app_notice_popup(ad, msg, cam_app_timeout_notice_response_cb);
5196 static void __recorder_state_cb(recorder_state_e previous , recorder_state_e current , bool by_policy, void *user_data)
5198 struct appdata *ad = NULL;
5199 CamAppData *camapp = NULL;
5201 ad = (struct appdata *)user_data;
5202 cam_retm_if(ad == NULL, "appdata is NULL");
5203 camapp = ad->camapp_handle;
5204 cam_retm_if(camapp == NULL, "camapp is NULL");
5205 if (current == RECORDER_STATE_READY) {
5206 ad->enable_mode_change = TRUE;
5208 ad->enable_mode_change = FALSE;
5210 cam_app_recorder_state_manager(previous, current, by_policy);
5213 void __recording_status_cb(unsigned long long elapsed_time, unsigned long long file_size, void *user_data)
5215 struct appdata *ad = NULL;
5216 CamAppData *camapp = NULL;
5217 ad = (struct appdata *)user_data;
5218 cam_retm_if(ad == NULL, "appdata is NULL");
5219 camapp = ad->camapp_handle;
5220 cam_retm_if(camapp == NULL, "camapp is NULL");
5221 /* update current time */
5225 elapsed = elapsed_time / 1000;
5226 filesize = file_size;
5227 if (camapp->rec_elapsed < elapsed) {
5228 GValue value = { 0, };
5230 cam_debug(LOG_UI, "time updated: %u ", elapsed);
5231 CAM_GVALUE_SET_UINT(value, elapsed);
5232 cam_handle_value_set(ad, PROP_REC_TIME, &value);
5234 if (camapp->rec_filesize < filesize) {
5235 GValue value = { 0, };
5237 cam_debug(LOG_UI, "filesize updated: %u ", filesize);
5238 CAM_GVALUE_SET_UINT(value, filesize);
5239 cam_handle_value_set(ad, PROP_REC_FILE_SIZE, &value);
5243 void __recording_limit_reached_cb(recorder_recording_limit_type_e type, void *user_data)
5245 struct appdata *ad = NULL;
5246 CamAppData *camapp = NULL;
5247 ad = (struct appdata *)user_data;
5248 cam_retm_if(ad == NULL, "appdata is NULL");
5249 camapp = ad->camapp_handle;
5250 cam_retm_if(camapp == NULL, "camapp is NULL");
5253 if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
5254 if (type == RECORDER_RECORDING_LIMIT_FREE_SPACE)
5255 camapp->rec_stop_type = CAM_REC_STOP_NO_SPACE;
5256 else if (type == RECORDER_RECORDING_LIMIT_TIME
5257 || type == RECORDER_RECORDING_LIMIT_SIZE)
5258 camapp->rec_stop_type = CAM_REC_STOP_TIME_LIMIT;
5260 DEBUG_TRACE("invalid type:%d", type);
5261 camapp->rec_stop_type = CAM_REC_STOP_TIME_LIMIT;
5263 ad->recording_commit = ecore_idler_add(cam_video_idler_record_stop, ad);
5267 gboolean cam_callback_init(void *data)
5269 struct appdata *ad = (struct appdata *)data;
5270 CamAppData *camapp = NULL;
5272 debug_fenter(LOG_UI);
5274 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5275 camapp = ad->camapp_handle;
5276 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
5277 camapp->error_cb = __cam_error_cb;
5278 camapp->focus_cb = __cam_focus_cb;
5279 camapp->state_cb = __cam_state_change_cb;
5280 camapp->preview_cb = __cam_preview_cb;
5281 camapp->capture_completed_cb = __cam_capture_completed_cb;
5282 camapp->cam_interrupted_cb = __cam_interrupted_cb;
5284 camapp->recording_status_cb = __recording_status_cb;
5285 camapp->recording_state_changed_cb = __recorder_state_cb;
5286 camapp->recording_limit_reached_cb = __recording_limit_reached_cb;
5287 camapp->rec_interrupted_cb = __rec_interrupted_cb;
5289 /*set face detect cb*/
5290 camapp->face_detect_cb = cam_face_detection_focus_face_detected_cb;
5291 camapp->capture_cb = __cam_capture_cb;
5294 if (camapp->camera_mode == CAM_CAMERA_MODE) {
5295 /*ret &= cam_mm_recorder_unset_state_changed_cb();*/
5296 ret &= cam_mm_set_preview_cb(camapp->preview_cb, (void*)ad);
5297 ret &= cam_mm_set_focus_changed_cb(camapp->focus_cb, (void*)ad);
5298 ret &= cam_mm_set_state_changed_cb(camapp->state_cb, (void*)ad);
5299 ret &= cam_mm_set_error_cb(camapp->error_cb, (void*)ad);
5300 ret &= cam_mm_set_camera_interrupted_cb(camapp->cam_interrupted_cb, (void*)ad);
5301 } else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
5302 ret &= cam_mm_unset_state_changed_cb();
5303 ret &= cam_mm_set_focus_changed_cb(camapp->focus_cb, (void*)ad);
5304 ret &= cam_mm_recorder_set_state_changed_cb(camapp->recording_state_changed_cb, (void*)ad);
5305 ret &= cam_mm_recorder_set_recording_status_cb(camapp->recording_status_cb, (void*)ad);
5306 ret &= cam_mm_recorder_set_recording_limit_reached_cb(camapp->recording_limit_reached_cb, (void*)ad);
5307 ret &= cam_mm_set_recorder_interrupted_cb(camapp->rec_interrupted_cb, (void*)ad);
5314 gboolean cam_app_lbs_stop(void *data)
5316 struct appdata *ad = (struct appdata *)data;
5317 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5318 CamAppData *camapp = ad->camapp_handle;
5319 cam_retvm_if(camapp == NULL, FALSE, "camapp is NULL");
5323 ret = cam_lbs_stop();
5325 DEBUG_TRACE("cam_app_lbs_stop failed");
5328 camapp->gps = FALSE;
5329 camapp->gps_level = cam_lbs_get_state();
5330 indicator_update_gps(ad); /* update gps icon */
5331 if (!cam_mm_remove_geo_tag())
5332 DEBUG_TRACE("cam_mm_remove_geo_tag failed");
5337 gboolean cam_app_lbs_start(void *data)
5339 struct appdata *ad = (struct appdata *)data;
5340 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5341 CamAppData *camapp = ad->camapp_handle;
5342 cam_retvm_if(camapp == NULL, FALSE, "camapp is NULL");
5346 ret = cam_lbs_start(cam_app_update_gps_level, ad);
5348 if(camapp->need_gps_popup == TRUE) {
5349 cam_app_gps_enable_popup(ad,
5350 dgettext(PACKAGE, "IDS_CAM_POP_ENABLE_LOCATION_SERVICE_IN_SETTINGS_TO_USE_GPS_TAG"), NULL);
5356 REMOVE_TIMER(ad->gps_animation_timer);
5357 ad->gps_animation_timer = ecore_timer_add(0.5, cam_app_gps_timer_cb, ad);
5363 static void cam_app_close_ug(void *data)
5365 cam_debug(LOG_UI, " ");
5366 struct appdata *ad = (struct appdata *)data;
5369 cam_info(LOG_UI, "ad->imageviewer_ug : %p", ad->imageviewer_ug);
5370 if (ad->imageviewer_ug) {
5371 ug_destroy(ad->imageviewer_ug);
5372 ad->imageviewer_ug = NULL;
5374 if (ad->location_ug) {
5375 ug_destroy(ad->location_ug);
5376 ad->location_ug = NULL;
5379 cam_file_init(NULL);
5383 static void __ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
5385 cam_debug(LOG_UI, " ");
5392 base = ug_get_layout(ug);
5397 case UG_MODE_FULLVIEW:
5398 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5399 ug_disable_effect(ug);/*note: disable Image viewer ug effect*/
5400 evas_object_show(base);
5407 void __ug_result_cb(ui_gadget_h ug, service_h result, void *priv)
5409 cam_debug(LOG_UI, " ");
5411 struct appdata *ad = (struct appdata *)priv;
5412 cam_retm_if(ad == NULL, "appdata is NULL");
5413 CamAppData *camapp = ad->camapp_handle;
5414 cam_retm_if(camapp == NULL, "cam_handle is NULL");
5417 ad->path_in_return = false;
5419 if (ad->imageviewer_ug) {
5420 if (ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
5421 if (result == NULL) {
5425 if ((ad->exe_args->caller) && (strcmp(ad->exe_args->caller, "contacts") == 0)) {
5427 service_create(&reply);
5429 service_get_extra_data(result, "crop_image_path", &val);
5430 service_add_extra_data(reply, "crop_image_path", val);
5431 service_get_extra_data(result, "image_path", &val);
5432 service_add_extra_data(reply, "image_path", val);
5434 service_reply_to_launch_request(reply, ad->service_handle, SERVICE_RESULT_SUCCEEDED);
5435 service_destroy(reply);
5437 ad->path_in_return = true;
5438 } else if ((ad->exe_args->caller) && (strcmp(ad->exe_args->caller, "ug-setting-call-efl") == 0)) {
5440 service_create(&reply);
5442 service_get_extra_data(result, "crop_image_path", &val);
5443 service_add_extra_data(reply, SERVICE_DATA_SELECTED, val);
5445 service_reply_to_launch_request(reply, ad->service_handle, SERVICE_RESULT_SUCCEEDED);
5446 service_destroy(reply);
5448 ad->path_in_return = true;
5450 /* get result value. */
5451 service_get_extra_data(result, "Result", &val);
5453 if (strcmp(val, "Ok") == 0) {
5454 ad->path_in_return = true;
5456 else if (strcmp(val, "Cancel") == 0) {
5457 ad->path_in_return = false;
5464 void __ug_destroy_cb(ui_gadget_h ug, void *priv)
5466 cam_debug(LOG_UI, " ");
5471 struct appdata *ad = (struct appdata *)priv;
5472 cam_retm_if(ad == NULL, "appdata is NULL");
5473 CamAppData *camapp = ad->camapp_handle;
5474 cam_retm_if(camapp == NULL, "camapp is NULL");
5476 if (ad->path_in_return) {
5477 elm_win_lower(ad->win_main);
5480 ad->ug_is_deleting_process = TRUE;
5482 cam_app_timeout_checker_init(ad);
5484 if (ad->imageviewer_ug) {
5485 ug_destroy(ad->imageviewer_ug);
5486 ad->imageviewer_ug = NULL;
5489 if (ad->location_ug) {
5490 ug_destroy(ad->location_ug);
5491 ad->location_ug = NULL;
5492 camapp->need_gps_popup = FALSE;
5493 if (!cam_app_lbs_start(ad)) {
5494 if (!cam_app_lbs_stop(ad))
5495 DEBUG_TRACE("The LBS failed to stop");
5499 cam_app_start_rotate(ad, false);
5501 ecore_idler_add(__ug_destory_postprocessing, ad);
5507 Eina_Bool __ug_destory_postprocessing(void *data)
5509 struct appdata *ad = data;
5510 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5511 ad->ug_is_deleting_process = TRUE;
5512 CamAppData *camapp = NULL;
5513 camapp = ad->camapp_handle;
5514 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
5516 cam_app_focus_guide_create(ad);
5517 show_toolbar_edje(ad);
5519 if (!cam_file_check_exists(camapp->filename)) {
5520 free(camapp->filename);
5521 camapp->filename = NULL;
5524 if (!cam_app_preview_start(ad)) {
5525 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_START_CAMERA"), cam_app_timeout_notice_response_cb);
5528 cam_mm_set_mdnie_mode(TRUE);
5530 if (camapp->outdoor_visibility)
5531 cam_mm_set_outdoor_visibility(TRUE);
5533 power_lock_state(POWER_STATE_NORMAL, 0);
5535 if (camapp->camera_mode == CAM_CAMERA_MODE) {
5536 if(camapp->af_mode == CAM_FOCUS_FACE){
5537 /*start face detection*/
5538 if (cam_mm_is_supported_face_detection()) {
5539 cam_mm_start_camera_face_detection(camapp->face_detect_cb, (void *)ad);
5540 if (!cam_mm_set_preview_cb(cam_face_detection_focus_start_stream, (void*)ad)) {
5541 DEBUG_TRACE("preview callback set error");
5543 cam_app_run_video_stream();
5545 DEBUG_TRACE("not support face detect mode");
5549 if (!cam_key_grab_init(ad))
5550 DEBUG_TRACE("cam_key_grab_init fail");
5551 cam_app_key_event_init(ad);
5553 cam_app_update_quickview_icon(ad);
5554 cam_file_init(NULL);
5555 ad->ug_is_deleting_process = FALSE;
5557 return ECORE_CALLBACK_CANCEL;
5560 gboolean cam_app_run_location_ug(void *data)
5562 DEBUG_TRACE("START");
5564 struct appdata *ad = (struct appdata *)data;
5565 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5566 CamAppData *camapp = NULL;
5567 camapp = ad->camapp_handle;
5568 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
5570 if (ad->ug_is_deleting_process) /*NOTE:before old ug is not deleted completely, should not create new ug*/
5573 if (ad->location_ug) {
5574 ug_destroy(ad->location_ug);
5575 ad->location_ug = NULL;
5578 DEL_EVAS_OBJECT(ad->focus_edje);
5580 struct ug_cbs cbs = { 0, };
5582 cbs.layout_cb = __ug_layout_cb;
5583 cbs.result_cb = __ug_result_cb;
5584 cbs.destroy_cb = __ug_destroy_cb;
5585 cbs.priv = (void *)data;
5587 /* Create UI gadget */
5588 ad->location_ug = ug_create(NULL, LOCATION_UG_NAME, UG_MODE_FULLVIEW, NULL, &cbs);
5590 if (!ad->location_ug) {
5591 cam_critical(LOG_SYS, "location UI Gadget create fail...");
5594 if (ad->location_ug) {
5595 cam_mm_set_mdnie_mode(FALSE);
5597 if (camapp->outdoor_visibility)
5598 cam_mm_set_outdoor_visibility(FALSE);
5600 cam_app_preview_stop();
5601 power_unlock_state(POWER_STATE_NORMAL);
5603 cam_warning(LOG_UI, "Cannot create location_ug");
5604 cam_file_init(NULL);
5609 cam_app_timeout_checker_remove();
5613 gboolean cam_app_run_image_viewer_ug(void *data, char *file_path, gboolean launch_special_view)
5615 DEBUG_TRACE("START");
5617 struct appdata *ad = (struct appdata *)data;
5618 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5619 CamAppData *camapp = ad->camapp_handle;
5620 cam_retvm_if(camapp == NULL, FALSE,"camapp is NULL");
5621 cam_retvm_if(file_path == NULL, FALSE, "file_path is NULL");
5623 if (ad->ug_is_deleting_process) /*NOTE:before old ug is not deleted completely, should not create new ug*/
5626 cam_debug(LOG_UI, "path :%s", file_path);
5628 if (ad->imageviewer_ug) {
5629 return FALSE;/*NOTE: ug is login, not create ug again.*/
5631 if (ad->is_rotating == TRUE) {
5632 return FALSE; /*note: while rotating, could not create image view ug*/
5635 DEL_EVAS_OBJECT(ad->focus_edje);
5637 struct ug_cbs cbs = { 0, };
5639 cbs.layout_cb = __ug_layout_cb;
5640 cbs.result_cb = __ug_result_cb;
5641 cbs.destroy_cb = __ug_destroy_cb;
5642 cbs.priv = (void *)data;
5645 if (ad->imageviewer_service)
5646 service_destroy(ad->imageviewer_service);
5648 int ret = service_create(&ad->imageviewer_service);
5649 if (ret != SERVICE_ERROR_NONE) {
5650 cam_critical(LOG_UI, "service_create error [%d]", ret);
5654 if (ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
5655 if ((ad->exe_args->caller) && (strcmp(ad->exe_args->caller, "contacts") == 0)) {
5656 service_add_extra_data(ad->imageviewer_service, IMAGE_VIEWER_VIEW_MODE_KEY_NAME, "SETAS");
5657 service_add_extra_data(ad->imageviewer_service, IMAGE_VIEWER_SET_AS_TYPE, "CallerID");
5658 } else if ((ad->exe_args->caller) && (strcmp(ad->exe_args->caller, "ug-setting-call-efl") == 0)) {
5659 service_add_extra_data(ad->imageviewer_service, IMAGE_VIEWER_VIEW_MODE_KEY_NAME, "SETAS");
5660 service_add_extra_data(ad->imageviewer_service, IMAGE_VIEWER_SET_AS_TYPE, "VideoCallID");
5661 service_add_extra_data(ad->imageviewer_service, IMAGE_VIEWER_RESOLUTION, "176x144");
5663 service_add_extra_data(ad->imageviewer_service, IMAGE_VIEWER_VIEW_MODE_KEY_NAME, "DISPLAY");
5665 } else if (ad->launching_mode == CAM_LAUNCHING_MODE_NORMAL) {
5666 service_add_extra_data(ad->imageviewer_service, IMAGE_VIEWER_VIEW_MODE_KEY_NAME, "CAMERA");
5669 service_add_extra_data(ad->imageviewer_service, IMAGE_VIEWER_FILE_PATH_KEY_NAME, file_path);
5671 /* Create UI gadget */
5672 ad->imageviewer_ug = ug_create(NULL, IMAGE_VIEWER_UG_NAME, UG_MODE_FULLVIEW, ad->imageviewer_service, &cbs);
5674 if (!ad->imageviewer_ug) {
5675 cam_critical(LOG_SYS, "image viewer UI Gadget create fail...");
5678 if (ad->imageviewer_ug) {
5679 cam_app_key_event_deinit(ad);
5680 if(!cam_key_grab_deinit(ad)){
5681 DEBUG_TRACE("cam_key_grab_deinit fail");
5683 cam_mm_set_mdnie_mode(FALSE);
5685 if (camapp->outdoor_visibility)
5686 cam_mm_set_outdoor_visibility(FALSE);
5688 cam_app_preview_stop();
5689 power_unlock_state(POWER_STATE_NORMAL);
5691 cam_warning(LOG_UI, "Cannot create imageviewer ug");
5692 cam_file_init(NULL);
5697 if(camapp->af_mode == CAM_FOCUS_FACE){
5698 cam_face_detection_reset();
5702 cam_app_timeout_checker_remove();
5707 gboolean cam_app_run_media_browser(void *data, gchar *filename)
5709 cam_debug(LOG_UI, "filename = %s", filename);
5710 struct appdata *ad = (struct appdata *)data;
5711 CamAppData *camapp = NULL;
5714 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5715 camapp = ad->camapp_handle;
5716 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
5718 debug_fenter(LOG_UI);
5720 state = cam_mm_get_state();
5721 if (state > CAMERA_STATE_PREVIEW) {
5722 cam_warning(LOG_MM, "Invaild state : %d", state);
5726 if (!cam_app_run_image_viewer_ug(ad, cam_app_get_last_filename(), FALSE)) {
5727 DEBUG_TRACE("cam_app_run_image_viewer_ug failed");
5731 if (camapp->thumbnail_name) { /* Some image is deleted from image viewer and galler -> BS */
5732 free(camapp->thumbnail_name);
5733 camapp->thumbnail_name = NULL;
5739 gboolean cam_app_clear_engine_data(void *data, gboolean release)
5741 #ifndef CAMERA_MACHINE_I686
5743 /* release is not used */
5744 struct appdata *ad = (struct appdata *)data;
5745 CamAppData *camapp = NULL;
5747 cam_debug(LOG_UI, "");
5749 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5750 camapp = ad->camapp_handle;
5751 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
5757 gboolean cam_app_check_wide_resolution(int id)
5760 gfloat get_value = (HIWORD(id) * 3.0) / (LOWORD(id) * 4.0);
5761 if (ABS(get_value - 1.0) < CAM_EPSINON
5762 || ABS((gfloat)((HIWORD(id) * 25.0) / (LOWORD(id) * 36.0)) - 1.0) < CAM_EPSINON) {
5770 gboolean cam_app_is_skip_video_stream()
5771 { /*if true , must finish function in stream callback function */
5772 return video_stream_skip_flag;
5775 void cam_app_stop_video_stream()
5777 video_stream_skip_flag = TRUE;
5780 void cam_app_run_video_stream()
5782 video_stream_skip_flag = FALSE;
5785 Eina_Bool _auto_shot_idle_cb(void *data)
5787 debug_fenter(LOG_CAM);
5788 struct appdata *ad = (struct appdata *)data;
5789 CamAppData *camapp = NULL;
5790 gboolean capture_result = false;
5792 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5793 camapp = ad->camapp_handle;
5794 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
5796 if (ad->auto_shot_idle) {
5797 ecore_idler_del(ad->auto_shot_idle);
5798 ad->auto_shot_idle = NULL;
5801 cam_warning(LOG_CAM, "position state not enough");
5802 debug_fleave(LOG_CAM);
5804 return ECORE_CALLBACK_CANCEL;
5807 gboolean cam_app_create_progressbar(void *data)
5809 struct appdata *ad = (struct appdata *)(data);
5810 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5812 cam_debug(LOG_UI, "");
5814 cam_app_destroy_progressbar(ad);
5816 ad->progressbar = elm_progressbar_add(ad->ug_base);
5817 cam_retvm_if(ad->progressbar == NULL, FALSE, "Cannot create progressbar object\n");
5819 elm_object_style_set(ad->progressbar, "list_progress");
5820 evas_object_size_hint_align_set(ad->progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
5822 evas_object_show(ad->progressbar);
5827 gboolean cam_app_set_progressbar_value(void *data, double value)
5829 struct appdata *ad = (struct appdata *)(data);
5830 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5832 if (ad->progressbar) {
5833 cam_debug(LOG_UI, " value [%f]", value);
5834 elm_progressbar_value_set(ad->progressbar, value);
5841 gboolean cam_app_set_progressbar_text(void *data, const char *text)
5843 struct appdata *ad = (struct appdata *)(data);
5844 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5846 cam_retv_if(text == NULL, FALSE);
5848 if (ad->progressbar_edje)
5849 edje_object_part_text_set(_EDJ(ad->progressbar_edje),
5850 "progressbar_text", text);
5855 gboolean cam_app_destroy_progressbar(void *data)
5857 struct appdata *ad = (struct appdata *)(data);
5858 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5860 cam_debug(LOG_UI, " start");
5861 DEL_EVAS_OBJECT(ad->progressbar);
5862 DEL_EVAS_OBJECT(ad->progressbar_edje);
5863 cam_debug(LOG_UI, " done");
5868 gboolean cam_app_hide_progressbar(void *data)
5870 struct appdata *ad = (struct appdata *)(data);
5871 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5873 cam_debug(LOG_UI, " start");
5874 HIDE_EVAS_OBJECT(ad->progressbar);
5875 HIDE_EVAS_OBJECT(ad->progressbar_edje);
5876 cam_debug(LOG_UI, " done");
5881 gboolean cam_app_timeout_checker_update()
5883 struct appdata *ad = NULL;
5884 CamAppData *camapp = NULL;
5885 gdouble c_time = 0.0;
5886 cam_debug(LOG_UI, "");
5888 ad = (struct appdata *)cam_appdata_get();
5889 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
5890 camapp = ad->camapp_handle;
5891 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
5893 if (ad->timeout_checker) {
5894 c_time = _get_current_time();
5895 ecore_timer_delay(ad->timeout_checker,
5896 (c_time - camapp->last_time));
5897 camapp->last_time = c_time;
5903 void cam_app_mdm_syspopup(void *data)
5905 struct appdata *ad = (struct appdata *)(data);
5906 cam_retm_if(ad == NULL, " appdata is NULL");
5908 b = bundle_create();
5910 bundle_add(b, "_SYSPOPUP_CONTENT_", dgettext(PACKAGE, "IDS_CAM_POP_SECURITY_POLICY_RESTRICTS_USE_OF_CAMERA"));
5911 syspopup_launch("mdm-syspopup", b);
5918 void cam_app_notice_popup(void *data, const char *msg,
5919 void (*func) (void *data,
5924 struct appdata *ad = (struct appdata *)(data);
5925 cam_retm_if(ad == NULL, " appdata is NULL");
5926 cam_retm_if(ad->ug_base == NULL, " ad->ug_base is NULL");
5927 Evas_Object *popup = NULL;
5929 popup = elm_popup_add(ad->ug_base);
5933 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5934 elm_object_text_set(popup, msg);
5935 /*elm_popup_mode_set(popup, ELM_POPUP_TYPE_ALERT);*/
5936 elm_popup_timeout_set(popup, 3.0);
5937 evas_object_smart_callback_add(popup, "timeout", func, data);
5938 ad->waring_popup = popup;
5939 evas_object_show(popup);
5942 static void cam_app_capture_error_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
5944 struct appdata *ad = (struct appdata *)cam_appdata_get();
5945 cam_retm_if(ad == NULL, " appdata is NULL");
5946 CamAppData *camapp = ad->camapp_handle;
5947 cam_retm_if(camapp == NULL, " camapp is NULL");
5949 evas_object_del(obj);
5952 cam_app_stop_capture(ad);
5956 void cam_app_gps_enable_popup(void *data, const char *msg,
5957 Eina_Bool (*func) (void *data))
5959 struct appdata *ad = (struct appdata *)(data);
5960 cam_retm_if(ad == NULL, " appdata is NULL");
5961 cam_retm_if(ad->ug_base == NULL, " ad->ug_base is NULL");
5962 Evas_Object * popup = NULL;
5963 popup = elm_popup_add(ad->ug_base);
5966 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5968 char popup_str[1024 + 1] = { '\0',};
5969 snprintf(popup_str, 1024, "%s%s%s", _("<font=SLP:style=Roman><color=#000000><align=center>"),
5970 msg, _("</align></color></font>"));
5972 elm_object_text_set(popup, popup_str);
5973 Evas_Object *btn1 = elm_button_add(popup);
5974 elm_object_text_set(btn1, dgettext(PACKAGE, "IDS_CAM_BODY_SETTINGS"));
5975 elm_object_part_content_set(popup, "button1", btn1);
5976 evas_object_smart_callback_add(btn1, "clicked", cam_app_gps_popup_response_ok_cb, (void*)ad);
5977 Evas_Object *btn2 = elm_button_add(popup);
5978 elm_object_text_set(btn2, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
5979 elm_object_part_content_set(popup, "button2", btn2);
5980 evas_object_smart_callback_add(btn2, "clicked", cam_app_gps_popup_response_cancel_cb, (void*)ad);
5981 ad->confirm_popup = popup;
5983 evas_object_show(popup);
5987 void cam_app_timeout_notice_response_cb(void *data, Evas_Object *obj,
5990 struct appdata *ad = (struct appdata *)cam_appdata_get();
5991 cam_retm_if(ad == NULL, " appdata is NULL");
5993 CamAppData *camapp = NULL;
5994 camapp = ad->camapp_handle;
5995 cam_retm_if(camapp == NULL, "camapp_handle is NULL");
5998 evas_object_del(obj);
6002 cam_app_stop_capture(ad);
6007 void cam_close_flash_feature(void *data)
6009 struct appdata *ad = (struct appdata *)data;
6010 cam_retm_if(ad == NULL, " appdata is NULL");
6011 CamAppData *camapp = ad->camapp_handle;
6012 cam_retm_if(camapp == NULL, " appdata is NULL");
6013 if (camapp->flash > CAM_FLASH_OFF) {
6014 GValue value = { 0 };
6015 CAM_GVALUE_SET_INT(value, CAM_FLASH_OFF);
6016 gint tempval = g_value_get_int(&value);
6017 if (!cam_mm_set_flash(tempval)) {
6018 cam_warning(LOG_UI, "flash set fail");
6021 camapp->flash = tempval;
6024 /*lowbattery callback*/
6025 void cam_app_lowbattery_close_flash_cb(void *data, Evas_Object *obj, void *event_info)
6027 struct appdata *ad = (struct appdata *)cam_appdata_get();
6028 cam_retm_if(ad == NULL, " appdata is NULL");
6030 evas_object_del(obj);
6032 cam_close_flash_feature(ad);
6034 cam_toolbar_update(ad);
6037 static Eina_Bool cam_app_timeout_checker_cb(void *data)
6039 struct appdata *ad = (struct appdata *)(data);
6040 CamAppData *camapp = NULL;
6043 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
6044 camapp = ad->camapp_handle;
6045 if (camapp == NULL) {
6046 ad->timeout_checker = NULL;
6047 return ECORE_CALLBACK_CANCEL;
6049 ad->timeout_checker = NULL;
6051 diff = _get_current_time() - camapp->last_time;
6053 if ((cam_mm_get_state() == CAMERA_STATE_PREVIEW)
6054 && (diff >= CAMERA_APP_TIMEOUT)) {
6055 cam_debug(LOG_UI, "Close camera application!!! diff time:[%lf]", diff);
6056 ad->timeout_checker = NULL;
6057 camapp->last_time = 0;
6058 elm_win_lower(ug_get_window());
6061 cam_debug(LOG_UI, "diff time : [%lf]", diff);
6062 return ECORE_CALLBACK_CANCEL;
6065 gboolean cam_app_timeout_checker_init(void *data)
6067 struct appdata *ad = (struct appdata *)(data);
6068 CamAppData *camapp = NULL;
6070 debug_fenter(LOG_CAM);
6072 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
6073 camapp = ad->camapp_handle;
6074 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
6076 if (ad->timeout_checker) {
6077 ecore_timer_del(ad->timeout_checker);
6078 ad->timeout_checker = NULL;
6080 if (ad->timer_timer) {
6081 ad->timer_activated = false;
6082 DEL_EVAS_OBJECT(ad->timer_icon_edje);
6083 REMOVE_TIMER(ad->timer_timer);
6085 if (ad->continuous_shot_timer) {
6086 REMOVE_TIMER(ad->continuous_shot_timer);
6088 if (ad->check_af_timer) {
6089 REMOVE_TIMER(ad->check_af_timer);
6091 if (ad->gps_animation_timer) {
6092 REMOVE_TIMER(ad->gps_animation_timer);
6095 ad->timeout_checker = ecore_timer_add(CAMERA_APP_TIMEOUT, cam_app_timeout_checker_cb, ad);
6096 camapp->last_time = _get_current_time();
6101 gboolean cam_app_timeout_checker_remove(void)
6103 struct appdata *ad = NULL;
6104 CamAppData *camapp = NULL;
6106 debug_fenter(LOG_CAM);
6108 ad = (struct appdata *)cam_appdata_get();
6109 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
6110 camapp = ad->camapp_handle;
6111 cam_retvm_if(camapp == NULL, FALSE, "cam_handle is NULL");
6113 if (ad->timeout_checker) {
6114 ecore_timer_del(ad->timeout_checker);
6115 ad->timeout_checker = NULL;
6117 camapp->last_time = 0;
6122 #ifdef USE_FIFO_THREAD
6123 void *cam_app_FIFO_thread_run(void *data)
6125 struct appdata *ad = (struct appdata *)data;
6129 char buf[128] = { '\0', };
6131 cam_retvm_if(ad == NULL, NULL, "appdata is NULL");
6133 if (!access(CAM_FIFO_PATH, F_OK)) {
6134 unlink(CAM_FIFO_PATH);
6137 if (-1 == mkfifo(CAM_FIFO_PATH, 0666)) {
6138 cam_critical(LOG_SYS, " Make CamApp FIFO failed.");
6143 fd = open(CAM_FIFO_PATH, O_RDWR);
6145 cam_critical(LOG_SYS, " Open CamApp FIFO failed.");
6150 cam_debug(LOG_SYS, "Open CamApp FIFO [%s] success", CAM_FIFO_PATH);
6153 memset(buf, 0x00, 128);
6155 cam_debug(LOG_SYS, " Wait CamApp FIFO write...");
6157 int count = read(fd, buf, 128);
6159 cam_debug(LOG_SYS, " read error occur!");
6161 cam_debug(LOG_SYS, " Read from CamApp FIFO : [%s]", buf);
6163 if (!strcmp(buf, CAM_CAPTURE_AUTO_START)) {
6164 cam_debug(LOG_SYS, " #### Start _auto_shot_idle_cb");
6165 _auto_shot_idle_cb(data);
6166 } else if (!strcmp(buf, CAM_FIFO_CMD_EXIT)) {
6170 cam_warning(LOG_SYS, " Skip this...");
6175 unlink(CAM_FIFO_PATH);
6177 cam_debug(LOG_SYS, " Exit CamApp FIFO thread...");
6182 void cam_app_FIFO_thread_exit()
6184 int fd = open(CAM_FIFO_PATH, O_WRONLY);
6185 char *str_write = CAM_FIFO_CMD_EXIT;
6188 cam_critical(LOG_SYS, " Open CammApp FIFO file[%s] failed",
6191 int count = write(fd, str_write, strlen(str_write));
6193 cam_debug(LOG_SYS, " write error occur! ");
6196 cam_debug(LOG_SYS, " Write [%s] to FIFO Done.", str_write);
6202 gboolean cam_app_create_file_register_thread(void *data)
6204 struct appdata *ad = (struct appdata *)data;
6207 cam_debug(LOG_SYS, "");
6209 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
6211 err = pthread_mutex_init(&(ad->file_reg_mutex), NULL);
6213 cam_critical(LOG_CAM,
6214 "Create Camera file register mutex failed");
6218 err = pthread_cond_init(&(ad->file_reg_cond), NULL);
6220 cam_critical(LOG_CAM,
6221 "Create Camera file register cond failed");
6225 ad->file_reg_queue = g_queue_new();
6226 if (ad->file_reg_queue == NULL) {
6227 cam_critical(LOG_CAM,
6228 "Create Camera file register queue failed");
6232 err = pthread_create(&(ad->file_reg_thread), NULL, cam_app_file_register_thread_run, (void *)ad);
6235 cam_critical(LOG_CAM,
6236 "Create Camera file register thread failed");
6243 void *cam_app_file_register_thread_run(void *data)
6245 struct appdata *ad = (struct appdata *)data;
6246 gboolean Exit_loop = FALSE;
6247 cam_debug(LOG_FILE, "");
6249 pthread_mutex_lock(&ad->file_reg_mutex);
6251 while (!Exit_loop) {
6252 cam_debug(LOG_FILE, " wait signal...");
6254 pthread_cond_wait(&ad->file_reg_cond, &ad->file_reg_mutex);
6256 cam_debug(LOG_FILE, " signal received");
6257 while (!g_queue_is_empty(ad->file_reg_queue)) {
6258 char *filename = NULL;
6259 filename = g_queue_pop_head(ad->file_reg_queue);
6260 DEBUG_TRACE("filename is %s", filename);
6261 if (strcmp(REG_THREAD_EXIT, filename) == 0) {
6265 } else if (strcmp(UPDATE_THUMBNAIL, filename) == 0) {
6267 } else if (strcmp(UPDATE_THUMBNAIL_NO_ANI, filename) == 0) {
6269 } else if (strcmp(REC_FILE_SAVE_REG, filename) == 0) {
6270 cam_rec_save_and_register_video_file(ad);
6274 __cam_single_shot_reg_file(filename);
6276 cam_debug(LOG_FILE, " register done.");
6279 /*TODO: update thumbnail*/
6283 pthread_mutex_unlock(&ad->file_reg_mutex);
6285 pthread_mutex_destroy(&ad->file_reg_mutex);
6286 pthread_cond_destroy(&ad->file_reg_cond);
6288 cam_debug(LOG_SYS, " thread exit...");
6293 void cam_app_file_register_thread_exit(void *data)
6295 struct appdata *ad = (struct appdata *)data;
6296 char *exit_cmd = NULL;
6298 if (ad->file_reg_queue != NULL) {
6299 exit_cmd = strdup(REG_THREAD_EXIT);
6300 g_queue_push_tail(ad->file_reg_queue, exit_cmd);
6301 pthread_cond_signal(&ad->file_reg_cond);
6306 gboolean cam_app_init_with_args(void *data)
6308 struct appdata *ad = (struct appdata *)data;
6309 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
6310 cam_retvm_if(ad->camapp_handle == NULL, FALSE, "camapp is NULL");
6312 cam_debug(LOG_SYS, "");
6313 if (ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
6314 ad->camapp_handle->camera_mode = ad->exe_args->cam_mode;
6315 if (CAM_CAMCORDER_MODE == ad->camapp_handle->camera_mode) {
6316 if (ad->exe_args->resolution == CAM_RESOLUTION_QCIF) {
6317 ad->camapp_handle->recording_mode = CAM_RECORD_MMS;
6318 ad->camapp_handle->video_resolution = CAM_RESOLUTION_QCIF;
6319 ad->camapp_handle->reserved_setting_data.rear_recording_mode = CAM_RECORD_MMS;
6320 ad->camapp_handle->reserved_setting_data.rear_video_resolution = CAM_RESOLUTION_QCIF;
6321 ad->camapp_handle->reserved_setting_data.front_recording_mode = CAM_RECORD_SELF_MMS;
6322 ad->camapp_handle->reserved_setting_data.front_video_resolution = CAM_RESOLUTION_QCIF;
6323 ad->camapp_handle->fps = FPS_SLOW;
6324 if (ad->exe_args->size_limit <= 0) {
6325 ad->camapp_handle->size_limit = CAM_REC_MMS_MAX_SIZE;
6327 ad->camapp_handle->size_limit = ad->exe_args->size_limit;
6329 ad->camapp_handle->size_limit_type = CAM_MM_SIZE_LIMIT_TYPE_BYTE;
6331 ad->camapp_handle->recording_mode = CAM_RECORD_NORMAL;
6332 ad->camapp_handle->video_resolution = ad->exe_args->resolution;
6333 ad->camapp_handle->fps = FPS_DEFAULT;
6334 if (ad->exe_args->size_limit <= 0) {
6335 ad->camapp_handle->size_limit = CAM_REC_NORMAL_MAX_SIZE;
6337 ad->camapp_handle->size_limit = ad->exe_args->size_limit;
6339 ad->camapp_handle->size_limit_type = CAM_MM_SIZE_LIMIT_TYPE_BYTE;
6342 ad->camapp_handle->shooting_mode = CAM_SINGLE_MODE;
6343 ad->camapp_handle->default_capture_mode = CAM_CAPTURE_SINGLE;
6344 if (ad->exe_args->width <= 0
6345 || ad->exe_args->height <= 0) {
6346 ad->camapp_handle->photo_resolution = CAM_RESOLUTION_VGA;
6348 ad->camapp_handle->photo_resolution = CAM_RESOLUTION(ad->exe_args->width, ad->exe_args->height);
6351 ad->camapp_handle->review = ad->exe_args->review;
6353 cam_debug(LOG_SYS, " camera launch mode is normal.");
6357 cam_debug(LOG_SYS, " done");
6362 Eina_Bool cam_app_focus_guide_create(void *data)
6364 struct appdata *ad = (struct appdata *)data;
6365 cam_retv_if(ad == NULL, EINA_FALSE);
6367 /*NOTE: TODO, perhaps there is issue:
6368 while focus is animating, now delete focus_edje, what will occur?
6370 cam_ui_effect_utils_stop_zoom_effect();
6371 DEL_EVAS_OBJECT(ad->focus_edje);
6373 ad->focus_edje = cam_app_load_edj(ad->ug_base, CAM_UTILS_EDJ_NAME, "focus_image");
6375 if (ad->focus_edje == NULL) {
6376 cam_critical(LOG_UI, "focus_edje load failed ");
6379 evas_object_show(ad->focus_edje);
6384 static Eina_Bool __focus_guide_hide_timer_cb(void *data)
6386 struct appdata *ad = (struct appdata *)data;
6387 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
6389 if (ad->focus_guide_hide_timer)
6390 ad->focus_guide_hide_timer = NULL;
6393 edje_object_signal_emit(_EDJ(ad->focus_edje), "focus,hide", "program");
6395 return ECORE_CALLBACK_CANCEL;
6398 Eina_Bool cam_app_focus_guide_update(void *data)
6401 #ifndef CAMERA_MACHINE_I686
6402 struct appdata *ad = (struct appdata *)data;
6403 cam_retvm_if(ad == NULL, EINA_FALSE, "appdata is NULL");
6404 CamAppData *camapp = ad->camapp_handle;
6405 cam_retvm_if(ad->camapp_handle == NULL, EINA_FALSE, "camapp is NULL");
6407 if (ad->focus_edje == NULL) {
6411 REMOVE_TIMER(ad->focus_guide_hide_timer);
6413 /*note: relocation the focus edje*/
6414 evas_object_resize(ad->focus_edje, ad->camera_focus_w, ad->camera_focus_h);
6415 evas_object_move(ad->focus_edje, ad->af_start_x, ad->af_start_y);
6416 evas_object_show(ad->focus_edje);
6418 if (ad->imageviewer_ug) {
6419 edje_object_signal_emit(_EDJ(ad->focus_edje), "focus,hide", "program");
6423 if (ad->confirm_popup) {
6424 edje_object_signal_emit(_EDJ(ad->focus_edje), "focus,hide", "program");
6428 if (ad->is_processing) {
6429 edje_object_signal_emit(_EDJ(ad->focus_edje), "focus,hide", "program");
6433 if (ad->setting_ctxpopup
6435 || (ad->toolbar_setting_popup)
6436 || (ad->edit_shortcuts_popup)) {
6437 cam_debug(LOG_UI, "do not need to update focus");
6438 edje_object_signal_emit(_EDJ(ad->focus_edje), "focus,hide", "program");
6442 if (camapp->camera_mode == CAM_CAMERA_MODE
6443 && ad->mm_state == CAMERA_STATE_CAPTURING) {
6447 if (camapp->camera_mode == CAM_CAMERA_MODE
6448 && (ad->mm_state < CAMERA_STATE_PREVIEW || camapp->af_mode == CAM_FOCUS_FACE)) {
6449 edje_object_signal_emit(_EDJ(ad->focus_edje), "focus,hide", "program");
6452 if ((camapp->camera_mode == CAM_CAMCORDER_MODE)
6453 && (camapp->recording_mode == CAM_RECORD_SLOW
6454 || camapp->recording_mode == CAM_RECORD_FAST
6455 || camapp->recording_mode == CAM_RECORD_SELF
6456 || camapp->recording_mode == CAM_RECORD_SELF_MMS)) {
6457 edje_object_signal_emit(_EDJ(ad->focus_edje), "focus,hide", "program");
6459 char signame[30] = { '\0', };
6460 const char *focus_state_name[4] = {
6467 snprintf(signame, sizeof(signame), "%s,%s", "focus", focus_state_name[camapp->focus_state]);
6468 edje_object_signal_emit(_EDJ(ad->focus_edje), signame, "program");
6471 if ((camapp->focus_state == CAMERA_FOCUS_STATE_FOCUSED) || (camapp->focus_state == CAMERA_FOCUS_STATE_FAILED))
6472 ad->focus_guide_hide_timer = ecore_timer_add(1.0, __focus_guide_hide_timer_cb, ad);
6478 static int cam_app_camera_state_manager(int previous, int current, gboolean by_asm)
6480 struct appdata *ad = NULL;
6481 CamAppData *camapp = NULL;
6483 cam_info(LOG_UI, "STATE_CHANGED : %d -> %d ", previous, current);
6485 ad = (struct appdata *)cam_appdata_get();
6486 cam_retv_if(ad == NULL, FALSE);
6488 camapp = ad->camapp_handle;
6489 cam_retv_if(camapp == NULL, FALSE);
6491 ad->mm_state = current;
6493 if (current == CAMERA_STATE_PREVIEW) {
6494 if (previous == CAMERA_STATE_CAPTURING) {
6495 CAM_TA_ACUM_ITEM_END(" capture stop to preview", 0);
6496 CAM_TA_ACUM_ITEM_END("Total capture time", 0);
6497 cam_debug(LOG_MM, "capture end, preview start");
6501 if (current == CAMERA_STATE_CAPTURING) {
6502 if (previous == CAMERA_STATE_PREVIEW) {
6503 cam_debug(LOG_MM, "capture start, preview end");
6504 if ((camapp->shooting_mode == CAM_SELF_SINGLE_MODE
6505 && camapp->default_capture_mode == CAM_CAPTURE_SINGLE)){
6506 cam_app_create_screennail_and_start_animation(ad);
6514 static int cam_app_recorder_state_manager(int previous, int current, gboolean by_asm)
6516 struct appdata *ad = NULL;
6517 CamAppData *camapp = NULL;
6519 cam_info(LOG_UI, "STATE_CHANGED : %d -> %d ", previous, current);
6521 ad = (struct appdata *)cam_appdata_get();
6522 cam_retv_if(ad == NULL, FALSE);
6524 camapp = ad->camapp_handle;
6525 cam_retv_if(camapp == NULL, FALSE);
6527 ad->mm_state = current;
6529 if (((previous == RECORDER_STATE_RECORDING)
6530 && (current != RECORDER_STATE_PAUSED))
6531 ||((previous == RECORDER_STATE_PAUSED)
6532 && (current != RECORDER_STATE_RECORDING))) {/*finished recording*/
6534 cam_info(LOG_UI, "Set gamma NORMAL");
6536 if (camapp->filename) {
6537 free(camapp->filename);
6538 camapp->filename = NULL;
6541 if (cam_mm_get_filename(&camapp->filename, 0) == FALSE) { /*file size not used,so set to 0*/
6544 cam_info(LOG_UI, "Recorded file name [%s] ", camapp->filename);
6546 /*note: shooting mode change*/
6548 /* change to camera mode*/
6550 * TODO: if for any reason, not run here, there will be caused now now recording, but in record mode
6551 * So: I suggest while click capture button: judge now state and whether recording.
6553 if(ad->launching_mode == CAM_LAUNCHING_MODE_NORMAL) {
6554 if (ad->ug_state != CAM_UG_PAUSE_STATE) {/*if now is pause state, so do not set mode, just set while resume*/
6555 if (cam_app_mode_change(ad, CAM_CAMERA_MODE) == FALSE)
6561 /*TODO: I think state manager callback is called in thread, so we could do data logic here,
6562 and request ui operation to ecore_pipe*/
6563 cam_utils_request_main_pipe_handler(ad, NULL, CAM_MAIN_PIPE_OP_TYPE_VIDEO_CAPTURE_HANDLE);
6569 static Eina_Bool __cam_ug_destroy(void *data)
6571 struct appdata *ad = (struct appdata *)data;
6572 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
6574 ug_destroy_me(ad->camera_ug);
6576 return ECORE_CALLBACK_CANCEL;
6579 gboolean cam_app_exit(void *data)
6581 struct appdata *ad = (struct appdata *)data;
6582 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
6584 ecore_idler_add(__cam_ug_destroy, ad);
6589 static void cam_mmc_state_change_cb(keynode_t *key, void *data)
6591 struct appdata *ad = (struct appdata *)data;
6592 CamAppData *camapp = NULL;
6593 int mmc_state = vconf_keynode_get_int(key);
6595 cam_retm_if(ad == NULL, "appdata is NULL");
6596 camapp = ad->camapp_handle;
6597 cam_retm_if(camapp == NULL, "camapp_handle is NULL");
6599 cam_debug(LOG_SYS, " start");
6601 if (mmc_state == VCONFKEY_SYSMAN_MMC_REMOVED
6602 && camapp->storage == CAM_STORAGE_EXTERNAL) {
6604 GValue value = { 0 };
6605 int mm_state = cam_mm_get_state();
6607 if (mm_state == CAMERA_STATE_CAPTURING
6608 && (camapp->shooting_mode == CAM_SINGLE_MODE
6609 && camapp->default_capture_mode == CAM_CAPTURE_BURST)
6610 &&camapp->camera_mode == CAM_CAMERA_MODE) {
6611 if (camapp->continuous_shot_data) {
6612 if (camapp->continuous_shot_data->error != NULL) {
6613 cam_debug(LOG_SYS, " error [%s,%d]", camapp->continuous_shot_data->error->message, camapp->continuous_shot_data->error->code);
6614 g_error_free(camapp->continuous_shot_data->error);
6615 camapp->continuous_shot_data->error = NULL;
6618 camapp->continuous_shot_data->error = cam_error_new_literal(CAM_CONTI_SHOT_ERROR_MMC_REMOVED, dgettext(PACKAGE, "IDS_CAM_POP_MEMORY_CARD_REMOVED"));
6620 cam_debug(LOG_SYS, " continuous_shot_data is NULL");
6623 if ((mm_state == RECORDER_STATE_RECORDING
6624 || mm_state == RECORDER_STATE_PAUSED)
6625 &&camapp->camera_mode == CAM_CAMCORDER_MODE) {
6626 cam_video_record_cancel(ad);
6627 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_POP_REMOVE_MMC_RECORDING"), cam_app_popup_response_cb);
6629 #ifndef CAMERA_MACHINE_I686
6630 else if (mm_state != CAMERA_STATE_CAPTURING
6631 && camapp->camera_mode == CAM_CAMERA_MODE) {
6632 if (cam_app_check_blocking_popup()) {
6633 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_POP_MEMORY_CARD_REMOVED"), cam_app_popup_response_cb);
6639 CAM_GVALUE_SET_INT(value, CAM_STORAGE_INTERNAL);
6640 cam_handle_value_set(ad, PROP_STORAGE, &value);
6642 cam_info(LOG_UI, "MMC card is removed");
6645 cam_toolbar_setting_popup_update(ad);
6646 indicator_update_storage(ad);
6650 #ifdef CAMAPP_SIG_HANDLING
6652 * This function registers a user space signal handler for the signal SIGSEGV (Signal #11)
6656 static void cam_app_register_sigsegv(void)
6658 debug_fenter(LOG_SYS);
6660 /* cam_app_act.sa_flags = SA_SIGINFO | SA_NOCLDSTOP; */
6661 cam_app_act.sa_flags = SA_SIGINFO;
6662 cam_app_act.sa_handler = (void *)cam_app_sigsegv_handler;
6663 sigemptyset(&cam_app_act.sa_mask);
6665 #ifdef ENABLE_CHECK_CAM_STATUS
6666 sigaction(SIGALRM, &cam_app_act, &cam_app_act_old); /* register an action with a previous action */
6668 sigaction(SIGABRT, &cam_app_act, &cam_app_act_old);
6669 sigaction(SIGSEGV, &cam_app_act, &cam_app_act_old);
6670 sigaction(SIGILL, &cam_app_act, &cam_app_act_old);
6672 debug_fleave(LOG_SYS);
6676 cam_app_sigsegv_handler(int signal_no, siginfo_t *info, void *context)
6678 debug_fenter(LOG_SYS);
6680 cam_debug(LOG_SYS, "signal_no = %d", signal_no);
6682 if (signal_no == SIGALRM) { /* if alarm, check the camera status. */
6683 #ifdef ENABLE_CHECK_CAM_STATUS
6684 cam_app_check_status();
6685 alarm(CAM_CHECK_STATUS_INTERVAL_TIME);
6689 sigaction(signal_no, &cam_app_act_old, NULL); /* register the previous action */
6693 debug_fleave(LOG_SYS);
6698 #ifdef ENABLE_CHECK_CAM_STATUS
6700 static void cam_app_check_status()
6702 cam_debug(LOG_SYS, "check status");
6704 #endif /* ENABLE_CHECK_CAM_STATUS */
6706 void cam_app_toggle_indicator(void *data, gboolean hide)
6708 struct appdata *ad = (struct appdata *)data;
6709 cam_retm_if(ad == NULL, "appdata is NULL");
6711 indicator_toggle(ad, hide);
6716 void cam_app_toggle_toolbar(void *data, gboolean hide)
6718 struct appdata *ad = (struct appdata *)data;
6719 cam_retm_if(ad == NULL, "appdata is NULL");
6722 hide_toolbar_edje(ad);
6724 show_toolbar_edje(ad);
6731 cam_app_reset_settings_launch_cb(void *data, Evas_Object *obj, void *event_info)
6733 Evas_Object *notify = (Evas_Object *)data;
6734 GValue i_value = { 0, };
6735 GValue b_value = { 0, };
6736 struct appdata *ad = (struct appdata *)cam_appdata_get();
6737 CamAppData *camapp = NULL;
6739 cam_debug(LOG_CAM, "!!!!!!!!!cam_app_reset_settings_launch_cb");
6741 cam_retm_if(ad == NULL, " appdata is NULL");
6742 camapp = ad->camapp_handle;
6743 cam_retm_if(camapp == NULL, " cam_handle is NULL");
6745 cam_popup_remove(notify);
6746 hide_toolbar_edje(ad);
6748 cam_app_preview_stop();
6750 g_value_init(&i_value, G_TYPE_INT);
6751 g_value_init(&b_value, G_TYPE_BOOLEAN);
6755 g_value_set_int(&i_value, AF_DEFAULT);
6756 cam_handle_value_set(ad, PROP_AF_MODE, &i_value);
6759 g_value_set_int(&i_value, TIMER_DEFAULT);
6760 cam_handle_value_set(ad, PROP_TIMER, &i_value);
6763 g_value_set_int(&i_value, WB_DEFAULT);
6764 cam_handle_value_set(ad, PROP_WB, &i_value);
6767 g_value_set_int(&i_value, EFFECT_DEFAULT);
6768 cam_handle_value_set(ad, PROP_EFFECT, &i_value);
6771 g_value_set_int(&i_value, ISO_DEFAULT);
6772 cam_handle_value_set(ad, PROP_ISO, &i_value);
6775 g_value_set_int(&i_value, AE_DEFAULT);
6776 cam_handle_value_set(ad, PROP_METERING, &i_value);
6779 g_value_set_int(&i_value, AHS_DEFAULT);
6780 cam_handle_value_set(ad, PROP_AHS, &i_value);
6782 /* wild dynamic range */
6783 g_value_set_int(&i_value, WDR_DEFAULT);
6784 cam_handle_value_set(ad, PROP_WDR, &i_value);
6787 g_value_set_int(&i_value, QUALITY_DEFAULT);
6788 cam_handle_value_set(ad, PROP_IMAGE_QUALITY, &i_value);
6791 g_value_set_int(&i_value, QUALITY_DEFAULT);
6792 cam_handle_value_set(ad, PROP_VIDEO_QUALITY, &i_value);
6795 g_value_set_boolean(&b_value, FALSE);
6796 cam_handle_value_set(ad, PROP_GUIDELINE, &b_value);
6797 settings_guideline_refresh(ad);
6799 g_value_set_boolean(&b_value, FALSE);
6800 cam_handle_value_set(ad, PROP_REVIEW, &b_value);
6803 g_value_set_boolean(&b_value, FALSE);
6804 cam_handle_value_set(ad, PROP_GPS, &b_value);
6807 g_value_set_int(&i_value, SHUTTER_SOUND_DEFAULT);
6808 cam_handle_value_set(ad, PROP_SHUTTER_SOUND, &i_value);
6810 /* audio recording */
6811 g_value_set_boolean(&b_value, TRUE);
6812 cam_handle_value_set(ad, PROP_AUDIO_REC, &b_value);
6815 g_value_set_int(&i_value, STORAGE_DEFAULT);
6816 cam_handle_value_set(ad, PROP_STORAGE, &i_value);
6819 g_value_set_int(&i_value, BRIGHTNESS_DEFAULT);
6820 cam_handle_value_set(ad, PROP_BRIGHTNESS, &i_value);
6823 g_value_set_int(&i_value, IMAGE_RESOLUTION_DEFAULT);
6824 cam_handle_value_set(ad, PROP_PHOTO_RESOLUTION, &i_value);
6826 g_value_set_int(&i_value, REC_RESOLUTION_DEFAULT);
6827 cam_handle_value_set(ad, PROP_VIDEO_RESOLUTION, &i_value);
6829 if (ad->indicator_edje) {
6830 /* delete indicator */
6831 evas_object_hide(ad->indicator_edje);
6832 cam_indicator_destory(ad);
6834 cam_indicator_create(ad);
6836 show_toolbar_edje(ad);
6838 if (!cam_app_preview_start(ad)) {
6839 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_START_CAMERA"), cam_app_timeout_notice_response_cb);
6844 void cam_app_reset_settings(void *data)
6846 struct appdata *ad = (struct appdata *)data;
6847 cam_retm_if(ad == NULL, "appdata is NULL");
6848 cam_popup_question_add(ad->ug_base,
6849 dgettext(PACKAGE, "IDS_CAM_POP_RESET_CAMERA_SETTINGS"),
6850 dgettext("sys_string", "IDS_COM_SK_YES"),
6851 cam_app_reset_settings_launch_cb,
6852 dgettext("sys_string", "IDS_COM_SK_NO"),
6857 static gboolean __cam_toolbar_new_thumbnail_create(Evas_Object **obj,
6859 Evas_Coord *thumbnail_x,
6860 Evas_Coord *thumbnail_y,
6861 Evas_Coord *thumbnail_w,
6862 Evas_Coord *thumbnail_h)
6864 cam_retv_if(ad == NULL, FALSE);
6865 CamAppData *camapp = ad->camapp_handle;
6866 cam_retv_if(camapp == NULL, FALSE);
6867 cam_retv_if(obj == NULL, FALSE);
6868 cam_retv_if(ad->evas == NULL, FALSE);
6869 cam_retv_if(ad->toolbar.quickview_item.edje == NULL, FALSE);
6871 if(camapp->thumbnail_name == NULL) {
6875 Evas_Object *new_thumbnail_img = elm_bg_add(ad->toolbar.quickview_item.edje);
6876 Evas_Coord x = 0, y = 0, w = 0, h = 0;
6877 Evas_Object *layout = NULL;
6878 Evas_Object *thumbnail_area = NULL;
6880 cam_retv_if(new_thumbnail_img == NULL, FALSE);
6881 elm_bg_file_set(new_thumbnail_img, camapp->thumbnail_name, NULL);
6883 layout = elm_layout_edje_get(ad->toolbar.quickview_item.edje);
6884 thumbnail_area = (Evas_Object *) edje_object_part_object_get(layout,"thumbnail_area");
6885 cam_retv_if(thumbnail_area == NULL, FALSE);
6886 evas_object_geometry_get(thumbnail_area, &x, &y, &w, &h);
6892 evas_object_resize(new_thumbnail_img, 0, 0);
6893 evas_object_move(new_thumbnail_img, x, y);
6894 evas_object_show(new_thumbnail_img);
6895 *obj = new_thumbnail_img;
6899 static gboolean __filter_cam_app_pipe_handler(void *data, gint pipe_type)
6901 struct appdata *ad = (struct appdata *)data;
6902 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
6903 if (ad->ug_state == CAM_UG_TERMINATE_STATE
6904 || ad->ug_state == CAM_UG_PAUSE_STATE) {
6905 switch (pipe_type) {
6906 case CAM_MAIN_PIPE_OP_TYPE_BEST_SHOT_IMAGE_HANDLE:
6907 case CAM_MAIN_PIPE_OP_TYPE_VIDEO_CAPTURE_HANDLE:
6917 static void cam_app_pipe_handler(void *data, void *buffer, unsigned int nbyte)
6919 struct appdata *ad = (struct appdata *)data;
6920 cam_retm_if(ad == NULL, "appdata is NULL");
6923 /* DO NOT free buffer in here */
6924 /* buffer is freed by ecore */
6927 Ecore_Pipe_Data_Info * pipe_info = (Ecore_Pipe_Data_Info *)buffer;
6928 int main_pipe_type = pipe_info->cmd;
6929 DEBUG_TRACE("main_pipe_type %d", main_pipe_type);
6931 if (__filter_cam_app_pipe_handler(ad, main_pipe_type) == TRUE) {
6935 switch (main_pipe_type) {
6936 case CAM_MAIN_PIPE_OP_TYPE_UPDATE_THUMBNAIL:
6938 Evas_Object *new_thumbnail_image = NULL;
6939 Evas_Coord x = 0, y = 0, w = 0, h = 0;
6940 gboolean ret = FALSE;
6941 ret = __cam_toolbar_new_thumbnail_create(&new_thumbnail_image, ad, &x, &y, &w, &h);
6942 if (ret == FALSE || !new_thumbnail_image) {
6943 if (!new_thumbnail_image && ret) {
6944 DEL_EVAS_OBJECT(ad->toolbar.quickview_item.thumbnail_image);
6948 cam_ui_effect_utils_set_thumbnail_effect(new_thumbnail_image,
6953 CAM_THUMBNAIL_ANTIMATION_EFFECT_DURATION);
6956 case CAM_MAIN_PIPE_OP_TYPE_UPDATE_THUMBNAIL_NO_ANI:
6958 toolbar_update_quickview_thumbnail_no_animation(ad);
6961 case CAM_MAIN_PIPE_OP_TYPE_ROTATE_ANIMATOR:
6963 cam_ui_rotate_utils_rotate_start(ad, CAM_ROTATE_ICONS_ANTIMATION_DURATION);
6966 case CAM_MAIN_PIPE_OP_TYPE_SHUTTER_ANIMATION:
6968 cam_app_create_start_animation(ad);
6971 case CAM_MAIN_PIPE_OP_TYPE_BURST_SHOT_UPDATE_PROGRESS:
6973 cam_continuous_shot_update_progress_value(ad);
6976 case CAM_MAIN_PIPE_OP_TYPE_BURST_SHOT_DISPLAY_POPUP:
6978 cam_app_destroy_progressbar(ad);
6979 cam_app_create_burst_popup(ad);
6982 case CAM_MAIN_PIPE_OP_TYPE_BEST_SHOT_IMAGE_HANDLE:
6984 cam_image_capture_handle(ad);
6987 case CAM_MAIN_PIPE_OP_TYPE_UPDATE_VIEW:
6989 CamAppData *camapp = ad->camapp_handle;
6990 cam_retm_if(camapp == NULL, "camapp is NULL");
6992 camapp->update_view_cb(ad);
6995 case CAM_MAIN_PIPE_OP_TYPE_ERROR_POPUP:
6997 cam_create_error_popup(ad);
7000 case CAM_MAIN_PIPE_OP_TYPE_VIDEO_CAPTURE_HANDLE:
7002 cam_video_capture_handle(ad);
7005 case CAM_MAIN_PIPE_OP_TYPE_RUN_IMAGE_VIEWER:
7007 CamAppData *camapp = ad->camapp_handle;
7008 cam_retm_if(camapp == NULL, "camapp is NULL");
7009 cam_retm_if(camapp->filename == NULL, "camapp is NULL");
7010 if (!cam_app_run_image_viewer_ug(ad, camapp->filename, FALSE)) {
7018 /*note: free memory*/
7019 if (pipe_info->data) {
7020 free(pipe_info->data);
7028 void cam_focus_edje_rotate(void *data)
7030 struct appdata *ad = (struct appdata *)data;
7031 cam_retm_if(ad == NULL, "appdata is NULL");
7033 DEL_EVAS_OBJECT(ad->focus_edje);
7034 ad->focus_edje = cam_app_load_edj(ad->ug_base, CAM_UTILS_EDJ_NAME, "focus_image");
7036 cam_retm_if(ad->focus_edje == NULL, "focus_edje load failed");
7038 evas_object_resize(ad->focus_edje, ad->camera_focus_w, ad->camera_focus_h);
7039 evas_object_move(ad->focus_edje, ad->af_start_x, ad->af_start_y);
7040 evas_object_show(ad->focus_edje);
7042 cam_app_draw_af_box(ad);
7043 cam_app_focus_guide_update(ad);
7046 Eina_Bool cam_screen_rotate(void *data)
7048 struct appdata *ad = (struct appdata *)data;
7049 cam_retvm_if(ad == NULL, -1, "appdata is NULL");
7051 if (ad->imageviewer_ug) {
7052 ad->is_rotating = FALSE;
7056 elm_win_rotation_with_resize_set(ad->win_main, ad->angle);
7059 cam_focus_edje_rotate(ad);
7061 if (ad->timer_icon_edje)
7062 cam_app_timer_icon_rotate(ad);
7064 if (ad->toolbar_edje)
7065 cam_toolbar_rotate(ad);
7067 if (ad->recording_edje)
7068 cam_recording_rotate(ad);
7070 if (ad->indicator_edje)
7071 cam_indicator_rotate(ad);
7074 cam_tip_popup_rotate(ad);
7077 cam_zoom_create_pinch_edje(ad);
7079 if (ad->progress_popup != NULL)
7080 cam_popup_rotate(ad);
7082 cam_retvm_if(ad->camapp_handle == NULL, -1, "camapp_handle is NULL");
7084 toolbar_shot_guide_popup_create(ad, ad->camapp_handle->shooting_mode);
7091 if (ad->zoom_edje) {
7092 unload_zoom_edje(ad);
7096 if (ad->guideline_edje)
7097 settings_guideline_refresh(ad);
7099 /*update thumbnail*/
7100 toolbar_update_quickview_thumbnail_no_animation(ad);
7102 DEBUG_TRACE("ad->displayed_setting_popup = %d", ad->displayed_setting_popup);
7103 DEBUG_TRACE("ad->show_edit_shortcuts_popup_after_rotate = %d", ad->show_edit_shortcuts_popup_after_rotate);
7104 DEBUG_TRACE("ad->show_setting_popup_after_rotate = %d", ad->show_setting_popup_after_rotate);
7105 if ((ad->displayed_setting_popup != DISPLAY_NONE_POPUP)
7106 || (ad->show_edit_shortcuts_popup_after_rotate == TRUE)
7107 || (ad->show_setting_popup_after_rotate == TRUE)) {
7108 /*ecore_idler_add(cam_show_setting_menu, ad);*/
7109 /*note: use timer to delay creating the popup*/
7110 ecore_timer_add(0.1, cam_show_setting_menu, ad);
7112 ad->is_rotating = FALSE;
7115 if (ad->confirm_popup)
7116 evas_object_raise(ad->confirm_popup);
7118 return ECORE_CALLBACK_CANCEL;
7121 static Ecore_Idler *rotate_delay_idler = NULL;
7122 Eina_Bool cam_app_screen_rotate_idler(void *data)
7124 if (rotate_delay_idler) {
7125 ecore_idler_del(rotate_delay_idler);
7126 rotate_delay_idler = NULL;
7128 struct appdata *ad = (struct appdata *)data;
7129 cam_retv_if(ad == NULL, ECORE_CALLBACK_CANCEL);
7130 if (ad->ug_state == CAM_UG_TERMINATE_STATE
7131 || ad->ug_state == CAM_UG_PAUSE_STATE) {
7132 ad->is_rotating = FALSE;
7133 return ECORE_CALLBACK_CANCEL;
7135 cam_screen_rotate(ad);
7136 return ECORE_CALLBACK_CANCEL;
7139 void cam_app_screen_rotate(void *data)
7141 struct appdata *ad = (struct appdata *)data;
7142 cam_ret_if(ad == NULL);
7143 if (ad->ug_state == CAM_UG_TERMINATE_STATE
7144 || ad->ug_state == CAM_UG_PAUSE_STATE) {
7145 ad->is_rotating = FALSE;
7148 CamAppData *cam_handle = ad->camapp_handle;
7149 cam_ret_if(cam_handle == NULL);
7152 if (ad->toolbar_edje) {
7153 rotate_delay_idler = ecore_idler_add(cam_app_screen_rotate_idler, data);
7157 gboolean cam_app_get_photo_resolution(int *width, int *height)
7159 cam_retv_if(width == NULL || height == NULL, FALSE);
7161 struct appdata *ad = (struct appdata *)cam_appdata_get();
7162 cam_retvm_if(ad == NULL, FALSE, "ad is NULL");
7163 CamAppData *camapp = ad->camapp_handle;
7164 cam_retvm_if(ad->camapp_handle == NULL, FALSE, "camapp_handle is NULL");
7166 *width = CAM_RESOLUTION_W(camapp->photo_resolution);
7167 *height = CAM_RESOLUTION_H(camapp->photo_resolution);
7172 gboolean cam_app_reset_resolution(void *data, int width, int height, gboolean force_set)
7174 struct appdata *ad = (struct appdata *)data;
7175 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
7176 CamAppData *camapp = NULL;
7177 camapp = ad->camapp_handle;
7178 cam_retvm_if(camapp == NULL, FALSE, "camapp is NULL");
7180 gboolean ret = TRUE;
7183 cam_debug(LOG_MM, " reset resolution = [%d x %d], need_change_state = [%d]",
7184 width, height, force_set);
7186 if (camapp->camera_mode == CAM_CAMERA_MODE) {
7187 int cur_img_w, cur_img_h = 0;
7188 int recommanded_cur_w, recommanded_cur_h = 0;
7189 int recommanded_new_w, recommanded_new_h = 0;
7191 ret &= cam_mm_get_image_size(&cur_img_w, &cur_img_h);
7193 if ((cur_img_w == 1392) && (cur_img_h == 1392)) {
7194 recommanded_cur_w = 1392;
7195 recommanded_cur_h = 1392;
7197 cam_mm_get_recommanded_preview_size(&recommanded_cur_w, &recommanded_cur_h);
7199 ret &= cam_mm_set_image_size(width, height);
7201 if ((width == 1392) && (height == 1392)) {
7202 recommanded_new_w = 1392;
7203 recommanded_new_h = 1392;
7205 cam_mm_get_recommanded_preview_size(&recommanded_new_w, &recommanded_new_h);
7207 DEBUG_TRACE("cam_mm_get_recommanded_preview_size CUR[%d %d] NEW[%d %d]",
7208 recommanded_cur_w, recommanded_cur_h, recommanded_new_w, recommanded_new_h);
7210 if ((recommanded_cur_w != recommanded_new_w)
7211 ||(recommanded_cur_h != recommanded_new_h)
7214 state = cam_mm_get_cam_state();
7216 if (state == CAMERA_STATE_PREVIEW) {
7217 ret &= cam_app_preview_stop();
7218 ret &= cam_mm_set_video_size(recommanded_new_w, recommanded_new_h);
7219 ret &= cam_app_preview_start(ad);
7221 ret &= cam_mm_set_video_size(recommanded_new_w, recommanded_new_h);
7224 } else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
7225 int cur_video_w, cur_video_h = 0;
7226 cam_mm_get_video_size(&cur_video_w, &cur_video_h);
7228 if (((cur_video_w != width) || (cur_video_h != height)) && (force_set)) {
7229 state = cam_mm_get_rec_state();
7231 if (state == RECORDER_STATE_READY) {
7232 ret &= cam_app_preview_stop();
7233 ret &= cam_mm_set_video_size(width, height);
7234 ret &= cam_app_preview_start(ad);
7236 ret &= cam_mm_set_video_size(width, height);
7239 ret &= cam_mm_set_video_size(width, height);
7247 int cam_app_get_aenc_bitrate(void *data)
7249 struct appdata *ad = (struct appdata *)data;
7250 CamAppData *camapp = NULL;
7253 cam_retvm_if(ad == NULL, 0, "appdata is NULL");
7254 camapp = ad->camapp_handle;
7255 cam_retvm_if(camapp == NULL, 0, "camapp is NULL");
7257 if ((camapp->recording_mode == CAM_RECORD_MMS) ||(camapp->recording_mode == CAM_RECORD_SELF_MMS)) {
7258 bitrate = CAM_AUDIO_BITRATE_MMS;
7260 bitrate = CAM_AUDIO_BITRATE_NORMAL;
7266 int cam_app_get_venc_bitrate(void *data, int quality)
7268 struct appdata *ad = (struct appdata *)data;
7269 CamAppData *camapp = NULL;
7272 cam_retvm_if(ad == NULL, 0, "appdata is NULL");
7273 camapp = ad->camapp_handle;
7274 cam_retvm_if(camapp == NULL, 0, "camapp is NULL");
7276 if ((camapp->recording_mode == CAM_RECORD_MMS) ||(camapp->recording_mode == CAM_RECORD_SELF_MMS)) {
7278 case CAM_QUALITY_HIGH:
7279 case CAM_QUALITY_BEST:
7283 case CAM_QUALITY_MEDIUM:
7287 case CAM_QUALITY_LOW:
7292 cam_critical(LOG_MM, "INVALID QUAILTY");
7295 } else if ((camapp->recording_mode == CAM_RECORD_SLOW) ||(camapp->recording_mode == CAM_RECORD_FAST)) {
7297 case CAM_QUALITY_HIGH:
7298 case CAM_QUALITY_BEST:
7299 return_val = 10000000;
7302 case CAM_QUALITY_MEDIUM:
7303 return_val = 4000000;
7306 case CAM_QUALITY_LOW:
7307 return_val = 2000000;
7311 cam_critical(LOG_MM, "INVALID QUAILTY");
7315 switch (camapp->video_resolution) {
7316 case CAM_RESOLUTION_FULLHD:
7319 case CAM_QUALITY_HIGH:
7320 case CAM_QUALITY_BEST:
7321 return_val = 8000000;
7324 case CAM_QUALITY_MEDIUM:
7325 return_val = 4000000;
7328 case CAM_QUALITY_LOW:
7329 return_val = 2000000;
7333 cam_critical(LOG_MM, "INVALID QUAILTY");
7338 case CAM_RESOLUTION_HD:
7341 case CAM_QUALITY_HIGH:
7342 case CAM_QUALITY_BEST:
7343 return_val = 10000000;
7346 case CAM_QUALITY_MEDIUM:
7347 return_val = 4000000;
7350 case CAM_QUALITY_LOW:
7351 return_val = 2000000;
7355 cam_critical(LOG_MM, "INVALID QUAILTY");
7361 case CAM_RESOLUTION_WVGA:
7362 case CAM_RESOLUTION_WVGA2:
7365 case CAM_QUALITY_HIGH:
7366 case CAM_QUALITY_BEST:
7367 return_val = 4000000;
7370 case CAM_QUALITY_MEDIUM:
7371 return_val = 2000000;
7374 case CAM_QUALITY_LOW:
7375 return_val = 1000000;
7379 cam_critical(LOG_MM, "INVALID QUAILTY");
7385 case CAM_RESOLUTION_VGA:
7389 case CAM_QUALITY_HIGH:
7390 case CAM_QUALITY_BEST:
7391 return_val = 3000000;
7394 case CAM_QUALITY_MEDIUM:
7395 return_val = 1500000;
7398 case CAM_QUALITY_LOW:
7399 return_val = 500000;
7403 cam_critical(LOG_MM, "INVALID QUAILTY");
7409 case CAM_RESOLUTION_WQVGA:
7412 case CAM_QUALITY_HIGH:
7413 case CAM_QUALITY_BEST:
7414 return_val = 2000000;
7417 case CAM_QUALITY_MEDIUM:
7418 return_val = 1000000;
7421 case CAM_QUALITY_LOW:
7422 return_val = 500000;
7426 cam_critical(LOG_MM, "INVALID QUAILTY");
7432 case CAM_RESOLUTION_QVGA:
7435 case CAM_QUALITY_HIGH:
7436 case CAM_QUALITY_BEST:
7437 return_val = 384000;
7440 case CAM_QUALITY_MEDIUM:
7441 return_val = 192000;
7444 case CAM_QUALITY_LOW:
7449 cam_critical(LOG_MM, "INVALID QUAILTY");
7455 case CAM_RESOLUTION_QCIF:
7458 case CAM_QUALITY_HIGH:
7459 case CAM_QUALITY_BEST:
7460 return_val = 384000;
7463 case CAM_QUALITY_MEDIUM:
7464 return_val = 192000;
7467 case CAM_QUALITY_LOW:
7472 cam_critical(LOG_MM, "INVALID QUAILTY");
7479 cam_critical(LOG_MM, "INVALID QUAILTY");
7484 cam_debug(LOG_MM, "videoenc bit rate = %d, current quilty = %d",
7485 return_val, quality);
7489 gboolean cam_app_set_video_quality(void *data, int quality)
7491 struct appdata *ad = (struct appdata *)data;
7492 CamAppData *camapp = NULL;
7495 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
7496 camapp = ad->camapp_handle;
7497 cam_retvm_if(camapp == NULL, FALSE, "camapp is NULL");
7499 v_bitrate = cam_app_get_venc_bitrate(ad, quality);
7500 if (v_bitrate > 0) {
7501 cam_mm_set_video_encoder_bitrate(v_bitrate);
7509 gboolean cam_app_set_recording_mode(void *data, int mode)
7511 struct appdata *ad = (struct appdata *)data;
7512 CamAppData *camapp = NULL;
7513 int video_codec = 0, audio_codec = 0, sample_rate = 0;
7514 int file_format = RECORDER_FILE_FORMAT_MP4;
7518 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
7519 camapp = ad->camapp_handle;
7520 cam_retvm_if(camapp == NULL, FALSE, "camapp is NULL");
7521 DEBUG_TRACE("mode = %d" , mode);
7522 if (mode == CAM_RECORD_MMS || mode == CAM_RECORD_SELF_MMS) {
7523 DEBUG_TRACE("mode = %d" , mode);
7524 video_codec = RECORDER_VIDEO_CODEC_H263;
7525 audio_codec = RECORDER_AUDIO_CODEC_AMR;
7527 file_format = RECORDER_FILE_FORMAT_3GP;
7530 DEBUG_TRACE("mode = %d" , mode);
7531 video_codec = RECORDER_VIDEO_CODEC_MPEG4;
7532 audio_codec = RECORDER_AUDIO_CODEC_AAC;
7533 sample_rate = 44100;
7534 file_format = RECORDER_FILE_FORMAT_MP4;
7538 if (!cam_mm_set_codec(audio_codec, video_codec))
7541 if (!cam_mm_set_audio_source(sample_rate, channel))
7544 a_bitrate = cam_app_get_aenc_bitrate(ad);
7545 if (a_bitrate > 0) {
7546 cam_mm_set_audio_encoder_bitrate(a_bitrate);
7551 if (!cam_app_set_video_quality(ad, camapp->video_quality))
7554 if (!cam_mm_set_file_format(file_format))
7560 gboolean cam_app_set_size_limit(int max_val, int size_limit_type)
7564 switch (size_limit_type) {
7565 case CAM_MM_SIZE_LIMIT_TYPE_BYTE:
7566 ret = cam_mm_set_max_size(max_val);
7570 ret = cam_mm_set_max_time(REC_MAX_TIME_LIMITED);
7575 case CAM_MM_SIZE_LIMIT_TYPE_SECOND:
7576 ret = cam_mm_set_max_size(0);
7579 ret = cam_mm_set_max_time(max_val);
7584 g_assert_not_reached();
7590 gboolean cam_app_init_attribute(void *data, CamMode mode)
7592 struct appdata *ad = (struct appdata *)data;
7593 CamAppData *camapp = NULL;
7594 gboolean ret = TRUE;
7598 int rotate = CAMERA_ROTATION_270;
7599 int camera_rotate = CAMERA_ROTATION_NONE;
7601 int capture_video_format = -1;
7602 #ifdef TODO_SURRPORT
7603 int recording_video_format = -1;
7606 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
7607 camapp = ad->camapp_handle;
7608 cam_retvm_if(camapp == NULL, FALSE, "camapp is NULL");
7610 state = cam_mm_get_state();
7613 if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
7614 if (state != RECORDER_STATE_CREATED) {
7617 } else if(camapp->camera_mode == CAM_CAMERA_MODE) {
7618 if (state != CAMERA_STATE_CREATED) {
7624 cam_mm_get_video_size( &camapp->default_preview_width, &camapp->default_preview_height);
7625 DEBUG_TRACE("default_width = %d,default_height = %d", camapp->default_preview_width, camapp->default_preview_height);
7627 if (CAM_CAMERA_MODE == mode) {
7628 width = CAM_RESOLUTION_W(camapp->photo_resolution);
7629 height = CAM_RESOLUTION_H(camapp->photo_resolution);
7631 ret &= cam_mm_set_image_size(width, height);
7632 ret &= cam_mm_set_image_count(camapp->image_count);
7633 ret &= cam_mm_set_image_enc_quality(camapp->image_quality);
7634 ret &= cam_mm_set_fps(CAMERA_ATTR_FPS_AUTO);
7635 ret &= cam_mm_get_video_source_format(NULL, &capture_video_format);
7636 ret &= cam_mm_set_video_source_format(capture_video_format);
7637 ret &= cam_app_set_capture_format_shooting_mode(camapp->shooting_mode);
7639 if (cam_is_enabled_menu(ad, CAM_MENU_SAVE_AS_FLIP))
7640 ret &= cam_mm_set_image_flip(camapp->save_as_flip);
7642 ret &= cam_mm_set_image_flip(FALSE);
7644 ret &= cam_mm_set_anti_hand_shake(camapp->anti_shake);
7645 } else if (CAM_CAMCORDER_MODE == mode) {
7646 width = CAM_RESOLUTION_W(camapp->video_resolution);
7647 height = CAM_RESOLUTION_H(camapp->video_resolution);
7649 ret &= cam_mm_set_image_size(CAM_RESOLUTION_W(camapp->photo_resolution), CAM_RESOLUTION_H(camapp->photo_resolution));
7650 ret &= cam_mm_set_image_enc_quality(camapp->image_quality);
7651 ret &= cam_mm_set_video_profile();
7653 ret &= cam_mm_set_fps(camapp->fps);
7654 if (camapp->anti_shake) {
7655 ret &= cam_mm_set_video_source_format(CAMERA_PIXEL_FORMAT_NV12);
7657 ret &= cam_mm_get_video_source_format(NULL, &recording_video_format);
7658 DEBUG_TRACE("recording_video_format:%d", recording_video_format);
7659 ret &= cam_mm_set_video_source_format(recording_video_format);
7661 ret &= cam_mm_set_audio_recording(camapp->audio_recording);
7662 ret &= cam_app_set_recording_mode(ad, camapp->recording_mode);
7663 DEBUG_TRACE("camapp->size_limit = %d" , camapp->size_limit);
7664 DEBUG_TRACE("camapp->size_limit_type = %d" , camapp->size_limit_type);
7665 ret &= cam_app_set_size_limit(camapp->size_limit, camapp->size_limit_type);
7669 cam_mm_get_video_device(&video_dev);
7670 DEBUG_TRACE("video_dev = %d",video_dev);
7671 if (video_dev == CAM_DEVICE_VGA) {
7673 cam_mm_get_front_cam_display_rotate_value(&value, &rotate);
7675 DEBUG_TRACE("get front camera rotate %d value = %d", rotate, value);
7677 #ifdef TODO_SURRPORT
7678 rotate = CAMERA_ROTATION_270;
7679 #endif /*TODO:if new capi will released, this could be removed,but take care.*/
7682 cam_mm_get_zoom_valid_intrange(&camapp->zoom_min,&camapp->zoom_max);
7683 DEBUG_TRACE("Zoom range [%d - %d]",camapp->zoom_min, camapp->zoom_max);
7685 cam_mm_get_brightless_valid_intrange(&camapp->brightness_min,&camapp->brightness_max);
7686 DEBUG_TRACE("brightness range [%d - %d]",camapp->brightness_min, camapp->brightness_max);
7687 camapp->brightness = (camapp->brightness_min + camapp->brightness_max) /2;
7689 ret &= cam_mm_remove_geo_tag();
7690 DEBUG_TRACE("cam_mm_remove_geo_tag = %d", ret);
7691 ret &= cam_mm_set_display_device(CAMERA_DISPLAY_TYPE_X11, GET_DISPLAY(ad->main_xid));
7692 ret &= cam_mm_set_camera_rotate(camera_rotate);
7693 ret &= cam_mm_set_display_rotate(rotate);
7694 ret &= cam_mm_set_display_geometry_method(CAMERA_DISPLAY_MODE_LETTER_BOX);
7695 #ifndef USE_CAMERA_APP_SHUTTER_SOUND
7696 ret &= cam_mm_set_shutter_sound(TRUE);
7698 ret &= cam_app_reset_resolution(ad, width, height, TRUE);
7699 ret &= cam_mm_set_zoom(camapp->zoom_mode);
7700 ret &= cam_mm_set_auto_exposure(camapp->auto_exposure);
7701 ret &= cam_mm_set_iso(camapp->iso);
7702 ret &= cam_mm_set_wdr(camapp->wdr);
7703 ret &= cam_mm_set_brightness(camapp->brightness);
7704 ret &= cam_mm_enable_auto_contrast(camapp->auto_contrast);
7705 ret &= cam_mm_set_white_balance(camapp->white_balance);
7706 ret &= cam_mm_set_effect(camapp->effect);
7707 ret &= cam_mm_set_program_mode(camapp->scene_mode);
7709 if (ad->torchlight_on && camapp->flash != CAM_FLASH_OFF)
7710 ret &= cam_mm_set_flash(CAM_FLASH_OFF);
7712 ret &= cam_mm_set_flash(camapp->flash);
7714 if (camapp->af_mode == CAM_FOCUS_AUTO
7715 || camapp->af_mode == CAM_FOCUS_MACRO) {
7716 ret &= cam_mm_set_focus_mode(camapp->af_mode);
7717 } else if (camapp->af_mode == CAM_FOCUS_FACE) {
7718 ret &= cam_mm_set_focus_mode(CAMERA_ATTR_AF_NORMAL);
7721 ret &= cam_mm_set_tag_enable(TRUE);
7722 ret &= cam_mm_set_outdoor_visibility(camapp->outdoor_visibility);
7723 ad->enable_mode_change = TRUE;
7724 ad->is_recording = FALSE;
7729 static void cam_app_update_gps_level(void *data, int lbs_state)
7731 struct appdata *ad = (struct appdata *)data;
7732 GValue value = { 0, };
7733 cam_retm_if(ad == NULL, "appdata is NULL");
7735 cam_debug(LOG_UI, " cam_app_update_gps_level : %d", lbs_state);
7737 CAM_GVALUE_SET_INT(value, lbs_state);
7738 cam_handle_value_set(ad, PROP_GPS_LEVEL, &value);
7743 static gboolean cam_app_return_ext_app(void *data, const char *r_file_path)
7745 struct appdata *ad = (struct appdata *)data;
7747 service_create(&reply);
7749 if (ad->service_mime != NULL) {
7750 if (r_file_path == NULL) {
7751 service_add_extra_data(reply, SERVICE_DATA_SELECTED, "exit");
7752 service_reply_to_launch_request(reply, ad->service_handle, SERVICE_RESULT_FAILED);
7754 service_add_extra_data(reply, SERVICE_DATA_SELECTED, r_file_path);
7755 service_reply_to_launch_request(reply, ad->service_handle, SERVICE_RESULT_SUCCEEDED);
7759 service_destroy(reply);
7763 static void cam_app_battery_status_cb(keynode_t *key, void *data)
7765 struct appdata *ad = (struct appdata *)data;
7767 debug_fenter(LOG_UI);
7768 cam_retm_if(ad == NULL, "appdata is NULL");
7770 int low_status = -1;
7772 if (!vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &low_status)) {
7773 cam_debug(LOG_UI, "battery status low = %d", low_status);
7774 if (low_status <= VCONFKEY_SYSMAN_BAT_CRITICAL_LOW) {
7775 ad->battery_status = LOW_BATTERY_CRITICAL_STATUS;
7776 cam_app_notice_popup(ad, dgettext("sys_string", "IDS_COM_BODY_LOW_BATTERY"),
7777 cam_app_timeout_notice_response_cb);
7778 } else if (low_status == VCONFKEY_SYSMAN_BAT_WARNING_LOW) {
7779 ad->battery_status = LOW_BATTERY_WARNING_STATUS;
7780 cam_app_notice_popup((void *)ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_USE_FLASH_BATTERY_LOW"), cam_app_lowbattery_close_flash_cb);
7782 ad->battery_status = NORMAL_BATTERY_STATUS;
7788 /*if torch light vconf key value is changed, this cb is called*/
7789 static void cam_torchlight_update_cb(keynode_t *key, void *data)
7791 struct appdata *ad = (struct appdata *)data;
7792 cam_retm_if(ad == NULL, "appdata is NULL");
7793 CamAppData *camapp = ad->camapp_handle;
7794 cam_retm_if(camapp == NULL, "camapp is NULL");
7796 int key_value = vconf_keynode_get_bool(key); /* -1: error, 1:True, 0:False */
7797 if (key_value == -1) {
7798 DEBUG_TRACE("vconf_keynode_get_bool failed");
7801 DEBUG_TRACE("VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT is changed to %d", key_value);
7803 /* disable flash icon */
7804 ad->torchlight_on = TRUE;
7805 cam_mm_set_flash(CAM_FLASH_OFF);
7808 /* enable flash icon */
7809 ad->torchlight_on = FALSE;
7810 cam_mm_set_flash(camapp->flash);
7812 cam_toolbar_update(ad); /*update flash icon*/
7816 static void cam_app_battery_update_cb(keynode_t *key, void *data)
7818 struct appdata *ad = (struct appdata *)data;
7819 CamAppData *camapp = NULL;
7820 char *keyname = NULL;
7822 debug_fenter(LOG_UI);
7824 cam_retm_if(ad == NULL, "appdata is NULL");
7825 camapp = ad->camapp_handle;
7826 cam_retm_if(camapp == NULL, "camapp_handle is NULL");
7828 keyname = vconf_keynode_get_name(key);
7830 if (!strcmp(keyname, VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW)) {
7831 GValue value = { 0 };
7832 gint charging = vconf_keynode_get_int(key);
7833 DEBUG_TRACE("charging = %d", charging);
7834 CAM_GVALUE_SET_INT(value, charging);
7835 cam_handle_value_set(ad, PROP_BATTERY_CHARG, &value);
7837 } else if (!strcmp(keyname, VCONFKEY_SYSMAN_BATTERY_CAPACITY)) {
7838 GValue value = { 0 };
7839 int battery_level = vconf_keynode_get_int(key);
7840 CAM_GVALUE_SET_INT(value, battery_level);
7841 cam_handle_value_set(ad, PROP_BATTERY_LEVEL, &value);
7847 Evas_Object *cam_screen_load_edj(Evas_Object *parent, const char *file,
7853 eo = elm_layout_add(parent);
7855 r = elm_layout_file_set(eo, file, group);
7857 evas_object_del(eo);
7861 evas_object_size_hint_weight_set(eo,
7865 /* //if(!strcmp((const char *)elm_widget_type_get(parent), "win")) { */
7866 elm_win_resize_object_add(parent, eo);
7873 Evas_Object *cam_app_load_edj(Evas_Object *parent, const char *file,
7876 Evas_Object *eo = NULL;
7879 eo = elm_layout_add(parent);
7881 r = elm_layout_file_set(eo, file, group);
7883 evas_object_del(eo);
7887 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
7888 evas_object_show(eo);
7894 Eina_Bool __cam_app_update_thumbnail_idler(void *data)
7896 struct appdata *ad = (struct appdata *)data;
7898 return ECORE_CALLBACK_CANCEL;
7900 CamAppData *camapp = ad->camapp_handle;
7903 REMOVE_IDLER(ad->update_thumbnail_idler);
7904 return ECORE_CALLBACK_CANCEL;
7909 if (!g_file_test(camapp->filename,G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
7910 DEBUG_TRACE( "The captured File is not existed");
7911 REMOVE_IDLER(ad->update_thumbnail_idler);
7912 return ECORE_CALLBACK_CANCEL;;
7915 gboolean ret = FALSE;
7917 if (ad->imageviewer_ug) { /*review on */
7918 DEBUG_TRACE("Image viewer was LAUNCHED. skip this...");
7919 REMOVE_IDLER(ad->update_thumbnail_idler);
7920 return ECORE_CALLBACK_CANCEL;;
7923 if (camapp->thumbnail_name != NULL) {
7924 free (camapp->thumbnail_name);
7925 camapp->thumbnail_name = NULL;
7929 ret = cam_file_get_cam_file_thumbnail_path(camapp->filename, &camapp->thumbnail_name);
7930 DEBUG_TRACE("ret[0:success] = [%d] camapp->filename: [%s]",
7931 ret, camapp->filename);
7932 DEBUG_TRACE("ret[0:success] = [%d] camapp->thumbnail_name: [%s]",
7933 ret, camapp->thumbnail_name);
7934 if (!g_file_test(camapp->thumbnail_name, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
7936 if (g_thumbnail_image_check_count > 10) {
7937 REMOVE_IDLER(ad->update_thumbnail_idler);
7938 return ECORE_CALLBACK_CANCEL;
7941 DEBUG_TRACE("The thumbnail File is not existed,try the %d nums", g_thumbnail_image_check_count);
7942 g_thumbnail_image_check_count++;
7943 usleep(THUMBNAIL_UPDATE_WAIT_TIME);
7944 /*REMOVE_IDLER(ad->update_thumbnail_idler);*//*note:renew, do not delete idler*/
7945 return ECORE_CALLBACK_RENEW;
7947 else if (camapp->camera_mode == CAM_CAMERA_MODE) {
7948 DEBUG_TRACE("thumbnail image check count=[%d]", g_thumbnail_image_check_count);
7949 toolbar_update_quickview_thumbnail(ad);
7951 else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
7952 toolbar_update_quickview_thumbnail(ad);
7955 DEBUG_TRACE("NOT REACHED CODES REACHED!");
7957 REMOVE_IDLER(ad->update_thumbnail_idler);
7958 return ECORE_CALLBACK_CANCEL;
7960 /* update thumbnail to quickview after first launching or return from image viewer */
7961 void cam_app_update_quickview_icon(void *data) {
7963 struct appdata *ad = (struct appdata *)data;
7964 cam_ret_if(ad == NULL);
7965 cam_ret_if(ad->camapp_handle == NULL);
7966 gchar *filename = NULL;
7970 /*To update quickview image, get last filename*/
7971 if (ad->camapp_handle->filename) {
7972 free(ad->camapp_handle->filename);
7973 ad->camapp_handle->filename = NULL;
7976 if (ad->camapp_handle->thumbnail_name) {
7977 free(ad->camapp_handle->thumbnail_name);
7978 ad->camapp_handle->thumbnail_name = NULL;
7981 filename = cam_app_get_last_filename();
7983 if (filename != NULL) {
7984 ad->camapp_handle->filename = strdup(filename);
7988 if (!cam_file_get_cam_file_thumbnail_path
7989 (ad->camapp_handle->filename, &ad->camapp_handle->thumbnail_name))
7990 DEBUG_TRACE("cam_file_get_cam_file_thumbnail_path() fail");
7994 toolbar_update_quickview_thumbnail_no_animation(ad);
7999 void cam_app_update_thumbnail()
8001 struct appdata *ad = (struct appdata *)cam_appdata_get();
8002 cam_ret_if(ad == NULL);
8003 CamAppData *camapp = ad->camapp_handle;
8004 cam_ret_if(camapp == NULL);
8006 DEBUG_TRACE("cam_app_update_thumbnail");
8008 if (CAM_LAUNCHING_MODE_NORMAL == ad->launching_mode && camapp->filename) {
8010 g_thumbnail_image_check_count = 0;
8011 if (!ad->update_thumbnail_idler)
8012 ad->update_thumbnail_idler = ecore_idler_add(__cam_app_update_thumbnail_idler, ad);
8017 gboolean cam_app_parse_args(CamExeArgs *args, service_h service)
8019 struct appdata *ad = (struct appdata *)cam_appdata_get();
8020 cam_retv_if(ad == NULL, FALSE);
8022 ad->service_mime = NULL;
8024 int ret = service_get_mime(service, &ad->service_mime);
8025 if (ret != SERVICE_ERROR_NONE) {
8026 cam_debug(LOG_UI, "service_get_mime is error ");
8030 if (ad->service_mime != NULL) {
8032 if ((strcmp(ad->service_mime, SERVICE_MIME_TYPE_IMAGE_1) == 0)
8033 || (strcmp(ad->service_mime, SERVICE_MIME_TYPE_IMAGE_2) == 0)) {
8034 cam_debug(LOG_UI, "CAM_CAMERA_MODE");
8035 args->cam_mode = CAM_CAMERA_MODE;
8036 } else if ((strcmp(ad->service_mime, SERVICE_MIME_TYPE_VIDEO_1) == 0)
8037 || (strcmp(ad->service_mime, SERVICE_MIME_TYPE_VIDEO_2) == 0)) {
8038 cam_debug(LOG_UI, "CAM_CAMCORDER_MODE");
8039 args->cam_mode = CAM_CAMCORDER_MODE;
8041 cam_critical(LOG_UI, "Invalid mime type");
8042 args->cam_mode = CAM_CAMERA_MODE;
8046 const char *val = NULL;
8047 /* get caller appl. */
8048 service_get_extra_data(service, "CALLER", (char **)&val);
8050 cam_debug(LOG_UI, "CALLER %s", val);
8051 args->caller = strdup(val);
8053 args->caller = NULL;
8059 service_get_extra_data(service, "RESOLUTION", (char **)&val);
8061 cam_debug(LOG_UI, "RESOLUTION %s", val);
8063 if (args->cam_mode == CAM_CAMERA_MODE) {
8064 if (0 == strcmp(val, CAM_CAPTURE_RES_VGA))
8065 res = CAM_RESOLUTION_VGA;
8067 res = IMAGE_RESOLUTION_DEFAULT;
8069 if (0 == strcmp(val, CAM_RECORDING_RES_QCIF))
8070 res = CAM_RESOLUTION_QCIF;
8072 res = REC_RESOLUTION_DEFAULT;
8075 if (args->cam_mode == CAM_CAMERA_MODE) {
8076 res = IMAGE_RESOLUTION_DEFAULT;
8078 res = REC_RESOLUTION_DEFAULT;
8081 args->width = CAM_RESOLUTION_W(res);
8082 args->height = CAM_RESOLUTION_H(res);
8083 args->resolution = res;
8087 service_get_extra_data(service, "LIMIT", (char **)&val);
8089 cam_debug(LOG_UI, "LIMIT %s", val);
8090 args->size_limit = atoi(val);
8092 args->size_limit = 0;
8095 args->review = TRUE;
8097 /* print exe args */
8098 cam_debug(LOG_SYS, "############### exe args ###############");
8099 cam_debug(LOG_SYS, "mode =%d", args->cam_mode);
8100 cam_debug(LOG_SYS, "caller =%s", args->caller);
8101 cam_debug(LOG_SYS, "width =%d", args->width);
8102 cam_debug(LOG_SYS, "height =%d", args->height);
8103 cam_debug(LOG_SYS, "limit =%d", args->size_limit);
8104 cam_debug(LOG_SYS, "review =%d", args->review);
8105 cam_debug(LOG_SYS, "############### end ###############");
8111 void cam_app_draw_af_box(void *data)
8114 cam_retm_if(data == NULL, "data is null");
8115 struct appdata *ad = (struct appdata *)data;
8119 switch (ad->rot_current) {
8120 case APP_DEVICE_ORIENTATION_0:
8122 ad->af_start_x = ad->touch_lcd_x;
8123 ad->af_start_y = ad->touch_lcd_y;
8126 case APP_DEVICE_ORIENTATION_180:
8128 ad->af_start_x = ad->win_height - ad->touch_lcd_x;
8129 ad->af_start_y = ad->win_width - ad->touch_lcd_y;
8132 case APP_DEVICE_ORIENTATION_270:
8134 ad->af_start_x = ad->touch_lcd_y;
8135 ad->af_start_y = ad->win_height - ad->touch_lcd_x;
8138 case APP_DEVICE_ORIENTATION_90:
8140 ad->af_start_x = ad->win_width - ad->touch_lcd_y;
8141 ad->af_start_y = ad->touch_lcd_x;
8149 DEBUG_TRACE("ad->af_start_x=%f, ad->af_start_y=%f", ad->af_start_x, ad->af_start_y);
8151 ad->camera_focus_w = CAMERA_FOCUS_W * elm_config_scale_get();
8152 ad->camera_focus_h = CAMERA_FOCUS_H * elm_config_scale_get();
8153 DEBUG_TRACE("ad->camera_focus_w=%f, ad->camera_focus_h=%f", ad->camera_focus_w, ad->camera_focus_h);
8155 ad->af_start_x = ad->af_start_x - (ad->camera_focus_w / 2);
8156 ad->af_start_y = ad->af_start_y - (ad->camera_focus_h / 2);
8157 DEBUG_TRACE("af area box start x,y =[%f,%f]\n", ad->af_start_x, ad->af_start_y);
8159 if (ad->rot_current == APP_DEVICE_ORIENTATION_270
8160 || ad->rot_current == APP_DEVICE_ORIENTATION_90) {
8161 if (ad->af_start_x < ad->preview_offset_x) {
8162 ad->af_start_x = ad->preview_offset_x;
8164 if (ad->af_start_y < ad->preview_offset_y) {
8165 ad->af_start_y = ad->preview_offset_y;
8167 if ((ad->af_start_x + ad->camera_focus_w) >
8168 (ad->preview_w + ad->preview_offset_x)) {
8170 (ad->preview_w + ad->preview_offset_x) -
8173 if ((ad->af_start_y + ad->camera_focus_h) >
8174 (ad->preview_h + ad->preview_offset_y)) {
8176 (ad->preview_h + ad->preview_offset_y) -
8181 if (ad->af_start_y < ad->preview_offset_x) {
8182 ad->af_start_y = ad->preview_offset_x;
8184 if (ad->af_start_x < ad->preview_offset_y) {
8185 ad->af_start_x = ad->preview_offset_y;
8187 if ((ad->af_start_y + ad->camera_focus_h) >
8188 (ad->preview_w + ad->preview_offset_x)) {
8190 (ad->preview_w + ad->preview_offset_x) -
8193 if ((ad->af_start_x + ad->camera_focus_w) >
8194 (ad->preview_h + ad->preview_offset_y)) {
8196 (ad->preview_h + ad->preview_offset_y) -
8201 if (ad->focus_edje) {
8203 ("####################################################");
8204 DEBUG_TRACE("af area start ,ad->af_start_x,y =[%f,%f]\n",
8205 ad->af_start_x, ad->af_start_y);
8207 ("####################################################");
8208 evas_object_move(ad->focus_edje, ad->af_start_x,
8210 DEBUG_TRACE(" MOVE FOCUS_EDJE : %f,%f", ad->af_start_x,
8217 /* get preview start x,y coordinate */
8218 void cam_app_get_preview_offset_coordinate(void *data)
8221 cam_retm_if(data == NULL, "data is null");
8222 struct appdata *ad = (struct appdata *)data;
8224 CamAppData *camapp = ad->camapp_handle;
8225 cam_retm_if(camapp == NULL, "camapp is null");
8229 CamVideoRectangle result; /* result ractangle */
8230 CamVideoRectangle window; /* target window ractangle */
8231 CamVideoRectangle preview; /* target preview rectangle */
8232 /*wow,now, the MMHandleType is not created*/
8233 cam_mm_get_video_size(&width, &height);
8235 ad->camfw_video_width = width;
8236 ad->camfw_video_height = height;
8240 DEBUG_TRACE("************************************************");
8241 DEBUG_TRACE("preview.w =%d, preview.h=%d", preview.w, preview.h);
8243 window.h = ad->win_height;
8244 window.w = ad->win_width;
8245 DEBUG_TRACE("window.w =%d, window.h=%d\n", window.w, window.h);
8246 DEBUG_TRACE("************************************************");
8247 cam_app_preview_start_coordinate(preview, window, &result);
8249 ad->preview_offset_x = result.x;
8250 ad->preview_offset_y = result.y;
8251 ad->preview_w = result.w;
8252 ad->preview_h = result.h;
8254 DEBUG_TRACE("************************************************");
8255 DEBUG_TRACE("ad->preview_offset_x = %d, ad->preview_offset_y = %d",
8256 ad->preview_offset_x, ad->preview_offset_y);
8257 DEBUG_TRACE("*************************************************");
8259 camapp->focus_state = CAM_FOCUS_STATUS_RELEASED;
8260 cam_app_focus_guide_update(ad);
8263 ad->af_x = (ad->win_width / 2) - ad->preview_offset_x;
8264 ad->af_y = (ad->win_height / 2) - ad->preview_offset_y;
8266 ad->af_x = (ad->af_x * ad->camfw_video_width) / ad->preview_w;
8267 ad->af_y = (ad->af_y * ad->camfw_video_height) / ad->preview_h;
8269 ad->touch_lcd_x = (ad->win_height / 2);
8270 ad->touch_lcd_y = (ad->win_width / 2);
8272 DEBUG_TRACE("*************************************************");
8273 DEBUG_TRACE(" ad->af_x=%d, ad->af_y=%d", ad->af_x, ad->af_y);
8274 DEBUG_TRACE(" ad->af_start_x=%d, ad->af_start_y=%d", ad->af_start_x, ad->af_start_y);
8275 DEBUG_TRACE(" ad->touch_lcd_x=%d, ad->touch_lcd_y=%d", ad->touch_lcd_x, ad->touch_lcd_y);
8276 DEBUG_TRACE("*************************************************");
8278 cam_app_draw_af_box(ad);
8281 evas_object_show(ad->focus_edje);
8284 void cam_app_preview_start_coordinate(CamVideoRectangle src,
8285 CamVideoRectangle dst,
8286 CamVideoRectangle *result)
8288 /* src is target preview rectangle */
8289 /* dst is target window rectangle */
8290 g_return_if_fail(result != NULL);
8291 gdouble src_ratio, dst_ratio;
8292 src_ratio = (gdouble) src.w / src.h;
8293 dst_ratio = (gdouble) dst.w / dst.h;
8294 if (src_ratio > dst_ratio) {
8295 DEBUG_TRACE("#### case 1\n");
8297 result->h = dst.w / src_ratio;
8299 result->y = (dst.h - result->h) / 2;
8300 } else if (src_ratio < dst_ratio) {
8301 DEBUG_TRACE("#### case 2\n");
8302 result->w = dst.h * src_ratio;
8304 result->x = (dst.w - result->w) / 2;
8307 DEBUG_TRACE("#### case 3\n");
8314 ("************************************************************");
8316 ("source is %dx%d dest is %dx%d, result window size is %dx%d result offset x= %dx y=%d",
8317 src.w, src.h, dst.w, dst.h, result->w, result->h, result->x,
8320 ("************************************************************");
8324 void cam_remove_tmp_file()
8326 const gchar *default_path = NULL;
8327 char tmpfile_name[256] = { 0 };
8329 default_path = cam_file_get_internal_video_path();
8330 DEBUG_TRACE(" video = %s", default_path);
8331 snprintf(tmpfile_name, sizeof(tmpfile_name), "%s%s", default_path,
8333 if (g_file_test(tmpfile_name, G_FILE_TEST_EXISTS)) {
8334 DEBUG_TRACE("REMOVE tmp file");
8335 unlink(tmpfile_name);
8337 default_path = cam_file_get_external_video_path();
8338 DEBUG_TRACE(" video = %s", default_path);
8339 snprintf(tmpfile_name, sizeof(tmpfile_name), "%s%s", default_path,
8342 if (g_file_test(tmpfile_name, G_FILE_TEST_EXISTS)) {
8343 DEBUG_TRACE("REMOVE tmp file");
8344 unlink(tmpfile_name);
8349 Eina_Bool cam_app_launch_after_preview_began(void *data)
8351 struct appdata *ad = (struct appdata *)data;
8352 cam_retv_if(ad == NULL, FALSE);
8354 cam_debug(LOG_UI, "cam_app_launch_after_preview_began");
8356 int state = cam_mm_get_state();
8358 if (state != RECORDER_STATE_RECORDING) {
8359 cam_debug(LOG_UI, "remove previous file");
8360 cam_remove_tmp_file();
8363 cam_app_get_preview_offset_coordinate(data);
8364 cam_toolbar_setting_popup_create(data);
8365 return ECORE_CALLBACK_CANCEL;
8368 void cam_utils_remove_idler_all(void *data)
8370 struct appdata *ad = (struct appdata *)data;
8372 Ecore_Idler *idler = NULL;
8374 debug_fenter(LOG_UI);
8376 cam_retm_if(ad == NULL, "appdata is NULL");
8379 In fact, a Lock is needed here. However, because all related functions are working main loop, practically it may not be needed. */
8381 if (!ad->capture_cb_list) {
8382 cam_debug(LOG_UI, "No idler is remained.");
8384 list = ad->capture_cb_list;
8391 "Fail to remove idler. The idler is NULL");
8393 cam_debug(LOG_UI, "Remove idler[%p].", idler);
8394 ecore_idler_del(idler);
8396 ad->capture_cb_list =
8397 g_list_remove(ad->capture_cb_list, idler);
8400 list = g_list_next(list);
8403 g_list_free(ad->capture_cb_list);
8404 ad->capture_cb_list = NULL;
8408 debug_fleave(LOG_UI);
8412 Eina_Bool cam_elm_cache_flush()
8414 /*Make the canvas discard as much data as possible used by the engine at runtime.*/
8415 DEBUG_TRACE("start");
8416 struct appdata *ad = (struct appdata *)cam_appdata_get();
8419 evas_render_idle_flush(ad->evas);
8422 elm_cache_all_flush();
8427 gboolean cam_condition_check_to_start_camera(void *data)
8429 struct appdata *ad = (struct appdata *)data;
8430 cam_retvm_if(ad == NULL, EINA_FALSE, "appdata is NULL");
8433 if (cam_utils_check_battery_critical_low()) {
8434 ad->battery_status = LOW_BATTERY_CRITICAL_STATUS;
8435 cam_app_notice_popup(ad, dgettext("sys_string", "IDS_COM_BODY_LOW_BATTERY"), cam_app_timeout_notice_response_cb);
8437 } else if (cam_utils_check_battery_warning_low()) {
8438 ad->battery_status = LOW_BATTERY_WARNING_STATUS;
8439 cam_app_notice_popup((void *)ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_USE_FLASH_BATTERY_LOW"), cam_app_lowbattery_close_flash_cb);
8441 ad->battery_status = NORMAL_BATTERY_STATUS;
8444 if (cam_utils_check_call_running()) {
8445 ad->is_calling = TRUE;
8446 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_START_CAMERA_DURING_CALL"), cam_app_timeout_notice_response_cb);
8449 ad->is_calling = FALSE;
8454 static Eina_Bool __cam_continuous_af_timer_cb(void *data)
8458 struct appdata *ad = (struct appdata *)data;
8459 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
8461 if (ad->continuous_af_timer)
8462 ad->continuous_af_timer = NULL;
8464 cam_reset_focus_mode(ad);
8466 return ECORE_CALLBACK_CANCEL;
8469 void cam_reset_focus_mode(void *data)
8473 struct appdata *ad = (struct appdata *)data;
8474 cam_retm_if(ad == NULL, "appdata is NULL");
8475 CamAppData *camapp = ad->camapp_handle;
8476 cam_retm_if(camapp == NULL, "camapp is NULL");
8479 cam_toolbar_show_cafbutton(ad, FALSE);
8481 cam_reset_focus_coordinate(ad);
8483 camapp->touch_af_state = CAM_TOUCH_AF_STATE_NONE;
8484 camapp->focus_state = CAM_FOCUS_STATUS_RELEASED;
8486 cam_app_focus_guide_create(ad);
8487 cam_app_focus_guide_update(ad);
8489 cam_continuous_af_start(ad);
8492 static Eina_Bool __focus_guide_destroy(void *data)
8496 struct appdata *ad = (struct appdata *)data;
8497 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
8499 if (ad->continuous_af_timer)
8500 ad->continuous_af_timer = NULL;
8501 DEL_EVAS_OBJECT(ad->focus_edje);
8503 return ECORE_CALLBACK_CANCEL;
8507 gboolean cam_set_default_capture_mode(void *data, CamCaptureMode type)
8511 struct appdata *ad = (struct appdata *)data;
8512 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
8513 CamAppData *camapp = ad->camapp_handle;
8514 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
8516 if (camapp->camera_mode == CAM_CAMERA_MODE
8517 && camapp->shooting_mode == CAM_SINGLE_MODE
8518 && camapp->burst_shot == TRUE) {
8520 camapp->default_capture_mode = type;
8521 if (camapp->default_capture_mode == CAM_CAPTURE_BURST)
8522 camapp->capture_cb = (camera_capturing_cb)cam_continuous_shot_capture_callback;
8524 camapp->capture_cb = (camera_capturing_cb)__cam_capture_cb;
8533 gint cam_app_get_max_image_size_by_ratio(void *data, int resolution)
8535 struct appdata *ad = (struct appdata *)data;
8536 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
8537 CamAppData *camapp = ad->camapp_handle;
8538 cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
8541 unsigned int capacity = 0;
8542 gdouble ratio = (gdouble) CAM_RESOLUTION_W(resolution) / CAM_RESOLUTION_H(resolution);
8544 GetCamDevCamResolutionCaps(&capacity, ad);
8546 if (ratio == (gdouble)4.0/3.0) {
8547 if (capacity & CAM_CP_SIZE_3264X2448)
8548 result = CAM_RESOLUTION_3264x2448;
8549 else if (capacity & CAM_CP_SIZE_2048X1536)
8550 result = CAM_RESOLUTION_2048x1536;
8551 else if (capacity & CAM_CP_SIZE_1280X960)
8552 result = CAM_RESOLUTION_1280x960;
8554 result = CAM_RESOLUTION_VGA;
8555 } else if (ratio == (gdouble)16.0/9.0) {
8556 if (capacity & CAM_CP_SIZE_3264X1836)
8557 result = CAM_RESOLUTION_3264x1836;
8558 else if (capacity & CAM_CP_SIZE_2048X1152)
8559 result = CAM_RESOLUTION_2048x1152;
8560 else if (capacity & CAM_CP_SIZE_1280X720)
8561 result = CAM_RESOLUTION_1280x720;
8563 result = CAM_RESOLUTION_VGA;
8564 } else if (ratio == (gdouble)3.0/2.0) {
8565 if (capacity & CAM_CP_SIZE_3264X2176)
8566 result = CAM_RESOLUTION_3264x2176;
8568 result = CAM_RESOLUTION_VGA;
8570 result = CAM_RESOLUTION_VGA;
8576 void cam_app_stop_capture(void* data)
8578 cam_retm_if(data == NULL, "data is null");
8579 struct appdata *ad = (struct appdata *)data;
8581 CamAppData *camapp = ad->camapp_handle;
8582 cam_retm_if(camapp == NULL, "camapp is null");
8584 if (camapp->camera_mode == CAM_CAMERA_MODE) {
8585 if (camapp->shooting_mode == CAM_SINGLE_MODE) {
8586 if (camapp->continuous_shot_data && camapp->continuous_shot_data->capture_status == CAM_CONTI_SHOT_STATUS_CAPTURING) {
8587 if (cam_is_enabled_menu((void*)ad, CAM_MENU_BURST_SHOT_MODE) && camapp->burst_shot == TRUE && camapp->default_capture_mode == CAM_CAPTURE_BURST) {
8588 DEBUG_TRACE("burst capture mode");
8589 cam_mm_set_conti_shot_break(TRUE);
8590 ad->emit_continuous_shutter = FALSE;
8591 cam_app_destroy_progressbar(ad);
8592 camapp->continuous_shot_data->capture_status = CAM_CONTI_SHOT_STATUS_STOPPED;
8598 void cam_create_error_popup(void* data)
8600 cam_retm_if(data == NULL, "data is null");
8601 struct appdata *ad = (struct appdata *)data;
8603 if( ad->error_type == CAM_ERROR_TYPE_UNABLE_TO_LAUNCH){
8604 if (ad->fw_error_type == CAMERA_ERROR_SOUND_POLICY ||ad->fw_error_type == RECORDER_ERROR_SOUND_POLICY) {
8605 cam_app_notice_popup(data, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_START_CAMERA_DURING_CALL"), cam_app_timeout_notice_response_cb);
8607 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_START_CAMERA"), cam_app_timeout_notice_response_cb);
8612 static Eina_Bool __cam_app_display_error_popup_idler(void *data)
8614 debug_fenter(LOG_CAM);
8615 struct appdata *ad = (struct appdata *)data;
8616 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
8618 if (ad->battery_status == LOW_BATTERY_CRITICAL_STATUS){
8619 cam_app_notice_popup(ad, dgettext("sys_string", "IDS_COM_BODY_LOW_BATTERY"), cam_app_timeout_notice_response_cb);
8620 } else if (ad->is_calling == TRUE) {
8621 cam_app_notice_popup(ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_START_CAMERA_DURING_CALL"), cam_app_timeout_notice_response_cb);
8622 } else if(ad->battery_status == LOW_BATTERY_WARNING_STATUS){
8623 cam_app_notice_popup((void *)ad, dgettext(PACKAGE, "IDS_CAM_POP_UNABLE_TO_USE_FLASH_BATTERY_LOW"), cam_app_lowbattery_close_flash_cb);
8626 return ECORE_CALLBACK_CANCEL;