camerabin2: Add properties for supported capture caps
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>
Mon, 13 Dec 2010 02:03:21 +0000 (23:03 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>
Thu, 23 Dec 2010 16:18:57 +0000 (13:18 -0300)
Adds 2 property for getting the supported image/video capture
caps from the camera source.

gst/camerabin2/gstbasecamerasrc.c
gst/camerabin2/gstcamerabin2.c

index a5e7053..a906840 100644 (file)
@@ -482,7 +482,6 @@ gst_base_camera_src_class_init (GstBaseCameraSrcClass * klass)
   gobject_class->set_property = gst_base_camera_src_set_property;
   gobject_class->get_property = gst_base_camera_src_get_property;
 
-  // g_object_class_install_property ....
   g_object_class_install_property (gobject_class, PROP_MODE,
       g_param_spec_enum ("mode", "Mode",
           "The capture mode (still image capture or video recording)",
index 7036e19..4f40072 100644 (file)
@@ -49,6 +49,7 @@
 #include "config.h"
 #endif
 
+#include "gstbasecamerasrc.h"
 #include "gstcamerabin2.h"
 #include "gstcamerabin-enum.h"
 
@@ -61,7 +62,9 @@ enum
 {
   PROP_0,
   PROP_MODE,
-  PROP_LOCATION
+  PROP_LOCATION,
+  PROP_IMAGE_CAPTURE_SUPPORTED_CAPS,
+  PROP_VIDEO_CAPTURE_SUPPORTED_CAPS
 };
 
 enum
@@ -271,6 +274,21 @@ gst_camera_bin_class_init (GstCameraBinClass * klass)
           "Default for images is img_%d and vid_%d for videos",
           DEFAULT_IMG_LOCATION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  g_object_class_install_property (object_class,
+      PROP_IMAGE_CAPTURE_SUPPORTED_CAPS,
+      g_param_spec_boxed ("image-capture-supported-caps",
+          "Image capture supported caps",
+          "Formats supported for capturing images represented as GstCaps",
+          GST_TYPE_CAPS, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (object_class,
+      PROP_VIDEO_CAPTURE_SUPPORTED_CAPS,
+      g_param_spec_boxed ("video-capture-supported-caps",
+          "Video capture supported caps",
+          "Formats supported for capturing videos represented as GstCaps",
+          GST_TYPE_CAPS, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+
   /**
    * GstCameraBin::capture-start:
    * @camera: the camera bin element
@@ -469,6 +487,41 @@ gst_camera_bin_get_property (GObject * object, guint prop_id,
         g_value_set_string (value, camera->img_location);
       }
       break;
+    case PROP_VIDEO_CAPTURE_SUPPORTED_CAPS:
+    case PROP_IMAGE_CAPTURE_SUPPORTED_CAPS:{
+      GstPad *pad;
+      GstCaps *caps;
+      const gchar *padname;
+
+      if (prop_id == PROP_VIDEO_CAPTURE_SUPPORTED_CAPS) {
+        padname = GST_BASE_CAMERA_SRC_VIDEO_PAD_NAME;
+      } else {
+        padname = GST_BASE_CAMERA_SRC_IMAGE_PAD_NAME;
+      }
+
+      if (camera->src) {
+        pad = gst_element_get_static_pad (camera->src, padname);
+
+        g_assert (pad != NULL);
+
+        /* TODO not sure if we want get_caps or get_allowed_caps to already
+         * consider the full pipeline scenario and avoid picking a caps that
+         * won't negotiate. Need to take care on the special case of the
+         * pad being unlinked.
+         */
+        caps = gst_pad_get_caps_reffed (pad);
+        if (caps) {
+          gst_value_set_caps (value, caps);
+          gst_caps_unref (caps);
+        }
+
+        gst_object_unref (pad);
+      } else {
+        GST_DEBUG_OBJECT (camera, "Camera source not created, can't get "
+            "supported caps");
+      }
+    }
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;