Hello! I'm doing my first steps with GStreamer :)

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?

Notes:
width x height x bits_per_pixel / 8 = buffer size (in bytes)
YUY2: 640x480x16/8 = 614400
RGB: 640x480x24/8 = 921600

Program output "ch_havedata: buffer size 614400" :(


Thanks,
Juan Pablo


[code]

// Compile: g++ -Wall `pkg-config --cflags --libs gstreamer-0.10` pipeline03.cpp -o pipeline03
#include <gst/gst.h>

static GMainLoop *loop;

static gboolean cb_have_data(GstPad *pad, GstBuffer *buffer, gpointer u_data)
{
  g_print("ch_havedata: buffer size %d\n",GST_BUFFER_SIZE(buffer));
  return TRUE;
}


gint main (gint argc, gchar *argv[])
{
  GstElement *pipeline, *webcamsrc, *flt, *colorspace, *videosink;
  GstPad *pad;

  // init GStreamer
  gst_init (&argc, &argv);

  // create pipeline
  pipeline = gst_pipeline_new ("pipeline");
 
  // configure pipeline
  webcamsrc = gst_element_factory_make ("v4l2src", "webcamsrc");
  flt = gst_element_factory_make ("capsfilter", "flt");
  colorspace = gst_element_factory_make ("ffmpegcolorspace", "colorspace");
  videosink = gst_element_factory_make ("xvimagesink", "videosink");

  // setup capsfilter
  g_object_set (G_OBJECT (flt), "caps",
    gst_caps_new_simple ("video/x-raw-yuv",
      "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
      "width", G_TYPE_INT, 640,
      "height", G_TYPE_INT, 480,
      "framerate", GST_TYPE_FRACTION, 20, 1,
      "bpp", G_TYPE_INT, 16,
      "depth", G_TYPE_INT, 16,
      "endianness", G_TYPE_INT, G_BYTE_ORDER,
      NULL), NULL);

  // add two callback
  pad = gst_element_get_pad(videosink, "sink");
  gst_pad_add_buffer_probe (pad, G_CALLBACK (cb_have_data), NULL);
  gst_object_unref (pad);

  // link
  gst_bin_add_many (GST_BIN (pipeline), webcamsrc, flt, colorspace, videosink, NULL);
  gst_element_link_many (webcamsrc, flt, videosink, NULL);

  // play pipeline
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  // create mainloop
  loop = g_main_loop_new (NULL, FALSE);
  g_main_loop_run (loop);
 
  // clean up
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  g_main_loop_unref (loop);

  return 0;
}