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 */
227 em_init(Evas_Object *obj,
228 void **emotion_video,
229 Emotion_Module_Options *opt)
231 Emotion_Gstreamer_Video *ev;
238 printf ("Init gstreamer...\n");
240 ev = calloc(1, sizeof(Emotion_Gstreamer_Video));
246 /* Initialization of gstreamer */
247 if (!gst_init_check (NULL, NULL, &error))
248 goto failure_gstreamer;
250 ev->pipeline = gst_pipeline_new ("pipeline");
252 goto failure_pipeline;
254 ev->eos_bus = gst_pipeline_get_bus (GST_PIPELINE (ev->pipeline));
258 /* We allocate the sinks lists */
259 ev->video_sinks = ecore_list_new ();
260 if (!ev->video_sinks)
261 goto failure_video_sinks;
262 ecore_list_free_cb_set(ev->video_sinks, ECORE_FREE_CB(free));
263 ev->audio_sinks = ecore_list_new ();
264 if (!ev->audio_sinks)
265 goto failure_audio_sinks;
266 ecore_list_free_cb_set(ev->audio_sinks, ECORE_FREE_CB(free));
272 ev->video_sink_nbr = 0;
273 ev->audio_sink_nbr = 0;
274 ev->vis = EMOTION_VIS_GOOM;
276 /* Create the file descriptors */
277 if (pipe(fds) == 0) {
278 ev->fd_ev_read = fds[0];
279 ev->fd_ev_write = fds[1];
280 fcntl(ev->fd_ev_read, F_SETFL, O_NONBLOCK);
281 ev->fd_ev_handler = ecore_main_fd_handler_add(ev->fd_ev_read,
286 ecore_main_fd_handler_active_set(ev->fd_ev_handler, ECORE_FD_READ);
294 ecore_list_destroy (ev->audio_sinks);
296 ecore_list_destroy (ev->video_sinks);
298 gst_object_unref (GST_OBJECT (ev->eos_bus));
300 /* this call is not really necessary */
301 gst_element_set_state (ev->pipeline, GST_STATE_NULL);
302 gst_object_unref (GST_OBJECT (ev->pipeline));
312 em_shutdown(void *video)
314 Emotion_Gstreamer_Video *ev;
316 ev = (Emotion_Gstreamer_Video *)video;
320 gst_element_set_state (ev->pipeline, GST_STATE_NULL);
321 gst_object_unref (GST_OBJECT (ev->pipeline));
322 gst_object_unref (GST_OBJECT (ev->eos_bus));
325 ecore_list_destroy (ev->video_sinks);
326 ecore_list_destroy (ev->audio_sinks);
328 /* FIXME: and the evas object ? */
330 ecore_main_fd_handler_del(ev->fd_ev_handler);
331 close(ev->fd_ev_write);
332 close(ev->fd_ev_read);
340 em_file_open(const char *file,
344 Emotion_Gstreamer_Video *ev;
346 ev = (Emotion_Gstreamer_Video *)video;
352 if (strstr (file,"cdda://")) {
353 const char *device = NULL;
354 unsigned int track = 1;
356 device = file + strlen ("cdda://");
357 if (device[0] == '/') {
360 if ((tmp = strchr (device, '?')) || (tmp = strchr (device, '#'))) {
361 sscanf (tmp + 1,"%d", &track);
367 sscanf (file,"cdda://%d", &track);
369 fprintf (stderr, "[Emotion] [gst] build CD Audio pipeline\n");
370 if (!(emotion_pipeline_cdda_build (ev, device, track))) {
371 fprintf (stderr, "[Emotion] [gst] error while building CD Audio pipeline\n");
376 else if (strstr (file, "dvd://")) {
378 fprintf (stderr, "[Emotion] [gst] build DVD pipeline \n");
379 if (!(emotion_pipeline_dvd_build (ev, NULL))) {
380 fprintf (stderr, "[Emotion] [gst] error while building DVD pipeline\n");
385 else if (strstr (file, "http://")) {
386 fprintf (stderr, "[Emotion] [gst] build URI pipeline \n");
387 if (!(emotion_pipeline_uri_build (ev, file))) {
388 fprintf (stderr, "[Emotion] [gst] error while building URI pipeline\n");
392 /* Normal media file */
394 const char *filename;
396 filename = strstr (file, "file://")
397 ? file + strlen ("file://")
400 fprintf (stderr, "[Emotion] [gst] build file pipeline \n");
401 if (!(emotion_pipeline_file_build (ev, filename))) {
402 fprintf (stderr, "[Emotion] [gst] error while building File pipeline\n");
410 /* on recapitule : */
411 Emotion_Video_Sink *vsink;
412 Emotion_Audio_Sink *asink;
414 vsink = (Emotion_Video_Sink *)ecore_list_first_goto (ev->video_sinks);
416 g_print ("video : \n");
417 g_print (" size : %dx%d\n", vsink->width, vsink->height);
418 g_print (" fps : %d/%d\n", vsink->fps_num, vsink->fps_den);
419 g_print (" fourcc : %" GST_FOURCC_FORMAT "\n", GST_FOURCC_ARGS (vsink->fourcc));
420 g_print (" length : %" GST_TIME_FORMAT "\n\n",
421 GST_TIME_ARGS ((guint64)(vsink->length_time * GST_SECOND)));
424 asink = (Emotion_Audio_Sink *)ecore_list_first_goto (ev->audio_sinks);
426 g_print ("audio : \n");
427 g_print (" chan : %d\n", asink->channels);
428 g_print (" rate : %d\n", asink->samplerate);
429 g_print (" length : %" GST_TIME_FORMAT "\n\n",
430 GST_TIME_ARGS ((guint64)(asink->length_time * GST_SECOND)));
438 em_file_close(void *video)
440 Emotion_Gstreamer_Video *ev;
445 ev = (Emotion_Gstreamer_Video *)video;
449 printf("EX pause end...\n");
450 if (!emotion_object_play_get(ev->obj))
452 printf(" ... unpause\n");
453 emotion_pipeline_pause (ev->pipeline);
457 gst_element_set_state (ev->pipeline, GST_STATE_READY);
459 /* we remove all the elements in the pipeline */
460 iter = gst_bin_iterate_elements (GST_BIN (ev->pipeline));
463 switch (gst_iterator_next (iter, &data)) {
464 case GST_ITERATOR_OK: {
467 element = GST_ELEMENT (data);
469 gst_bin_remove (GST_BIN (ev->pipeline), element);
473 case GST_ITERATOR_RESYNC: {
476 element = GST_ELEMENT (data);
478 gst_bin_remove (GST_BIN (ev->pipeline), element);
480 gst_iterator_resync (iter);
483 case GST_ITERATOR_ERROR:
484 printf("error iter\n");
487 case GST_ITERATOR_DONE:
492 gst_iterator_free (iter);
494 /* we clear the sink lists */
495 ecore_list_clear (ev->video_sinks);
496 ecore_list_clear (ev->audio_sinks);
500 ecore_timer_del (ev->eos_timer);
501 ev->eos_timer = NULL;
509 Emotion_Gstreamer_Video *ev;
511 ev = (Emotion_Gstreamer_Video *)video;
512 gst_element_set_state (ev->pipeline, GST_STATE_PLAYING);
516 ev->eos_timer = ecore_timer_add (0.1, _eos_timer_fct, ev);
522 Emotion_Gstreamer_Video *ev;
524 ev = (Emotion_Gstreamer_Video *)video;
526 gst_element_set_state (ev->pipeline, GST_STATE_PAUSED);
531 ecore_timer_del (ev->eos_timer);
532 ev->eos_timer = NULL;
537 em_size_get(void *video,
541 Emotion_Gstreamer_Video *ev;
542 Emotion_Video_Sink *vsink;
544 ev = (Emotion_Gstreamer_Video *)video;
546 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
548 if (width) *width = vsink->width;
549 if (height) *height = vsink->height;
552 if (width) *width = 0;
553 if (height) *height = 0;
558 em_pos_set(void *video,
561 Emotion_Gstreamer_Video *ev;
562 Emotion_Video_Sink *vsink;
563 Emotion_Audio_Sink *asink;
565 ev = (Emotion_Gstreamer_Video *)video;
567 if (ev->seek_to_pos == pos) return;
569 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
570 asink = (Emotion_Audio_Sink *)ecore_list_index_goto (ev->video_sinks, ev->audio_sink_nbr);
573 gst_element_seek(vsink->sink, 1.0,
575 GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH,
577 (gint64)(pos * (double)GST_SECOND),
582 gst_element_seek(asink->sink, 1.0,
584 GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH,
586 (gint64)(pos * (double)GST_SECOND),
590 ev->seek_to_pos = pos;
594 em_vis_set(void *video,
597 Emotion_Gstreamer_Video *ev;
599 ev = (Emotion_Gstreamer_Video *)video;
601 if (ev->vis == vis) return;
606 em_len_get(void *video)
608 Emotion_Gstreamer_Video *ev;
609 Emotion_Video_Sink *vsink;
611 ev = (Emotion_Gstreamer_Video *)video;
613 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
615 return (double)vsink->length_time;
621 em_fps_num_get(void *video)
623 Emotion_Gstreamer_Video *ev;
624 Emotion_Video_Sink *vsink;
626 ev = (Emotion_Gstreamer_Video *)video;
628 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
630 return vsink->fps_num;
636 em_fps_den_get(void *video)
638 Emotion_Gstreamer_Video *ev;
639 Emotion_Video_Sink *vsink;
641 ev = (Emotion_Gstreamer_Video *)video;
643 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
645 return vsink->fps_den;
651 em_fps_get(void *video)
653 Emotion_Gstreamer_Video *ev;
654 Emotion_Video_Sink *vsink;
656 ev = (Emotion_Gstreamer_Video *)video;
658 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
660 return (double)vsink->fps_num / (double)vsink->fps_den;
666 em_pos_get(void *video)
668 Emotion_Gstreamer_Video *ev;
670 ev = (Emotion_Gstreamer_Video *)video;
676 em_vis_get(void *video)
678 Emotion_Gstreamer_Video *ev;
680 ev = (Emotion_Gstreamer_Video *)video;
686 em_ratio_get(void *video)
688 Emotion_Gstreamer_Video *ev;
690 ev = (Emotion_Gstreamer_Video *)video;
696 em_video_handled(void *video)
698 Emotion_Gstreamer_Video *ev;
700 ev = (Emotion_Gstreamer_Video *)video;
702 if (ecore_list_empty_is (ev->video_sinks))
709 em_audio_handled(void *video)
711 Emotion_Gstreamer_Video *ev;
713 ev = (Emotion_Gstreamer_Video *)video;
715 if (ecore_list_empty_is (ev->audio_sinks))
722 em_seekable(void *video)
724 Emotion_Gstreamer_Video *ev;
726 ev = (Emotion_Gstreamer_Video *)video;
732 em_frame_done(void *video)
734 Emotion_Gstreamer_Video *ev;
736 ev = (Emotion_Gstreamer_Video *)video;
739 static Emotion_Format
740 em_format_get (void *video)
742 Emotion_Gstreamer_Video *ev;
743 Emotion_Video_Sink *vsink;
745 ev = (Emotion_Gstreamer_Video *)video;
747 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
749 switch (vsink->fourcc) {
750 case GST_MAKE_FOURCC ('I','4','2','0'):
751 return EMOTION_FORMAT_I420;
752 case GST_MAKE_FOURCC ('Y','V','1','2'):
753 return EMOTION_FORMAT_YV12;
754 case GST_MAKE_FOURCC ('Y','U','Y','2'):
755 return EMOTION_FORMAT_YUY2;
756 case GST_MAKE_FOURCC ('A','R','G','B'):
757 return EMOTION_FORMAT_BGRA;
759 return EMOTION_FORMAT_NONE;
762 return EMOTION_FORMAT_NONE;
766 em_video_data_size_get(void *video, int *w, int *h)
768 Emotion_Gstreamer_Video *ev;
769 Emotion_Video_Sink *vsink;
771 ev = (Emotion_Gstreamer_Video *)video;
773 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
785 em_yuv_rows_get(void *video,
788 unsigned char **yrows,
789 unsigned char **urows,
790 unsigned char **vrows)
792 Emotion_Gstreamer_Video *ev;
795 ev = (Emotion_Gstreamer_Video *)video;
799 if (em_format_get(video) == EMOTION_FORMAT_I420) {
800 for (i = 0; i < h; i++)
801 yrows[i] = &ev->obj_data[i * w];
803 for (i = 0; i < (h / 2); i++)
804 urows[i] = &ev->obj_data[h * w + i * (w / 2) ];
806 for (i = 0; i < (h / 2); i++)
807 vrows[i] = &ev->obj_data[h * w + h * (w /4) + i * (w / 2)];
809 else if (em_format_get(video) == EMOTION_FORMAT_YV12) {
810 for (i = 0; i < h; i++)
811 yrows[i] = &ev->obj_data[i * w];
813 for (i = 0; i < (h / 2); i++)
814 vrows[i] = &ev->obj_data[h * w + i * (w / 2) ];
816 for (i = 0; i < (h / 2); i++)
817 urows[i] = &ev->obj_data[h * w + h * (w /4) + i * (w / 2)];
829 em_bgra_data_get(void *video, unsigned char **bgra_data)
831 Emotion_Gstreamer_Video *ev;
833 ev = (Emotion_Gstreamer_Video *)video;
835 if (ev->obj_data && em_format_get(video) == EMOTION_FORMAT_BGRA) {
836 *bgra_data = ev->obj_data;
843 em_event_feed(void *video, int event)
845 Emotion_Gstreamer_Video *ev;
847 ev = (Emotion_Gstreamer_Video *)video;
851 em_event_mouse_button_feed(void *video, int button, int x, int y)
853 Emotion_Gstreamer_Video *ev;
855 ev = (Emotion_Gstreamer_Video *)video;
859 em_event_mouse_move_feed(void *video, int x, int y)
861 Emotion_Gstreamer_Video *ev;
863 ev = (Emotion_Gstreamer_Video *)video;
868 em_video_channel_count(void *video)
870 Emotion_Gstreamer_Video *ev;
872 ev = (Emotion_Gstreamer_Video *)video;
874 return ecore_list_count(ev->video_sinks);
878 em_video_channel_set(void *video,
881 Emotion_Gstreamer_Video *ev;
883 ev = (Emotion_Gstreamer_Video *)video;
885 if (channel < 0) channel = 0;
886 /* FIXME: a faire... */
890 em_video_channel_get(void *video)
892 Emotion_Gstreamer_Video *ev;
894 ev = (Emotion_Gstreamer_Video *)video;
896 return ev->video_sink_nbr;
900 em_video_channel_name_get(void *video,
903 Emotion_Gstreamer_Video *ev;
905 ev = (Emotion_Gstreamer_Video *)video;
911 em_video_channel_mute_set(void *video,
914 Emotion_Gstreamer_Video *ev;
916 ev = (Emotion_Gstreamer_Video *)video;
918 ev->video_mute = mute;
922 em_video_channel_mute_get(void *video)
924 Emotion_Gstreamer_Video *ev;
926 ev = (Emotion_Gstreamer_Video *)video;
928 return ev->video_mute;
934 em_audio_channel_count(void *video)
936 Emotion_Gstreamer_Video *ev;
938 ev = (Emotion_Gstreamer_Video *)video;
940 return ecore_list_count(ev->audio_sinks);
944 em_audio_channel_set(void *video,
947 Emotion_Gstreamer_Video *ev;
949 ev = (Emotion_Gstreamer_Video *)video;
951 if (channel < -1) channel = -1;
952 /* FIXME: a faire... */
956 em_audio_channel_get(void *video)
958 Emotion_Gstreamer_Video *ev;
960 ev = (Emotion_Gstreamer_Video *)video;
962 return ev->audio_sink_nbr;
966 em_audio_channel_name_get(void *video,
969 Emotion_Gstreamer_Video *ev;
971 ev = (Emotion_Gstreamer_Video *)video;
977 em_audio_channel_mute_set(void *video,
980 Emotion_Gstreamer_Video *ev;
983 ev = (Emotion_Gstreamer_Video *)video;
985 if (ev->audio_mute == mute)
988 ev->audio_mute = mute;
989 volume = gst_bin_get_by_name (GST_BIN (ev->pipeline), "volume");
993 g_object_set (G_OBJECT (volume), "volume", 0.0, NULL);
995 g_object_set (G_OBJECT (volume), "volume", ev->volume * 10.0, NULL);
997 gst_object_unref (volume);
1001 em_audio_channel_mute_get(void *video)
1003 Emotion_Gstreamer_Video *ev;
1005 ev = (Emotion_Gstreamer_Video *)video;
1007 return ev->audio_mute;
1011 em_audio_channel_volume_set(void *video,
1014 Emotion_Gstreamer_Video *ev;
1017 ev = (Emotion_Gstreamer_Video *)video;
1024 volume = gst_bin_get_by_name (GST_BIN (ev->pipeline), "volume");
1025 if (!volume) return;
1026 g_object_set (G_OBJECT (volume), "volume",
1028 gst_object_unref (volume);
1032 em_audio_channel_volume_get(void *video)
1034 Emotion_Gstreamer_Video *ev;
1036 ev = (Emotion_Gstreamer_Video *)video;
1044 em_spu_channel_count(void *video)
1046 Emotion_Gstreamer_Video *ev;
1048 ev = (Emotion_Gstreamer_Video *)video;
1054 em_spu_channel_set(void *video, int channel)
1056 Emotion_Gstreamer_Video *ev;
1058 ev = (Emotion_Gstreamer_Video *)video;
1062 em_spu_channel_get(void *video)
1064 Emotion_Gstreamer_Video *ev;
1066 ev = (Emotion_Gstreamer_Video *)video;
1072 em_spu_channel_name_get(void *video, int channel)
1074 Emotion_Gstreamer_Video *ev;
1076 ev = (Emotion_Gstreamer_Video *)video;
1081 em_spu_channel_mute_set(void *video, int mute)
1083 Emotion_Gstreamer_Video *ev;
1085 ev = (Emotion_Gstreamer_Video *)video;
1089 em_spu_channel_mute_get(void *video)
1091 Emotion_Gstreamer_Video *ev;
1093 ev = (Emotion_Gstreamer_Video *)video;
1099 em_chapter_count(void *video)
1101 Emotion_Gstreamer_Video *ev;
1103 ev = (Emotion_Gstreamer_Video *)video;
1108 em_chapter_set(void *video, int chapter)
1110 Emotion_Gstreamer_Video *ev;
1112 ev = (Emotion_Gstreamer_Video *)video;
1116 em_chapter_get(void *video)
1118 Emotion_Gstreamer_Video *ev;
1120 ev = (Emotion_Gstreamer_Video *)video;
1126 em_chapter_name_get(void *video, int chapter)
1128 Emotion_Gstreamer_Video *ev;
1130 ev = (Emotion_Gstreamer_Video *)video;
1136 em_speed_set(void *video, double speed)
1138 Emotion_Gstreamer_Video *ev;
1140 ev = (Emotion_Gstreamer_Video *)video;
1144 em_speed_get(void *video)
1146 Emotion_Gstreamer_Video *ev;
1148 ev = (Emotion_Gstreamer_Video *)video;
1154 em_eject(void *video)
1156 Emotion_Gstreamer_Video *ev;
1158 ev = (Emotion_Gstreamer_Video *)video;
1164 em_meta_get(void *video, int meta)
1166 Emotion_Gstreamer_Video *ev;
1171 ev = (Emotion_Gstreamer_Video *)video;
1172 if (!ev) return NULL;
1175 bus = gst_element_get_bus (ev->pipeline);
1176 if (!bus) return NULL;
1179 GstMessage *message;
1181 message = gst_bus_pop (bus);
1182 if (message == NULL)
1183 /* All messages read, we're done */
1186 switch (GST_MESSAGE_TYPE (message)) {
1187 case GST_MESSAGE_TAG: {
1188 GstTagList *new_tags;
1190 gst_message_parse_tag (message, &new_tags);
1193 case META_TRACK_TITLE:
1194 gst_tag_list_get_string (new_tags, GST_TAG_TITLE, &str);
1195 if (str) done = TRUE;
1197 case META_TRACK_ARTIST:
1198 gst_tag_list_get_string (new_tags, GST_TAG_ARTIST, &str);
1199 if (str) done = TRUE;
1201 case META_TRACK_GENRE:
1202 gst_tag_list_get_string (new_tags, GST_TAG_GENRE, &str);
1203 if (str) done = TRUE;
1205 case META_TRACK_COMMENT:
1206 gst_tag_list_get_string (new_tags, GST_TAG_COMMENT, &str);
1207 if (str) done = TRUE;
1209 case META_TRACK_ALBUM:
1210 gst_tag_list_get_string (new_tags, GST_TAG_ALBUM, &str);
1211 if (str) done = TRUE;
1213 case META_TRACK_YEAR: {
1216 date = gst_tag_list_get_value_index (new_tags, GST_TAG_DATE, 0);
1218 str = g_strdup_value_contents (date);
1219 if (str) done = TRUE;
1222 case META_TRACK_DISCID:
1223 #ifdef GST_TAG_CDDA_CDDB_DISCID
1224 gst_tag_list_get_string (new_tags, GST_TAG_CDDA_CDDB_DISCID, &str);
1226 if (str) done = TRUE;
1228 case META_TRACK_COUNT: {
1231 track_count = emotion_pipeline_cdda_track_count_get (video);
1232 if (track_count > 0) {
1235 g_snprintf (buf, 64, "%d", track_count);
1236 str = g_strdup (buf);
1247 gst_message_unref (message);
1250 gst_object_unref (GST_OBJECT (bus));
1256 module_open(Evas_Object *obj,
1257 Emotion_Video_Module **module,
1259 Emotion_Module_Options *opt)
1264 if (!em_module.init(obj, video, opt))
1267 *module = &em_module;
1272 module_close(Emotion_Video_Module *module,
1275 em_module.shutdown(video);
1279 _em_fd_ev_active(void *data, Ecore_Fd_Handler *fdh)
1284 unsigned char *frame_data;
1285 Emotion_Gstreamer_Video *ev;
1289 fd = ecore_main_fd_handler_fd_get(fdh);
1291 while ((len = read(fd, buf, sizeof(buf))) > 0)
1293 if (len == sizeof(buf))
1295 Emotion_Video_Sink *vsink;
1297 frame_data = buf[0];
1299 _emotion_frame_new(ev->obj);
1300 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
1301 _emotion_video_pos_update(ev->obj, ev->position, vsink->length_time);
1307 int _eos_timer_fct (void *data)
1309 Emotion_Gstreamer_Video *ev;
1312 ev = (Emotion_Gstreamer_Video *)data;
1313 while ((msg = gst_bus_poll (ev->eos_bus, GST_MESSAGE_ERROR | GST_MESSAGE_EOS, 0))) {
1314 switch (GST_MESSAGE_TYPE(msg)) {
1315 case GST_MESSAGE_ERROR: {
1319 gst_message_parse_error (msg, &err, &debug);
1322 g_print ("Error: %s\n", err->message);
1327 case GST_MESSAGE_EOS:
1330 ecore_timer_del(ev->eos_timer);
1331 ev->eos_timer = NULL;
1334 _emotion_decode_stop(ev->obj);
1335 _emotion_playback_finished(ev->obj);
1340 gst_message_unref (msg);