basecamerabin: Do not set the pad templates in the base class.

It is best to let the subclass define the pad templates, this would
allow the subclass to decide which caps the pads should have.
This commit is contained in:
Youness Alaoui 2012-05-03 19:11:57 -04:00 committed by Thiago Santos
parent 99b6f14486
commit d3303121c8
2 changed files with 50 additions and 28 deletions

View file

@ -23,7 +23,7 @@
/** /**
* SECTION:element-basecamerasrc * 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 * Sophisticated camera hardware can derive from this baseclass and map the
* features to this interface. * features to this interface.
* *
@ -40,11 +40,32 @@
* During construct_pipeline() vmethod a subclass can add several elements into * 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. * 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,
* &vidsrc_template);
* gst_element_class_add_static_pad_template (gstelement_class,
* &imgsrc_template);
* gst_element_class_add_static_pad_template (gstelement_class,
* &vfsrc_template);
* // see #GstElementDetails
* gst_element_class_set_details (gstelement_class, &details);
* }
* ]|
*
* It is also possible to add regular pads from the subclass and implement the * 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 * dataflow methods on these pads. This way all functionality can be implemneted
* directly in the subclass without extra elements. * 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 * #GstBaseCameraSrc:mode property. Possible capture modes are defined in
* #GstCameraBinMode. * #GstCameraBinMode.
*/ */
@ -88,23 +109,6 @@ GST_DEBUG_CATEGORY (base_camera_src_debug);
#define parent_class gst_base_camera_src_parent_class #define parent_class gst_base_camera_src_parent_class
G_DEFINE_TYPE (GstBaseCameraSrc, gst_base_camera_src, GST_TYPE_BIN); 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 /* 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 * 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, gst_element_class_set_details_simple (gstelement_class,
"Base class for camerabin src bin", "Source/Video", "Base class for camerabin src bin", "Source/Video",
"Abstracts capture device for camerabin2", "Rob Clark <rob@ti.com>"); "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 static void

View file

@ -54,6 +54,24 @@ GST_DEBUG_CATEGORY (wrapper_camera_bin_src_debug);
G_DEFINE_TYPE (GstWrapperCameraBinSrc, gst_wrapper_camera_bin_src, G_DEFINE_TYPE (GstWrapperCameraBinSrc, gst_wrapper_camera_bin_src,
GST_TYPE_BASE_CAMERA_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, static void set_capsfilter_caps (GstWrapperCameraBinSrc * self,
GstCaps * new_caps); 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", GST_DEBUG_CATEGORY_INIT (wrapper_camera_bin_src_debug, "wrappercamerabinsrc",
0, "wrapper camera src"); 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, gst_element_class_set_details_simple (gstelement_class,
"Wrapper camera src element for camerabin2", "Source/Video", "Wrapper camera src element for camerabin2", "Source/Video",
"Wrapper camera src element for camerabin2", "Wrapper camera src element for camerabin2",