summaryrefslogtreecommitdiff
path: root/src/tests/emotion
diff options
context:
space:
mode:
authorAvi Levin <avi.levin@samsung.com>2015-06-14 11:46:59 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2015-06-29 11:42:17 +0300
commitdc5d6a6f7d7e0068625a9d9dead65dc49595393a (patch)
tree6d2129e42ebc8e4d7bfd8277d38513aa704e692c /src/tests/emotion
parentd833722e6ee2fb2848ab28e940aac6dd2a4b2969 (diff)
Emotion: Adding Eo test for emotion
This test is exactly like the existing legacy one but works with Eo invocations.
Diffstat (limited to 'src/tests/emotion')
-rw-r--r--src/tests/emotion/emotion_test_main-eo.c835
1 files changed, 835 insertions, 0 deletions
diff --git a/src/tests/emotion/emotion_test_main-eo.c b/src/tests/emotion/emotion_test_main-eo.c
new file mode 100644
index 0000000000..efa9d3c8ea
--- /dev/null
+++ b/src/tests/emotion/emotion_test_main-eo.c
@@ -0,0 +1,835 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#else
4#define EFL_EO_API_SUPPORT
5#define EFL_BETA_API_SUPPORT
6#endif
7
8#include <Eo.h>
9#include <stdlib.h>
10#include <stdio.h>
11#include <string.h>
12
13#include <Evas.h>
14#include <Ecore.h>
15#include <Ecore_Getopt.h>
16#include <Ecore_Evas.h>
17#include <Edje.h>
18
19#include "Emotion.h"
20
21static const Ecore_Getopt options = {
22 "emotion_test",
23 "%prog [options] <filename>",
24 "1.0.0",
25 "(C) 2011-2014 Enlightenment",
26 "BSD\nThis is a 3 clause bsd bla bla",
27 "a simple test program for emotion.",
28 1,
29 {
30 ECORE_GETOPT_STORE_STR('e', "engine", "ecore-evas engine to use"),
31 ECORE_GETOPT_CALLBACK_NOARGS('E', "list-engines", "list ecore-evas engines",
32 ecore_getopt_callback_ecore_evas_list_engines, NULL),
33 ECORE_GETOPT_CALLBACK_ARGS('g', "geometry", "geometry to use in x:y:w:h form.", "X:Y:W:H",
34 ecore_getopt_callback_geometry_parse, NULL),
35 ECORE_GETOPT_STORE_STR('b', "backend", "backend to use"),
36 ECORE_GETOPT_STORE_INT('v', "vis", "visualization type"),
37 ECORE_GETOPT_STORE_TRUE('w', "webcams", "show all the available v4l streams"),
38 ECORE_GETOPT_STORE_TRUE('r', "reflex", "show video reflex effect"),
39 ECORE_GETOPT_STORE_TRUE('l', "loop", "restart the video when end reached"),
40 ECORE_GETOPT_STORE_TRUE('p', "position", "start the video from last know position"),
41 ECORE_GETOPT_VERSION('V', "version"),
42 ECORE_GETOPT_COPYRIGHT('R', "copyright"),
43 ECORE_GETOPT_LICENSE('L', "license"),
44 ECORE_GETOPT_HELP('h', "help"),
45 ECORE_GETOPT_SENTINEL
46 }
47};
48
49typedef struct _Frame_Data Frame_Data;
50
51struct _Frame_Data
52{
53 unsigned char moving : 1;
54 unsigned char resizing : 1;
55 int button;
56 Evas_Coord x, y;
57};
58
59static Eina_Bool bg_key_down(void *data EINA_UNUSED, Eo *obj EINA_UNUSED,
60 const Eo_Event_Description *desc EINA_UNUSED, void *event_info);
61
62
63static Evas_Object *o_bg = NULL;
64
65static Ecore_Evas *ecore_evas = NULL;
66static Evas *evas = NULL;
67static int startw = 800;
68static int starth = 600;
69
70static Eina_List *video_objs = NULL;
71static Emotion_Vis vis = EMOTION_VIS_NONE;
72static unsigned char reflex = 0;
73static unsigned char loop = 0;
74static unsigned char last_position_load = 0;
75static const char *theme_file = NULL;
76
77static void
78bg_resize(Evas_Coord w, Evas_Coord h)
79{
80 eo_do(o_bg, efl_gfx_size_set(w, h));
81}
82
83static void
84main_resize(Ecore_Evas *ee)
85{
86 Evas_Coord w, h;
87
88 eo_do(ecore_evas_get(ee),
89 evas_canvas_output_viewport_get(NULL, NULL, &w, &h));
90 bg_resize(w, h);
91}
92
93static Eina_Bool
94main_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
95{
96 Evas_Object *o;
97
98 ecore_main_loop_quit();
99 EINA_LIST_FREE(video_objs, o)
100 {
101 emotion_object_last_position_save(o);
102 eo_del(o);
103 }
104 return EINA_TRUE;
105}
106
107static void
108main_delete_request(Ecore_Evas *ee EINA_UNUSED)
109{
110 ecore_main_loop_quit();
111}
112
113static void
114bg_setup(void)
115{
116 o_bg = eo_add(EDJE_OBJECT_CLASS, evas);
117 eo_do(o_bg, efl_file_set(theme_file, "background"),
118 efl_gfx_position_set(0, 0),
119 efl_gfx_size_set(startw, starth),
120 efl_gfx_stack_layer_set(-999),
121 efl_gfx_visible_set(EINA_TRUE),
122 evas_obj_focus_set(EINA_TRUE),
123
124 eo_event_callback_add(EVAS_OBJECT_EVENT_KEY_DOWN,
125 bg_key_down, NULL));
126}
127
128static void
129broadcast_event(Emotion_Event ev)
130{
131 Eina_List *l;
132 Evas_Object *obj;
133
134 EINA_LIST_FOREACH(video_objs, l, obj)
135 emotion_object_event_simple_send(obj, ev);
136}
137
138static Eina_Bool
139bg_key_down(void *data EINA_UNUSED, Eo *obj EINA_UNUSED,
140 const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
141{
142 Evas_Event_Key_Down *ev = event_info;
143 Eina_List *l;
144 Evas_Object *o;
145
146 if (!strcmp(ev->keyname, "Escape"))
147 ecore_main_loop_quit();
148 else if (!strcmp(ev->keyname, "Up"))
149 broadcast_event(EMOTION_EVENT_UP);
150 else if (!strcmp(ev->keyname, "Down"))
151 broadcast_event(EMOTION_EVENT_DOWN);
152 else if (!strcmp(ev->keyname, "Left"))
153 broadcast_event(EMOTION_EVENT_LEFT);
154 else if (!strcmp(ev->keyname, "Right"))
155 broadcast_event(EMOTION_EVENT_RIGHT);
156 else if (!strcmp(ev->keyname, "Return"))
157 broadcast_event(EMOTION_EVENT_SELECT);
158 else if (!strcmp(ev->keyname, "m"))
159 broadcast_event(EMOTION_EVENT_MENU1);
160 else if (!strcmp(ev->keyname, "Prior"))
161 broadcast_event(EMOTION_EVENT_PREV);
162 else if (!strcmp(ev->keyname, "Next"))
163 broadcast_event(EMOTION_EVENT_NEXT);
164 else if (!strcmp(ev->keyname, "0"))
165 broadcast_event(EMOTION_EVENT_0);
166 else if (!strcmp(ev->keyname, "1"))
167 broadcast_event(EMOTION_EVENT_1);
168 else if (!strcmp(ev->keyname, "2"))
169 broadcast_event(EMOTION_EVENT_2);
170 else if (!strcmp(ev->keyname, "3"))
171 broadcast_event(EMOTION_EVENT_3);
172 else if (!strcmp(ev->keyname, "4"))
173 broadcast_event(EMOTION_EVENT_4);
174 else if (!strcmp(ev->keyname, "5"))
175 broadcast_event(EMOTION_EVENT_5);
176 else if (!strcmp(ev->keyname, "6"))
177 broadcast_event(EMOTION_EVENT_6);
178 else if (!strcmp(ev->keyname, "7"))
179 broadcast_event(EMOTION_EVENT_7);
180 else if (!strcmp(ev->keyname, "8"))
181 broadcast_event(EMOTION_EVENT_8);
182 else if (!strcmp(ev->keyname, "9"))
183 broadcast_event(EMOTION_EVENT_9);
184 else if (!strcmp(ev->keyname, "-"))
185 broadcast_event(EMOTION_EVENT_10);
186 else if (!strcmp(ev->keyname, "v"))
187 {
188 EINA_LIST_FOREACH(video_objs, l, o)
189 {
190 if (emotion_object_video_mute_get(o))
191 emotion_object_video_mute_set(o, EINA_FALSE);
192 else
193 emotion_object_video_mute_set(o, EINA_TRUE);
194 }
195 }
196 else if (!strcmp(ev->keyname, "a"))
197 {
198 EINA_LIST_FOREACH(video_objs, l, o)
199 {
200 if (emotion_object_audio_mute_get(o))
201 {
202 emotion_object_audio_mute_set(o, EINA_FALSE);
203 printf("unmute\n");
204 }
205 else
206 {
207 emotion_object_audio_mute_set(o, EINA_TRUE);
208 printf("mute\n");
209 }
210 }
211 }
212 else if (!strcmp(ev->keyname, "i"))
213 {
214 EINA_LIST_FOREACH(video_objs, l, o)
215 {
216 printf("audio channels: %i\n", emotion_object_audio_channel_count(o));
217 printf("video channels: %i\n", emotion_object_video_channel_count(o));
218 printf("spu channels: %i\n", emotion_object_spu_channel_count(o));
219 printf("seekable: %i\n", emotion_object_seekable_get(o));
220 }
221 }
222 else if (!strcmp(ev->keyname, "f"))
223 {
224 if (!ecore_evas_fullscreen_get(ecore_evas))
225 ecore_evas_fullscreen_set(ecore_evas, EINA_TRUE);
226 else
227 ecore_evas_fullscreen_set(ecore_evas, EINA_FALSE);
228 }
229 else if (!strcmp(ev->keyname, "d"))
230 {
231 if (!ecore_evas_avoid_damage_get(ecore_evas))
232 ecore_evas_avoid_damage_set(ecore_evas, EINA_TRUE);
233 else
234 ecore_evas_avoid_damage_set(ecore_evas, EINA_FALSE);
235 }
236 else if (!strcmp(ev->keyname, "s"))
237 {
238 if (!ecore_evas_shaped_get(ecore_evas))
239 {
240 ecore_evas_shaped_set(ecore_evas, EINA_TRUE);
241 evas_object_hide(o_bg);
242 }
243 else
244 {
245 ecore_evas_shaped_set(ecore_evas, EINA_FALSE);
246 evas_object_show(o_bg);
247 }
248 }
249 else if (!strcmp(ev->keyname, "b"))
250 {
251 if (!ecore_evas_borderless_get(ecore_evas))
252 ecore_evas_borderless_set(ecore_evas, EINA_TRUE);
253 else
254 ecore_evas_borderless_set(ecore_evas, EINA_FALSE);
255 }
256 else if (!strcmp(ev->keyname, "q"))
257 {
258 ecore_main_loop_quit();
259 while (video_objs)
260 {
261 printf("del obj!\n");
262 evas_object_del(video_objs->data);
263 video_objs = eina_list_remove_list(video_objs, video_objs);
264 printf("done\n");
265 }
266 }
267 else if (!strcmp(ev->keyname, "z"))
268 {
269 vis = (vis + 1) % EMOTION_VIS_LAST;
270 printf("new visualization: %d\n", vis);
271
272 EINA_LIST_FOREACH(video_objs, l, o)
273 {
274 Eina_Bool supported;
275
276 supported = emotion_object_vis_supported(o, vis);
277 if (supported)
278 emotion_object_vis_set(o, vis);
279 else
280 {
281 const char *file;
282
283 file = emotion_object_file_get(o);
284 printf("object %p (%s) does not support visualization %d\n",
285 o, file, vis);
286 }
287 }
288 }
289 else
290 {
291 printf("UNHANDLED: %s\n", ev->keyname);
292 }
293
294 return EINA_TRUE;
295}
296
297static Eina_Bool
298_oe_free_cb(void *data,
299 Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
300{
301 free(data);
302 return EINA_TRUE;
303}
304
305static void
306video_obj_time_changed(Evas_Object *obj, Evas_Object *edje)
307{
308 double pos, len, scale;
309 char buf[256];
310 int ph, pm, ps, pf, lh, lm, ls;
311
312 pos = emotion_object_position_get(obj);
313 len = emotion_object_play_length_get(obj);
314 scale = (len > 0.0) ? pos / len : 0.0;
315 eo_do(edje, edje_obj_part_drag_value_set("video_progress", scale, 0.0));
316
317 lh = len / 3600;
318 lm = len / 60 - (lh * 60);
319 ls = len - (lh * 3600) - (lm * 60);
320
321 ph = pos / 3600;
322 pm = pos / 60 - (ph * 60);
323 ps = pos - (ph * 3600) - (pm * 60);
324
325 pf = pos * 100 - (ps * 100) - (pm * 60 * 100) - (ph * 60 * 60 * 100);
326
327 snprintf(buf, sizeof(buf), "%i:%02i:%02i.%02i / %i:%02i:%02i",
328 ph, pm, ps, pf, lh, lm, ls);
329 eo_do(edje, edje_obj_part_text_set("video_progress_txt", buf));
330}
331
332static Eina_Bool
333video_obj_frame_decode_cb(void *data,
334 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
335{
336 video_obj_time_changed(obj, data);
337
338 if (0)
339 {
340 double t;
341 static double pt = 0.0;
342 t = ecore_time_get();
343 printf("FPS: %3.3f\n", 1.0 / (t - pt));
344 pt = t;
345 }
346 return EINA_TRUE;
347}
348
349static Eina_Bool
350video_obj_frame_resize_cb(void *data,
351 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
352{
353 Evas_Object *oe;
354 int iw, ih;
355 Evas_Coord w, h;
356 double ratio;
357
358 oe = data;
359 emotion_object_size_get(obj, &iw, &ih);
360 ratio = emotion_object_ratio_get(obj);
361 printf("HANDLE %ix%i @ %3.3f\n", iw, ih, ratio);
362 if (ratio > 0.0) iw = (ih * ratio) + 0.5;
363 evas_object_size_hint_min_set(obj, iw, ih);
364 eo_do(oe, edje_obj_part_swallow( "video_swallow", obj),
365 edje_obj_size_min_calc(&w, &h),
366 efl_gfx_size_set(w, h)
367 );
368 eo_do(obj, evas_obj_size_hint_min_set(0, 0));
369 eo_do(oe, edje_obj_part_swallow( "video_swallow", obj));
370
371 return EINA_TRUE;
372}
373
374static Eina_Bool
375video_obj_length_change_cb(void *data,
376 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
377{
378 printf("len change!\n");
379 video_obj_time_changed(obj, data);
380
381 return EINA_TRUE;
382}
383
384static Eina_Bool
385video_obj_position_update_cb(void *data,
386 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
387{
388 printf("pos up!\n");
389 video_obj_time_changed(obj, data);
390
391 return EINA_TRUE;
392}
393
394static Eina_Bool
395video_obj_stopped_cb(void *data EINA_UNUSED,
396 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
397{
398 printf("video stopped!!!\n");
399 if (loop)
400 {
401 emotion_object_position_set(obj, 0.0);
402 emotion_object_play_set(obj, EINA_TRUE);
403 }
404
405 return EINA_TRUE;
406}
407
408static Eina_Bool
409video_obj_channels_cb(void *data EINA_UNUSED,
410 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
411{
412 printf("channels changed: [AUD %i][VID %i][SPU %i]\n",
413 emotion_object_audio_channel_count(obj),
414 emotion_object_video_channel_count(obj),
415 emotion_object_spu_channel_count(obj));
416
417 return EINA_TRUE;
418}
419
420static Eina_Bool
421 video_obj_title_cb(void *data EINA_UNUSED,
422 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
423{
424 printf("video title to: \"%s\"\n", emotion_object_title_get(obj));
425
426 return EINA_TRUE;
427}
428
429static Eina_Bool
430video_obj_progress_cb(void *data EINA_UNUSED,
431 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
432{
433 printf("progress: \"%s\" %3.3f\n",
434 emotion_object_progress_info_get(obj),
435 emotion_object_progress_status_get(obj));
436
437 return EINA_TRUE;
438}
439
440static Eina_Bool
441video_obj_ref_cb(void *data EINA_UNUSED,
442 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
443{
444 printf("video ref to: \"%s\" %i\n",
445 emotion_object_ref_file_get(obj),
446 emotion_object_ref_num_get(obj));
447
448 return EINA_TRUE;
449}
450
451static Eina_Bool
452video_obj_button_num_cb(void *data EINA_UNUSED,
453 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
454{
455 printf("video spu buttons to: %i\n",
456 emotion_object_spu_button_count_get(obj));
457
458 return EINA_TRUE;
459}
460
461static Eina_Bool
462video_obj_button_cb(void *data EINA_UNUSED,
463 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
464{
465 printf("video selected spu button: %i\n",
466 emotion_object_spu_button_get(obj));
467
468 return EINA_TRUE;
469}
470
471static void
472video_obj_signal_play_cb(void *data, Evas_Object *o, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
473{
474 Evas_Object *ov = data;
475 emotion_object_play_set(ov, EINA_TRUE);
476 eo_do(o, edje_obj_signal_emit("video_state", "play"));
477}
478
479static void
480video_obj_signal_pause_cb(void *data, Evas_Object *o, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
481{
482 Evas_Object *ov = data;
483 emotion_object_play_set(ov, EINA_FALSE);
484 eo_do(o, edje_obj_signal_emit("video_state", "pause"));
485}
486
487static void
488video_obj_signal_stop_cb(void *data, Evas_Object *o, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
489{
490 Evas_Object *ov = data;
491 emotion_object_play_set(ov, EINA_FALSE);
492 emotion_object_position_set(ov, 0.0);
493 eo_do(o, edje_obj_signal_emit("video_state", "stop"));
494}
495
496static void
497video_obj_signal_jump_cb(void *data, Evas_Object *o, const char *emission EINA_UNUSED, const char *source)
498{
499 Evas_Object *ov = data;
500 double len;
501 double x, y;
502
503 eo_do(o, edje_obj_part_drag_value_get(source, &x, &y));
504 len = emotion_object_play_length_get(ov);
505 emotion_object_position_set(ov, x * len);
506}
507
508static void
509video_obj_signal_alpha_cb(void *data, Evas_Object *o, const char *emission EINA_UNUSED, const char *source)
510{
511 Evas_Object *ov = data;
512 double alpha;
513 double x, y;
514 char buf[256];
515
516 eo_do(o, edje_obj_part_drag_value_get(source, &x, &y));
517 alpha = 255 * y;
518 eo_do(ov, efl_gfx_color_set(alpha, alpha, alpha, alpha));
519 snprintf(buf, sizeof(buf), "alpha %.0f", alpha);
520 eo_do(o, edje_obj_part_text_set("video_alpha_txt", buf));
521}
522
523static void
524video_obj_signal_vol_cb(void *data, Evas_Object *o, const char *emission EINA_UNUSED, const char *source)
525{
526 Evas_Object *ov = data;
527 double vol;
528 char buf[256];
529
530 eo_do(o, edje_obj_part_drag_value_get(source, NULL, &vol));
531 emotion_object_audio_volume_set(ov, vol);
532 snprintf(buf, sizeof(buf), "vol %.2f", vol);
533 eo_do(o, edje_obj_part_text_set("video_volume_txt", buf));
534}
535
536static void
537video_obj_signal_frame_move_start_cb(void *data EINA_UNUSED, Evas_Object *o, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
538{
539 Frame_Data *fd;
540 Evas_Coord x, y;
541
542 eo_do(o, fd = eo_key_data_get("frame_data"));
543 if (!fd) return;
544 fd->moving = 1;
545 eo_do(evas_object_evas_get(o),
546 evas_canvas_pointer_canvas_xy_get(&x, &y));
547 fd->x = x;
548 fd->y = y;
549 eo_do(o, efl_gfx_stack_raise());
550}
551
552static void
553video_obj_signal_frame_move_stop_cb(void *data EINA_UNUSED, Evas_Object *o, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
554{
555 Frame_Data *fd;
556
557 eo_do(o, fd = eo_key_data_get("frame_data"));
558 if (!fd) return;
559 fd->moving = 0;
560}
561
562static void
563video_obj_signal_frame_resize_start_cb(void *data EINA_UNUSED, Evas_Object *o, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
564{
565 Frame_Data *fd;
566 Evas_Coord x, y;
567
568 eo_do(o, fd = eo_key_data_get("frame_data"));
569 if (!fd) return;
570 fd->resizing = 1;
571 eo_do(evas_object_evas_get(o),
572 evas_canvas_pointer_canvas_xy_get(&x, &y));
573 fd->x = x;
574 fd->y = y;
575 eo_do(o, efl_gfx_stack_raise());
576}
577
578static void
579video_obj_signal_frame_resize_stop_cb(void *data EINA_UNUSED, Evas_Object *o, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
580{
581 Frame_Data *fd;
582
583 eo_do(o, fd = eo_key_data_get("frame_data"));
584 if (!fd) return;
585 fd->resizing = 0;
586}
587
588static void
589video_obj_signal_frame_move_cb(void *data EINA_UNUSED, Evas_Object *o, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
590{
591 Frame_Data *fd;
592
593 eo_do(o, fd = eo_key_data_get("frame_data"));
594 if (!fd) return;
595 if (fd->moving)
596 {
597 Evas_Coord x, y, ox, oy;
598
599 eo_do(evas_object_evas_get(o),
600 evas_canvas_pointer_canvas_xy_get(&x, &y));
601 eo_do(o,
602 efl_gfx_position_get(&ox, &oy),
603 efl_gfx_position_set(ox + (x - fd->x), oy + (y - fd->y))
604 );
605 fd->x = x;
606 fd->y = y;
607 }
608 else if (fd->resizing)
609 {
610 Evas_Coord x, y, ow, oh;
611
612 eo_do(evas_object_evas_get(o),
613 evas_canvas_pointer_canvas_xy_get(&x, &y));
614 eo_do(o, efl_gfx_size_get(&ow, &oh));
615 evas_object_resize(o, ow + (x - fd->x), oh + (y - fd->y));
616 fd->x = x;
617 fd->y = y;
618 }
619}
620
621static const Eo_Callback_Array_Item emotion_object_test_callbacks[] = {
622 { EMOTION_OBJECT_EVENT_FRAME_DECODE, video_obj_frame_decode_cb },
623 { EMOTION_OBJECT_EVENT_FRAME_RESIZE, video_obj_frame_resize_cb },
624 { EMOTION_OBJECT_EVENT_LENGTH_CHANGE, video_obj_length_change_cb },
625 { EMOTION_OBJECT_EVENT_POSITION_UPDATE, video_obj_position_update_cb },
626 { EMOTION_OBJECT_EVENT_DECODE_STOP, video_obj_stopped_cb },
627 { EMOTION_OBJECT_EVENT_CHANNELS_CHANGE, video_obj_channels_cb },
628 { EMOTION_OBJECT_EVENT_TITLE_CHANGE, video_obj_title_cb },
629 { EMOTION_OBJECT_EVENT_PROGRESS_CHANGE, video_obj_progress_cb },
630 { EMOTION_OBJECT_EVENT_REF_CHANGE, video_obj_ref_cb },
631 { EMOTION_OBJECT_EVENT_BUTTON_NUM_CHANGE, video_obj_button_num_cb },
632 { EMOTION_OBJECT_EVENT_BUTTON_CHANGE, video_obj_button_cb },
633 { NULL, NULL }
634};
635
636static void
637init_video_object(const char *module_filename, const char *filename)
638{
639 Evas_Object *o, *oe;
640 Evas_Coord w, h, offset;
641 Frame_Data *fd;
642
643 /* basic video object setup */
644 o = emotion_object_add(evas);
645 if ((module_filename) && (!emotion_object_init(o, module_filename)))
646 return;
647 emotion_object_vis_set(o, vis);
648 if (!emotion_object_file_set(o, filename))
649 return;
650 if (last_position_load)
651 emotion_object_last_position_load(o);
652 emotion_object_play_set(o, 1);
653 emotion_object_audio_volume_set(o, 0.5);
654 evas_object_move(o, 0, 0);
655 evas_object_resize(o, 320, 240);
656 emotion_object_smooth_scale_set(o, 1);
657 evas_object_show(o);
658
659 video_objs = eina_list_append(video_objs, o);
660 /* end basic video setup. all the rest here is just to be fancy */
661
662
663 fd = calloc(1, sizeof(Frame_Data));
664 if (!fd) exit(1);
665
666 oe = eo_add(EDJE_OBJECT_CLASS, evas);
667 eo_do(oe,
668 eo_event_callback_add(EVAS_OBJECT_EVENT_FREE, _oe_free_cb, fd),
669 eo_key_data_set("frame_data", fd),
670 efl_file_set(theme_file,
671 reflex ? "video_controller/reflex" : "video_controller"),
672 edje_obj_part_swallow("video_swallow", o));
673
674 offset = 20 * (eina_list_count(video_objs) - 1);
675 eo_do(oe,
676 efl_gfx_position_set(offset, offset),
677 edje_obj_size_min_calc(&w, &h),
678 efl_gfx_size_set(w, h));
679
680 eo_do(o, eo_event_callback_array_add(emotion_object_test_callbacks, oe));
681
682 eo_do(oe,
683 edje_obj_signal_callback_add("video_control", "play", video_obj_signal_play_cb, o),
684 edje_obj_signal_callback_add("video_control", "pause", video_obj_signal_pause_cb, o),
685 edje_obj_signal_callback_add("video_control", "stop", video_obj_signal_stop_cb, o),
686 edje_obj_signal_callback_add("drag", "video_progress", video_obj_signal_jump_cb, o),
687 edje_obj_signal_callback_add("drag", "video_alpha", video_obj_signal_alpha_cb, o),
688 edje_obj_signal_callback_add("drag", "video_volume", video_obj_signal_vol_cb, o),
689
690 edje_obj_signal_callback_add("frame_move", "start", video_obj_signal_frame_move_start_cb, oe),
691 edje_obj_signal_callback_add("frame_move", "stop", video_obj_signal_frame_move_stop_cb, oe),
692 edje_obj_signal_callback_add("frame_resize", "start", video_obj_signal_frame_resize_start_cb, oe),
693 edje_obj_signal_callback_add("frame_resize", "stop", video_obj_signal_frame_resize_stop_cb, oe),
694 edje_obj_signal_callback_add("mouse,move", "*", video_obj_signal_frame_move_cb, oe),
695
696 edje_obj_part_drag_value_set("video_alpha", 0.0, 1.0),
697 edje_obj_part_text_set("video_alpha_txt", "alpha 255"),
698 edje_obj_part_drag_value_set("video_volume", 0.0, 0.5),
699 edje_obj_part_text_set("video_volume_txt", "vol 0.50"),
700
701 edje_obj_signal_emit("video_state", "play"),
702
703 efl_gfx_visible_set(EINA_TRUE));
704}
705
706int
707main(int argc, char **argv)
708{
709 int args;
710 Eina_Rectangle geometry = {0, 0, startw, starth};
711 char *engine = NULL;
712 char *backend = NULL;
713 Eina_Bool webcams = EINA_FALSE;
714 int visual = EMOTION_VIS_NONE;
715 unsigned char help = 0;
716 unsigned char engines_listed = 0;
717 Ecore_Getopt_Value values[] = {
718 ECORE_GETOPT_VALUE_STR(engine),
719 ECORE_GETOPT_VALUE_BOOL(engines_listed),
720 ECORE_GETOPT_VALUE_PTR_CAST(geometry),
721 ECORE_GETOPT_VALUE_STR(backend),
722 ECORE_GETOPT_VALUE_INT(visual),
723 ECORE_GETOPT_VALUE_BOOL(webcams),
724 ECORE_GETOPT_VALUE_BOOL(reflex),
725 ECORE_GETOPT_VALUE_BOOL(loop),
726 ECORE_GETOPT_VALUE_BOOL(last_position_load),
727 ECORE_GETOPT_VALUE_NONE,
728 ECORE_GETOPT_VALUE_NONE,
729 ECORE_GETOPT_VALUE_NONE,
730 ECORE_GETOPT_VALUE_BOOL(help),
731 ECORE_GETOPT_VALUE_NONE
732 };
733
734 // init ecore_evas
735 if (!ecore_evas_init())
736 return -1;
737
738 // init edje
739 if (!edje_init())
740 goto shutdown_ecore_evas;
741 edje_frametime_set(1.0 / 30.0);
742
743 // search the theme file
744 struct stat st;
745 if (stat(PACKAGE_BUILD_DIR"/src/tests/emotion/data/theme.edj", &st) == 0)
746 theme_file = PACKAGE_BUILD_DIR"/src/tests/emotion/data/theme.edj";
747 else if (stat(PACKAGE_DATA_DIR"/data/theme.edj", &st) == 0)
748 theme_file = PACKAGE_DATA_DIR"/data/theme.edj";
749 else
750 {
751 printf("Cannot find the theme file\n");
752 goto shutdown_edje;
753 }
754 printf("theme file: %s\n", theme_file);
755
756 // parse command line arguments
757 ecore_app_args_set(argc, (const char **)argv);
758 args = ecore_getopt_parse(&options, values, argc, argv);
759 if (args < 0) goto shutdown_edje;
760 else if (help) goto shutdown_edje;
761 else if (engines_listed) goto shutdown_edje;
762 else if ((args == argc) && (!webcams))
763 {
764 printf("must provide at least one file to play!\n");
765 goto shutdown_edje;
766 }
767 if (geometry.w == 0) geometry.w = 320;
768 if (geometry.h == 0) geometry.h = 240;
769 vis = visual;
770
771 printf("evas engine: %s\n", engine ? engine : "<auto>");
772 printf("emotion backend: %s\n", backend ? backend : "<auto>");
773 printf("vis: %d\n", vis);
774 printf("geometry: %d %d %dx%d\n", geometry.x, geometry.y, geometry.w, geometry.h);
775
776 ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, main_signal_exit, NULL);
777
778 // create the ecore_evas window
779 ecore_evas = ecore_evas_new(engine, geometry.x, geometry.y,
780 geometry.w, geometry.h, NULL);
781 if (!ecore_evas) goto shutdown_edje;
782 ecore_evas_callback_delete_request_set(ecore_evas, main_delete_request);
783 ecore_evas_callback_resize_set(ecore_evas, main_resize);
784 ecore_evas_title_set(ecore_evas, "Evas Media Test Program");
785 ecore_evas_name_class_set(ecore_evas, "evas_media_test", "main");
786 ecore_evas_show(ecore_evas);
787 evas = ecore_evas_get(ecore_evas);
788 evas_image_cache_set(evas, 8 * 1024 * 1024);
789 evas_font_cache_set(evas, 1 * 1024 * 1024);
790
791 // init emotion
792 emotion_init();
793
794 // create the checkboard background edje object
795 bg_setup();
796
797 // open files and webcams
798 for (; args < argc; args++)
799 init_video_object(backend, argv[args]);
800
801 if (webcams)
802 {
803 const Eina_List *wl, *l;
804 Emotion_Webcam *webcam;
805
806 wl = emotion_webcams_get();
807 EINA_LIST_FOREACH(wl, l, webcam)
808 {
809 printf("Playing stream: '%s' url: '%s'\n",
810 emotion_webcam_name_get(webcam),
811 emotion_webcam_device_get(webcam));
812 init_video_object(backend, emotion_webcam_device_get(webcam));
813 }
814 }
815
816 // start the main loop
817 ecore_main_loop_begin();
818
819 // shutdown
820 main_signal_exit(NULL, 0, NULL);
821
822 emotion_shutdown();
823 ecore_evas_free(ecore_evas);
824 ecore_evas_shutdown();
825 edje_shutdown();
826
827 return 0;
828
829 shutdown_edje:
830 edje_shutdown();
831 shutdown_ecore_evas:
832 ecore_evas_shutdown();
833
834 return -1;
835}