summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2013-01-02 21:03:30 +0000
committerLeandro Dorileo <dorileo@profusion.mobi>2013-01-02 21:03:30 +0000
commite3e1511bacd6f7b528f860408a18dc4fb76f3070 (patch)
treee3cf55bd13fb4c8ad8187d074baa0ad77b4fcdd2
parent37bcda87ed63e79a8a3b39431cfe9bf9233e12ce (diff)
Emotion: introce emotion_object_video_subtitle_file_set() call
For setting an arbitrary subtitle file, this patch introduces the emotion_object_video_subtitle_file_set() and its counterpart emotion_object_video_subtitle_file_get(). The tag @sice were added as 1.7.2 since we're preparing a backport to stable tree. SVN revision: 82019
-rw-r--r--legacy/emotion/.gitignore6
-rw-r--r--legacy/emotion/AUTHORS1
-rw-r--r--legacy/emotion/ChangeLog4
-rw-r--r--legacy/emotion/NEWS8
-rw-r--r--legacy/emotion/src/examples/Makefile.am2
-rw-r--r--legacy/emotion/src/examples/emotion_generic_subtitle_example.c97
-rw-r--r--legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c15
-rw-r--r--legacy/emotion/src/lib/Emotion.h32
-rw-r--r--legacy/emotion/src/lib/emotion_private.h2
-rw-r--r--legacy/emotion/src/lib/emotion_smart.c23
-rw-r--r--legacy/emotion/src/modules/generic/Emotion_Generic_Plugin.h1
-rw-r--r--legacy/emotion/src/modules/generic/emotion_generic.c24
-rw-r--r--legacy/emotion/src/modules/generic/emotion_generic.h1
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c21
14 files changed, 236 insertions, 1 deletions
diff --git a/legacy/emotion/.gitignore b/legacy/emotion/.gitignore
index a38523edd2..70e8e3c54d 100644
--- a/legacy/emotion/.gitignore
+++ b/legacy/emotion/.gitignore
@@ -49,8 +49,14 @@ src/edje_external/Makefile.in
49src/edje_external/module.la 49src/edje_external/module.la
50src/edje_external/module_la-emotion.lo 50src/edje_external/module_la-emotion.lo
51src/examples/.deps/ 51src/examples/.deps/
52src/examples/.libs/
52src/examples/Makefile 53src/examples/Makefile
53src/examples/Makefile.in 54src/examples/Makefile.in
55src/examples/emotion_basic_example
56src/examples/emotion_border_example
57src/examples/emotion_generic_example
58src/examples/emotion_generic_subtitle_example
59src/examples/emotion_signals_example
54src/generic_players/Makefile 60src/generic_players/Makefile
55src/generic_players/Makefile.in 61src/generic_players/Makefile.in
56src/generic_players/vlc/.deps/ 62src/generic_players/vlc/.deps/
diff --git a/legacy/emotion/AUTHORS b/legacy/emotion/AUTHORS
index c2579a8e4e..0cfd8c62f2 100644
--- a/legacy/emotion/AUTHORS
+++ b/legacy/emotion/AUTHORS
@@ -8,3 +8,4 @@ Jérôme Pinot <ngc891@gmail.com>
8Pierre Le Magourou <pierre.lemagourou@openwide.fr> 8Pierre Le Magourou <pierre.lemagourou@openwide.fr>
9Hugo Camboulive <hugo.camboulive@zodiacaerospace.com> 9Hugo Camboulive <hugo.camboulive@zodiacaerospace.com>
10Sohyun Kim <anna1014.kim@samsung.com> 10Sohyun Kim <anna1014.kim@samsung.com>
11Leandro Dorileo <dorileo@profusion.mobi> \ No newline at end of file
diff --git a/legacy/emotion/ChangeLog b/legacy/emotion/ChangeLog
index 36a608d761..3298ea3dee 100644
--- a/legacy/emotion/ChangeLog
+++ b/legacy/emotion/ChangeLog
@@ -58,3 +58,7 @@
582012-10-11 Sohyun Kim 582012-10-11 Sohyun Kim
59 59
60 * Fix to call correct render function based on the format. 60 * Fix to call correct render function based on the format.
61
622013-01-02 Leandro Dorileo (dorileo)
63
64 * Add subtitle file API.
diff --git a/legacy/emotion/NEWS b/legacy/emotion/NEWS
index d3715bdf63..112b405035 100644
--- a/legacy/emotion/NEWS
+++ b/legacy/emotion/NEWS
@@ -1,4 +1,10 @@
1Emotion 1.7.1 1Emotion 1.7.2
2
3Changes since Emotion 1.7.1:
4-------------------------
5
6Additions:
7 - Add video subtitle file API.
2 8
3Changes since Emotion 1.7.0: 9Changes since Emotion 1.7.0:
4------------------------- 10-------------------------
diff --git a/legacy/emotion/src/examples/Makefile.am b/legacy/emotion/src/examples/Makefile.am
index 7476f08857..5e39adcf7a 100644
--- a/legacy/emotion/src/examples/Makefile.am
+++ b/legacy/emotion/src/examples/Makefile.am
@@ -17,6 +17,7 @@ LDADD = \
17SRCS = \ 17SRCS = \
18 emotion_basic_example.c \ 18 emotion_basic_example.c \
19 emotion_generic_example.c \ 19 emotion_generic_example.c \
20 emotion_generic_subtitle_example.c \
20 emotion_border_example.c \ 21 emotion_border_example.c \
21 emotion_signals_example.c 22 emotion_signals_example.c
22 23
@@ -33,6 +34,7 @@ if EFL_BUILD_EXAMPLES
33examples_PROGRAMS += \ 34examples_PROGRAMS += \
34 emotion_basic_example \ 35 emotion_basic_example \
35 emotion_generic_example \ 36 emotion_generic_example \
37 emotion_generic_subtitle_example \
36 emotion_border_example \ 38 emotion_border_example \
37 emotion_signals_example 39 emotion_signals_example
38endif 40endif
diff --git a/legacy/emotion/src/examples/emotion_generic_subtitle_example.c b/legacy/emotion/src/examples/emotion_generic_subtitle_example.c
new file mode 100644
index 0000000000..448b505449
--- /dev/null
+++ b/legacy/emotion/src/examples/emotion_generic_subtitle_example.c
@@ -0,0 +1,97 @@
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_playback_started_cb(void *data, Evas_Object *o, void *event_info)
12{
13 printf("Emotion object started playback.\n");
14}
15
16static void
17_on_delete(Ecore_Evas *ee)
18{
19 ecore_main_loop_quit();
20}
21
22int
23main(int argc, const char *argv[])
24{
25 Ecore_Evas *ee;
26 Evas *e;
27 Evas_Object *bg, *em;
28 const char *filename = NULL;
29 const char *subtitle_filename = NULL;
30
31 if (argc < 2)
32 {
33 printf("At least one argument is necessary. Usage:\n");
34 printf("\t%s <filename> <subtitle filename>\n", argv[0]);
35 return -1;
36 }
37
38 filename = argv[1];
39
40 if (argc > 2)
41 subtitle_filename = argv[2];
42
43 if (!ecore_evas_init())
44 return EXIT_FAILURE;
45
46 /* this will give you a window with an Evas canvas under the first
47 * engine available */
48 ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
49 if (!ee)
50 goto error;
51
52 ecore_evas_callback_delete_request_set(ee, _on_delete);
53
54 ecore_evas_show(ee);
55
56 /* the canvas pointer, de facto */
57 e = ecore_evas_get(ee);
58
59 /* adding a background to this example */
60 bg = evas_object_rectangle_add(e);
61 evas_object_name_set(bg, "our dear rectangle");
62 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
63 evas_object_move(bg, 0, 0); /* at canvas' origin */
64 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
65 evas_object_show(bg);
66
67 /* Creating the emotion object */
68 em = emotion_object_add(e);
69 emotion_object_init(em, "generic");
70
71 if (subtitle_filename)
72 emotion_object_video_subtitle_file_set(em, subtitle_filename);
73
74 evas_object_smart_callback_add(
75 em, "playback_started", _playback_started_cb, NULL);
76
77 emotion_object_file_set(em, filename);
78
79 evas_object_move(em, 0, 0);
80 evas_object_resize(em, WIDTH, HEIGHT);
81 evas_object_show(em);
82
83 emotion_object_play_set(em, EINA_TRUE);
84
85 ecore_main_loop_begin();
86
87 ecore_evas_free(ee);
88 ecore_evas_shutdown();
89 return 0;
90
91error:
92 fprintf(stderr, "you got to have at least one evas engine built and linked"
93 " up to ecore-evas for this example to run properly.\n");
94
95 ecore_evas_shutdown();
96 return -1;
97}
diff --git a/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c b/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
index 836eda3a45..d15341667a 100644
--- a/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
+++ b/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
@@ -37,6 +37,7 @@ struct _App {
37 libvlc_event_manager_t *event_mgr; 37 libvlc_event_manager_t *event_mgr;
38 libvlc_event_manager_t *mevent_mgr; 38 libvlc_event_manager_t *mevent_mgr;
39 char *filename; 39 char *filename;
40 char *subtitle_path;
40 char *shmname; 41 char *shmname;
41 void *tmpbuffer; 42 void *tmpbuffer;
42 int w, h; 43 int w, h;
@@ -313,6 +314,10 @@ _play(struct _App *app)
313 libvlc_time_t new_time = pos * 1000; 314 libvlc_time_t new_time = pos * 1000;
314 libvlc_media_player_set_time(app->mp, new_time); 315 libvlc_media_player_set_time(app->mp, new_time);
315 libvlc_media_player_play(app->mp); 316 libvlc_media_player_play(app->mp);
317
318 if (app->subtitle_path)
319 libvlc_video_set_subtitle_file(app->mp, app->subtitle_path);
320
316 app->playing = 1; 321 app->playing = 1;
317 } 322 }
318} 323}
@@ -378,6 +383,12 @@ _event_cb(const struct libvlc_event_t *ev, void *data)
378} 383}
379 384
380static void 385static void
386_subtitle_set(struct _App *app)
387{
388 _em_str_read(app->em_read, &app->subtitle_path);
389}
390
391static void
381_file_set(struct _App *app) 392_file_set(struct _App *app)
382{ 393{
383 if (app->opening) 394 if (app->opening)
@@ -585,6 +596,9 @@ _process_emotion_commands(struct _App *app)
585 case EM_CMD_FILE_SET_DONE: 596 case EM_CMD_FILE_SET_DONE:
586 _file_set_done(app); 597 _file_set_done(app);
587 break; 598 break;
599 case EM_CMD_SUBTITLE_SET:
600 _subtitle_set(app);
601 break;
588 case EM_CMD_FILE_CLOSE: 602 case EM_CMD_FILE_CLOSE:
589 _file_close(app); 603 _file_close(app);
590 break; 604 break;
@@ -805,6 +819,7 @@ main(int argc, const char *argv[])
805 app.libvlc = libvlc_new(vlc_argc, vlc_argv); 819 app.libvlc = libvlc_new(vlc_argc, vlc_argv);
806 app.mp = NULL; 820 app.mp = NULL;
807 app.filename = NULL; 821 app.filename = NULL;
822 app.subtitle_path = NULL;
808 app.w = 0; 823 app.w = 0;
809 app.h = 0; 824 app.h = 0;
810 app.size_sent = 0; 825 app.size_sent = 0;
diff --git a/legacy/emotion/src/lib/Emotion.h b/legacy/emotion/src/lib/Emotion.h
index 361e4e55e5..186144ea4f 100644
--- a/legacy/emotion/src/lib/Emotion.h
+++ b/legacy/emotion/src/lib/Emotion.h
@@ -980,6 +980,38 @@ EAPI void emotion_object_video_mute_set (Evas_Object *obj, Eina_B
980EAPI Eina_Bool emotion_object_video_mute_get (const Evas_Object *obj); 980EAPI Eina_Bool emotion_object_video_mute_get (const Evas_Object *obj);
981 981
982/** 982/**
983 * @brief Set the video's subtitle file path.
984 *
985 * @param obj The object which we are setting a subtitle file path.
986 * @param filepath The subtitle file path.
987 *
988 * This function sets a video's subtitle file path(i.e an .srt file) for
989 * supported subtitle formats consult the backend's documentation.
990 *
991 * @see emotion_object_video_subtitle_file_get().
992 *
993 * @ingroup Emotion_Video
994 * @since 1.7.2
995 */
996EAPI void emotion_object_video_subtitle_file_set (Evas_Object *obj, const char *filepath);
997
998/**
999 * @brief Get the video's subtitle file path.
1000 *
1001 * @param obj The object which we are retrieving the subtitle file path from.
1002 * @return The video's subtitle file path previously set, NULL otherwise.
1003 *
1004 * This function returns the video's subtitle file path, if not previously set
1005 * or in error NULL is returned.
1006 *
1007 * @see emotion_object_video_subtitle_file_set().
1008 *
1009 * @ingroup Emotion_Video
1010 * @since 1.7.2
1011 */
1012EAPI const char *emotion_object_video_subtitle_file_get (const Evas_Object *obj);
1013
1014/**
983 * @brief Get the number of available video channel 1015 * @brief Get the number of available video channel
984 * 1016 *
985 * @param obj The object which we are retrieving the channel count from 1017 * @param obj The object which we are retrieving the channel count from
diff --git a/legacy/emotion/src/lib/emotion_private.h b/legacy/emotion/src/lib/emotion_private.h
index cf24c7543e..73a1b7ddf0 100644
--- a/legacy/emotion/src/lib/emotion_private.h
+++ b/legacy/emotion/src/lib/emotion_private.h
@@ -74,6 +74,8 @@ struct _Emotion_Video_Module
74 int (*video_channel_count) (void *ef); 74 int (*video_channel_count) (void *ef);
75 void (*video_channel_set) (void *ef, int channel); 75 void (*video_channel_set) (void *ef, int channel);
76 int (*video_channel_get) (void *ef); 76 int (*video_channel_get) (void *ef);
77 void (*video_subtitle_file_set) (void *ef, const char *filepath);
78 const char * (*video_subtitle_file_get) (void *ef);
77 const char * (*video_channel_name_get) (void *ef, int channel); 79 const char * (*video_channel_name_get) (void *ef, int channel);
78 void (*video_channel_mute_set) (void *ef, int mute); 80 void (*video_channel_mute_set) (void *ef, int mute);
79 int (*video_channel_mute_get) (void *ef); 81 int (*video_channel_mute_get) (void *ef);
diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c
index 48eafdacc7..8a80f838db 100644
--- a/legacy/emotion/src/lib/emotion_smart.c
+++ b/legacy/emotion/src/lib/emotion_smart.c
@@ -999,6 +999,29 @@ emotion_object_video_mute_get(const Evas_Object *obj)
999 return sd->module->video_channel_mute_get(sd->video_data); 999 return sd->module->video_channel_mute_get(sd->video_data);
1000} 1000}
1001 1001
1002EAPI void
1003emotion_object_video_subtitle_file_set(Evas_Object *obj, const char *filepath)
1004{
1005 Smart_Data *sd;
1006
1007 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1008 DBG("subtitle=%s", filepath);
1009 if (!sd->module) return;
1010 if (!sd->video_data) return;
1011 sd->module->video_subtitle_file_set(sd->video_data, filepath);
1012}
1013
1014EAPI const char *
1015emotion_object_video_subtitle_file_get(const Evas_Object *obj)
1016{
1017 Smart_Data *sd;
1018
1019 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1020 if (!sd->module) return EINA_FALSE;
1021 if (!sd->video_data) return EINA_FALSE;
1022 return sd->module->video_subtitle_file_get(sd->video_data);
1023}
1024
1002EAPI int 1025EAPI int
1003emotion_object_video_channel_count(const Evas_Object *obj) 1026emotion_object_video_channel_count(const Evas_Object *obj)
1004{ 1027{
diff --git a/legacy/emotion/src/modules/generic/Emotion_Generic_Plugin.h b/legacy/emotion/src/modules/generic/Emotion_Generic_Plugin.h
index 17bd7e9c50..f00ea6e405 100644
--- a/legacy/emotion/src/modules/generic/Emotion_Generic_Plugin.h
+++ b/legacy/emotion/src/modules/generic/Emotion_Generic_Plugin.h
@@ -35,6 +35,7 @@ enum _Emotion_Generic_Cmd
35 EM_CMD_AUDIO_TRACK_SET, // param: track id (int) 35 EM_CMD_AUDIO_TRACK_SET, // param: track id (int)
36 EM_CMD_VIDEO_TRACK_SET, // param: track id (int) 36 EM_CMD_VIDEO_TRACK_SET, // param: track id (int)
37 EM_CMD_SPU_TRACK_SET, // param: track id (int) 37 EM_CMD_SPU_TRACK_SET, // param: track id (int)
38 EM_CMD_SUBTITLE_SET, // param: subtitle filename (string)
38 EM_CMD_LAST 39 EM_CMD_LAST
39}; 40};
40 41
diff --git a/legacy/emotion/src/modules/generic/emotion_generic.c b/legacy/emotion/src/modules/generic/emotion_generic.c
index e0ff6d9a16..648be6dfd8 100644
--- a/legacy/emotion/src/modules/generic/emotion_generic.c
+++ b/legacy/emotion/src/modules/generic/emotion_generic.c
@@ -1129,6 +1129,7 @@ em_file_close(void *data)
1129 INF("file close: %s", ev->filename); 1129 INF("file close: %s", ev->filename);
1130 1130
1131 eina_stringshare_replace(&ev->filename, NULL); 1131 eina_stringshare_replace(&ev->filename, NULL);
1132 eina_stringshare_replace(&ev->subtitle_path, NULL);
1132 1133
1133 ev->file_ready = EINA_FALSE; 1134 ev->file_ready = EINA_FALSE;
1134 _audio_channels_free(ev); 1135 _audio_channels_free(ev);
@@ -1175,8 +1176,15 @@ em_play(void *data, double pos)
1175 1176
1176 if (ev->ready) 1177 if (ev->ready)
1177 { 1178 {
1179 if (ev->subtitle_path)
1180 {
1181 _player_send_cmd(ev, EM_CMD_SUBTITLE_SET);
1182 _player_send_str(ev, ev->subtitle_path, EINA_TRUE);
1183 }
1184
1178 _player_send_cmd(ev, EM_CMD_PLAY); 1185 _player_send_cmd(ev, EM_CMD_PLAY);
1179 _player_send_float(ev, ev->pos); 1186 _player_send_float(ev, ev->pos);
1187
1180 return; 1188 return;
1181 } 1189 }
1182 1190
@@ -1392,6 +1400,20 @@ em_video_channel_get(void *data)
1392 return ev->video_channel_current; 1400 return ev->video_channel_current;
1393} 1401}
1394 1402
1403static void
1404em_video_subtitle_file_set(void *data, const char *filepath)
1405{
1406 Emotion_Generic_Video *ev = data;
1407 eina_stringshare_replace(&ev->subtitle_path, filepath);
1408}
1409
1410static const char *
1411em_video_subtitle_file_get(void *data)
1412{
1413 Emotion_Generic_Video *ev = data;
1414 return ev->subtitle_path;
1415}
1416
1395static const char * 1417static const char *
1396em_video_channel_name_get(void *data, int channel) 1418em_video_channel_name_get(void *data, int channel)
1397{ 1419{
@@ -1694,6 +1716,8 @@ static Emotion_Video_Module em_module =
1694 em_video_channel_count, /* video_channel_count */ 1716 em_video_channel_count, /* video_channel_count */
1695 em_video_channel_set, /* video_channel_set */ 1717 em_video_channel_set, /* video_channel_set */
1696 em_video_channel_get, /* video_channel_get */ 1718 em_video_channel_get, /* video_channel_get */
1719 em_video_subtitle_file_set, /* video_subtitle_file_set */
1720 em_video_subtitle_file_get, /* video_subtitle_file_get */
1697 em_video_channel_name_get, /* video_channel_name_get */ 1721 em_video_channel_name_get, /* video_channel_name_get */
1698 em_video_channel_mute_set, /* video_channel_mute_set */ 1722 em_video_channel_mute_set, /* video_channel_mute_set */
1699 em_video_channel_mute_get, /* video_channel_mute_get */ 1723 em_video_channel_mute_get, /* video_channel_mute_get */
diff --git a/legacy/emotion/src/modules/generic/emotion_generic.h b/legacy/emotion/src/modules/generic/emotion_generic.h
index ed3bdb042e..864abb3f41 100644
--- a/legacy/emotion/src/modules/generic/emotion_generic.h
+++ b/legacy/emotion/src/modules/generic/emotion_generic.h
@@ -106,6 +106,7 @@ struct _Emotion_Generic_Video
106 int spu_channel_current; 106 int spu_channel_current;
107 Emotion_Generic_Channel *spu_channels; 107 Emotion_Generic_Channel *spu_channels;
108 Emotion_Generic_Meta meta; 108 Emotion_Generic_Meta meta;
109 const char *subtitle_path;
109}; 110};
110 111
111#endif 112#endif
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
index 8ec71fb2c0..395d9310cd 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
+++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
@@ -132,6 +132,11 @@ static void em_video_channel_set (void *video,
132 132
133static int em_video_channel_get (void *video); 133static int em_video_channel_get (void *video);
134 134
135static void em_video_subtitle_file_set (void *video,
136 const char *filepath);
137
138static const char *em_video_subtitle_file_get (void *video);
139
135static const char *em_video_channel_name_get (void *video, 140static const char *em_video_channel_name_get (void *video,
136 int channel); 141 int channel);
137 142
@@ -241,6 +246,8 @@ static Emotion_Video_Module em_module =
241 em_video_channel_count, /* video_channel_count */ 246 em_video_channel_count, /* video_channel_count */
242 em_video_channel_set, /* video_channel_set */ 247 em_video_channel_set, /* video_channel_set */
243 em_video_channel_get, /* video_channel_get */ 248 em_video_channel_get, /* video_channel_get */
249 em_video_subtitle_file_set, /* video_subtitle_file_set */
250 em_video_subtitle_file_get, /* video_subtitle_file_get */
244 em_video_channel_name_get, /* video_channel_name_get */ 251 em_video_channel_name_get, /* video_channel_name_get */
245 em_video_channel_mute_set, /* video_channel_mute_set */ 252 em_video_channel_mute_set, /* video_channel_mute_set */
246 em_video_channel_mute_get, /* video_channel_mute_get */ 253 em_video_channel_mute_get, /* video_channel_mute_get */
@@ -1028,6 +1035,20 @@ em_video_channel_get(void *video)
1028 return ev->video_stream_nbr; 1035 return ev->video_stream_nbr;
1029} 1036}
1030 1037
1038static void
1039em_video_subtitle_file_set(void *video __UNUSED__,
1040 const char *filepath __UNUSED__)
1041{
1042 DBG("video_subtitle_file_set not implemented for gstreamer yet.");
1043}
1044
1045static const char *
1046em_video_subtitle_file_get(void *video __UNUSED__)
1047{
1048 DBG("video_subtitle_file_get not implemented for gstreamer yet.");
1049 return NULL;
1050}
1051
1031static const char * 1052static const char *
1032em_video_channel_name_get(void *video __UNUSED__, 1053em_video_channel_name_get(void *video __UNUSED__,
1033 int channel __UNUSED__) 1054 int channel __UNUSED__)