5 #include "emotion_private.h"
6 #include "emotion_gstreamer.h"
7 #include "emotion_gstreamer_pipeline.h"
10 /* Callbacks to get the eos */
11 static int _eos_timer_fct (void *data);
13 static int _em_fd_ev_active(void *data, Ecore_Fd_Handler *fdh);
18 static unsigned char em_init (Evas_Object *obj,
20 Emotion_Module_Options *opt);
22 static int em_shutdown (void *video);
24 static unsigned char em_file_open (const char *file,
28 static void em_file_close (void *video);
30 static void em_play (void *video,
33 static void em_stop (void *video);
35 static void em_size_get (void *video,
39 static void em_pos_set (void *video,
42 static void em_vis_set (void *video,
45 static double em_len_get (void *video);
47 static int em_fps_num_get (void *video);
49 static int em_fps_den_get (void *video);
51 static double em_fps_get (void *video);
53 static double em_pos_get (void *video);
55 static Emotion_Vis em_vis_get (void *video);
57 static double em_ratio_get (void *video);
59 static int em_video_handled (void *video);
61 static int em_audio_handled (void *video);
63 static int em_seekable (void *video);
65 static void em_frame_done (void *video);
67 static Emotion_Format em_format_get (void *video);
69 static void em_video_data_size_get (void *video,
73 static int em_yuv_rows_get (void *video,
76 unsigned char **yrows,
77 unsigned char **urows,
78 unsigned char **vrows);
80 static int em_bgra_data_get (void *video,
81 unsigned char **bgra_data);
83 static void em_event_feed (void *video,
86 static void em_event_mouse_button_feed (void *video,
91 static void em_event_mouse_move_feed (void *video,
95 static int em_video_channel_count (void *video);
97 static void em_video_channel_set (void *video,
100 static int em_video_channel_get (void *video);
102 static const char *em_video_channel_name_get (void *video,
105 static void em_video_channel_mute_set (void *video,
108 static int em_video_channel_mute_get (void *video);
110 static int em_audio_channel_count (void *video);
112 static void em_audio_channel_set (void *video,
115 static int em_audio_channel_get (void *video);
117 static const char *em_audio_channel_name_get (void *video,
120 static void em_audio_channel_mute_set (void *video,
123 static int em_audio_channel_mute_get (void *video);
125 static void em_audio_channel_volume_set (void *video,
128 static double em_audio_channel_volume_get (void *video);
130 static int em_spu_channel_count (void *video);
132 static void em_spu_channel_set (void *video,
135 static int em_spu_channel_get (void *video);
137 static const char *em_spu_channel_name_get (void *video,
140 static void em_spu_channel_mute_set (void *video,
143 static int em_spu_channel_mute_get (void *video);
145 static int em_chapter_count (void *video);
147 static void em_chapter_set (void *video,
150 static int em_chapter_get (void *video);
152 static const char *em_chapter_name_get (void *video,
155 static void em_speed_set (void *video,
158 static double em_speed_get (void *video);
160 static int em_eject (void *video);
162 static const char *em_meta_get (void *video,
165 /* Module interface */
167 static Emotion_Video_Module em_module =
170 em_shutdown, /* shutdown */
171 em_file_open, /* file_open */
172 em_file_close, /* file_close */
175 em_size_get, /* size_get */
176 em_pos_set, /* pos_set */
177 em_vis_set, /* vis_set */
178 em_len_get, /* len_get */
179 em_fps_num_get, /* fps_num_get */
180 em_fps_den_get, /* fps_den_get */
181 em_fps_get, /* fps_get */
182 em_pos_get, /* pos_get */
183 em_vis_get, /* vis_get */
184 em_ratio_get, /* ratio_get */
185 em_video_handled, /* video_handled */
186 em_audio_handled, /* audio_handled */
187 em_seekable, /* seekable */
188 em_frame_done, /* frame_done */
189 em_format_get, /* format_get */
190 em_video_data_size_get, /* video_data_size_get */
191 em_yuv_rows_get, /* yuv_rows_get */
192 em_bgra_data_get, /* bgra_data_get */
193 em_event_feed, /* event_feed */
194 em_event_mouse_button_feed, /* event_mouse_button_feed */
195 em_event_mouse_move_feed, /* event_mouse_move_feed */
196 em_video_channel_count, /* video_channel_count */
197 em_video_channel_set, /* video_channel_set */
198 em_video_channel_get, /* video_channel_get */
199 em_video_channel_name_get, /* video_channel_name_get */
200 em_video_channel_mute_set, /* video_channel_mute_set */
201 em_video_channel_mute_get, /* video_channel_mute_get */
202 em_audio_channel_count, /* audio_channel_count */
203 em_audio_channel_set, /* audio_channel_set */
204 em_audio_channel_get, /* audio_channel_get */
205 em_audio_channel_name_get, /* audio_channel_name_get */
206 em_audio_channel_mute_set, /* audio_channel_mute_set */
207 em_audio_channel_mute_get, /* audio_channel_mute_get */
208 em_audio_channel_volume_set, /* audio_channel_volume_set */
209 em_audio_channel_volume_get, /* audio_channel_volume_get */
210 em_spu_channel_count, /* spu_channel_count */
211 em_spu_channel_set, /* spu_channel_set */
212 em_spu_channel_get, /* spu_channel_get */
213 em_spu_channel_name_get, /* spu_channel_name_get */
214 em_spu_channel_mute_set, /* spu_channel_mute_set */
215 em_spu_channel_mute_get, /* spu_channel_mute_get */
216 em_chapter_count, /* chapter_count */
217 em_chapter_set, /* chapter_set */
218 em_chapter_get, /* chapter_get */
219 em_chapter_name_get, /* chapter_name_get */
220 em_speed_set, /* speed_set */
221 em_speed_get, /* speed_get */
222 em_eject, /* eject */
223 em_meta_get, /* meta_get */
229 em_init(Evas_Object *obj,
230 void **emotion_video,
231 Emotion_Module_Options *opt)
233 Emotion_Gstreamer_Video *ev;
240 printf ("Init gstreamer...\n");
242 ev = calloc(1, sizeof(Emotion_Gstreamer_Video));
248 /* Initialization of gstreamer */
249 if (!gst_init_check (NULL, NULL, &error))
250 goto failure_gstreamer;
252 ev->pipeline = gst_pipeline_new ("pipeline");
254 goto failure_pipeline;
256 ev->eos_bus = gst_pipeline_get_bus (GST_PIPELINE (ev->pipeline));
260 /* We allocate the sinks lists */
261 ev->video_sinks = ecore_list_new ();
262 if (!ev->video_sinks)
263 goto failure_video_sinks;
264 ecore_list_free_cb_set(ev->video_sinks, ECORE_FREE_CB(free));
265 ev->audio_sinks = ecore_list_new ();
266 if (!ev->audio_sinks)
267 goto failure_audio_sinks;
268 ecore_list_free_cb_set(ev->audio_sinks, ECORE_FREE_CB(free));
274 ev->video_sink_nbr = 0;
275 ev->audio_sink_nbr = 0;
276 ev->vis = EMOTION_VIS_GOOM;
278 /* Create the file descriptors */
279 if (pipe(fds) == 0) {
280 ev->fd_ev_read = fds[0];
281 ev->fd_ev_write = fds[1];
282 fcntl(ev->fd_ev_read, F_SETFL, O_NONBLOCK);
283 ev->fd_ev_handler = ecore_main_fd_handler_add(ev->fd_ev_read,
288 ecore_main_fd_handler_active_set(ev->fd_ev_handler, ECORE_FD_READ);
296 ecore_list_destroy (ev->audio_sinks);
298 ecore_list_destroy (ev->video_sinks);
300 gst_object_unref (GST_OBJECT (ev->eos_bus));
302 /* this call is not really necessary */
303 gst_element_set_state (ev->pipeline, GST_STATE_NULL);
304 gst_object_unref (GST_OBJECT (ev->pipeline));
314 em_shutdown(void *video)
316 Emotion_Gstreamer_Video *ev;
318 ev = (Emotion_Gstreamer_Video *)video;
322 gst_element_set_state (ev->pipeline, GST_STATE_NULL);
323 gst_object_unref (GST_OBJECT (ev->pipeline));
324 gst_object_unref (GST_OBJECT (ev->eos_bus));
327 ecore_list_destroy (ev->video_sinks);
328 ecore_list_destroy (ev->audio_sinks);
330 /* FIXME: and the evas object ? */
332 ecore_main_fd_handler_del(ev->fd_ev_handler);
333 close(ev->fd_ev_write);
334 close(ev->fd_ev_read);
342 em_file_open(const char *file,
346 Emotion_Gstreamer_Video *ev;
348 ev = (Emotion_Gstreamer_Video *)video;
354 if (strstr (file,"cdda://")) {
355 const char *device = NULL;
356 unsigned int track = 1;
358 device = file + strlen ("cdda://");
359 if (device[0] == '/') {
362 if ((tmp = strchr (device, '?')) || (tmp = strchr (device, '#'))) {
363 sscanf (tmp + 1,"%d", &track);
369 sscanf (file,"cdda://%d", &track);
371 fprintf (stderr, "[Emotion] [gst] build CD Audio pipeline\n");
372 if (!(emotion_pipeline_cdda_build (ev, device, track))) {
373 fprintf (stderr, "[Emotion] [gst] error while building CD Audio pipeline\n");
378 else if (strstr (file, "dvd://")) {
380 fprintf (stderr, "[Emotion] [gst] build DVD pipeline \n");
381 if (!(emotion_pipeline_dvd_build (ev, NULL))) {
382 fprintf (stderr, "[Emotion] [gst] error while building DVD pipeline\n");
387 else if (strstr (file, "http://")) {
388 fprintf (stderr, "[Emotion] [gst] build URI pipeline \n");
389 if (!(emotion_pipeline_uri_build (ev, file))) {
390 fprintf (stderr, "[Emotion] [gst] error while building URI pipeline\n");
394 /* Normal media file */
396 const char *filename;
398 filename = strstr (file, "file://")
399 ? file + strlen ("file://")
402 fprintf (stderr, "[Emotion] [gst] build file pipeline \n");
403 if (!(emotion_pipeline_file_build (ev, filename))) {
404 fprintf (stderr, "[Emotion] [gst] error while building File pipeline\n");
412 /* on recapitule : */
413 Emotion_Video_Sink *vsink;
414 Emotion_Audio_Sink *asink;
416 vsink = (Emotion_Video_Sink *)ecore_list_first_goto (ev->video_sinks);
418 g_print ("video : \n");
419 g_print (" size : %dx%d\n", vsink->width, vsink->height);
420 g_print (" fps : %d/%d\n", vsink->fps_num, vsink->fps_den);
421 g_print (" fourcc : %" GST_FOURCC_FORMAT "\n", GST_FOURCC_ARGS (vsink->fourcc));
422 g_print (" length : %" GST_TIME_FORMAT "\n\n",
423 GST_TIME_ARGS ((guint64)(vsink->length_time * GST_SECOND)));
426 asink = (Emotion_Audio_Sink *)ecore_list_first_goto (ev->audio_sinks);
428 g_print ("audio : \n");
429 g_print (" chan : %d\n", asink->channels);
430 g_print (" rate : %d\n", asink->samplerate);
431 g_print (" length : %" GST_TIME_FORMAT "\n\n",
432 GST_TIME_ARGS ((guint64)(asink->length_time * GST_SECOND)));
440 em_file_close(void *video)
442 Emotion_Gstreamer_Video *ev;
447 ev = (Emotion_Gstreamer_Video *)video;
451 printf("EX pause end...\n");
452 if (!emotion_object_play_get(ev->obj))
454 printf(" ... unpause\n");
455 emotion_pipeline_pause (ev->pipeline);
459 gst_element_set_state (ev->pipeline, GST_STATE_READY);
461 /* we remove all the elements in the pipeline */
462 iter = gst_bin_iterate_elements (GST_BIN (ev->pipeline));
465 switch (gst_iterator_next (iter, &data)) {
466 case GST_ITERATOR_OK: {
469 element = GST_ELEMENT (data);
471 gst_bin_remove (GST_BIN (ev->pipeline), element);
475 case GST_ITERATOR_RESYNC: {
478 element = GST_ELEMENT (data);
480 gst_bin_remove (GST_BIN (ev->pipeline), element);
482 gst_iterator_resync (iter);
485 case GST_ITERATOR_ERROR:
486 printf("error iter\n");
489 case GST_ITERATOR_DONE:
494 gst_iterator_free (iter);
496 /* we clear the sink lists */
497 ecore_list_clear (ev->video_sinks);
498 ecore_list_clear (ev->audio_sinks);
502 ecore_timer_del (ev->eos_timer);
503 ev->eos_timer = NULL;
511 Emotion_Gstreamer_Video *ev;
513 ev = (Emotion_Gstreamer_Video *)video;
514 gst_element_set_state (ev->pipeline, GST_STATE_PLAYING);
518 ev->eos_timer = ecore_timer_add (0.1, _eos_timer_fct, ev);
524 Emotion_Gstreamer_Video *ev;
526 ev = (Emotion_Gstreamer_Video *)video;
528 gst_element_set_state (ev->pipeline, GST_STATE_PAUSED);
533 ecore_timer_del (ev->eos_timer);
534 ev->eos_timer = NULL;
539 em_size_get(void *video,
543 Emotion_Gstreamer_Video *ev;
544 Emotion_Video_Sink *vsink;
546 ev = (Emotion_Gstreamer_Video *)video;
548 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
550 if (width) *width = vsink->width;
551 if (height) *height = vsink->height;
554 if (width) *width = 0;
555 if (height) *height = 0;
560 em_pos_set(void *video,
563 Emotion_Gstreamer_Video *ev;
564 Emotion_Video_Sink *vsink;
565 Emotion_Audio_Sink *asink;
567 ev = (Emotion_Gstreamer_Video *)video;
569 if (ev->seek_to_pos == pos) return;
571 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
572 asink = (Emotion_Audio_Sink *)ecore_list_index_goto (ev->video_sinks, ev->audio_sink_nbr);
575 gst_element_seek(vsink->sink, 1.0,
577 GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH,
579 (gint64)(pos * (double)GST_SECOND),
584 gst_element_seek(asink->sink, 1.0,
586 GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH,
588 (gint64)(pos * (double)GST_SECOND),
592 ev->seek_to_pos = pos;
596 em_vis_set(void *video,
599 Emotion_Gstreamer_Video *ev;
601 ev = (Emotion_Gstreamer_Video *)video;
603 if (ev->vis == vis) return;
608 em_len_get(void *video)
610 Emotion_Gstreamer_Video *ev;
611 Emotion_Video_Sink *vsink;
613 ev = (Emotion_Gstreamer_Video *)video;
615 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
617 return (double)vsink->length_time;
623 em_fps_num_get(void *video)
625 Emotion_Gstreamer_Video *ev;
626 Emotion_Video_Sink *vsink;
628 ev = (Emotion_Gstreamer_Video *)video;
630 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
632 return vsink->fps_num;
638 em_fps_den_get(void *video)
640 Emotion_Gstreamer_Video *ev;
641 Emotion_Video_Sink *vsink;
643 ev = (Emotion_Gstreamer_Video *)video;
645 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
647 return vsink->fps_den;
653 em_fps_get(void *video)
655 Emotion_Gstreamer_Video *ev;
656 Emotion_Video_Sink *vsink;
658 ev = (Emotion_Gstreamer_Video *)video;
660 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
662 return (double)vsink->fps_num / (double)vsink->fps_den;
668 em_pos_get(void *video)
670 Emotion_Gstreamer_Video *ev;
672 ev = (Emotion_Gstreamer_Video *)video;
678 em_vis_get(void *video)
680 Emotion_Gstreamer_Video *ev;
682 ev = (Emotion_Gstreamer_Video *)video;
688 em_ratio_get(void *video)
690 Emotion_Gstreamer_Video *ev;
692 ev = (Emotion_Gstreamer_Video *)video;
698 em_video_handled(void *video)
700 Emotion_Gstreamer_Video *ev;
702 ev = (Emotion_Gstreamer_Video *)video;
704 if (ecore_list_empty_is (ev->video_sinks))
711 em_audio_handled(void *video)
713 Emotion_Gstreamer_Video *ev;
715 ev = (Emotion_Gstreamer_Video *)video;
717 if (ecore_list_empty_is (ev->audio_sinks))
724 em_seekable(void *video)
726 Emotion_Gstreamer_Video *ev;
728 ev = (Emotion_Gstreamer_Video *)video;
734 em_frame_done(void *video)
736 Emotion_Gstreamer_Video *ev;
738 ev = (Emotion_Gstreamer_Video *)video;
741 static Emotion_Format
742 em_format_get (void *video)
744 Emotion_Gstreamer_Video *ev;
745 Emotion_Video_Sink *vsink;
747 ev = (Emotion_Gstreamer_Video *)video;
749 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
751 switch (vsink->fourcc) {
752 case GST_MAKE_FOURCC ('I','4','2','0'):
753 return EMOTION_FORMAT_I420;
754 case GST_MAKE_FOURCC ('Y','V','1','2'):
755 return EMOTION_FORMAT_YV12;
756 case GST_MAKE_FOURCC ('Y','U','Y','2'):
757 return EMOTION_FORMAT_YUY2;
758 case GST_MAKE_FOURCC ('A','R','G','B'):
759 return EMOTION_FORMAT_BGRA;
761 return EMOTION_FORMAT_NONE;
764 return EMOTION_FORMAT_NONE;
768 em_video_data_size_get(void *video, int *w, int *h)
770 Emotion_Gstreamer_Video *ev;
771 Emotion_Video_Sink *vsink;
773 ev = (Emotion_Gstreamer_Video *)video;
775 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
787 em_yuv_rows_get(void *video,
790 unsigned char **yrows,
791 unsigned char **urows,
792 unsigned char **vrows)
794 Emotion_Gstreamer_Video *ev;
797 ev = (Emotion_Gstreamer_Video *)video;
801 if (em_format_get(video) == EMOTION_FORMAT_I420) {
802 for (i = 0; i < h; i++)
803 yrows[i] = &ev->obj_data[i * w];
805 for (i = 0; i < (h / 2); i++)
806 urows[i] = &ev->obj_data[h * w + i * (w / 2) ];
808 for (i = 0; i < (h / 2); i++)
809 vrows[i] = &ev->obj_data[h * w + h * (w /4) + i * (w / 2)];
811 else if (em_format_get(video) == EMOTION_FORMAT_YV12) {
812 for (i = 0; i < h; i++)
813 yrows[i] = &ev->obj_data[i * w];
815 for (i = 0; i < (h / 2); i++)
816 vrows[i] = &ev->obj_data[h * w + i * (w / 2) ];
818 for (i = 0; i < (h / 2); i++)
819 urows[i] = &ev->obj_data[h * w + h * (w /4) + i * (w / 2)];
831 em_bgra_data_get(void *video, unsigned char **bgra_data)
833 Emotion_Gstreamer_Video *ev;
835 ev = (Emotion_Gstreamer_Video *)video;
837 if (ev->obj_data && em_format_get(video) == EMOTION_FORMAT_BGRA) {
838 *bgra_data = ev->obj_data;
845 em_event_feed(void *video, int event)
847 Emotion_Gstreamer_Video *ev;
849 ev = (Emotion_Gstreamer_Video *)video;
853 em_event_mouse_button_feed(void *video, int button, int x, int y)
855 Emotion_Gstreamer_Video *ev;
857 ev = (Emotion_Gstreamer_Video *)video;
861 em_event_mouse_move_feed(void *video, int x, int y)
863 Emotion_Gstreamer_Video *ev;
865 ev = (Emotion_Gstreamer_Video *)video;
870 em_video_channel_count(void *video)
872 Emotion_Gstreamer_Video *ev;
874 ev = (Emotion_Gstreamer_Video *)video;
876 return ecore_list_count(ev->video_sinks);
880 em_video_channel_set(void *video,
883 Emotion_Gstreamer_Video *ev;
885 ev = (Emotion_Gstreamer_Video *)video;
887 if (channel < 0) channel = 0;
888 /* FIXME: a faire... */
892 em_video_channel_get(void *video)
894 Emotion_Gstreamer_Video *ev;
896 ev = (Emotion_Gstreamer_Video *)video;
898 return ev->video_sink_nbr;
902 em_video_channel_name_get(void *video,
905 Emotion_Gstreamer_Video *ev;
907 ev = (Emotion_Gstreamer_Video *)video;
913 em_video_channel_mute_set(void *video,
916 Emotion_Gstreamer_Video *ev;
918 ev = (Emotion_Gstreamer_Video *)video;
920 ev->video_mute = mute;
924 em_video_channel_mute_get(void *video)
926 Emotion_Gstreamer_Video *ev;
928 ev = (Emotion_Gstreamer_Video *)video;
930 return ev->video_mute;
936 em_audio_channel_count(void *video)
938 Emotion_Gstreamer_Video *ev;
940 ev = (Emotion_Gstreamer_Video *)video;
942 return ecore_list_count(ev->audio_sinks);
946 em_audio_channel_set(void *video,
949 Emotion_Gstreamer_Video *ev;
951 ev = (Emotion_Gstreamer_Video *)video;
953 if (channel < -1) channel = -1;
954 /* FIXME: a faire... */
958 em_audio_channel_get(void *video)
960 Emotion_Gstreamer_Video *ev;
962 ev = (Emotion_Gstreamer_Video *)video;
964 return ev->audio_sink_nbr;
968 em_audio_channel_name_get(void *video,
971 Emotion_Gstreamer_Video *ev;
973 ev = (Emotion_Gstreamer_Video *)video;
979 em_audio_channel_mute_set(void *video,
982 Emotion_Gstreamer_Video *ev;
985 ev = (Emotion_Gstreamer_Video *)video;
987 if (ev->audio_mute == mute)
990 ev->audio_mute = mute;
991 volume = gst_bin_get_by_name (GST_BIN (ev->pipeline), "volume");
995 g_object_set (G_OBJECT (volume), "volume", 0.0, NULL);
997 g_object_set (G_OBJECT (volume), "volume", ev->volume * 10.0, NULL);
999 gst_object_unref (volume);
1003 em_audio_channel_mute_get(void *video)
1005 Emotion_Gstreamer_Video *ev;
1007 ev = (Emotion_Gstreamer_Video *)video;
1009 return ev->audio_mute;
1013 em_audio_channel_volume_set(void *video,
1016 Emotion_Gstreamer_Video *ev;
1019 ev = (Emotion_Gstreamer_Video *)video;
1026 volume = gst_bin_get_by_name (GST_BIN (ev->pipeline), "volume");
1027 if (!volume) return;
1028 g_object_set (G_OBJECT (volume), "volume",
1030 gst_object_unref (volume);
1034 em_audio_channel_volume_get(void *video)
1036 Emotion_Gstreamer_Video *ev;
1038 ev = (Emotion_Gstreamer_Video *)video;
1046 em_spu_channel_count(void *video)
1048 Emotion_Gstreamer_Video *ev;
1050 ev = (Emotion_Gstreamer_Video *)video;
1056 em_spu_channel_set(void *video, int channel)
1058 Emotion_Gstreamer_Video *ev;
1060 ev = (Emotion_Gstreamer_Video *)video;
1064 em_spu_channel_get(void *video)
1066 Emotion_Gstreamer_Video *ev;
1068 ev = (Emotion_Gstreamer_Video *)video;
1074 em_spu_channel_name_get(void *video, int channel)
1076 Emotion_Gstreamer_Video *ev;
1078 ev = (Emotion_Gstreamer_Video *)video;
1083 em_spu_channel_mute_set(void *video, int mute)
1085 Emotion_Gstreamer_Video *ev;
1087 ev = (Emotion_Gstreamer_Video *)video;
1091 em_spu_channel_mute_get(void *video)
1093 Emotion_Gstreamer_Video *ev;
1095 ev = (Emotion_Gstreamer_Video *)video;
1101 em_chapter_count(void *video)
1103 Emotion_Gstreamer_Video *ev;
1105 ev = (Emotion_Gstreamer_Video *)video;
1110 em_chapter_set(void *video, int chapter)
1112 Emotion_Gstreamer_Video *ev;
1114 ev = (Emotion_Gstreamer_Video *)video;
1118 em_chapter_get(void *video)
1120 Emotion_Gstreamer_Video *ev;
1122 ev = (Emotion_Gstreamer_Video *)video;
1128 em_chapter_name_get(void *video, int chapter)
1130 Emotion_Gstreamer_Video *ev;
1132 ev = (Emotion_Gstreamer_Video *)video;
1138 em_speed_set(void *video, double speed)
1140 Emotion_Gstreamer_Video *ev;
1142 ev = (Emotion_Gstreamer_Video *)video;
1146 em_speed_get(void *video)
1148 Emotion_Gstreamer_Video *ev;
1150 ev = (Emotion_Gstreamer_Video *)video;
1156 em_eject(void *video)
1158 Emotion_Gstreamer_Video *ev;
1160 ev = (Emotion_Gstreamer_Video *)video;
1166 em_meta_get(void *video, int meta)
1168 Emotion_Gstreamer_Video *ev;
1173 ev = (Emotion_Gstreamer_Video *)video;
1174 if (!ev) return NULL;
1177 bus = gst_element_get_bus (ev->pipeline);
1178 if (!bus) return NULL;
1181 GstMessage *message;
1183 message = gst_bus_pop (bus);
1184 if (message == NULL)
1185 /* All messages read, we're done */
1188 switch (GST_MESSAGE_TYPE (message)) {
1189 case GST_MESSAGE_TAG: {
1190 GstTagList *new_tags;
1192 gst_message_parse_tag (message, &new_tags);
1195 case META_TRACK_TITLE:
1196 gst_tag_list_get_string (new_tags, GST_TAG_TITLE, &str);
1197 if (str) done = TRUE;
1199 case META_TRACK_ARTIST:
1200 gst_tag_list_get_string (new_tags, GST_TAG_ARTIST, &str);
1201 if (str) done = TRUE;
1203 case META_TRACK_GENRE:
1204 gst_tag_list_get_string (new_tags, GST_TAG_GENRE, &str);
1205 if (str) done = TRUE;
1207 case META_TRACK_COMMENT:
1208 gst_tag_list_get_string (new_tags, GST_TAG_COMMENT, &str);
1209 if (str) done = TRUE;
1211 case META_TRACK_ALBUM:
1212 gst_tag_list_get_string (new_tags, GST_TAG_ALBUM, &str);
1213 if (str) done = TRUE;
1215 case META_TRACK_YEAR: {
1218 date = gst_tag_list_get_value_index (new_tags, GST_TAG_DATE, 0);
1220 str = g_strdup_value_contents (date);
1221 if (str) done = TRUE;
1224 case META_TRACK_DISCID:
1225 #ifdef GST_TAG_CDDA_CDDB_DISCID
1226 gst_tag_list_get_string (new_tags, GST_TAG_CDDA_CDDB_DISCID, &str);
1228 if (str) done = TRUE;
1230 case META_TRACK_COUNT: {
1233 track_count = emotion_pipeline_cdda_track_count_get (video);
1234 if (track_count > 0) {
1237 g_snprintf (buf, 64, "%d", track_count);
1238 str = g_strdup (buf);
1249 gst_message_unref (message);
1252 gst_object_unref (GST_OBJECT (bus));
1258 module_open(Evas_Object *obj,
1259 Emotion_Video_Module **module,
1261 Emotion_Module_Options *opt)
1266 if (!em_module.init(obj, video, opt))
1269 *module = &em_module;
1274 module_close(Emotion_Video_Module *module,
1277 em_module.shutdown(video);
1281 _em_fd_ev_active(void *data, Ecore_Fd_Handler *fdh)
1286 unsigned char *frame_data;
1287 Emotion_Gstreamer_Video *ev;
1291 fd = ecore_main_fd_handler_fd_get(fdh);
1293 while ((len = read(fd, buf, sizeof(buf))) > 0)
1295 if (len == sizeof(buf))
1297 Emotion_Video_Sink *vsink;
1299 frame_data = buf[0];
1301 _emotion_frame_new(ev->obj);
1302 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
1303 _emotion_video_pos_update(ev->obj, ev->position, vsink->length_time);
1309 int _eos_timer_fct (void *data)
1311 Emotion_Gstreamer_Video *ev;
1314 ev = (Emotion_Gstreamer_Video *)data;
1315 while ((msg = gst_bus_poll (ev->eos_bus, GST_MESSAGE_ERROR | GST_MESSAGE_EOS, 0))) {
1316 switch (GST_MESSAGE_TYPE(msg)) {
1317 case GST_MESSAGE_ERROR: {
1321 gst_message_parse_error (msg, &err, &debug);
1324 g_print ("Error: %s\n", err->message);
1329 case GST_MESSAGE_EOS:
1332 ecore_timer_del(ev->eos_timer);
1333 ev->eos_timer = NULL;
1336 _emotion_decode_stop(ev->obj);
1337 _emotion_playback_finished(ev->obj);
1342 gst_message_unref (msg);