[gst-devel] How to get the real capabilities of a v4l2src element

Zheng, Huan huan.zheng at intel.com
Wed Jan 6 09:30:01 CET 2010


Cheated from cheese, have fun. :)

static void
cheese_webcam_get_webcam_device_data (CheeseWebcam       *webcam,
                                      CheeseWebcamDevice *webcam_device)
{
  char                *pipeline_desc;
  GstElement          *pipeline;
  GError              *err;
  GstStateChangeReturn ret;
  GstMessage          *msg;
  GstBus              *bus;

  {
    pipeline_desc = g_strdup_printf ("%s name=source device=%s ! fakesink",
                                     webcam_device->gstreamer_src,
                                     webcam_device->video_device);
    err      = NULL;
    pipeline = gst_parse_launch (pipeline_desc, &err);
    if ((pipeline != NULL) && (err == NULL))
    {
      /* Start the pipeline and wait for max. 10 seconds for it to start up */
      gst_element_set_state (pipeline, GST_STATE_PLAYING);
      ret = gst_element_get_state (pipeline, NULL, NULL, 10 * GST_SECOND);

      /* Check if any error messages were posted on the bus */
      bus = gst_element_get_bus (pipeline);
      msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
      gst_object_unref (bus);

      if ((msg == NULL) && (ret == GST_STATE_CHANGE_SUCCESS))
      {
        GstElement *src;
        GstPad     *pad;
        char       *name;
        GstCaps    *caps;

        gst_element_set_state (pipeline, GST_STATE_PAUSED);

        src = gst_bin_get_by_name (GST_BIN (pipeline), "source");

        g_object_get (G_OBJECT (src), "device-name", &name, NULL);
        if (name == NULL)
          name = "Unknown";

        g_print ("Device: %s (%s)\n", name, webcam_device->video_device);
        pad  = gst_element_get_pad (src, "src");
        caps = gst_pad_get_caps (pad);
        gst_object_unref (pad);
        cheese_webcam_get_supported_video_formats (webcam_device, caps);
        gst_caps_unref (caps);
      }
      gst_element_set_state (pipeline, GST_STATE_NULL);
      gst_object_unref (pipeline);
    }
    if (err)
      g_error_free (err);

    g_free (pipeline_desc);
  }
} 

Best Regards, Zheng, Huan(ZBT)
OTC/SSD/SSG
Intel Asia-Pacific Research & Developement Ltd
Tel: 021-6116 6435
Inet: 8821 6435
Cub: 3W035

-----Original Message-----
From: Dave Tarkowski [mailto:Dave.Tarkowski at mathworks.com] 
Sent: 2010年1月6日 3:21
To: gstreamer-devel at lists.sourceforge.net
Subject: [gst-devel] How to get the real capabilities of a v4l2src element

Hi all,

I'm trying to write a program to interface with webcams via gstreamer and I'm having a bit of a problem understanding how to get the real capabilities of the webcam.

What I'm doing is basically the following:

GstElement* source = gst_element_factory_make("v4l2src", "v4l2source");
GstPad* pad = gst_element_get_pad(source, "src");
GstCaps* padCaps = gst_pad_get_caps(pad);
g_print("The caps for the first source pad are:\n%s\n", gst_caps_to_string(padCaps));

This prints the various generic capabilities of the pad, basically what I get when I run "gst-inspect-0.10 v4l2src", but not the actual capabilities of the currently connected camera.

If I run "gst-launch-0.10 --gst-debug=v4l2src:3 v4l2src num_buffers=0 ! fakesink" I can see that the information that I want is obtained internally:

v4l2src gstv4l2src.c:710:gst_v4l2src_get_caps:<v4l2src0> probed caps:

Is there any way to get at this information without going directly to the v4l2 apis?

BTW, I'm building on Debian 5.0 and the version of GStreamer installed is 0.10.19.

Thanks,
Dave

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


More information about the gstreamer-devel mailing list