3 #include "emotion_gstreamer.h"
5 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE("sink",
6 GST_PAD_SINK, GST_PAD_ALWAYS,
7 GST_STATIC_CAPS(GST_VIDEO_CAPS_YUV("{ I420, YV12, YUY2, NV12, ST12, TM12 }") ";"
8 GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_BGR ";" GST_VIDEO_CAPS_BGRA));
10 GST_DEBUG_CATEGORY_STATIC(evas_video_sink_debug);
11 #define GST_CAT_DEFAULT evas_video_sink_debug
27 static guint evas_video_sink_signals[LAST_SIGNAL] = { 0, };
29 #define _do_init(bla) \
30 GST_DEBUG_CATEGORY_INIT(evas_video_sink_debug, \
35 GST_BOILERPLATE_FULL(EvasVideoSink,
42 static void unlock_buffer_mutex(EvasVideoSinkPrivate* priv);
43 static void evas_video_sink_main_render(void *data);
44 static void evas_video_sink_samsung_main_render(void *data);
47 _evas_video_bgrx_step(unsigned char *evas_data, const unsigned char *gst_data,
48 unsigned int w, unsigned int h __UNUSED__, unsigned int output_height, unsigned int step)
53 for (y = 0; y < output_height; ++y)
55 for (x = 0; x < w; x++)
57 evas_data[0] = gst_data[0];
58 evas_data[1] = gst_data[1];
59 evas_data[2] = gst_data[2];
68 _evas_video_bgr(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
70 _evas_video_bgrx_step(evas_data, gst_data, w, h, output_height, 3);
74 _evas_video_bgrx(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
76 _evas_video_bgrx_step(evas_data, gst_data, w, h, output_height, 4);
80 _evas_video_bgra(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
85 for (y = 0; y < output_height; ++y)
89 for (x = 0; x < w; ++x)
92 evas_data[0] = (gst_data[0] * alpha) / 255;
93 evas_data[1] = (gst_data[1] * alpha) / 255;
94 evas_data[2] = (gst_data[2] * alpha) / 255;
103 _evas_video_i420(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
105 const unsigned char **rows;
111 rows = (const unsigned char **)evas_data;
113 for (i = 0; i < rh; i++)
114 rows[i] = &gst_data[i * w];
116 for (j = 0; j < (rh / 2); j++, i++)
117 rows[i] = &gst_data[h * w + j * (w / 2)];
119 for (j = 0; j < (rh / 2); j++, i++)
120 rows[i] = &gst_data[h * w + h * (w / 4) + j * (w / 2)];
121 WRN("I420: %i (max: %i for height %i, real height = %i) = %p", i, 2 * h, h, rh, evas_data);
125 _evas_video_yv12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
127 const unsigned char **rows;
133 rows = (const unsigned char **)evas_data;
135 for (i = 0; i < rh; i++)
136 rows[i] = &gst_data[i * w];
138 for (j = 0; j < (rh / 2); j++, i++)
139 rows[i] = &gst_data[h * w + h * (w / 4) + j * (w / 2)];
141 for (j = 0; j < (rh / 2); j++, i++)
142 rows[i] = &gst_data[h * w + j * (w / 2)];
143 WRN("YV12: %i (max: %i for height %i, real height = %i) = %p", i, 2 * h, h, rh, evas_data);
147 _evas_video_yuy2(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
149 const unsigned char **rows;
152 rows = (const unsigned char **)evas_data;
154 for (i = 0; i < output_height; i++)
155 rows[i] = &gst_data[i * w * 2];
159 _evas_video_nv12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
161 const unsigned char **rows;
167 rows = (const unsigned char **)evas_data;
169 for (i = 0; i < rh; i++)
170 rows[i] = &gst_data[i * w];
172 for (j = 0; j < (rh / 2); j++, i++)
173 rows[i] = &gst_data[h * w + j * w];
177 _evas_video_mt12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height __UNUSED__)
179 const unsigned char **rows;
183 rows = (const unsigned char **)evas_data;
185 for (i = 0; i < (h / 32) / 2; i++)
186 rows[i] = &gst_data[i * w * 2 * 32];
190 rows[i] = &gst_data[i * w * 2 * 32];
194 for (j = 0; j < ((h / 2) / 32) / 2; ++j, ++i)
195 rows[i] = &gst_data[h * w + j * (w / 2) * 2 * 16];
199 _evas_video_st12_multiplane(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height __UNUSED__)
201 const GstMultiPlaneImageBuffer *mp_buf = (const GstMultiPlaneImageBuffer *) gst_data;
202 const unsigned char **rows;
206 rows = (const unsigned char **)evas_data;
208 for (i = 0; i < (h / 32) / 2; i++)
209 rows[i] = mp_buf->uaddr[0] + i * w * 2 * 32;
212 rows[i] = mp_buf->uaddr[0] + i * w * 2 * 32;
216 for (j = 0; j < ((h / 2) / 16) / 2; j++, i++)
217 rows[i] = mp_buf->uaddr[1] + j * w * 2 * 16;
218 if (((h / 2) / 16) % 2)
219 rows[i] = mp_buf->uaddr[0] + j * w * 2 * 16;
223 _evas_video_st12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height __UNUSED__)
225 const SCMN_IMGB *imgb = (const SCMN_IMGB *) gst_data;
226 const unsigned char **rows;
229 rows = (const unsigned char **)evas_data;
231 for (i = 0; i < (h / 32) / 2; i++)
232 rows[i] = imgb->uaddr[0] + i * w * 2 * 32;
235 rows[i] = imgb->uaddr[0] + i * w * 2 * 32;
239 for (j = 0; j < ((h / 2) / 16) / 2; j++, i++)
240 rows[i] = imgb->uaddr[1] + j * w * 2 * 16;
241 if (((h / 2) / 16) % 2)
242 rows[i] = imgb->uaddr[1] + j * w * 2 * 16;
245 static const struct {
247 Evas_Colorspace eformat;
248 Evas_Video_Convert_Cb func;
249 Eina_Bool force_height;
250 } colorspace_fourcc_convertion[] = {
251 { GST_MAKE_FOURCC('I', '4', '2', '0'), EVAS_COLORSPACE_YCBCR422P601_PL, _evas_video_i420, EINA_TRUE },
252 { GST_MAKE_FOURCC('Y', 'V', '1', '2'), EVAS_COLORSPACE_YCBCR422P601_PL, _evas_video_yv12, EINA_TRUE },
253 { GST_MAKE_FOURCC('Y', 'U', 'Y', '2'), EVAS_COLORSPACE_YCBCR422601_PL, _evas_video_yuy2, EINA_FALSE },
254 { GST_MAKE_FOURCC('N', 'V', '1', '2'), EVAS_COLORSPACE_YCBCR420NV12601_PL, _evas_video_nv12, EINA_TRUE },
255 { GST_MAKE_FOURCC('T', 'M', '1', '2'), EVAS_COLORSPACE_YCBCR420TM12601_PL, _evas_video_mt12, EINA_TRUE }
258 static const struct {
259 GstVideoFormat format;
260 Evas_Colorspace eformat;
261 Evas_Video_Convert_Cb func;
262 } colorspace_format_convertion[] = {
263 { GST_VIDEO_FORMAT_BGR, EVAS_COLORSPACE_ARGB8888, _evas_video_bgr },
264 { GST_VIDEO_FORMAT_BGRx, EVAS_COLORSPACE_ARGB8888, _evas_video_bgrx },
265 { GST_VIDEO_FORMAT_BGRA, EVAS_COLORSPACE_ARGB8888, _evas_video_bgra }
269 evas_video_sink_base_init(gpointer g_class)
271 GstElementClass* element_class;
273 element_class = GST_ELEMENT_CLASS(g_class);
274 gst_element_class_add_pad_template(element_class, gst_static_pad_template_get(&sinktemplate));
275 gst_element_class_set_details_simple(element_class, "Evas video sink",
276 "Sink/Video", "Sends video data from a GStreamer pipeline to an Evas object",
277 "Vincent Torri <vtorri@univ-evry.fr>");
281 evas_video_sink_init(EvasVideoSink* sink, EvasVideoSinkClass* klass __UNUSED__)
283 EvasVideoSinkPrivate* priv;
286 sink->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE(sink, EVAS_TYPE_VIDEO_SINK, EvasVideoSinkPrivate);
288 priv->last_buffer = NULL;
292 priv->eformat = EVAS_COLORSPACE_ARGB8888;
293 priv->samsung = EINA_FALSE;
294 eina_lock_new(&priv->m);
295 eina_condition_new(&priv->c, &priv->m);
296 priv->unlocked = EINA_FALSE;
299 /**** Object methods ****/
301 _cleanup_priv(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
303 EvasVideoSinkPrivate* priv;
307 eina_lock_take(&priv->m);
310 eina_lock_release(&priv->m);
314 evas_video_sink_set_property(GObject * object, guint prop_id,
315 const GValue * value, GParamSpec * pspec)
318 EvasVideoSinkPrivate* priv;
320 sink = EVAS_VIDEO_SINK (object);
324 case PROP_EVAS_OBJECT:
325 eina_lock_take(&priv->m);
326 evas_object_event_callback_del(priv->o, EVAS_CALLBACK_FREE, _cleanup_priv);
327 priv->o = g_value_get_pointer (value);
328 INF("sink set Evas_Object %p.", priv->o);
329 evas_object_event_callback_add(priv->o, EVAS_CALLBACK_FREE, _cleanup_priv, priv);
330 eina_lock_release(&priv->m);
334 eina_lock_take(&priv->m);
335 priv->ev = g_value_get_pointer (value);
336 eina_lock_release(&priv->m);
339 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
340 ERR("invalid property");
346 evas_video_sink_get_property(GObject * object, guint prop_id,
347 GValue * value, GParamSpec * pspec)
350 EvasVideoSinkPrivate* priv;
352 sink = EVAS_VIDEO_SINK (object);
356 case PROP_EVAS_OBJECT:
357 INF("sink get property.");
358 eina_lock_take(&priv->m);
359 g_value_set_pointer(value, priv->o);
360 eina_lock_release(&priv->m);
363 INF("sink get width.");
364 eina_lock_take(&priv->m);
365 g_value_set_int(value, priv->width);
366 eina_lock_release(&priv->m);
369 INF("sink get height.");
370 eina_lock_take(&priv->m);
371 g_value_set_int (value, priv->height);
372 eina_lock_release(&priv->m);
376 eina_lock_take(&priv->m);
377 g_value_set_pointer (value, priv->ev);
378 eina_lock_release(&priv->m);
381 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
382 ERR("invalide property");
388 evas_video_sink_dispose(GObject* object)
391 EvasVideoSinkPrivate* priv;
395 sink = EVAS_VIDEO_SINK(object);
398 eina_lock_free(&priv->m);
399 eina_condition_free(&priv->c);
401 if (priv->last_buffer) {
402 gst_buffer_unref(priv->last_buffer);
403 priv->last_buffer = NULL;
406 G_OBJECT_CLASS(parent_class)->dispose(object);
410 /**** BaseSink methods ****/
412 gboolean evas_video_sink_set_caps(GstBaseSink *bsink, GstCaps *caps)
415 EvasVideoSinkPrivate* priv;
416 GstStructure *structure;
417 GstVideoFormat format;
421 sink = EVAS_VIDEO_SINK(bsink);
424 structure = gst_caps_get_structure(caps, 0);
426 if (gst_structure_get_int(structure, "width", (int*) &priv->width)
427 && gst_structure_get_int(structure, "height", (int*) &priv->height)
428 && gst_structure_get_fourcc(structure, "format", &fourcc))
430 priv->source_height = priv->height;
432 for (i = 0; i < sizeof (colorspace_fourcc_convertion) / sizeof (colorspace_fourcc_convertion[0]); ++i)
433 if (fourcc == colorspace_fourcc_convertion[i].fourcc)
435 priv->eformat = colorspace_fourcc_convertion[i].eformat;
436 priv->func = colorspace_fourcc_convertion[i].func;
437 if (colorspace_fourcc_convertion[i].force_height)
439 priv->height = (priv->height >> 1) << 1;
444 if (fourcc == GST_MAKE_FOURCC('S', 'T', '1', '2'))
446 priv->eformat = EVAS_COLORSPACE_YCBCR420TM12601_PL;
447 priv->samsung = EINA_TRUE;
453 INF("fallback code !");
454 if (!gst_video_format_parse_caps(caps, &format, (int*) &priv->width, (int*) &priv->height))
456 ERR("Unable to parse caps.");
460 priv->source_height = priv->height;
462 for (i = 0; i < sizeof (colorspace_format_convertion) / sizeof (colorspace_format_convertion[0]); ++i)
463 if (format == colorspace_format_convertion[i].format)
465 priv->eformat = colorspace_format_convertion[i].eformat;
466 priv->func = colorspace_format_convertion[i].func;
470 ERR("unsupported : %d\n", format);
475 evas_video_sink_start(GstBaseSink* base_sink)
477 EvasVideoSinkPrivate* priv;
482 priv = EVAS_VIDEO_SINK(base_sink)->priv;
483 eina_lock_take(&priv->m);
487 priv->unlocked = EINA_FALSE;
488 eina_lock_release(&priv->m);
493 evas_video_sink_stop(GstBaseSink* base_sink)
495 EvasVideoSinkPrivate* priv = EVAS_VIDEO_SINK(base_sink)->priv;
499 unlock_buffer_mutex(priv);
504 evas_video_sink_unlock(GstBaseSink* object)
510 sink = EVAS_VIDEO_SINK(object);
512 unlock_buffer_mutex(sink->priv);
514 return GST_CALL_PARENT_WITH_DEFAULT(GST_BASE_SINK_CLASS, unlock,
519 evas_video_sink_unlock_stop(GstBaseSink* object)
522 EvasVideoSinkPrivate* priv;
524 sink = EVAS_VIDEO_SINK(object);
527 INF("sink unlock stop");
529 eina_lock_take(&priv->m);
530 priv->unlocked = FALSE;
531 eina_lock_release(&priv->m);
533 return GST_CALL_PARENT_WITH_DEFAULT(GST_BASE_SINK_CLASS, unlock_stop,
538 evas_video_sink_preroll(GstBaseSink* bsink, GstBuffer* buffer)
540 Emotion_Gstreamer_Buffer *send;
541 EvasVideoSinkPrivate *priv;
544 INF("sink preroll %p [%i]", GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE(buffer));
546 sink = EVAS_VIDEO_SINK(bsink);
549 if (GST_BUFFER_SIZE(buffer) <= 0 && !priv->samsung)
555 send = emotion_gstreamer_buffer_alloc(priv, buffer, EINA_TRUE);
563 GstStructure *structure;
565 gboolean is_multiplane = FALSE;
567 caps = GST_BUFFER_CAPS(buffer);
568 structure = gst_caps_get_structure (caps, 0);
569 gst_structure_get_boolean(structure, "multiplane", &is_multiplane);
572 priv->func = _evas_video_st12_multiplane;
574 priv->func = _evas_video_st12;
577 ecore_main_loop_thread_safe_call_async(evas_video_sink_samsung_main_render, send);
580 ecore_main_loop_thread_safe_call_async(evas_video_sink_main_render, send);
587 evas_video_sink_render(GstBaseSink* bsink, GstBuffer* buffer)
589 Emotion_Gstreamer_Buffer *send;
590 EvasVideoSinkPrivate *priv;
593 INF("sink render %p [%i]", GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE(buffer));
595 sink = EVAS_VIDEO_SINK(bsink);
598 eina_lock_take(&priv->m);
600 if (priv->unlocked) {
602 eina_lock_release(&priv->m);
606 send = emotion_gstreamer_buffer_alloc(priv, buffer, EINA_FALSE);
608 eina_lock_release(&priv->m);
609 return GST_FLOW_ERROR;
616 GstStructure *structure;
618 gboolean is_multiplane = FALSE;
620 caps = GST_BUFFER_CAPS(buffer);
621 structure = gst_caps_get_structure (caps, 0);
622 gst_structure_get_boolean(structure, "multiplane", &is_multiplane);
625 priv->func = _evas_video_st12_multiplane;
627 priv->func = _evas_video_st12;
630 ecore_main_loop_thread_safe_call_async(evas_video_sink_samsung_main_render, send);
633 ecore_main_loop_thread_safe_call_async(evas_video_sink_main_render, send);
635 eina_condition_wait(&priv->c);
636 eina_lock_release(&priv->m);
642 evas_video_sink_samsung_main_render(void *data)
644 Emotion_Gstreamer_Buffer *send;
645 Emotion_Video_Stream *vstream;
646 EvasVideoSinkPrivate* priv;
648 unsigned char *evas_data;
649 const guint8 *gst_data;
650 GstFormat fmt = GST_FORMAT_TIME;
653 int stride, elevation;
658 if (!send) goto exit_point;
661 buffer = send->frame;
662 preroll = send->preroll;
664 if (!priv || !priv->o || priv->unlocked || !send->ev)
667 _emotion_gstreamer_video_pipeline_parse(send->ev, EINA_TRUE);
669 /* Getting stride to compute the right size and then fill the object properly */
670 /* Y => [0] and UV in [1] */
671 if (priv->func == _evas_video_st12_multiplane)
673 const GstMultiPlaneImageBuffer *mp_buf = (const GstMultiPlaneImageBuffer *) buffer;
675 stride = mp_buf->stride[0];
676 elevation = mp_buf->elevation[0];
677 priv->width = mp_buf->width[0];
678 priv->height = mp_buf->height[0];
680 gst_data = (const guint8 *) mp_buf;
684 const SCMN_IMGB *imgb = (const SCMN_IMGB *) GST_BUFFER_MALLOCDATA(buffer);
686 stride = imgb->stride[0];
687 elevation = imgb->elevation[0];
688 priv->width = imgb->width[0];
689 priv->height = imgb->height[0];
691 gst_data = (const guint8 *) imgb;
694 INF("sink main render [%i, %i] - [%i, %i]", priv->width, priv->height, stride, elevation);
696 evas_object_image_alpha_set(priv->o, 0);
697 evas_object_image_colorspace_set(priv->o, priv->eformat);
698 evas_object_image_size_set(priv->o, stride, elevation);
699 evas_object_geometry_get(priv->o, NULL, NULL, &w, &h);
700 evas_object_image_fill_set(priv->o, 0, 0, stride * w / priv->width, elevation * h / priv->height);
702 evas_data = evas_object_image_data_get(priv->o, 1);
705 priv->func(evas_data, gst_data, stride, elevation, elevation);
707 WRN("No way to decode %x colorspace !", priv->eformat);
709 evas_object_image_data_set(priv->o, evas_data);
710 evas_object_image_data_update_add(priv->o, 0, 0, priv->width, priv->height);
711 evas_object_image_pixels_dirty_set(priv->o, 0);
713 _emotion_frame_new(send->ev->obj);
715 vstream = eina_list_nth(send->ev->video_streams, send->ev->video_stream_nbr - 1);
717 gst_element_query_position(send->ev->pipeline, &fmt, &pos);
718 send->ev->position = (double)pos / (double)GST_SECOND;
720 vstream->width = priv->width;
721 vstream->height = priv->height;
722 send->ev->ratio = (double) priv->width / (double) priv->height;
724 _emotion_video_pos_update(send->ev->obj, send->ev->position, vstream->length_time);
725 _emotion_frame_resize(send->ev->obj, priv->width, priv->height, send->ev->ratio);
727 if (priv->last_buffer) gst_buffer_unref(priv->last_buffer);
728 priv->last_buffer = gst_buffer_ref(buffer);
731 emotion_gstreamer_buffer_free(send);
733 if (preroll || !priv->o || !send->ev) return ;
735 eina_lock_take(&priv->m);
737 eina_condition_signal(&priv->c);
739 eina_lock_release(&priv->m);
743 evas_video_sink_main_render(void *data)
745 Emotion_Gstreamer_Buffer *send;
746 Emotion_Gstreamer_Video *ev = NULL;
747 Emotion_Video_Stream *vstream;
748 EvasVideoSinkPrivate* priv;
750 unsigned char *evas_data;
751 GstFormat fmt = GST_FORMAT_TIME;
757 if (!send) goto exit_point;
760 buffer = send->frame;
761 preroll = send->preroll;
764 if (!priv || !priv->o || priv->unlocked || !ev)
767 _emotion_gstreamer_video_pipeline_parse(ev, EINA_TRUE);
769 INF("sink main render [%i, %i] (source height: %i)", priv->width, priv->height, priv->source_height);
771 evas_object_image_alpha_set(priv->o, 0);
772 evas_object_image_colorspace_set(priv->o, priv->eformat);
773 evas_object_image_size_set(priv->o, priv->width, priv->height);
775 evas_data = evas_object_image_data_get(priv->o, 1);
778 priv->func(evas_data, GST_BUFFER_DATA(buffer), priv->width, priv->source_height, priv->height);
780 WRN("No way to decode %x colorspace !", priv->eformat);
782 evas_object_image_data_set(priv->o, evas_data);
783 evas_object_image_data_update_add(priv->o, 0, 0, priv->width, priv->height);
784 evas_object_image_pixels_dirty_set(priv->o, 0);
786 _emotion_frame_new(ev->obj);
788 vstream = eina_list_nth(ev->video_streams, ev->video_stream_nbr - 1);
790 gst_element_query_position(ev->pipeline, &fmt, &pos);
791 ev->position = (double)pos / (double)GST_SECOND;
793 vstream->width = priv->width;
794 vstream->height = priv->height;
795 ev->ratio = (double) priv->width / (double) priv->height;
797 _emotion_video_pos_update(ev->obj, ev->position, vstream->length_time);
798 _emotion_frame_resize(ev->obj, priv->width, priv->height, ev->ratio);
800 if (priv->last_buffer) gst_buffer_unref(priv->last_buffer);
801 priv->last_buffer = gst_buffer_ref(buffer);
804 emotion_gstreamer_buffer_free(send);
806 if (preroll || !priv->o || !ev) return ;
808 eina_lock_take(&priv->m);
810 eina_condition_signal(&priv->c);
812 eina_lock_release(&priv->m);
816 unlock_buffer_mutex(EvasVideoSinkPrivate* priv)
818 eina_lock_take(&priv->m);
819 priv->unlocked = EINA_TRUE;
821 eina_condition_signal(&priv->c);
822 eina_lock_release(&priv->m);
826 marshal_VOID__MINIOBJECT(GClosure * closure, GValue * return_value __UNUSED__,
827 guint n_param_values, const GValue * param_values,
828 gpointer invocation_hint __UNUSED__, gpointer marshal_data)
830 typedef void (*marshalfunc_VOID__MINIOBJECT) (gpointer obj, gpointer arg1, gpointer data2);
831 marshalfunc_VOID__MINIOBJECT callback;
833 gpointer data1, data2;
835 cc = (GCClosure *) closure;
837 g_return_if_fail(n_param_values == 2);
839 if (G_CCLOSURE_SWAP_DATA(closure)) {
840 data1 = closure->data;
841 data2 = g_value_peek_pointer(param_values + 0);
843 data1 = g_value_peek_pointer(param_values + 0);
844 data2 = closure->data;
846 callback = (marshalfunc_VOID__MINIOBJECT) (marshal_data ? marshal_data : cc->callback);
848 callback(data1, gst_value_get_mini_object(param_values + 1), data2);
852 evas_video_sink_class_init(EvasVideoSinkClass* klass)
854 GObjectClass* gobject_class;
855 GstBaseSinkClass* gstbase_sink_class;
857 gobject_class = G_OBJECT_CLASS(klass);
858 gstbase_sink_class = GST_BASE_SINK_CLASS(klass);
860 g_type_class_add_private(klass, sizeof(EvasVideoSinkPrivate));
862 gobject_class->set_property = evas_video_sink_set_property;
863 gobject_class->get_property = evas_video_sink_get_property;
865 g_object_class_install_property (gobject_class, PROP_EVAS_OBJECT,
866 g_param_spec_pointer ("evas-object", "Evas Object",
867 "The Evas object where the display of the video will be done",
870 g_object_class_install_property (gobject_class, PROP_WIDTH,
871 g_param_spec_int ("width", "Width",
872 "The width of the video",
873 0, 65536, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
875 g_object_class_install_property (gobject_class, PROP_HEIGHT,
876 g_param_spec_int ("height", "Height",
877 "The height of the video",
878 0, 65536, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
879 g_object_class_install_property (gobject_class, PROP_EV,
880 g_param_spec_pointer ("ev", "Emotion_Gstreamer_Video",
881 "THe internal data of the emotion object",
884 gobject_class->dispose = evas_video_sink_dispose;
886 gstbase_sink_class->set_caps = evas_video_sink_set_caps;
887 gstbase_sink_class->stop = evas_video_sink_stop;
888 gstbase_sink_class->start = evas_video_sink_start;
889 gstbase_sink_class->unlock = evas_video_sink_unlock;
890 gstbase_sink_class->unlock_stop = evas_video_sink_unlock_stop;
891 gstbase_sink_class->render = evas_video_sink_render;
892 gstbase_sink_class->preroll = evas_video_sink_preroll;
894 evas_video_sink_signals[REPAINT_REQUESTED] = g_signal_new("repaint-requested",
895 G_TYPE_FROM_CLASS(klass),
896 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
900 marshal_VOID__MINIOBJECT,
901 G_TYPE_NONE, 1, GST_TYPE_BUFFER);
905 gstreamer_plugin_init (GstPlugin * plugin)
907 return gst_element_register (plugin,
910 EVAS_TYPE_VIDEO_SINK);
914 _emotion_gstreamer_pause(void *data, Ecore_Thread *thread)
916 Emotion_Gstreamer_Video *ev = data;
918 if (ecore_thread_check(thread) || !ev->pipeline) return ;
920 gst_element_set_state(ev->pipeline, GST_STATE_PAUSED);
924 _emotion_gstreamer_cancel(void *data, Ecore_Thread *thread)
926 Emotion_Gstreamer_Video *ev = data;
928 ev->threads = eina_list_remove(ev->threads, thread);
930 if (getenv("EMOTION_GSTREAMER_DOT")) GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(ev->pipeline), GST_DEBUG_GRAPH_SHOW_ALL, getenv("EMOTION_GSTREAMER_DOT"));
932 if (ev->in == ev->out && ev->threads == NULL && ev->delete_me)
937 _emotion_gstreamer_end(void *data, Ecore_Thread *thread)
939 Emotion_Gstreamer_Video *ev = data;
941 ev->threads = eina_list_remove(ev->threads, thread);
945 gst_element_set_state(ev->pipeline, GST_STATE_PLAYING);
946 ev->play_started = 1;
949 if (getenv("EMOTION_GSTREAMER_DOT")) GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(ev->pipeline), GST_DEBUG_GRAPH_SHOW_ALL, getenv("EMOTION_GSTREAMER_DOT"));
951 if (ev->in == ev->out && ev->threads == NULL && ev->delete_me)
954 _emotion_gstreamer_video_pipeline_parse(data, EINA_TRUE);
958 gstreamer_video_sink_new(Emotion_Gstreamer_Video *ev,
967 obj = emotion_object_image_get(o);
970 ERR("Not Evas_Object specified");
974 playbin = gst_element_factory_make("playbin2", "playbin");
977 ERR("Unable to create 'playbin' GstElement.");
981 sink = gst_element_factory_make("emotion-sink", "sink");
984 ERR("Unable to create 'emotion-sink' GstElement.");
988 #define GST_PLAY_FLAG_NATIVE_VIDEO (1 << 6)
989 #define GST_PLAY_FLAG_DOWNLOAD (1 << 7)
990 #define GST_PLAY_FLAG_BUFFERING (1 << 8)
992 g_object_set(G_OBJECT(sink), "evas-object", obj, NULL);
993 g_object_set(G_OBJECT(sink), "ev", ev, NULL);
995 evas_object_image_pixels_get_callback_set(obj, NULL, NULL);
997 g_object_get(G_OBJECT(playbin), "flags", &flags, NULL);
998 g_object_set(G_OBJECT(playbin), "flags", flags | GST_PLAY_FLAG_NATIVE_VIDEO | GST_PLAY_FLAG_DOWNLOAD | GST_PLAY_FLAG_BUFFERING, NULL);
999 g_object_set(G_OBJECT(playbin), "video-sink", sink, NULL);
1000 g_object_set(G_OBJECT(playbin), "uri", uri, NULL);
1002 ev->pipeline = playbin;
1004 ev->threads = eina_list_append(ev->threads,
1005 ecore_thread_run(_emotion_gstreamer_pause,
1006 _emotion_gstreamer_end,
1007 _emotion_gstreamer_cancel,
1010 /** NOTE: you need to set: GST_DEBUG_DUMP_DOT_DIR=/tmp EMOTION_ENGINE=gstreamer to save the $EMOTION_GSTREAMER_DOT file in '/tmp' */
1011 /** then call dot -Tpng -oemotion_pipeline.png /tmp/$TIMESTAMP-$EMOTION_GSTREAMER_DOT.dot */
1012 if (getenv("EMOTION_GSTREAMER_DOT")) GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(playbin), GST_DEBUG_GRAPH_SHOW_ALL, getenv("EMOTION_GSTREAMER_DOT"));
1017 gst_object_unref(playbin);