basecamerabin: Do not set the pad templates in the base class.
authorYouness Alaoui <youness.alaoui@collabora.co.uk>
Thu, 3 May 2012 23:11:57 +0000 (19:11 -0400)
committerThiago Santos <thiago.sousa.santos@collabora.com>
Fri, 4 May 2012 22:50:52 +0000 (19:50 -0300)
It is best to let the subclass define the pad templates, this would
allow the subclass to decide which caps the pads should have.

gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c
gst/camerabin2/gstwrappercamerabinsrc.c

index 42d1343..199bf08 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * SECTION:element-basecamerasrc
  *
- * Base class for the camera source bin used by camerabin for capture. 
+ * Base class for the camera source bin used by camerabin for capture.
  * Sophisticated camera hardware can derive from this baseclass and map the
  * features to this interface.
  *
  * During construct_pipeline() vmethod a subclass can add several elements into
  * the bin and expose 3 srcs pads as ghostpads implementing the 3 pad templates.
  *
+ * However the subclass is responsable for adding the pad templates for the
+ * source pads and they must be named "vidsrc", "imgsrc" and "vfsrc". The pad
+ * templates should be installed in the subclass' class_init function, like so:
+ * |[
+ * static void
+ * my_element_class_init (GstMyElementClass *klass)
+ * {
+ *   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
+ *   // pad templates should be a #GstStaticPadTemplate with direction
+ *   // #GST_PAD_SRC and name "vidsrc", "imgsrc" and "vfsrc"
+ *   gst_element_class_add_static_pad_template (gstelement_class,
+ *       &amp;vidsrc_template);
+ *   gst_element_class_add_static_pad_template (gstelement_class,
+ *       &amp;imgsrc_template);
+ *   gst_element_class_add_static_pad_template (gstelement_class,
+ *       &amp;vfsrc_template);
+ *   // see #GstElementDetails
+ *   gst_element_class_set_details (gstelement_class, &amp;details);
+ * }
+ * ]|
+ *
  * It is also possible to add regular pads from the subclass and implement the
  * dataflow methods on these pads. This way all functionality can be implemneted
  * directly in the subclass without extra elements.
  *
- * The src will receive the capture mode from #GstCameraBin2 on the 
+ * The src will receive the capture mode from #GstCameraBin2 on the
  * #GstBaseCameraSrc:mode property. Possible capture modes are defined in
  * #GstCameraBinMode.
  */
@@ -88,23 +109,6 @@ GST_DEBUG_CATEGORY (base_camera_src_debug);
 #define parent_class gst_base_camera_src_parent_class
 G_DEFINE_TYPE (GstBaseCameraSrc, gst_base_camera_src, GST_TYPE_BIN);
 
-static GstStaticPadTemplate vfsrc_template =
-GST_STATIC_PAD_TEMPLATE (GST_BASE_CAMERA_SRC_VIEWFINDER_PAD_NAME,
-    GST_PAD_SRC,
-    GST_PAD_ALWAYS,
-    GST_STATIC_CAPS_ANY);
-
-static GstStaticPadTemplate imgsrc_template =
-GST_STATIC_PAD_TEMPLATE (GST_BASE_CAMERA_SRC_IMAGE_PAD_NAME,
-    GST_PAD_SRC,
-    GST_PAD_ALWAYS,
-    GST_STATIC_CAPS_ANY);
-
-static GstStaticPadTemplate vidsrc_template =
-GST_STATIC_PAD_TEMPLATE (GST_BASE_CAMERA_SRC_VIDEO_PAD_NAME,
-    GST_PAD_SRC,
-    GST_PAD_ALWAYS,
-    GST_STATIC_CAPS_ANY);
 
 /* NOTE: we could provide a vmethod for derived class to overload to provide
  * it's own implementation of interface..  but in all cases I can think of at
@@ -530,15 +534,6 @@ gst_base_camera_src_class_init (GstBaseCameraSrcClass * klass)
   gst_element_class_set_details_simple (gstelement_class,
       "Base class for camerabin src bin", "Source/Video",
       "Abstracts capture device for camerabin2", "Rob Clark <rob@ti.com>");
-
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&vfsrc_template));
-
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&imgsrc_template));
-
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&vidsrc_template));
 }
 
 static void
index b69a088..189d668 100644 (file)
@@ -54,6 +54,24 @@ GST_DEBUG_CATEGORY (wrapper_camera_bin_src_debug);
 G_DEFINE_TYPE (GstWrapperCameraBinSrc, gst_wrapper_camera_bin_src,
     GST_TYPE_BASE_CAMERA_SRC);
 
+static GstStaticPadTemplate vfsrc_template =
+GST_STATIC_PAD_TEMPLATE (GST_BASE_CAMERA_SRC_VIEWFINDER_PAD_NAME,
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS_ANY);
+
+static GstStaticPadTemplate imgsrc_template =
+GST_STATIC_PAD_TEMPLATE (GST_BASE_CAMERA_SRC_IMAGE_PAD_NAME,
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS_ANY);
+
+static GstStaticPadTemplate vidsrc_template =
+GST_STATIC_PAD_TEMPLATE (GST_BASE_CAMERA_SRC_VIDEO_PAD_NAME,
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS_ANY);
+
 static void set_capsfilter_caps (GstWrapperCameraBinSrc * self,
     GstCaps * new_caps);
 
@@ -1126,6 +1144,15 @@ gst_wrapper_camera_bin_src_class_init (GstWrapperCameraBinSrcClass * klass)
   GST_DEBUG_CATEGORY_INIT (wrapper_camera_bin_src_debug, "wrappercamerabinsrc",
       0, "wrapper camera src");
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&vfsrc_template));
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&imgsrc_template));
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&vidsrc_template));
+
   gst_element_class_set_details_simple (gstelement_class,
       "Wrapper camera src element for camerabin2", "Source/Video",
       "Wrapper camera src element for camerabin2",