Hello! I'm doing my first steps with GStreamer :)<br><br>I'd like to draw lines in a RGB space before show it. I let you a simple c++ program that shows a webcam. I've add a callback to get the buffer after convert it, but it's in YUY2 and not in RGB. What am I doing wrong?<br>
<br>Notes:<br>width x height x bits_per_pixel / 8 = buffer size (in bytes)<br>YUY2: 640x480x16/8 = 614400<br>RGB: 640x480x24/8 = 921600<br><br>Program output "ch_havedata: buffer size 614400" :(<br><br><br>Thanks,<br>
Juan Pablo<br><br><br>[code]<br><br>// Compile: g++ -Wall `pkg-config --cflags --libs gstreamer-0.10` pipeline03.cpp -o pipeline03<br>#include <gst/gst.h><br><br>static GMainLoop *loop;<br><br>static gboolean cb_have_data(GstPad *pad, GstBuffer *buffer, gpointer u_data)<br>
{<br> g_print("ch_havedata: buffer size %d\n",GST_BUFFER_SIZE(buffer));<br> return TRUE;<br>}<br><br><br>gint main (gint argc, gchar *argv[])<br>{<br> GstElement *pipeline, *webcamsrc, *flt, *colorspace, *videosink;<br>
GstPad *pad;<br><br> // init GStreamer<br> gst_init (&argc, &argv);<br><br> // create pipeline<br> pipeline = gst_pipeline_new ("pipeline");<br> <br> // configure pipeline<br> webcamsrc = gst_element_factory_make ("v4l2src", "webcamsrc");<br>
flt = gst_element_factory_make ("capsfilter", "flt");<br> colorspace = gst_element_factory_make ("ffmpegcolorspace", "colorspace");<br> videosink = gst_element_factory_make ("xvimagesink", "videosink");<br>
<br> // setup capsfilter<br> g_object_set (G_OBJECT (flt), "caps",<br> gst_caps_new_simple ("video/x-raw-yuv",<br> "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),<br>
"width", G_TYPE_INT, 640,<br> "height", G_TYPE_INT, 480,<br> "framerate", GST_TYPE_FRACTION, 20, 1,<br> "bpp", G_TYPE_INT, 16,<br> "depth", G_TYPE_INT, 16,<br>
"endianness", G_TYPE_INT, G_BYTE_ORDER,<br> NULL), NULL);<br><br> // add two callback<br> pad = gst_element_get_pad(videosink, "sink");<br> gst_pad_add_buffer_probe (pad, G_CALLBACK (cb_have_data), NULL);<br>
gst_object_unref (pad);<br><br> // link<br> gst_bin_add_many (GST_BIN (pipeline), webcamsrc, flt, colorspace, videosink, NULL);<br> gst_element_link_many (webcamsrc, flt, videosink, NULL);<br><br> // play pipeline<br>
gst_element_set_state (pipeline, GST_STATE_PLAYING);<br><br> // create mainloop<br> loop = g_main_loop_new (NULL, FALSE);<br> g_main_loop_run (loop);<br> <br> // clean up<br> gst_element_set_state (pipeline, GST_STATE_NULL);<br>
gst_object_unref (pipeline);<br> g_main_loop_unref (loop);<br><br> return 0;<br>}<br><br>