2a137eac0693f189c58f9ef46d5b185846bd2300
[profile/ivi/emotion.git] / src / bin / emotion_test_main.c
1 #include <Evas.h>
2 #include <Ecore.h>
3 #ifndef FB_ONLY
4 #include <Ecore_X.h>
5 #else
6 #include <Ecore_Fb.h>
7 #endif
8 #include <Ecore_Evas.h>
9 #include <Edje.h>
10
11 #include "Emotion.h"
12
13 #include "config.h"
14
15 #include <stdlib.h>
16 #include <stdio.h>
17 #include <string.h>
18
19 typedef struct _Frame_Data Frame_Data;
20
21 struct _Frame_Data
22 {
23    char       moving : 1;
24    char       resizing : 1;
25    int        button;
26    Evas_Coord x, y;
27 };
28
29 static int  main_start(int argc, char **argv);
30 static void main_stop(void);
31 static void main_resize(Ecore_Evas *ee);
32 static int  main_signal_exit(void *data, int ev_type, void *ev);
33 static void main_delete_request(Ecore_Evas *ee);
34
35 void        bg_setup(void);
36 void        bg_resize(Evas_Coord w, Evas_Coord h);
37 static void bg_key_down(void *data, Evas * e, Evas_Object * obj, void *event_info);
38
39 static Evas_Object *o_bg = NULL;
40
41 double       start_time = 0.0;
42 Ecore_Evas  *ecore_evas = NULL;
43 Evas        *evas       = NULL;
44 int          startw     = 800;
45 int          starth     = 600;
46
47 Evas_List   *video_objs = NULL;
48
49 static int
50 main_start(int argc, char **argv)
51 {
52    int mode = 0;
53    
54    start_time = ecore_time_get();
55    if (!ecore_init()) return -1;
56    ecore_app_args_set(argc, (const char **)argv);
57    ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, main_signal_exit, NULL);
58    if (!ecore_evas_init()) return -1;
59 #ifndef FB_ONLY  
60      {
61         int i;
62
63         for (i = 1; i < argc; i++)
64           {
65              if (((!strcmp(argv[i], "-g")) ||
66                   (!strcmp(argv[i], "-geometry")) ||
67                   (!strcmp(argv[i], "--geometry"))) && (i < (argc - 1)))
68                {
69                   int n, w, h;
70                   char buf[16], buf2[16];
71                   
72                   n = sscanf(argv[i +1], "%10[^x]x%10s", buf, buf2);
73                   if (n == 2)
74                     {
75                        w = atoi(buf);
76                        h = atoi(buf2);
77                        startw = w;
78                        starth = h;
79                     }
80                   i++;
81                }
82              else if (!strcmp(argv[i], "-gl"))
83                {
84                   mode = 1;
85                }
86              else if (!strcmp(argv[i], "-fb"))
87                {
88                   mode = 2;
89                }
90           }
91      }
92 #if HAVE_ECORE_EVAS_X
93    if (mode == 0)
94      ecore_evas = ecore_evas_software_x11_new(NULL, 0,  0, 0, startw, starth);
95 #endif   
96 #if HAVE_ECORE_EVAS_GL
97    if (mode == 1)
98      ecore_evas = ecore_evas_gl_x11_new(NULL, 0, 0, 0, startw, starth);
99 #endif
100 #if HAVE_ECORE_EVAS_FB
101    if (mode == 2)
102      ecore_evas = ecore_evas_fb_new(NULL, 0, startw, starth);
103 #endif
104    
105 #else
106    startw = 240;
107    starth = 320;
108    ecore_evas = ecore_evas_fb_new(NULL, 270,  startw, starth);
109 #endif
110    if (!ecore_evas) return -1;
111    ecore_evas_callback_delete_request_set(ecore_evas, main_delete_request);
112    ecore_evas_callback_resize_set(ecore_evas, main_resize);
113    ecore_evas_title_set(ecore_evas, "Evas Media Test Program");
114    ecore_evas_name_class_set(ecore_evas, "evas_media_test", "main");
115    ecore_evas_show(ecore_evas);
116    evas = ecore_evas_get(ecore_evas);
117    evas_image_cache_set(evas, 8 * 1024 * 1024);
118    evas_font_cache_set(evas, 1 * 1024 * 1024);
119    evas_font_path_append(evas, PACKAGE_DATA_DIR"/data/fonts");
120    
121    edje_init();
122    edje_frametime_set(1.0 / 30.0);
123    return 1;
124 }
125
126 static void
127 main_stop(void)
128 {
129    ecore_evas_shutdown();
130    ecore_shutdown();
131 }
132
133 static void
134 main_resize(Ecore_Evas *ee)
135 {
136    Evas_Coord w, h;
137    
138    evas_output_viewport_get(evas, NULL, NULL, &w, &h);
139    bg_resize(w, h);
140 }
141
142 static int
143 main_signal_exit(void *data, int ev_type, void *ev)
144 {
145    ecore_main_loop_quit();
146    while (video_objs)
147      {
148         printf("del obj!\n");
149         evas_object_del(video_objs->data);
150         video_objs = evas_list_remove_list(video_objs, video_objs);
151         printf("done\n");
152      }
153    return 1;
154 }
155
156 static void
157 main_delete_request(Ecore_Evas *ee)
158 {
159    ecore_main_loop_quit();
160 }
161
162 void
163 bg_setup(void)
164 {
165    Evas_Object *o;
166
167    o = edje_object_add(evas);
168    edje_object_file_set(o, PACKAGE_DATA_DIR"/data/theme.edj", "background");
169    evas_object_move(o, 0, 0);
170    evas_object_resize(o, startw, starth);
171    evas_object_layer_set(o, -999);
172    evas_object_show(o);   
173    evas_object_focus_set(o, 1);
174    evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, bg_key_down, NULL);
175    o_bg = o;
176 }
177
178 void
179 bg_resize(Evas_Coord w, Evas_Coord h)
180 {
181    evas_object_resize(o_bg, w, h);
182 }
183
184 static void
185 broadcast_event(Emotion_Event ev)
186 {
187    Evas_List *l;
188    
189    for (l = video_objs; l; l = l->next)
190      {
191         Evas_Object *obj;
192                      
193         obj = l->data;
194         emotion_object_event_simple_send(obj, ev);
195      }
196 }
197
198 static void
199 bg_key_down(void *data, Evas * e, Evas_Object * obj, void *event_info)
200 {
201    Evas_Event_Key_Down *ev;
202    
203    ev = (Evas_Event_Key_Down *)event_info;
204    if      (!strcmp(ev->keyname, "Escape"))
205      ecore_main_loop_quit();
206    else if (!strcmp(ev->keyname, "Up"))
207      broadcast_event(EMOTION_EVENT_UP);
208    else if (!strcmp(ev->keyname, "Down"))
209      broadcast_event(EMOTION_EVENT_DOWN);
210    else if (!strcmp(ev->keyname, "Left"))
211      broadcast_event(EMOTION_EVENT_LEFT);
212    else if (!strcmp(ev->keyname, "Right"))
213      broadcast_event(EMOTION_EVENT_RIGHT);
214    else if (!strcmp(ev->keyname, "Return"))
215      broadcast_event(EMOTION_EVENT_SELECT);
216    else if (!strcmp(ev->keyname, "m"))
217      broadcast_event(EMOTION_EVENT_MENU1);
218    else if (!strcmp(ev->keyname, "Prior"))
219      broadcast_event(EMOTION_EVENT_PREV);
220    else if (!strcmp(ev->keyname, "Next"))
221      broadcast_event(EMOTION_EVENT_NEXT);
222    else if (!strcmp(ev->keyname, "0"))
223      broadcast_event(EMOTION_EVENT_0);
224    else if (!strcmp(ev->keyname, "1"))
225      broadcast_event(EMOTION_EVENT_1);
226    else if (!strcmp(ev->keyname, "2"))
227      broadcast_event(EMOTION_EVENT_2);
228    else if (!strcmp(ev->keyname, "3"))
229      broadcast_event(EMOTION_EVENT_3);
230    else if (!strcmp(ev->keyname, "4"))
231      broadcast_event(EMOTION_EVENT_4);
232    else if (!strcmp(ev->keyname, "5"))
233      broadcast_event(EMOTION_EVENT_5);
234    else if (!strcmp(ev->keyname, "6"))
235      broadcast_event(EMOTION_EVENT_6);
236    else if (!strcmp(ev->keyname, "7"))
237      broadcast_event(EMOTION_EVENT_7);
238    else if (!strcmp(ev->keyname, "8"))
239      broadcast_event(EMOTION_EVENT_8);
240    else if (!strcmp(ev->keyname, "9"))
241      broadcast_event(EMOTION_EVENT_9);
242    else if (!strcmp(ev->keyname, "-"))
243      broadcast_event(EMOTION_EVENT_10);
244    else if (!strcmp(ev->keyname, "bracketleft"))
245      {
246         Evas_List *l;
247         
248         for (l = video_objs; l; l = l->next)
249           {
250              Evas_Object *obj;
251              
252              obj = l->data;
253              emotion_object_audio_volume_set(obj, emotion_object_audio_volume_get(obj) - 0.1);
254           }
255      }
256    else if (!strcmp(ev->keyname, "bracketright"))
257      {
258         Evas_List *l;
259         
260         for (l = video_objs; l; l = l->next)
261           {
262              Evas_Object *obj;
263              
264              obj = l->data;
265              emotion_object_audio_volume_set(obj, emotion_object_audio_volume_get(obj) + 0.1);
266           }
267      }
268    else if (!strcmp(ev->keyname, "v"))
269      {
270         Evas_List *l;
271         
272         for (l = video_objs; l; l = l->next)
273           {
274              Evas_Object *obj;
275              
276              obj = l->data;
277              if (emotion_object_video_mute_get(obj))
278                emotion_object_video_mute_set(obj, 0);
279              else
280                emotion_object_video_mute_set(obj, 1);
281           }
282      }
283    else if (!strcmp(ev->keyname, "a"))
284      {
285         Evas_List *l;
286         
287         for (l = video_objs; l; l = l->next)
288           {
289              Evas_Object *obj;
290              
291              obj = l->data;
292              if (emotion_object_audio_mute_get(obj))
293                {
294                   emotion_object_audio_mute_set(obj, 0);
295                   printf("unmute\n");
296                }
297              else
298                {
299                   emotion_object_audio_mute_set(obj, 1);
300                   printf("mute\n");
301                }
302           }
303      }
304    else if (!strcmp(ev->keyname, "i"))
305      {
306         Evas_List *l;
307         
308         for (l = video_objs; l; l = l->next)
309           {
310              Evas_Object *obj;
311              
312              obj = l->data;
313              printf("audio channels: %i\n", emotion_object_audio_channel_count(obj));
314              printf("video channels: %i\n", emotion_object_video_channel_count(obj));
315              printf("spu channels: %i\n", emotion_object_spu_channel_count(obj));
316              printf("seekable: %i\n", emotion_object_seekable_get(obj));
317           }
318      }
319    else if (!strcmp(ev->keyname, "f"))
320      {
321         if (!ecore_evas_fullscreen_get(ecore_evas))
322           ecore_evas_fullscreen_set(ecore_evas, 1);
323         else
324           ecore_evas_fullscreen_set(ecore_evas, 0);
325      }
326    else if (!strcmp(ev->keyname, "d"))
327      {
328         if (!ecore_evas_avoid_damage_get(ecore_evas))
329           ecore_evas_avoid_damage_set(ecore_evas, 1);
330         else
331           ecore_evas_avoid_damage_set(ecore_evas, 0);
332      }
333    else if (!strcmp(ev->keyname, "s"))
334      {
335         if (!ecore_evas_shaped_get(ecore_evas))
336           {
337              ecore_evas_shaped_set(ecore_evas, 1);
338              evas_object_hide(o_bg);
339           }
340         else
341           {
342              ecore_evas_shaped_set(ecore_evas, 0);
343              evas_object_show(o_bg);
344           }
345      }
346    else if (!strcmp(ev->keyname, "b"))
347      {
348         if (!ecore_evas_borderless_get(ecore_evas))
349           ecore_evas_borderless_set(ecore_evas, 1);
350         else
351           ecore_evas_borderless_set(ecore_evas, 0);
352      }
353    else if (!strcmp(ev->keyname, "q"))
354      {
355         ecore_main_loop_quit();
356         while (video_objs)
357           {
358              printf("del obj!\n");
359              evas_object_del(video_objs->data);
360              video_objs = evas_list_remove_list(video_objs, video_objs);
361              printf("done\n");
362           }
363      }
364    else
365      {
366         printf("UNHANDLED: %s\n", ev->keyname);
367      }
368 }
369
370 static void
371 video_obj_in_cb(void *data, Evas *ev, Evas_Object *obj, void *event_info)
372 {
373 //   evas_object_color_set(obj, 255, 255, 255, 100);
374 }
375
376 static void
377 video_obj_out_cb(void *data, Evas *ev, Evas_Object *obj, void *event_info)
378 {
379 //   evas_object_color_set(obj, 255, 255, 255, 200);
380 }
381
382 static void
383 video_obj_down_cb(void *data, Evas *ev, Evas_Object *obj, void *event_info)
384 {
385    Evas_Event_Mouse_Down *e;
386    
387    e = event_info;
388    evas_object_color_set(obj, 255, 50, 40, 200);
389    evas_object_raise(obj);
390 }
391
392 static void
393 video_obj_up_cb(void *data, Evas *ev, Evas_Object *obj, void *event_info)
394 {
395    Evas_Event_Mouse_Up *e;
396    
397    e = event_info;
398    evas_object_color_set(obj, 255, 255, 255, 100);
399 }
400
401 static void
402 video_obj_move_cb(void *data, Evas *ev, Evas_Object *obj, void *event_info)
403 {
404    Evas_Event_Mouse_Move *e;
405    
406    e = event_info;
407    if (e->buttons & 0x1)
408      {
409         Evas_Coord x, y;
410         
411         evas_object_geometry_get(obj, &x, &y, NULL, NULL);
412         x += e->cur.canvas.x - e->prev.canvas.x;
413         y += e->cur.canvas.y - e->prev.canvas.y;
414         evas_object_move(obj, x, y);
415      }
416    else if (e->buttons & 0x4)
417      {
418         Evas_Coord w, h;
419         
420         evas_object_geometry_get(obj, NULL, NULL, &w, &h);
421         w += e->cur.canvas.x - e->prev.canvas.x;
422         h += e->cur.canvas.y - e->prev.canvas.y;
423         evas_object_resize(obj, w, h);
424      }
425 }
426
427 static void
428 video_obj_frame_decode_cb(void *data, Evas_Object *obj, void *event_info)
429 {
430    Evas_Object *oe;
431    double pos, len;
432    char buf[256];
433    int ph, pm, ps, pf, lh, lm, ls;
434
435    oe = data;
436    pos = emotion_object_position_get(obj);
437    len = emotion_object_play_length_get(obj);
438 //   printf("%3.3f, %3.3f\n", pos, len);
439    edje_object_part_drag_value_set(oe, "video_progress", pos / len, 0.0);
440    lh = len / 3600;
441    lm = len / 60 - (lh * 60);
442    ls = len - (lm * 60);
443    ph = pos / 3600;
444    pm = pos / 60 - (ph * 60);
445    ps = pos - (pm * 60);
446    pf = pos * 100 - (ps * 100) - (pm * 60 * 100) - (ph * 60 * 60 * 100);
447    snprintf(buf, sizeof(buf), "%i:%02i:%02i.%02i / %i:%02i:%02i",
448             ph, pm, ps, pf, lh, lm, ls);
449    edje_object_part_text_set(oe, "video_progress_txt", buf);
450    
451    if (0)
452      {
453         double t;
454         static double pt = 0.0;
455         t = ecore_time_get();
456         printf("FPS: %3.3f\n", 1.0 / (t - pt));
457         pt = t;
458      }
459 }
460
461 static void
462 video_obj_frame_resize_cb(void *data, Evas_Object *obj, void *event_info)
463 {
464    Evas_Object *oe;
465    int iw, ih;
466    Evas_Coord w, h;
467    double ratio;
468
469    oe = data;
470    emotion_object_size_get(obj, &iw, &ih);
471    ratio = emotion_object_ratio_get(obj);
472    printf("HANDLE %ix%i @ %3.3f\n", iw, ih, ratio);
473    if (ratio > 0.0) iw = ih * ratio;
474    edje_extern_object_min_size_set(obj, iw, ih);
475    edje_object_part_swallow(oe, "video_swallow", obj);
476    edje_object_size_min_calc(oe, &w, &h);
477    evas_object_resize(oe, w, h);
478    edje_extern_object_min_size_set(obj, 0, 0);
479    edje_object_part_swallow(oe, "video_swallow", obj);
480 }
481
482 static void
483 video_obj_length_change_cb(void *data, Evas_Object *obj, void *event_info)
484 {
485    Evas_Object *oe;
486    double pos, len;
487    char buf[256];
488    int ph, pm, ps, pf, lh, lm, ls;
489
490    oe = data;
491    pos = emotion_object_position_get(obj);
492    len = emotion_object_play_length_get(obj);
493    edje_object_part_drag_value_set(oe, "video_progress", pos / len, 0.0);
494    lh = len / 3600;
495    lm = len / 60 - (lh * 60);
496    ls = len - (lm * 60);
497    ph = pos / 3600;
498    pm = pos / 60 - (ph * 60);
499    ps = pos - (pm * 60);
500    pf = pos * 100 - (ps * 100) - (pm * 60 * 100) - (ph * 60 * 60 * 100);
501    snprintf(buf, sizeof(buf), "%i:%02i:%02i.%02i / %i:%02i:%02i",
502             ph, pm, ps, pf, lh, lm, ls);
503    edje_object_part_text_set(oe, "video_progress_txt", buf);
504 }
505
506 static void
507 video_obj_stopped_cb(void *data, Evas_Object *obj, void *event_info)
508 {
509    Evas_Object *oe;
510
511    oe = data;
512    printf("video stopped!\n");
513    emotion_object_position_set(obj, 0.0);
514    emotion_object_play_set(obj, 1);
515 }
516
517 static void
518 video_obj_channels_cb(void *data, Evas_Object *obj, void *event_info)
519 {
520    Evas_Object *oe;
521
522    oe = data;
523    printf("channels changed: [AUD %i][VID %i][SPU %i]\n",
524           emotion_object_audio_channel_count(obj),
525           emotion_object_video_channel_count(obj),
526           emotion_object_spu_channel_count(obj));
527 }
528
529 static void
530 video_obj_title_cb(void *data, Evas_Object *obj, void *event_info)
531 {
532    Evas_Object *oe;
533
534    oe = data;
535    printf("video title to: \"%s\"\n", emotion_object_title_get(obj));
536 }
537
538 static void
539 video_obj_progress_cb(void *data, Evas_Object *obj, void *event_info)
540 {
541    Evas_Object *oe;
542
543    oe = data;
544    printf("progress: \"%s\" %3.3f\n", 
545           emotion_object_progress_info_get(obj),
546           emotion_object_progress_status_get(obj));
547 }
548
549 static void
550 video_obj_ref_cb(void *data, Evas_Object *obj, void *event_info)
551 {
552    Evas_Object *oe;
553
554    oe = data;
555    printf("video ref to: \"%s\" %i\n",
556           emotion_object_ref_file_get(obj),
557           emotion_object_ref_num_get(obj));
558 }
559
560 static void
561 video_obj_button_num_cb(void *data, Evas_Object *obj, void *event_info)
562 {
563    Evas_Object *oe;
564
565    oe = data;
566    printf("video spu buttons to: %i\n",
567           emotion_object_spu_button_count_get(obj));
568 }
569
570 static void
571 video_obj_button_cb(void *data, Evas_Object *obj, void *event_info)
572 {
573    Evas_Object *oe;
574
575    oe = data;
576    printf("video selected spu button: %i\n",
577           emotion_object_spu_button_get(obj));
578 }
579
580
581
582 static void
583 video_obj_signal_play_cb(void *data, Evas_Object *o, const char *emission, const char *source)
584 {
585    Evas_Object *ov;
586    
587    ov = data;
588    emotion_object_play_set(ov, 1);
589    edje_object_signal_emit(o, "video_state", "play");
590 }
591
592 static void
593 video_obj_signal_pause_cb(void *data, Evas_Object *o, const char *emission, const char *source)
594 {
595    Evas_Object *ov;
596    
597    ov = data;
598    emotion_object_play_set(ov, 0);
599    edje_object_signal_emit(o, "video_state", "pause");
600 }
601
602 static void
603 video_obj_signal_stop_cb(void *data, Evas_Object *o, const char *emission, const char *source)
604 {
605    Evas_Object *ov;
606    
607    ov = data;
608    emotion_object_play_set(ov, 0);
609    emotion_object_position_set(ov, 0);
610    edje_object_signal_emit(o, "video_state", "stop");
611 }
612
613 static void
614 video_obj_signal_jump_cb(void *data, Evas_Object *o, const char *emission, const char *source)
615 {
616    Evas_Object *ov;
617    double len;
618    double x, y;
619    
620    ov = data;
621    edje_object_part_drag_value_get(o, source, &x, &y);
622    len = emotion_object_play_length_get(ov);
623    emotion_object_position_set(ov, x * len);
624 }
625
626 static void
627 video_obj_signal_speed_cb(void *data, Evas_Object *o, const char *emission, const char *source)
628 {
629    Evas_Object *ov;
630    double spd;
631    double x, y;
632    char buf[256];
633    
634    ov = data;
635    edje_object_part_drag_value_get(o, source, &x, &y);
636    spd = 255 * y;
637    evas_object_color_set(ov, 255, 255, 255, spd);
638    snprintf(buf, sizeof(buf), "%.0f", spd);
639    edje_object_part_text_set(o, "video_speed_txt", buf);
640 }
641
642 static void
643 video_obj_signal_frame_move_start_cb(void *data, Evas_Object *o, const char *emission, const char *source)
644 {
645    Frame_Data *fd;
646    Evas_Coord x, y;
647    
648    fd = evas_object_data_get(o, "frame_data");
649    fd->moving = 1;
650    evas_pointer_canvas_xy_get(evas_object_evas_get(o), &x, &y);
651    fd->x = x;
652    fd->y = y;
653    evas_object_raise(o);
654 }
655
656 static void
657 video_obj_signal_frame_move_stop_cb(void *data, Evas_Object *o, const char *emission, const char *source)
658 {
659    Frame_Data *fd;
660    
661    fd = evas_object_data_get(o, "frame_data");
662    fd->moving = 0;
663 }
664
665 static void
666 video_obj_signal_frame_resize_start_cb(void *data, Evas_Object *o, const char *emission, const char *source)
667 {
668    Frame_Data *fd;
669    Evas_Coord x, y;
670    
671    fd = evas_object_data_get(o, "frame_data");
672    fd->resizing = 1;
673    evas_pointer_canvas_xy_get(evas_object_evas_get(o), &x, &y);
674    fd->x = x;
675    fd->y = y;
676    evas_object_raise(o);
677 }
678
679 static void
680 video_obj_signal_frame_resize_stop_cb(void *data, Evas_Object *o, const char *emission, const char *source)
681 {
682    Frame_Data *fd;
683    
684    fd = evas_object_data_get(o, "frame_data");
685    fd->resizing = 0;
686 }
687
688 static void
689 video_obj_signal_frame_move_cb(void *data, Evas_Object *o, const char *emission, const char *source)
690 {
691    Frame_Data *fd;
692    
693    fd = evas_object_data_get(o, "frame_data");
694    if (fd->moving)
695      {
696         Evas_Coord x, y, ox, oy;
697         
698         evas_pointer_canvas_xy_get(evas_object_evas_get(o), &x, &y);
699         evas_object_geometry_get(o, &ox, &oy, NULL, NULL);
700         evas_object_move(o, ox + (x - fd->x), oy + (y - fd->y));
701         fd->x = x;
702         fd->y = y;
703      }
704    else if (fd->resizing)
705      {
706         Evas_Coord x, y, ow, oh;
707         
708         evas_pointer_canvas_xy_get(evas_object_evas_get(o), &x, &y);
709         evas_object_geometry_get(o, NULL, NULL, &ow, &oh);
710         evas_object_resize(o, ow + (x - fd->x), oh + (y - fd->y));
711         fd->x = x;
712         fd->y = y;
713      }
714 }
715
716
717 static void
718 init_video_object(char *module_filename, char *filename)
719 {
720    Evas_Object *o, *oe;
721    int iw, ih;
722    Evas_Coord w, h;
723    Frame_Data *fd;
724
725    
726 /* basic video object setup */   
727    o = emotion_object_add(evas); 
728    if (!emotion_object_init(o, module_filename))
729      return; 
730    emotion_object_file_set(o, filename);
731    emotion_object_play_set(o, 1);
732    evas_object_move(o, 0, 0);
733    evas_object_resize(o, 320, 240);
734    emotion_object_smooth_scale_set(o, 1);
735    evas_object_show(o);
736 /* end basic video setup. all the rest here is just to be fancy */
737
738    
739    video_objs = evas_list_append(video_objs, o);
740    
741    emotion_object_size_get(o, &iw, &ih);
742    w = iw; h = ih;
743    
744    fd = calloc(1, sizeof(Frame_Data));
745    
746    oe = edje_object_add(evas);
747    evas_object_data_set(oe, "frame_data", fd);
748    edje_object_file_set(oe, PACKAGE_DATA_DIR"/data/theme.edj", "video_controller");
749    edje_extern_object_min_size_set(o, w, h);
750    edje_object_part_swallow(oe, "video_swallow", o);
751    edje_object_size_min_calc(oe, &w, &h);
752 //   evas_object_move(oe, rand() % (int)(startw - w), rand() % (int)(starth - h));
753    evas_object_move(oe, 0, 0);
754    evas_object_resize(oe, w, h);
755    edje_extern_object_min_size_set(o, 0, 0);
756    edje_object_part_swallow(oe, "video_swallow", o);
757    
758    evas_object_smart_callback_add(o, "frame_decode", video_obj_frame_decode_cb, oe);
759    evas_object_smart_callback_add(o, "frame_resize", video_obj_frame_resize_cb, oe);
760    evas_object_smart_callback_add(o, "length_change", video_obj_length_change_cb, oe);
761
762    evas_object_smart_callback_add(o, "decode_stop", video_obj_stopped_cb, oe);
763    evas_object_smart_callback_add(o, "channels_change", video_obj_channels_cb, oe);
764    evas_object_smart_callback_add(o, "title_change", video_obj_title_cb, oe);
765    evas_object_smart_callback_add(o, "progress_change", video_obj_progress_cb, oe);
766    evas_object_smart_callback_add(o, "ref_change", video_obj_ref_cb, oe);
767    evas_object_smart_callback_add(o, "button_num_change", video_obj_button_num_cb, oe);
768    evas_object_smart_callback_add(o, "button_change", video_obj_button_cb, oe);
769    
770    edje_object_signal_callback_add(oe, "video_control", "play", video_obj_signal_play_cb, o);
771    edje_object_signal_callback_add(oe, "video_control", "pause", video_obj_signal_pause_cb, o);
772    edje_object_signal_callback_add(oe, "video_control", "stop", video_obj_signal_stop_cb, o);
773    edje_object_signal_callback_add(oe, "drag", "video_progress", video_obj_signal_jump_cb, o);
774    edje_object_signal_callback_add(oe, "drag", "video_speed", video_obj_signal_speed_cb, o);
775
776    edje_object_signal_callback_add(oe, "frame_move", "start", video_obj_signal_frame_move_start_cb, oe);
777    edje_object_signal_callback_add(oe, "frame_move", "stop", video_obj_signal_frame_move_stop_cb, oe);
778    edje_object_signal_callback_add(oe, "frame_resize", "start", video_obj_signal_frame_resize_start_cb, oe);
779    edje_object_signal_callback_add(oe, "frame_resize", "stop", video_obj_signal_frame_resize_stop_cb, oe);
780    edje_object_signal_callback_add(oe, "mouse,move", "*", video_obj_signal_frame_move_cb, oe);
781    
782    edje_object_part_drag_value_set(oe, "video_speed", 0.0, 1.0);
783    edje_object_part_text_set(oe, "video_speed_txt", "1.0");
784
785    edje_object_signal_emit(o, "video_state", "play");
786    
787    evas_object_show(oe);
788 }
789
790 static int
791 enter_idle(void *data)
792 {
793    double t;
794    static double pt = 0.0;
795    static int frames = 0;
796    
797    t = ecore_time_get();
798    if (frames == 0) pt = t;
799    frames++;
800    if (frames == 100)
801      {
802 //      printf("FPS: %3.3f\n", frames / (t - pt));
803         frames = 0;
804      }
805    return 1;
806 }
807
808 int
809 main(int argc, char **argv)
810 {
811    char *module_filename;
812    int i;
813    
814    if (main_start(argc, argv) < 1) return -1;
815    bg_setup();
816
817    module_filename = "emotion_decoder_xine.so";
818
819    for (i = 1; i < argc; i++)
820      {
821         if (((!strcmp(argv[i], "-g")) ||
822             (!strcmp(argv[i], "-geometry")) ||
823             (!strcmp(argv[i], "--geometry"))) && (i < (argc - 1)))
824              i++;
825         else if (((!strcmp(argv[i], "-h")) ||
826             (!strcmp(argv[i], "-help")) ||
827             (!strcmp(argv[i], "--help"))))
828           {
829              printf("Usage:\n");
830              printf("  %s [-gl] [-g WxH] [-xine] [-gstreamer] filename\n", argv[0]);
831              exit(-1);
832           }
833         else if (!strcmp(argv[i], "-gl"))
834           {
835           }
836         else if (!strcmp(argv[i], "-fb"))
837           {
838           }
839         else if (!strcmp(argv[i], "-xine"))
840           {
841              module_filename = "emotion_decoder_xine.so";
842           }
843         else if (!strcmp(argv[i], "-gstreamer"))
844           {
845              module_filename = "emotion_decoder_gstreamer.so";
846           }
847         else
848           {
849              printf ("module : %s\n", module_filename);
850              init_video_object(module_filename, argv[i]);
851           }
852      }
853    
854    ecore_idle_enterer_add(enter_idle, NULL);
855
856    ecore_main_loop_begin();
857    main_stop();
858    return 0;
859 }
860