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