summaryrefslogtreecommitdiff
path: root/legacy/emotion/src
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-10 06:08:41 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-10 06:08:41 +0000
commit09e6baa5a422e988dbcd7af1466d91e5b825f47b (patch)
treefd4b0e9bbaa7076019e93edb904add6b60fedd45 /legacy/emotion/src
parentff2a1607cf8b5759b8eeca03069f1bae0e9186cb (diff)
emotion moved into efl
SVN revision: 82513
Diffstat (limited to 'legacy/emotion/src')
-rw-r--r--legacy/emotion/src/Makefile.am12
-rw-r--r--legacy/emotion/src/bin/Makefile.am26
-rw-r--r--legacy/emotion/src/edje_external/Makefile.am18
-rw-r--r--legacy/emotion/src/examples/Makefile.am41
-rw-r--r--legacy/emotion/src/generic_players/Makefile.am8
-rw-r--r--legacy/emotion/src/generic_players/vlc/Makefile.am18
-rw-r--r--legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c916
-rw-r--r--legacy/emotion/src/lib/Makefile.am59
-rw-r--r--legacy/emotion/src/modules/Makefile.am4
-rw-r--r--legacy/emotion/src/modules/generic/Makefile.am31
-rw-r--r--legacy/emotion/src/modules/gstreamer/Makefile.am37
-rw-r--r--legacy/emotion/src/modules/xine/Makefile.am31
12 files changed, 0 insertions, 1201 deletions
diff --git a/legacy/emotion/src/Makefile.am b/legacy/emotion/src/Makefile.am
deleted file mode 100644
index 4082c3a67d..0000000000
--- a/legacy/emotion/src/Makefile.am
+++ /dev/null
@@ -1,12 +0,0 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4SUBDIRS = lib bin modules examples
5
6if ENABLE_EDJE_EXTERNAL
7SUBDIRS += edje_external
8endif
9
10if EMOTION_BUILD_GENERIC
11SUBDIRS += generic_players
12endif
diff --git a/legacy/emotion/src/bin/Makefile.am b/legacy/emotion/src/bin/Makefile.am
deleted file mode 100644
index 79dd4e3527..0000000000
--- a/legacy/emotion/src/bin/Makefile.am
+++ /dev/null
@@ -1,26 +0,0 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4AM_CPPFLAGS = \
5-I$(top_srcdir) \
6-I$(top_srcdir)/src/lib \
7-DPACKAGE_BIN_DIR=\"$(bindir)\" \
8-DPACKAGE_LIB_DIR=\"$(libdir)\" \
9-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
10@EMOTION_CFLAGS@ \
11@EMOTION_CPPFLAGS@ \
12@EMOTION_BIN_CFLAGS@ \
13@ECORE_X_CFLAGS@ \
14@ECORE_FB_CFLAGS@
15
16bin_PROGRAMS =
17
18if BUILD_EMOTION_TEST
19
20bin_PROGRAMS += emotion_test
21
22endif
23
24emotion_test_SOURCES = emotion_test_main.c
25
26emotion_test_LDADD = @ECORE_X_CFLAGS@ @ECORE_FB_CFLAGS@ @EMOTION_BIN_LIBS@ $(top_builddir)/src/lib/libemotion.la
diff --git a/legacy/emotion/src/edje_external/Makefile.am b/legacy/emotion/src/edje_external/Makefile.am
deleted file mode 100644
index 9b36fafd4f..0000000000
--- a/legacy/emotion/src/edje_external/Makefile.am
+++ /dev/null
@@ -1,18 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_srcdir) \
5-I$(top_srcdir)/src/lib \
6-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
7@EMOTION_CPPFLAGS@ \
8@EMOTION_CFLAGS@ \
9@EDJE_EXTERNAL_CFLAGS@ \
10@EFL_EMOTION_BUILD@
11
12pkgdir = $(libdir)/edje/modules/emotion/$(MODULE_EDJE)
13pkg_LTLIBRARIES = module.la
14
15module_la_SOURCES = emotion.c
16module_la_LIBADD = @EMOTION_LIBS@ $(top_builddir)/src/lib/libemotion.la @EDJE_EXTERNAL_LIBS@
17module_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
18module_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/legacy/emotion/src/examples/Makefile.am b/legacy/emotion/src/examples/Makefile.am
deleted file mode 100644
index 5e39adcf7a..0000000000
--- a/legacy/emotion/src/examples/Makefile.am
+++ /dev/null
@@ -1,41 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3examplesdir = $(datadir)/$(PACKAGE)/examples
4
5AM_CPPFLAGS = \
6-I. \
7-I$(top_srcdir) \
8-I$(top_srcdir)/src/lib \
9@EMOTION_CFLAGS@ \
10@EMOTION_CPPFLAGS@ \
11@EMOTION_BIN_CFLAGS@
12
13LDADD = \
14 $(top_builddir)/src/lib/libemotion.la \
15 @EMOTION_BIN_LIBS@
16
17SRCS = \
18 emotion_basic_example.c \
19 emotion_generic_example.c \
20 emotion_generic_subtitle_example.c \
21 emotion_border_example.c \
22 emotion_signals_example.c
23
24EXTRA_DIST = $(SRCS)
25
26examples_PROGRAMS =
27
28if EFL_INSTALL_EXAMPLES
29filesdir = $(datadir)/$(PACKAGE)/examples
30files_DATA = $(SRCS)
31endif
32
33if EFL_BUILD_EXAMPLES
34examples_PROGRAMS += \
35 emotion_basic_example \
36 emotion_generic_example \
37 emotion_generic_subtitle_example \
38 emotion_border_example \
39 emotion_signals_example
40endif
41
diff --git a/legacy/emotion/src/generic_players/Makefile.am b/legacy/emotion/src/generic_players/Makefile.am
deleted file mode 100644
index bbdd8c34b6..0000000000
--- a/legacy/emotion/src/generic_players/Makefile.am
+++ /dev/null
@@ -1,8 +0,0 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4SUBDIRS =
5
6if EMOTION_BUILD_GENERIC_VLC
7SUBDIRS += vlc
8endif
diff --git a/legacy/emotion/src/generic_players/vlc/Makefile.am b/legacy/emotion/src/generic_players/vlc/Makefile.am
deleted file mode 100644
index 5cda1b95b4..0000000000
--- a/legacy/emotion/src/generic_players/vlc/Makefile.am
+++ /dev/null
@@ -1,18 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_srcdir) \
5-I$(top_srcdir)/src/lib \
6-I$(top_srcdir)/src/modules \
7-I$(top_srcdir)/src/modules/generic \
8-DPACKAGE_BIN_DIR=\"$(bindir)\" \
9-DPACKAGE_LIB_DIR=\"$(libdir)\" \
10-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
11@GENERIC_VLC_CFLAGS@
12
13internal_bindir = $(libdir)/emotion/utils
14internal_bin_PROGRAMS = em_generic_vlc
15
16em_generic_vlc_SOURCES = emotion_generic_vlc.c
17em_generic_vlc_DEPENDENCIES = $(top_srcdir)/src/modules/generic/Emotion_Generic_Plugin.h
18em_generic_vlc_LDADD = @GENERIC_VLC_LIBS@ @EFL_SHM_OPEN_LIBS@ -lpthread
diff --git a/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c b/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
deleted file mode 100644
index a20717303c..0000000000
--- a/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
+++ /dev/null
@@ -1,916 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <errno.h>
6#include <limits.h>
7#include <stdio.h>
8#include <stdlib.h>
9#include <unistd.h>
10#include <string.h>
11#include <sys/mman.h>
12#include <sys/stat.h>
13#include <fcntl.h>
14#include <pthread.h>
15#include <poll.h>
16
17#include <sys/prctl.h>
18#include <signal.h>
19
20#include <vlc/vlc.h>
21
22#include <Emotion_Generic_Plugin.h>
23#include <Eina.h>
24
25static int _em_vlc_log_dom = -1;
26#define ERR(...) EINA_LOG_DOM_ERR(_em_vlc_log_dom, __VA_ARGS__)
27#define DBG(...) EINA_LOG_DOM_DBG(_em_vlc_log_dom, __VA_ARGS__)
28#define INF(...) EINA_LOG_DOM_INFO(_em_vlc_log_dom, __VA_ARGS__)
29#define WRN(...) EINA_LOG_DOM_WARN(_em_vlc_log_dom, __VA_ARGS__)
30#define CRIT(...) EINA_LOG_DOM_CRIT(_em_vlc_log_dom, __VA_ARGS__)
31
32enum _Thread_Events {
33 EM_THREAD_POSITION_CHANGED,
34 EM_THREAD_PLAYBACK_STARTED,
35 EM_THREAD_PLAYBACK_STOPPED,
36 EM_THREAD_LAST
37};
38
39struct _App {
40 Emotion_Generic_Video_Shared *vs;
41 Emotion_Generic_Video_Frame vf;
42 libvlc_instance_t *libvlc;
43 libvlc_media_t *m;
44 libvlc_media_player_t *mp;
45 libvlc_event_manager_t *event_mgr;
46 libvlc_event_manager_t *mevent_mgr;
47 char *filename;
48 char *subtitle_path;
49 char *shmname;
50 void *tmpbuffer;
51 int w, h;
52 int fd_read; // read commands from theads here
53 int fd_write; // write commands from threads here
54 int em_read; // read commands from emotion here
55 int em_write; // write commands to emotion here
56 int size_sent;
57 int opening;
58 int closing;
59 int playing;
60};
61
62static pthread_mutex_t _mutex_fd = PTHREAD_MUTEX_INITIALIZER;
63
64int
65_em_read_safe(int fd, void *buf, ssize_t size)
66{
67 ssize_t todo;
68 char *p;
69
70 todo = size;
71 p = buf;
72
73 while (todo > 0)
74 {
75 ssize_t r;
76
77 r = read(fd, p, todo);
78 if (r > 0)
79 {
80 todo -= r;
81 p += r;
82 }
83 else if (r == 0)
84 return 0;
85 else
86 {
87 if (errno == EINTR || errno == EAGAIN)
88 continue;
89 else
90 {
91 ERR("could not read from fd %d: %s", fd, strerror(errno));
92 return 0;
93 }
94 }
95 }
96
97 return 1;
98}
99
100int
101_em_write_safe(int fd, const void *buf, ssize_t size)
102{
103 ssize_t todo;
104 const char *p;
105
106 todo = size;
107 p = buf;
108
109 while (todo > 0)
110 {
111 ssize_t r;
112
113 r = write(fd, p, todo);
114 if (r > 0)
115 {
116 todo -= r;
117 p += r;
118 }
119 else if (r == 0)
120 return 0;
121 else
122 {
123 if (errno == EINTR || errno == EAGAIN)
124 continue;
125 else
126 {
127 ERR("could not write to fd %d: %s", fd, strerror(errno));
128 return 0;
129 }
130 }
131 }
132
133 return 1;
134}
135
136static int
137_em_str_read(int fd, char **str)
138{
139 int size;
140 int r;
141 char buf[PATH_MAX];
142
143 r = _em_read_safe(fd, &size, sizeof(size));
144 if (!r)
145 {
146 *str = NULL;
147 return 0;
148 }
149
150 if (!size)
151 {
152 *str = NULL;
153 return 1;
154 }
155
156 r = _em_read_safe(fd, buf, size);
157 if (!r)
158 {
159 *str = NULL;
160 return 0;
161 }
162
163 *str = strdup(buf);
164 return 1;
165}
166
167static int
168_em_cmd_read(struct _App *app)
169{
170 int cmd;
171 _em_read_safe(app->em_read, &cmd, sizeof(cmd));
172
173 return cmd;
174}
175
176static void
177_send_cmd_start(struct _App *app, int cmd)
178{
179 pthread_mutex_lock(&_mutex_fd);
180 _em_write_safe(app->em_write, &cmd, sizeof(cmd));
181}
182
183static void
184_send_cmd_finish(struct _App *app __UNUSED__)
185{
186 pthread_mutex_unlock(&_mutex_fd);
187}
188
189static void
190_send_cmd(struct _App *app, int cmd)
191{
192 _send_cmd_start(app, cmd);
193 _send_cmd_finish(app);
194}
195
196static void
197_send_cmd_str(struct _App *app, const char *str)
198{
199 int len;
200 if (str)
201 len = strlen(str) + 1;
202 else
203 len = 0;
204 _em_write_safe(app->em_write, &len, sizeof(len));
205 _em_write_safe(app->em_write, str, len);
206}
207
208#define SEND_CMD_PARAM(app, i) \
209 _em_write_safe((app)->em_write, &(i), sizeof((i)));
210
211static void
212_send_resize(struct _App *app, int width, int height)
213{
214 _send_cmd_start(app, EM_RESULT_FRAME_SIZE);
215 SEND_CMD_PARAM(app, width);
216 SEND_CMD_PARAM(app, height);
217 _send_cmd_finish(app);
218}
219
220static void
221_send_length_changed(struct _App *app, const struct libvlc_event_t *ev)
222{
223 float length = ev->u.media_player_length_changed.new_length;
224 length /= 1000;
225
226 _send_cmd_start(app, EM_RESULT_LENGTH_CHANGED);
227 SEND_CMD_PARAM(app, length);
228 _send_cmd_finish(app);
229}
230
231static void
232_send_time_changed(struct _App *app, const struct libvlc_event_t *ev)
233{
234 float new_time = ev->u.media_player_time_changed.new_time;
235 new_time /= 1000;
236 if (app->vs->frame_drop > 1)
237 return;
238 _send_cmd_start(app, EM_RESULT_POSITION_CHANGED);
239 SEND_CMD_PARAM(app, new_time);
240 _send_cmd_finish(app);
241}
242
243static void
244_send_seekable_changed(struct _App *app, const struct libvlc_event_t *ev)
245{
246 int seekable = ev->u.media_player_seekable_changed.new_seekable;
247 _send_cmd_start(app, EM_RESULT_SEEKABLE_CHANGED);
248 SEND_CMD_PARAM(app, seekable);
249 _send_cmd_finish(app);
250}
251
252static void *
253_lock(void *data, void **pixels)
254{
255 struct _App *app = data;
256
257 if (app->playing)
258 *pixels = app->vf.frames[app->vs->frame.player];
259 else
260 *pixels = NULL;
261
262 return NULL; // picture identifier, not needed here
263}
264
265static void
266_unlock(void *data __UNUSED__, void *id __UNUSED__, void *const *pixels __UNUSED__)
267{
268}
269
270static void
271_display(void *data, void *id __UNUSED__)
272{
273 struct _App *app = data;
274 if (!app->playing)
275 return;
276
277 sem_wait(&app->vs->lock);
278 app->vs->frame.last = app->vs->frame.player;
279 app->vs->frame.player = app->vs->frame.next;
280 app->vs->frame.next = app->vs->frame.last;
281 if (!app->vs->frame_drop++)
282 _send_cmd(app, EM_RESULT_FRAME_NEW);
283 sem_post(&app->vs->lock);
284}
285
286static void *
287_tmp_lock(void *data, void **pixels)
288{
289 struct _App *app = data;
290 *pixels = app->tmpbuffer;
291 return NULL;
292}
293
294static void
295_tmp_unlock(void *data __UNUSED__, void *id __UNUSED__, void *const *pixels __UNUSED__)
296{
297}
298
299static void
300_tmp_display(void *data __UNUSED__, void *id __UNUSED__)
301{
302}
303
304static void
305_play(struct _App *app)
306{
307 float pos;
308
309 if (!app->mp)
310 return;
311
312 _em_read_safe(app->em_read, &pos, sizeof(pos));
313
314 if (app->playing)
315 {
316 libvlc_media_player_set_pause(app->mp, 0);
317 }
318 else
319 {
320 libvlc_time_t new_time = pos * 1000;
321 libvlc_media_player_set_time(app->mp, new_time);
322 libvlc_media_player_play(app->mp);
323
324 if (app->subtitle_path)
325 libvlc_video_set_subtitle_file(app->mp, app->subtitle_path);
326
327 app->playing = 1;
328 }
329}
330
331static void
332_stop(struct _App *app)
333{
334 if (app->mp)
335 libvlc_media_player_set_pause(app->mp, 1);
336}
337
338static void
339_send_file_closed(struct _App *app)
340{
341 app->closing = 0;
342 emotion_generic_shm_free(app->vs);
343 _send_cmd(app, EM_RESULT_FILE_CLOSE);
344}
345
346static void
347_send_file_set(struct _App *app)
348{
349 if (app->opening)
350 _send_cmd(app, EM_RESULT_FILE_SET);
351
352 if (app->closing)
353 _send_file_closed(app);
354}
355
356static void
357_event_cb(const struct libvlc_event_t *ev, void *data)
358{
359 struct _App *app = data;
360 int thread_event;
361
362 switch (ev->type) {
363 case libvlc_MediaPlayerTimeChanged:
364 _send_time_changed(app, ev);
365 break;
366 case libvlc_MediaPlayerPositionChanged:
367 thread_event = EM_THREAD_POSITION_CHANGED;
368 write(app->fd_write, &thread_event, sizeof(thread_event));
369 break;
370 case libvlc_MediaPlayerLengthChanged:
371 _send_length_changed(app, ev);
372 break;
373 case libvlc_MediaPlayerSeekableChanged:
374 _send_seekable_changed(app, ev);
375 break;
376 case libvlc_MediaPlayerPlaying:
377 _send_resize(app, app->w, app->h);
378 thread_event = EM_THREAD_PLAYBACK_STARTED;
379 write(app->fd_write, &thread_event, sizeof(thread_event));
380 break;
381 case libvlc_MediaPlayerStopped:
382 _send_file_set(app);
383 break;
384 case libvlc_MediaPlayerEndReached:
385 thread_event = EM_THREAD_PLAYBACK_STOPPED;
386 write(app->fd_write, &thread_event, sizeof(thread_event));
387 break;
388 }
389}
390
391static void
392_subtitle_set(struct _App *app)
393{
394 _em_str_read(app->em_read, &app->subtitle_path);
395}
396
397static void
398_file_set(struct _App *app)
399{
400 if (app->opening)
401 {
402 libvlc_media_release(app->m);
403 libvlc_media_player_release(app->mp);
404 free(app->filename);
405 }
406
407 _em_str_read(app->em_read, &app->filename);
408
409 app->m = libvlc_media_new_path(app->libvlc, app->filename);
410 if (!app->m)
411 {
412 ERR("could not open path: \"%s\"", app->filename);
413 return;
414 }
415
416 app->mp = libvlc_media_player_new_from_media(app->m);
417 if (!app->mp)
418 {
419 ERR("could not create new player from media.");
420 return;
421 }
422
423 app->opening = 1;
424 libvlc_video_set_format(app->mp, "RV32", DEFAULTWIDTH, DEFAULTHEIGHT, DEFAULTWIDTH * 4);
425 libvlc_video_set_callbacks(app->mp, _tmp_lock, _tmp_unlock, _tmp_display, app);
426 app->event_mgr = libvlc_media_player_event_manager(app->mp);
427 libvlc_event_attach(app->event_mgr, libvlc_MediaPlayerPositionChanged,
428 _event_cb, app);
429 libvlc_event_attach(app->event_mgr, libvlc_MediaPlayerStopped,
430 _event_cb, app);
431
432 app->mevent_mgr = libvlc_media_event_manager(app->m);
433
434 app->tmpbuffer = malloc(sizeof(char) * DEFAULTWIDTH * DEFAULTHEIGHT * 4);
435 libvlc_audio_set_mute(app->mp, 1);
436 libvlc_media_player_play(app->mp);
437}
438
439static void
440_position_set(struct _App *app)
441{
442 if (!app->mp)
443 return;
444
445 float position;
446 _em_read_safe(app->em_read, &position, sizeof(position));
447
448 libvlc_time_t new_time = position * 1000;
449 libvlc_media_player_set_time(app->mp, new_time);
450}
451
452static void
453_speed_set(struct _App *app)
454{
455 float rate;
456
457 if (!app->mp)
458 return;
459
460 _em_read_safe(app->em_read, &rate, sizeof(rate));
461
462 libvlc_media_player_set_rate(app->mp, rate);
463}
464
465static void
466_mute_set(struct _App *app)
467{
468 int mute;
469
470 if (!app->mp)
471 return;
472
473 _em_read_safe(app->em_read, &mute, sizeof(mute));
474
475 libvlc_audio_set_mute(app->mp, mute);
476}
477
478static void
479_volume_set(struct _App *app)
480{
481 float volume;
482 int vol;
483
484 if (!app->mp)
485 return;
486
487 _em_read_safe(app->em_read, &volume, sizeof(volume));
488 vol = volume * 100;
489
490 libvlc_audio_set_volume(app->mp, vol);
491}
492
493static void
494_spu_track_set(struct _App *app)
495{
496 int track;
497
498 _em_read_safe(app->em_read, &track, sizeof(track));
499
500 libvlc_video_set_spu(app->mp, track);
501}
502
503static void
504_audio_track_set(struct _App *app)
505{
506 int track;
507
508 _em_read_safe(app->em_read, &track, sizeof(track));
509
510 libvlc_audio_set_track(app->mp, track);
511}
512
513static void
514_video_track_set(struct _App *app)
515{
516 int track;
517
518 _em_read_safe(app->em_read, &track, sizeof(track));
519
520 libvlc_video_set_track(app->mp, track);
521}
522
523static void
524_file_set_done(struct _App *app)
525{
526 int r;
527
528 app->opening = 0;
529
530 r = emotion_generic_shm_get(app->shmname, &app->vs, &app->vf);
531 if (!r)
532 {
533 free(app->filename);
534 libvlc_media_release(app->m);
535 libvlc_media_player_release(app->mp);
536 app->filename = NULL;
537 app->m = NULL;
538 app->mp = NULL;
539 _send_cmd_start(app, EM_RESULT_FILE_SET_DONE);
540 SEND_CMD_PARAM(app, r);
541 _send_cmd_finish(app);
542 }
543 app->w = app->vs->width;
544 app->h = app->vs->height;
545 libvlc_video_set_format(app->mp, "RV32", app->w, app->h, app->w * 4);
546 libvlc_video_set_callbacks(app->mp, _lock, _unlock, _display, app);
547
548
549 libvlc_event_attach(app->event_mgr, libvlc_MediaPlayerPlaying,
550 _event_cb, app);
551 libvlc_event_attach(app->event_mgr, libvlc_MediaPlayerTimeChanged,
552 _event_cb, app);
553 libvlc_event_attach(app->event_mgr, libvlc_MediaPlayerLengthChanged,
554 _event_cb, app);
555 libvlc_event_attach(app->event_mgr, libvlc_MediaPlayerSeekableChanged,
556 _event_cb, app);
557 libvlc_event_attach(app->event_mgr, libvlc_MediaPlayerEndReached,
558 _event_cb, app);
559
560 libvlc_audio_set_mute(app->mp, 0);
561
562 _send_cmd_start(app, EM_RESULT_FILE_SET_DONE);
563 SEND_CMD_PARAM(app, r);
564 _send_cmd_finish(app);
565}
566
567static void
568_file_close(struct _App *app)
569{
570 app->playing = 0;
571 if (app->opening)
572 goto release_resources;
573
574 if (libvlc_media_player_get_state(app->mp) != libvlc_Playing)
575 {
576 _send_file_closed(app);
577 return;
578 }
579
580 app->closing = 1;
581
582release_resources:
583 libvlc_media_player_stop(app->mp);
584 if (app->filename)
585 free(app->filename);
586 if (app->mp)
587 {
588 libvlc_media_release(app->m);
589 libvlc_media_player_release(app->mp);
590 free(app->tmpbuffer);
591 }
592}
593
594static void
595_process_emotion_commands(struct _App *app)
596{
597 int cmd = _em_cmd_read(app);
598 switch (cmd) {
599 case EM_CMD_FILE_SET:
600 _file_set(app);
601 break;
602 case EM_CMD_FILE_SET_DONE:
603 _file_set_done(app);
604 break;
605 case EM_CMD_SUBTITLE_SET:
606 _subtitle_set(app);
607 break;
608 case EM_CMD_FILE_CLOSE:
609 _file_close(app);
610 break;
611 case EM_CMD_PLAY:
612 _play(app);
613 break;
614 case EM_CMD_STOP:
615 _stop(app);
616 break;
617 case EM_CMD_POSITION_SET:
618 _position_set(app);
619 break;
620 case EM_CMD_SPEED_SET:
621 _speed_set(app);
622 break;
623 case EM_CMD_AUDIO_MUTE_SET:
624 _mute_set(app);
625 break;
626 case EM_CMD_VOLUME_SET:
627 _volume_set(app);
628 break;
629 case EM_CMD_SPU_TRACK_SET:
630 _spu_track_set(app);
631 break;
632 case EM_CMD_AUDIO_TRACK_SET:
633 _audio_track_set(app);
634 break;
635 case EM_CMD_VIDEO_TRACK_SET:
636 _video_track_set(app);
637 break;
638 };
639}
640
641static void
642_send_track_info(struct _App *app, int cmd, int current, int count, libvlc_track_description_t *desc)
643{
644 _send_cmd_start(app, cmd);
645 SEND_CMD_PARAM(app, current);
646 SEND_CMD_PARAM(app, count);
647 while (desc)
648 {
649 int tid = desc->i_id;
650 const char *name = desc->psz_name;
651 SEND_CMD_PARAM(app, tid);
652 _send_cmd_str(app, name);
653 desc = desc->p_next;
654 }
655 _send_cmd_finish(app);
656}
657
658static void
659_send_all_track_info(struct _App *app)
660{
661 int track_count, current;
662 libvlc_track_description_t *desc;
663
664 current = libvlc_audio_get_track(app->mp);
665 track_count = libvlc_audio_get_track_count(app->mp);
666 desc = libvlc_audio_get_track_description(app->mp);
667
668 _send_track_info(app, EM_RESULT_AUDIO_TRACK_INFO,
669 current, track_count, desc);
670
671 current = libvlc_video_get_track(app->mp);
672 track_count = libvlc_video_get_track_count(app->mp);
673 desc = libvlc_video_get_track_description(app->mp);
674
675 _send_track_info(app, EM_RESULT_VIDEO_TRACK_INFO,
676 current, track_count, desc);
677
678 current = libvlc_video_get_spu(app->mp);
679 track_count = libvlc_video_get_spu_count(app->mp);
680 desc = libvlc_video_get_spu_description(app->mp);
681
682 _send_track_info(app, EM_RESULT_SPU_TRACK_INFO,
683 current, track_count, desc);
684}
685
686static void
687_send_all_meta_info(struct _App *app)
688{
689 const char *meta;
690
691 _send_cmd_start(app, EM_RESULT_META_INFO);
692
693 /*
694 * Will send in this order: title, artist, album, year,
695 * genre, comments, disc id and track count.
696 */
697 meta = libvlc_media_get_meta(app->m, libvlc_meta_Title);
698 _send_cmd_str(app, meta);
699 meta = libvlc_media_get_meta(app->m, libvlc_meta_Artist);
700 _send_cmd_str(app, meta);
701 meta = libvlc_media_get_meta(app->m, libvlc_meta_Album);
702 _send_cmd_str(app, meta);
703 meta = libvlc_media_get_meta(app->m, libvlc_meta_Date);
704 _send_cmd_str(app, meta);
705 meta = libvlc_media_get_meta(app->m, libvlc_meta_Genre);
706 _send_cmd_str(app, meta);
707 meta = NULL; // sending empty comments
708 _send_cmd_str(app, meta);
709 meta = NULL; // sending empty disc id
710 _send_cmd_str(app, meta);
711 meta = libvlc_media_get_meta(app->m, libvlc_meta_TrackNumber);
712 _send_cmd_str(app, meta);
713 _send_cmd_finish(app);
714}
715
716static void
717_position_changed(struct _App *app)
718{
719 if (!app->opening)
720 return;
721
722 /* sending size info only once */
723 int r;
724 unsigned int w, h;
725 r = libvlc_video_get_size(app->mp, 0, &w, &h);
726 if (r < 0)
727 {
728 w = 1;
729 h = 1;
730 }
731
732 if (w > 0 || h > 0)
733 {
734 _send_resize(app, w, h);
735 app->size_sent = 1;
736 }
737
738 /* sending audio track info */
739 _send_all_track_info(app);
740
741 /* sending meta info */
742 _send_all_meta_info(app);
743
744 if (app->size_sent)
745 libvlc_media_player_stop(app->mp);
746}
747
748static void
749_process_thread_events(struct _App *app)
750{
751 int event;
752 size_t size;
753
754 size = read(app->fd_read, &event, sizeof(event));
755 if (size != sizeof(event))
756 {
757 ERR("player: problem when reading thread event. size = %zd", size);
758 return;
759 }
760
761 switch (event) {
762 case EM_THREAD_POSITION_CHANGED:
763 _position_changed(app);
764 break;
765 case EM_THREAD_PLAYBACK_STARTED:
766 _send_cmd(app, EM_RESULT_PLAYBACK_STARTED);
767 break;
768 case EM_THREAD_PLAYBACK_STOPPED:
769 app->playing = 0;
770 _send_cmd(app, EM_RESULT_PLAYBACK_STOPPED);
771 break;
772 }
773}
774
775int
776main(int argc, const char *argv[])
777{
778 struct _App app;
779 struct pollfd fds[3];
780 int tpipe[2]; // pipe for comunicating events from threads
781 char cwidth[64], cheight[64], cpitch[64], chroma[64];
782 char buf[64];
783
784 if (!eina_init())
785 {
786 EINA_LOG_CRIT("Can't initialize generic vlc player, eina failed.");
787 return -1;
788 }
789
790 _em_vlc_log_dom = eina_log_domain_register("emotion_generic_vlc",
791 EINA_COLOR_CYAN);
792 if (_em_vlc_log_dom < 0)
793 {
794 EINA_LOG_CRIT("Unable to register emotion_generic_vlc log domain.");
795 goto error;
796 }
797
798 if (!eina_log_domain_level_check(_em_vlc_log_dom, EINA_LOG_LEVEL_WARN))
799 eina_log_domain_level_set("emotion_generic_vlc", EINA_LOG_LEVEL_WARN);
800
801 const char *vlc_argv[] =
802 {
803 "--quiet",
804 "--vout",
805 "vmem",
806 "--vmem-width",
807 cwidth,
808 "--vmem-height",
809 cheight,
810 "--vmem-pitch",
811 cpitch,
812 "--vmem-chroma",
813 chroma
814 };
815
816 if (argc < 3)
817 {
818 ERR("missing parameters.");
819 ERR("syntax:\n\t%s <fd read> <fd write>", argv[0]);
820 goto error;
821 }
822
823 app.em_read = atoi(argv[1]);
824 app.em_write = atoi(argv[2]);
825
826 int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);
827 snprintf(cwidth, sizeof(cwidth), "%d", DEFAULTWIDTH);
828 snprintf(cheight, sizeof(cheight), "%d", DEFAULTHEIGHT);
829 snprintf(cpitch, sizeof(cpitch), "%d", DEFAULTWIDTH * 4);
830 snprintf(chroma, sizeof(chroma), "RV32");
831
832 /*
833 * Naughty xattr in emotion uses ecore_thread to run its thing, this
834 * may leave emotion's reference count high and it won't kill us...
835 * letting us play the video in the background. not good.
836 *
837 * prctl(PR_SET_PDEATHSIG) is a linux only thing. Need to find ways
838 * to do it on other platforms. Until then leave it breaking on
839 * such platforms so people port it instead of ignoring.
840 */
841 prctl(PR_SET_PDEATHSIG, SIGHUP);
842
843 app.libvlc = libvlc_new(vlc_argc, vlc_argv);
844 app.mp = NULL;
845 app.filename = NULL;
846 app.subtitle_path = NULL;
847 app.w = 0;
848 app.h = 0;
849 app.size_sent = 0;
850 app.opening = 0;
851 app.playing = 0;
852 app.closing = 0;
853
854 if (_em_cmd_read(&app) != EM_CMD_INIT)
855 {
856 ERR("wrong init command!");
857 goto error;
858 }
859
860 int size;
861 _em_read_safe(app.em_read, &size, sizeof(size));
862 _em_read_safe(app.em_read, buf, size);
863 app.shmname = strdup(buf);
864
865 _send_cmd(&app, EM_RESULT_INIT);
866
867 pipe(tpipe);
868 app.fd_read = tpipe[0];
869 app.fd_write = tpipe[1];
870 fds[0].fd = app.em_read;
871 fds[0].events = POLLIN;
872 fds[1].fd = app.fd_read;
873 fds[1].events = POLLIN;
874 fds[2].fd = STDERR_FILENO;
875 fds[2].events = 0;
876
877 while (1)
878 {
879 int r;
880
881 r = poll(fds, 3, -1);
882 if (r == 0)
883 continue;
884 else if (r < 0)
885 {
886 ERR("an error ocurred on poll(): %s", strerror(errno));
887 break;
888 }
889
890 if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL))
891 {
892 ERR("error communicating with stdin", stderr);
893 break;
894 }
895 if (fds[1].revents & (POLLERR | POLLHUP | POLLNVAL))
896 {
897 ERR("error communicating with thread", stderr);
898 break;
899 }
900
901 if (fds[0].revents & POLLIN)
902 _process_emotion_commands(&app);
903 if (fds[1].revents & POLLIN)
904 _process_thread_events(&app);
905 if (fds[2].revents & (POLLERR | POLLHUP | POLLNVAL))
906 break;
907 }
908
909 libvlc_release(app.libvlc);
910 return 0;
911
912 error:
913 eina_shutdown();
914 return -1;
915}
916#undef SEND_CMD_PARAM
diff --git a/legacy/emotion/src/lib/Makefile.am b/legacy/emotion/src/lib/Makefile.am
deleted file mode 100644
index a2d2198683..0000000000
--- a/legacy/emotion/src/lib/Makefile.am
+++ /dev/null
@@ -1,59 +0,0 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4AM_CPPFLAGS = \
5-I$(top_srcdir) \
6-I$(top_srcdir)/src/lib \
7-DPACKAGE_BIN_DIR=\"$(bindir)\" \
8-DPACKAGE_LIB_DIR=\"$(libdir)\" \
9-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
10@EMOTION_CPPFLAGS@ \
11@EMOTION_CFLAGS@ \
12@EIO_CFLAGS@ \
13@EFL_EMOTION_BUILD@ \
14@EEZE_CFLAGS@
15
16if EMOTION_STATIC_BUILD_XINE
17AM_CPPFLAGS += @XINE_CFLAGS@
18endif
19
20if EMOTION_STATIC_BUILD_GSTREAMER
21AM_CPPFLAGS += @GSTREAMER_CFLAGS@
22endif
23
24lib_LTLIBRARIES = libemotion.la
25includes_HEADERS = Emotion.h
26includesdir = $(includedir)/emotion-@VMAJ@
27
28libemotion_la_SOURCES = emotion_smart.c emotion_main.c
29
30if EMOTION_STATIC_BUILD_XINE
31libemotion_la_SOURCES += \
32$(top_srcdir)/src/modules/xine/emotion_xine.c \
33$(top_srcdir)/src/modules/xine/emotion_xine_vo_out.c
34endif
35
36if EMOTION_STATIC_BUILD_GSTREAMER
37libemotion_la_SOURCES += \
38$(top_srcdir)/src/modules/gstreamer/emotion_gstreamer.c \
39$(top_srcdir)/src/modules/gstreamer/emotion_sink.c
40endif
41
42if EMOTION_STATIC_BUILD_GENERIC
43libemotion_la_SOURCES += \
44$(top_srcdir)/src/modules/generic/emotion_generic.c
45endif
46
47libemotion_la_LIBADD = @EMOTION_LIBS@ @EIO_LIBS@ @EEZE_LIBS@
48
49if EMOTION_STATIC_BUILD_XINE
50libemotion_la_LIBADD += @XINE_LIBS@
51endif
52
53if EMOTION_STATIC_BUILD_GSTREAMER
54libemotion_la_LIBADD += @GSTREAMER_LIBS@
55endif
56
57libemotion_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@
58
59EXTRA_DIST = emotion_private.h
diff --git a/legacy/emotion/src/modules/Makefile.am b/legacy/emotion/src/modules/Makefile.am
deleted file mode 100644
index faaa146341..0000000000
--- a/legacy/emotion/src/modules/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4SUBDIRS = xine gstreamer generic
diff --git a/legacy/emotion/src/modules/generic/Makefile.am b/legacy/emotion/src/modules/generic/Makefile.am
deleted file mode 100644
index 23be9873db..0000000000
--- a/legacy/emotion/src/modules/generic/Makefile.am
+++ /dev/null
@@ -1,31 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_srcdir) \
5-I$(top_srcdir)/src/lib \
6-I$(top_srcdir)/src/modules \
7-DPACKAGE_BIN_DIR=\"$(bindir)\" \
8-DPACKAGE_LIB_DIR=\"$(libdir)\" \
9-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
10@EMOTION_CFLAGS@ \
11@EMOTION_CPPFLAGS@ \
12@EFL_EMOTION_BUILD@
13
14if EMOTION_BUILD_GENERIC
15if !EMOTION_STATIC_BUILD_GENERIC
16
17pkgdir = $(libdir)/emotion
18
19pkg_LTLIBRARIES = em_generic.la
20includes_HEADERS = Emotion_Generic_Plugin.h
21includesdir = $(includedir)/emotion-@VMAJ@
22noinst_HEADERS = emotion_generic.h
23
24em_generic_la_SOURCES = emotion_generic.c
25em_generic_la_LIBADD = @EMOTION_LIBS@ @EFL_SHM_OPEN_LIBS@ $(top_builddir)/src/lib/libemotion.la
26em_generic_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
27em_generic_la_LIBTOOLFLAGS = --tag=disable-static
28em_generic_la_DEPENDENCIES = emotion_generic.h Emotion_Generic_Plugin.h
29
30endif
31endif
diff --git a/legacy/emotion/src/modules/gstreamer/Makefile.am b/legacy/emotion/src/modules/gstreamer/Makefile.am
deleted file mode 100644
index 367251096f..0000000000
--- a/legacy/emotion/src/modules/gstreamer/Makefile.am
+++ /dev/null
@@ -1,37 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_srcdir) \
5-I$(top_srcdir)/src/lib \
6-DPACKAGE_BIN_DIR=\"$(bindir)\" \
7-DPACKAGE_LIB_DIR=\"$(libdir)\" \
8-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
9@EMOTION_CFLAGS@ \
10@EMOTION_CPPFLAGS@ \
11@EFL_EMOTION_BUILD@ \
12@GSTREAMER_CFLAGS@ \
13@GSTREAMER_INTERFACE_CFLAGS@ \
14@ECORE_X_CFLAGS@
15
16if EMOTION_BUILD_GSTREAMER
17if !EMOTION_STATIC_BUILD_GSTREAMER
18
19pkgdir = $(libdir)/emotion
20
21pkg_LTLIBRARIES = gstreamer.la
22gstreamer_la_SOURCES = \
23emotion_gstreamer.c \
24emotion_sink.c \
25emotion_alloc.c \
26emotion_fakeeos.c \
27emotion_convert.c
28
29gstreamer_la_LIBADD = @EMOTION_LIBS@ @ECORE_X_LIBS@ @GSTREAMER_LIBS@ @GSTREAMER_INTERFACE_LIBS@ $(top_builddir)/src/lib/libemotion.la
30gstreamer_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
31gstreamer_la_LIBTOOLFLAGS = --tag=disable-static
32gstreamer_la_DEPENDENCIES = $(top_builddir)/config.h
33
34endif
35endif
36
37EXTRA_DIST = emotion_gstreamer.h
diff --git a/legacy/emotion/src/modules/xine/Makefile.am b/legacy/emotion/src/modules/xine/Makefile.am
deleted file mode 100644
index baf8fecab5..0000000000
--- a/legacy/emotion/src/modules/xine/Makefile.am
+++ /dev/null
@@ -1,31 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_srcdir) \
5-I$(top_srcdir)/src/lib \
6-I$(top_srcdir)/src/modules \
7-DPACKAGE_BIN_DIR=\"$(bindir)\" \
8-DPACKAGE_LIB_DIR=\"$(libdir)\" \
9-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
10@EMOTION_CFLAGS@ \
11@EMOTION_CPPFLAGS@ \
12@EFL_EMOTION_BUILD@ \
13@XINE_CFLAGS@
14
15if EMOTION_BUILD_XINE
16if !EMOTION_STATIC_BUILD_XINE
17
18pkgdir = $(libdir)/emotion
19
20pkg_LTLIBRARIES = xine.la
21
22xine_la_SOURCES = \
23emotion_xine.c \
24emotion_xine.h \
25emotion_xine_vo_out.c
26xine_la_LIBADD = @EMOTION_LIBS@ @XINE_LIBS@ $(top_builddir)/src/lib/libemotion.la -lpthread
27xine_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
28xine_la_LIBTOOLFLAGS = --tag=disable-static
29
30endif
31endif