mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
basecamerasrc: Remove ghostpads
Remove ghost pads from basecamerasrc. Different implementations of camera sources might not use ghostpads and use default pads.
This commit is contained in:
parent
91d8bbd8a1
commit
b6d5763e05
4 changed files with 44 additions and 54 deletions
|
@ -50,17 +50,20 @@ GST_DEBUG_CATEGORY (base_camera_src_debug);
|
|||
|
||||
GST_BOILERPLATE (GstBaseCameraSrc, gst_base_camera_src, GstBin, GST_TYPE_BIN);
|
||||
|
||||
static GstStaticPadTemplate vfsrc_template = GST_STATIC_PAD_TEMPLATE ("vfsrc",
|
||||
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 ("imgsrc",
|
||||
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 ("vidsrc",
|
||||
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);
|
||||
|
@ -368,35 +371,14 @@ static gboolean
|
|||
construct_pipeline (GstBaseCameraSrc * self)
|
||||
{
|
||||
GstBaseCameraSrcClass *bclass = GST_BASE_CAMERA_SRC_GET_CLASS (self);
|
||||
GstPad *vfsrc = NULL;
|
||||
GstPad *imgsrc = NULL;
|
||||
GstPad *vidsrc = NULL;
|
||||
|
||||
g_return_val_if_fail (bclass->construct_pipeline, FALSE);
|
||||
|
||||
if (!bclass->construct_pipeline (self, &vfsrc, &imgsrc, &vidsrc)) {
|
||||
if (!bclass->construct_pipeline (self)) {
|
||||
GST_ERROR_OBJECT (self, "pipeline construction failed");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!vfsrc || !imgsrc || !vidsrc) {
|
||||
GST_ERROR_OBJECT (self, "derived class must return src pads");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (self, "vfsrc: %" GST_PTR_FORMAT, vfsrc);
|
||||
GST_DEBUG_OBJECT (self, "imgsrc: %" GST_PTR_FORMAT, imgsrc);
|
||||
GST_DEBUG_OBJECT (self, "vidsrc: %" GST_PTR_FORMAT, vidsrc);
|
||||
|
||||
/* hook-up the ghostpads */
|
||||
gst_ghost_pad_set_target (GST_GHOST_PAD (self->vfsrc), vfsrc);
|
||||
gst_ghost_pad_set_target (GST_GHOST_PAD (self->imgsrc), imgsrc);
|
||||
gst_ghost_pad_set_target (GST_GHOST_PAD (self->vidsrc), vidsrc);
|
||||
|
||||
gst_pad_set_active (self->vfsrc, TRUE);
|
||||
gst_pad_set_active (self->imgsrc, TRUE); /* XXX ??? */
|
||||
gst_pad_set_active (self->vidsrc, TRUE); /* XXX ??? */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -527,15 +509,6 @@ static void
|
|||
gst_base_camera_src_init (GstBaseCameraSrc * self,
|
||||
GstBaseCameraSrcClass * klass)
|
||||
{
|
||||
self->vfsrc = gst_ghost_pad_new_no_target ("vfsrc", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (self), self->vfsrc);
|
||||
|
||||
self->imgsrc = gst_ghost_pad_new_no_target ("imgsrc", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (self), self->imgsrc);
|
||||
|
||||
self->vidsrc = gst_ghost_pad_new_no_target ("vidsrc", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (self), self->vidsrc);
|
||||
|
||||
self->width = DEFAULT_WIDTH;
|
||||
self->height = DEFAULT_HEIGHT;
|
||||
self->zoom = DEFAULT_ZOOM;
|
||||
|
|
|
@ -48,6 +48,9 @@ GType gst_base_camera_src_get_type (void);
|
|||
typedef struct _GstBaseCameraSrc GstBaseCameraSrc;
|
||||
typedef struct _GstBaseCameraSrcClass GstBaseCameraSrcClass;
|
||||
|
||||
#define GST_BASE_CAMERA_SRC_VIEWFINDER_PAD_NAME "vfsrc"
|
||||
#define GST_BASE_CAMERA_SRC_IMAGE_PAD_NAME "imgsrc"
|
||||
#define GST_BASE_CAMERA_SRC_VIDEO_PAD_NAME "vidsrc"
|
||||
|
||||
/**
|
||||
* GstBaseCameraSrc:
|
||||
|
@ -56,10 +59,6 @@ struct _GstBaseCameraSrc
|
|||
{
|
||||
GstBin parent;
|
||||
|
||||
GstPad *vfsrc;
|
||||
GstPad *imgsrc;
|
||||
GstPad *vidsrc;
|
||||
|
||||
gint mode;
|
||||
|
||||
gboolean capturing;
|
||||
|
@ -105,13 +104,8 @@ struct _GstBaseCameraSrcClass
|
|||
{
|
||||
GstBinClass parent;
|
||||
|
||||
/* construct pipeline must be implemented by derived class, and return by
|
||||
* reference vfsrc, imgsrc, and vidsrc pads of the contained pipeline, which
|
||||
* will be ghosted to the src pads of the camerasrc bin (and optionally the
|
||||
* preview src pads?) */
|
||||
gboolean (*construct_pipeline) (GstBaseCameraSrc *self,
|
||||
GstPad **vfsrc, GstPad **imgsrc,
|
||||
GstPad **vidsrc);
|
||||
/* construct pipeline must be implemented by derived class */
|
||||
gboolean (*construct_pipeline) (GstBaseCameraSrc *self);
|
||||
|
||||
/* optional */
|
||||
gboolean (*setup_pipeline) (GstBaseCameraSrc *self);
|
||||
|
@ -131,7 +125,6 @@ struct _GstBaseCameraSrcClass
|
|||
gboolean (*start_capture) (GstBaseCameraSrc * src);
|
||||
void (*stop_capture) (GstBaseCameraSrc * src);
|
||||
|
||||
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE];
|
||||
};
|
||||
|
||||
|
|
|
@ -199,9 +199,6 @@ gst_v4l2_camera_src_vidsrc_probe (GstPad * pad, GstBuffer * buffer,
|
|||
/**
|
||||
* gst_v4l2_camera_src_construct_pipeline:
|
||||
* @bcamsrc: camerasrc object
|
||||
* @vfsrc: viewfinder src element (returned by reference)
|
||||
* @imgsrc: image src element (returned by reference)
|
||||
* @vidsrc: video src element (returned by reference)
|
||||
*
|
||||
* This function creates and links the elements of the camerasrc bin
|
||||
* videosrc ! cspconv ! capsfilter ! crop ! scale ! capsfilter ! tee ! ..
|
||||
|
@ -209,8 +206,7 @@ gst_v4l2_camera_src_vidsrc_probe (GstPad * pad, GstBuffer * buffer,
|
|||
* Returns: TRUE, if elements were successfully created, FALSE otherwise
|
||||
*/
|
||||
static gboolean
|
||||
gst_v4l2_camera_src_construct_pipeline (GstBaseCameraSrc * bcamsrc,
|
||||
GstPad ** vfsrc, GstPad ** imgsrc, GstPad ** vidsrc)
|
||||
gst_v4l2_camera_src_construct_pipeline (GstBaseCameraSrc * bcamsrc)
|
||||
{
|
||||
GstV4l2CameraSrc *self = GST_V4L2_CAMERA_SRC (bcamsrc);
|
||||
GstBin *cbin = GST_BIN (bcamsrc);
|
||||
|
@ -265,9 +261,17 @@ gst_v4l2_camera_src_construct_pipeline (GstBaseCameraSrc * bcamsrc,
|
|||
gst_pad_add_buffer_probe (self->tee_video_srcpad,
|
||||
G_CALLBACK (gst_v4l2_camera_src_vidsrc_probe), self);
|
||||
|
||||
*vfsrc = self->tee_vf_srcpad;
|
||||
*imgsrc = self->tee_image_srcpad;
|
||||
*vidsrc = self->tee_video_srcpad;
|
||||
/* hook-up the ghostpads */
|
||||
gst_ghost_pad_set_target (GST_GHOST_PAD (self->vfsrc), self->tee_vf_srcpad);
|
||||
gst_ghost_pad_set_target (GST_GHOST_PAD (self->imgsrc),
|
||||
self->tee_image_srcpad);
|
||||
gst_ghost_pad_set_target (GST_GHOST_PAD (self->vidsrc),
|
||||
self->tee_video_srcpad);
|
||||
|
||||
gst_pad_set_active (self->vfsrc, TRUE);
|
||||
gst_pad_set_active (self->imgsrc, TRUE); /* XXX ??? */
|
||||
gst_pad_set_active (self->vidsrc, TRUE); /* XXX ??? */
|
||||
|
||||
|
||||
ret = TRUE;
|
||||
done:
|
||||
|
@ -1036,6 +1040,22 @@ static void
|
|||
gst_v4l2_camera_src_init (GstV4l2CameraSrc * self,
|
||||
GstV4l2CameraSrcClass * klass)
|
||||
{
|
||||
self->vfsrc =
|
||||
gst_ghost_pad_new_no_target (GST_BASE_CAMERA_SRC_VIEWFINDER_PAD_NAME,
|
||||
GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (self), self->vfsrc);
|
||||
|
||||
self->imgsrc =
|
||||
gst_ghost_pad_new_no_target (GST_BASE_CAMERA_SRC_IMAGE_PAD_NAME,
|
||||
GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (self), self->imgsrc);
|
||||
|
||||
self->vidsrc =
|
||||
gst_ghost_pad_new_no_target (GST_BASE_CAMERA_SRC_VIDEO_PAD_NAME,
|
||||
GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (self), self->vidsrc);
|
||||
|
||||
|
||||
/* TODO where are variables reset? */
|
||||
self->image_capture_count = 0;
|
||||
self->video_rec_status = GST_VIDEO_RECORDING_STATUS_DONE;
|
||||
|
|
|
@ -57,6 +57,10 @@ struct _GstV4l2CameraSrc
|
|||
{
|
||||
GstBaseCameraSrc parent;
|
||||
|
||||
GstPad *vfsrc;
|
||||
GstPad *imgsrc;
|
||||
GstPad *vidsrc;
|
||||
|
||||
/* video recording controls */
|
||||
gint video_rec_status;
|
||||
|
||||
|
|
Loading…
Reference in a new issue