From 18f0e57f27e9c0949950febc50a05da143cff6da Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Thu, 10 Jan 2013 03:43:32 +0000 Subject: [PATCH] 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 --- Makefile.am | 2 +- emotion/Makefile.am | 57 +++++ unsorted/emotion/emotion_basic_example.c | 81 ++++++ unsorted/emotion/emotion_border_example.c | 238 ++++++++++++++++++ unsorted/emotion/emotion_generic_example.c | 233 +++++++++++++++++ .../emotion_generic_subtitle_example.c | 97 +++++++ unsorted/emotion/emotion_signals_example.c | 173 +++++++++++++ 7 files changed, 880 insertions(+), 1 deletion(-) create mode 100644 emotion/Makefile.am create mode 100644 unsorted/emotion/emotion_basic_example.c create mode 100644 unsorted/emotion/emotion_border_example.c create mode 100644 unsorted/emotion/emotion_generic_example.c create mode 100644 unsorted/emotion/emotion_generic_subtitle_example.c create mode 100644 unsorted/emotion/emotion_signals_example.c diff --git a/Makefile.am b/Makefile.am index d46cfedf..61062776 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = eina eo eet evas ecore eio edbus ephysics edje +SUBDIRS = eina eo eet evas ecore eio edbus ephysics edje emotion .PHONY: examples install-examples diff --git a/emotion/Makefile.am b/emotion/Makefile.am new file mode 100644 index 00000000..b1bf86e6 --- /dev/null +++ b/emotion/Makefile.am @@ -0,0 +1,57 @@ +MAINTAINERCLEANFILES = Makefile.in + +AM_CPPFLAGS = \ +-I$(top_srcdir)/src/lib/eina \ +-I$(top_srcdir)/src/lib/eo \ +-I$(top_srcdir)/src/lib/evas \ +-I$(top_srcdir)/src/lib/ecore \ +-I$(top_srcdir)/src/lib/ecore_evas \ +-I$(top_srcdir)/src/lib/emotion \ +-I$(top_builddir)/src/lib/eina \ +-I$(top_builddir)/src/lib/eo \ +-I$(top_builddir)/src/lib/evas \ +-I$(top_builddir)/src/lib/ecore \ +-I$(top_builddir)/src/lib/ecore_evas \ +-I$(top_builddir)/src/lib/emotion \ +@EMOTION_CFLAGS@ + +LDADD = \ +$(top_builddir)/src/lib/eina/libeina.la \ +$(top_builddir)/src/lib/eo/libeo.la \ +$(top_builddir)/src/lib/evas/libevas.la \ +$(top_builddir)/src/lib/ecore/libecore.la \ +$(top_builddir)/src/lib/ecore_evas/libecore_evas.la \ +$(top_builddir)/src/lib/emotion/libemotion.la \ +@EMOTION_LDFLAGS@ + +EXTRA_PROGRAMS = \ +emotion_basic_example \ +emotion_generic_example \ +emotion_generic_subtitle_example \ +emotion_border_example \ +emotion_signals_example + +SRCS = \ +emotion_basic_example.c \ +emotion_generic_example.c \ +emotion_generic_subtitle_example.c \ +emotion_border_example.c \ +emotion_signals_example.c + +examples: $(EXTRA_PROGRAMS) + +clean-local: + rm -f $(EXTRA_PROGRAMS) + +install-examples: + mkdir -p $(datadir)/emotion/examples + $(install_sh_DATA) -c $(SRCS) $(datadir)/emotion/examples + +uninstall-local: + for f in $(SRCS); do \ + rm -f $(datadir)/emotion/examples/$$f ; \ + done + +if ALWAYS_BUILD_EXAMPLES +noinst_PROGRAMS = $(EXTRA_PROGRAMS) +endif diff --git a/unsorted/emotion/emotion_basic_example.c b/unsorted/emotion/emotion_basic_example.c new file mode 100644 index 00000000..7e3e4c2e --- /dev/null +++ b/unsorted/emotion/emotion_basic_example.c @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include + +#define WIDTH (320) +#define HEIGHT (240) + +static void +_playback_started_cb(void *data, Evas_Object *o, void *event_info) +{ + printf("Emotion object started playback.\n"); +} + +int +main(int argc, const char *argv[]) +{ + Ecore_Evas *ee; + Evas *e; + Evas_Object *bg, *em; + const char *filename = NULL; + + if (argc < 2) + { + printf("One argument is necessary. Usage:\n"); + printf("\t%s \n", argv[0]); + } + + filename = argv[1]; + + if (!ecore_evas_init()) + return EXIT_FAILURE; + + /* this will give you a window with an Evas canvas under the first + * engine available */ + ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL); + if (!ee) + goto error; + + ecore_evas_show(ee); + + /* the canvas pointer, de facto */ + e = ecore_evas_get(ee); + + /* adding a background to this example */ + bg = evas_object_rectangle_add(e); + evas_object_name_set(bg, "our dear rectangle"); + evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */ + evas_object_move(bg, 0, 0); /* at canvas' origin */ + evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ + evas_object_show(bg); + + /* Creating the emotion object */ + em = emotion_object_add(e); + emotion_object_init(em, NULL); + + evas_object_smart_callback_add( + em, "playback_started", _playback_started_cb, NULL); + + emotion_object_file_set(em, filename); + + evas_object_move(em, 0, 0); + evas_object_resize(em, WIDTH, HEIGHT); + evas_object_show(em); + + emotion_object_play_set(em, EINA_TRUE); + + ecore_main_loop_begin(); + + ecore_evas_free(ee); + ecore_evas_shutdown(); + return 0; + +error: + fprintf(stderr, "you got to have at least one evas engine built and linked" + " up to ecore-evas for this example to run properly.\n"); + + ecore_evas_shutdown(); + return -1; +} diff --git a/unsorted/emotion/emotion_border_example.c b/unsorted/emotion/emotion_border_example.c new file mode 100644 index 00000000..9df53f43 --- /dev/null +++ b/unsorted/emotion/emotion_border_example.c @@ -0,0 +1,238 @@ +#include +#include +#include +#include +#include +#include + +#define WIDTH (320) +#define HEIGHT (240) + +static Eina_List *filenames = NULL; +static Eina_List *curfile = NULL; + +static void +_playback_started_cb(void *data, Evas_Object *o, void *event_info) +{ + printf("Emotion object started playback.\n"); +} + +static Evas_Object * +_create_emotion_object(Evas *e) +{ + Evas_Object *em = emotion_object_add(e); + + emotion_object_init(em, "gstreamer"); + + evas_object_smart_callback_add( + em, "playback_started", _playback_started_cb, NULL); + + return em; +} + +static void +_on_key_down(void *data, Evas *e, Evas_Object *o, void *event_info) +{ + Evas_Event_Key_Down *ev = event_info; + Evas_Object *em = data; + + if (!strcmp(ev->keyname, "Return")) + { + emotion_object_play_set(em, EINA_TRUE); + } + else if (!strcmp(ev->keyname, "space")) + { + emotion_object_play_set(em, EINA_FALSE); + } + else if (!strcmp(ev->keyname, "Escape")) + { + ecore_main_loop_quit(); + } + else if (!strcmp(ev->keyname, "n")) + { + const char *file; + if (!curfile) + curfile = filenames; + else + curfile = eina_list_next(curfile); + file = eina_list_data_get(curfile); + fprintf(stderr, "playing next file: %s\n", file); + emotion_object_file_set(em, file); + } + else if (!strcmp(ev->keyname, "p")) + { + const char *file; + if (!curfile) + curfile = eina_list_last(filenames); + else + curfile = eina_list_prev(curfile); + file = eina_list_data_get(curfile); + fprintf(stderr, "playing next file: %s\n", file); + emotion_object_file_set(em, file); + } + else if (!strcmp(ev->keyname, "b")) + { + emotion_object_border_set(em, 0, 0, 50, 50); + } + else if (!strcmp(ev->keyname, "0")) + { + emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_NONE); + } + else if (!strcmp(ev->keyname, "w")) + { + emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_WIDTH); + } + else if (!strcmp(ev->keyname, "h")) + { + emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_HEIGHT); + } + else if (!strcmp(ev->keyname, "2")) + { + emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_BOTH); + } + else if (!strcmp(ev->keyname, "c")) + { + emotion_object_keep_aspect_set(em, EMOTION_ASPECT_CROP); + } + else + { + fprintf(stderr, "unhandled key: %s\n", ev->keyname); + } +} + +static void +_frame_decode_cb(void *data, Evas_Object *o, void *event_info) +{ + // fprintf(stderr, "smartcb: frame_decode\n"); +} + +static void +_length_change_cb(void *data, Evas_Object *o, void *event_info) +{ + fprintf(stderr, "smartcb: length_change: %0.3f\n", emotion_object_play_length_get(o)); +} + +static void +_position_update_cb(void *data, Evas_Object *o, void *event_info) +{ + fprintf(stderr, "smartcb: position_update: %0.3f\n", emotion_object_position_get(o)); +} + +static void +_progress_change_cb(void *data, Evas_Object *o, void *event_info) +{ + fprintf(stderr, "smartcb: progress_change: %0.3f, %s\n", + emotion_object_progress_status_get(o), + emotion_object_progress_info_get(o)); +} + +static void +_frame_resize_cb(void *data, Evas_Object *o, void *event_info) +{ + int w, h; + emotion_object_size_get(o, &w, &h); + fprintf(stderr, "smartcb: frame_resize: %dx%d\n", w, h); +} + +static void /* adjust canvas' contents on resizes */ +_canvas_resize_cb(Ecore_Evas *ee) +{ + int w, h; + Evas_Object *bg, *em; + + ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); + + bg = ecore_evas_data_get(ee, "bg"); + em = ecore_evas_data_get(ee, "emotion"); + + evas_object_resize(bg, w, h); + evas_object_move(em, 10, 10); + evas_object_resize(em, w - 20, h - 20); +} + +int +main(int argc, const char *argv[]) +{ + Ecore_Evas *ee; + Evas *e; + Evas_Object *bg, *em; + int i; + + if (argc < 2) + { + printf("One argument is necessary. Usage:\n"); + printf("\t%s \n", argv[0]); + } + + eina_init(); + for (i = 1; i < argc; i++) + filenames = eina_list_append(filenames, eina_stringshare_add(argv[i])); + + curfile = filenames; + + if (!ecore_evas_init()) + return EXIT_FAILURE; + + /* this will give you a window with an Evas canvas under the first + * engine available */ + ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL); + if (!ee) + goto error; + + ecore_evas_callback_resize_set(ee, _canvas_resize_cb); + + ecore_evas_show(ee); + + /* the canvas pointer, de facto */ + e = ecore_evas_get(ee); + + /* adding a background to this example */ + bg = evas_object_rectangle_add(e); + evas_object_name_set(bg, "our dear rectangle"); + evas_object_color_set(bg, 255, 0, 0, 255); /* white bg */ + evas_object_move(bg, 0, 0); /* at canvas' origin */ + evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ + evas_object_show(bg); + + ecore_evas_data_set(ee, "bg", bg); + + /* Creating the emotion object */ + em = _create_emotion_object(e); + emotion_object_file_set(em, eina_list_data_get(curfile)); + evas_object_move(em, 10, 10); + evas_object_resize(em, WIDTH, HEIGHT); + evas_object_resize(em, WIDTH - 20, HEIGHT - 20); + emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_BOTH); + emotion_object_bg_color_set(em, 0, 128, 0, 255); + evas_object_show(em); + + ecore_evas_data_set(ee, "emotion", em); + + evas_object_smart_callback_add(em, "frame_decode", _frame_decode_cb, NULL); + evas_object_smart_callback_add(em, "length_change", _length_change_cb, NULL); + evas_object_smart_callback_add(em, "position_update", _position_update_cb, NULL); + evas_object_smart_callback_add(em, "progress_change", _progress_change_cb, NULL); + evas_object_smart_callback_add(em, "frame_resize", _frame_resize_cb, NULL); + + evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_key_down, em); + evas_object_focus_set(bg, EINA_TRUE); + + emotion_object_play_set(em, EINA_TRUE); + + ecore_main_loop_begin(); + + ecore_evas_free(ee); + ecore_evas_shutdown(); + return 0; + +error: + fprintf(stderr, "you got to have at least one evas engine built and linked" + " up to ecore-evas for this example to run properly.\n"); + + EINA_LIST_FREE(filenames, curfile) + eina_stringshare_del(eina_list_data_get(curfile)); + + ecore_evas_shutdown(); + eina_shutdown(); + return -1; +} diff --git a/unsorted/emotion/emotion_generic_example.c b/unsorted/emotion/emotion_generic_example.c new file mode 100644 index 00000000..b8382862 --- /dev/null +++ b/unsorted/emotion/emotion_generic_example.c @@ -0,0 +1,233 @@ +#include +#include +#include +#include +#include +#include +#include + +#define WIDTH (320) +#define HEIGHT (240) + +static Eina_List *filenames = NULL; +static Eina_List *curfile = NULL; + +static void +_playback_started_cb(void *data, Evas_Object *o, void *event_info) +{ + printf("Emotion object started playback.\n"); +} + +static void +_playback_stopped_cb(void *data, Evas_Object *o, void *event_info) +{ + printf("Emotion playback stopped.\n"); + emotion_object_play_set(o, EINA_FALSE); + emotion_object_position_set(o, 0); +} + +static Evas_Object * +_create_emotion_object(Evas *e) +{ + Evas_Object *em = emotion_object_add(e); + + emotion_object_init(em, "generic"); + + evas_object_smart_callback_add( + em, "playback_started", _playback_started_cb, NULL); + evas_object_smart_callback_add( + em, "playback_finished", _playback_stopped_cb, NULL); + + return em; +} + +static void +_on_key_down(void *data, Evas *e, Evas_Object *o, void *event_info) +{ + Evas_Event_Key_Down *ev = event_info; + Evas_Object *em = data; + + if (!strcmp(ev->keyname, "Return")) + { + emotion_object_play_set(em, EINA_TRUE); + } + else if (!strcmp(ev->keyname, "space")) + { + emotion_object_play_set(em, EINA_FALSE); + } + else if (!strcmp(ev->keyname, "Escape")) + { + ecore_main_loop_quit(); + } + else if (!strcmp(ev->keyname, "t")) + { + int w, h; + emotion_object_size_get(em, &w, &h); + fprintf(stderr, "example -> size: %dx%d\n", w, h); + } + else if (!strcmp(ev->keyname, "s")) + { + float len, pos; + len = emotion_object_play_length_get(em); + pos = 0.98 * len; + fprintf(stderr, "skipping to position %0.3f\n", pos); + emotion_object_position_set(em, pos); + } + else if (!strcmp(ev->keyname, "1")) + { + fprintf(stderr, "setting speed to 1.0\n"); + emotion_object_play_speed_set(em, 1.0); + } + else if (!strcmp(ev->keyname, "2")) + { + fprintf(stderr, "setting speed to 2.0\n"); + emotion_object_play_speed_set(em, 2.0); + } + else if (!strcmp(ev->keyname, "n")) + { + const char *file; + if (!curfile) + curfile = filenames; + else + curfile = eina_list_next(curfile); + file = eina_list_data_get(curfile); + fprintf(stderr, "playing next file: %s\n", file); + emotion_object_file_set(em, file); + } + else if (!strcmp(ev->keyname, "p")) + { + const char *file; + if (!curfile) + curfile = eina_list_last(filenames); + else + curfile = eina_list_prev(curfile); + file = eina_list_data_get(curfile); + fprintf(stderr, "playing next file: %s\n", file); + emotion_object_file_set(em, file); + } + else if (!strcmp(ev->keyname, "d")) + { + evas_object_del(em); + } + else if (!strcmp(ev->keyname, "l")) + { + // force frame dropping + sleep(5); + } + else + { + fprintf(stderr, "unhandled key: %s\n", ev->keyname); + } +} + +static void +_frame_decode_cb(void *data, Evas_Object *o, void *event_info) +{ + // fprintf(stderr, "smartcb: frame_decode\n"); +} + +static void +_length_change_cb(void *data, Evas_Object *o, void *event_info) +{ + fprintf(stderr, "smartcb: length_change: %0.3f\n", emotion_object_play_length_get(o)); +} + +static void +_position_update_cb(void *data, Evas_Object *o, void *event_info) +{ + fprintf(stderr, "smartcb: position_update: %0.3f\n", emotion_object_position_get(o)); +} + +static void +_progress_change_cb(void *data, Evas_Object *o, void *event_info) +{ + fprintf(stderr, "smartcb: progress_change: %0.3f, %s\n", + emotion_object_progress_status_get(o), + emotion_object_progress_info_get(o)); +} + +static void +_frame_resize_cb(void *data, Evas_Object *o, void *event_info) +{ + int w, h; + emotion_object_size_get(o, &w, &h); + fprintf(stderr, "smartcb: frame_resize: %dx%d\n", w, h); +} + +int +main(int argc, const char *argv[]) +{ + Ecore_Evas *ee; + Evas *e; + Evas_Object *bg, *em; + int i; + + if (argc < 2) + { + printf("One argument is necessary. Usage:\n"); + printf("\t%s \n", argv[0]); + } + + eina_init(); + for (i = 1; i < argc; i++) + filenames = eina_list_append(filenames, eina_stringshare_add(argv[i])); + + curfile = filenames; + + if (!ecore_evas_init()) + return EXIT_FAILURE; + + /* this will give you a window with an Evas canvas under the first + * engine available */ + ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL); + if (!ee) + goto error; + + ecore_evas_show(ee); + + /* the canvas pointer, de facto */ + e = ecore_evas_get(ee); + + /* adding a background to this example */ + bg = evas_object_rectangle_add(e); + evas_object_name_set(bg, "our dear rectangle"); + evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */ + evas_object_move(bg, 0, 0); /* at canvas' origin */ + evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ + evas_object_show(bg); + + /* Creating the emotion object */ + em = _create_emotion_object(e); + emotion_object_file_set(em, eina_list_data_get(curfile)); + evas_object_move(em, 0, 0); + evas_object_resize(em, WIDTH, HEIGHT); + evas_object_show(em); + + evas_object_smart_callback_add(em, "frame_decode", _frame_decode_cb, NULL); + evas_object_smart_callback_add(em, "length_change", _length_change_cb, NULL); + evas_object_smart_callback_add(em, "position_update", _position_update_cb, NULL); + evas_object_smart_callback_add(em, "progress_change", _progress_change_cb, NULL); + evas_object_smart_callback_add(em, "frame_resize", _frame_resize_cb, NULL); + + evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_key_down, em); + evas_object_focus_set(bg, EINA_TRUE); + + emotion_object_play_set(em, EINA_TRUE); + + ecore_main_loop_begin(); + + ecore_evas_free(ee); + ecore_evas_shutdown(); + return 0; + +error: + fprintf(stderr, "you got to have at least one evas engine built and linked" + " up to ecore-evas for this example to run properly.\n"); + + EINA_LIST_FREE(filenames, curfile) + eina_stringshare_del(eina_list_data_get(curfile)); + + ecore_evas_shutdown(); + eina_shutdown(); + return -1; +} diff --git a/unsorted/emotion/emotion_generic_subtitle_example.c b/unsorted/emotion/emotion_generic_subtitle_example.c new file mode 100644 index 00000000..448b5054 --- /dev/null +++ b/unsorted/emotion/emotion_generic_subtitle_example.c @@ -0,0 +1,97 @@ +#include +#include +#include +#include +#include + +#define WIDTH (320) +#define HEIGHT (240) + +static void +_playback_started_cb(void *data, Evas_Object *o, void *event_info) +{ + printf("Emotion object started playback.\n"); +} + +static void +_on_delete(Ecore_Evas *ee) +{ + ecore_main_loop_quit(); +} + +int +main(int argc, const char *argv[]) +{ + Ecore_Evas *ee; + Evas *e; + Evas_Object *bg, *em; + const char *filename = NULL; + const char *subtitle_filename = NULL; + + if (argc < 2) + { + printf("At least one argument is necessary. Usage:\n"); + printf("\t%s \n", argv[0]); + return -1; + } + + filename = argv[1]; + + if (argc > 2) + subtitle_filename = argv[2]; + + if (!ecore_evas_init()) + return EXIT_FAILURE; + + /* this will give you a window with an Evas canvas under the first + * engine available */ + ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL); + if (!ee) + goto error; + + ecore_evas_callback_delete_request_set(ee, _on_delete); + + ecore_evas_show(ee); + + /* the canvas pointer, de facto */ + e = ecore_evas_get(ee); + + /* adding a background to this example */ + bg = evas_object_rectangle_add(e); + evas_object_name_set(bg, "our dear rectangle"); + evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */ + evas_object_move(bg, 0, 0); /* at canvas' origin */ + evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ + evas_object_show(bg); + + /* Creating the emotion object */ + em = emotion_object_add(e); + emotion_object_init(em, "generic"); + + if (subtitle_filename) + emotion_object_video_subtitle_file_set(em, subtitle_filename); + + evas_object_smart_callback_add( + em, "playback_started", _playback_started_cb, NULL); + + emotion_object_file_set(em, filename); + + evas_object_move(em, 0, 0); + evas_object_resize(em, WIDTH, HEIGHT); + evas_object_show(em); + + emotion_object_play_set(em, EINA_TRUE); + + ecore_main_loop_begin(); + + ecore_evas_free(ee); + ecore_evas_shutdown(); + return 0; + +error: + fprintf(stderr, "you got to have at least one evas engine built and linked" + " up to ecore-evas for this example to run properly.\n"); + + ecore_evas_shutdown(); + return -1; +} diff --git a/unsorted/emotion/emotion_signals_example.c b/unsorted/emotion/emotion_signals_example.c new file mode 100644 index 00000000..2469c468 --- /dev/null +++ b/unsorted/emotion/emotion_signals_example.c @@ -0,0 +1,173 @@ +#include +#include +#include +#include +#include + +#define WIDTH (320) +#define HEIGHT (240) + +static void +_display_info(Evas_Object *o) +{ + int w, h; + printf("playing: %d\n", emotion_object_play_get(o)); + printf("meta title: %s\n", + emotion_object_meta_info_get(o, EMOTION_META_INFO_TRACK_TITLE)); + printf("seek position: %0.3f\n", + emotion_object_position_get(o)); + printf("play length: %0.3f\n", + emotion_object_play_length_get(o)); + printf("is seekable: %d\n", + emotion_object_seekable_get(o)); + emotion_object_size_get(o, &w, &h); + printf("video geometry: %dx%d\n", w, h); + printf("video width / height ratio: %0.3f\n", + emotion_object_ratio_get(o)); + printf("\n"); +} + +static void +_playback_started_cb(void *data, Evas_Object *o, void *event_info) +{ + printf(">>> Emotion object started playback.\n"); + _display_info(o); +} + +static void +_playback_finished_cb(void *data, Evas_Object *o, void *event_info) +{ + printf(">>> Emotion object finished playback.\n"); + _display_info(o); +} + +static void +_open_done_cb(void *data, Evas_Object *o, void *event_info) +{ + printf(">>> Emotion object open done.\n"); + _display_info(o); +} + +static void +_position_update_cb(void *data, Evas_Object *o, void *event_info) +{ + printf(">>> Emotion object first position update.\n"); + evas_object_smart_callback_del(o, "position_update", _position_update_cb); + _display_info(o); +} + +static void +_frame_decode_cb(void *data, Evas_Object *o, void *event_info) +{ + printf(">>> Emotion object first frame decode.\n"); + evas_object_smart_callback_del(o, "frame_decode", _frame_decode_cb); + _display_info(o); +} + +static void +_decode_stop_cb(void *data, Evas_Object *o, void *event_info) +{ + printf(">>> Emotion object decode stop.\n"); + _display_info(o); +} + +static void +_frame_resize_cb(void *data, Evas_Object *o, void *event_info) +{ + printf(">>> Emotion object frame resize.\n"); + _display_info(o); +} + +static void +_setup_emotion_callbacks(Evas_Object *o) +{ + evas_object_smart_callback_add( + o, "playback_started", _playback_started_cb, NULL); + evas_object_smart_callback_add( + o, "playback_finished", _playback_finished_cb, NULL); + evas_object_smart_callback_add( + o, "open_done", _open_done_cb, NULL); + evas_object_smart_callback_add( + o, "position_update", _position_update_cb, NULL); + evas_object_smart_callback_add( + o, "frame_decode", _frame_decode_cb, NULL); + evas_object_smart_callback_add( + o, "decode_stop", _decode_stop_cb, NULL); + evas_object_smart_callback_add( + o, "frame_resize", _frame_resize_cb, NULL); +} + +int +main(int argc, const char *argv[]) +{ + Ecore_Evas *ee; + Evas *e; + Evas_Object *bg, *em; + const char *filename = NULL; + const char *module = NULL; + + if (argc < 2) + { + printf("At least one argument is necessary. Usage:\n"); + printf("\t%s [module_name]\n", argv[0]); + goto error; + } + + filename = argv[1]; + + if (argc >= 3) + module = argv[2]; + + if (!ecore_evas_init()) + return EXIT_FAILURE; + + /* this will give you a window with an Evas canvas under the first + * engine available */ + ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL); + if (!ee) + goto error; + + ecore_evas_show(ee); + + /* the canvas pointer, de facto */ + e = ecore_evas_get(ee); + + /* adding a background to this example */ + bg = evas_object_rectangle_add(e); + evas_object_name_set(bg, "our dear rectangle"); + evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */ + evas_object_move(bg, 0, 0); /* at canvas' origin */ + evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ + evas_object_show(bg); + + /* Creating the emotion object */ + em = emotion_object_add(e); + + /* Try to load the specified module - NULL for auto-discover */ + if (!emotion_object_init(em, module)) + fprintf(stderr, "Emotion: \"%s\" module could not be initialized.\n", module); + + _display_info(em); + _setup_emotion_callbacks(em); + + if (!emotion_object_file_set(em, filename)) + fprintf(stderr, "Emotion: Could not load the file \"%s\"\n", filename); + + evas_object_move(em, 0, 0); + evas_object_resize(em, WIDTH, HEIGHT); + evas_object_show(em); + + emotion_object_play_set(em, EINA_TRUE); + + ecore_main_loop_begin(); + + ecore_evas_free(ee); + ecore_evas_shutdown(); + return 0; + + ecore_evas_free(ee); + +error: + ecore_evas_shutdown(); + return -1; +}