949885f8aa6f424339eb407298dd66a781916920
[profile/ivi/camera.git] / src / cam.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *        http://www.tizenopensource.org/license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #include <stdio.h>
19 #include <pthread.h>
20 #include <X11/Xlib.h>
21 #include <utilX.h>
22 #include <power.h>
23 #include "cam.h"
24 #include "cam_app.h"
25 #include "camera_utils.h"
26 #include "cam_ta.h"
27 #include "cam_mm.h"
28 #include "cam_debug.h"
29 #include "cam_toolbar_edc_callback.h"
30 #include "cam_zoom_edc_callback.h"
31 #include "cam_indicator_edc_callback.h"
32 #include "cam_common_edc_callback.h"
33 #include "cam_rec.h"
34 #include "cam_file.h"
35 #include "cam_menu_composer.h"
36 #include "cam_device_capacity.h"
37
38
39 static int __is_idle_lock(void);
40
41 static int _is_running(void)
42 {
43 #ifdef CHECK_RUNNING_PROC
44         GDir *dir = NULL;
45         GError *error = NULL;
46         const gchar *dir_name;
47         char path[255] = { 0, };
48         char proc_name[255] = { 0, };
49         int fd = 0, count = 0;
50         dir = g_dir_open("/proc", 0, &error);
51
52         if (dir) {
53                 while ((dir_name = g_dir_read_name(dir)) != NULL) {
54                         if (!isdigit(dir_name[0]))
55                                 continue;
56
57                         snprintf(path, sizeof(path), "/proc/%s/cmdline",
58                                  dir_name);
59                         fd = open(path, O_RDONLY);
60                         read(fd, proc_name, sizeof(proc_name) - 1);
61                         close(fd);
62                         if (strstr(proc_name, "camera")) {
63                                 static int pid = 0;
64                                 count++;
65                                 if (count > 1) {
66                                         g_dir_close(dir);
67                                         printf
68                                             ("camera application[PID: %d] is already running !!!!\n\n",
69                                              pid);
70                                         return 1;
71                                 }
72                                 pid = atoi(dir_name);
73                         }
74                 }
75                 g_dir_close(dir);
76         } else {
77                 printf("cannot open proc directory [%s]", error->message);
78         }
79
80         if (error)
81                 g_error_free(error);
82
83         return 0;
84 #else
85         return 0;
86 #endif
87 }
88
89 static bool cam_create(void *data)
90 {
91         CAM_TA_ACUM_ITEM_BEGIN("==cam_create==", 0);
92         cam_debug(LOG_UI, "************** cam_create START **************");
93
94         if (__is_idle_lock()) {
95                 return FALSE;/*fix crash*/
96         }
97
98         struct appdata *ad = data;
99         Ecore_X_Display *dpy = NULL;
100         debug_fenter(LOG_CAM);
101
102         /* create main window */
103         ad->win_main = cam_app_create_win(PACKAGE);
104         cam_retvm_if(ad->win_main == NULL, FALSE, "cam_app_create_win failed");
105 #ifdef EFL_TEMP_CODE
106         cam_win_transparent_set(ad);
107 #endif
108         /* remove effect */
109         dpy = ecore_x_display_get();
110         if (dpy) {
111                 Ecore_X_Window win;
112                 win = elm_win_xwindow_get(ad->win_main);
113
114                 printf("dpy is not null .. set no effect to display = %d\n",
115                        win);
116                 utilx_set_window_effect_style(dpy, win,
117                                               UTILX_EFFECT_TYPE_ROTATION,
118                                               UTILX_EFFECT_STYLE_NONE);
119         }
120
121         /* set indicator. */
122 #ifndef CAMERA_MACHINE_I686
123         elm_win_indicator_mode_set(ad->win_main, ELM_WIN_INDICATOR_HIDE);
124 #endif
125
126
127         ad->evas = evas_object_evas_get(ad->win_main);
128         ad->ee = ecore_evas_ecore_evas_get(ad->evas);
129         ad->main_xid = elm_win_xwindow_get(ad->win_main);
130         ad->launch_type = CAM_LAUNCH_FIRST;
131
132         /* camera application initialization */
133         CAM_TA_ACUM_ITEM_BEGIN("  cam_app_init", 0);
134         if (!cam_app_init(ad))
135                 return FALSE;
136         CAM_TA_ACUM_ITEM_END("  cam_app_init", 0);
137
138         /*add camera exteral engine lib load*/
139         open_cam_ext_handle();
140         evas_object_show(ad->win_main);
141
142         cam_debug(LOG_UI, "******** cam_create END**********");
143         CAM_TA_ACUM_ITEM_END("==cam_create==", 0);
144
145         return true;
146 }
147
148
149
150 static void cam_terminate(void *data)
151 {
152         cam_debug(LOG_UI, "############## cam_terminate ##############");
153
154         struct appdata *ad = (struct appdata *)data;
155         if (!ad) return;
156         ad->appcore_state = CAM_APPCORE_TERMINATE_STATE;
157
158
159         debug_fenter(LOG_CAM);
160
161         CAM_TA_ACUM_ITEM_BEGIN("cam_terminate", 0);
162
163         cam_key_grab_deinit(ad);
164
165 #ifdef USE_FIFO_THREAD
166         cam_app_FIFO_thread_exit();
167 #endif
168
169 #ifdef USE_FILE_REG_THREAD
170         cam_app_file_register_thread_exit(ad);
171 #endif
172
173         CAM_TA_ACUM_ITEM_BEGIN("  cam_app_quit", 0);
174         cam_app_quit(ad);
175         CAM_TA_ACUM_ITEM_END("  cam_app_quit", 0);
176
177         power_unlock_state(POWER_STATE_NORMAL);
178
179         CAM_TA_ACUM_ITEM_END("app_terminate", 0);
180
181         CAM_TA_ACUM_ITEM_SHOW_RESULT_TO(CAM_TA_SHOW_FILE);
182         CAM_TA_RELEASE();
183
184         close_cam_ext_handle();
185 }
186
187 static void cam_pause(void *data)
188 {
189         cam_debug(LOG_UI, "############## cam_pause ##############");
190
191         struct appdata *ad = (struct appdata *)data;
192         cam_ret_if(ad == NULL);
193         CamAppData *camapp = ad->camapp_handle;
194         cam_ret_if(camapp == NULL);
195         debug_fenter(LOG_CAM);
196         ad->appcore_state = CAM_APPCORE_PAUSE_STATE;
197
198         if ( ad->launching_mode == CAM_LAUNCHING_MODE_EXTERNAL) {
199                 int mm_state = 0;
200                 mm_state = cam_mm_get_state();
201                 ad->appcore_state = CAM_APPCORE_PAUSE_STATE;
202
203                 if (mm_state < CAMERA_STATE_CAPTURING) { /* MM_CAMCORDER_STATE_CAPTURING < MM_CAMCORDER_STATE_RECORDING */
204                         if (ad->imageviewer_ug) { /*Is this paused by Video player ? */
205                                 DEBUG_TRACE("###### ug_pause() ######");
206                                 ug_pause();
207                                 return;
208                         } else {
209                                 cam_app_exit(ad);
210                                 return;
211                         }
212                 } else if (mm_state == RECORDER_STATE_RECORDING && camapp->camera_mode == CAM_CAMCORDER_MODE) {
213                         if (!cam_video_record_stop(ad)) {
214                                 DEBUG_TRACE("record stop fail");
215                                 return;
216                         }
217                 }
218         }
219
220         if (ad->imageviewer_ug) {
221                 DEBUG_TRACE("###### ug_pause() ######");
222                 ug_pause();
223         }
224
225         if (ad->foucs_out_from_quickview == TRUE) {
226                 DEBUG_TRACE("image viewer UG->image editor");
227                 ad->foucs_out_from_quickview = FALSE;
228                 return;
229         }
230         CAM_TA_ACUM_ITEM_BEGIN("app_stop", 0);
231         DEBUG_TRACE(" ");
232         ad->foucs_out_from_quickview = FALSE;
233         ad->launch_type = CAM_LAUNCH_RELAUNCH;  /* set launch type */
234         cam_app_pause(ad);
235
236         power_unlock_state(POWER_STATE_NORMAL);
237         CAM_TA_ACUM_ITEM_END("app_stop", 0);
238
239 }
240
241 static void cam_resume(void *data)
242 {
243         cam_debug(LOG_UI, "############## cam_resume ##############");
244
245         struct appdata *ad = (struct appdata *)data;
246         cam_ret_if(ad == NULL);
247         debug_fenter(LOG_CAM);
248         DEBUG_TRACE(" ");
249         CamAppData *camapp = ad->camapp_handle;
250         cam_ret_if(camapp == NULL);
251
252         ad->appcore_state = CAM_APPCORE_RESUME_STATE;
253
254         if (!cam_check_dir()) {
255                 cam_app_notice_popup(data, "Cannot make default path",
256                          cam_app_timeout_notice_response_cb);
257                 return;
258         }
259         if (!cam_utils_check_torchlight_status(ad)) {
260                 DEBUG_TRACE("Can not get torchlight status");
261         }
262
263         if (ad->imageviewer_ug) {       /* bug fix camera app overlab with imageviewer_ug */
264                 DEBUG_TRACE("####### ug_resume() ######");
265                 ug_resume();
266                 return;
267         }
268         else
269                 power_lock_state(POWER_STATE_NORMAL, 0);
270
271         CAM_TA_INIT();
272
273         if (ad) {
274                 CAM_TA_ACUM_ITEM_BEGIN("  cam_app_resume", 0);
275                 if (!cam_app_resume(ad))
276                         return;
277                 CAM_TA_ACUM_ITEM_END("  cam_app_resume", 0);
278         }
279
280 }
281
282 void *cam_start_thread_run(void *data)
283 {
284         struct appdata *ad = (struct appdata *)data;
285         cam_retv_if(ad == NULL, NULL);
286
287         if (cam_app_start(ad) == FALSE)
288                 cam_critical(LOG_CAM, "cam_app_start failed");
289
290         pthread_exit(NULL);
291
292         return NULL;
293 }
294
295 static void cam_service(service_h service, void *user_data)
296 {
297         CAM_TA_ACUM_ITEM_BEGIN("==cam_service==", 0);
298         cam_debug(LOG_UI, "############## cam_service START##############");
299         struct appdata *ad = (struct appdata *)user_data;
300         cam_ret_if(ad == NULL);
301         CamAppData *camapp = ad->camapp_handle;
302         cam_ret_if(camapp == NULL);
303
304         DEBUG_TRACE("ad->launch_type = %d ", ad->launch_type);
305         gint latest_mode = 0;
306         ad->appcore_state = CAM_APPCORE_RESET_STATE;
307
308         if (!cam_check_dir()) {
309                 cam_app_notice_popup(ad, "Cannot make default path",
310                          cam_app_timeout_notice_response_cb);
311                 return;
312         }
313         if (!cam_utils_check_torchlight_status(ad)) {
314                 DEBUG_TRACE("Can not get torchlight status");
315         }
316         if (ad->launch_type == CAM_LAUNCH_IS_ALREADY_RUNNING) {
317                 cam_app_notice_popup(ad, "Camera is alreay running.",
318                                      cam_app_popup_response_cb);
319                 return;
320         }
321         /* remove exe args */
322         if (ad->exe_args) {
323                 if (ad->exe_args->caller) {
324                         free(ad->exe_args->caller);
325                         ad->exe_args->caller = NULL;
326                 }
327                 free(ad->exe_args);
328                 ad->exe_args = NULL;
329         }
330
331         char *operation = NULL;
332
333         int ret = service_get_operation(service, &operation);
334         if (ret != SERVICE_ERROR_NONE)
335         {
336                 cam_debug(LOG_UI, "service_get_operation failed");
337                 return;
338         }
339
340         if ( operation == NULL )
341         {
342                 cam_debug(LOG_UI, "operation is null");
343                 return;
344         }
345
346         ret = service_clone(&ad->service_handle, service);
347         if (ret != SERVICE_ERROR_NONE)
348         {
349                 cam_debug(LOG_UI, "service_clone failed");
350                 return;
351         }
352
353         CamExeArgs *args = (CamExeArgs *)malloc(sizeof(CamExeArgs));
354         if (args == NULL) {
355                 return;
356         }
357         memset(args,0,sizeof(CamExeArgs));
358
359         if (!cam_app_parse_args(args, service)) {
360                 return;
361         }
362         ad->exe_args = args;
363
364         if( strcmp(operation, SERVICE_OPERATION_CREATE_CONTENT ) == 0){
365                 cam_debug(LOG_UI, "Operation is SERVICE_OPERATION_CREATE_CONTENT");
366
367                 ad->launching_mode = CAM_LAUNCHING_MODE_EXTERNAL;
368
369
370                 CAM_TA_ACUM_ITEM_BEGIN("    cam_handle_init", 0);
371                 if (!cam_handle_init(ad, ad->exe_args->cam_mode)) {
372                         cam_critical(LOG_CAM, "cam_handle_init failed");
373                         return;
374                 }
375                 CAM_TA_ACUM_ITEM_END("    cam_handle_init", 0);
376
377                 cam_app_init_with_args(ad);
378         } else {
379                 ad->launching_mode = CAM_LAUNCHING_MODE_NORMAL;
380
381                 latest_mode = cam_app_get_latest_mode();
382
383                 CAM_TA_ACUM_ITEM_BEGIN("    cam_handle_init", 0);
384                 if (!cam_handle_init(ad, latest_mode)) {
385                         cam_critical(LOG_CAM, "cam_handle_init failed");
386                         return;
387                 }
388                 CAM_TA_ACUM_ITEM_END("    cam_handle_init", 0);
389         }
390
391         if (ad->launch_type == CAM_LAUNCH_FIRST) {
392                 debug_fenter(LOG_CAM);
393
394                 if (!cam_condition_check_to_start_camera(ad)) {
395                         cam_critical(LOG_CAM, "cannot start camera");
396                         return;
397                 }
398
399                 if (!open_cam_handle((void*)ad)) {
400                         cam_critical(LOG_CAM, "open_cam_handle failed");
401                         return;
402                 }
403
404                 if (pthread_create(&(ad->camera_start_thread), NULL, cam_start_thread_run, (void *)ad) < 0) {
405                         cam_critical(LOG_CAM, "Create camera start thread failed");
406                         return;
407                 }
408
409                 power_lock_state(POWER_STATE_NORMAL, 0);
410
411                 /*elm_win_alpha_set(ad->win_main, EINA_TRUE);*/
412
413                 ad->setting_menu_composer = NULL;
414
415                 if( ad->setting_menu_composer == NULL){
416                         ad->setting_menu_composer = malloc(sizeof(ad->setting_menu_composer));
417                         cam_compose_setting_menu(ad->setting_menu_composer);
418                 }
419
420                 CAM_TA_ACUM_ITEM_BEGIN("    cam_layout_init", 0);
421                 if (!cam_layout_init(ad)) {
422                         cam_critical(LOG_UI, "cam_layout_init failed");
423                         return;
424                 }
425                 CAM_TA_ACUM_ITEM_END("    cam_layout_init", 0);
426         } else {
427                 /* RELUNCHING!! //in paused -> Camera process is called by External process  */
428
429                 cam_debug(LOG_SYS, "RELUNCHING !!!");
430
431                 /*remove GUI*/
432                 if (ad->imageviewer_ug) {
433                         DEBUG_TRACE("destory imageviewer");
434                         ug_destroy(ad->imageviewer_ug);
435                         ad->imageviewer_ug = NULL;
436                 }
437
438                 cam_layout_del_all(ad);
439
440                 power_lock_state(POWER_STATE_NORMAL, 0);
441
442                 if (ad->exe_args == NULL)
443                         return;
444
445                 if (!cam_condition_check_to_start_camera(ad)) {
446                         cam_critical(LOG_CAM, "cannot start camera");
447                         return;
448                 }
449
450                 if (pthread_create(&(ad->camera_start_thread), NULL, cam_start_thread_run, (void *)ad) < 0) {
451                         cam_critical(LOG_CAM, "Create camera start thread failed");
452                         return;
453                 }
454
455                 ResetCaps();
456
457                 CAM_TA_ACUM_ITEM_BEGIN("    cam_layout_init", 0);
458                 if (!cam_layout_init(ad)) {
459                         cam_critical(LOG_UI, "cam_layout_init failed");
460                         return;
461                 }
462                 CAM_TA_ACUM_ITEM_END("    cam_layout_init", 0);
463
464                 evas_object_raise(ad->win_main);
465         }
466
467         cam_debug(LOG_UI, "############## cam_service END##############");
468         CAM_TA_ACUM_ITEM_END("==cam_service==", 0);
469 }
470
471 static int __is_idle_lock(void)
472 {
473
474         int vconf_val = 0;
475         int vconf_ret = 0;
476
477         vconf_ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &vconf_val);
478         if(vconf_ret == 0){
479                 if (vconf_val == VCONFKEY_IDLE_LOCK) {
480                         DEBUG_TRACE("  IDLE IN LOCK STATE  ");
481                         return 1;
482                 }
483         }
484
485         return 0;
486
487 }
488
489 #define CAM_EXT_LIB_PATH "/usr/lib/libcamera-external-engine.so"
490
491 void *handle = NULL;
492 gboolean open_cam_ext_handle()
493 {
494
495         if (!handle) {
496                 handle = dlopen(CAM_EXT_LIB_PATH, RTLD_NOW);
497                 if ( !handle ) {
498                         return FALSE;
499                 }
500         }
501         return TRUE;
502 }
503
504 void close_cam_ext_handle()
505 {
506
507         if (handle) {
508                 dlclose(handle);
509                 handle = NULL;
510         }
511 }
512
513 gboolean open_cam_handle(void* data)
514 {
515         struct appdata *ad = (struct appdata *)data;
516         CamAppData *camapp = NULL;
517         int session_type;
518         cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
519         camapp = ad->camapp_handle;
520         cam_retvm_if(camapp == NULL, FALSE, "camapp_handle is NULL");
521
522         if (camapp->camera_mode == CAM_CAMERA_MODE) {
523                 DEBUG_TRACE("session_type : SOUND_SESSION_TYPE_SHARE");
524                 session_type = SOUND_SESSION_TYPE_SHARE;
525         } else {
526                 DEBUG_TRACE("session_type : SOUND_SESSION_TYPE_EXCLUSIVE");
527                 session_type = SOUND_SESSION_TYPE_EXCLUSIVE;
528         }
529         if (!cam_mm_session_init(session_type)) {
530                 cam_critical(LOG_MM, "cam_mm_session_init faild");
531                 return FALSE;
532         }
533
534 /*open camera handle*/
535         if (!cam_mm_create(CAM_DEVICE_MEGA, camapp->camera_mode)) {
536                 cam_critical(LOG_MM, "cam_mm_create failed");
537                 cam_app_notice_popup(ad, "UNABLE TO LAUNCH CAMERA", cam_app_timeout_notice_response_cb);
538
539                 return FALSE;
540         }
541         return TRUE;
542
543 }
544
545 static void cam_low_power_cb(void *data)
546 {
547         struct appdata *ad = (struct appdata *)data;
548
549         cam_info(LOG_SYS, "Low battery !!");
550
551         cam_retm_if(ad == NULL, "appdata is NULL");
552         CamAppData *camapp = ad->camapp_handle;
553         cam_retm_if(camapp == NULL, "camapp_handle is NULL");
554         if (evas_object_visible_get(ad->win_main)) {
555                 int state = cam_mm_get_state();
556                 if ((state == RECORDER_STATE_RECORDING
557                     || state == RECORDER_STATE_PAUSED)
558                     &&camapp->camera_mode == CAM_CAMCORDER_MODE) {
559                         camapp->rec_stop_type = CAM_REC_STOP_LOW_BATTERY;
560                         ad->recording_commit =
561                             ecore_idler_add(cam_video_idler_record_stop, ad);
562                 } else {
563                         cam_app_exit(ad);
564                 }
565         }
566
567 }
568
569 static void cam_update_ts_cb(void *data)
570 {
571         struct appdata *ad = (struct appdata *)data;
572
573         cam_info(LOG_SYS, "#################Update String !!");
574
575         cam_retm_if(ad == NULL, "appdata is NULL");
576         char *path = NULL;
577
578         elm_win_indicator_mode_set(ad->win_main, 0);
579
580         path = vconf_get_str(VCONFKEY_LANGSET);
581         if (!path) {
582                 return;
583         }
584
585
586         /* update main */
587         update_ts_main(data);
588
589         enum ug_event ev = UG_EVENT_LANG_CHANGE;
590         ug_send_event(ev);
591 }
592
593 static void cam_device_orientation_cb(app_device_orientation_e mode, void *data)
594 {
595         struct appdata *ad = (struct appdata *)data;
596         cam_retm_if(ad == NULL, "appdata is NULL");
597         if (ad->appcore_state == CAM_APPCORE_TERMINATE_STATE
598                 || ad->appcore_state == CAM_APPCORE_PAUSE_STATE) {/*NOTE: in pause state, and terminate state, not cb*/
599                 return;
600         }
601         cam_retm_if(ad->camapp_handle == NULL, "ad->camapp_handle is NULL");
602
603         cam_debug(LOG_UI, "rotated : %d", mode);
604
605         /*TODO: now just return, if the last rotated is not finished*/
606         if (ad->is_rotating) {
607                 return;
608         }
609
610         int angle = 0;
611         ui_gadget_h ug = NULL;
612
613         enum ug_event ev = UG_EVENT_ROTATE_LANDSCAPE;
614         ad->rot_previous = ad->rot_current;
615         ad->rot_current = mode;
616
617         if (ad->toolbar_edj_file)
618                 free(ad->toolbar_edj_file);
619         ad->toolbar_edj_file = NULL;
620
621         switch (mode) {
622         case APP_DEVICE_ORIENTATION_0:
623                 angle = 0;
624                 ad->target_direction = CAM_TARGET_DIRECTION_PORTRAIT;
625                 ev = UG_EVENT_ROTATE_PORTRAIT;
626                 ad->camcorder_rotate = CAMERA_ROTATION_90;
627                 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_VERTICAL_EDJ_NAME);
628                 break;
629         case APP_DEVICE_ORIENTATION_270:
630                 angle = 270;
631                 ad->target_direction = CAM_TARGET_DIRECTION_LANDSCAPE;
632                 ev = UG_EVENT_ROTATE_LANDSCAPE;
633                 ad->camcorder_rotate = CAMERA_ROTATION_NONE;
634                 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_EDJ_NAME);
635                 break;
636         case APP_DEVICE_ORIENTATION_180:
637                 angle = 180;
638                 ad->target_direction = CAM_TARGET_DIRECTION_PORTRAIT_INVERSE;
639                 ev = UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN;
640                 ad->camcorder_rotate = CAMERA_ROTATION_270;
641                 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_VERTICAL_INVERSE_EDJ_NAME);
642                 break;
643         case APP_DEVICE_ORIENTATION_90:
644                 angle = 90;
645                 ad->target_direction = CAM_TARGET_DIRECTION_LANDSCAPE_INVERSE;
646                 ev = UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN;
647                 ad->camcorder_rotate = CAMERA_ROTATION_180;
648                 ad->toolbar_edj_file = strdup(CAM_TOOLBAR_LAYOUT_INVERSE_EDJ_NAME);
649                 break;
650
651         default:
652                 break;
653         }
654         ad->angle = angle;
655
656         if (ad->imageviewer_ug) {
657                 ug = ad->imageviewer_ug;
658         }
659         if (ug) {
660                 enum ug_mode md = ug_get_mode(ug);
661                 if (md == UG_MODE_FULLVIEW) {
662                         if(ev == UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN)
663                                 return;
664                         elm_win_rotation_with_resize_set(ad->win_main, angle);
665                         /* send event to ug      */
666                         ug_send_event(ev);
667                 }
668         } else {
669
670
671                 unsigned int *main_pipe_op_type = NULL;
672                 main_pipe_op_type = (unsigned int *)calloc(1, sizeof(unsigned int));
673                 if (main_pipe_op_type)
674                         *main_pipe_op_type = CAM_MAIN_PIPE_OP_TYPE_ROTATE_ANIMATOR;
675                 ecore_pipe_write(ad->main_pipe, (void *)main_pipe_op_type, sizeof(unsigned int));
676         }
677 }
678
679 int main(int argc, char *argv[])
680 {
681         DEBUG_TRACE(" ");
682
683         int i = 0;
684         struct appdata ad;
685         if (_is_running())
686                 return 0;
687
688         /*set appdata init variable*/
689         memset(&ad, 0x0, sizeof(struct appdata));
690
691         g_type_init();
692
693         CAM_TA_INIT();
694         DEBUG_TRACE("argc = %d", argc, argv);
695         for (i = 0; i < argc; i++) {
696                 DEBUG_TRACE("argv[%d] = %s", i, argv[i]);
697         }
698
699         app_event_callback_s event_callbacks;
700
701         event_callbacks.create = cam_create;
702         event_callbacks.terminate = cam_terminate;
703         event_callbacks.pause = cam_pause;
704         event_callbacks.resume = cam_resume;
705         event_callbacks.service = cam_service;
706
707         event_callbacks.language_changed = cam_update_ts_cb;
708         event_callbacks.low_battery = cam_low_power_cb;
709         event_callbacks.device_orientation = cam_device_orientation_cb;
710
711         event_callbacks.low_memory = NULL;
712         event_callbacks.region_format_changed = NULL;
713
714         setenv("ELM_ENGINE", "gl", 1); /*add open gl support for 3D slide_show of image viewer*/
715
716         return app_efl_main(&argc, &argv, &event_callbacks, &ad);
717
718 }
719
720 int update_ts_main(void *data)
721 {
722         DEBUG_TRACE(" ");
723
724         struct appdata *ad = (struct appdata *)data;
725
726         if (ad && ad->layout_main)
727                 edje_object_part_text_set(_EDJ(ad->layout_main), "txt_title", dgettext("sys_string", "IDS_COM_BODY_CAMERA"));
728
729         return TRUE;
730 }
731 //end file