summaryrefslogtreecommitdiff
path: root/src/examples/emotion/emotion_signals_example.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-10 03:43:32 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-10 03:43:32 +0000
commitdfb84c1657bfb14a5236b881193b81f4c0b8a69b (patch)
treeb51b210fc88a21eec8e5907b8bbfe12ebc669f90 /src/examples/emotion/emotion_signals_example.c
parent532284dbbe4259a9f2291f44d3eff376849e8031 (diff)
efl: merge emotion.
this one was quite a huge work, but hopefully it's correct. NOTES: * removed vlc generic module, it should go into a separate package. * gstreamer is enabled by default (see --disable-gstreamer) * xine is disabled by default (see --enable-gstreamer) * generic is always built statically if supported * gstreamer and xine can't be configured as static (just lacks command line options, build system supports it) * v4l2 is enabled by default on linux if eeze is built (see --disable-v4l2) * emotion_test moved to src/tests/emotion and depends on EFL_ENABLE_TESTS (--with-tests), but is still installed if enabled. TODO (need your help!): * fix warnings with gstreamer and xine engine * call engine shutdown functions if building as static * remove direct usage of PACKAGE_*_DIR and use eina_prefix * add eina_prefix checkme file as evas and others * add support for $EFL_RUN_IN_TREE * create separate package for emotion_generic_modules * check docs hierarchy (doxygen is segv'in here) SVN revision: 82501
Diffstat (limited to 'src/examples/emotion/emotion_signals_example.c')
-rw-r--r--src/examples/emotion/emotion_signals_example.c173
1 files changed, 173 insertions, 0 deletions
diff --git a/src/examples/emotion/emotion_signals_example.c b/src/examples/emotion/emotion_signals_example.c
new file mode 100644
index 0000000000..2469c468ba
--- /dev/null
+++ b/src/examples/emotion/emotion_signals_example.c
@@ -0,0 +1,173 @@
1#include <Ecore.h>
2#include <Ecore_Evas.h>
3#include <Evas.h>
4#include <Emotion.h>
5#include <stdio.h>
6
7#define WIDTH (320)
8#define HEIGHT (240)
9
10static void
11_display_info(Evas_Object *o)
12{
13 int w, h;
14 printf("playing: %d\n", emotion_object_play_get(o));
15 printf("meta title: %s\n",
16 emotion_object_meta_info_get(o, EMOTION_META_INFO_TRACK_TITLE));
17 printf("seek position: %0.3f\n",
18 emotion_object_position_get(o));
19 printf("play length: %0.3f\n",
20 emotion_object_play_length_get(o));
21 printf("is seekable: %d\n",
22 emotion_object_seekable_get(o));
23 emotion_object_size_get(o, &w, &h);
24 printf("video geometry: %dx%d\n", w, h);
25 printf("video width / height ratio: %0.3f\n",
26 emotion_object_ratio_get(o));
27 printf("\n");
28}
29
30static void
31_playback_started_cb(void *data, Evas_Object *o, void *event_info)
32{
33 printf(">>> Emotion object started playback.\n");
34 _display_info(o);
35}
36
37static void
38_playback_finished_cb(void *data, Evas_Object *o, void *event_info)
39{
40 printf(">>> Emotion object finished playback.\n");
41 _display_info(o);
42}
43
44static void
45_open_done_cb(void *data, Evas_Object *o, void *event_info)
46{
47 printf(">>> Emotion object open done.\n");
48 _display_info(o);
49}
50
51static void
52_position_update_cb(void *data, Evas_Object *o, void *event_info)
53{
54 printf(">>> Emotion object first position update.\n");
55 evas_object_smart_callback_del(o, "position_update", _position_update_cb);
56 _display_info(o);
57}
58
59static void
60_frame_decode_cb(void *data, Evas_Object *o, void *event_info)
61{
62 printf(">>> Emotion object first frame decode.\n");
63 evas_object_smart_callback_del(o, "frame_decode", _frame_decode_cb);
64 _display_info(o);
65}
66
67static void
68_decode_stop_cb(void *data, Evas_Object *o, void *event_info)
69{
70 printf(">>> Emotion object decode stop.\n");
71 _display_info(o);
72}
73
74static void
75_frame_resize_cb(void *data, Evas_Object *o, void *event_info)
76{
77 printf(">>> Emotion object frame resize.\n");
78 _display_info(o);
79}
80
81static void
82_setup_emotion_callbacks(Evas_Object *o)
83{
84 evas_object_smart_callback_add(
85 o, "playback_started", _playback_started_cb, NULL);
86 evas_object_smart_callback_add(
87 o, "playback_finished", _playback_finished_cb, NULL);
88 evas_object_smart_callback_add(
89 o, "open_done", _open_done_cb, NULL);
90 evas_object_smart_callback_add(
91 o, "position_update", _position_update_cb, NULL);
92 evas_object_smart_callback_add(
93 o, "frame_decode", _frame_decode_cb, NULL);
94 evas_object_smart_callback_add(
95 o, "decode_stop", _decode_stop_cb, NULL);
96 evas_object_smart_callback_add(
97 o, "frame_resize", _frame_resize_cb, NULL);
98}
99
100int
101main(int argc, const char *argv[])
102{
103 Ecore_Evas *ee;
104 Evas *e;
105 Evas_Object *bg, *em;
106 const char *filename = NULL;
107 const char *module = NULL;
108
109 if (argc < 2)
110 {
111 printf("At least one argument is necessary. Usage:\n");
112 printf("\t%s <filename> [module_name]\n", argv[0]);
113 goto error;
114 }
115
116 filename = argv[1];
117
118 if (argc >= 3)
119 module = argv[2];
120
121 if (!ecore_evas_init())
122 return EXIT_FAILURE;
123
124 /* this will give you a window with an Evas canvas under the first
125 * engine available */
126 ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
127 if (!ee)
128 goto error;
129
130 ecore_evas_show(ee);
131
132 /* the canvas pointer, de facto */
133 e = ecore_evas_get(ee);
134
135 /* adding a background to this example */
136 bg = evas_object_rectangle_add(e);
137 evas_object_name_set(bg, "our dear rectangle");
138 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
139 evas_object_move(bg, 0, 0); /* at canvas' origin */
140 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
141 evas_object_show(bg);
142
143 /* Creating the emotion object */
144 em = emotion_object_add(e);
145
146 /* Try to load the specified module - NULL for auto-discover */
147 if (!emotion_object_init(em, module))
148 fprintf(stderr, "Emotion: \"%s\" module could not be initialized.\n", module);
149
150 _display_info(em);
151 _setup_emotion_callbacks(em);
152
153 if (!emotion_object_file_set(em, filename))
154 fprintf(stderr, "Emotion: Could not load the file \"%s\"\n", filename);
155
156 evas_object_move(em, 0, 0);
157 evas_object_resize(em, WIDTH, HEIGHT);
158 evas_object_show(em);
159
160 emotion_object_play_set(em, EINA_TRUE);
161
162 ecore_main_loop_begin();
163
164 ecore_evas_free(ee);
165 ecore_evas_shutdown();
166 return 0;
167
168 ecore_evas_free(ee);
169
170error:
171 ecore_evas_shutdown();
172 return -1;
173}